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