mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-16 15:20:42 +01:00
Moved injection of AudioDecoderFactory into voe::Channel.
Channel's API remains unchanged, but the creation of a BuiltinAudioDecoderFactory is now in Channel. The next step would be to amend Channel's API (through CreateChannel, I believe) to allow an AudioDecoderFactory to be sent along. BUG=webrtc:5805 Review-Url: https://codereview.webrtc.org/1992763002 Cr-Commit-Position: refs/heads/master@{#12893}
This commit is contained in:
parent
57779104f0
commit
e352578bc8
19 changed files with 62 additions and 19 deletions
|
@ -49,7 +49,7 @@ bool IsCng(int codec_id) {
|
|||
AcmReceiver::AcmReceiver(const AudioCodingModule::Config& config)
|
||||
: last_audio_decoder_(nullptr),
|
||||
last_audio_buffer_(new int16_t[AudioFrame::kMaxDataSizeSamples]),
|
||||
neteq_(NetEq::Create(config.neteq_config)),
|
||||
neteq_(NetEq::Create(config.neteq_config, config.decoder_factory)),
|
||||
clock_(config.clock),
|
||||
resampled_last_output_frame_(true) {
|
||||
assert(clock_);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#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/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/test/test_suite.h"
|
||||
|
@ -60,6 +61,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
|
|||
packet_sent_(false),
|
||||
last_packet_send_timestamp_(timestamp_),
|
||||
last_frame_type_(kEmptyFrame) {
|
||||
config_.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
}
|
||||
|
||||
~AcmReceiverTestOldApi() {}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
|
||||
|
@ -24,6 +25,7 @@ AudioCodingModule* AudioCodingModule::Create(int id) {
|
|||
Config config;
|
||||
config.id = id;
|
||||
config.clock = Clock::GetRealTimeClock();
|
||||
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
return Create(config);
|
||||
}
|
||||
|
||||
|
@ -31,10 +33,18 @@ AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
|
|||
Config config;
|
||||
config.id = id;
|
||||
config.clock = clock;
|
||||
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
return Create(config);
|
||||
}
|
||||
|
||||
AudioCodingModule* AudioCodingModule::Create(const Config& config) {
|
||||
if (!config.decoder_factory) {
|
||||
// TODO(ossu): Backwards compatibility. Will be removed after a deprecation
|
||||
// cycle.
|
||||
Config config_copy = config;
|
||||
config_copy.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
return new acm2::AudioCodingModuleImpl(config_copy);
|
||||
}
|
||||
return new acm2::AudioCodingModuleImpl(config);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "webrtc/base/deprecation.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
|
||||
#include "webrtc/modules/include/module.h"
|
||||
|
@ -72,6 +73,7 @@ class AudioCodingModule {
|
|||
int id;
|
||||
NetEq::Config neteq_config;
|
||||
Clock* clock;
|
||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
@ -26,6 +27,7 @@ namespace webrtc {
|
|||
// Forward declarations.
|
||||
class AudioFrame;
|
||||
struct WebRtcRTPHeader;
|
||||
class AudioDecoderFactory;
|
||||
|
||||
struct NetEqNetworkStatistics {
|
||||
uint16_t current_buffer_size_ms; // Current jitter buffer size in ms.
|
||||
|
@ -133,7 +135,9 @@ class NetEq {
|
|||
// Creates a new NetEq object, with parameters set in |config|. The |config|
|
||||
// object will only have to be valid for the duration of the call to this
|
||||
// method.
|
||||
static NetEq* Create(const NetEq::Config& config);
|
||||
static NetEq* Create(
|
||||
const NetEq::Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
|
||||
virtual ~NetEq() {}
|
||||
|
||||
|
|
|
@ -34,8 +34,11 @@ std::string NetEq::Config::ToString() const {
|
|||
|
||||
// Creates all classes needed and inject them into a new NetEqImpl object.
|
||||
// Return the new object.
|
||||
NetEq* NetEq::Create(const NetEq::Config& config) {
|
||||
return new NetEqImpl(config, NetEqImpl::Dependencies(config));
|
||||
NetEq* NetEq::Create(
|
||||
const NetEq::Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
|
||||
return new NetEqImpl(config,
|
||||
NetEqImpl::Dependencies(config, decoder_factory));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h"
|
||||
|
@ -178,7 +179,8 @@ class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest,
|
|||
NetEq::Config config;
|
||||
config.sample_rate_hz =
|
||||
CodecSampleRateHz(NetEqDecoder::kDecoderPCM16Bswb32kHz);
|
||||
neteq_internal_.reset(NetEq::Create(config));
|
||||
neteq_internal_.reset(
|
||||
NetEq::Create(config, CreateBuiltinAudioDecoderFactory()));
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "webrtc/base/trace_event.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/accelerate.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/background_noise.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/buffer_level_filter.h"
|
||||
|
@ -55,10 +54,12 @@
|
|||
|
||||
namespace webrtc {
|
||||
|
||||
NetEqImpl::Dependencies::Dependencies(const NetEq::Config& config)
|
||||
NetEqImpl::Dependencies::Dependencies(
|
||||
const NetEq::Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)
|
||||
: tick_timer(new TickTimer),
|
||||
buffer_level_filter(new BufferLevelFilter),
|
||||
decoder_database(new DecoderDatabase(CreateBuiltinAudioDecoderFactory())),
|
||||
decoder_database(new DecoderDatabase(decoder_factory)),
|
||||
delay_peak_detector(new DelayPeakDetector(tick_timer.get())),
|
||||
delay_manager(new DelayManager(config.max_packets_in_buffer,
|
||||
delay_peak_detector.get(),
|
||||
|
|
|
@ -72,7 +72,9 @@ class NetEqImpl : public webrtc::NetEq {
|
|||
// before sending the struct to the NetEqImpl constructor. However, there
|
||||
// are dependencies between some of the classes inside the struct, so
|
||||
// swapping out one may make it necessary to re-create another one.
|
||||
explicit Dependencies(const NetEq::Config& config);
|
||||
explicit Dependencies(
|
||||
const NetEq::Config& config,
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
|
||||
~Dependencies();
|
||||
|
||||
std::unique_ptr<TickTimer> tick_timer;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/safe_conversions.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/accelerate.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/expand.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
|
||||
|
@ -59,7 +60,7 @@ class NetEqImplTest : public ::testing::Test {
|
|||
NetEqImplTest() { config_.sample_rate_hz = 8000; }
|
||||
|
||||
void CreateInstance() {
|
||||
NetEqImpl::Dependencies deps(config_);
|
||||
NetEqImpl::Dependencies deps(config_, CreateBuiltinAudioDecoderFactory());
|
||||
|
||||
// Get a local pointer to NetEq's TickTimer object.
|
||||
tick_timer_ = deps.tick_timer.get();
|
||||
|
@ -205,7 +206,7 @@ class NetEqImplTest : public ::testing::Test {
|
|||
// TODO(hlundin): Move to separate file?
|
||||
TEST(NetEq, CreateAndDestroy) {
|
||||
NetEq::Config config;
|
||||
NetEq* neteq = NetEq::Create(config);
|
||||
NetEq* neteq = NetEq::Create(config, CreateBuiltinAudioDecoderFactory());
|
||||
delete neteq;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <list>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
|
||||
|
@ -63,8 +64,10 @@ class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> {
|
|||
last_arrival_time_(0) {
|
||||
NetEq::Config config;
|
||||
config.sample_rate_hz = sample_rate_hz_;
|
||||
neteq_mono_ = NetEq::Create(config);
|
||||
neteq_ = NetEq::Create(config);
|
||||
rtc::scoped_refptr<AudioDecoderFactory> factory =
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
neteq_mono_ = NetEq::Create(config, factory);
|
||||
neteq_ = NetEq::Create(config, factory);
|
||||
input_ = new int16_t[frame_size_samples_];
|
||||
encoded_ = new uint8_t[2 * frame_size_samples_];
|
||||
input_multi_channel_ = new int16_t[frame_size_samples_ * num_channels_];
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/sha1digest.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
|
||||
|
@ -315,7 +316,7 @@ NetEqDecodingTest::NetEqDecodingTest()
|
|||
}
|
||||
|
||||
void NetEqDecodingTest::SetUp() {
|
||||
neteq_ = NetEq::Create(config_);
|
||||
neteq_ = NetEq::Create(config_, CreateBuiltinAudioDecoderFactory());
|
||||
NetEqNetworkStatistics stat;
|
||||
ASSERT_EQ(0, neteq_->NetworkStatistics(&stat));
|
||||
algorithmic_delay_ms_ = stat.current_buffer_size_ms;
|
||||
|
@ -1666,7 +1667,7 @@ class NetEqDecodingTestTwoInstances : public NetEqDecodingTest {
|
|||
}
|
||||
|
||||
void CreateSecondInstance() {
|
||||
neteq2_.reset(NetEq::Create(config2_));
|
||||
neteq2_.reset(NetEq::Create(config2_, CreateBuiltinAudioDecoderFactory()));
|
||||
ASSERT_TRUE(neteq2_);
|
||||
LoadDecoders(neteq2_.get());
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/format_macros.h"
|
||||
|
||||
|
@ -25,7 +26,7 @@ NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec,
|
|||
channels_(decoder_->Channels()) {
|
||||
NetEq::Config config;
|
||||
config.sample_rate_hz = sample_rate_hz_;
|
||||
neteq_.reset(NetEq::Create(config));
|
||||
neteq_.reset(NetEq::Create(config, CreateBuiltinAudioDecoderFactory()));
|
||||
printf("%" PRIuS "\n", channels_);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
|
||||
|
@ -42,7 +43,7 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms,
|
|||
// Initialize NetEq instance.
|
||||
NetEq::Config config;
|
||||
config.sample_rate_hz = kSampRateHz;
|
||||
NetEq* neteq = NetEq::Create(config);
|
||||
NetEq* neteq = NetEq::Create(config, CreateBuiltinAudioDecoderFactory());
|
||||
// Register decoder in |neteq|.
|
||||
if (neteq->RegisterPayloadType(kDecoderType, kDecoderName, kPayloadType) != 0)
|
||||
return -1;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/output_wav_file.h"
|
||||
|
@ -245,7 +246,8 @@ NetEqQualityTest::NetEqQualityTest(int block_duration_ms,
|
|||
|
||||
NetEq::Config config;
|
||||
config.sample_rate_hz = out_sampling_khz_ * 1000;
|
||||
neteq_.reset(NetEq::Create(config));
|
||||
neteq_.reset(
|
||||
NetEq::Create(config, webrtc::CreateBuiltinAudioDecoderFactory()));
|
||||
max_payload_bytes_ = in_size_samples_ * channels_ * sizeof(int16_t);
|
||||
in_data_.reset(new int16_t[in_size_samples_ * channels_]);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "gflags/gflags.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/safe_conversions.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
|
||||
|
@ -474,7 +475,8 @@ int main(int argc, char* argv[]) {
|
|||
// Initialize NetEq instance.
|
||||
NetEq::Config config;
|
||||
config.sample_rate_hz = sample_rate_hz;
|
||||
NetEq* neteq = NetEq::Create(config);
|
||||
NetEq* neteq =
|
||||
NetEq::Create(config, CreateBuiltinAudioDecoderFactory());
|
||||
RegisterPayloadTypes(neteq);
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_coding/test/PCMFile.h"
|
||||
#include "webrtc/modules/audio_coding/test/utility.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
|
@ -40,6 +41,7 @@ TwoWayCommunication::TwoWayCommunication(int testMode)
|
|||
// The clicks will be more obvious in FAX mode. TODO(henrik.lundin) Really?
|
||||
config.neteq_config.playout_mode = kPlayoutFax;
|
||||
config.id = 2;
|
||||
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
_acmB.reset(AudioCodingModule::Create(config));
|
||||
config.id = 4;
|
||||
_acmRefB.reset(AudioCodingModule::Create(config));
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/utility/source/coder.h"
|
||||
|
||||
|
@ -19,6 +20,7 @@ AudioCodingModule::Config GetAcmConfig(uint32_t id) {
|
|||
// This class does not handle muted output.
|
||||
config.neteq_config.enable_muted_state = false;
|
||||
config.id = id;
|
||||
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
return config;
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/config.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
|
@ -825,6 +826,7 @@ Channel::Channel(int32_t channelId,
|
|||
acm_config.neteq_config.enable_fast_accelerate =
|
||||
config.Get<NetEqFastAccelerate>().enabled;
|
||||
acm_config.neteq_config.enable_muted_state = true;
|
||||
acm_config.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
||||
audio_coding_.reset(AudioCodingModule::Create(acm_config));
|
||||
|
||||
_outputAudioLevel.Clear();
|
||||
|
|
Loading…
Reference in a new issue