Add CreatePeerConnectionFactory overloads that take audio codec factory args
BUG=5805 Review-Url: https://codereview.webrtc.org/2653343003 Cr-Commit-Position: refs/heads/master@{#16371}
This commit is contained in:
parent
7ce109acd3
commit
1e4e8cb43d
@ -11,4 +11,10 @@ specific_include_rules = {
|
||||
"peerconnection_jni\.cc": [
|
||||
"+webrtc/voice_engine",
|
||||
],
|
||||
|
||||
# TODO(kwiberg): Remove this exception when audio_decoder_factory.h
|
||||
# has moved to api/.
|
||||
"peerconnectioninterface\.h": [
|
||||
"+webrtc/modules/audio_coding/codecs/audio_decoder_factory.h",
|
||||
],
|
||||
}
|
||||
|
||||
@ -73,6 +73,7 @@
|
||||
#include "webrtc/base/socketaddress.h"
|
||||
#include "webrtc/base/sslstreamadapter.h"
|
||||
#include "webrtc/media/base/mediachannel.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_decoder_factory.h"
|
||||
#include "webrtc/p2p/base/portallocator.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -830,6 +831,14 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
|
||||
~PeerConnectionFactoryInterface() {} // NOLINT
|
||||
};
|
||||
|
||||
// TODO(ossu): Remove these and define a real builtin audio encoder factory
|
||||
// instead.
|
||||
class AudioEncoderFactory : public rtc::RefCountInterface {};
|
||||
inline rtc::scoped_refptr<AudioEncoderFactory>
|
||||
CreateBuiltinAudioEncoderFactory() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Create a new instance of PeerConnectionFactoryInterface.
|
||||
//
|
||||
// This method relies on the thread it's called on as the "signaling thread"
|
||||
@ -840,6 +849,12 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
|
||||
// rtc::Thread::Current()->Run(), or call
|
||||
// rtc::Thread::Current()->ProcessMessages() within the application's own
|
||||
// message loop.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory);
|
||||
|
||||
// Deprecated variant of the above.
|
||||
// TODO(kwiberg): Remove.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory();
|
||||
|
||||
@ -850,6 +865,18 @@ CreatePeerConnectionFactory();
|
||||
//
|
||||
// If non-null, ownership of |default_adm|, |encoder_factory| and
|
||||
// |decoder_factory| are transferred to the returned factory.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
|
||||
|
||||
// Deprecated variant of the above.
|
||||
// TODO(kwiberg): Remove.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
@ -863,6 +890,20 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
//
|
||||
// If |audio_mixer| is null, an internal audio mixer will be created and used.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer);
|
||||
|
||||
// Deprecated variant of the above.
|
||||
// TODO(kwiberg): Remove.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
@ -875,6 +916,23 @@ CreatePeerConnectionFactoryWithAudioMixer(
|
||||
// Create a new instance of PeerConnectionFactoryInterface.
|
||||
// Same thread is used as worker and network thread.
|
||||
inline rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory(
|
||||
rtc::Thread* worker_and_network_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory) {
|
||||
return CreatePeerConnectionFactory(
|
||||
worker_and_network_thread, worker_and_network_thread, signaling_thread,
|
||||
default_adm, audio_encoder_factory, audio_decoder_factory,
|
||||
video_encoder_factory, video_decoder_factory);
|
||||
}
|
||||
|
||||
// Deprecated variant of the above.
|
||||
// TODO(kwiberg): Remove.
|
||||
inline rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory(
|
||||
rtc::Thread* worker_and_network_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
|
||||
@ -23,7 +23,13 @@ specific_include_rules = {
|
||||
"srtpfilter_unittest\.cc": [
|
||||
"+crypto",
|
||||
],
|
||||
|
||||
# TODO(kwiberg): Remove these exceptions when audio_decoder_factory.h
|
||||
# has moved to api/.
|
||||
"peerconnectionfactory\.cc": [
|
||||
"+webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h",
|
||||
],
|
||||
"peerconnectioninterface_unittest\.cc": [
|
||||
"+webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h",
|
||||
],
|
||||
}
|
||||
|
||||
@ -36,10 +36,12 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory() {
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory) {
|
||||
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
||||
new rtc::RefCountedObject<PeerConnectionFactory>());
|
||||
new rtc::RefCountedObject<PeerConnectionFactory>(audio_encoder_factory,
|
||||
audio_decoder_factory));
|
||||
|
||||
RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread());
|
||||
// The signaling thread is the current thread so we can
|
||||
@ -51,6 +53,27 @@ CreatePeerConnectionFactory() {
|
||||
pc_factory);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory() {
|
||||
return CreatePeerConnectionFactory(CreateBuiltinAudioEncoderFactory(),
|
||||
CreateBuiltinAudioDecoderFactory());
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, nullptr);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
@ -63,35 +86,22 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
|
||||
encoder_factory, decoder_factory, nullptr);
|
||||
}
|
||||
|
||||
PeerConnectionFactory::PeerConnectionFactory()
|
||||
: owns_ptrs_(true),
|
||||
wraps_current_thread_(false),
|
||||
network_thread_(rtc::Thread::CreateWithSocketServer().release()),
|
||||
worker_thread_(rtc::Thread::Create().release()),
|
||||
signaling_thread_(rtc::Thread::Current()),
|
||||
audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) {
|
||||
if (!signaling_thread_) {
|
||||
signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
|
||||
wraps_current_thread_ = true;
|
||||
}
|
||||
network_thread_->Start();
|
||||
worker_thread_->Start();
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
cricket::WebRtcVideoEncoderFactory* encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* decoder_factory,
|
||||
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer) {
|
||||
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
||||
new rtc::RefCountedObject<PeerConnectionFactory>(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
CreateBuiltinAudioDecoderFactory(), encoder_factory, decoder_factory,
|
||||
audio_mixer));
|
||||
audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, audio_mixer));
|
||||
|
||||
// Call Initialize synchronously but make sure it is executed on
|
||||
// |signaling_thread|.
|
||||
@ -105,13 +115,46 @@ CreatePeerConnectionFactoryWithAudioMixer(
|
||||
return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactoryWithAudioMixer(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
cricket::WebRtcVideoEncoderFactory* encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer) {
|
||||
return CreatePeerConnectionFactoryWithAudioMixer(
|
||||
network_thread, worker_thread, signaling_thread, default_adm,
|
||||
CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(),
|
||||
encoder_factory, decoder_factory, audio_mixer);
|
||||
}
|
||||
|
||||
PeerConnectionFactory::PeerConnectionFactory(
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory)
|
||||
: owns_ptrs_(true),
|
||||
wraps_current_thread_(false),
|
||||
network_thread_(rtc::Thread::CreateWithSocketServer().release()),
|
||||
worker_thread_(rtc::Thread::Create().release()),
|
||||
signaling_thread_(rtc::Thread::Current()),
|
||||
// TODO(ossu): Take care of audio_encoder_factory (see bug 5806).
|
||||
audio_decoder_factory_(audio_decoder_factory) {
|
||||
if (!signaling_thread_) {
|
||||
signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
|
||||
wraps_current_thread_ = true;
|
||||
}
|
||||
network_thread_->Start();
|
||||
worker_thread_->Start();
|
||||
}
|
||||
|
||||
PeerConnectionFactory::PeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
||||
audio_decoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer)
|
||||
@ -121,6 +164,7 @@ PeerConnectionFactory::PeerConnectionFactory(
|
||||
worker_thread_(worker_thread),
|
||||
signaling_thread_(signaling_thread),
|
||||
default_adm_(default_adm),
|
||||
// TODO(ossu): Take care of audio_encoder_factory (see bug 5806).
|
||||
audio_decoder_factory_(audio_decoder_factory),
|
||||
video_encoder_factory_(video_encoder_factory),
|
||||
video_decoder_factory_(video_decoder_factory),
|
||||
|
||||
@ -102,14 +102,16 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
|
||||
const Options& options() const { return options_; }
|
||||
|
||||
protected:
|
||||
PeerConnectionFactory();
|
||||
PeerConnectionFactory(
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory);
|
||||
PeerConnectionFactory(
|
||||
rtc::Thread* network_thread,
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* signaling_thread,
|
||||
AudioDeviceModule* default_adm,
|
||||
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
||||
audio_decoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
|
||||
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<AudioMixer> audio_mixer);
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/media/base/fakevideocapturer.h"
|
||||
#include "webrtc/media/sctp/sctptransportinternal.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
|
||||
#include "webrtc/p2p/base/fakeportallocator.h"
|
||||
#include "webrtc/pc/audiotrack.h"
|
||||
#include "webrtc/pc/mediasession.h"
|
||||
@ -665,6 +666,11 @@ class MockPeerConnectionObserver : public PeerConnectionObserver {
|
||||
// constructors, but that is not exercised by these unittest.
|
||||
class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory {
|
||||
public:
|
||||
PeerConnectionFactoryForTest()
|
||||
: webrtc::PeerConnectionFactory(
|
||||
webrtc::CreateBuiltinAudioEncoderFactory(),
|
||||
webrtc::CreateBuiltinAudioDecoderFactory()) {}
|
||||
|
||||
webrtc::MediaControllerInterface* CreateMediaController(
|
||||
const cricket::MediaConfig& config,
|
||||
webrtc::RtcEventLog* event_log) const override {
|
||||
|
||||
@ -20,7 +20,12 @@ namespace webrtc {
|
||||
|
||||
// The factory isn't really used; it just satisfies the base PeerConnection.
|
||||
class FakePeerConnectionFactory
|
||||
: public rtc::RefCountedObject<webrtc::PeerConnectionFactory> {};
|
||||
: public rtc::RefCountedObject<webrtc::PeerConnectionFactory> {
|
||||
public:
|
||||
FakePeerConnectionFactory()
|
||||
: rtc::RefCountedObject<webrtc::PeerConnectionFactory>(nullptr, nullptr) {
|
||||
}
|
||||
};
|
||||
|
||||
class MockPeerConnection
|
||||
: public rtc::RefCountedObject<webrtc::PeerConnection> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user