OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 DecoderDatabase db; | 46 DecoderDatabase db; |
47 const uint8_t kPayloadType = 0; | 47 const uint8_t kPayloadType = 0; |
48 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; | 48 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; |
49 EXPECT_EQ( | 49 EXPECT_EQ( |
50 DecoderDatabase::kOK, | 50 DecoderDatabase::kOK, |
51 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); | 51 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); |
52 const DecoderDatabase::DecoderInfo* info; | 52 const DecoderDatabase::DecoderInfo* info; |
53 info = db.GetDecoderInfo(kPayloadType); | 53 info = db.GetDecoderInfo(kPayloadType); |
54 ASSERT_TRUE(info != NULL); | 54 ASSERT_TRUE(info != NULL); |
55 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); | 55 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); |
56 EXPECT_EQ(NULL, info->decoder); | 56 EXPECT_EQ(nullptr, info->external_decoder); |
57 EXPECT_EQ(8000, info->fs_hz); | 57 EXPECT_EQ(8000, info->fs_hz); |
58 EXPECT_EQ(kCodecName, info->name); | 58 EXPECT_EQ(kCodecName, info->name); |
59 EXPECT_FALSE(info->external); | |
60 info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. | 59 info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. |
61 EXPECT_TRUE(info == NULL); // Should not be found. | 60 EXPECT_TRUE(info == NULL); // Should not be found. |
62 } | 61 } |
63 | 62 |
64 TEST(DecoderDatabase, GetRtpPayloadType) { | 63 TEST(DecoderDatabase, GetRtpPayloadType) { |
65 DecoderDatabase db; | 64 DecoderDatabase db; |
66 const uint8_t kPayloadType = 0; | 65 const uint8_t kPayloadType = 0; |
67 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; | 66 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; |
68 EXPECT_EQ( | 67 EXPECT_EQ( |
69 DecoderDatabase::kOK, | 68 DecoderDatabase::kOK, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 kCodecName, 8000, &decoder)); | 131 kCodecName, 8000, &decoder)); |
133 EXPECT_EQ(1, db.Size()); | 132 EXPECT_EQ(1, db.Size()); |
134 // Get decoder and make sure we get the external one. | 133 // Get decoder and make sure we get the external one. |
135 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType)); | 134 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType)); |
136 // Get the decoder info struct and check it too. | 135 // Get the decoder info struct and check it too. |
137 const DecoderDatabase::DecoderInfo* info; | 136 const DecoderDatabase::DecoderInfo* info; |
138 info = db.GetDecoderInfo(kPayloadType); | 137 info = db.GetDecoderInfo(kPayloadType); |
139 ASSERT_TRUE(info != NULL); | 138 ASSERT_TRUE(info != NULL); |
140 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); | 139 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); |
141 EXPECT_EQ(kCodecName, info->name); | 140 EXPECT_EQ(kCodecName, info->name); |
142 EXPECT_EQ(&decoder, info->decoder); | 141 EXPECT_EQ(&decoder, info->external_decoder); |
143 EXPECT_EQ(8000, info->fs_hz); | 142 EXPECT_EQ(8000, info->fs_hz); |
144 EXPECT_TRUE(info->external); | |
145 // Expect not to delete the decoder when removing it from the database, since | 143 // Expect not to delete the decoder when removing it from the database, since |
146 // it was declared externally. | 144 // it was declared externally. |
147 EXPECT_CALL(decoder, Die()).Times(0); | 145 EXPECT_CALL(decoder, Die()).Times(0); |
148 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); | 146 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); |
149 EXPECT_TRUE(db.Empty()); | 147 EXPECT_TRUE(db.Empty()); |
150 | 148 |
151 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted. | 149 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted. |
152 } | 150 } |
153 | 151 |
154 TEST(DecoderDatabase, CheckPayloadTypes) { | 152 TEST(DecoderDatabase, CheckPayloadTypes) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); | 238 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); |
241 EXPECT_EQ(NULL, db.GetActiveCngDecoder()); | 239 EXPECT_EQ(NULL, db.GetActiveCngDecoder()); |
242 | 240 |
243 // Try to set non-existing codecs as active. | 241 // Try to set non-existing codecs as active. |
244 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, | 242 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, |
245 db.SetActiveDecoder(17, &changed)); | 243 db.SetActiveDecoder(17, &changed)); |
246 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, | 244 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, |
247 db.SetActiveCngDecoder(17)); | 245 db.SetActiveCngDecoder(17)); |
248 } | 246 } |
249 } // namespace webrtc | 247 } // namespace webrtc |
OLD | NEW |