OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #import "RTCPeerConnectionFactory+Private.h" | |
12 | |
13 #import "NSString+StdString.h" | |
14 #import "RTCAVFoundationVideoSource+Private.h" | |
15 #import "RTCAudioSource+Private.h" | |
16 #import "RTCAudioTrack+Private.h" | |
17 #import "RTCMediaConstraints+Private.h" | |
18 #import "RTCMediaStream+Private.h" | |
19 #import "RTCPeerConnection+Private.h" | |
20 #import "RTCVideoSource+Private.h" | |
21 #import "RTCVideoTrack+Private.h" | |
22 #import "WebRTC/RTCLogging.h" | |
23 | |
24 #include "Video/objcvideotracksource.h" | |
25 #include "VideoToolbox/videocodecfactory.h" | |
26 #include "webrtc/api/videosourceproxy.h" | |
27 | |
28 #if !defined(HAVE_RTC_AUDIO) && !defined(HAVE_RTC_VIDEO) | |
29 #include "webrtc/media/engine/webrtcmediaengine.h" | |
30 namespace webrtc { | |
31 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> CreatePeerConnectionF actory( | |
tkchin_webrtc
2017/06/20 21:51:23
why is this method declared only if !defined(HAVE_
| |
32 rtc::Thread* network_thread, | |
33 rtc::Thread* worker_thread, | |
34 rtc::Thread* signaling_thread, | |
35 webrtc::AudioDeviceModule* default_adm, | |
36 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, | |
37 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) { | |
38 return CreateModularPeerConnectionFactory(network_thread, | |
39 worker_thread, | |
40 signaling_thread, | |
41 default_adm, | |
42 nullptr, | |
43 nullptr, | |
44 video_encoder_factory, | |
45 video_decoder_factory, | |
46 nullptr, | |
47 std::unique_ptr<cricket::MediaEngine Interface>(), | |
48 std::unique_ptr<webrtc::CallFactoryI nterface>(), | |
49 std::unique_ptr<webrtc::RtcEventLogF actoryInterface>()); | |
50 } | |
51 } // namespace webrtc | |
52 #endif | |
53 | |
54 @implementation RTCPeerConnectionFactory (Media) | |
tkchin_webrtc
2017/06/20 21:51:23
same question: why does this need to be in its own
| |
55 | |
56 - (instancetype)init { | |
57 if ((self = [super init])) { | |
58 _networkThread = rtc::Thread::CreateWithSocketServer(); | |
59 BOOL result = _networkThread->Start(); | |
60 NSAssert(result, @"Failed to start network thread."); | |
61 | |
62 _workerThread = rtc::Thread::Create(); | |
63 result = _workerThread->Start(); | |
64 NSAssert(result, @"Failed to start worker thread."); | |
65 | |
66 _signalingThread = rtc::Thread::Create(); | |
67 result = _signalingThread->Start(); | |
68 NSAssert(result, @"Failed to start signaling thread."); | |
69 | |
70 webrtc::VideoToolboxVideoEncoderFactory* encoder_factory = nullptr; | |
71 webrtc::VideoToolboxVideoDecoderFactory* decoder_factory = nullptr; | |
72 | |
73 #if defined(HAVE_RTC_VIDEO) | |
74 encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); | |
75 decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); | |
76 #endif | |
77 | |
78 // Ownership of encoder/decoder factories is passed on to the | |
79 // peerconnectionfactory, that handles deleting them. | |
80 _nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(), | |
81 _workerThread.get(), | |
82 _signalingThread.get(), | |
83 nullptr, | |
84 encoder_factory, | |
85 decoder_factory); | |
86 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | |
87 } | |
88 return self; | |
89 } | |
90 | |
91 - (RTCMediaStream*)mediaStreamWithStreamId:(NSString*)streamId { | |
92 #if defined(HAVE_RTC_AUDIO) || defined(HAVE_RTC_VIDEO) | |
93 return [[RTCMediaStream alloc] initWithFactory:self streamId:streamId]; | |
94 #else | |
95 return nil; | |
96 #endif | |
97 } | |
98 | |
99 @end | |
OLD | NEW |