Chromium Code Reviews| Index: webrtc/pc/mediasession.cc |
| diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc |
| index a9d1b95c22aee6aae9299315a9ecc05586242336..3905655900f16d1588cfd8d538d90177fb10e430 100644 |
| --- a/webrtc/pc/mediasession.cc |
| +++ b/webrtc/pc/mediasession.cc |
| @@ -57,6 +57,13 @@ const char kMediaProtocolAvpf[] = "RTP/AVPF"; |
| // RFC5124 |
| const char kMediaProtocolDtlsSavpf[] = "UDP/TLS/RTP/SAVPF"; |
| +// The accepted pattern for media protocol (JSEP Section 5.1.3) |
| +const std::vector<std::string> kMediaProtocols = {"RTP/SAVPF", "RTP/SAVP", |
| + "RTP/AVPF", "RTP/AVP"}; |
| +const std::vector<std::string> kMediaProtocolsDtls = { |
| + "UDP/TLS/RTP/SAVPF", "UDP/TLS/RTP/SAVP", "TCP/TLS/RTP/SAVPF", |
| + "TCP/TLS/RTP/SAVP"}; |
| + |
| // We always generate offers with "UDP/TLS/RTP/SAVPF" when using DTLS-SRTP, |
| // but we tolerate "RTP/SAVPF" in offers we receive, for compatibility. |
| const char kMediaProtocolSavpf[] = "RTP/SAVPF"; |
| @@ -1105,6 +1112,12 @@ static bool CreateMediaContentAnswer( |
| return true; |
| } |
| +static bool IsProtocolFound(const std::vector<std::string> protocol_vec, |
|
pthatcher1
2016/04/12 23:08:36
protocol_vec => protocols
|
| + const std::string& protocol) { |
| + return std::find(protocol_vec.begin(), protocol_vec.end(), protocol) != |
| + protocol_vec.end(); |
| +} |
| + |
| static bool IsMediaProtocolSupported(MediaType type, |
| const std::string& protocol, |
| bool secure_transport) { |
| @@ -1117,9 +1130,8 @@ static bool IsMediaProtocolSupported(MediaType type, |
| // Since not all applications serialize and deserialize the media protocol, |
| // we will have to accept |protocol| to be empty. |
| - return protocol == kMediaProtocolAvpf || protocol.empty() || |
| - protocol == kMediaProtocolSavpf || |
| - (protocol == kMediaProtocolDtlsSavpf && secure_transport); |
| + return protocol.empty() || IsProtocolFound(kMediaProtocols, protocol) || |
| + (IsProtocolFound(kMediaProtocolsDtls, protocol) && secure_transport); |
| } |
| static void SetMediaProtocol(bool secure_transport, |