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

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

Powered by Google App Engine
This is Rietveld 408576698