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

Side by Side Diff: talk/app/webrtc/webrtcsessiondescriptionfactory.cc

Issue 1516993002: Properly handle different transports having different SSL roles. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 JsepSessionDescription* offer(new JsepSessionDescription( 383 JsepSessionDescription* offer(new JsepSessionDescription(
384 JsepSessionDescription::kOffer)); 384 JsepSessionDescription::kOffer));
385 if (!offer->Initialize(desc, session_id_, 385 if (!offer->Initialize(desc, session_id_,
386 rtc::ToString(session_version_++))) { 386 rtc::ToString(session_version_++))) {
387 delete offer; 387 delete offer;
388 PostCreateSessionDescriptionFailed(request.observer, 388 PostCreateSessionDescriptionFailed(request.observer,
389 "Failed to initialize the offer."); 389 "Failed to initialize the offer.");
390 return; 390 return;
391 } 391 }
392 if (session_->local_description() && 392 if (session_->local_description() &&
393 !request.options.transport_options.ice_restart) { 393 !request.options.audio_transport_options.ice_restart &&
394 !request.options.video_transport_options.ice_restart &&
395 !request.options.data_transport_options.ice_restart) {
394 // Include all local ice candidates in the SessionDescription unless 396 // Include all local ice candidates in the SessionDescription unless
395 // the an ice restart has been requested. 397 // the an ice restart has been requested.
396 CopyCandidatesFromSessionDescription(session_->local_description(), offer); 398 CopyCandidatesFromSessionDescription(session_->local_description(), offer);
397 } 399 }
398 PostCreateSessionDescriptionSucceeded(request.observer, offer); 400 PostCreateSessionDescriptionSucceeded(request.observer, offer);
399 } 401 }
400 402
401 void WebRtcSessionDescriptionFactory::InternalCreateAnswer( 403 void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
402 CreateSessionDescriptionRequest request) { 404 CreateSessionDescriptionRequest request) {
403 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1 405 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1
404 // an answer should also contain new ice ufrag and password if an offer has 406 // an answer should also contain new ice ufrag and password if an offer has
405 // been received with new ufrag and password. 407 // been received with new ufrag and password.
406 request.options.transport_options.ice_restart = session_->IceRestartPending(); 408 request.options.audio_transport_options.ice_restart =
409 session_->IceRestartPending();
410 request.options.video_transport_options.ice_restart =
411 session_->IceRestartPending();
412 request.options.data_transport_options.ice_restart =
413 session_->IceRestartPending();
407 // We should pass current ssl role to the transport description factory, if 414 // We should pass current ssl role to the transport description factory, if
408 // there is already an existing ongoing session. 415 // there is already an existing ongoing session.
409 rtc::SSLRole ssl_role; 416 rtc::SSLRole ssl_role;
410 if (session_->GetSslRole(&ssl_role)) { 417 if (session_->voice_channel() &&
411 request.options.transport_options.prefer_passive_role = 418 session_->GetSslRole(session_->voice_channel()->transport_name(),
419 &ssl_role)) {
pthatcher1 2015/12/11 03:16:09 Again, a helper method for GetSslRole(base_channel
Taylor Brandstetter 2016/01/07 22:25:55 Done.
420 request.options.audio_transport_options.prefer_passive_role =
421 (rtc::SSL_SERVER == ssl_role);
422 }
423 if (session_->video_channel() &&
424 session_->GetSslRole(session_->video_channel()->transport_name(),
425 &ssl_role)) {
426 request.options.video_transport_options.prefer_passive_role =
427 (rtc::SSL_SERVER == ssl_role);
428 }
429 if (session_->data_channel() &&
430 session_->GetSslRole(session_->data_channel()->transport_name(),
431 &ssl_role)) {
432 request.options.data_transport_options.prefer_passive_role =
412 (rtc::SSL_SERVER == ssl_role); 433 (rtc::SSL_SERVER == ssl_role);
413 } 434 }
414 435
415 cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer( 436 cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer(
416 session_->remote_description() 437 session_->remote_description()
417 ? session_->remote_description()->description() 438 ? session_->remote_description()->description()
418 : nullptr, 439 : nullptr,
419 request.options, session_->local_description() 440 request.options, session_->local_description()
420 ? session_->local_description()->description() 441 ? session_->local_description()->description()
421 : nullptr)); 442 : nullptr));
422 // RFC 3264 443 // RFC 3264
423 // If the answer is different from the offer in any way (different IP 444 // 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. 445 // 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 446 // 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. 447 // unrelated to the version number in the o line of the offer.
427 // Get a new version number by increasing the |session_version_answer_|. 448 // 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. 449 // The |session_version_| is a uint64_t, the wrap around should not happen.
429 ASSERT(session_version_ + 1 > session_version_); 450 ASSERT(session_version_ + 1 > session_version_);
430 JsepSessionDescription* answer(new JsepSessionDescription( 451 JsepSessionDescription* answer(new JsepSessionDescription(
431 JsepSessionDescription::kAnswer)); 452 JsepSessionDescription::kAnswer));
432 if (!answer->Initialize(desc, session_id_, 453 if (!answer->Initialize(desc, session_id_,
433 rtc::ToString(session_version_++))) { 454 rtc::ToString(session_version_++))) {
434 delete answer; 455 delete answer;
435 PostCreateSessionDescriptionFailed(request.observer, 456 PostCreateSessionDescriptionFailed(request.observer,
436 "Failed to initialize the answer."); 457 "Failed to initialize the answer.");
437 return; 458 return;
438 } 459 }
439 if (session_->local_description() && 460 if (session_->local_description() &&
440 !request.options.transport_options.ice_restart) { 461 !request.options.audio_transport_options.ice_restart &&
462 !request.options.video_transport_options.ice_restart &&
463 !request.options.data_transport_options.ice_restart) {
441 // Include all local ice candidates in the SessionDescription unless 464 // Include all local ice candidates in the SessionDescription unless
442 // the remote peer has requested an ice restart. 465 // the remote peer has requested an ice restart.
443 CopyCandidatesFromSessionDescription(session_->local_description(), answer); 466 CopyCandidatesFromSessionDescription(session_->local_description(), answer);
444 } 467 }
445 session_->ResetIceRestartLatch(); 468 session_->ResetIceRestartLatch();
446 PostCreateSessionDescriptionSucceeded(request.observer, answer); 469 PostCreateSessionDescriptionSucceeded(request.observer, answer);
447 } 470 }
448 471
449 void WebRtcSessionDescriptionFactory::FailPendingRequests( 472 void WebRtcSessionDescriptionFactory::FailPendingRequests(
450 const std::string& reason) { 473 const std::string& reason) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 if (create_session_description_requests_.front().type == 522 if (create_session_description_requests_.front().type ==
500 CreateSessionDescriptionRequest::kOffer) { 523 CreateSessionDescriptionRequest::kOffer) {
501 InternalCreateOffer(create_session_description_requests_.front()); 524 InternalCreateOffer(create_session_description_requests_.front());
502 } else { 525 } else {
503 InternalCreateAnswer(create_session_description_requests_.front()); 526 InternalCreateAnswer(create_session_description_requests_.front());
504 } 527 }
505 create_session_description_requests_.pop(); 528 create_session_description_requests_.pop();
506 } 529 }
507 } 530 }
508 } // namespace webrtc 531 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698