Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc

Issue 1859953002: Unit test for AudioFrame output from AcmReceiver::GetAudio (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/include/neteq.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "webrtc/modules/audio_coding/acm2/acm_receiver.h" 11 #include "webrtc/modules/audio_coding/acm2/acm_receiver.h"
12 12
13 #include <algorithm> // std::min 13 #include <algorithm> // std::min
14 #include <memory> 14 #include <memory>
15 15
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/safe_conversions.h"
17 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" 19 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
18 #include "webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h" 20 #include "webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h"
19 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" 21 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
20 #include "webrtc/system_wrappers/include/clock.h" 22 #include "webrtc/system_wrappers/include/clock.h"
21 #include "webrtc/test/test_suite.h" 23 #include "webrtc/test/test_suite.h"
22 #include "webrtc/test/testsupport/fileutils.h" 24 #include "webrtc/test/testsupport/fileutils.h"
23 25
24 namespace webrtc { 26 namespace webrtc {
25 27
26 namespace acm2 { 28 namespace acm2 {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 const CodecIdInst codec(codec_id); 284 const CodecIdInst codec(codec_id);
283 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); 285 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100);
284 InsertOnePacketOfSilence(codec.id); 286 InsertOnePacketOfSilence(codec.id);
285 for (int k = 0; k < num_10ms_frames; ++k) { 287 for (int k = 0; k < num_10ms_frames; ++k) {
286 EXPECT_EQ(0, receiver_->GetAudio(kOutSampleRateHz, &frame)); 288 EXPECT_EQ(0, receiver_->GetAudio(kOutSampleRateHz, &frame));
287 } 289 }
288 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz()); 290 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz());
289 } 291 }
290 } 292 }
291 293
294 class AcmReceiverTestFaxModeOldApi : public AcmReceiverTestOldApi {
295 protected:
296 AcmReceiverTestFaxModeOldApi() {
297 config_.neteq_config.playout_mode = kPlayoutFax;
298 }
299 };
300
301 #if defined(WEBRTC_ANDROID)
302 #define MAYBE_VerifyAudioFrame DISABLED_VerifyAudioFrame
303 #else
304 #define MAYBE_VerifyAudioFrame VerifyAudioFrame
305 #endif
306 TEST_F(AcmReceiverTestFaxModeOldApi, MAYBE_VerifyAudioFrame) {
307 // Make sure "fax mode" is enabled. This will avoid delay changes unless the
308 // packet-loss concealment is made. We do this in order to make the timestamp
309 // increments predictable; in normal mode, NetEq may decide to do accelerate
310 // or pre-emptive expand operations after some time, offsetting the timestamp.
311 EXPECT_EQ(kPlayoutFax, config_.neteq_config.playout_mode);
312
313 const RentACodec::CodecId codec_id = RentACodec::CodecId::kOpus;
314 const RentACodec::CodecId kCodecId[] = {codec_id};
315 AddSetOfCodecs(kCodecId);
316
317 const CodecIdInst codec(codec_id);
318 const int output_sample_rate_hz = codec.inst.plfreq;
319 const size_t samples_per_ms = rtc::checked_cast<size_t>(
320 rtc::CheckedDivExact(output_sample_rate_hz, 1000));
321 const int num_10ms_frames = codec.inst.pacsize / (10 * samples_per_ms);
minyue-webrtc 2016/04/05 13:00:22 no CheckedDivExact on this?
hlundin-webrtc 2016/04/05 13:24:14 Done.
322
323 // Expect the first output timestamp to be 30 samples before the first
324 // inserted timestamp (because of NetEq's look-ahead).
325 uint32_t expected_output_ts = last_packet_send_timestamp_ - 30u;
minyue-webrtc 2016/04/05 13:00:22 what would it be if |last_packet_send_timestamp_|
hlundin-webrtc 2016/04/05 13:24:14 In fact it is; last_packet_send_timestamp_ = 0 fro
minyue-webrtc 2016/04/05 13:30:04 Acknowledged.
326
327 AudioFrame frame;
328 for (int i = 0; i < 5; ++i) {
329 InsertOnePacketOfSilence(codec.id);
330 for (int k = 0; k < num_10ms_frames; ++k) {
331 EXPECT_EQ(0, receiver_->GetAudio(output_sample_rate_hz, &frame));
332 EXPECT_EQ(expected_output_ts, frame.timestamp_);
333 expected_output_ts += 10 * samples_per_ms;
334 EXPECT_EQ(10 * samples_per_ms, frame.samples_per_channel_);
335 EXPECT_EQ(output_sample_rate_hz, frame.sample_rate_hz_);
336 EXPECT_EQ(2u, frame.num_channels_);
337 EXPECT_EQ(AudioFrame::kNormalSpeech, frame.speech_type_);
338 EXPECT_EQ(AudioFrame::kVadActive, frame.vad_activity_);
minyue-webrtc 2016/04/05 13:00:22 why is VadActive when packet is silent?
hlundin-webrtc 2016/04/05 13:24:14 There is a restriction on the post-decode VAD in N
minyue-webrtc 2016/04/05 13:30:04 so if codec_id equals to a 16kHz codec, this line
339 }
340 }
341 }
342
292 #if defined(WEBRTC_ANDROID) 343 #if defined(WEBRTC_ANDROID)
293 #define MAYBE_PostdecodingVad DISABLED_PostdecodingVad 344 #define MAYBE_PostdecodingVad DISABLED_PostdecodingVad
294 #else 345 #else
295 #define MAYBE_PostdecodingVad PostdecodingVad 346 #define MAYBE_PostdecodingVad PostdecodingVad
296 #endif 347 #endif
297 TEST_F(AcmReceiverTestOldApi, MAYBE_PostdecodingVad) { 348 TEST_F(AcmReceiverTestOldApi, MAYBE_PostdecodingVad) {
298 EXPECT_TRUE(config_.neteq_config.enable_post_decode_vad); 349 EXPECT_TRUE(config_.neteq_config.enable_post_decode_vad);
299 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); 350 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb);
300 ASSERT_EQ( 351 ASSERT_EQ(
301 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, 352 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 receiver_->last_packet_sample_rate_hz()); 458 receiver_->last_packet_sample_rate_hz());
408 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); 459 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec));
409 EXPECT_TRUE(CodecsEqual(c.inst, codec)); 460 EXPECT_TRUE(CodecsEqual(c.inst, codec));
410 } 461 }
411 } 462 }
412 #endif 463 #endif
413 464
414 } // namespace acm2 465 } // namespace acm2
415 466
416 } // namespace webrtc 467 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/include/neteq.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698