Pass MediaTransportFactory to PeerConnectionFactory.

And use RTCConfiguration to enable/disable it on a per connection basis.

With the advent of MediaTransportInterface, we need to be able to enable
it on the per PeerConnection basis.

At this point PeerConnection will not take any action when the
MediaTransportInterface is set; this code will land a bit later, and
will be accompanied by the tests that verify correct setup (hence no tests right now).

At this point this is just a method stub to enable further development.

Bug: webrtc:9719
Change-Id: I1f77d650cb03bf1191aa0b35669cd32f1b68446f
Reviewed-on: https://webrtc-review.googlesource.com/c/103860
Reviewed-by: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Anton Sukhanov <sukhanov@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25053}
This commit is contained in:
Piotr (Peter) Slatala
2018-10-08 09:43:21 -07:00
committed by Peter Slatala
parent 1e05486914
commit e0c2e97474
16 changed files with 177 additions and 30 deletions

View File

@ -168,6 +168,12 @@ RTC_OBJC_EXPORT
*/
@property(nonatomic, assign) BOOL activeResetSrtpParams;
/**
* If MediaTransportFactory is provided in PeerConnectionFactory, this flag informs PeerConnection
* that it should use the MediaTransportInterface.
*/
@property(nonatomic, assign) BOOL useMediaTransport;
- (instancetype)init;
@end

View File

@ -48,6 +48,7 @@
@synthesize sdpSemantics = _sdpSemantics;
@synthesize turnCustomizer = _turnCustomizer;
@synthesize activeResetSrtpParams = _activeResetSrtpParams;
@synthesize useMediaTransport = _useMediaTransport;
- (instancetype)init {
// Copy defaults.
@ -117,7 +118,7 @@
- (NSString *)description {
static NSString *formatString =
@"RTCConfiguration: "
@"{\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%@\n%@\n%d\n%d\n%d\n}\n";
@"{\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%@\n%@\n%d\n%d\n%d\n%@\n}\n";
return [NSString
stringWithFormat:formatString,
@ -140,7 +141,8 @@
_iceRegatherIntervalRange,
_disableLinkLocalNetworks,
_maxIPv6Networks,
_activeResetSrtpParams];
_activeResetSrtpParams,
_useMediaTransport];
}
#pragma mark - Private

View File

@ -29,6 +29,7 @@
#include <memory>
#include "api/jsepicecandidate.h"
#include "api/media_transport_interface.h"
#include "rtc_base/checks.h"
NSString * const kRTCPeerConnectionErrorDomain =

View File

@ -17,6 +17,7 @@ namespace webrtc {
class AudioDeviceModule;
class AudioEncoderFactory;
class AudioDecoderFactory;
class MediaTransportFactory;
class VideoEncoderFactory;
class VideoDecoderFactory;
class AudioProcessing;
@ -49,6 +50,25 @@ NS_ASSUME_NONNULL_BEGIN
audioProcessingModule:
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule;
- (instancetype)
initWithNativeAudioEncoderFactory:
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
nativeAudioDecoderFactory:
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
nativeVideoEncoderFactory:
(std::unique_ptr<webrtc::VideoEncoderFactory>)videoEncoderFactory
nativeVideoDecoderFactory:
(std::unique_ptr<webrtc::VideoDecoderFactory>)videoDecoderFactory
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule
audioProcessingModule:
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule
mediaTransportFactory:
(std::unique_ptr<webrtc::MediaTransportFactory>)mediaTransportFactory;
- (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory
mediaTransportFactory:
(std::unique_ptr<webrtc::MediaTransportFactory>)mediaTransportFactory;
@end
NS_ASSUME_NONNULL_END

View File

@ -50,6 +50,7 @@
// TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++
// API layer.
#include "absl/memory/memory.h"
#include "api/media_transport_interface.h"
#include "media/engine/webrtcmediaengine.h" // nogncheck
@implementation RTCPeerConnectionFactory {
@ -80,12 +81,15 @@
nativeVideoDecoderFactory:webrtc::ObjCToNativeVideoDecoderFactory(
[[RTCVideoDecoderFactoryH264 alloc] init])
audioDeviceModule:[self audioDeviceModule]
audioProcessingModule:nullptr];
audioProcessingModule:nullptr
mediaTransportFactory:nullptr];
#endif
}
- (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory {
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory
mediaTransportFactory:
(std::unique_ptr<webrtc::MediaTransportFactory>)mediaTransportFactory {
#ifdef HAVE_NO_MEDIA
return [self initWithNoMedia];
#else
@ -102,9 +106,16 @@
nativeVideoEncoderFactory:std::move(native_encoder_factory)
nativeVideoDecoderFactory:std::move(native_decoder_factory)
audioDeviceModule:[self audioDeviceModule]
audioProcessingModule:nullptr];
audioProcessingModule:nullptr
mediaTransportFactory:std::move(mediaTransportFactory)];
#endif
}
- (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory {
return [self initWithEncoderFactory:encoderFactory
decoderFactory:decoderFactory
mediaTransportFactory:nullptr];
}
- (instancetype)initNative {
if (self = [super init]) {
@ -152,20 +163,57 @@
(nullable webrtc::AudioDeviceModule *)audioDeviceModule
audioProcessingModule:
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule {
return [self initWithNativeAudioEncoderFactory:audioEncoderFactory
nativeAudioDecoderFactory:audioDecoderFactory
nativeVideoEncoderFactory:std::move(videoEncoderFactory)
nativeVideoDecoderFactory:std::move(videoDecoderFactory)
audioDeviceModule:audioDeviceModule
audioProcessingModule:audioProcessingModule
mediaTransportFactory:nullptr];
}
- (instancetype)
initWithNativeAudioEncoderFactory:
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
nativeAudioDecoderFactory:
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
nativeVideoEncoderFactory:
(std::unique_ptr<webrtc::VideoEncoderFactory>)videoEncoderFactory
nativeVideoDecoderFactory:
(std::unique_ptr<webrtc::VideoDecoderFactory>)videoDecoderFactory
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule
audioProcessingModule:
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule
mediaTransportFactory:
(std::unique_ptr<webrtc::MediaTransportFactory>)mediaTransportFactory {
#ifdef HAVE_NO_MEDIA
return [self initWithNoMedia];
#else
if (self = [self initNative]) {
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
_workerThread.get(),
_signalingThread.get(),
audioDeviceModule,
audioEncoderFactory,
audioDecoderFactory,
std::move(videoEncoderFactory),
std::move(videoDecoderFactory),
nullptr, // audio mixer
audioProcessingModule);
if (!audioProcessingModule) audioProcessingModule = webrtc::AudioProcessingBuilder().Create();
std::unique_ptr<cricket::MediaEngineInterface> media_engine =
cricket::WebRtcMediaEngineFactory::Create(audioDeviceModule,
audioEncoderFactory,
audioDecoderFactory,
std::move(videoEncoderFactory),
std::move(videoDecoderFactory),
nullptr, // audio mixer
audioProcessingModule);
std::unique_ptr<webrtc::CallFactoryInterface> call_factory = webrtc::CreateCallFactory();
std::unique_ptr<webrtc::RtcEventLogFactoryInterface> event_log_factory =
webrtc::CreateRtcEventLogFactory();
webrtc::PeerConnectionFactoryDependencies dependencies;
dependencies.network_thread = _networkThread.get();
dependencies.worker_thread = _workerThread.get();
dependencies.signaling_thread = _signalingThread.get();
dependencies.media_engine = std::move(media_engine);
dependencies.call_factory = std::move(call_factory);
dependencies.event_log_factory = std::move(event_log_factory);
dependencies.media_transport_factory = std::move(mediaTransportFactory);
_nativeFactory = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies));
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
}
return self;

View File

@ -13,6 +13,7 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/audio_codecs/audio_encoder_factory.h"
#include "api/media_transport_interface.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "modules/audio_device/include/audio_device.h"
@ -25,6 +26,7 @@
rtc::scoped_refptr<webrtc::AudioDecoderFactory> _audioDecoderFactory;
rtc::scoped_refptr<webrtc::AudioDeviceModule> _audioDeviceModule;
rtc::scoped_refptr<webrtc::AudioProcessing> _audioProcessingModule;
std::unique_ptr<webrtc::MediaTransportFactory> _mediaTransportFactory;
}
+ (RTCPeerConnectionFactoryBuilder *)builder {
@ -38,7 +40,8 @@
nativeVideoEncoderFactory:std::move(_videoEncoderFactory)
nativeVideoDecoderFactory:std::move(_videoDecoderFactory)
audioDeviceModule:_audioDeviceModule
audioProcessingModule:_audioProcessingModule];
audioProcessingModule:_audioProcessingModule
mediaTransportFactory:std::move(_mediaTransportFactory)];
}
- (void)setVideoEncoderFactory:(std::unique_ptr<webrtc::VideoEncoderFactory>)videoEncoderFactory {