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

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

Issue 1880913002: Accept all the media profiles required by JSEP. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename a local vairable Created 4 years, 8 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 namespace cricket { 50 namespace cricket {
51 51
52 52
53 // RTP Profile names 53 // RTP Profile names
54 // http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xml 54 // http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xml
55 // RFC4585 55 // RFC4585
56 const char kMediaProtocolAvpf[] = "RTP/AVPF"; 56 const char kMediaProtocolAvpf[] = "RTP/AVPF";
57 // RFC5124 57 // RFC5124
58 const char kMediaProtocolDtlsSavpf[] = "UDP/TLS/RTP/SAVPF"; 58 const char kMediaProtocolDtlsSavpf[] = "UDP/TLS/RTP/SAVPF";
59 59
60 // The accepted pattern for media protocol (JSEP Section 5.1.3)
61 const std::vector<std::string> kMediaProtocols = {"RTP/SAVPF", "RTP/SAVP",
62 "RTP/AVPF", "RTP/AVP"};
Avi (use Gerrit) 2016/04/13 17:42:05 This is a static initializer.
63 const std::vector<std::string> kMediaProtocolsDtls = {
64 "UDP/TLS/RTP/SAVPF", "UDP/TLS/RTP/SAVP", "TCP/TLS/RTP/SAVPF",
65 "TCP/TLS/RTP/SAVP"};
Avi (use Gerrit) 2016/04/13 17:42:05 This is a static initializer.
66
60 // We always generate offers with "UDP/TLS/RTP/SAVPF" when using DTLS-SRTP, 67 // We always generate offers with "UDP/TLS/RTP/SAVPF" when using DTLS-SRTP,
61 // but we tolerate "RTP/SAVPF" in offers we receive, for compatibility. 68 // but we tolerate "RTP/SAVPF" in offers we receive, for compatibility.
62 const char kMediaProtocolSavpf[] = "RTP/SAVPF"; 69 const char kMediaProtocolSavpf[] = "RTP/SAVPF";
63 70
64 const char kMediaProtocolRtpPrefix[] = "RTP/"; 71 const char kMediaProtocolRtpPrefix[] = "RTP/";
65 72
66 const char kMediaProtocolSctp[] = "SCTP"; 73 const char kMediaProtocolSctp[] = "SCTP";
67 const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP"; 74 const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP";
68 const char kMediaProtocolUdpDtlsSctp[] = "UDP/DTLS/SCTP"; 75 const char kMediaProtocolUdpDtlsSctp[] = "UDP/DTLS/SCTP";
69 const char kMediaProtocolTcpDtlsSctp[] = "TCP/DTLS/SCTP"; 76 const char kMediaProtocolTcpDtlsSctp[] = "TCP/DTLS/SCTP";
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 : MD_SENDRECV); 1105 : MD_SENDRECV);
1099 break; 1106 break;
1100 default: 1107 default:
1101 RTC_DCHECK(false && "MediaContentDescription has unexpected direction."); 1108 RTC_DCHECK(false && "MediaContentDescription has unexpected direction.");
1102 break; 1109 break;
1103 } 1110 }
1104 1111
1105 return true; 1112 return true;
1106 } 1113 }
1107 1114
1115 static bool IsProtocolFound(const std::vector<std::string> protocols,
1116 const std::string& protocol) {
1117 return std::find(protocols.begin(), protocols.end(), protocol) !=
1118 protocols.end();
1119 }
1120
1108 static bool IsMediaProtocolSupported(MediaType type, 1121 static bool IsMediaProtocolSupported(MediaType type,
1109 const std::string& protocol, 1122 const std::string& protocol,
1110 bool secure_transport) { 1123 bool secure_transport) {
1111 // Data channels can have a protocol of SCTP or SCTP/DTLS. 1124 // Data channels can have a protocol of SCTP or SCTP/DTLS.
Avi (use Gerrit) 2016/04/13 17:42:05 You can totally put those variable declarations in
1112 if (type == MEDIA_TYPE_DATA && 1125 if (type == MEDIA_TYPE_DATA &&
1113 ((protocol == kMediaProtocolSctp && !secure_transport)|| 1126 ((protocol == kMediaProtocolSctp && !secure_transport)||
1114 (protocol == kMediaProtocolDtlsSctp && secure_transport))) { 1127 (protocol == kMediaProtocolDtlsSctp && secure_transport))) {
1115 return true; 1128 return true;
1116 } 1129 }
1117 1130
1118 // Since not all applications serialize and deserialize the media protocol, 1131 // Since not all applications serialize and deserialize the media protocol,
1119 // we will have to accept |protocol| to be empty. 1132 // we will have to accept |protocol| to be empty.
1120 return protocol == kMediaProtocolAvpf || protocol.empty() || 1133 return protocol.empty() || IsProtocolFound(kMediaProtocols, protocol) ||
1121 protocol == kMediaProtocolSavpf || 1134 (IsProtocolFound(kMediaProtocolsDtls, protocol) && secure_transport);
1122 (protocol == kMediaProtocolDtlsSavpf && secure_transport);
1123 } 1135 }
1124 1136
1125 static void SetMediaProtocol(bool secure_transport, 1137 static void SetMediaProtocol(bool secure_transport,
1126 MediaContentDescription* desc) { 1138 MediaContentDescription* desc) {
1127 if (!desc->cryptos().empty()) 1139 if (!desc->cryptos().empty())
1128 desc->set_protocol(kMediaProtocolSavpf); 1140 desc->set_protocol(kMediaProtocolSavpf);
1129 else if (secure_transport) 1141 else if (secure_transport)
1130 desc->set_protocol(kMediaProtocolDtlsSavpf); 1142 desc->set_protocol(kMediaProtocolDtlsSavpf);
1131 else 1143 else
1132 desc->set_protocol(kMediaProtocolAvpf); 1144 desc->set_protocol(kMediaProtocolAvpf);
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); 2006 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
1995 } 2007 }
1996 2008
1997 const DataContentDescription* GetFirstDataContentDescription( 2009 const DataContentDescription* GetFirstDataContentDescription(
1998 const SessionDescription* sdesc) { 2010 const SessionDescription* sdesc) {
1999 return static_cast<const DataContentDescription*>( 2011 return static_cast<const DataContentDescription*>(
2000 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); 2012 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
2001 } 2013 }
2002 2014
2003 } // namespace cricket 2015 } // 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