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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 DecoderDatabase db(factory); | 74 DecoderDatabase db(factory); |
75 const uint8_t kPayloadType = 0; | 75 const uint8_t kPayloadType = 0; |
76 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; | 76 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; |
77 EXPECT_EQ( | 77 EXPECT_EQ( |
78 DecoderDatabase::kOK, | 78 DecoderDatabase::kOK, |
79 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); | 79 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); |
80 const DecoderDatabase::DecoderInfo* info; | 80 const DecoderDatabase::DecoderInfo* info; |
81 info = db.GetDecoderInfo(kPayloadType); | 81 info = db.GetDecoderInfo(kPayloadType); |
82 ASSERT_TRUE(info != NULL); | 82 ASSERT_TRUE(info != NULL); |
83 EXPECT_TRUE(info->IsType("pcmu")); | 83 EXPECT_TRUE(info->IsType("pcmu")); |
84 EXPECT_EQ(kCodecName, info->name); | 84 EXPECT_EQ(kCodecName, info->get_name()); |
85 EXPECT_EQ(decoder, db.GetDecoder(kPayloadType)); | 85 EXPECT_EQ(decoder, db.GetDecoder(kPayloadType)); |
86 info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. | 86 info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. |
87 EXPECT_TRUE(info == NULL); // Should not be found. | 87 EXPECT_TRUE(info == NULL); // Should not be found. |
88 } | 88 } |
89 | 89 |
90 TEST(DecoderDatabase, GetDecoder) { | 90 TEST(DecoderDatabase, GetDecoder) { |
91 DecoderDatabase db(CreateBuiltinAudioDecoderFactory()); | 91 DecoderDatabase db(CreateBuiltinAudioDecoderFactory()); |
92 const uint8_t kPayloadType = 0; | 92 const uint8_t kPayloadType = 0; |
93 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; | 93 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; |
94 EXPECT_EQ(DecoderDatabase::kOK, | 94 EXPECT_EQ(DecoderDatabase::kOK, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 db.InsertExternal(kPayloadType, NetEqDecoder::kDecoderPCMu, | 143 db.InsertExternal(kPayloadType, NetEqDecoder::kDecoderPCMu, |
144 kCodecName, &decoder)); | 144 kCodecName, &decoder)); |
145 EXPECT_EQ(1, db.Size()); | 145 EXPECT_EQ(1, db.Size()); |
146 // Get decoder and make sure we get the external one. | 146 // Get decoder and make sure we get the external one. |
147 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType)); | 147 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType)); |
148 // Get the decoder info struct and check it too. | 148 // Get the decoder info struct and check it too. |
149 const DecoderDatabase::DecoderInfo* info; | 149 const DecoderDatabase::DecoderInfo* info; |
150 info = db.GetDecoderInfo(kPayloadType); | 150 info = db.GetDecoderInfo(kPayloadType); |
151 ASSERT_TRUE(info != NULL); | 151 ASSERT_TRUE(info != NULL); |
152 EXPECT_TRUE(info->IsType("pcmu")); | 152 EXPECT_TRUE(info->IsType("pcmu")); |
153 EXPECT_EQ(info->name, kCodecName); | 153 EXPECT_EQ(info->get_name(), kCodecName); |
154 EXPECT_EQ(kCodecName, info->name); | 154 EXPECT_EQ(kCodecName, info->get_name()); |
155 // Expect not to delete the decoder when removing it from the database, since | 155 // Expect not to delete the decoder when removing it from the database, since |
156 // it was declared externally. | 156 // it was declared externally. |
157 EXPECT_CALL(decoder, Die()).Times(0); | 157 EXPECT_CALL(decoder, Die()).Times(0); |
158 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); | 158 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); |
159 EXPECT_TRUE(db.Empty()); | 159 EXPECT_TRUE(db.Empty()); |
160 | 160 |
161 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted. | 161 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted. |
162 } | 162 } |
163 | 163 |
164 TEST(DecoderDatabase, CheckPayloadTypes) { | 164 TEST(DecoderDatabase, CheckPayloadTypes) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); | 247 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); |
248 EXPECT_EQ(NULL, db.GetActiveCngDecoder()); | 248 EXPECT_EQ(NULL, db.GetActiveCngDecoder()); |
249 | 249 |
250 // Try to set non-existing codecs as active. | 250 // Try to set non-existing codecs as active. |
251 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, | 251 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, |
252 db.SetActiveDecoder(17, &changed)); | 252 db.SetActiveDecoder(17, &changed)); |
253 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, | 253 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, |
254 db.SetActiveCngDecoder(17)); | 254 db.SetActiveCngDecoder(17)); |
255 } | 255 } |
256 } // namespace webrtc | 256 } // namespace webrtc |
OLD | NEW |