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

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

Issue 2224563004: Add signaling to support ICE renomination. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . Created 4 years, 4 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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } else if (is_offer) { 463 } else if (is_offer) {
464 session_options->recv_video = false; 464 session_options->recv_video = false;
465 } else { 465 } else {
466 session_options->recv_video = true; 466 session_options->recv_video = true;
467 } 467 }
468 468
469 session_options->vad_enabled = rtc_options.voice_activity_detection; 469 session_options->vad_enabled = rtc_options.voice_activity_detection;
470 session_options->bundle_enabled = rtc_options.use_rtp_mux; 470 session_options->bundle_enabled = rtc_options.use_rtp_mux;
471 for (auto& kv : session_options->transport_options) { 471 for (auto& kv : session_options->transport_options) {
472 kv.second.ice_restart = rtc_options.ice_restart; 472 kv.second.ice_restart = rtc_options.ice_restart;
473 kv.second.ice_renomination = rtc_options.ice_renomination;
473 } 474 }
474 475
475 return true; 476 return true;
476 } 477 }
477 478
478 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, 479 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
479 cricket::MediaSessionOptions* session_options) { 480 cricket::MediaSessionOptions* session_options) {
480 bool value = false; 481 bool value = false;
481 size_t mandatory_constraints_satisfied = 0; 482 size_t mandatory_constraints_satisfied = 0;
482 483
(...skipping 23 matching lines...) Expand all
506 } 507 }
507 508
508 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value, 509 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value,
509 &mandatory_constraints_satisfied)) { 510 &mandatory_constraints_satisfied)) {
510 session_options->bundle_enabled = value; 511 session_options->bundle_enabled = value;
511 } else { 512 } else {
512 // kUseRtpMux defaults to true according to spec. 513 // kUseRtpMux defaults to true according to spec.
513 session_options->bundle_enabled = true; 514 session_options->bundle_enabled = true;
514 } 515 }
515 516
517 // kIceRestart defaults to false according to spec.
516 bool ice_restart = false; 518 bool ice_restart = false;
517 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart, 519 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart,
518 &value, &mandatory_constraints_satisfied)) { 520 &value, &mandatory_constraints_satisfied)) {
519 // kIceRestart defaults to false according to spec. 521 ice_restart = value;
honghaiz3 2016/08/11 04:57:58 This appeared to be wrong before. Plus this value
Taylor Brandstetter 2016/08/11 22:36:50 You're right; setting the value here (in ParseCons
honghaiz3 2016/08/12 18:26:40 Done.
520 ice_restart = true; 522 }
523 bool ice_renomination = false;
524 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRenomination,
525 &value, &mandatory_constraints_satisfied)) {
526 ice_renomination = value;
521 } 527 }
522 for (auto& kv : session_options->transport_options) { 528 for (auto& kv : session_options->transport_options) {
523 kv.second.ice_restart = ice_restart; 529 kv.second.ice_restart = ice_restart;
530 kv.second.ice_renomination = ice_renomination;
524 } 531 }
525 532
526 if (!constraints) { 533 if (!constraints) {
527 return true; 534 return true;
528 } 535 }
529 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); 536 return mandatory_constraints_satisfied == constraints->GetMandatory().size();
530 } 537 }
531 538
532 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, 539 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
533 cricket::ServerAddresses* stun_servers, 540 cricket::ServerAddresses* stun_servers,
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 options.voice_activity_detection = value; 987 options.voice_activity_detection = value;
981 } 988 }
982 989
983 if (FindConstraint(constraints, 990 if (FindConstraint(constraints,
984 MediaConstraintsInterface::kIceRestart, 991 MediaConstraintsInterface::kIceRestart,
985 &value, 992 &value,
986 &mandatory_constraints)) { 993 &mandatory_constraints)) {
987 options.ice_restart = value; 994 options.ice_restart = value;
988 } 995 }
989 996
997 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRenomination,
998 &value, &mandatory_constraints)) {
999 options.ice_renomination = value;
1000 }
1001
990 if (FindConstraint(constraints, 1002 if (FindConstraint(constraints,
991 MediaConstraintsInterface::kUseRtpMux, 1003 MediaConstraintsInterface::kUseRtpMux,
992 &value, 1004 &value,
993 &mandatory_constraints)) { 1005 &mandatory_constraints)) {
994 options.use_rtp_mux = value; 1006 options.use_rtp_mux = value;
995 } 1007 }
996 1008
997 CreateOffer(observer, options); 1009 CreateOffer(observer, options);
998 } 1010 }
999 1011
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 // people won't try to use them. 1654 // people won't try to use them.
1643 if (HasDataChannels() && session_->data_channel_type() != cricket::DCT_RTP) { 1655 if (HasDataChannels() && session_->data_channel_type() != cricket::DCT_RTP) {
1644 session_options->data_channel_type = session_->data_channel_type(); 1656 session_options->data_channel_type = session_->data_channel_type();
1645 } 1657 }
1646 1658
1647 session_options->rtcp_cname = rtcp_cname_; 1659 session_options->rtcp_cname = rtcp_cname_;
1648 session_options->crypto_options = factory_->options().crypto_options; 1660 session_options->crypto_options = factory_->options().crypto_options;
1649 return true; 1661 return true;
1650 } 1662 }
1651 1663
1652 void PeerConnection::FinishOptionsForAnswer( 1664 void PeerConnection::InitializeOptionsForAnswer(
1653 cricket::MediaSessionOptions* session_options) { 1665 cricket::MediaSessionOptions* session_options) {
1654 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of 1666 session_options->recv_audio = false;
1655 // ContentInfos. 1667 session_options->recv_video = false;
1656 if (session_->remote_description()) { 1668 if (session_->remote_description()) {
1657 // Initialize the transport_options map. 1669 // Initialize the transport_options map.
1658 for (const cricket::ContentInfo& content : 1670 for (const cricket::ContentInfo& content :
1659 session_->remote_description()->description()->contents()) { 1671 session_->remote_description()->description()->contents()) {
1660 session_options->transport_options[content.name] = 1672 session_options->transport_options[content.name] =
1661 cricket::TransportOptions(); 1673 cricket::TransportOptions();
1662 } 1674 }
1663 } 1675 }
1676 }
1677
1678 void PeerConnection::FinishOptionsForAnswer(
1679 cricket::MediaSessionOptions* session_options) {
1680 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of
1681 // ContentInfos.
1664 AddSendStreams(session_options, senders_, rtp_data_channels_); 1682 AddSendStreams(session_options, senders_, rtp_data_channels_);
1665 session_options->bundle_enabled = 1683 session_options->bundle_enabled =
1666 session_options->bundle_enabled && 1684 session_options->bundle_enabled &&
1667 (session_options->has_audio() || session_options->has_video() || 1685 (session_options->has_audio() || session_options->has_video() ||
1668 session_options->has_data()); 1686 session_options->has_data());
1669 1687
1670 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams 1688 // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams
1671 // are not signaled in the SDP so does not go through that path and must be 1689 // are not signaled in the SDP so does not go through that path and must be
1672 // handled here. 1690 // handled here.
1673 // Intentionally unset the data channel type for RTP data channel. Otherwise 1691 // Intentionally unset the data channel type for RTP data channel. Otherwise
1674 // the RTP data channels would be successfully negotiated by default and the 1692 // the RTP data channels would be successfully negotiated by default and the
1675 // unit tests in WebRtcDataBrowserTest will fail when building with chromium. 1693 // unit tests in WebRtcDataBrowserTest will fail when building with chromium.
1676 // We want to leave RTP data channels broken, so people won't try to use them. 1694 // We want to leave RTP data channels broken, so people won't try to use them.
1677 if (session_->data_channel_type() != cricket::DCT_RTP) { 1695 if (session_->data_channel_type() != cricket::DCT_RTP) {
1678 session_options->data_channel_type = session_->data_channel_type(); 1696 session_options->data_channel_type = session_->data_channel_type();
1679 } 1697 }
1680 session_options->crypto_options = factory_->options().crypto_options; 1698 session_options->crypto_options = factory_->options().crypto_options;
1681 } 1699 }
1682 1700
1683 bool PeerConnection::GetOptionsForAnswer( 1701 bool PeerConnection::GetOptionsForAnswer(
1684 const MediaConstraintsInterface* constraints, 1702 const MediaConstraintsInterface* constraints,
1685 cricket::MediaSessionOptions* session_options) { 1703 cricket::MediaSessionOptions* session_options) {
1686 session_options->recv_audio = false; 1704 InitializeOptionsForAnswer(session_options);
1687 session_options->recv_video = false;
1688 if (!ParseConstraintsForAnswer(constraints, session_options)) { 1705 if (!ParseConstraintsForAnswer(constraints, session_options)) {
1689 return false; 1706 return false;
1690 } 1707 }
1691 session_options->rtcp_cname = rtcp_cname_; 1708 session_options->rtcp_cname = rtcp_cname_;
1692 1709
1693 FinishOptionsForAnswer(session_options); 1710 FinishOptionsForAnswer(session_options);
1694 return true; 1711 return true;
1695 } 1712 }
1696 1713
1697 bool PeerConnection::GetOptionsForAnswer( 1714 bool PeerConnection::GetOptionsForAnswer(
1698 const RTCOfferAnswerOptions& options, 1715 const RTCOfferAnswerOptions& options,
1699 cricket::MediaSessionOptions* session_options) { 1716 cricket::MediaSessionOptions* session_options) {
1700 session_options->recv_audio = false; 1717 InitializeOptionsForAnswer(session_options);
1701 session_options->recv_video = false;
1702 if (!ExtractMediaSessionOptions(options, false, session_options)) { 1718 if (!ExtractMediaSessionOptions(options, false, session_options)) {
1703 return false; 1719 return false;
1704 } 1720 }
1705 session_options->rtcp_cname = rtcp_cname_; 1721 session_options->rtcp_cname = rtcp_cname_;
1706 1722
1707 FinishOptionsForAnswer(session_options); 1723 FinishOptionsForAnswer(session_options);
1708 return true; 1724 return true;
1709 } 1725 }
1710 1726
1711 void PeerConnection::RemoveTracks(cricket::MediaType media_type) { 1727 void PeerConnection::RemoveTracks(cricket::MediaType media_type) {
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 2339
2324 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file, 2340 bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file,
2325 int64_t max_size_bytes) { 2341 int64_t max_size_bytes) {
2326 return media_controller_->call_w()->StartEventLog(file, max_size_bytes); 2342 return media_controller_->call_w()->StartEventLog(file, max_size_bytes);
2327 } 2343 }
2328 2344
2329 void PeerConnection::StopRtcEventLog_w() { 2345 void PeerConnection::StopRtcEventLog_w() {
2330 media_controller_->call_w()->StopEventLog(); 2346 media_controller_->call_w()->StopEventLog();
2331 } 2347 }
2332 } // namespace webrtc 2348 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698