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

Side by Side Diff: webrtc/api/webrtcsessiondescriptionfactory.cc

Issue 1671173002: Track pending ICE restarts independently for different media sections. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merging with master. Created 4 years, 10 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
« no previous file with comments | « webrtc/api/webrtcsessiondescriptionfactory.h ('k') | webrtc/p2p/base/transport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 void WebRtcIdentityRequestObserver::OnSuccess( 90 void WebRtcIdentityRequestObserver::OnSuccess(
91 rtc::scoped_ptr<rtc::SSLIdentity> identity) { 91 rtc::scoped_ptr<rtc::SSLIdentity> identity) {
92 SignalCertificateReady(rtc::RTCCertificate::Create(std::move(identity))); 92 SignalCertificateReady(rtc::RTCCertificate::Create(std::move(identity)));
93 } 93 }
94 94
95 // static 95 // static
96 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( 96 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription(
97 const SessionDescriptionInterface* source_desc, 97 const SessionDescriptionInterface* source_desc,
98 const std::string& content_name,
98 SessionDescriptionInterface* dest_desc) { 99 SessionDescriptionInterface* dest_desc) {
99 if (!source_desc) 100 if (!source_desc) {
100 return; 101 return;
101 for (size_t m = 0; m < source_desc->number_of_mediasections() && 102 }
102 m < dest_desc->number_of_mediasections(); ++m) { 103 const cricket::ContentInfos& contents =
103 const IceCandidateCollection* source_candidates = 104 source_desc->description()->contents();
104 source_desc->candidates(m); 105 const cricket::ContentInfo* cinfo =
105 const IceCandidateCollection* dest_candidates = dest_desc->candidates(m); 106 source_desc->description()->GetContentByName(content_name);
106 for (size_t n = 0; n < source_candidates->count(); ++n) { 107 if (!cinfo) {
107 const IceCandidateInterface* new_candidate = source_candidates->at(n); 108 return;
108 if (!dest_candidates->HasCandidate(new_candidate)) 109 }
109 dest_desc->AddCandidate(source_candidates->at(n)); 110 size_t mediasection_index = static_cast<int>(cinfo - &contents[0]);
111 const IceCandidateCollection* source_candidates =
112 source_desc->candidates(mediasection_index);
113 const IceCandidateCollection* dest_candidates =
114 dest_desc->candidates(mediasection_index);
115 for (size_t n = 0; n < source_candidates->count(); ++n) {
116 const IceCandidateInterface* new_candidate = source_candidates->at(n);
117 if (!dest_candidates->HasCandidate(new_candidate)) {
118 dest_desc->AddCandidate(source_candidates->at(n));
110 } 119 }
111 } 120 }
112 } 121 }
113 122
114 // Private constructor called by other constructors. 123 // Private constructor called by other constructors.
115 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( 124 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
116 rtc::Thread* signaling_thread, 125 rtc::Thread* signaling_thread,
117 cricket::ChannelManager* channel_manager, 126 cricket::ChannelManager* channel_manager,
118 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 127 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
119 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>& 128 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>&
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 ASSERT(session_version_ + 1 > session_version_); 376 ASSERT(session_version_ + 1 > session_version_);
368 JsepSessionDescription* offer(new JsepSessionDescription( 377 JsepSessionDescription* offer(new JsepSessionDescription(
369 JsepSessionDescription::kOffer)); 378 JsepSessionDescription::kOffer));
370 if (!offer->Initialize(desc, session_id_, 379 if (!offer->Initialize(desc, session_id_,
371 rtc::ToString(session_version_++))) { 380 rtc::ToString(session_version_++))) {
372 delete offer; 381 delete offer;
373 PostCreateSessionDescriptionFailed(request.observer, 382 PostCreateSessionDescriptionFailed(request.observer,
374 "Failed to initialize the offer."); 383 "Failed to initialize the offer.");
375 return; 384 return;
376 } 385 }
377 if (session_->local_description() && 386 if (session_->local_description()) {
378 !request.options.audio_transport_options.ice_restart && 387 for (const cricket::ContentInfo& content :
379 !request.options.video_transport_options.ice_restart && 388 session_->local_description()->description()->contents()) {
380 !request.options.data_transport_options.ice_restart) { 389 // Include all local ICE candidates in the SessionDescription unless
381 // Include all local ice candidates in the SessionDescription unless 390 // the remote peer has requested an ICE restart.
382 // the an ice restart has been requested. 391 if (!request.options.transport_options[content.name].ice_restart) {
383 CopyCandidatesFromSessionDescription(session_->local_description(), offer); 392 CopyCandidatesFromSessionDescription(session_->local_description(),
393 content.name, offer);
394 }
395 }
384 } 396 }
385 PostCreateSessionDescriptionSucceeded(request.observer, offer); 397 PostCreateSessionDescriptionSucceeded(request.observer, offer);
386 } 398 }
387 399
388 void WebRtcSessionDescriptionFactory::InternalCreateAnswer( 400 void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
389 CreateSessionDescriptionRequest request) { 401 CreateSessionDescriptionRequest request) {
390 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1 402 if (session_->remote_description()) {
391 // an answer should also contain new ice ufrag and password if an offer has 403 for (const cricket::ContentInfo& content :
392 // been received with new ufrag and password. 404 session_->remote_description()->description()->contents()) {
393 request.options.audio_transport_options.ice_restart = 405 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1
394 session_->IceRestartPending(); 406 // an answer should also contain new ICE ufrag and password if an offer
395 request.options.video_transport_options.ice_restart = 407 // has been received with new ufrag and password.
396 session_->IceRestartPending(); 408 request.options.transport_options[content.name].ice_restart =
397 request.options.data_transport_options.ice_restart = 409 session_->IceRestartPending(content.name);
398 session_->IceRestartPending(); 410 // We should pass the current SSL role to the transport description
399 // We should pass current ssl role to the transport description factory, if 411 // factory, if there is already an existing ongoing session.
400 // there is already an existing ongoing session. 412 rtc::SSLRole ssl_role;
401 rtc::SSLRole ssl_role; 413 if (session_->GetSslRole(session_->GetChannel(content.name), &ssl_role)) {
402 if (session_->GetSslRole(session_->voice_channel(), &ssl_role)) { 414 request.options.transport_options[content.name].prefer_passive_role =
403 request.options.audio_transport_options.prefer_passive_role = 415 (rtc::SSL_SERVER == ssl_role);
404 (rtc::SSL_SERVER == ssl_role); 416 }
405 } 417 }
406 if (session_->GetSslRole(session_->video_channel(), &ssl_role)) {
407 request.options.video_transport_options.prefer_passive_role =
408 (rtc::SSL_SERVER == ssl_role);
409 }
410 if (session_->GetSslRole(session_->data_channel(), &ssl_role)) {
411 request.options.data_transport_options.prefer_passive_role =
412 (rtc::SSL_SERVER == ssl_role);
413 } 418 }
414 419
415 cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer( 420 cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer(
416 session_->remote_description() 421 session_->remote_description()
417 ? session_->remote_description()->description() 422 ? session_->remote_description()->description()
418 : nullptr, 423 : nullptr,
419 request.options, session_->local_description() 424 request.options, session_->local_description()
420 ? session_->local_description()->description() 425 ? session_->local_description()->description()
421 : nullptr)); 426 : nullptr));
422 // RFC 3264 427 // RFC 3264
423 // If the answer is different from the offer in any way (different IP 428 // If the answer is different from the offer in any way (different IP
424 // addresses, ports, etc.), the origin line MUST be different in the answer. 429 // addresses, ports, etc.), the origin line MUST be different in the answer.
425 // In that case, the version number in the "o=" line of the answer is 430 // In that case, the version number in the "o=" line of the answer is
426 // unrelated to the version number in the o line of the offer. 431 // unrelated to the version number in the o line of the offer.
427 // Get a new version number by increasing the |session_version_answer_|. 432 // Get a new version number by increasing the |session_version_answer_|.
428 // The |session_version_| is a uint64_t, the wrap around should not happen. 433 // The |session_version_| is a uint64_t, the wrap around should not happen.
429 ASSERT(session_version_ + 1 > session_version_); 434 ASSERT(session_version_ + 1 > session_version_);
430 JsepSessionDescription* answer(new JsepSessionDescription( 435 JsepSessionDescription* answer(new JsepSessionDescription(
431 JsepSessionDescription::kAnswer)); 436 JsepSessionDescription::kAnswer));
432 if (!answer->Initialize(desc, session_id_, 437 if (!answer->Initialize(desc, session_id_,
433 rtc::ToString(session_version_++))) { 438 rtc::ToString(session_version_++))) {
434 delete answer; 439 delete answer;
435 PostCreateSessionDescriptionFailed(request.observer, 440 PostCreateSessionDescriptionFailed(request.observer,
436 "Failed to initialize the answer."); 441 "Failed to initialize the answer.");
437 return; 442 return;
438 } 443 }
439 if (session_->local_description() && 444 if (session_->local_description()) {
440 !request.options.audio_transport_options.ice_restart && 445 for (const cricket::ContentInfo& content :
441 !request.options.video_transport_options.ice_restart && 446 session_->local_description()->description()->contents()) {
442 !request.options.data_transport_options.ice_restart) { 447 // Include all local ICE candidates in the SessionDescription unless
443 // Include all local ice candidates in the SessionDescription unless 448 // the remote peer has requested an ICE restart.
444 // the remote peer has requested an ice restart. 449 if (!request.options.transport_options[content.name].ice_restart) {
445 CopyCandidatesFromSessionDescription(session_->local_description(), answer); 450 CopyCandidatesFromSessionDescription(session_->local_description(),
451 content.name, answer);
452 }
453 }
446 } 454 }
447 session_->ResetIceRestartLatch();
448 PostCreateSessionDescriptionSucceeded(request.observer, answer); 455 PostCreateSessionDescriptionSucceeded(request.observer, answer);
449 } 456 }
450 457
451 void WebRtcSessionDescriptionFactory::FailPendingRequests( 458 void WebRtcSessionDescriptionFactory::FailPendingRequests(
452 const std::string& reason) { 459 const std::string& reason) {
453 ASSERT(signaling_thread_->IsCurrent()); 460 ASSERT(signaling_thread_->IsCurrent());
454 while (!create_session_description_requests_.empty()) { 461 while (!create_session_description_requests_.empty()) {
455 const CreateSessionDescriptionRequest& request = 462 const CreateSessionDescriptionRequest& request =
456 create_session_description_requests_.front(); 463 create_session_description_requests_.front();
457 PostCreateSessionDescriptionFailed(request.observer, 464 PostCreateSessionDescriptionFailed(request.observer,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (create_session_description_requests_.front().type == 508 if (create_session_description_requests_.front().type ==
502 CreateSessionDescriptionRequest::kOffer) { 509 CreateSessionDescriptionRequest::kOffer) {
503 InternalCreateOffer(create_session_description_requests_.front()); 510 InternalCreateOffer(create_session_description_requests_.front());
504 } else { 511 } else {
505 InternalCreateAnswer(create_session_description_requests_.front()); 512 InternalCreateAnswer(create_session_description_requests_.front());
506 } 513 }
507 create_session_description_requests_.pop(); 514 create_session_description_requests_.pop();
508 } 515 }
509 } 516 }
510 } // namespace webrtc 517 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsessiondescriptionfactory.h ('k') | webrtc/p2p/base/transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698