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 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 PeerConnectionInterface::SignalingState new_state) { | 120 PeerConnectionInterface::SignalingState new_state) { |
121 RTCSignalingState state = | 121 RTCSignalingState state = |
122 [[RTCPeerConnection class] signalingStateForNativeState:new_state]; | 122 [[RTCPeerConnection class] signalingStateForNativeState:new_state]; |
123 RTCPeerConnection *peer_connection = peer_connection_; | 123 RTCPeerConnection *peer_connection = peer_connection_; |
124 [peer_connection.delegate peerConnection:peer_connection | 124 [peer_connection.delegate peerConnection:peer_connection |
125 didChangeSignalingState:state]; | 125 didChangeSignalingState:state]; |
126 } | 126 } |
127 | 127 |
128 void PeerConnectionDelegateAdapter::OnAddStream( | 128 void PeerConnectionDelegateAdapter::OnAddStream( |
129 rtc::scoped_refptr<MediaStreamInterface> stream) { | 129 rtc::scoped_refptr<MediaStreamInterface> stream) { |
130 RTCMediaStream *mediaStream = | 130 RTCMediaStream* mediaStream = GetOrCreateObjcStream(stream); |
131 [[RTCMediaStream alloc] initWithNativeMediaStream:stream]; | |
132 RTCPeerConnection *peer_connection = peer_connection_; | 131 RTCPeerConnection *peer_connection = peer_connection_; |
133 [peer_connection.delegate peerConnection:peer_connection | 132 [peer_connection.delegate peerConnection:peer_connection |
134 didAddStream:mediaStream]; | 133 didAddStream:mediaStream]; |
135 } | 134 } |
136 | 135 |
137 void PeerConnectionDelegateAdapter::OnRemoveStream( | 136 void PeerConnectionDelegateAdapter::OnRemoveStream( |
138 rtc::scoped_refptr<MediaStreamInterface> stream) { | 137 rtc::scoped_refptr<MediaStreamInterface> stream) { |
139 RTCMediaStream *mediaStream = | 138 RTCMediaStream *mediaStream = |
140 [[RTCMediaStream alloc] initWithNativeMediaStream:stream]; | 139 [[RTCMediaStream alloc] initWithNativeMediaStream:stream]; |
141 RTCPeerConnection *peer_connection = peer_connection_; | 140 RTCPeerConnection *peer_connection = peer_connection_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 new JsepIceCandidate(candidate.transport_name(), -1, candidate)); | 192 new JsepIceCandidate(candidate.transport_name(), -1, candidate)); |
194 RTCIceCandidate* ice_candidate = [[RTCIceCandidate alloc] | 193 RTCIceCandidate* ice_candidate = [[RTCIceCandidate alloc] |
195 initWithNativeCandidate:candidate_wrapper.get()]; | 194 initWithNativeCandidate:candidate_wrapper.get()]; |
196 [ice_candidates addObject:ice_candidate]; | 195 [ice_candidates addObject:ice_candidate]; |
197 } | 196 } |
198 RTCPeerConnection* peer_connection = peer_connection_; | 197 RTCPeerConnection* peer_connection = peer_connection_; |
199 [peer_connection.delegate peerConnection:peer_connection | 198 [peer_connection.delegate peerConnection:peer_connection |
200 didRemoveIceCandidates:ice_candidates]; | 199 didRemoveIceCandidates:ice_candidates]; |
201 } | 200 } |
202 | 201 |
202 void PeerConnectionDelegateAdapter::OnAddTrack( | |
203 rtc::scoped_refptr<RtpReceiverInterface> receiver, | |
204 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams) { | |
205 RTCRtpReceiver* rtpReceiver = | |
tkchin_webrtc
2016/11/22 20:41:34
* on right
RTCRtpReceiver *rtpReceiver
here and e
Zhi Huang
2016/11/22 23:38:42
Done.
| |
206 [[RTCRtpReceiver alloc] initWithNativeRtpReceiver:receiver]; | |
207 NSMutableArray* mediaStreams = | |
208 [NSMutableArray arrayWithCapacity:streams.size()]; | |
209 for (const auto stream : streams) { | |
210 RTCMediaStream* mediaStream = GetOrCreateObjcStream(stream); | |
211 [mediaStreams addObject:mediaStream]; | |
212 } | |
213 RTCPeerConnection* peer_connection = peer_connection_; | |
214 [peer_connection.delegate peerConnection:peer_connection | |
215 didAddTrack:rtpReceiver | |
216 attachedStreams:mediaStreams]; | |
217 } | |
218 | |
219 RTCMediaStream* PeerConnectionDelegateAdapter::GetOrCreateObjcStream( | |
tkchin_webrtc
2016/11/22 20:41:34
I'd suggest placing these streams refs on peerconn
Zhi Huang
2016/11/22 23:38:42
Ah, yes. This is a good point.
Done.
| |
220 rtc::scoped_refptr<MediaStreamInterface> stream) { | |
221 RTCMediaStream* mediaStream = | |
222 nativeToObjcMediaStream_[[NSNumber numberWithLong:(long)stream.get()]]; | |
223 if (!mediaStream) { | |
224 mediaStream = | |
225 [[RTCMediaStream alloc] initWithNativeMediaStream:stream.get()]; | |
226 nativeToObjcMediaStream_[[NSNumber numberWithLong:(long)stream.get()]] = | |
227 mediaStream; | |
228 } | |
229 return mediaStream; | |
230 } | |
231 | |
203 } // namespace webrtc | 232 } // namespace webrtc |
204 | 233 |
205 | 234 |
206 @implementation RTCPeerConnection { | 235 @implementation RTCPeerConnection { |
207 NSMutableArray<RTCMediaStream *> *_localStreams; | 236 NSMutableArray<RTCMediaStream *> *_localStreams; |
208 std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer; | 237 std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer; |
209 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; | 238 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; |
210 BOOL _hasStartedRtcEventLog; | 239 BOOL _hasStartedRtcEventLog; |
211 } | 240 } |
212 | 241 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 case RTCStatsOutputLevelDebug: | 612 case RTCStatsOutputLevelDebug: |
584 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; | 613 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; |
585 } | 614 } |
586 } | 615 } |
587 | 616 |
588 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { | 617 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { |
589 return _peerConnection; | 618 return _peerConnection; |
590 } | 619 } |
591 | 620 |
592 @end | 621 @end |
OLD | NEW |