Index: webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Media.mm |
diff --git a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Media.mm b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Media.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f0124c09a0ad0f8aeca5ac5805d0e7b6dd960932 |
--- /dev/null |
+++ b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Media.mm |
@@ -0,0 +1,99 @@ |
+/* |
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#import "RTCPeerConnectionFactory+Private.h" |
+ |
+#import "NSString+StdString.h" |
+#import "RTCAVFoundationVideoSource+Private.h" |
+#import "RTCAudioSource+Private.h" |
+#import "RTCAudioTrack+Private.h" |
+#import "RTCMediaConstraints+Private.h" |
+#import "RTCMediaStream+Private.h" |
+#import "RTCPeerConnection+Private.h" |
+#import "RTCVideoSource+Private.h" |
+#import "RTCVideoTrack+Private.h" |
+#import "WebRTC/RTCLogging.h" |
+ |
+#include "Video/objcvideotracksource.h" |
+#include "VideoToolbox/videocodecfactory.h" |
+#include "webrtc/api/videosourceproxy.h" |
+ |
+#if !defined(HAVE_RTC_AUDIO) && !defined(HAVE_RTC_VIDEO) |
+#include "webrtc/media/engine/webrtcmediaengine.h" |
+namespace webrtc { |
+rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
tkchin_webrtc
2017/06/20 21:51:23
why is this method declared only if !defined(HAVE_
|
+ rtc::Thread* network_thread, |
+ rtc::Thread* worker_thread, |
+ rtc::Thread* signaling_thread, |
+ webrtc::AudioDeviceModule* default_adm, |
+ cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
+ cricket::WebRtcVideoDecoderFactory* video_decoder_factory) { |
+ return CreateModularPeerConnectionFactory(network_thread, |
+ worker_thread, |
+ signaling_thread, |
+ default_adm, |
+ nullptr, |
+ nullptr, |
+ video_encoder_factory, |
+ video_decoder_factory, |
+ nullptr, |
+ std::unique_ptr<cricket::MediaEngineInterface>(), |
+ std::unique_ptr<webrtc::CallFactoryInterface>(), |
+ std::unique_ptr<webrtc::RtcEventLogFactoryInterface>()); |
+} |
+} // namespace webrtc |
+#endif |
+ |
+@implementation RTCPeerConnectionFactory (Media) |
tkchin_webrtc
2017/06/20 21:51:23
same question: why does this need to be in its own
|
+ |
+- (instancetype)init { |
+ if ((self = [super init])) { |
+ _networkThread = rtc::Thread::CreateWithSocketServer(); |
+ BOOL result = _networkThread->Start(); |
+ NSAssert(result, @"Failed to start network thread."); |
+ |
+ _workerThread = rtc::Thread::Create(); |
+ result = _workerThread->Start(); |
+ NSAssert(result, @"Failed to start worker thread."); |
+ |
+ _signalingThread = rtc::Thread::Create(); |
+ result = _signalingThread->Start(); |
+ NSAssert(result, @"Failed to start signaling thread."); |
+ |
+ webrtc::VideoToolboxVideoEncoderFactory* encoder_factory = nullptr; |
+ webrtc::VideoToolboxVideoDecoderFactory* decoder_factory = nullptr; |
+ |
+#if defined(HAVE_RTC_VIDEO) |
+ encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); |
+ decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); |
+#endif |
+ |
+ // 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, |
+ encoder_factory, |
+ decoder_factory); |
+ NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
+ } |
+ return self; |
+} |
+ |
+- (RTCMediaStream*)mediaStreamWithStreamId:(NSString*)streamId { |
+#if defined(HAVE_RTC_AUDIO) || defined(HAVE_RTC_VIDEO) |
+ return [[RTCMediaStream alloc] initWithFactory:self streamId:streamId]; |
+#else |
+ return nil; |
+#endif |
+} |
+ |
+@end |