OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #import "RTCVideoTrack+Internal.h" | 48 #import "RTCVideoTrack+Internal.h" |
49 | 49 |
50 #include "webrtc/api/audiotrack.h" | 50 #include "webrtc/api/audiotrack.h" |
51 #include "webrtc/api/mediastreaminterface.h" | 51 #include "webrtc/api/mediastreaminterface.h" |
52 #include "webrtc/api/peerconnectioninterface.h" | 52 #include "webrtc/api/peerconnectioninterface.h" |
53 #include "webrtc/api/videotrack.h" | 53 #include "webrtc/api/videotrack.h" |
54 #include "webrtc/base/logging.h" | 54 #include "webrtc/base/logging.h" |
55 #include "webrtc/base/ssladapter.h" | 55 #include "webrtc/base/ssladapter.h" |
56 | 56 |
57 @implementation RTCPeerConnectionFactory { | 57 @implementation RTCPeerConnectionFactory { |
| 58 std::unique_ptr<rtc::Thread> _networkThread; |
| 59 std::unique_ptr<rtc::Thread> _workerThread; |
58 std::unique_ptr<rtc::Thread> _signalingThread; | 60 std::unique_ptr<rtc::Thread> _signalingThread; |
59 std::unique_ptr<rtc::Thread> _workerThread; | |
60 } | 61 } |
61 | 62 |
62 @synthesize nativeFactory = _nativeFactory; | 63 @synthesize nativeFactory = _nativeFactory; |
63 | 64 |
64 + (void)initializeSSL { | 65 + (void)initializeSSL { |
65 BOOL initialized = rtc::InitializeSSL(); | 66 BOOL initialized = rtc::InitializeSSL(); |
66 NSAssert(initialized, @"Failed to initialize SSL library"); | 67 NSAssert(initialized, @"Failed to initialize SSL library"); |
67 } | 68 } |
68 | 69 |
69 + (void)deinitializeSSL { | 70 + (void)deinitializeSSL { |
70 BOOL deinitialized = rtc::CleanupSSL(); | 71 BOOL deinitialized = rtc::CleanupSSL(); |
71 NSAssert(deinitialized, @"Failed to deinitialize SSL library"); | 72 NSAssert(deinitialized, @"Failed to deinitialize SSL library"); |
72 } | 73 } |
73 | 74 |
74 - (id)init { | 75 - (id)init { |
75 if ((self = [super init])) { | 76 if ((self = [super init])) { |
76 _signalingThread.reset(new rtc::Thread()); | 77 _networkThread = rtc::Thread::CreateWithSocketServer(); |
77 BOOL result = _signalingThread->Start(); | 78 BOOL result = _networkThread->Start(); |
78 NSAssert(result, @"Failed to start signaling thread."); | 79 NSAssert(result, @"Failed to start network thread."); |
79 _workerThread.reset(new rtc::Thread()); | 80 |
| 81 _workerThread = rtc::Thread::Create(); |
80 result = _workerThread->Start(); | 82 result = _workerThread->Start(); |
81 NSAssert(result, @"Failed to start worker thread."); | 83 NSAssert(result, @"Failed to start worker thread."); |
82 | 84 |
| 85 _signalingThread = rtc::Thread::Create(); |
| 86 result = _signalingThread->Start(); |
| 87 NSAssert(result, @"Failed to start signaling thread."); |
| 88 |
83 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 89 _nativeFactory = webrtc::CreatePeerConnectionFactory( |
84 _signalingThread.get(), _workerThread.get(), nullptr, nullptr, nullptr); | 90 _networkThread.get(), _workerThread.get(), _signalingThread.get(), |
| 91 nullptr, nullptr, nullptr); |
85 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 92 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
86 // Uncomment to get sensitive logs emitted (to stderr or logcat). | 93 // Uncomment to get sensitive logs emitted (to stderr or logcat). |
87 // rtc::LogMessage::LogToDebug(rtc::LS_SENSITIVE); | 94 // rtc::LogMessage::LogToDebug(rtc::LS_SENSITIVE); |
88 } | 95 } |
89 return self; | 96 return self; |
90 } | 97 } |
91 | 98 |
92 - (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)confi
guration | 99 - (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)confi
guration |
93 constraints:(RTCMediaConstraints *)co
nstraints | 100 constraints:(RTCMediaConstraints *)co
nstraints |
94 delegate:(id<RTCPeerConnectionDele
gate>)delegate { | 101 delegate:(id<RTCPeerConnectionDele
gate>)delegate { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 return [[RTCVideoTrack alloc] initWithMediaTrack:track]; | 145 return [[RTCVideoTrack alloc] initWithMediaTrack:track]; |
139 } | 146 } |
140 | 147 |
141 - (RTCAudioTrack*)audioTrackWithID:(NSString*)audioId { | 148 - (RTCAudioTrack*)audioTrackWithID:(NSString*)audioId { |
142 rtc::scoped_refptr<webrtc::AudioTrackInterface> track = | 149 rtc::scoped_refptr<webrtc::AudioTrackInterface> track = |
143 self.nativeFactory->CreateAudioTrack([audioId UTF8String], NULL); | 150 self.nativeFactory->CreateAudioTrack([audioId UTF8String], NULL); |
144 return [[RTCAudioTrack alloc] initWithMediaTrack:track]; | 151 return [[RTCAudioTrack alloc] initWithMediaTrack:track]; |
145 } | 152 } |
146 | 153 |
147 @end | 154 @end |
OLD | NEW |