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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/include/neteq.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc
diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc
index a26b2e217fe2a90a13c4e0389f2dc6807ecbb798..970e32d7d152e6c09e1643f113cf5b8af4ee0c6a 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc
@@ -14,6 +14,8 @@
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/base/checks.h"
+#include "webrtc/base/safe_conversions.h"
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
#include "webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h"
#include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
@@ -289,6 +291,55 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_SampleRate) {
}
}
+class AcmReceiverTestFaxModeOldApi : public AcmReceiverTestOldApi {
+ protected:
+ AcmReceiverTestFaxModeOldApi() {
+ config_.neteq_config.playout_mode = kPlayoutFax;
+ }
+};
+
+#if defined(WEBRTC_ANDROID)
+#define MAYBE_VerifyAudioFrame DISABLED_VerifyAudioFrame
+#else
+#define MAYBE_VerifyAudioFrame VerifyAudioFrame
+#endif
+TEST_F(AcmReceiverTestFaxModeOldApi, MAYBE_VerifyAudioFrame) {
+ // Make sure "fax mode" is enabled. This will avoid delay changes unless the
+ // packet-loss concealment is made. We do this in order to make the timestamp
+ // increments predictable; in normal mode, NetEq may decide to do accelerate
+ // or pre-emptive expand operations after some time, offsetting the timestamp.
+ EXPECT_EQ(kPlayoutFax, config_.neteq_config.playout_mode);
+
+ const RentACodec::CodecId codec_id = RentACodec::CodecId::kOpus;
+ const RentACodec::CodecId kCodecId[] = {codec_id};
+ AddSetOfCodecs(kCodecId);
+
+ const CodecIdInst codec(codec_id);
+ const int output_sample_rate_hz = codec.inst.plfreq;
+ const size_t samples_per_ms = rtc::checked_cast<size_t>(
+ rtc::CheckedDivExact(output_sample_rate_hz, 1000));
+ 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.
+
+ // Expect the first output timestamp to be 30 samples before the first
+ // inserted timestamp (because of NetEq's look-ahead).
+ 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.
+
+ AudioFrame frame;
+ for (int i = 0; i < 5; ++i) {
+ InsertOnePacketOfSilence(codec.id);
+ for (int k = 0; k < num_10ms_frames; ++k) {
+ EXPECT_EQ(0, receiver_->GetAudio(output_sample_rate_hz, &frame));
+ EXPECT_EQ(expected_output_ts, frame.timestamp_);
+ expected_output_ts += 10 * samples_per_ms;
+ EXPECT_EQ(10 * samples_per_ms, frame.samples_per_channel_);
+ EXPECT_EQ(output_sample_rate_hz, frame.sample_rate_hz_);
+ EXPECT_EQ(2u, frame.num_channels_);
+ EXPECT_EQ(AudioFrame::kNormalSpeech, frame.speech_type_);
+ 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
+ }
+ }
+}
+
#if defined(WEBRTC_ANDROID)
#define MAYBE_PostdecodingVad DISABLED_PostdecodingVad
#else
« 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