| 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 "RTCAVFoundationVideoSource+Private.h" |
| 15 #import "RTCAudioSource+Private.h" | 15 #import "RTCAudioSource+Private.h" |
| 16 #import "RTCAudioTrack+Private.h" | 16 #import "RTCAudioTrack+Private.h" |
| 17 #import "RTCMediaConstraints+Private.h" | 17 #import "RTCMediaConstraints+Private.h" |
| 18 #import "RTCMediaStream+Private.h" | 18 #import "RTCMediaStream+Private.h" |
| 19 #import "RTCPeerConnection+Private.h" | 19 #import "RTCPeerConnection+Private.h" |
| 20 #import "RTCVideoSource+Private.h" | 20 #import "RTCVideoSource+Private.h" |
| 21 #import "RTCVideoTrack+Private.h" | 21 #import "RTCVideoTrack+Private.h" |
| 22 #import "WebRTC/RTCLogging.h" | 22 #import "WebRTC/RTCLogging.h" |
| 23 | 23 |
| 24 #include "videotoolboxvideocodecfactory.h" |
| 25 |
| 24 @implementation RTCPeerConnectionFactory { | 26 @implementation RTCPeerConnectionFactory { |
| 25 std::unique_ptr<rtc::Thread> _networkThread; | 27 std::unique_ptr<rtc::Thread> _networkThread; |
| 26 std::unique_ptr<rtc::Thread> _workerThread; | 28 std::unique_ptr<rtc::Thread> _workerThread; |
| 27 std::unique_ptr<rtc::Thread> _signalingThread; | 29 std::unique_ptr<rtc::Thread> _signalingThread; |
| 28 BOOL _hasStartedAecDump; | 30 BOOL _hasStartedAecDump; |
| 29 } | 31 } |
| 30 | 32 |
| 31 @synthesize nativeFactory = _nativeFactory; | 33 @synthesize nativeFactory = _nativeFactory; |
| 32 | 34 |
| 33 - (instancetype)init { | 35 - (instancetype)init { |
| 34 if ((self = [super init])) { | 36 if ((self = [super init])) { |
| 35 _networkThread = rtc::Thread::CreateWithSocketServer(); | 37 _networkThread = rtc::Thread::CreateWithSocketServer(); |
| 36 BOOL result = _networkThread->Start(); | 38 BOOL result = _networkThread->Start(); |
| 37 NSAssert(result, @"Failed to start network thread."); | 39 NSAssert(result, @"Failed to start network thread."); |
| 38 | 40 |
| 39 _workerThread = rtc::Thread::Create(); | 41 _workerThread = rtc::Thread::Create(); |
| 40 result = _workerThread->Start(); | 42 result = _workerThread->Start(); |
| 41 NSAssert(result, @"Failed to start worker thread."); | 43 NSAssert(result, @"Failed to start worker thread."); |
| 42 | 44 |
| 43 _signalingThread = rtc::Thread::Create(); | 45 _signalingThread = rtc::Thread::Create(); |
| 44 result = _signalingThread->Start(); | 46 result = _signalingThread->Start(); |
| 45 NSAssert(result, @"Failed to start signaling thread."); | 47 NSAssert(result, @"Failed to start signaling thread."); |
| 46 | 48 |
| 49 const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); |
| 50 const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); |
| 51 |
| 52 // Ownership of encoder/decoder factories is passed on to the |
| 53 // peerconnectionfactory, that handles deleting them. |
| 47 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 54 _nativeFactory = webrtc::CreatePeerConnectionFactory( |
| 48 _networkThread.get(), _workerThread.get(), _signalingThread.get(), | 55 _networkThread.get(), _workerThread.get(), _signalingThread.get(), |
| 49 nullptr, nullptr, nullptr); | 56 nullptr, encoder_factory, decoder_factory); |
| 50 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 57 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
| 51 } | 58 } |
| 52 return self; | 59 return self; |
| 53 } | 60 } |
| 54 | 61 |
| 55 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c
onstraints { | 62 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c
onstraints { |
| 56 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; | 63 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; |
| 57 if (constraints) { | 64 if (constraints) { |
| 58 nativeConstraints = constraints.nativeConstraints; | 65 nativeConstraints = constraints.nativeConstraints; |
| 59 } | 66 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); | 128 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); |
| 122 return _hasStartedAecDump; | 129 return _hasStartedAecDump; |
| 123 } | 130 } |
| 124 | 131 |
| 125 - (void)stopAecDump { | 132 - (void)stopAecDump { |
| 126 _nativeFactory->StopAecDump(); | 133 _nativeFactory->StopAecDump(); |
| 127 _hasStartedAecDump = NO; | 134 _hasStartedAecDump = NO; |
| 128 } | 135 } |
| 129 | 136 |
| 130 @end | 137 @end |
| OLD | NEW |