Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: talk/app/webrtc/objc/RTCPeerConnectionFactory.mm

Issue 2296613002: Delete talk directory, and references from build_ios_libs.sh. (Closed)
Patch Set: Update filenames for c -> c++ conversion. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * libjingle
3 * Copyright 2013 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #if !defined(__has_feature) || !__has_feature(objc_arc)
29 #error "This file requires ARC support."
30 #endif
31
32 #import "RTCPeerConnectionFactory+Internal.h"
33
34 #include <memory>
35 #include <vector>
36
37 #import "RTCAudioTrack+Internal.h"
38 #import "RTCICEServer+Internal.h"
39 #import "RTCMediaConstraints+Internal.h"
40 #import "RTCMediaSource+Internal.h"
41 #import "RTCMediaStream+Internal.h"
42 #import "RTCMediaStreamTrack+Internal.h"
43 #import "RTCPeerConnection+Internal.h"
44 #import "RTCPeerConnectionDelegate.h"
45 #import "RTCPeerConnectionInterface+Internal.h"
46 #import "RTCVideoCapturer+Internal.h"
47 #import "RTCVideoSource+Internal.h"
48 #import "RTCVideoTrack+Internal.h"
49
50 #include "webrtc/api/audiotrack.h"
51 #include "webrtc/api/mediastreaminterface.h"
52 #include "webrtc/api/peerconnectioninterface.h"
53 #include "webrtc/api/videotrack.h"
54 #include "webrtc/base/logging.h"
55 #include "webrtc/base/ssladapter.h"
56
57 @implementation RTCPeerConnectionFactory {
58 std::unique_ptr<rtc::Thread> _networkThread;
59 std::unique_ptr<rtc::Thread> _workerThread;
60 std::unique_ptr<rtc::Thread> _signalingThread;
61 }
62
63 @synthesize nativeFactory = _nativeFactory;
64
65 + (void)initializeSSL {
66 BOOL initialized = rtc::InitializeSSL();
67 NSAssert(initialized, @"Failed to initialize SSL library");
68 }
69
70 + (void)deinitializeSSL {
71 BOOL deinitialized = rtc::CleanupSSL();
72 NSAssert(deinitialized, @"Failed to deinitialize SSL library");
73 }
74
75 - (id)init {
76 if ((self = [super init])) {
77 _networkThread = rtc::Thread::CreateWithSocketServer();
78 BOOL result = _networkThread->Start();
79 NSAssert(result, @"Failed to start network thread.");
80
81 _workerThread = rtc::Thread::Create();
82 result = _workerThread->Start();
83 NSAssert(result, @"Failed to start worker thread.");
84
85 _signalingThread = rtc::Thread::Create();
86 result = _signalingThread->Start();
87 NSAssert(result, @"Failed to start signaling thread.");
88
89 _nativeFactory = webrtc::CreatePeerConnectionFactory(
90 _networkThread.get(), _workerThread.get(), _signalingThread.get(),
91 nullptr, nullptr, nullptr);
92 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
93 // Uncomment to get sensitive logs emitted (to stderr or logcat).
94 // rtc::LogMessage::LogToDebug(rtc::LS_SENSITIVE);
95 }
96 return self;
97 }
98
99 - (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)confi guration
100 constraints:(RTCMediaConstraints *)co nstraints
101 delegate:(id<RTCPeerConnectionDele gate>)delegate {
102 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config(
103 [configuration createNativeConfiguration]);
104 if (!config) {
105 return nil;
106 }
107 return [[RTCPeerConnection alloc] initWithFactory:self.nativeFactory.get()
108 config:*config
109 constraints:constraints.constraints
110 delegate:delegate];
111 }
112
113 - (RTCPeerConnection*)
114 peerConnectionWithICEServers:(NSArray*)servers
115 constraints:(RTCMediaConstraints*)constraints
116 delegate:(id<RTCPeerConnectionDelegate>)delegate {
117 webrtc::PeerConnectionInterface::IceServers iceServers;
118 for (RTCICEServer* server in servers) {
119 iceServers.push_back(server.iceServer);
120 }
121 RTCPeerConnection* pc =
122 [[RTCPeerConnection alloc] initWithFactory:self.nativeFactory.get()
123 iceServers:iceServers
124 constraints:constraints.constraints];
125 pc.delegate = delegate;
126 return pc;
127 }
128
129 - (RTCMediaStream*)mediaStreamWithLabel:(NSString*)label {
130 rtc::scoped_refptr<webrtc::MediaStreamInterface> nativeMediaStream =
131 self.nativeFactory->CreateLocalMediaStream([label UTF8String]);
132 return [[RTCMediaStream alloc] initWithMediaStream:nativeMediaStream];
133 }
134
135 - (RTCVideoSource*)videoSourceWithCapturer:(RTCVideoCapturer*)capturer
136 constraints:(RTCMediaConstraints*)constraints {
137 if (!capturer) {
138 return nil;
139 }
140 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
141 self.nativeFactory->CreateVideoSource([capturer takeNativeCapturer], const raints.constraints);
142 return [[RTCVideoSource alloc] initWithMediaSource:source];
143 }
144
145 - (RTCVideoTrack*)videoTrackWithID:(NSString*)videoId
146 source:(RTCVideoSource*)source {
147 rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
148 self.nativeFactory->CreateVideoTrack([videoId UTF8String],
149 source.videoSource);
150 return [[RTCVideoTrack alloc] initWithMediaTrack:track];
151 }
152
153 - (RTCAudioTrack*)audioTrackWithID:(NSString*)audioId {
154 rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
155 self.nativeFactory->CreateAudioTrack([audioId UTF8String], NULL);
156 return [[RTCAudioTrack alloc] initWithMediaTrack:track];
157 }
158
159 @end
OLDNEW
« no previous file with comments | « talk/app/webrtc/objc/RTCPeerConnection+Internal.h ('k') | talk/app/webrtc/objc/RTCPeerConnectionFactory+Internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698