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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 : MD_SENDRECV); | 1108 : MD_SENDRECV); |
1109 break; | 1109 break; |
1110 default: | 1110 default: |
1111 RTC_DCHECK(false && "MediaContentDescription has unexpected direction."); | 1111 RTC_DCHECK(false && "MediaContentDescription has unexpected direction."); |
1112 break; | 1112 break; |
1113 } | 1113 } |
1114 | 1114 |
1115 return true; | 1115 return true; |
1116 } | 1116 } |
1117 | 1117 |
| 1118 static bool IsDtlsRtp(const std::string& protocol) { |
| 1119 // Most-likely values first. |
| 1120 return protocol == "UDP/TLS/RTP/SAVPF" || protocol == "TCP/TLS/RTP/SAVPF" || |
| 1121 protocol == "UDP/TLS/RTP/SAVP" || protocol == "TCP/TLS/RTP/SAVP"; |
| 1122 } |
| 1123 |
| 1124 static bool IsPlainRtp(const std::string& protocol) { |
| 1125 // Most-likely values first. |
| 1126 return protocol == "RTP/SAVPF" || protocol == "RTP/AVPF" || |
| 1127 protocol == "RTP/SAVP" || protocol == "RTP/AVP"; |
| 1128 } |
| 1129 |
| 1130 static bool IsDtlsSctp(const std::string& protocol) { |
| 1131 return protocol == "DTLS/SCTP"; |
| 1132 } |
| 1133 |
| 1134 static bool IsPlainSctp(const std::string& protocol) { |
| 1135 return protocol == "SCTP"; |
| 1136 } |
| 1137 |
1118 static bool IsMediaProtocolSupported(MediaType type, | 1138 static bool IsMediaProtocolSupported(MediaType type, |
1119 const std::string& protocol, | 1139 const std::string& protocol, |
1120 bool secure_transport) { | 1140 bool secure_transport) { |
1121 // Data channels can have a protocol of SCTP or SCTP/DTLS. | 1141 // Since not all applications serialize and deserialize the media protocol, |
1122 if (type == MEDIA_TYPE_DATA && | 1142 // we will have to accept |protocol| to be empty. |
1123 ((protocol == kMediaProtocolSctp && !secure_transport)|| | 1143 if (protocol.empty()) { |
1124 (protocol == kMediaProtocolDtlsSctp && secure_transport))) { | |
1125 return true; | 1144 return true; |
1126 } | 1145 } |
1127 | 1146 |
1128 // Since not all applications serialize and deserialize the media protocol, | 1147 if (type == MEDIA_TYPE_DATA) { |
1129 // we will have to accept |protocol| to be empty. | 1148 // Check for SCTP, but also for RTP for RTP-based data channels. |
1130 return protocol == kMediaProtocolAvpf || protocol.empty() || | 1149 // TODO(pthatcher): Remove RTP once RTP-based data channels are gone. |
1131 protocol == kMediaProtocolSavpf || | 1150 if (secure_transport) { |
1132 (protocol == kMediaProtocolDtlsSavpf && secure_transport); | 1151 // Most likely scenarios first. |
| 1152 return IsDtlsSctp(protocol) || IsDtlsRtp(protocol) || |
| 1153 IsPlainRtp(protocol); |
| 1154 } else { |
| 1155 return IsPlainSctp(protocol) || IsPlainRtp(protocol); |
| 1156 } |
| 1157 } |
| 1158 |
| 1159 // Allow for non-DTLS RTP protocol even when using DTLS because that's what |
| 1160 // JSEP specifies. |
| 1161 if (secure_transport) { |
| 1162 // Most likely scenarios first. |
| 1163 return IsDtlsRtp(protocol) || IsPlainRtp(protocol); |
| 1164 } else { |
| 1165 return IsPlainRtp(protocol); |
| 1166 } |
1133 } | 1167 } |
1134 | 1168 |
1135 static void SetMediaProtocol(bool secure_transport, | 1169 static void SetMediaProtocol(bool secure_transport, |
1136 MediaContentDescription* desc) { | 1170 MediaContentDescription* desc) { |
1137 if (!desc->cryptos().empty()) | 1171 if (!desc->cryptos().empty()) |
1138 desc->set_protocol(kMediaProtocolSavpf); | 1172 desc->set_protocol(kMediaProtocolSavpf); |
1139 else if (secure_transport) | 1173 else if (secure_transport) |
1140 desc->set_protocol(kMediaProtocolDtlsSavpf); | 1174 desc->set_protocol(kMediaProtocolDtlsSavpf); |
1141 else | 1175 else |
1142 desc->set_protocol(kMediaProtocolAvpf); | 1176 desc->set_protocol(kMediaProtocolAvpf); |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2038 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
2005 } | 2039 } |
2006 | 2040 |
2007 const DataContentDescription* GetFirstDataContentDescription( | 2041 const DataContentDescription* GetFirstDataContentDescription( |
2008 const SessionDescription* sdesc) { | 2042 const SessionDescription* sdesc) { |
2009 return static_cast<const DataContentDescription*>( | 2043 return static_cast<const DataContentDescription*>( |
2010 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2044 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
2011 } | 2045 } |
2012 | 2046 |
2013 } // namespace cricket | 2047 } // namespace cricket |
OLD | NEW |