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..bc95edaa5ca159c0a428353e8c5d7485fb3312b0 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,63 @@ 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 output_channels = codec.inst.channels; |
+ const size_t samples_per_ms = rtc::checked_cast<size_t>( |
+ rtc::CheckedDivExact(output_sample_rate_hz, 1000)); |
+ const int num_10ms_frames = rtc::CheckedDivExact( |
+ codec.inst.pacsize, rtc::checked_cast<int>(10 * samples_per_ms)); |
+ const AudioFrame::VADActivity expected_vad_activity = |
+ output_sample_rate_hz > 16000 ? AudioFrame::kVadActive |
+ : AudioFrame::kVadPassive; |
+ |
+ // Expect the first output timestamp to be 5*fs/8000 samples before the first |
+ // inserted timestamp (because of NetEq's look-ahead). (This value is defined |
+ // in Expand::overlap_length_.) |
+ uint32_t expected_output_ts = |
+ last_packet_send_timestamp_ - |
minyue-webrtc
2016/04/05 14:08:59
better moving this line up
hlundin-webrtc
2016/04/05 14:24:15
Done.
|
+ rtc::CheckedDivExact(5 * output_sample_rate_hz, 8000); |
+ |
+ 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(output_channels, frame.num_channels_); |
+ EXPECT_EQ(AudioFrame::kNormalSpeech, frame.speech_type_); |
+ EXPECT_EQ(expected_vad_activity, frame.vad_activity_); |
+ } |
+ } |
+} |
+ |
#if defined(WEBRTC_ANDROID) |
#define MAYBE_PostdecodingVad DISABLED_PostdecodingVad |
#else |