Enable injection of a custom NetEqFactory into PeerConnectionFactory.

Injecting both a custom NetEqFactory and an AudioDecoderFactory is not
supported, in that case the AudioDecoderFactory should be wrapped inside
the NetEqFactory.

Bug: webrtc:11005
Change-Id: I4e311eb1bfa03c91bca587d70540e81829f881c9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158720
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29673}
This commit is contained in:
Ivo Creusen
2019-11-01 11:47:51 +01:00
committed by Commit Bot
parent 2ebbff83ee
commit c3d1f9b0cd
15 changed files with 50 additions and 13 deletions

View File

@ -37,19 +37,28 @@ namespace acm2 {
namespace {
std::unique_ptr<NetEq> CreateNetEq(
NetEqFactory* neteq_factory,
const NetEq::Config& config,
Clock* clock,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
CustomNetEqFactory neteq_factory(
RTC_CHECK((neteq_factory == nullptr) || (decoder_factory.get() == nullptr))
<< "Either a NetEqFactory or a AudioDecoderFactory should be injected, "
"supplying both is not supported. Please wrap the AudioDecoderFactory "
"inside the NetEqFactory when using both.";
if (neteq_factory) {
return neteq_factory->CreateNetEq(config, clock);
}
CustomNetEqFactory custom_factory(
decoder_factory, std::make_unique<DefaultNetEqControllerFactory>());
return neteq_factory.CreateNetEq(config, clock);
return custom_factory.CreateNetEq(config, clock);
}
} // namespace
AcmReceiver::AcmReceiver(const AudioCodingModule::Config& config)
: last_audio_buffer_(new int16_t[AudioFrame::kMaxDataSizeSamples]),
neteq_(CreateNetEq(config.neteq_config,
neteq_(CreateNetEq(config.neteq_factory,
config.neteq_config,
config.clock,
config.decoder_factory)),
clock_(config.clock),

View File

@ -21,6 +21,7 @@
#include "api/audio_codecs/audio_encoder.h"
#include "api/function_view.h"
#include "api/neteq/neteq.h"
#include "api/neteq/neteq_factory.h"
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "system_wrappers/include/clock.h"
@ -68,6 +69,7 @@ class AudioCodingModule {
NetEq::Config neteq_config;
Clock* clock;
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory;
NetEqFactory* neteq_factory = nullptr;
};
static AudioCodingModule* Create(const Config& config);