| Index: webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm
|
| diff --git a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm
|
| index dffacb69c9397083cdac83f13719824604547f3b..48d788f19289b62f00209a061f0ce94f33997cc3 100644
|
| --- a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm
|
| +++ b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm
|
| @@ -8,6 +8,7 @@
|
| * be found in the AUTHORS file in the root of the source tree.
|
| */
|
|
|
| +#import "RTCPeerConnectionFactory+Native.h"
|
| #import "RTCPeerConnectionFactory+Private.h"
|
|
|
| #import "NSString+StdString.h"
|
| @@ -22,12 +23,16 @@
|
| #import "WebRTC/RTCLogging.h"
|
| #import "WebRTC/RTCVideoCodecFactory.h"
|
| #ifndef HAVE_NO_MEDIA
|
| +#include "VideoToolbox/objc_video_decoder_factory.h"
|
| +#include "VideoToolbox/objc_video_encoder_factory.h"
|
| #import "WebRTC/RTCVideoCodecH264.h"
|
| +// The no-media version PeerConnectionFactory doesn't depend on these files, but the gn check tool
|
| +// is not smart enough to take the #ifdef into account.
|
| +#include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" // nogncheck
|
| +#include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" // nogncheck
|
| #endif
|
|
|
| #include "Video/objcvideotracksource.h"
|
| -#include "VideoToolbox/objc_video_decoder_factory.h"
|
| -#include "VideoToolbox/objc_video_encoder_factory.h"
|
| #include "webrtc/api/videosourceproxy.h"
|
| // Adding the nogncheck to disable the including header check.
|
| // The no-media version PeerConnectionFactory doesn't depend on media related
|
| @@ -47,15 +52,47 @@
|
|
|
| - (instancetype)init {
|
| #ifdef HAVE_NO_MEDIA
|
| - return [self initWithEncoderFactory:nil decoderFactory:nil];
|
| + return [self initWithNativeAudioEncoderFactory:nil
|
| + nativeAudioDecoderFactory:nil
|
| + nativeVideoEncoderFactory:nil
|
| + nativeVideoDecoderFactory:nil];
|
| #else
|
| - return [self initWithEncoderFactory:[[RTCVideoEncoderFactoryH264 alloc] init]
|
| - decoderFactory:[[RTCVideoDecoderFactoryH264 alloc] init]];
|
| + return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
| + nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
| + nativeVideoEncoderFactory:new webrtc::ObjCVideoEncoderFactory(
|
| + [[RTCVideoEncoderFactoryH264 alloc] init])
|
| + nativeVideoDecoderFactory:new webrtc::ObjCVideoDecoderFactory(
|
| + [[RTCVideoDecoderFactoryH264 alloc] init])];
|
| #endif
|
| }
|
|
|
| - (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
|
| decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory {
|
| +#ifdef HAVE_NO_MEDIA
|
| + return [self initWithNativeAudioEncoderFactory:nil
|
| + nativeAudioDecoderFactory:nil
|
| + nativeVideoEncoderFactory:nil
|
| + nativeVideoDecoderFactory:nil];
|
| +#else
|
| + cricket::WebRtcVideoEncoderFactory *native_encoder_factory =
|
| + encoderFactory ? new webrtc::ObjCVideoEncoderFactory(encoderFactory) : nullptr;
|
| + cricket::WebRtcVideoDecoderFactory *native_decoder_factory =
|
| + decoderFactory ? new webrtc::ObjCVideoDecoderFactory(decoderFactory) : nullptr;
|
| + return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
| + nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
| + nativeVideoEncoderFactory:native_encoder_factory
|
| + nativeVideoDecoderFactory:native_decoder_factory];
|
| +#endif
|
| +}
|
| +
|
| +- (instancetype)initWithNativeAudioEncoderFactory:
|
| + (rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
| + nativeAudioDecoderFactory:
|
| + (rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
|
| + nativeVideoEncoderFactory:
|
| + (nullable cricket::WebRtcVideoEncoderFactory *)videoEncoderFactory
|
| + nativeVideoDecoderFactory:
|
| + (nullable cricket::WebRtcVideoDecoderFactory *)videoDecoderFactory {
|
| if (self = [super init]) {
|
| _networkThread = rtc::Thread::CreateWithSocketServer();
|
| BOOL result = _networkThread->Start();
|
| @@ -83,23 +120,16 @@
|
| std::unique_ptr<webrtc::CallFactoryInterface>(),
|
| std::unique_ptr<webrtc::RtcEventLogFactoryInterface>());
|
| #else
|
| - cricket::WebRtcVideoEncoderFactory *platform_encoder_factory = nullptr;
|
| - cricket::WebRtcVideoDecoderFactory *platform_decoder_factory = nullptr;
|
| - if (encoderFactory) {
|
| - platform_encoder_factory = new webrtc::ObjCVideoEncoderFactory(encoderFactory);
|
| - }
|
| - if (decoderFactory) {
|
| - platform_decoder_factory = new webrtc::ObjCVideoDecoderFactory(decoderFactory);
|
| - }
|
| -
|
| // Ownership of encoder/decoder factories is passed on to the
|
| // peerconnectionfactory, that handles deleting them.
|
| _nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
|
| _workerThread.get(),
|
| _signalingThread.get(),
|
| - nullptr,
|
| - platform_encoder_factory,
|
| - platform_decoder_factory);
|
| + nullptr, // audio device module
|
| + audioEncoderFactory,
|
| + audioDecoderFactory,
|
| + videoEncoderFactory,
|
| + videoDecoderFactory);
|
| #endif
|
| NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
|
| }
|
|
|