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

Side by Side Diff: webrtc/pc/mediasession.cc

Issue 2902213002: Support "UDP/DTLS/SCTP" and "TCP/DTLS/SCTP" profile strings. (Closed)
Patch Set: Created 3 years, 6 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 | webrtc/pc/mediasession_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 * Copyright 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // but we tolerate "RTP/SAVPF" in offers we receive, for compatibility. 60 // but we tolerate "RTP/SAVPF" in offers we receive, for compatibility.
61 const char kMediaProtocolSavpf[] = "RTP/SAVPF"; 61 const char kMediaProtocolSavpf[] = "RTP/SAVPF";
62 62
63 const char kMediaProtocolRtpPrefix[] = "RTP/"; 63 const char kMediaProtocolRtpPrefix[] = "RTP/";
64 64
65 const char kMediaProtocolSctp[] = "SCTP"; 65 const char kMediaProtocolSctp[] = "SCTP";
66 const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP"; 66 const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP";
67 const char kMediaProtocolUdpDtlsSctp[] = "UDP/DTLS/SCTP"; 67 const char kMediaProtocolUdpDtlsSctp[] = "UDP/DTLS/SCTP";
68 const char kMediaProtocolTcpDtlsSctp[] = "TCP/DTLS/SCTP"; 68 const char kMediaProtocolTcpDtlsSctp[] = "TCP/DTLS/SCTP";
69 69
70 // Note that the below functions support some protocol strings purely for
71 // legacy compatibility, as required by JSEP in Section 5.1.2, Profile Names
72 // and Interoperability.
73
74 static bool IsDtlsRtp(const std::string& protocol) {
75 // Most-likely values first.
76 return protocol == "UDP/TLS/RTP/SAVPF" || protocol == "TCP/TLS/RTP/SAVPF" ||
77 protocol == "UDP/TLS/RTP/SAVP" || protocol == "TCP/TLS/RTP/SAVP";
78 }
79
80 static bool IsPlainRtp(const std::string& protocol) {
81 // Most-likely values first.
82 return protocol == "RTP/SAVPF" || protocol == "RTP/AVPF" ||
83 protocol == "RTP/SAVP" || protocol == "RTP/AVP";
84 }
85
86 static bool IsDtlsSctp(const std::string& protocol) {
87 return protocol == kMediaProtocolDtlsSctp ||
88 protocol == kMediaProtocolUdpDtlsSctp ||
89 protocol == kMediaProtocolTcpDtlsSctp;
Taylor Brandstetter 2017/05/24 17:43:21 This is the only method that was changed and not j
90 }
91
92 static bool IsPlainSctp(const std::string& protocol) {
93 return protocol == kMediaProtocolSctp;
94 }
95
96 static bool IsSctp(const std::string& protocol) {
97 return IsPlainSctp(protocol) || IsDtlsSctp(protocol);
98 }
99
70 RtpTransceiverDirection RtpTransceiverDirection::FromMediaContentDirection( 100 RtpTransceiverDirection RtpTransceiverDirection::FromMediaContentDirection(
71 MediaContentDirection md) { 101 MediaContentDirection md) {
72 const bool send = (md == MD_SENDRECV || md == MD_SENDONLY); 102 const bool send = (md == MD_SENDRECV || md == MD_SENDONLY);
73 const bool recv = (md == MD_SENDRECV || md == MD_RECVONLY); 103 const bool recv = (md == MD_SENDRECV || md == MD_RECVONLY);
74 return RtpTransceiverDirection(send, recv); 104 return RtpTransceiverDirection(send, recv);
75 } 105 }
76 106
77 MediaContentDirection RtpTransceiverDirection::ToMediaContentDirection() const { 107 MediaContentDirection RtpTransceiverDirection::ToMediaContentDirection() const {
78 if (send && recv) { 108 if (send && recv) {
79 return MD_SENDRECV; 109 return MD_SENDRECV;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // audio and video extensions. 421 // audio and video extensions.
392 class UsedRtpHeaderExtensionIds : public UsedIds<webrtc::RtpExtension> { 422 class UsedRtpHeaderExtensionIds : public UsedIds<webrtc::RtpExtension> {
393 public: 423 public:
394 UsedRtpHeaderExtensionIds() 424 UsedRtpHeaderExtensionIds()
395 : UsedIds<webrtc::RtpExtension>(webrtc::RtpExtension::kMinId, 425 : UsedIds<webrtc::RtpExtension>(webrtc::RtpExtension::kMinId,
396 webrtc::RtpExtension::kMaxId) {} 426 webrtc::RtpExtension::kMaxId) {}
397 427
398 private: 428 private:
399 }; 429 };
400 430
401 static bool IsSctp(const MediaContentDescription* desc) {
402 return ((desc->protocol() == kMediaProtocolSctp) ||
403 (desc->protocol() == kMediaProtocolDtlsSctp));
404 }
405
406 // Adds a StreamParams for each Stream in Streams with media type 431 // Adds a StreamParams for each Stream in Streams with media type
407 // media_type to content_description. 432 // media_type to content_description.
408 // |current_params| - All currently known StreamParams of any media type. 433 // |current_params| - All currently known StreamParams of any media type.
409 template <class C> 434 template <class C>
410 static bool AddStreamParams(MediaType media_type, 435 static bool AddStreamParams(MediaType media_type,
411 const MediaSessionOptions& options, 436 const MediaSessionOptions& options,
412 StreamParamsVec* current_streams, 437 StreamParamsVec* current_streams,
413 MediaContentDescriptionImpl<C>* content_description, 438 MediaContentDescriptionImpl<C>* content_description,
414 const bool add_legacy_stream) { 439 const bool add_legacy_stream) {
415 // SCTP streams are not negotiated using SDP/ContentDescriptions. 440 // SCTP streams are not negotiated using SDP/ContentDescriptions.
416 if (IsSctp(content_description)) { 441 if (IsSctp(content_description->protocol())) {
417 return true; 442 return true;
418 } 443 }
419 444
420 const bool include_rtx_streams = 445 const bool include_rtx_streams =
421 ContainsRtxCodec(content_description->codecs()); 446 ContainsRtxCodec(content_description->codecs());
422 447
423 const MediaSessionOptions::Streams& streams = options.streams; 448 const MediaSessionOptions::Streams& streams = options.streams;
424 if (streams.empty() && add_legacy_stream) { 449 if (streams.empty() && add_legacy_stream) {
425 // TODO(perkj): Remove this legacy stream when all apps use StreamParams. 450 // TODO(perkj): Remove this legacy stream when all apps use StreamParams.
426 std::vector<uint32_t> ssrcs; 451 std::vector<uint32_t> ssrcs;
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 const bool wants_receive = recv_audio || recv_video || recv_data; 1103 const bool wants_receive = recv_audio || recv_video || recv_data;
1079 1104
1080 auto offer_rtd = 1105 auto offer_rtd =
1081 RtpTransceiverDirection::FromMediaContentDirection(offer->direction()); 1106 RtpTransceiverDirection::FromMediaContentDirection(offer->direction());
1082 auto wants_rtd = RtpTransceiverDirection(wants_send, wants_receive); 1107 auto wants_rtd = RtpTransceiverDirection(wants_send, wants_receive);
1083 answer->set_direction(NegotiateRtpTransceiverDirection(offer_rtd, wants_rtd) 1108 answer->set_direction(NegotiateRtpTransceiverDirection(offer_rtd, wants_rtd)
1084 .ToMediaContentDirection()); 1109 .ToMediaContentDirection());
1085 return true; 1110 return true;
1086 } 1111 }
1087 1112
1088 static bool IsDtlsRtp(const std::string& protocol) {
1089 // Most-likely values first.
1090 return protocol == "UDP/TLS/RTP/SAVPF" || protocol == "TCP/TLS/RTP/SAVPF" ||
1091 protocol == "UDP/TLS/RTP/SAVP" || protocol == "TCP/TLS/RTP/SAVP";
1092 }
1093
1094 static bool IsPlainRtp(const std::string& protocol) {
1095 // Most-likely values first.
1096 return protocol == "RTP/SAVPF" || protocol == "RTP/AVPF" ||
1097 protocol == "RTP/SAVP" || protocol == "RTP/AVP";
1098 }
1099
1100 static bool IsDtlsSctp(const std::string& protocol) {
1101 return protocol == "DTLS/SCTP";
1102 }
1103
1104 static bool IsPlainSctp(const std::string& protocol) {
1105 return protocol == "SCTP";
1106 }
1107
1108 static bool IsMediaProtocolSupported(MediaType type, 1113 static bool IsMediaProtocolSupported(MediaType type,
1109 const std::string& protocol, 1114 const std::string& protocol,
1110 bool secure_transport) { 1115 bool secure_transport) {
1111 // Since not all applications serialize and deserialize the media protocol, 1116 // Since not all applications serialize and deserialize the media protocol,
1112 // we will have to accept |protocol| to be empty. 1117 // we will have to accept |protocol| to be empty.
1113 if (protocol.empty()) { 1118 if (protocol.empty()) {
1114 return true; 1119 return true;
1115 } 1120 }
1116 1121
1117 if (type == MEDIA_TYPE_DATA) { 1122 if (type == MEDIA_TYPE_DATA) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 audio_added = true; 1355 audio_added = true;
1351 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) { 1356 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) {
1352 if (!AddVideoContentForOffer(options, current_description, 1357 if (!AddVideoContentForOffer(options, current_description,
1353 video_rtp_extensions, video_codecs, 1358 video_rtp_extensions, video_codecs,
1354 &current_streams, offer.get())) { 1359 &current_streams, offer.get())) {
1355 return NULL; 1360 return NULL;
1356 } 1361 }
1357 video_added = true; 1362 video_added = true;
1358 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)) { 1363 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)) {
1359 MediaSessionOptions options_copy(options); 1364 MediaSessionOptions options_copy(options);
1360 if (IsSctp(static_cast<const MediaContentDescription*>( 1365 if (IsSctp(static_cast<const MediaContentDescription*>(it->description)
1361 it->description))) { 1366 ->protocol())) {
1362 options_copy.data_channel_type = DCT_SCTP; 1367 options_copy.data_channel_type = DCT_SCTP;
1363 } 1368 }
1364 if (!AddDataContentForOffer(options_copy, current_description, 1369 if (!AddDataContentForOffer(options_copy, current_description,
1365 &data_codecs, &current_streams, 1370 &data_codecs, &current_streams,
1366 offer.get())) { 1371 offer.get())) {
1367 return NULL; 1372 return NULL;
1368 } 1373 }
1369 data_added = true; 1374 data_added = true;
1370 } else { 1375 } else {
1371 RTC_NOTREACHED(); 1376 RTC_NOTREACHED();
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 : secure(); 1795 : secure();
1791 std::vector<std::string> crypto_suites; 1796 std::vector<std::string> crypto_suites;
1792 if (is_sctp) { 1797 if (is_sctp) {
1793 // SDES doesn't make sense for SCTP, so we disable it, and we only 1798 // SDES doesn't make sense for SCTP, so we disable it, and we only
1794 // get SDES crypto suites for RTP-based data channels. 1799 // get SDES crypto suites for RTP-based data channels.
1795 sdes_policy = cricket::SEC_DISABLED; 1800 sdes_policy = cricket::SEC_DISABLED;
1796 // Unlike SetMediaProtocol below, we need to set the protocol 1801 // Unlike SetMediaProtocol below, we need to set the protocol
1797 // before we call CreateMediaContentOffer. Otherwise, 1802 // before we call CreateMediaContentOffer. Otherwise,
1798 // CreateMediaContentOffer won't know this is SCTP and will 1803 // CreateMediaContentOffer won't know this is SCTP and will
1799 // generate SSRCs rather than SIDs. 1804 // generate SSRCs rather than SIDs.
1805 // TODO(deadbeef): Use kMediaProtocolDtls
1800 data->set_protocol( 1806 data->set_protocol(
1801 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp); 1807 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp);
1802 } else { 1808 } else {
1803 GetSupportedDataSdesCryptoSuiteNames(options.crypto_options, 1809 GetSupportedDataSdesCryptoSuiteNames(options.crypto_options,
1804 &crypto_suites); 1810 &crypto_suites);
1805 } 1811 }
1806 1812
1807 if (!CreateMediaContentOffer( 1813 if (!CreateMediaContentOffer(
1808 options, 1814 options,
1809 *data_codecs, 1815 *data_codecs,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2183 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); 2189 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
2184 } 2190 }
2185 2191
2186 DataContentDescription* GetFirstDataContentDescription( 2192 DataContentDescription* GetFirstDataContentDescription(
2187 SessionDescription* sdesc) { 2193 SessionDescription* sdesc) {
2188 return static_cast<DataContentDescription*>( 2194 return static_cast<DataContentDescription*>(
2189 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); 2195 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
2190 } 2196 }
2191 2197
2192 } // namespace cricket 2198 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/pc/mediasession_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698