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

Side by Side Diff: talk/app/webrtc/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: Revising some comments. 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
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 void WebRtcIdentityRequestObserver::OnSuccess( 107 void WebRtcIdentityRequestObserver::OnSuccess(
108 rtc::scoped_ptr<rtc::SSLIdentity> identity) { 108 rtc::scoped_ptr<rtc::SSLIdentity> identity) {
109 SignalCertificateReady(rtc::RTCCertificate::Create(std::move(identity))); 109 SignalCertificateReady(rtc::RTCCertificate::Create(std::move(identity)));
110 } 110 }
111 111
112 // static 112 // static
113 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( 113 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription(
114 const SessionDescriptionInterface* source_desc, 114 const SessionDescriptionInterface* source_desc,
115 cricket::MediaType media_type,
115 SessionDescriptionInterface* dest_desc) { 116 SessionDescriptionInterface* dest_desc) {
116 if (!source_desc) 117 if (!source_desc) {
117 return; 118 return;
118 for (size_t m = 0; m < source_desc->number_of_mediasections() && 119 }
119 m < dest_desc->number_of_mediasections(); ++m) { 120 const cricket::ContentInfos& contents =
120 const IceCandidateCollection* source_candidates = 121 source_desc->description()->contents();
121 source_desc->candidates(m); 122 const cricket::ContentInfo* cinfo =
122 const IceCandidateCollection* dest_candidates = dest_desc->candidates(m); 123 GetFirstMediaContent(contents, media_type);
123 for (size_t n = 0; n < source_candidates->count(); ++n) { 124 if (!cinfo) {
124 const IceCandidateInterface* new_candidate = source_candidates->at(n); 125 return;
125 if (!dest_candidates->HasCandidate(new_candidate)) 126 }
126 dest_desc->AddCandidate(source_candidates->at(n)); 127 size_t mediasection_index = static_cast<int>(cinfo - &contents[0]);
127 } 128 const IceCandidateCollection* source_candidates =
129 source_desc->candidates(mediasection_index);
130 const IceCandidateCollection* dest_candidates =
131 dest_desc->candidates(mediasection_index);
132 for (size_t n = 0; n < source_candidates->count(); ++n) {
133 const IceCandidateInterface* new_candidate = source_candidates->at(n);
134 if (!dest_candidates->HasCandidate(new_candidate))
135 dest_desc->AddCandidate(source_candidates->at(n));
128 } 136 }
129 } 137 }
130 138
131 // Private constructor called by other constructors. 139 // Private constructor called by other constructors.
132 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( 140 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
133 rtc::Thread* signaling_thread, 141 rtc::Thread* signaling_thread,
134 cricket::ChannelManager* channel_manager, 142 cricket::ChannelManager* channel_manager,
135 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 143 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
136 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>& 144 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>&
137 identity_request_observer, 145 identity_request_observer,
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 ASSERT(session_version_ + 1 > session_version_); 392 ASSERT(session_version_ + 1 > session_version_);
385 JsepSessionDescription* offer(new JsepSessionDescription( 393 JsepSessionDescription* offer(new JsepSessionDescription(
386 JsepSessionDescription::kOffer)); 394 JsepSessionDescription::kOffer));
387 if (!offer->Initialize(desc, session_id_, 395 if (!offer->Initialize(desc, session_id_,
388 rtc::ToString(session_version_++))) { 396 rtc::ToString(session_version_++))) {
389 delete offer; 397 delete offer;
390 PostCreateSessionDescriptionFailed(request.observer, 398 PostCreateSessionDescriptionFailed(request.observer,
391 "Failed to initialize the offer."); 399 "Failed to initialize the offer.");
392 return; 400 return;
393 } 401 }
394 if (session_->local_description() && 402 if (session_->local_description()) {
395 !request.options.audio_transport_options.ice_restart && 403 // Include all local ICE candidates in the SessionDescription unless
396 !request.options.video_transport_options.ice_restart && 404 // the remote peer has requested an ICE restart.
397 !request.options.data_transport_options.ice_restart) { 405 if (!request.options.audio_transport_options.ice_restart) {
398 // Include all local ice candidates in the SessionDescription unless 406 CopyCandidatesFromSessionDescription(session_->local_description(),
399 // the an ice restart has been requested. 407 cricket::MEDIA_TYPE_AUDIO, offer);
400 CopyCandidatesFromSessionDescription(session_->local_description(), offer); 408 }
409 if (!request.options.video_transport_options.ice_restart) {
410 CopyCandidatesFromSessionDescription(session_->local_description(),
411 cricket::MEDIA_TYPE_VIDEO, offer);
412 }
413 if (!request.options.data_transport_options.ice_restart) {
414 CopyCandidatesFromSessionDescription(session_->local_description(),
415 cricket::MEDIA_TYPE_DATA, offer);
416 }
401 } 417 }
402 PostCreateSessionDescriptionSucceeded(request.observer, offer); 418 PostCreateSessionDescriptionSucceeded(request.observer, offer);
403 } 419 }
404 420
405 void WebRtcSessionDescriptionFactory::InternalCreateAnswer( 421 void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
406 CreateSessionDescriptionRequest request) { 422 CreateSessionDescriptionRequest request) {
407 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1 423 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1
408 // an answer should also contain new ice ufrag and password if an offer has 424 // an answer should also contain new ice ufrag and password if an offer has
409 // been received with new ufrag and password. 425 // been received with new ufrag and password.
410 request.options.audio_transport_options.ice_restart = 426 request.options.audio_transport_options.ice_restart =
411 session_->IceRestartPending(); 427 session_->AudioIceRestartPending();
412 request.options.video_transport_options.ice_restart = 428 request.options.video_transport_options.ice_restart =
413 session_->IceRestartPending(); 429 session_->VideoIceRestartPending();
414 request.options.data_transport_options.ice_restart = 430 request.options.data_transport_options.ice_restart =
415 session_->IceRestartPending(); 431 session_->DataIceRestartPending();
416 // We should pass current ssl role to the transport description factory, if 432 // We should pass current ssl role to the transport description factory, if
417 // there is already an existing ongoing session. 433 // there is already an existing ongoing session.
418 rtc::SSLRole ssl_role; 434 rtc::SSLRole ssl_role;
419 if (session_->GetSslRole(session_->voice_channel(), &ssl_role)) { 435 if (session_->GetSslRole(session_->voice_channel(), &ssl_role)) {
420 request.options.audio_transport_options.prefer_passive_role = 436 request.options.audio_transport_options.prefer_passive_role =
421 (rtc::SSL_SERVER == ssl_role); 437 (rtc::SSL_SERVER == ssl_role);
422 } 438 }
423 if (session_->GetSslRole(session_->video_channel(), &ssl_role)) { 439 if (session_->GetSslRole(session_->video_channel(), &ssl_role)) {
424 request.options.video_transport_options.prefer_passive_role = 440 request.options.video_transport_options.prefer_passive_role =
425 (rtc::SSL_SERVER == ssl_role); 441 (rtc::SSL_SERVER == ssl_role);
(...skipping 20 matching lines...) Expand all
446 ASSERT(session_version_ + 1 > session_version_); 462 ASSERT(session_version_ + 1 > session_version_);
447 JsepSessionDescription* answer(new JsepSessionDescription( 463 JsepSessionDescription* answer(new JsepSessionDescription(
448 JsepSessionDescription::kAnswer)); 464 JsepSessionDescription::kAnswer));
449 if (!answer->Initialize(desc, session_id_, 465 if (!answer->Initialize(desc, session_id_,
450 rtc::ToString(session_version_++))) { 466 rtc::ToString(session_version_++))) {
451 delete answer; 467 delete answer;
452 PostCreateSessionDescriptionFailed(request.observer, 468 PostCreateSessionDescriptionFailed(request.observer,
453 "Failed to initialize the answer."); 469 "Failed to initialize the answer.");
454 return; 470 return;
455 } 471 }
456 if (session_->local_description() && 472 if (session_->local_description()) {
honghaiz3 2016/02/10 01:01:48 Does it make sense to write a method for this part
Taylor Brandstetter 2016/02/10 21:18:32 After refactoring, this section of code is smaller
457 !request.options.audio_transport_options.ice_restart && 473 // Include all local ICE candidates in the SessionDescription unless
458 !request.options.video_transport_options.ice_restart && 474 // the remote peer has requested an ICE restart.
459 !request.options.data_transport_options.ice_restart) { 475 if (!request.options.audio_transport_options.ice_restart) {
460 // Include all local ice candidates in the SessionDescription unless 476 CopyCandidatesFromSessionDescription(session_->local_description(),
461 // the remote peer has requested an ice restart. 477 cricket::MEDIA_TYPE_AUDIO, answer);
462 CopyCandidatesFromSessionDescription(session_->local_description(), answer); 478 }
479 if (!request.options.video_transport_options.ice_restart) {
480 CopyCandidatesFromSessionDescription(session_->local_description(),
481 cricket::MEDIA_TYPE_VIDEO, answer);
482 }
483 if (!request.options.data_transport_options.ice_restart) {
484 CopyCandidatesFromSessionDescription(session_->local_description(),
485 cricket::MEDIA_TYPE_DATA, answer);
486 }
463 } 487 }
464 session_->ResetIceRestartLatch();
honghaiz3 2016/02/10 01:01:48 Is there a good reason to move this from here to S
Taylor Brandstetter 2016/02/10 21:18:32 Yes. If the remote peer starts an ICE restart, cre
465 PostCreateSessionDescriptionSucceeded(request.observer, answer); 488 PostCreateSessionDescriptionSucceeded(request.observer, answer);
466 } 489 }
467 490
468 void WebRtcSessionDescriptionFactory::FailPendingRequests( 491 void WebRtcSessionDescriptionFactory::FailPendingRequests(
469 const std::string& reason) { 492 const std::string& reason) {
470 ASSERT(signaling_thread_->IsCurrent()); 493 ASSERT(signaling_thread_->IsCurrent());
471 while (!create_session_description_requests_.empty()) { 494 while (!create_session_description_requests_.empty()) {
472 const CreateSessionDescriptionRequest& request = 495 const CreateSessionDescriptionRequest& request =
473 create_session_description_requests_.front(); 496 create_session_description_requests_.front();
474 PostCreateSessionDescriptionFailed(request.observer, 497 PostCreateSessionDescriptionFailed(request.observer,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 if (create_session_description_requests_.front().type == 541 if (create_session_description_requests_.front().type ==
519 CreateSessionDescriptionRequest::kOffer) { 542 CreateSessionDescriptionRequest::kOffer) {
520 InternalCreateOffer(create_session_description_requests_.front()); 543 InternalCreateOffer(create_session_description_requests_.front());
521 } else { 544 } else {
522 InternalCreateAnswer(create_session_description_requests_.front()); 545 InternalCreateAnswer(create_session_description_requests_.front());
523 } 546 }
524 create_session_description_requests_.pop(); 547 create_session_description_requests_.pop();
525 } 548 }
526 } 549 }
527 } // namespace webrtc 550 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698