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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 class AcmReceiverTestOldApi : public AudioPacketizationCallback, | 53 class AcmReceiverTestOldApi : public AudioPacketizationCallback, |
54 public ::testing::Test { | 54 public ::testing::Test { |
55 protected: | 55 protected: |
56 AcmReceiverTestOldApi() | 56 AcmReceiverTestOldApi() |
57 : timestamp_(0), | 57 : timestamp_(0), |
58 packet_sent_(false), | 58 packet_sent_(false), |
59 last_packet_send_timestamp_(timestamp_), | 59 last_packet_send_timestamp_(timestamp_), |
60 last_frame_type_(kEmptyFrame) { | 60 last_frame_type_(kEmptyFrame) { |
61 AudioCodingModule::Config config; | |
62 acm_.reset(new AudioCodingModuleImpl(config)); | |
63 receiver_.reset(new AcmReceiver(config)); | |
64 } | 61 } |
65 | 62 |
66 ~AcmReceiverTestOldApi() {} | 63 ~AcmReceiverTestOldApi() {} |
67 | 64 |
68 void SetUp() override { | 65 void SetUp() override { |
| 66 acm_.reset(new AudioCodingModuleImpl(config_)); |
| 67 receiver_.reset(new AcmReceiver(config_)); |
69 ASSERT_TRUE(receiver_.get() != NULL); | 68 ASSERT_TRUE(receiver_.get() != NULL); |
70 ASSERT_TRUE(acm_.get() != NULL); | 69 ASSERT_TRUE(acm_.get() != NULL); |
71 codecs_ = RentACodec::Database(); | 70 codecs_ = RentACodec::Database(); |
72 | 71 |
73 acm_->InitializeReceiver(); | 72 acm_->InitializeReceiver(); |
74 acm_->RegisterTransportCallback(this); | 73 acm_->RegisterTransportCallback(this); |
75 | 74 |
76 rtp_header_.header.sequenceNumber = 0; | 75 rtp_header_.header.sequenceNumber = 0; |
77 rtp_header_.header.timestamp = 0; | 76 rtp_header_.header.timestamp = 0; |
78 rtp_header_.header.markerBit = false; | 77 rtp_header_.header.markerBit = false; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 if (ret_val < 0) { | 145 if (ret_val < 0) { |
147 assert(false); | 146 assert(false); |
148 return -1; | 147 return -1; |
149 } | 148 } |
150 rtp_header_.header.sequenceNumber++; | 149 rtp_header_.header.sequenceNumber++; |
151 packet_sent_ = true; | 150 packet_sent_ = true; |
152 last_frame_type_ = frame_type; | 151 last_frame_type_ = frame_type; |
153 return 0; | 152 return 0; |
154 } | 153 } |
155 | 154 |
| 155 AudioCodingModule::Config config_; |
156 std::unique_ptr<AcmReceiver> receiver_; | 156 std::unique_ptr<AcmReceiver> receiver_; |
157 rtc::ArrayView<const CodecInst> codecs_; | 157 rtc::ArrayView<const CodecInst> codecs_; |
158 std::unique_ptr<AudioCodingModule> acm_; | 158 std::unique_ptr<AudioCodingModule> acm_; |
159 WebRtcRTPHeader rtp_header_; | 159 WebRtcRTPHeader rtp_header_; |
160 uint32_t timestamp_; | 160 uint32_t timestamp_; |
161 bool packet_sent_; // Set when SendData is called reset when inserting audio. | 161 bool packet_sent_; // Set when SendData is called reset when inserting audio. |
162 uint32_t last_packet_send_timestamp_; | 162 uint32_t last_packet_send_timestamp_; |
163 FrameType last_frame_type_; | 163 FrameType last_frame_type_; |
164 }; | 164 }; |
165 | 165 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz()); | 288 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz()); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 #if defined(WEBRTC_ANDROID) | 292 #if defined(WEBRTC_ANDROID) |
293 #define MAYBE_PostdecodingVad DISABLED_PostdecodingVad | 293 #define MAYBE_PostdecodingVad DISABLED_PostdecodingVad |
294 #else | 294 #else |
295 #define MAYBE_PostdecodingVad PostdecodingVad | 295 #define MAYBE_PostdecodingVad PostdecodingVad |
296 #endif | 296 #endif |
297 TEST_F(AcmReceiverTestOldApi, MAYBE_PostdecodingVad) { | 297 TEST_F(AcmReceiverTestOldApi, MAYBE_PostdecodingVad) { |
298 receiver_->EnableVad(); | 298 EXPECT_TRUE(config_.neteq_config.enable_post_decode_vad); |
299 EXPECT_TRUE(receiver_->vad_enabled()); | |
300 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); | 299 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); |
301 ASSERT_EQ( | 300 ASSERT_EQ( |
302 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, | 301 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, |
303 codec.inst.plfreq, nullptr, "")); | 302 codec.inst.plfreq, nullptr, "")); |
304 const int kNumPackets = 5; | 303 const int kNumPackets = 5; |
305 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); | 304 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); |
306 AudioFrame frame; | 305 AudioFrame frame; |
307 for (int n = 0; n < kNumPackets; ++n) { | 306 for (int n = 0; n < kNumPackets; ++n) { |
308 InsertOnePacketOfSilence(codec.id); | 307 InsertOnePacketOfSilence(codec.id); |
309 for (int k = 0; k < num_10ms_frames; ++k) | 308 for (int k = 0; k < num_10ms_frames; ++k) |
310 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); | 309 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); |
311 } | 310 } |
312 EXPECT_EQ(AudioFrame::kVadPassive, frame.vad_activity_); | 311 EXPECT_EQ(AudioFrame::kVadPassive, frame.vad_activity_); |
| 312 } |
313 | 313 |
314 receiver_->DisableVad(); | 314 class AcmReceiverTestPostDecodeVadPassiveOldApi : public AcmReceiverTestOldApi { |
315 EXPECT_FALSE(receiver_->vad_enabled()); | 315 protected: |
| 316 AcmReceiverTestPostDecodeVadPassiveOldApi() { |
| 317 config_.neteq_config.enable_post_decode_vad = false; |
| 318 } |
| 319 }; |
316 | 320 |
| 321 #if defined(WEBRTC_ANDROID) |
| 322 #define MAYBE_PostdecodingVad DISABLED_PostdecodingVad |
| 323 #else |
| 324 #define MAYBE_PostdecodingVad PostdecodingVad |
| 325 #endif |
| 326 TEST_F(AcmReceiverTestPostDecodeVadPassiveOldApi, MAYBE_PostdecodingVad) { |
| 327 EXPECT_FALSE(config_.neteq_config.enable_post_decode_vad); |
| 328 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); |
| 329 ASSERT_EQ( |
| 330 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, |
| 331 codec.inst.plfreq, nullptr, "")); |
| 332 const int kNumPackets = 5; |
| 333 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); |
| 334 AudioFrame frame; |
317 for (int n = 0; n < kNumPackets; ++n) { | 335 for (int n = 0; n < kNumPackets; ++n) { |
318 InsertOnePacketOfSilence(codec.id); | 336 InsertOnePacketOfSilence(codec.id); |
319 for (int k = 0; k < num_10ms_frames; ++k) | 337 for (int k = 0; k < num_10ms_frames; ++k) |
320 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); | 338 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); |
321 } | 339 } |
322 EXPECT_EQ(AudioFrame::kVadUnknown, frame.vad_activity_); | 340 EXPECT_EQ(AudioFrame::kVadUnknown, frame.vad_activity_); |
323 } | 341 } |
324 | 342 |
325 #if defined(WEBRTC_ANDROID) | 343 #if defined(WEBRTC_ANDROID) |
326 #define MAYBE_LastAudioCodec DISABLED_LastAudioCodec | 344 #define MAYBE_LastAudioCodec DISABLED_LastAudioCodec |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 receiver_->last_packet_sample_rate_hz()); | 407 receiver_->last_packet_sample_rate_hz()); |
390 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); | 408 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); |
391 EXPECT_TRUE(CodecsEqual(c.inst, codec)); | 409 EXPECT_TRUE(CodecsEqual(c.inst, codec)); |
392 } | 410 } |
393 } | 411 } |
394 #endif | 412 #endif |
395 | 413 |
396 } // namespace acm2 | 414 } // namespace acm2 |
397 | 415 |
398 } // namespace webrtc | 416 } // namespace webrtc |
OLD | NEW |