| OLD | NEW |
| 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 Loading... |
| 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"}; | |
| 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"}; | |
| 66 | |
| 67 // We always generate offers with "UDP/TLS/RTP/SAVPF" when using DTLS-SRTP, | 60 // We always generate offers with "UDP/TLS/RTP/SAVPF" when using DTLS-SRTP, |
| 68 // but we tolerate "RTP/SAVPF" in offers we receive, for compatibility. | 61 // but we tolerate "RTP/SAVPF" in offers we receive, for compatibility. |
| 69 const char kMediaProtocolSavpf[] = "RTP/SAVPF"; | 62 const char kMediaProtocolSavpf[] = "RTP/SAVPF"; |
| 70 | 63 |
| 71 const char kMediaProtocolRtpPrefix[] = "RTP/"; | 64 const char kMediaProtocolRtpPrefix[] = "RTP/"; |
| 72 | 65 |
| 73 const char kMediaProtocolSctp[] = "SCTP"; | 66 const char kMediaProtocolSctp[] = "SCTP"; |
| 74 const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP"; | 67 const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP"; |
| 75 const char kMediaProtocolUdpDtlsSctp[] = "UDP/DTLS/SCTP"; | 68 const char kMediaProtocolUdpDtlsSctp[] = "UDP/DTLS/SCTP"; |
| 76 const char kMediaProtocolTcpDtlsSctp[] = "TCP/DTLS/SCTP"; | 69 const char kMediaProtocolTcpDtlsSctp[] = "TCP/DTLS/SCTP"; |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 : MD_SENDRECV); | 1098 : MD_SENDRECV); |
| 1106 break; | 1099 break; |
| 1107 default: | 1100 default: |
| 1108 RTC_DCHECK(false && "MediaContentDescription has unexpected direction."); | 1101 RTC_DCHECK(false && "MediaContentDescription has unexpected direction."); |
| 1109 break; | 1102 break; |
| 1110 } | 1103 } |
| 1111 | 1104 |
| 1112 return true; | 1105 return true; |
| 1113 } | 1106 } |
| 1114 | 1107 |
| 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 | |
| 1121 static bool IsMediaProtocolSupported(MediaType type, | 1108 static bool IsMediaProtocolSupported(MediaType type, |
| 1122 const std::string& protocol, | 1109 const std::string& protocol, |
| 1123 bool secure_transport) { | 1110 bool secure_transport) { |
| 1124 // Data channels can have a protocol of SCTP or SCTP/DTLS. | 1111 // Data channels can have a protocol of SCTP or SCTP/DTLS. |
| 1125 if (type == MEDIA_TYPE_DATA && | 1112 if (type == MEDIA_TYPE_DATA && |
| 1126 ((protocol == kMediaProtocolSctp && !secure_transport)|| | 1113 ((protocol == kMediaProtocolSctp && !secure_transport)|| |
| 1127 (protocol == kMediaProtocolDtlsSctp && secure_transport))) { | 1114 (protocol == kMediaProtocolDtlsSctp && secure_transport))) { |
| 1128 return true; | 1115 return true; |
| 1129 } | 1116 } |
| 1130 | 1117 |
| 1131 // Since not all applications serialize and deserialize the media protocol, | 1118 // Since not all applications serialize and deserialize the media protocol, |
| 1132 // we will have to accept |protocol| to be empty. | 1119 // we will have to accept |protocol| to be empty. |
| 1133 return protocol.empty() || IsProtocolFound(kMediaProtocols, protocol) || | 1120 return protocol == kMediaProtocolAvpf || protocol.empty() || |
| 1134 (IsProtocolFound(kMediaProtocolsDtls, protocol) && secure_transport); | 1121 protocol == kMediaProtocolSavpf || |
| 1122 (protocol == kMediaProtocolDtlsSavpf && secure_transport); |
| 1135 } | 1123 } |
| 1136 | 1124 |
| 1137 static void SetMediaProtocol(bool secure_transport, | 1125 static void SetMediaProtocol(bool secure_transport, |
| 1138 MediaContentDescription* desc) { | 1126 MediaContentDescription* desc) { |
| 1139 if (!desc->cryptos().empty()) | 1127 if (!desc->cryptos().empty()) |
| 1140 desc->set_protocol(kMediaProtocolSavpf); | 1128 desc->set_protocol(kMediaProtocolSavpf); |
| 1141 else if (secure_transport) | 1129 else if (secure_transport) |
| 1142 desc->set_protocol(kMediaProtocolDtlsSavpf); | 1130 desc->set_protocol(kMediaProtocolDtlsSavpf); |
| 1143 else | 1131 else |
| 1144 desc->set_protocol(kMediaProtocolAvpf); | 1132 desc->set_protocol(kMediaProtocolAvpf); |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 1994 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
| 2007 } | 1995 } |
| 2008 | 1996 |
| 2009 const DataContentDescription* GetFirstDataContentDescription( | 1997 const DataContentDescription* GetFirstDataContentDescription( |
| 2010 const SessionDescription* sdesc) { | 1998 const SessionDescription* sdesc) { |
| 2011 return static_cast<const DataContentDescription*>( | 1999 return static_cast<const DataContentDescription*>( |
| 2012 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2000 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
| 2013 } | 2001 } |
| 2014 | 2002 |
| 2015 } // namespace cricket | 2003 } // namespace cricket |
| OLD | NEW |