OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 }; | 167 }; |
168 | 168 |
169 #if defined(WEBRTC_ANDROID) | 169 #if defined(WEBRTC_ANDROID) |
170 #define MAYBE_AddCodecGetCodec DISABLED_AddCodecGetCodec | 170 #define MAYBE_AddCodecGetCodec DISABLED_AddCodecGetCodec |
171 #else | 171 #else |
172 #define MAYBE_AddCodecGetCodec AddCodecGetCodec | 172 #define MAYBE_AddCodecGetCodec AddCodecGetCodec |
173 #endif | 173 #endif |
174 TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecGetCodec) { | 174 TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecGetCodec) { |
175 // Add codec. | 175 // Add codec. |
176 for (size_t n = 0; n < codecs_.size(); ++n) { | 176 for (size_t n = 0; n < codecs_.size(); ++n) { |
177 if (n & 0x1) { // Just add codecs with odd index. | 177 if (n & 0x1) // Just add codecs with odd index. |
178 EXPECT_EQ( | 178 EXPECT_EQ(0, |
179 0, receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels, | 179 receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels, |
180 codecs_[n].plfreq, NULL, codecs_[n].plname)); | 180 codecs_[n].plfreq, NULL, "")); |
181 } | |
182 } | 181 } |
183 // Get codec and compare. | 182 // Get codec and compare. |
184 for (size_t n = 0; n < codecs_.size(); ++n) { | 183 for (size_t n = 0; n < codecs_.size(); ++n) { |
185 CodecInst my_codec; | 184 CodecInst my_codec; |
186 if (n & 0x1) { | 185 if (n & 0x1) { |
187 // Codecs with odd index should match the reference. | 186 // Codecs with odd index should match the reference. |
188 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codecs_[n].pltype, | 187 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codecs_[n].pltype, |
189 &my_codec)); | 188 &my_codec)); |
190 EXPECT_TRUE(CodecsEqual(codecs_[n], my_codec)); | 189 EXPECT_TRUE(CodecsEqual(codecs_[n], my_codec)); |
191 } else { | 190 } else { |
(...skipping 11 matching lines...) Expand all Loading... |
203 #endif | 202 #endif |
204 TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecChangePayloadType) { | 203 TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecChangePayloadType) { |
205 const CodecIdInst codec1(RentACodec::CodecId::kPCMA); | 204 const CodecIdInst codec1(RentACodec::CodecId::kPCMA); |
206 CodecInst codec2 = codec1.inst; | 205 CodecInst codec2 = codec1.inst; |
207 ++codec2.pltype; | 206 ++codec2.pltype; |
208 CodecInst test_codec; | 207 CodecInst test_codec; |
209 | 208 |
210 // Register the same codec with different payloads. | 209 // Register the same codec with different payloads. |
211 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, | 210 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, |
212 codec1.inst.channels, codec1.inst.plfreq, | 211 codec1.inst.channels, codec1.inst.plfreq, |
213 nullptr, codec1.inst.plname)); | 212 nullptr, "")); |
214 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec2.pltype, codec2.channels, | 213 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec2.pltype, codec2.channels, |
215 codec2.plfreq, NULL, codec2.plname)); | 214 codec2.plfreq, NULL, "")); |
216 | 215 |
217 // Both payload types should exist. | 216 // Both payload types should exist. |
218 EXPECT_EQ(0, | 217 EXPECT_EQ(0, |
219 receiver_->DecoderByPayloadType(codec1.inst.pltype, &test_codec)); | 218 receiver_->DecoderByPayloadType(codec1.inst.pltype, &test_codec)); |
220 EXPECT_EQ(true, CodecsEqual(codec1.inst, test_codec)); | 219 EXPECT_EQ(true, CodecsEqual(codec1.inst, test_codec)); |
221 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codec2.pltype, &test_codec)); | 220 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codec2.pltype, &test_codec)); |
222 EXPECT_EQ(true, CodecsEqual(codec2, test_codec)); | 221 EXPECT_EQ(true, CodecsEqual(codec2, test_codec)); |
223 } | 222 } |
224 | 223 |
225 #if defined(WEBRTC_ANDROID) | 224 #if defined(WEBRTC_ANDROID) |
226 #define MAYBE_AddCodecChangeCodecId DISABLED_AddCodecChangeCodecId | 225 #define MAYBE_AddCodecChangeCodecId DISABLED_AddCodecChangeCodecId |
227 #else | 226 #else |
228 #define MAYBE_AddCodecChangeCodecId AddCodecChangeCodecId | 227 #define MAYBE_AddCodecChangeCodecId AddCodecChangeCodecId |
229 #endif | 228 #endif |
230 TEST_F(AcmReceiverTestOldApi, AddCodecChangeCodecId) { | 229 TEST_F(AcmReceiverTestOldApi, AddCodecChangeCodecId) { |
231 const CodecIdInst codec1(RentACodec::CodecId::kPCMU); | 230 const CodecIdInst codec1(RentACodec::CodecId::kPCMU); |
232 CodecIdInst codec2(RentACodec::CodecId::kPCMA); | 231 CodecIdInst codec2(RentACodec::CodecId::kPCMA); |
233 codec2.inst.pltype = codec1.inst.pltype; | 232 codec2.inst.pltype = codec1.inst.pltype; |
234 CodecInst test_codec; | 233 CodecInst test_codec; |
235 | 234 |
236 // Register the same payload type with different codec ID. | 235 // Register the same payload type with different codec ID. |
237 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, | 236 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, |
238 codec1.inst.channels, codec1.inst.plfreq, | 237 codec1.inst.channels, codec1.inst.plfreq, |
239 nullptr, codec1.inst.plname)); | 238 nullptr, "")); |
240 EXPECT_EQ(0, receiver_->AddCodec(codec2.id, codec2.inst.pltype, | 239 EXPECT_EQ(0, receiver_->AddCodec(codec2.id, codec2.inst.pltype, |
241 codec2.inst.channels, codec2.inst.plfreq, | 240 codec2.inst.channels, codec2.inst.plfreq, |
242 nullptr, codec2.inst.plname)); | 241 nullptr, "")); |
243 | 242 |
244 // Make sure that the last codec is used. | 243 // Make sure that the last codec is used. |
245 EXPECT_EQ(0, | 244 EXPECT_EQ(0, |
246 receiver_->DecoderByPayloadType(codec2.inst.pltype, &test_codec)); | 245 receiver_->DecoderByPayloadType(codec2.inst.pltype, &test_codec)); |
247 EXPECT_EQ(true, CodecsEqual(codec2.inst, test_codec)); | 246 EXPECT_EQ(true, CodecsEqual(codec2.inst, test_codec)); |
248 } | 247 } |
249 | 248 |
250 #if defined(WEBRTC_ANDROID) | 249 #if defined(WEBRTC_ANDROID) |
251 #define MAYBE_AddCodecRemoveCodec DISABLED_AddCodecRemoveCodec | 250 #define MAYBE_AddCodecRemoveCodec DISABLED_AddCodecRemoveCodec |
252 #else | 251 #else |
253 #define MAYBE_AddCodecRemoveCodec AddCodecRemoveCodec | 252 #define MAYBE_AddCodecRemoveCodec AddCodecRemoveCodec |
254 #endif | 253 #endif |
255 TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecRemoveCodec) { | 254 TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecRemoveCodec) { |
256 const CodecIdInst codec(RentACodec::CodecId::kPCMA); | 255 const CodecIdInst codec(RentACodec::CodecId::kPCMA); |
257 const int payload_type = codec.inst.pltype; | 256 const int payload_type = codec.inst.pltype; |
258 EXPECT_EQ( | 257 EXPECT_EQ( |
259 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, | 258 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, |
260 codec.inst.plfreq, nullptr, codec.inst.plname)); | 259 codec.inst.plfreq, nullptr, "")); |
261 | 260 |
262 // Remove non-existing codec should not fail. ACM1 legacy. | 261 // Remove non-existing codec should not fail. ACM1 legacy. |
263 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type + 1)); | 262 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type + 1)); |
264 | 263 |
265 // Remove an existing codec. | 264 // Remove an existing codec. |
266 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type)); | 265 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type)); |
267 | 266 |
268 // Ask for the removed codec, must fail. | 267 // Ask for the removed codec, must fail. |
269 CodecInst ci; | 268 CodecInst ci; |
270 EXPECT_EQ(-1, receiver_->DecoderByPayloadType(payload_type, &ci)); | 269 EXPECT_EQ(-1, receiver_->DecoderByPayloadType(payload_type, &ci)); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 receiver_->last_packet_sample_rate_hz()); | 499 receiver_->last_packet_sample_rate_hz()); |
501 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); | 500 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); |
502 EXPECT_TRUE(CodecsEqual(c.inst, codec)); | 501 EXPECT_TRUE(CodecsEqual(c.inst, codec)); |
503 } | 502 } |
504 } | 503 } |
505 #endif | 504 #endif |
506 | 505 |
507 } // namespace acm2 | 506 } // namespace acm2 |
508 | 507 |
509 } // namespace webrtc | 508 } // namespace webrtc |
OLD | NEW |