| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #import "RTCPeerConnectionFactory+Private.h" | 11 #import "RTCPeerConnectionFactory+Private.h" |
| 12 | 12 |
| 13 #import "NSString+StdString.h" | 13 #import "NSString+StdString.h" |
| 14 #import "RTCAVFoundationVideoSource+Private.h" |
| 14 #import "RTCAudioSource+Private.h" | 15 #import "RTCAudioSource+Private.h" |
| 15 #import "RTCAudioTrack+Private.h" | 16 #import "RTCAudioTrack+Private.h" |
| 16 #import "RTCMediaConstraints+Private.h" | 17 #import "RTCMediaConstraints+Private.h" |
| 17 #import "RTCMediaStream+Private.h" | 18 #import "RTCMediaStream+Private.h" |
| 18 #import "RTCPeerConnection+Private.h" | 19 #import "RTCPeerConnection+Private.h" |
| 19 #import "RTCVideoSource+Private.h" | 20 #import "RTCVideoSource+Private.h" |
| 20 #import "RTCVideoTrack+Private.h" | 21 #import "RTCVideoTrack+Private.h" |
| 21 #import "RTCAVFoundationVideoSource+Private.h" | |
| 22 #import "WebRTC/RTCLogging.h" | 22 #import "WebRTC/RTCLogging.h" |
| 23 #import "WebRTC/RTCVideoCodecFactory.h" |
| 24 #ifndef HAVE_NO_MEDIA |
| 25 #import "WebRTC/RTCVideoCodecH264.h" |
| 26 #endif |
| 23 | 27 |
| 24 #include "Video/objcvideotracksource.h" | 28 #include "Video/objcvideotracksource.h" |
| 25 #include "VideoToolbox/videocodecfactory.h" | 29 #include "VideoToolbox/objc_video_decoder_factory.h" |
| 30 #include "VideoToolbox/objc_video_encoder_factory.h" |
| 26 #include "webrtc/api/videosourceproxy.h" | 31 #include "webrtc/api/videosourceproxy.h" |
| 27 // Adding the nogncheck to disable the including header check. | 32 // Adding the nogncheck to disable the including header check. |
| 28 // The no-media version PeerConnectionFactory doesn't depend on media related | 33 // The no-media version PeerConnectionFactory doesn't depend on media related |
| 29 // C++ target. | 34 // C++ target. |
| 30 // TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++ | 35 // TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++ |
| 31 // API layer. | 36 // API layer. |
| 32 #include "webrtc/media/engine/webrtcmediaengine.h" // nogncheck | 37 #include "webrtc/media/engine/webrtcmediaengine.h" // nogncheck |
| 33 | 38 |
| 34 @implementation RTCPeerConnectionFactory { | 39 @implementation RTCPeerConnectionFactory { |
| 35 std::unique_ptr<rtc::Thread> _networkThread; | 40 std::unique_ptr<rtc::Thread> _networkThread; |
| 36 std::unique_ptr<rtc::Thread> _workerThread; | 41 std::unique_ptr<rtc::Thread> _workerThread; |
| 37 std::unique_ptr<rtc::Thread> _signalingThread; | 42 std::unique_ptr<rtc::Thread> _signalingThread; |
| 38 BOOL _hasStartedAecDump; | 43 BOOL _hasStartedAecDump; |
| 39 } | 44 } |
| 40 | 45 |
| 41 @synthesize nativeFactory = _nativeFactory; | 46 @synthesize nativeFactory = _nativeFactory; |
| 42 | 47 |
| 43 - (instancetype)init { | 48 - (instancetype)init { |
| 44 if ((self = [super init])) { | 49 #ifdef HAVE_NO_MEDIA |
| 50 return [self initWithEncoderFactory:nil decoderFactory:nil]; |
| 51 #else |
| 52 return [self initWithEncoderFactory:[[RTCVideoEncoderFactoryH264 alloc] init] |
| 53 decoderFactory:[[RTCVideoDecoderFactoryH264 alloc] init]]
; |
| 54 #endif |
| 55 } |
| 56 |
| 57 - (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)enco
derFactory |
| 58 decoderFactory:(nullable id<RTCVideoDecoderFactory>)deco
derFactory { |
| 59 if (self = [super init]) { |
| 45 _networkThread = rtc::Thread::CreateWithSocketServer(); | 60 _networkThread = rtc::Thread::CreateWithSocketServer(); |
| 46 BOOL result = _networkThread->Start(); | 61 BOOL result = _networkThread->Start(); |
| 47 NSAssert(result, @"Failed to start network thread."); | 62 NSAssert(result, @"Failed to start network thread."); |
| 48 | 63 |
| 49 _workerThread = rtc::Thread::Create(); | 64 _workerThread = rtc::Thread::Create(); |
| 50 result = _workerThread->Start(); | 65 result = _workerThread->Start(); |
| 51 NSAssert(result, @"Failed to start worker thread."); | 66 NSAssert(result, @"Failed to start worker thread."); |
| 52 | 67 |
| 53 _signalingThread = rtc::Thread::Create(); | 68 _signalingThread = rtc::Thread::Create(); |
| 54 result = _signalingThread->Start(); | 69 result = _signalingThread->Start(); |
| 55 NSAssert(result, @"Failed to start signaling thread."); | 70 NSAssert(result, @"Failed to start signaling thread."); |
| 56 #ifdef HAVE_NO_MEDIA | 71 #ifdef HAVE_NO_MEDIA |
| 57 _nativeFactory = webrtc::CreateModularPeerConnectionFactory( | 72 _nativeFactory = webrtc::CreateModularPeerConnectionFactory( |
| 58 _networkThread.get(), | 73 _networkThread.get(), |
| 59 _workerThread.get(), | 74 _workerThread.get(), |
| 60 _signalingThread.get(), | 75 _signalingThread.get(), |
| 61 nullptr, // default_adm | 76 nullptr, // default_adm |
| 62 nullptr, // audio_encoder_factory | 77 nullptr, // audio_encoder_factory |
| 63 nullptr, // audio_decoder_factory | 78 nullptr, // audio_decoder_factory |
| 64 nullptr, // video_encoder_factory | 79 nullptr, // video_encoder_factory |
| 65 nullptr, // video_decoder_factory | 80 nullptr, // video_decoder_factory |
| 66 nullptr, // audio_mixer | 81 nullptr, // audio_mixer |
| 67 std::unique_ptr<cricket::MediaEngineInterface>(), | 82 std::unique_ptr<cricket::MediaEngineInterface>(), |
| 68 std::unique_ptr<webrtc::CallFactoryInterface>(), | 83 std::unique_ptr<webrtc::CallFactoryInterface>(), |
| 69 std::unique_ptr<webrtc::RtcEventLogFactoryInterface>()); | 84 std::unique_ptr<webrtc::RtcEventLogFactoryInterface>()); |
| 70 #else | 85 #else |
| 71 const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); | 86 cricket::WebRtcVideoEncoderFactory *platform_encoder_factory = nullptr; |
| 72 const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); | 87 cricket::WebRtcVideoDecoderFactory *platform_decoder_factory = nullptr; |
| 88 if (encoderFactory) { |
| 89 platform_encoder_factory = new webrtc::ObjCVideoEncoderFactory(encoderFact
ory); |
| 90 } |
| 91 if (decoderFactory) { |
| 92 platform_decoder_factory = new webrtc::ObjCVideoDecoderFactory(decoderFact
ory); |
| 93 } |
| 73 | 94 |
| 74 // Ownership of encoder/decoder factories is passed on to the | 95 // Ownership of encoder/decoder factories is passed on to the |
| 75 // peerconnectionfactory, that handles deleting them. | 96 // peerconnectionfactory, that handles deleting them. |
| 76 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 97 _nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(), |
| 77 _networkThread.get(), _workerThread.get(), _signalingThread.get(), | 98 _workerThread.get(), |
| 78 nullptr, encoder_factory, decoder_factory); | 99 _signalingThread.get(), |
| 100 nullptr, |
| 101 platform_encoder_factor
y, |
| 102 platform_decoder_factor
y); |
| 79 #endif | 103 #endif |
| 80 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 104 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
| 81 } | 105 } |
| 82 return self; | 106 return self; |
| 83 } | 107 } |
| 84 | 108 |
| 85 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c
onstraints { | 109 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c
onstraints { |
| 86 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; | 110 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; |
| 87 if (constraints) { | 111 if (constraints) { |
| 88 nativeConstraints = constraints.nativeConstraints; | 112 nativeConstraints = constraints.nativeConstraints; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); | 187 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); |
| 164 return _hasStartedAecDump; | 188 return _hasStartedAecDump; |
| 165 } | 189 } |
| 166 | 190 |
| 167 - (void)stopAecDump { | 191 - (void)stopAecDump { |
| 168 _nativeFactory->StopAecDump(); | 192 _nativeFactory->StopAecDump(); |
| 169 _hasStartedAecDump = NO; | 193 _hasStartedAecDump = NO; |
| 170 } | 194 } |
| 171 | 195 |
| 172 @end | 196 @end |
| OLD | NEW |