diff options
author | Per Åhgren <peah@webrtc.org> | 2020-03-17 13:23:58 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-17 13:55:41 +0000 |
commit | 71652f4b66ef4b7b39564efedb16802571f6b2f4 (patch) | |
tree | 0f498912858ae9ed045c3e5d638989f07565234c /audio | |
parent | 469205e1adafdc9cbe5942cd9a1c1af77e44fa82 (diff) | |
download | webrtc-71652f4b66ef4b7b39564efedb16802571f6b2f4.tar.gz |
APM: Localize/abstract the usage of AudioFrame
This CL moves the implementation of of the AudioFrame
support from the implementation of AudioProcessing
to proxy methods that map the call to the integer
stream interfaces (added in another CL).
The CL also changes the WebRTC code using the AudioFrame
interfaces to instead use the proxy methods.
This CL will be followed by one more CL that removes
the usage of the AudioFrame class from the rest of
APM (apart from the AudioProcessing API).
Bug: webrtc:5298
Change-Id: Iecb72e9fa896ebea3ac30e558489c1bac88f5891
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170110
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30812}
Diffstat (limited to 'audio')
-rw-r--r-- | audio/BUILD.gn | 1 | ||||
-rw-r--r-- | audio/audio_state_unittest.cc | 10 | ||||
-rw-r--r-- | audio/audio_transport_impl.cc | 6 |
3 files changed, 11 insertions, 6 deletions
diff --git a/audio/BUILD.gn b/audio/BUILD.gn index d7d7a12986..e03252ac96 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -69,6 +69,7 @@ rtc_library("audio") { "../modules/audio_device", "../modules/audio_processing", "../modules/audio_processing:api", + "../modules/audio_processing:audio_frame_proxies", "../modules/pacing", "../modules/remote_bitrate_estimator", "../modules/rtp_rtcp", diff --git a/audio/audio_state_unittest.cc b/audio/audio_state_unittest.cc index bf79529365..229a24d169 100644 --- a/audio/audio_state_unittest.cc +++ b/audio/audio_state_unittest.cc @@ -24,6 +24,8 @@ namespace webrtc { namespace test { namespace { +using ::testing::_; + constexpr int kSampleRate = 16000; constexpr int kNumberOfChannels = 1; @@ -120,7 +122,7 @@ TEST(AudioStateTest, RecordedAudioArrivesAtSingleStream) { static_cast<MockAudioProcessing*>(audio_state->audio_processing()); EXPECT_CALL(*ap, set_stream_delay_ms(0)); EXPECT_CALL(*ap, set_stream_key_pressed(false)); - EXPECT_CALL(*ap, ProcessStream(::testing::_)); + EXPECT_CALL(*ap, ProcessStream(_, _, _, _, _)); constexpr int kSampleRate = 16000; constexpr size_t kNumChannels = 2; @@ -170,7 +172,7 @@ TEST(AudioStateTest, RecordedAudioArrivesAtMultipleStreams) { static_cast<MockAudioProcessing*>(audio_state->audio_processing()); EXPECT_CALL(*ap, set_stream_delay_ms(5)); EXPECT_CALL(*ap, set_stream_key_pressed(true)); - EXPECT_CALL(*ap, ProcessStream(::testing::_)); + EXPECT_CALL(*ap, ProcessStream(_, _, _, _, _)); constexpr int kSampleRate = 16000; constexpr size_t kNumChannels = 1; @@ -198,7 +200,7 @@ TEST(AudioStateTest, EnableChannelSwap) { MockAudioSendStream stream; audio_state->AddSendingStream(&stream, kSampleRate, kNumChannels); - EXPECT_CALL(stream, SendAudioDataForMock(::testing::_)) + EXPECT_CALL(stream, SendAudioDataForMock(_)) .WillOnce( // Verify that channels are swapped. ::testing::Invoke([](AudioFrame* audio_frame) { @@ -225,7 +227,7 @@ TEST(AudioStateTest, FakeAudioSource fake_source; helper.mixer()->AddSource(&fake_source); - EXPECT_CALL(fake_source, GetAudioFrameWithInfo(::testing::_, ::testing::_)) + EXPECT_CALL(fake_source, GetAudioFrameWithInfo(_, _)) .WillOnce( ::testing::Invoke([](int sample_rate_hz, AudioFrame* audio_frame) { audio_frame->sample_rate_hz_ = sample_rate_hz; diff --git a/audio/audio_transport_impl.cc b/audio/audio_transport_impl.cc index 347e86b532..a61ea73102 100644 --- a/audio/audio_transport_impl.cc +++ b/audio/audio_transport_impl.cc @@ -17,6 +17,7 @@ #include "audio/remix_resample.h" #include "audio/utility/audio_frame_operations.h" #include "call/audio_sender.h" +#include "modules/audio_processing/include/audio_frame_proxies.h" #include "rtc_base/checks.h" namespace webrtc { @@ -52,7 +53,8 @@ void ProcessCaptureFrame(uint32_t delay_ms, RTC_DCHECK(audio_frame); audio_processing->set_stream_delay_ms(delay_ms); audio_processing->set_stream_key_pressed(key_pressed); - int error = audio_processing->ProcessStream(audio_frame); + int error = ProcessAudioFrame(audio_processing, audio_frame); + RTC_DCHECK_EQ(0, error) << "ProcessStream() error: " << error; if (swap_stereo_channels) { AudioFrameOperations::SwapStereoChannels(audio_frame); @@ -190,7 +192,7 @@ int32_t AudioTransportImpl::NeedMorePlayData(const size_t nSamples, *elapsed_time_ms = mixed_frame_.elapsed_time_ms_; *ntp_time_ms = mixed_frame_.ntp_time_ms_; - const auto error = audio_processing_->ProcessReverseStream(&mixed_frame_); + const auto error = ProcessReverseAudioFrame(audio_processing_, &mixed_frame_); RTC_DCHECK_EQ(error, AudioProcessing::kNoError); nSamplesOut = Resample(mixed_frame_, samplesPerSec, &render_resampler_, |