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..969ff40bc29baa3af6ecd34778cc8d769bdf9ee4 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,84 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_SampleRate) { |
} |
} |
+class AcmReceiverTestFaxModeOldApi : public AcmReceiverTestOldApi { |
+ protected: |
+ AcmReceiverTestFaxModeOldApi() { |
+ config_.neteq_config.playout_mode = kPlayoutFax; |
+ } |
+ |
+ void RunVerifyAudioFrame(RentACodec::CodecId codec_id) { |
+ // 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 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_ - |
+ 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_VerifyAudioFramePCMU DISABLED_VerifyAudioFramePCMU |
+#else |
+#define MAYBE_VerifyAudioFramePCMU VerifyAudioFramePCMU |
+#endif |
+TEST_F(AcmReceiverTestFaxModeOldApi, MAYBE_VerifyAudioFramePCMU) { |
+ RunVerifyAudioFrame(RentACodec::CodecId::kPCMU); |
+} |
+ |
+#if defined(WEBRTC_ANDROID) |
+#define MAYBE_VerifyAudioFrameISAC DISABLED_VerifyAudioFrameISAC |
+#else |
+#define MAYBE_VerifyAudioFrameISAC VerifyAudioFrameISAC |
+#endif |
+TEST_F(AcmReceiverTestFaxModeOldApi, MAYBE_VerifyAudioFrameISAC) { |
+ RunVerifyAudioFrame(RentACodec::CodecId::kISAC); |
+} |
+ |
+#if defined(WEBRTC_ANDROID) |
+#define MAYBE_VerifyAudioFrameOpus DISABLED_VerifyAudioFrameOpus |
+#else |
+#define MAYBE_VerifyAudioFrameOpus VerifyAudioFrameOpus |
+#endif |
+TEST_F(AcmReceiverTestFaxModeOldApi, MAYBE_VerifyAudioFrameOpus) { |
+ RunVerifyAudioFrame(RentACodec::CodecId::kOpus); |
+} |
+ |
#if defined(WEBRTC_ANDROID) |
#define MAYBE_PostdecodingVad DISABLED_PostdecodingVad |
#else |