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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm

Issue 1972483002: Pass around the candidate removals events in IOS clients Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 7 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
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 "RTCPeerConnection+Private.h" 11 #import "RTCPeerConnection+Private.h"
12 12
13 #import "NSString+StdString.h" 13 #import "NSString+StdString.h"
14 #import "RTCConfiguration+Private.h" 14 #import "RTCConfiguration+Private.h"
15 #import "RTCDataChannel+Private.h" 15 #import "RTCDataChannel+Private.h"
16 #import "RTCIceCandidate+Private.h" 16 #import "RTCIceCandidate+Private.h"
17 #import "RTCMediaConstraints+Private.h" 17 #import "RTCMediaConstraints+Private.h"
18 #import "RTCMediaStream+Private.h" 18 #import "RTCMediaStream+Private.h"
19 #import "RTCPeerConnectionFactory+Private.h" 19 #import "RTCPeerConnectionFactory+Private.h"
20 #import "RTCRtpReceiver+Private.h" 20 #import "RTCRtpReceiver+Private.h"
21 #import "RTCRtpSender+Private.h" 21 #import "RTCRtpSender+Private.h"
22 #import "RTCSessionDescription+Private.h" 22 #import "RTCSessionDescription+Private.h"
23 #import "RTCStatsReport+Private.h" 23 #import "RTCStatsReport+Private.h"
24 #import "WebRTC/RTCLogging.h" 24 #import "WebRTC/RTCLogging.h"
25 25
26 #include <memory> 26 #include <memory>
27 27
28 #include "webrtc/api/jsepicecandidate.h"
28 #include "webrtc/base/checks.h" 29 #include "webrtc/base/checks.h"
29 30
30 NSString * const kRTCPeerConnectionErrorDomain = 31 NSString * const kRTCPeerConnectionErrorDomain =
31 @"org.webrtc.RTCPeerConnection"; 32 @"org.webrtc.RTCPeerConnection";
32 int const kRTCPeerConnnectionSessionDescriptionError = -1; 33 int const kRTCPeerConnnectionSessionDescriptionError = -1;
33 34
34 namespace webrtc { 35 namespace webrtc {
35 36
36 class CreateSessionDescriptionObserverAdapter 37 class CreateSessionDescriptionObserverAdapter
37 : public CreateSessionDescriptionObserver { 38 : public CreateSessionDescriptionObserver {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 176 }
176 177
177 void PeerConnectionDelegateAdapter::OnIceCandidate( 178 void PeerConnectionDelegateAdapter::OnIceCandidate(
178 const IceCandidateInterface *candidate) { 179 const IceCandidateInterface *candidate) {
179 RTCIceCandidate *iceCandidate = 180 RTCIceCandidate *iceCandidate =
180 [[RTCIceCandidate alloc] initWithNativeCandidate:candidate]; 181 [[RTCIceCandidate alloc] initWithNativeCandidate:candidate];
181 RTCPeerConnection *peer_connection = peer_connection_; 182 RTCPeerConnection *peer_connection = peer_connection_;
182 [peer_connection.delegate peerConnection:peer_connection 183 [peer_connection.delegate peerConnection:peer_connection
183 didGenerateIceCandidate:iceCandidate]; 184 didGenerateIceCandidate:iceCandidate];
184 } 185 }
186
187 void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
188 const std::vector<cricket::Candidate>& candidates) {
189 NSMutableArray* ice_candidates =
190 [NSMutableArray arrayWithCapacity:candidates.size()];
191 for (const auto& candidate : candidates) {
192 std::unique_ptr<JsepIceCandidate> candidate_wrapper(
193 new JsepIceCandidate(candidate.transport_name(), -1, candidate));
194 RTCIceCandidate* ice_candidate = [[RTCIceCandidate alloc]
195 initWithNativeCandidate:candidate_wrapper.get()];
196 [ice_candidates addObject:ice_candidate];
197 }
198 RTCPeerConnection* peer_connection = peer_connection_;
199 [peer_connection.delegate peerConnection:peer_connection
200 didRemoveIceCandidates:ice_candidates];
201 }
202
185 } // namespace webrtc 203 } // namespace webrtc
186 204
187 205
188 @implementation RTCPeerConnection { 206 @implementation RTCPeerConnection {
189 NSMutableArray *_localStreams; 207 NSMutableArray *_localStreams;
190 std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer; 208 std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer;
191 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; 209 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
192 } 210 }
193 211
194 @synthesize delegate = _delegate; 212 @synthesize delegate = _delegate;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 - (void)close { 282 - (void)close {
265 _peerConnection->Close(); 283 _peerConnection->Close();
266 } 284 }
267 285
268 - (void)addIceCandidate:(RTCIceCandidate *)candidate { 286 - (void)addIceCandidate:(RTCIceCandidate *)candidate {
269 std::unique_ptr<const webrtc::IceCandidateInterface> iceCandidate( 287 std::unique_ptr<const webrtc::IceCandidateInterface> iceCandidate(
270 candidate.nativeCandidate); 288 candidate.nativeCandidate);
271 _peerConnection->AddIceCandidate(iceCandidate.get()); 289 _peerConnection->AddIceCandidate(iceCandidate.get());
272 } 290 }
273 291
292 - (void)removeRemoteIceCandidates:(NSArray<RTCIceCandidate *> *)iceCandidates {
293 std::vector<cricket::Candidate> candidates;
294 RTCLogInfo(@"Remove %lu remote ice candidates",
295 (unsigned long)iceCandidates.count);
296 for (RTCIceCandidate *iceCandidate in iceCandidates) {
297 std::unique_ptr<const webrtc::IceCandidateInterface> candidate(
298 iceCandidate.nativeCandidate);
299 if (candidate) {
300 candidates.push_back(candidate->candidate());
301 // Need to fill the transport name from the sdp_mid.
302 candidates.back().set_transport_name(candidate->sdp_mid());
303 }
304 }
305 if (!candidates.empty()) {
306 _peerConnection->RemoveIceCandidates(candidates);
307 }
308 }
309
274 - (void)addStream:(RTCMediaStream *)stream { 310 - (void)addStream:(RTCMediaStream *)stream {
275 if (!_peerConnection->AddStream(stream.nativeMediaStream)) { 311 if (!_peerConnection->AddStream(stream.nativeMediaStream)) {
276 RTCLogError(@"Failed to add stream: %@", stream); 312 RTCLogError(@"Failed to add stream: %@", stream);
277 return; 313 return;
278 } 314 }
279 [_localStreams addObject:stream]; 315 [_localStreams addObject:stream];
280 } 316 }
281 317
282 - (void)removeStream:(RTCMediaStream *)stream { 318 - (void)removeStream:(RTCMediaStream *)stream {
283 _peerConnection->RemoveStream(stream.nativeMediaStream); 319 _peerConnection->RemoveStream(stream.nativeMediaStream);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 case RTCStatsOutputLevelDebug: 554 case RTCStatsOutputLevelDebug:
519 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; 555 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug;
520 } 556 }
521 } 557 }
522 558
523 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { 559 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection {
524 return _peerConnection; 560 return _peerConnection;
525 } 561 }
526 562
527 @end 563 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698