Passed AudioMixer to AudioState::Config.
This is a refactoring change in preparation for enabling AudioMixer with the goal to have a small CL as possible for passing audio through the new audio mixer in WebRTC. The dependent CL https://codereview.webrtc.org/2436033002/ enables the mixer. An object of class AudioState is shared across different webrtc audio connections. It is created in tests and in WebRTCVoiceEngine. AudioState is constructed by passing a Config struct, where one argument is scoped_refptr<AudioMixer>. Populating this field has now been mandatory. Tests and WebRTCVoiceEngine create and pass either a AudioMixerImpl. WebRTCVoiceEngine passes a real AudioMixer, which is currently unused. An alternative would have tests pass a mocked audio mixer. We chose not to do that, because we believe that tests should use the real thing unless there are reasons against it. Construction time is not an issue, because the real mixer is relatively lightweight. We couldn't find a way to test any mixer-related changes in AudioState before the mixes is connected. The next dependent CL https://codereview.webrtc.org/2436033002/ contains unit tests for mixer usage. BUG=webrtc:6346 Review-Url: https://codereview.webrtc.org/2469743002 Cr-Commit-Position: refs/heads/master@{#15134}
This commit is contained in:
parent
dd31071e19
commit
10111bc495
@ -48,7 +48,9 @@ if (rtc_include_tests) {
|
||||
]
|
||||
deps = [
|
||||
":audio",
|
||||
"../base:rtc_base_approved",
|
||||
"../modules/audio_device:mock_audio_device",
|
||||
"../test:test_common",
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
]
|
||||
|
||||
@ -4,6 +4,7 @@ include_rules = [
|
||||
"+webrtc/logging/rtc_event_log",
|
||||
"+webrtc/modules/audio_coding/codecs/mock",
|
||||
"+webrtc/modules/audio_device",
|
||||
"+webrtc/modules/audio_mixer",
|
||||
"+webrtc/modules/audio_processing/include",
|
||||
"+webrtc/modules/bitrate_controller",
|
||||
"+webrtc/modules/congestion_controller",
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include "webrtc/audio/conversion.h"
|
||||
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h"
|
||||
#include "webrtc/modules/pacing/packet_router.h"
|
||||
@ -84,6 +85,7 @@ struct ConfigHelper {
|
||||
|
||||
AudioState::Config config;
|
||||
config.voice_engine = &voice_engine_;
|
||||
config.audio_mixer = AudioMixerImpl::Create();
|
||||
audio_state_ = AudioState::Create(config);
|
||||
|
||||
EXPECT_CALL(voice_engine_, ChannelProxyFactory(kChannelId))
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "webrtc/audio/conversion.h"
|
||||
#include "webrtc/base/task_queue.h"
|
||||
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/modules/audio_processing/include/mock_audio_processing.h"
|
||||
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h"
|
||||
@ -81,6 +82,7 @@ struct ConfigHelper {
|
||||
|
||||
AudioState::Config config;
|
||||
config.voice_engine = &voice_engine_;
|
||||
config.audio_mixer = AudioMixerImpl::Create();
|
||||
audio_state_ = AudioState::Create(config);
|
||||
|
||||
SetupDefaultChannelProxy();
|
||||
|
||||
@ -26,6 +26,8 @@ AudioState::AudioState(const AudioState::Config& config)
|
||||
voe_base_->audio_processing(),
|
||||
config_.audio_mixer) {
|
||||
process_thread_checker_.DetachFromThread();
|
||||
RTC_DCHECK(config_.audio_mixer);
|
||||
|
||||
// Only one AudioState should be created per VoiceEngine.
|
||||
RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1);
|
||||
|
||||
@ -48,6 +50,7 @@ VoiceEngine* AudioState::voice_engine() {
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<AudioMixer> AudioState::mixer() {
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
return config_.audio_mixer;
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/audio/audio_state.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/test/mock_voice_engine.h"
|
||||
|
||||
@ -29,6 +30,7 @@ struct ConfigHelper {
|
||||
EXPECT_CALL(voice_engine_, audio_transport());
|
||||
|
||||
config_.voice_engine = &voice_engine_;
|
||||
config_.audio_mixer = AudioMixerImpl::Create();
|
||||
}
|
||||
AudioState::Config& config() { return config_; }
|
||||
MockVoiceEngine& voice_engine() { return voice_engine_; }
|
||||
|
||||
@ -49,7 +49,10 @@ if (rtc_include_tests) {
|
||||
]
|
||||
deps = [
|
||||
":call",
|
||||
"../base:rtc_base_approved",
|
||||
"../modules/audio_device:mock_audio_device",
|
||||
"../modules/audio_mixer",
|
||||
"../test:test_common",
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
]
|
||||
|
||||
@ -4,6 +4,7 @@ include_rules = [
|
||||
"+webrtc/logging/rtc_event_log",
|
||||
"+webrtc/modules/audio_coding",
|
||||
"+webrtc/modules/audio_device",
|
||||
"+webrtc/modules/audio_mixer",
|
||||
"+webrtc/modules/audio_processing",
|
||||
"+webrtc/modules/bitrate_controller",
|
||||
"+webrtc/modules/congestion_controller",
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/metrics_default.h"
|
||||
@ -159,6 +160,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec,
|
||||
|
||||
AudioState::Config send_audio_state_config;
|
||||
send_audio_state_config.voice_engine = voice_engine;
|
||||
send_audio_state_config.audio_mixer = AudioMixerImpl::Create();
|
||||
Call::Config sender_config(&event_log_);
|
||||
sender_config.audio_state = AudioState::Create(send_audio_state_config);
|
||||
Call::Config receiver_config(&event_log_);
|
||||
@ -264,7 +266,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec,
|
||||
Start();
|
||||
|
||||
fake_audio_device.Start();
|
||||
EXPECT_EQ(0, voe_base->StartPlayout(recv_channel_id));
|
||||
audio_receive_stream->Start();
|
||||
EXPECT_EQ(0, voe_base->StartSend(send_channel_id));
|
||||
|
||||
EXPECT_TRUE(observer.Wait())
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "webrtc/api/call/audio_state.h"
|
||||
#include "webrtc/call.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/test/mock_voice_engine.h"
|
||||
@ -26,6 +27,7 @@ struct CallHelper {
|
||||
: voice_engine_(decoder_factory) {
|
||||
webrtc::AudioState::Config audio_state_config;
|
||||
audio_state_config.voice_engine = &voice_engine_;
|
||||
audio_state_config.audio_mixer = webrtc::AudioMixerImpl::Create();
|
||||
EXPECT_CALL(voice_engine_, audio_device_module());
|
||||
EXPECT_CALL(voice_engine_, audio_processing());
|
||||
EXPECT_CALL(voice_engine_, audio_transport());
|
||||
|
||||
@ -168,6 +168,7 @@ rtc_static_library("rtc_media") {
|
||||
"../api:call_api",
|
||||
"../base:rtc_base_approved",
|
||||
"../call",
|
||||
"../modules/audio_mixer:audio_mixer_impl",
|
||||
"../modules/video_coding",
|
||||
"../p2p",
|
||||
"../system_wrappers",
|
||||
|
||||
@ -6,6 +6,7 @@ include_rules = [
|
||||
"+webrtc/logging/rtc_event_log",
|
||||
"+webrtc/modules/audio_coding",
|
||||
"+webrtc/modules/audio_device",
|
||||
"+webrtc/modules/audio_mixer",
|
||||
"+webrtc/modules/audio_processing",
|
||||
"+webrtc/modules/video_capture",
|
||||
"+webrtc/modules/video_coding",
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
#include "webrtc/media/engine/webrtcmediaengine.h"
|
||||
#include "webrtc/media/engine/webrtcvoe.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/system_wrappers/include/field_trial.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
@ -279,6 +280,7 @@ void GetOpusConfig(const AudioCodec& codec,
|
||||
webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) {
|
||||
webrtc::AudioState::Config config;
|
||||
config.voice_engine = voe_wrapper->engine();
|
||||
config.audio_mixer = webrtc::AudioMixerImpl::Create();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@ -16,10 +16,6 @@ group("audio_mixer") {
|
||||
}
|
||||
|
||||
rtc_static_library("audio_mixer_impl") {
|
||||
visibility = [
|
||||
"../../audio:audio",
|
||||
"../../modules/*",
|
||||
]
|
||||
sources = [
|
||||
"audio_mixer_impl.cc",
|
||||
"audio_mixer_impl.h",
|
||||
|
||||
@ -334,6 +334,7 @@ rtc_source_set("test_common") {
|
||||
"../base:rtc_base_approved",
|
||||
"../call",
|
||||
"../modules/audio_device:mock_audio_device",
|
||||
"../modules/audio_mixer:audio_mixer_impl",
|
||||
"../modules/audio_processing",
|
||||
"../modules/media_file",
|
||||
"../modules/video_capture:video_capture_module",
|
||||
|
||||
@ -6,6 +6,7 @@ include_rules = [
|
||||
"+webrtc/media/base",
|
||||
"+webrtc/modules/audio_coding",
|
||||
"+webrtc/modules/audio_device",
|
||||
"+webrtc/modules/audio_mixer",
|
||||
"+webrtc/modules/audio_processing",
|
||||
"+webrtc/modules/media_file",
|
||||
"+webrtc/modules/rtp_rtcp",
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/test/call_test.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/voice_engine/include/voe_base.h"
|
||||
|
||||
@ -52,6 +54,7 @@ void CallTest::RunBaseTest(BaseTest* test) {
|
||||
CreateVoiceEngines();
|
||||
AudioState::Config audio_state_config;
|
||||
audio_state_config.voice_engine = voe_send_.voice_engine;
|
||||
audio_state_config.audio_mixer = AudioMixerImpl::Create();
|
||||
send_config.audio_state = AudioState::Create(audio_state_config);
|
||||
}
|
||||
CreateSenderCall(send_config);
|
||||
@ -60,6 +63,7 @@ void CallTest::RunBaseTest(BaseTest* test) {
|
||||
if (num_audio_streams_ > 0) {
|
||||
AudioState::Config audio_state_config;
|
||||
audio_state_config.voice_engine = voe_recv_.voice_engine;
|
||||
audio_state_config.audio_mixer = AudioMixerImpl::Create();
|
||||
recv_config.audio_state = AudioState::Create(audio_state_config);
|
||||
}
|
||||
CreateReceiverCall(recv_config);
|
||||
|
||||
@ -4,6 +4,7 @@ include_rules = [
|
||||
"+webrtc/common_video",
|
||||
"+webrtc/logging/rtc_event_log",
|
||||
"+webrtc/media/base",
|
||||
"+webrtc/modules/audio_mixer",
|
||||
"+webrtc/modules/bitrate_controller",
|
||||
"+webrtc/modules/congestion_controller",
|
||||
"+webrtc/modules/pacing",
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "webrtc/call.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
||||
#include "webrtc/system_wrappers/include/cpu_info.h"
|
||||
@ -1341,6 +1342,7 @@ void VideoQualityTest::RunWithRenderers(const Params& params) {
|
||||
CreateVoiceEngine(&voe, decoder_factory_);
|
||||
AudioState::Config audio_state_config;
|
||||
audio_state_config.voice_engine = voe.voice_engine;
|
||||
audio_state_config.audio_mixer = AudioMixerImpl::Create();
|
||||
call_config.audio_state = AudioState::Create(audio_state_config);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user