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

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: Adding a helper method for GetSslRole, and some more comments. 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
« no previous file with comments | « no previous file | talk/app/webrtc/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 454 }
455 455
456 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) { 456 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) {
457 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0); 457 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0);
458 } 458 }
459 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) { 459 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) {
460 session_options->recv_video = (rtc_options.offer_to_receive_video > 0); 460 session_options->recv_video = (rtc_options.offer_to_receive_video > 0);
461 } 461 }
462 462
463 session_options->vad_enabled = rtc_options.voice_activity_detection; 463 session_options->vad_enabled = rtc_options.voice_activity_detection;
464 session_options->transport_options.ice_restart = rtc_options.ice_restart; 464 session_options->audio_transport_options.ice_restart =
465 rtc_options.ice_restart;
466 session_options->video_transport_options.ice_restart =
467 rtc_options.ice_restart;
468 session_options->data_transport_options.ice_restart = rtc_options.ice_restart;
465 session_options->bundle_enabled = rtc_options.use_rtp_mux; 469 session_options->bundle_enabled = rtc_options.use_rtp_mux;
466 470
467 return true; 471 return true;
468 } 472 }
469 473
470 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, 474 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
471 cricket::MediaSessionOptions* session_options) { 475 cricket::MediaSessionOptions* session_options) {
472 bool value = false; 476 bool value = false;
473 size_t mandatory_constraints_satisfied = 0; 477 size_t mandatory_constraints_satisfied = 0;
474 478
(...skipping 25 matching lines...) Expand all
500 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value, 504 if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value,
501 &mandatory_constraints_satisfied)) { 505 &mandatory_constraints_satisfied)) {
502 session_options->bundle_enabled = value; 506 session_options->bundle_enabled = value;
503 } else { 507 } else {
504 // kUseRtpMux defaults to true according to spec. 508 // kUseRtpMux defaults to true according to spec.
505 session_options->bundle_enabled = true; 509 session_options->bundle_enabled = true;
506 } 510 }
507 511
508 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart, 512 if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart,
509 &value, &mandatory_constraints_satisfied)) { 513 &value, &mandatory_constraints_satisfied)) {
510 session_options->transport_options.ice_restart = value; 514 session_options->audio_transport_options.ice_restart = value;
515 session_options->video_transport_options.ice_restart = value;
516 session_options->data_transport_options.ice_restart = value;
511 } else { 517 } else {
512 // kIceRestart defaults to false according to spec. 518 // kIceRestart defaults to false according to spec.
513 session_options->transport_options.ice_restart = false; 519 session_options->audio_transport_options.ice_restart = false;
520 session_options->video_transport_options.ice_restart = false;
521 session_options->data_transport_options.ice_restart = false;
514 } 522 }
515 523
516 if (!constraints) { 524 if (!constraints) {
517 return true; 525 return true;
518 } 526 }
519 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); 527 return mandatory_constraints_satisfied == constraints->GetMandatory().size();
520 } 528 }
521 529
522 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, 530 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
523 cricket::ServerAddresses* stun_servers, 531 cricket::ServerAddresses* stun_servers,
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 std::string error; 963 std::string error;
956 if (!session_->SetLocalDescription(desc, &error)) { 964 if (!session_->SetLocalDescription(desc, &error)) {
957 PostSetSessionDescriptionFailure(observer, error); 965 PostSetSessionDescriptionFailure(observer, error);
958 return; 966 return;
959 } 967 }
960 968
961 // If setting the description decided our SSL role, allocate any necessary 969 // If setting the description decided our SSL role, allocate any necessary
962 // SCTP sids. 970 // SCTP sids.
963 rtc::SSLRole role; 971 rtc::SSLRole role;
964 if (session_->data_channel_type() == cricket::DCT_SCTP && 972 if (session_->data_channel_type() == cricket::DCT_SCTP &&
965 session_->GetSslRole(&role)) { 973 session_->GetSslRole(session_->data_channel(), &role)) {
966 AllocateSctpSids(role); 974 AllocateSctpSids(role);
967 } 975 }
968 976
969 // Update state and SSRC of local MediaStreams and DataChannels based on the 977 // Update state and SSRC of local MediaStreams and DataChannels based on the
970 // local session description. 978 // local session description.
971 const cricket::ContentInfo* audio_content = 979 const cricket::ContentInfo* audio_content =
972 GetFirstAudioContent(desc->description()); 980 GetFirstAudioContent(desc->description());
973 if (audio_content) { 981 if (audio_content) {
974 if (audio_content->rejected) { 982 if (audio_content->rejected) {
975 RemoveTracks(cricket::MEDIA_TYPE_AUDIO); 983 RemoveTracks(cricket::MEDIA_TYPE_AUDIO);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 std::string error; 1041 std::string error;
1034 if (!session_->SetRemoteDescription(desc, &error)) { 1042 if (!session_->SetRemoteDescription(desc, &error)) {
1035 PostSetSessionDescriptionFailure(observer, error); 1043 PostSetSessionDescriptionFailure(observer, error);
1036 return; 1044 return;
1037 } 1045 }
1038 1046
1039 // If setting the description decided our SSL role, allocate any necessary 1047 // If setting the description decided our SSL role, allocate any necessary
1040 // SCTP sids. 1048 // SCTP sids.
1041 rtc::SSLRole role; 1049 rtc::SSLRole role;
1042 if (session_->data_channel_type() == cricket::DCT_SCTP && 1050 if (session_->data_channel_type() == cricket::DCT_SCTP &&
1043 session_->GetSslRole(&role)) { 1051 session_->GetSslRole(session_->data_channel(), &role)) {
1044 AllocateSctpSids(role); 1052 AllocateSctpSids(role);
1045 } 1053 }
1046 1054
1047 const cricket::SessionDescription* remote_desc = desc->description(); 1055 const cricket::SessionDescription* remote_desc = desc->description();
1048 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); 1056 const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc);
1049 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc); 1057 const cricket::ContentInfo* video_content = GetFirstVideoContent(remote_desc);
1050 const cricket::AudioContentDescription* audio_desc = 1058 const cricket::AudioContentDescription* audio_desc =
1051 GetFirstAudioContentDescription(remote_desc); 1059 GetFirstAudioContentDescription(remote_desc);
1052 const cricket::VideoContentDescription* video_desc = 1060 const cricket::VideoContentDescription* video_desc =
1053 GetFirstVideoContentDescription(remote_desc); 1061 GetFirstVideoContentDescription(remote_desc);
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 if (session_->data_channel_type() == cricket::DCT_NONE) { 1834 if (session_->data_channel_type() == cricket::DCT_NONE) {
1827 LOG(LS_ERROR) 1835 LOG(LS_ERROR)
1828 << "InternalCreateDataChannel: Data is not supported in this call."; 1836 << "InternalCreateDataChannel: Data is not supported in this call.";
1829 return nullptr; 1837 return nullptr;
1830 } 1838 }
1831 InternalDataChannelInit new_config = 1839 InternalDataChannelInit new_config =
1832 config ? (*config) : InternalDataChannelInit(); 1840 config ? (*config) : InternalDataChannelInit();
1833 if (session_->data_channel_type() == cricket::DCT_SCTP) { 1841 if (session_->data_channel_type() == cricket::DCT_SCTP) {
1834 if (new_config.id < 0) { 1842 if (new_config.id < 0) {
1835 rtc::SSLRole role; 1843 rtc::SSLRole role;
1836 if (session_->GetSslRole(&role) && 1844 if ((session_->GetSslRole(session_->data_channel(), &role)) &&
1837 !sid_allocator_.AllocateSid(role, &new_config.id)) { 1845 !sid_allocator_.AllocateSid(role, &new_config.id)) {
1838 LOG(LS_ERROR) << "No id can be allocated for the SCTP data channel."; 1846 LOG(LS_ERROR) << "No id can be allocated for the SCTP data channel.";
1839 return nullptr; 1847 return nullptr;
1840 } 1848 }
1841 } else if (!sid_allocator_.ReserveSid(new_config.id)) { 1849 } else if (!sid_allocator_.ReserveSid(new_config.id)) {
1842 LOG(LS_ERROR) << "Failed to create a SCTP data channel " 1850 LOG(LS_ERROR) << "Failed to create a SCTP data channel "
1843 << "because the id is already in use or out of range."; 1851 << "because the id is already in use or out of range.";
1844 return nullptr; 1852 return nullptr;
1845 } 1853 }
1846 } 1854 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { 2015 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const {
2008 for (const auto& channel : sctp_data_channels_) { 2016 for (const auto& channel : sctp_data_channels_) {
2009 if (channel->id() == sid) { 2017 if (channel->id() == sid) {
2010 return channel; 2018 return channel;
2011 } 2019 }
2012 } 2020 }
2013 return nullptr; 2021 return nullptr;
2014 } 2022 }
2015 2023
2016 } // namespace webrtc 2024 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698