Moving/renaming webrtc/common.h.
This file defines webrtc::Config which was mostly used by modules/audio_processing. The files webrtc/common.h, webrtc/common.cc and webrtc/test/common_unittests.cc are moved to modules/audio_processing and the few remaining uses of webrtc::Config are replaced with simpler code. - For NetEq and pacing configuration, a VoEBase::ChannelConfig is passed to VoEBase::CreateChannel(). - Removes the need for VoiceEngine::Create(const Config& config). No need to store the webrtc::Config in VoE shared state. BUG=webrtc:5879 Review-Url: https://codereview.webrtc.org/2307533004 Cr-Commit-Position: refs/heads/master@{#14109}
This commit is contained in:
parent
4016a0b2e8
commit
88499ecaca
@ -325,9 +325,6 @@ if (!build_with_chromium) {
|
||||
|
||||
rtc_source_set("webrtc_common") {
|
||||
sources = [
|
||||
"audio_sink.h",
|
||||
"common.cc",
|
||||
"common.h",
|
||||
"common_types.cc",
|
||||
"common_types.h",
|
||||
"config.cc",
|
||||
|
||||
@ -159,9 +159,9 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec,
|
||||
FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), audio_filename,
|
||||
audio_rtp_speed);
|
||||
EXPECT_EQ(0, voe_base->Init(&fake_audio_device, nullptr, decoder_factory_));
|
||||
Config voe_config;
|
||||
voe_config.Set<VoicePacing>(new VoicePacing(true));
|
||||
int send_channel_id = voe_base->CreateChannel(voe_config);
|
||||
VoEBase::ChannelConfig config;
|
||||
config.enable_voice_pacing = true;
|
||||
int send_channel_id = voe_base->CreateChannel(config);
|
||||
int recv_channel_id = voe_base->CreateChannel();
|
||||
|
||||
AudioState::Config send_audio_state_config;
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
'target_name': 'webrtc_common',
|
||||
'type': 'static_library',
|
||||
'sources': [
|
||||
'common.cc',
|
||||
'common.h',
|
||||
'common_types.cc',
|
||||
'common_types.h',
|
||||
'config.h',
|
||||
|
||||
@ -52,8 +52,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Config;
|
||||
|
||||
class RewindableStream {
|
||||
public:
|
||||
virtual ~RewindableStream() {}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -170,35 +169,6 @@ class DecoderSpecificSettings {
|
||||
rtc::Optional<VideoDecoderH264Settings> h264_extra_settings;
|
||||
};
|
||||
|
||||
// Controls the capacity of the packet buffer in NetEq. The capacity is the
|
||||
// maximum number of packets that the buffer can contain. If the limit is
|
||||
// exceeded, the buffer will be flushed. The capacity does not affect the actual
|
||||
// audio delay in the general case, since this is governed by the target buffer
|
||||
// level (calculated from the jitter profile). It is only in the rare case of
|
||||
// severe network freezes that a higher capacity will lead to a (transient)
|
||||
// increase in audio delay.
|
||||
struct NetEqCapacityConfig {
|
||||
NetEqCapacityConfig() : enabled(false), capacity(0) {}
|
||||
explicit NetEqCapacityConfig(int value) : enabled(true), capacity(value) {}
|
||||
static const ConfigOptionID identifier = ConfigOptionID::kNetEqCapacityConfig;
|
||||
bool enabled;
|
||||
int capacity;
|
||||
};
|
||||
|
||||
struct NetEqFastAccelerate {
|
||||
NetEqFastAccelerate() : enabled(false) {}
|
||||
explicit NetEqFastAccelerate(bool value) : enabled(value) {}
|
||||
static const ConfigOptionID identifier = ConfigOptionID::kNetEqFastAccelerate;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
struct VoicePacing {
|
||||
VoicePacing() : enabled(false) {}
|
||||
explicit VoicePacing(bool value) : enabled(value) {}
|
||||
static const ConfigOptionID identifier = ConfigOptionID::kVoicePacing;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_CONFIG_H_
|
||||
|
||||
@ -154,7 +154,7 @@ class FakeWebRtcVoiceEngine
|
||||
int associate_send_channel = -1;
|
||||
std::vector<webrtc::CodecInst> recv_codecs;
|
||||
webrtc::CodecInst send_codec;
|
||||
int neteq_capacity = -1;
|
||||
size_t neteq_capacity = 0;
|
||||
bool neteq_fast_accelerate = false;
|
||||
};
|
||||
|
||||
@ -190,21 +190,6 @@ class FakeWebRtcVoiceEngine
|
||||
void set_fail_create_channel(bool fail_create_channel) {
|
||||
fail_create_channel_ = fail_create_channel;
|
||||
}
|
||||
int AddChannel(const webrtc::Config& config) {
|
||||
if (fail_create_channel_) {
|
||||
return -1;
|
||||
}
|
||||
Channel* ch = new Channel();
|
||||
auto db = webrtc::acm2::RentACodec::Database();
|
||||
ch->recv_codecs.assign(db.begin(), db.end());
|
||||
if (config.Get<webrtc::NetEqCapacityConfig>().enabled) {
|
||||
ch->neteq_capacity = config.Get<webrtc::NetEqCapacityConfig>().capacity;
|
||||
}
|
||||
ch->neteq_fast_accelerate =
|
||||
config.Get<webrtc::NetEqFastAccelerate>().enabled;
|
||||
channels_[++last_channel_] = ch;
|
||||
return last_channel_;
|
||||
}
|
||||
|
||||
int GetNumSetSendCodecs() const { return num_set_send_codecs_; }
|
||||
|
||||
@ -237,11 +222,20 @@ class FakeWebRtcVoiceEngine
|
||||
return nullptr;
|
||||
}
|
||||
WEBRTC_FUNC(CreateChannel, ()) {
|
||||
webrtc::Config empty_config;
|
||||
return AddChannel(empty_config);
|
||||
return CreateChannel(webrtc::VoEBase::ChannelConfig());
|
||||
}
|
||||
WEBRTC_FUNC(CreateChannel, (const webrtc::Config& config)) {
|
||||
return AddChannel(config);
|
||||
WEBRTC_FUNC(CreateChannel, (const webrtc::VoEBase::ChannelConfig& config)) {
|
||||
if (fail_create_channel_) {
|
||||
return -1;
|
||||
}
|
||||
Channel* ch = new Channel();
|
||||
auto db = webrtc::acm2::RentACodec::Database();
|
||||
ch->recv_codecs.assign(db.begin(), db.end());
|
||||
ch->neteq_capacity = config.acm_config.neteq_config.max_packets_in_buffer;
|
||||
ch->neteq_fast_accelerate =
|
||||
config.acm_config.neteq_config.enable_fast_accelerate;
|
||||
channels_[++last_channel_] = ch;
|
||||
return last_channel_;
|
||||
}
|
||||
WEBRTC_FUNC(DeleteChannel, (int channel)) {
|
||||
WEBRTC_CHECK_CHANNEL(channel);
|
||||
@ -547,7 +541,7 @@ class FakeWebRtcVoiceEngine
|
||||
void EnableStereoChannelSwapping(bool enable) override {
|
||||
stereo_swapping_enabled_ = enable;
|
||||
}
|
||||
int GetNetEqCapacity() const {
|
||||
size_t GetNetEqCapacity() const {
|
||||
auto ch = channels_.find(last_channel_);
|
||||
ASSERT(ch != channels_.end());
|
||||
return ch->second->neteq_capacity;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
#include "webrtc/base/stringencode.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/base/trace_event.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/media/base/audiosource.h"
|
||||
#include "webrtc/media/base/mediaconstants.h"
|
||||
#include "webrtc/media/base/streamparams.h"
|
||||
@ -538,7 +537,7 @@ WebRtcVoiceEngine::WebRtcVoiceEngine(
|
||||
LOG(LS_INFO) << ToString(codec);
|
||||
}
|
||||
|
||||
voe_config_.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true));
|
||||
channel_config_.enable_voice_pacing = true;
|
||||
|
||||
// Temporarily turn logging level up for the Init() call.
|
||||
webrtc::Trace::SetTraceCallback(this);
|
||||
@ -802,17 +801,14 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
|
||||
if (options.audio_jitter_buffer_max_packets) {
|
||||
LOG(LS_INFO) << "NetEq capacity is "
|
||||
<< *options.audio_jitter_buffer_max_packets;
|
||||
voe_config_.Set<webrtc::NetEqCapacityConfig>(
|
||||
new webrtc::NetEqCapacityConfig(
|
||||
*options.audio_jitter_buffer_max_packets));
|
||||
channel_config_.acm_config.neteq_config.max_packets_in_buffer =
|
||||
std::max(20, *options.audio_jitter_buffer_max_packets);
|
||||
}
|
||||
|
||||
if (options.audio_jitter_buffer_fast_accelerate) {
|
||||
LOG(LS_INFO) << "NetEq fast mode? "
|
||||
<< *options.audio_jitter_buffer_fast_accelerate;
|
||||
voe_config_.Set<webrtc::NetEqFastAccelerate>(
|
||||
new webrtc::NetEqFastAccelerate(
|
||||
*options.audio_jitter_buffer_fast_accelerate));
|
||||
channel_config_.acm_config.neteq_config.enable_fast_accelerate =
|
||||
*options.audio_jitter_buffer_fast_accelerate;
|
||||
}
|
||||
|
||||
if (options.typing_detection) {
|
||||
@ -1076,7 +1072,7 @@ void WebRtcVoiceEngine::StopAecDump() {
|
||||
|
||||
int WebRtcVoiceEngine::CreateVoEChannel() {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
return voe_wrapper_->base()->CreateChannel(voe_config_);
|
||||
return voe_wrapper_->base()->CreateChannel(channel_config_);
|
||||
}
|
||||
|
||||
webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#include "webrtc/base/stream.h"
|
||||
#include "webrtc/base/thread_checker.h"
|
||||
#include "webrtc/call.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/media/base/rtputils.h"
|
||||
#include "webrtc/media/engine/webrtccommon.h"
|
||||
@ -137,7 +136,7 @@ class WebRtcVoiceEngine final : public webrtc::TraceCallback {
|
||||
std::vector<AudioCodec> send_codecs_;
|
||||
std::vector<AudioCodec> recv_codecs_;
|
||||
std::vector<WebRtcVoiceMediaChannel*> channels_;
|
||||
webrtc::Config voe_config_;
|
||||
webrtc::VoEBase::ChannelConfig channel_config_;
|
||||
bool is_dumping_aec_ = false;
|
||||
|
||||
webrtc::AgcConfig default_agc_config_;
|
||||
|
||||
@ -322,6 +322,7 @@ if (rtc_include_tests) {
|
||||
"audio_processing/beamformer/matrix_unittest.cc",
|
||||
"audio_processing/beamformer/mock_nonlinear_beamformer.h",
|
||||
"audio_processing/beamformer/nonlinear_beamformer_unittest.cc",
|
||||
"audio_processing/config_unittest.cc",
|
||||
"audio_processing/echo_cancellation_impl_unittest.cc",
|
||||
"audio_processing/splitting_filter_unittest.cc",
|
||||
"audio_processing/transient/dyadic_decimator_unittest.cc",
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
|
||||
@ -48,7 +47,7 @@ void APITest::Wait(uint32_t waitLengthMs) {
|
||||
}
|
||||
}
|
||||
|
||||
APITest::APITest(const Config& config)
|
||||
APITest::APITest()
|
||||
: _acmA(AudioCodingModule::Create(1)),
|
||||
_acmB(AudioCodingModule::Create(2)),
|
||||
_channel_A2B(NULL),
|
||||
|
||||
@ -23,8 +23,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Config;
|
||||
|
||||
enum APITESTAction {
|
||||
TEST_CHANGE_CODEC_ONLY = 0,
|
||||
DTX_TEST = 1
|
||||
@ -32,7 +30,7 @@ enum APITESTAction {
|
||||
|
||||
class APITest : public ACMTest {
|
||||
public:
|
||||
explicit APITest(const Config& config);
|
||||
APITest();
|
||||
~APITest();
|
||||
|
||||
void Perform();
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -20,8 +20,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Config;
|
||||
|
||||
class TestPack : public AudioPacketizationCallback {
|
||||
public:
|
||||
TestPack();
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||
|
||||
@ -20,8 +20,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Config;
|
||||
|
||||
class TestRedFec : public ACMTest {
|
||||
public:
|
||||
explicit TestRedFec();
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
|
||||
|
||||
@ -128,10 +128,6 @@ class VADCallback : public ACMVADCallback {
|
||||
uint32_t _numFrameTypes[5];
|
||||
};
|
||||
|
||||
void UseLegacyAcm(webrtc::Config* config);
|
||||
|
||||
void UseNewAcm(webrtc::Config* config);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_TEST_UTILITY_H_
|
||||
|
||||
@ -71,6 +71,8 @@ rtc_source_set("audio_processing") {
|
||||
"high_pass_filter_impl.cc",
|
||||
"high_pass_filter_impl.h",
|
||||
"include/audio_processing.h",
|
||||
"include/config.cc",
|
||||
"include/config.h",
|
||||
"level_controller/biquad_filter.cc",
|
||||
"level_controller/biquad_filter.h",
|
||||
"level_controller/down_sampler.cc",
|
||||
|
||||
@ -83,6 +83,8 @@
|
||||
'high_pass_filter_impl.cc',
|
||||
'high_pass_filter_impl.h',
|
||||
'include/audio_processing.h',
|
||||
'include/config.cc',
|
||||
'include/config.h',
|
||||
'level_controller/biquad_filter.cc',
|
||||
'level_controller/biquad_filter.h',
|
||||
'level_controller/down_sampler.cc',
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/modules/audio_processing/include/config.h"
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -21,8 +21,8 @@
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/platform_file.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/modules/audio_processing/beamformer/array_util.h"
|
||||
#include "webrtc/modules/audio_processing/include/config.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/modules/audio_processing/include/config.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_COMMON_H_
|
||||
#define WEBRTC_COMMON_H_
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -23,10 +23,10 @@ namespace webrtc {
|
||||
enum class ConfigOptionID {
|
||||
kMyExperimentForTest,
|
||||
kAlgo1CostFunctionForTest,
|
||||
kTemporalLayersFactory,
|
||||
kNetEqCapacityConfig,
|
||||
kNetEqFastAccelerate,
|
||||
kVoicePacing,
|
||||
kTemporalLayersFactory, // Deprecated
|
||||
kNetEqCapacityConfig, // Deprecated
|
||||
kNetEqFastAccelerate, // Deprecated
|
||||
kVoicePacing, // Deprecated
|
||||
kExtendedFilter,
|
||||
kDelayAgnostic,
|
||||
kExperimentalAgc,
|
||||
@ -128,7 +128,6 @@ void Config::Set(T* value) {
|
||||
delete it;
|
||||
it = new Option<T>(value);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_COMMON_H_
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_CONFIG_H_
|
||||
@ -20,8 +20,8 @@
|
||||
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/audio_processing/include/config.h"
|
||||
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
|
||||
#include "webrtc/modules/audio_processing/test/test_utils.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
|
||||
@ -245,6 +245,7 @@
|
||||
'audio_processing/beamformer/matrix_unittest.cc',
|
||||
'audio_processing/beamformer/mock_nonlinear_beamformer.h',
|
||||
'audio_processing/beamformer/nonlinear_beamformer_unittest.cc',
|
||||
'audio_processing/config_unittest.cc',
|
||||
'audio_processing/echo_cancellation_impl_unittest.cc',
|
||||
'audio_processing/splitting_filter_unittest.cc',
|
||||
'audio_processing/transient/dyadic_decimator_unittest.cc',
|
||||
|
||||
@ -282,7 +282,6 @@ rtc_test("test_support_unittests") {
|
||||
"channel_transport/udp_socket_manager_unittest.cc",
|
||||
"channel_transport/udp_socket_wrapper_unittest.cc",
|
||||
"channel_transport/udp_transport_unittest.cc",
|
||||
"common_unittest.cc",
|
||||
"fake_network_pipe_unittest.cc",
|
||||
"frame_generator_unittest.cc",
|
||||
"rtp_file_reader_unittest.cc",
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/test/call_test.h"
|
||||
@ -312,9 +311,9 @@ void CallTest::CreateVoiceEngines() {
|
||||
voe_send_.codec = VoECodec::GetInterface(voe_send_.voice_engine);
|
||||
EXPECT_EQ(0, voe_send_.base->Init(fake_send_audio_device_.get(), nullptr,
|
||||
decoder_factory_));
|
||||
Config voe_config;
|
||||
voe_config.Set<VoicePacing>(new VoicePacing(true));
|
||||
voe_send_.channel_id = voe_send_.base->CreateChannel(voe_config);
|
||||
VoEBase::ChannelConfig config;
|
||||
config.enable_voice_pacing = true;
|
||||
voe_send_.channel_id = voe_send_.base->CreateChannel(config);
|
||||
EXPECT_GE(voe_send_.channel_id, 0);
|
||||
|
||||
voe_recv_.voice_engine = VoiceEngine::Create();
|
||||
|
||||
@ -30,8 +30,7 @@ class MockVoiceEngine : public VoiceEngineImpl {
|
||||
// http://crbug.com/428099.
|
||||
MockVoiceEngine(
|
||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory = nullptr)
|
||||
: VoiceEngineImpl(new Config(), true),
|
||||
decoder_factory_(decoder_factory) {
|
||||
: decoder_factory_(decoder_factory) {
|
||||
// Increase ref count so this object isn't automatically deleted whenever
|
||||
// interfaces are Release():d.
|
||||
++_ref_count;
|
||||
@ -123,7 +122,7 @@ class MockVoiceEngine : public VoiceEngineImpl {
|
||||
MOCK_METHOD0(audio_processing, AudioProcessing*());
|
||||
MOCK_METHOD0(Terminate, int());
|
||||
MOCK_METHOD0(CreateChannel, int());
|
||||
MOCK_METHOD1(CreateChannel, int(const Config& config));
|
||||
MOCK_METHOD1(CreateChannel, int(const ChannelConfig& config));
|
||||
MOCK_METHOD1(DeleteChannel, int(int channel));
|
||||
MOCK_METHOD1(StartReceive, int(int channel));
|
||||
MOCK_METHOD1(StopReceive, int(int channel));
|
||||
|
||||
@ -210,7 +210,6 @@
|
||||
'<(DEPTH)/testing/gtest.gyp:gtest',
|
||||
],
|
||||
'sources': [
|
||||
'common_unittest.cc',
|
||||
'fake_network_pipe_unittest.cc',
|
||||
'frame_generator_unittest.cc',
|
||||
'rtp_file_reader_unittest.cc',
|
||||
|
||||
@ -70,9 +70,9 @@ void CreateVoiceEngine(VoiceEngineState* voe,
|
||||
voe->base = webrtc::VoEBase::GetInterface(voe->voice_engine);
|
||||
voe->codec = webrtc::VoECodec::GetInterface(voe->voice_engine);
|
||||
EXPECT_EQ(0, voe->base->Init(nullptr, nullptr, decoder_factory));
|
||||
webrtc::Config voe_config;
|
||||
voe_config.Set<webrtc::VoicePacing>(new webrtc::VoicePacing(true));
|
||||
voe->send_channel_id = voe->base->CreateChannel(voe_config);
|
||||
webrtc::VoEBase::ChannelConfig config;
|
||||
config.enable_voice_pacing = true;
|
||||
voe->send_channel_id = voe->base->CreateChannel(config);
|
||||
EXPECT_GE(voe->send_channel_id, 0);
|
||||
voe->receive_channel_id = voe->base->CreateChannel();
|
||||
EXPECT_GE(voe->receive_channel_id, 0);
|
||||
|
||||
@ -28,7 +28,6 @@ namespace webrtc {
|
||||
|
||||
class CallStatsObserver;
|
||||
class ChannelStatsObserver;
|
||||
class Config;
|
||||
class EncodedImageCallback;
|
||||
class I420FrameCallback;
|
||||
class ReceiveStatisticsProxy;
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#include "webrtc/base/thread_checker.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/call/rtc_event_log.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
@ -34,7 +33,6 @@
|
||||
#include "webrtc/modules/utility/include/audio_frame_operations.h"
|
||||
#include "webrtc/modules/utility/include/process_thread.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
#include "webrtc/voice_engine/include/voe_base.h"
|
||||
#include "webrtc/voice_engine/include/voe_external_media.h"
|
||||
#include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
|
||||
#include "webrtc/voice_engine/output_mixer.h"
|
||||
@ -754,13 +752,12 @@ int32_t Channel::CreateChannel(
|
||||
Channel*& channel,
|
||||
int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
const VoEBase::ChannelConfig& config) {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
|
||||
"Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId,
|
||||
instanceId);
|
||||
|
||||
channel = new Channel(channelId, instanceId, config, decoder_factory);
|
||||
channel = new Channel(channelId, instanceId, config);
|
||||
if (channel == NULL) {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
|
||||
"Channel::CreateChannel() unable to allocate memory for"
|
||||
@ -819,8 +816,7 @@ void Channel::RecordFileEnded(int32_t id) {
|
||||
|
||||
Channel::Channel(int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)
|
||||
const VoEBase::ChannelConfig& config)
|
||||
: _instanceId(instanceId),
|
||||
_channelId(channelId),
|
||||
event_log_proxy_(new RtcEventLogProxy()),
|
||||
@ -886,27 +882,18 @@ Channel::Channel(int32_t channelId,
|
||||
rtcp_observer_(new VoERtcpObserver(this)),
|
||||
network_predictor_(new NetworkPredictor(Clock::GetRealTimeClock())),
|
||||
associate_send_channel_(ChannelOwner(nullptr)),
|
||||
pacing_enabled_(config.Get<VoicePacing>().enabled),
|
||||
pacing_enabled_(config.enable_voice_pacing),
|
||||
feedback_observer_proxy_(new TransportFeedbackProxy()),
|
||||
seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
|
||||
rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
|
||||
retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
|
||||
kMaxRetransmissionWindowMs)),
|
||||
decoder_factory_(decoder_factory) {
|
||||
decoder_factory_(config.acm_config.decoder_factory) {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
|
||||
"Channel::Channel() - ctor");
|
||||
AudioCodingModule::Config acm_config;
|
||||
AudioCodingModule::Config acm_config(config.acm_config);
|
||||
acm_config.id = VoEModuleId(instanceId, channelId);
|
||||
if (config.Get<NetEqCapacityConfig>().enabled) {
|
||||
// Clamping the buffer capacity at 20 packets. While going lower will
|
||||
// probably work, it makes little sense.
|
||||
acm_config.neteq_config.max_packets_in_buffer =
|
||||
std::max(20, config.Get<NetEqCapacityConfig>().capacity);
|
||||
}
|
||||
acm_config.neteq_config.enable_fast_accelerate =
|
||||
config.Get<NetEqFastAccelerate>().enabled;
|
||||
acm_config.neteq_config.enable_muted_state = true;
|
||||
acm_config.decoder_factory = decoder_factory;
|
||||
audio_coding_.reset(AudioCodingModule::Create(acm_config));
|
||||
|
||||
_outputAudioLevel.Clear();
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "webrtc/modules/utility/include/file_player.h"
|
||||
#include "webrtc/modules/utility/include/file_recorder.h"
|
||||
#include "webrtc/voice_engine/include/voe_audio_processing.h"
|
||||
#include "webrtc/voice_engine/include/voe_base.h"
|
||||
#include "webrtc/voice_engine/include/voe_network.h"
|
||||
#include "webrtc/voice_engine/level_indicator.h"
|
||||
#include "webrtc/voice_engine/network_predictor.h"
|
||||
@ -42,7 +43,6 @@ class TimestampWrapAroundHandler;
|
||||
namespace webrtc {
|
||||
|
||||
class AudioDeviceModule;
|
||||
class Config;
|
||||
class FileWrapper;
|
||||
class PacketRouter;
|
||||
class ProcessThread;
|
||||
@ -175,12 +175,10 @@ class Channel
|
||||
Channel*& channel,
|
||||
int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
const VoEBase::ChannelConfig& config);
|
||||
Channel(int32_t channelId,
|
||||
uint32_t instanceId,
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
const VoEBase::ChannelConfig& config);
|
||||
int32_t Init();
|
||||
int32_t SetEngineInformation(Statistics& engineStatistics,
|
||||
OutputMixer& outputMixer,
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#include "webrtc/voice_engine/channel_manager.h"
|
||||
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/voice_engine/channel.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -45,26 +44,13 @@ ChannelOwner& ChannelOwner::operator=(const ChannelOwner& other) {
|
||||
ChannelOwner::ChannelRef::ChannelRef(class Channel* channel)
|
||||
: channel(channel), ref_count(1) {}
|
||||
|
||||
ChannelManager::ChannelManager(uint32_t instance_id, const Config& config)
|
||||
: instance_id_(instance_id), last_channel_id_(-1), config_(config) {}
|
||||
ChannelManager::ChannelManager(uint32_t instance_id)
|
||||
: instance_id_(instance_id), last_channel_id_(-1) {}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannel(
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
return CreateChannelInternal(config_, decoder_factory);
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannel(
|
||||
const Config& external_config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
return CreateChannelInternal(external_config, decoder_factory);
|
||||
}
|
||||
|
||||
ChannelOwner ChannelManager::CreateChannelInternal(
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
const VoEBase::ChannelConfig& config) {
|
||||
Channel* channel;
|
||||
Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config,
|
||||
decoder_factory);
|
||||
Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config);
|
||||
ChannelOwner channel_owner(channel);
|
||||
|
||||
rtc::CritScope crit(&lock_);
|
||||
|
||||
@ -19,10 +19,10 @@
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/system_wrappers/include/atomic32.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/voice_engine/include/voe_base.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Config;
|
||||
class AudioDecoderFactory;
|
||||
|
||||
namespace voe {
|
||||
@ -72,7 +72,7 @@ class ChannelOwner {
|
||||
|
||||
class ChannelManager {
|
||||
public:
|
||||
ChannelManager(uint32_t instance_id, const Config& config);
|
||||
ChannelManager(uint32_t instance_id);
|
||||
|
||||
// Upon construction of an Iterator it will grab a copy of the channel list of
|
||||
// the ChannelManager. The iteration will then occur over this state, not the
|
||||
@ -95,16 +95,8 @@ class ChannelManager {
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Iterator);
|
||||
};
|
||||
|
||||
// CreateChannel will always return a valid ChannelOwner instance. The channel
|
||||
// is created either based on internal configuration, i.e. |config_|, by
|
||||
// calling CreateChannel(...), or using and external configuration
|
||||
// |external_config| if the overloaded method
|
||||
// CreateChannel(const Config& external_config, ...) is called.
|
||||
ChannelOwner CreateChannel(
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
ChannelOwner CreateChannel(
|
||||
const Config& external_config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
// CreateChannel will always return a valid ChannelOwner instance.
|
||||
ChannelOwner CreateChannel(const VoEBase::ChannelConfig& config);
|
||||
|
||||
// ChannelOwner.channel() will be NULL if channel_id is invalid or no longer
|
||||
// exists. This should be checked with ChannelOwner::IsValid().
|
||||
@ -117,11 +109,6 @@ class ChannelManager {
|
||||
size_t NumOfChannels() const;
|
||||
|
||||
private:
|
||||
// Create a channel given a configuration, |config|.
|
||||
ChannelOwner CreateChannelInternal(
|
||||
const Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
|
||||
uint32_t instance_id_;
|
||||
|
||||
Atomic32 last_channel_id_;
|
||||
@ -129,8 +116,6 @@ class ChannelManager {
|
||||
rtc::CriticalSection lock_;
|
||||
std::vector<ChannelOwner> channels_;
|
||||
|
||||
const Config& config_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelManager);
|
||||
};
|
||||
} // namespace voe
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -43,9 +44,6 @@ namespace webrtc {
|
||||
class AudioDeviceModule;
|
||||
class AudioProcessing;
|
||||
class AudioTransport;
|
||||
class Config;
|
||||
|
||||
const int kVoEDefault = -1;
|
||||
|
||||
// VoiceEngineObserver
|
||||
class WEBRTC_DLLEXPORT VoiceEngineObserver {
|
||||
@ -65,7 +63,6 @@ class WEBRTC_DLLEXPORT VoiceEngine {
|
||||
// Creates a VoiceEngine object, which can then be used to acquire
|
||||
// sub-APIs. Returns NULL on failure.
|
||||
static VoiceEngine* Create();
|
||||
static VoiceEngine* Create(const Config& config);
|
||||
|
||||
// Deletes a created VoiceEngine object and releases the utilized resources.
|
||||
// Note that if there are outstanding references held via other interfaces,
|
||||
@ -99,6 +96,11 @@ class WEBRTC_DLLEXPORT VoiceEngine {
|
||||
// VoEBase
|
||||
class WEBRTC_DLLEXPORT VoEBase {
|
||||
public:
|
||||
struct ChannelConfig {
|
||||
AudioCodingModule::Config acm_config;
|
||||
bool enable_voice_pacing = false;
|
||||
};
|
||||
|
||||
// Factory for the VoEBase sub-API. Increases an internal reference
|
||||
// counter if successful. Returns NULL if the API is not supported or if
|
||||
// construction fails.
|
||||
@ -146,11 +148,13 @@ class WEBRTC_DLLEXPORT VoEBase {
|
||||
virtual int Terminate() = 0;
|
||||
|
||||
// Creates a new channel and allocates the required resources for it.
|
||||
// One can use |config| to configure the channel. Currently that is used for
|
||||
// choosing between ACM1 and ACM2, when creating Audio Coding Module.
|
||||
// The second version accepts a |config| struct which includes an Audio Coding
|
||||
// Module config and an option to enable voice pacing. Note that the
|
||||
// decoder_factory member of the ACM config will be ignored (the decoder
|
||||
// factory set through Init() will always be used).
|
||||
// Returns channel ID or -1 in case of an error.
|
||||
virtual int CreateChannel() = 0;
|
||||
virtual int CreateChannel(const Config& config) = 0;
|
||||
virtual int CreateChannel(const ChannelConfig& config) = 0;
|
||||
|
||||
// Deletes an existing channel and releases the utilized resources.
|
||||
// Returns -1 in case of an error, 0 otherwise.
|
||||
|
||||
@ -22,9 +22,9 @@ namespace voe {
|
||||
|
||||
static int32_t _gInstanceCounter = 0;
|
||||
|
||||
SharedData::SharedData(const Config& config)
|
||||
SharedData::SharedData()
|
||||
: _instanceId(++_gInstanceCounter),
|
||||
_channelManager(_gInstanceCounter, config),
|
||||
_channelManager(_gInstanceCounter),
|
||||
_engineStatistics(_gInstanceCounter),
|
||||
_audioDevicePtr(NULL),
|
||||
_moduleProcessThreadPtr(
|
||||
|
||||
@ -25,8 +25,6 @@
|
||||
class ProcessThread;
|
||||
|
||||
namespace webrtc {
|
||||
class Config;
|
||||
|
||||
namespace voe {
|
||||
|
||||
class TransmitMixer;
|
||||
@ -77,11 +75,10 @@ protected:
|
||||
|
||||
AudioDeviceModule::AudioLayer _audioDeviceLayer;
|
||||
|
||||
SharedData(const Config& config);
|
||||
SharedData();
|
||||
virtual ~SharedData();
|
||||
};
|
||||
|
||||
} // namespace voe
|
||||
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_VOICE_ENGINE_SHARED_DATA_H
|
||||
|
||||
@ -11,9 +11,6 @@
|
||||
#ifndef SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_H_
|
||||
#define SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_H_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/voice_engine/include/voe_audio_processing.h"
|
||||
@ -65,7 +62,6 @@ class BeforeInitializationFixture : public testing::Test {
|
||||
webrtc::VoEHardware* voe_hardware_;
|
||||
webrtc::VoEExternalMedia* voe_xmedia_;
|
||||
webrtc::VoENetEqStats* voe_neteq_stats_;
|
||||
webrtc::Config config_;
|
||||
};
|
||||
|
||||
#endif // SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_H_
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
@ -355,25 +354,20 @@ int VoEBaseImpl::Terminate() {
|
||||
}
|
||||
|
||||
int VoEBaseImpl::CreateChannel() {
|
||||
rtc::CritScope cs(shared_->crit_sec());
|
||||
if (!shared_->statistics().Initialized()) {
|
||||
shared_->SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
|
||||
voe::ChannelOwner channel_owner =
|
||||
shared_->channel_manager().CreateChannel(decoder_factory_);
|
||||
return InitializeChannel(&channel_owner);
|
||||
return CreateChannel(ChannelConfig());
|
||||
}
|
||||
|
||||
int VoEBaseImpl::CreateChannel(const Config& config) {
|
||||
int VoEBaseImpl::CreateChannel(const ChannelConfig& config) {
|
||||
rtc::CritScope cs(shared_->crit_sec());
|
||||
if (!shared_->statistics().Initialized()) {
|
||||
shared_->SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ChannelConfig config_copy(config);
|
||||
config_copy.acm_config.decoder_factory = decoder_factory_;
|
||||
voe::ChannelOwner channel_owner =
|
||||
shared_->channel_manager().CreateChannel(config, decoder_factory_);
|
||||
shared_->channel_manager().CreateChannel(config_copy);
|
||||
return InitializeChannel(&channel_owner);
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ class VoEBaseImpl : public VoEBase,
|
||||
int Terminate() override;
|
||||
|
||||
int CreateChannel() override;
|
||||
int CreateChannel(const Config& config) override;
|
||||
int CreateChannel(const ChannelConfig& config) override;
|
||||
int DeleteChannel(int channel) override;
|
||||
|
||||
int StartReceive(int channel) override;
|
||||
|
||||
@ -29,8 +29,8 @@ namespace webrtc {
|
||||
// improvement here.
|
||||
static int32_t gVoiceEngineInstanceCounter = 0;
|
||||
|
||||
VoiceEngine* GetVoiceEngine(const Config* config, bool owns_config) {
|
||||
VoiceEngineImpl* self = new VoiceEngineImpl(config, owns_config);
|
||||
VoiceEngine* GetVoiceEngine() {
|
||||
VoiceEngineImpl* self = new VoiceEngineImpl();
|
||||
if (self != NULL) {
|
||||
self->AddRef(); // First reference. Released in VoiceEngine::Delete.
|
||||
gVoiceEngineInstanceCounter++;
|
||||
@ -72,12 +72,7 @@ std::unique_ptr<voe::ChannelProxy> VoiceEngineImpl::GetChannelProxy(
|
||||
}
|
||||
|
||||
VoiceEngine* VoiceEngine::Create() {
|
||||
Config* config = new Config();
|
||||
return GetVoiceEngine(config, true);
|
||||
}
|
||||
|
||||
VoiceEngine* VoiceEngine::Create(const Config& config) {
|
||||
return GetVoiceEngine(&config, false);
|
||||
return GetVoiceEngine();
|
||||
}
|
||||
|
||||
int VoiceEngine::SetTraceFilter(unsigned int filter) {
|
||||
|
||||
@ -83,8 +83,8 @@ class VoiceEngineImpl : public voe::SharedData, // Must be the first base class
|
||||
#endif
|
||||
public VoEBaseImpl {
|
||||
public:
|
||||
VoiceEngineImpl(const Config* config, bool owns_config)
|
||||
: SharedData(*config),
|
||||
VoiceEngineImpl()
|
||||
: SharedData(),
|
||||
#ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
|
||||
VoEAudioProcessingImpl(this),
|
||||
#endif
|
||||
@ -114,9 +114,7 @@ class VoiceEngineImpl : public voe::SharedData, // Must be the first base class
|
||||
VoEVolumeControlImpl(this),
|
||||
#endif
|
||||
VoEBaseImpl(this),
|
||||
_ref_count(0),
|
||||
own_config_(owns_config ? config : NULL) {
|
||||
}
|
||||
_ref_count(0) {}
|
||||
~VoiceEngineImpl() override { assert(_ref_count.Value() == 0); }
|
||||
|
||||
int AddRef();
|
||||
@ -132,8 +130,6 @@ class VoiceEngineImpl : public voe::SharedData, // Must be the first base class
|
||||
// manipulate the reference count. See: fake_voice_engine.h.
|
||||
protected:
|
||||
Atomic32 _ref_count;
|
||||
private:
|
||||
std::unique_ptr<const Config> own_config_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user