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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 template <size_t N> | 116 template <size_t N> |
117 void AddSetOfCodecs(const RentACodec::CodecId(&ids)[N]) { | 117 void AddSetOfCodecs(const RentACodec::CodecId(&ids)[N]) { |
118 for (auto id : ids) { | 118 for (auto id : ids) { |
119 const auto i = RentACodec::CodecIndexFromId(id); | 119 const auto i = RentACodec::CodecIndexFromId(id); |
120 ASSERT_TRUE(i); | 120 ASSERT_TRUE(i); |
121 ASSERT_EQ( | 121 ASSERT_EQ( |
122 0, receiver_->AddCodec(*i, codecs_[*i].pltype, codecs_[*i].channels, | 122 0, receiver_->AddCodec(*i, codecs_[*i].pltype, codecs_[*i].channels, |
123 codecs_[*i].plfreq, nullptr)); | 123 codecs_[*i].plfreq, nullptr, "")); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 int SendData(FrameType frame_type, | 127 int SendData(FrameType frame_type, |
128 uint8_t payload_type, | 128 uint8_t payload_type, |
129 uint32_t timestamp, | 129 uint32_t timestamp, |
130 const uint8_t* payload_data, | 130 const uint8_t* payload_data, |
131 size_t payload_len_bytes, | 131 size_t payload_len_bytes, |
132 const RTPFragmentationHeader* fragmentation) override { | 132 const RTPFragmentationHeader* fragmentation) override { |
133 if (frame_type == kEmptyFrame) | 133 if (frame_type == kEmptyFrame) |
(...skipping 29 matching lines...) Expand all Loading... |
163 uint32_t last_packet_send_timestamp_; | 163 uint32_t last_packet_send_timestamp_; |
164 FrameType last_frame_type_; | 164 FrameType last_frame_type_; |
165 }; | 165 }; |
166 | 166 |
167 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecGetCodec)) { | 167 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecGetCodec)) { |
168 // Add codec. | 168 // Add codec. |
169 for (size_t n = 0; n < codecs_.size(); ++n) { | 169 for (size_t n = 0; n < codecs_.size(); ++n) { |
170 if (n & 0x1) // Just add codecs with odd index. | 170 if (n & 0x1) // Just add codecs with odd index. |
171 EXPECT_EQ(0, | 171 EXPECT_EQ(0, |
172 receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels, | 172 receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels, |
173 codecs_[n].plfreq, NULL)); | 173 codecs_[n].plfreq, NULL, "")); |
174 } | 174 } |
175 // Get codec and compare. | 175 // Get codec and compare. |
176 for (size_t n = 0; n < codecs_.size(); ++n) { | 176 for (size_t n = 0; n < codecs_.size(); ++n) { |
177 CodecInst my_codec; | 177 CodecInst my_codec; |
178 if (n & 0x1) { | 178 if (n & 0x1) { |
179 // Codecs with odd index should match the reference. | 179 // Codecs with odd index should match the reference. |
180 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codecs_[n].pltype, | 180 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codecs_[n].pltype, |
181 &my_codec)); | 181 &my_codec)); |
182 EXPECT_TRUE(CodecsEqual(codecs_[n], my_codec)); | 182 EXPECT_TRUE(CodecsEqual(codecs_[n], my_codec)); |
183 } else { | 183 } else { |
184 // Codecs with even index are not registered. | 184 // Codecs with even index are not registered. |
185 EXPECT_EQ(-1, receiver_->DecoderByPayloadType(codecs_[n].pltype, | 185 EXPECT_EQ(-1, receiver_->DecoderByPayloadType(codecs_[n].pltype, |
186 &my_codec)); | 186 &my_codec)); |
187 } | 187 } |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecChangePayloadType)) { | 191 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecChangePayloadType)) { |
192 const CodecIdInst codec1(RentACodec::CodecId::kPCMA); | 192 const CodecIdInst codec1(RentACodec::CodecId::kPCMA); |
193 CodecInst codec2 = codec1.inst; | 193 CodecInst codec2 = codec1.inst; |
194 ++codec2.pltype; | 194 ++codec2.pltype; |
195 CodecInst test_codec; | 195 CodecInst test_codec; |
196 | 196 |
197 // Register the same codec with different payloads. | 197 // Register the same codec with different payloads. |
198 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, | 198 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, |
199 codec1.inst.channels, codec1.inst.plfreq, | 199 codec1.inst.channels, codec1.inst.plfreq, |
200 nullptr)); | 200 nullptr, "")); |
201 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec2.pltype, codec2.channels, | 201 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec2.pltype, codec2.channels, |
202 codec2.plfreq, NULL)); | 202 codec2.plfreq, NULL, "")); |
203 | 203 |
204 // Both payload types should exist. | 204 // Both payload types should exist. |
205 EXPECT_EQ(0, | 205 EXPECT_EQ(0, |
206 receiver_->DecoderByPayloadType(codec1.inst.pltype, &test_codec)); | 206 receiver_->DecoderByPayloadType(codec1.inst.pltype, &test_codec)); |
207 EXPECT_EQ(true, CodecsEqual(codec1.inst, test_codec)); | 207 EXPECT_EQ(true, CodecsEqual(codec1.inst, test_codec)); |
208 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codec2.pltype, &test_codec)); | 208 EXPECT_EQ(0, receiver_->DecoderByPayloadType(codec2.pltype, &test_codec)); |
209 EXPECT_EQ(true, CodecsEqual(codec2, test_codec)); | 209 EXPECT_EQ(true, CodecsEqual(codec2, test_codec)); |
210 } | 210 } |
211 | 211 |
212 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecChangeCodecId)) { | 212 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecChangeCodecId)) { |
213 const CodecIdInst codec1(RentACodec::CodecId::kPCMU); | 213 const CodecIdInst codec1(RentACodec::CodecId::kPCMU); |
214 CodecIdInst codec2(RentACodec::CodecId::kPCMA); | 214 CodecIdInst codec2(RentACodec::CodecId::kPCMA); |
215 codec2.inst.pltype = codec1.inst.pltype; | 215 codec2.inst.pltype = codec1.inst.pltype; |
216 CodecInst test_codec; | 216 CodecInst test_codec; |
217 | 217 |
218 // Register the same payload type with different codec ID. | 218 // Register the same payload type with different codec ID. |
219 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, | 219 EXPECT_EQ(0, receiver_->AddCodec(codec1.id, codec1.inst.pltype, |
220 codec1.inst.channels, codec1.inst.plfreq, | 220 codec1.inst.channels, codec1.inst.plfreq, |
221 nullptr)); | 221 nullptr, "")); |
222 EXPECT_EQ(0, receiver_->AddCodec(codec2.id, codec2.inst.pltype, | 222 EXPECT_EQ(0, receiver_->AddCodec(codec2.id, codec2.inst.pltype, |
223 codec2.inst.channels, codec2.inst.plfreq, | 223 codec2.inst.channels, codec2.inst.plfreq, |
224 nullptr)); | 224 nullptr, "")); |
225 | 225 |
226 // Make sure that the last codec is used. | 226 // Make sure that the last codec is used. |
227 EXPECT_EQ(0, | 227 EXPECT_EQ(0, |
228 receiver_->DecoderByPayloadType(codec2.inst.pltype, &test_codec)); | 228 receiver_->DecoderByPayloadType(codec2.inst.pltype, &test_codec)); |
229 EXPECT_EQ(true, CodecsEqual(codec2.inst, test_codec)); | 229 EXPECT_EQ(true, CodecsEqual(codec2.inst, test_codec)); |
230 } | 230 } |
231 | 231 |
232 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecRemoveCodec)) { | 232 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(AddCodecRemoveCodec)) { |
233 const CodecIdInst codec(RentACodec::CodecId::kPCMA); | 233 const CodecIdInst codec(RentACodec::CodecId::kPCMA); |
234 const int payload_type = codec.inst.pltype; | 234 const int payload_type = codec.inst.pltype; |
235 EXPECT_EQ( | 235 EXPECT_EQ( |
236 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, | 236 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, |
237 codec.inst.plfreq, nullptr)); | 237 codec.inst.plfreq, nullptr, "")); |
238 | 238 |
239 // Remove non-existing codec should not fail. ACM1 legacy. | 239 // Remove non-existing codec should not fail. ACM1 legacy. |
240 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type + 1)); | 240 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type + 1)); |
241 | 241 |
242 // Remove an existing codec. | 242 // Remove an existing codec. |
243 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type)); | 243 EXPECT_EQ(0, receiver_->RemoveCodec(payload_type)); |
244 | 244 |
245 // Ask for the removed codec, must fail. | 245 // Ask for the removed codec, must fail. |
246 CodecInst ci; | 246 CodecInst ci; |
247 EXPECT_EQ(-1, receiver_->DecoderByPayloadType(payload_type, &ci)); | 247 EXPECT_EQ(-1, receiver_->DecoderByPayloadType(payload_type, &ci)); |
(...skipping 16 matching lines...) Expand all Loading... |
264 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz()); | 264 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz()); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(PostdecodingVad)) { | 268 TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(PostdecodingVad)) { |
269 receiver_->EnableVad(); | 269 receiver_->EnableVad(); |
270 EXPECT_TRUE(receiver_->vad_enabled()); | 270 EXPECT_TRUE(receiver_->vad_enabled()); |
271 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); | 271 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); |
272 ASSERT_EQ( | 272 ASSERT_EQ( |
273 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, | 273 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, |
274 codec.inst.plfreq, nullptr)); | 274 codec.inst.plfreq, nullptr, "")); |
275 const int kNumPackets = 5; | 275 const int kNumPackets = 5; |
276 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); | 276 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); |
277 AudioFrame frame; | 277 AudioFrame frame; |
278 for (int n = 0; n < kNumPackets; ++n) { | 278 for (int n = 0; n < kNumPackets; ++n) { |
279 InsertOnePacketOfSilence(codec.id); | 279 InsertOnePacketOfSilence(codec.id); |
280 for (int k = 0; k < num_10ms_frames; ++k) | 280 for (int k = 0; k < num_10ms_frames; ++k) |
281 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); | 281 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); |
282 } | 282 } |
283 EXPECT_EQ(AudioFrame::kVadPassive, frame.vad_activity_); | 283 EXPECT_EQ(AudioFrame::kVadPassive, frame.vad_activity_); |
284 | 284 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 EXPECT_EQ(rtc::Optional<int>(c.inst.plfreq), | 360 EXPECT_EQ(rtc::Optional<int>(c.inst.plfreq), |
361 receiver_->last_packet_sample_rate_hz()); | 361 receiver_->last_packet_sample_rate_hz()); |
362 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); | 362 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); |
363 EXPECT_TRUE(CodecsEqual(c.inst, codec)); | 363 EXPECT_TRUE(CodecsEqual(c.inst, codec)); |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 } // namespace acm2 | 367 } // namespace acm2 |
368 | 368 |
369 } // namespace webrtc | 369 } // namespace webrtc |
OLD | NEW |