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

Side by Side Diff: talk/app/webrtc/peerconnection.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 2012 Google Inc. 3 * Copyright 2012 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 492 }
493 493
494 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) { 494 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) {
495 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0); 495 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0);
496 } 496 }
497 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) { 497 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) {
498 session_options->recv_video = (rtc_options.offer_to_receive_video > 0); 498 session_options->recv_video = (rtc_options.offer_to_receive_video > 0);
499 } 499 }
500 500
501 session_options->vad_enabled = rtc_options.voice_activity_detection; 501 session_options->vad_enabled = rtc_options.voice_activity_detection;
502 session_options->transport_options.ice_restart = rtc_options.ice_restart; 502 session_options->audio_transport_options.ice_restart =
503 rtc_options.ice_restart;
504 session_options->video_transport_options.ice_restart =
505 rtc_options.ice_restart;
506 session_options->data_transport_options.ice_restart = rtc_options.ice_restart;
503 session_options->bundle_enabled = rtc_options.use_rtp_mux; 507 session_options->bundle_enabled = rtc_options.use_rtp_mux;
504 508
505 return true; 509 return true;
506 } 510 }
507 511
508 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, 512 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
509 cricket::MediaSessionOptions* session_options) { 513 cricket::MediaSessionOptions* session_options) {
510 bool value = false; 514 bool value = false;
511 size_t mandatory_constraints_satisfied = 0; 515 size_t mandatory_constraints_satisfied = 0;
512 516
(...skipping 25 matching lines...) Expand all
538 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value, 542 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value,
539 &mandatory_constraints_satisfied)) { 543 &mandatory_constraints_satisfied)) {
540 session_options->bundle_enabled = value; 544 session_options->bundle_enabled = value;
541 } else { 545 } else {
542 // kUseRtpMux defaults to true according to spec. 546 // kUseRtpMux defaults to true according to spec.
543 session_options->bundle_enabled = true; 547 session_options->bundle_enabled = true;
544 } 548 }
545 549
546 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart, 550 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart,
547 &value, &mandatory_constraints_satisfied)) { 551 &value, &mandatory_constraints_satisfied)) {
548 session_options->transport_options.ice_restart = value; 552 session_options->audio_transport_options.ice_restart = value;
553 session_options->video_transport_options.ice_restart = value;
554 session_options->data_transport_options.ice_restart = value;
549 } else { 555 } else {
550 // kIceRestart defaults to false according to spec. 556 // kIceRestart defaults to false according to spec.
551 session_options->transport_options.ice_restart = false; 557 session_options->audio_transport_options.ice_restart = false;
558 session_options->video_transport_options.ice_restart = false;
559 session_options->data_transport_options.ice_restart = false;
552 } 560 }
553 561
554 if (!constraints) { 562 if (!constraints) {
555 return true; 563 return true;
556 } 564 }
557 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); 565 return mandatory_constraints_satisfied == constraints->GetMandatory().size();
558 } 566 }
559 567
560 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, 568 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
561 StunConfigurations* stun_config, 569 StunConfigurations* stun_config,
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 std::string error; 1055 std::string error;
1048 if (!session_->SetLocalDescription(desc, &error)) { 1056 if (!session_->SetLocalDescription(desc, &error)) {
1049 PostSetSessionDescriptionFailure(observer, error); 1057 PostSetSessionDescriptionFailure(observer, error);
1050 return; 1058 return;
1051 } 1059 }
1052 1060
1053 // If setting the description decided our SSL role, allocate any necessary 1061 // If setting the description decided our SSL role, allocate any necessary
1054 // SCTP sids. 1062 // SCTP sids.
1055 rtc::SSLRole role; 1063 rtc::SSLRole role;
1056 if (session_->data_channel_type() == cricket::DCT_SCTP && 1064 if (session_->data_channel_type() == cricket::DCT_SCTP &&
1057 session_->GetSslRole(&role)) { 1065 session_->data_channel() &&
pthatcher1 2015/12/11 03:16:09 This is duplicated a lot. Perhaps make a GetSslRo
Taylor Brandstetter 2016/01/07 22:25:55 Done.
1066 session_->GetSslRole(session_->data_channel()->transport_name(), &role)) {
1058 AllocateSctpSids(role); 1067 AllocateSctpSids(role);
1059 } 1068 }
1060 1069
1061 // Update state and SSRC of local MediaStreams and DataChannels based on the 1070 // Update state and SSRC of local MediaStreams and DataChannels based on the
1062 // local session description. 1071 // local session description.
1063 const cricket::ContentInfo* audio_content = 1072 const cricket::ContentInfo* audio_content =
1064 GetFirstAudioContent(desc->description()); 1073 GetFirstAudioContent(desc->description());
1065 if (audio_content) { 1074 if (audio_content) {
1066 if (audio_content->rejected) { 1075 if (audio_content->rejected) {
1067 RemoveTracks(cricket::MEDIA_TYPE_AUDIO); 1076 RemoveTracks(cricket::MEDIA_TYPE_AUDIO);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 std::string error; 1134 std::string error;
1126 if (!session_->SetRemoteDescription(desc, &error)) { 1135 if (!session_->SetRemoteDescription(desc, &error)) {
1127 PostSetSessionDescriptionFailure(observer, error); 1136 PostSetSessionDescriptionFailure(observer, error);
1128 return; 1137 return;
1129 } 1138 }
1130 1139
1131 // If setting the description decided our SSL role, allocate any necessary 1140 // If setting the description decided our SSL role, allocate any necessary
1132 // SCTP sids. 1141 // SCTP sids.
1133 rtc::SSLRole role; 1142 rtc::SSLRole role;
1134 if (session_->data_channel_type() == cricket::DCT_SCTP && 1143 if (session_->data_channel_type() == cricket::DCT_SCTP &&
1135 session_->GetSslRole(&role)) { 1144 session_->data_channel() &&
1145 session_->GetSslRole(session_->data_channel()->transport_name(), &role)) {
1136 AllocateSctpSids(role); 1146 AllocateSctpSids(role);
1137 } 1147 }
1138 1148
1139 const cricket::SessionDescription* remote_desc = desc->description(); 1149 const cricket::SessionDescription* remote_desc = desc->description();
1140 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); 1150 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc);
1141 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); 1151 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc);
1142 const cricket::AudioContentDescription* audio_desc = 1152 const cricket::AudioContentDescription* audio_desc =
1143 GetFirstAudioContentDescription(remote_desc); 1153 GetFirstAudioContentDescription(remote_desc);
1144 const cricket::VideoContentDescription* video_desc = 1154 const cricket::VideoContentDescription* video_desc =
1145 GetFirstVideoContentDescription(remote_desc); 1155 GetFirstVideoContentDescription(remote_desc);
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 if (session_->data_channel_type() == cricket::DCT_NONE) { 1858 if (session_->data_channel_type() == cricket::DCT_NONE) {
1849 LOG(LS_ERROR) 1859 LOG(LS_ERROR)
1850 << "InternalCreateDataChannel: Data is not supported in this call."; 1860 << "InternalCreateDataChannel: Data is not supported in this call.";
1851 return nullptr; 1861 return nullptr;
1852 } 1862 }
1853 InternalDataChannelInit new_config = 1863 InternalDataChannelInit new_config =
1854 config ? (*config) : InternalDataChannelInit(); 1864 config ? (*config) : InternalDataChannelInit();
1855 if (session_->data_channel_type() == cricket::DCT_SCTP) { 1865 if (session_->data_channel_type() == cricket::DCT_SCTP) {
1856 if (new_config.id < 0) { 1866 if (new_config.id < 0) {
1857 rtc::SSLRole role; 1867 rtc::SSLRole role;
1858 if (session_->GetSslRole(&role) && 1868 if ((session_->data_channel() &&
1869 session_->GetSslRole(session_->data_channel()->transport_name(),
1870 &role)) &&
1859 !sid_allocator_.AllocateSid(role, &new_config.id)) { 1871 !sid_allocator_.AllocateSid(role, &new_config.id)) {
1860 LOG(LS_ERROR) << "No id can be allocated for the SCTP data channel."; 1872 LOG(LS_ERROR) << "No id can be allocated for the SCTP data channel.";
1861 return nullptr; 1873 return nullptr;
1862 } 1874 }
1863 } else if (!sid_allocator_.ReserveSid(new_config.id)) { 1875 } else if (!sid_allocator_.ReserveSid(new_config.id)) {
1864 LOG(LS_ERROR) << "Failed to create a SCTP data channel " 1876 LOG(LS_ERROR) << "Failed to create a SCTP data channel "
1865 << "because the id is already in use or out of range."; 1877 << "because the id is already in use or out of range.";
1866 return nullptr; 1878 return nullptr;
1867 } 1879 }
1868 } 1880 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { 2041 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const {
2030 for (const auto& channel : sctp_data_channels_) { 2042 for (const auto& channel : sctp_data_channels_) {
2031 if (channel->id() == sid) { 2043 if (channel->id() == sid) {
2032 return channel; 2044 return channel;
2033 } 2045 }
2034 } 2046 }
2035 return nullptr; 2047 return nullptr;
2036 } 2048 }
2037 2049
2038 } // namespace webrtc 2050 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/peerconnectioninterface_unittest.cc » ('j') | talk/app/webrtc/webrtcsessiondescriptionfactory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698