Cleanup: Move some more protocol names into media_protocol_names
Bug: None Change-Id: I29ccee993ece01ffbafa85f09abb7cf64dba82d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237020 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35295}
This commit is contained in:
parent
08a6e35848
commit
1bffe9e885
@ -17,16 +17,42 @@
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// The official registry of RTP parameters is at
|
||||
// http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xml
|
||||
// The UDP/DTLS and TCP/DTLS prefixes are not registered there.
|
||||
|
||||
// There are multiple variants of the RTP protocol stack, including
|
||||
// UDP/TLS/RTP/SAVPF (WebRTC default), RTP/AVP, RTP/AVPF, RTP/SAVPF,
|
||||
// TCP/DTLS/RTP/SAVPF and so on. We accept anything that has RTP/
|
||||
// embedded in it somewhere as being an RTP protocol.
|
||||
const char kMediaProtocolRtpPrefix[] = "RTP/";
|
||||
|
||||
// Protocol names generated by WebRTC
|
||||
const char kMediaProtocolSctp[] = "SCTP";
|
||||
const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP";
|
||||
const char kMediaProtocolUdpDtlsSctp[] = "UDP/DTLS/SCTP";
|
||||
const char kMediaProtocolDtlsSctp[] = "DTLS/SCTP";
|
||||
const char kMediaProtocolTcpDtlsSctp[] = "TCP/DTLS/SCTP";
|
||||
// RFC5124
|
||||
const char kMediaProtocolDtlsSavpf[] = "UDP/TLS/RTP/SAVPF";
|
||||
const char kMediaProtocolSavpf[] = "RTP/SAVPF";
|
||||
const char kMediaProtocolAvpf[] = "RTP/AVPF";
|
||||
|
||||
namespace {
|
||||
|
||||
// Protocol names that we tolerate, but do not generate.
|
||||
// We always generate offers with "UDP/TLS/RTP/SAVPF" when using DTLS-SRTP,
|
||||
// but we tolerate "RTP/SAVPF" and "RTP/SAVP" and the "UDP/TLS" and "TCP/TLS"
|
||||
// prefixes in offers we receive, for compatibility.
|
||||
// RFC4585
|
||||
const char kMediaProtocolSavp[] = "RTP/SAVP";
|
||||
const char kMediaProtocolAvp[] = "RTP/AVP";
|
||||
|
||||
const char kMediaProtocolTcpTlsSavpf[] = "TCP/TLS/RTP/SAVPF";
|
||||
const char kMediaProtocolUdpTlsSavpf[] = "UDP/TLS/RTP/SAVPF";
|
||||
const char kMediaProtocolTcpTlsSavp[] = "TCP/TLS/RTP/SAVP";
|
||||
const char kMediaProtocolUdpTlsSavp[] = "UDP/TLS/RTP/SAVP";
|
||||
|
||||
} // namespace
|
||||
|
||||
bool IsDtlsSctp(absl::string_view protocol) {
|
||||
return protocol == kMediaProtocolDtlsSctp ||
|
||||
@ -38,6 +64,10 @@ bool IsPlainSctp(absl::string_view protocol) {
|
||||
return protocol == kMediaProtocolSctp;
|
||||
}
|
||||
|
||||
bool IsSctpProtocol(absl::string_view protocol) {
|
||||
return IsPlainSctp(protocol) || IsDtlsSctp(protocol);
|
||||
}
|
||||
|
||||
bool IsRtpProtocol(absl::string_view protocol) {
|
||||
if (protocol.empty()) {
|
||||
return true;
|
||||
@ -53,8 +83,23 @@ bool IsRtpProtocol(absl::string_view protocol) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsSctpProtocol(absl::string_view protocol) {
|
||||
return IsPlainSctp(protocol) || IsDtlsSctp(protocol);
|
||||
// Note that the below functions support some protocol strings purely for
|
||||
// legacy compatibility, as required by JSEP in Section 5.1.2, Profile Names
|
||||
// and Interoperability.
|
||||
|
||||
bool IsDtlsRtp(absl::string_view protocol) {
|
||||
// Most-likely values first.
|
||||
return protocol == kMediaProtocolDtlsSavpf ||
|
||||
protocol == kMediaProtocolTcpTlsSavpf ||
|
||||
protocol == kMediaProtocolUdpTlsSavpf ||
|
||||
protocol == kMediaProtocolUdpTlsSavp ||
|
||||
protocol == kMediaProtocolTcpTlsSavp;
|
||||
}
|
||||
|
||||
bool IsPlainRtp(absl::string_view protocol) {
|
||||
// Most-likely values first.
|
||||
return protocol == kMediaProtocolSavpf || protocol == kMediaProtocolAvpf ||
|
||||
protocol == kMediaProtocolSavp || protocol == kMediaProtocolAvp;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -15,21 +15,33 @@
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// Names or name prefixes of protocols as defined by SDP specifications.
|
||||
extern const char kMediaProtocolRtpPrefix[];
|
||||
// Names or name prefixes of protocols as defined by SDP specifications,
|
||||
// and generated in SDP produced by WebRTC.
|
||||
extern const char kMediaProtocolSctp[];
|
||||
extern const char kMediaProtocolDtlsSctp[];
|
||||
extern const char kMediaProtocolUdpDtlsSctp[];
|
||||
extern const char kMediaProtocolTcpDtlsSctp[];
|
||||
extern const char kMediaProtocolDtlsSavpf[];
|
||||
extern const char kMediaProtocolSavpf[];
|
||||
extern const char kMediaProtocolAvpf[];
|
||||
|
||||
bool IsDtlsSctp(absl::string_view protocol);
|
||||
bool IsPlainSctp(absl::string_view protocol);
|
||||
// Exported for testing only
|
||||
extern const char kMediaProtocolTcpDtlsSctp[];
|
||||
extern const char kMediaProtocolDtlsSctp[];
|
||||
|
||||
// Returns true if the given media section protocol indicates use of RTP.
|
||||
bool IsRtpProtocol(absl::string_view protocol);
|
||||
// Returns true if the given media section protocol indicates use of SCTP.
|
||||
bool IsSctpProtocol(absl::string_view protocol);
|
||||
|
||||
// Returns true if the given media protocol is unencrypted SCTP
|
||||
bool IsPlainSctp(absl::string_view protocol);
|
||||
// Returns true if the given media protocol is encrypted SCTP
|
||||
bool IsDtlsSctp(absl::string_view protocol);
|
||||
|
||||
// Returns true if the given media protocol is unencrypted RTP
|
||||
bool IsPlainRtp(absl::string_view protocol);
|
||||
// Returns true if the given media protocol is encrypted RTP
|
||||
bool IsDtlsRtp(absl::string_view protocol);
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // PC_MEDIA_PROTOCOL_NAMES_H_
|
||||
|
||||
@ -116,33 +116,6 @@ cricket::RtpHeaderExtensions UnstoppedOrPresentRtpHeaderExtensions(
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// RTP Profile names
|
||||
// http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xml
|
||||
// RFC4585
|
||||
const char kMediaProtocolAvpf[] = "RTP/AVPF";
|
||||
// RFC5124
|
||||
const char kMediaProtocolDtlsSavpf[] = "UDP/TLS/RTP/SAVPF";
|
||||
|
||||
// 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";
|
||||
|
||||
// Note that the below functions support some protocol strings purely for
|
||||
// legacy compatibility, as required by JSEP in Section 5.1.2, Profile Names
|
||||
// and Interoperability.
|
||||
|
||||
static bool IsDtlsRtp(const std::string& protocol) {
|
||||
// Most-likely values first.
|
||||
return protocol == "UDP/TLS/RTP/SAVPF" || protocol == "TCP/TLS/RTP/SAVPF" ||
|
||||
protocol == "UDP/TLS/RTP/SAVP" || protocol == "TCP/TLS/RTP/SAVP";
|
||||
}
|
||||
|
||||
static bool IsPlainRtp(const std::string& protocol) {
|
||||
// Most-likely values first.
|
||||
return protocol == "RTP/SAVPF" || protocol == "RTP/AVPF" ||
|
||||
protocol == "RTP/SAVP" || protocol == "RTP/AVP";
|
||||
}
|
||||
|
||||
static RtpTransceiverDirection NegotiateRtpTransceiverDirection(
|
||||
RtpTransceiverDirection offer,
|
||||
RtpTransceiverDirection wants) {
|
||||
@ -1436,14 +1409,12 @@ static bool IsMediaProtocolSupported(MediaType type,
|
||||
}
|
||||
|
||||
if (type == MEDIA_TYPE_DATA) {
|
||||
// Check for SCTP, but also for RTP for RTP-based data channels.
|
||||
// TODO(pthatcher): Remove RTP once RTP-based data channels are gone.
|
||||
// Check for SCTP
|
||||
if (secure_transport) {
|
||||
// Most likely scenarios first.
|
||||
return IsDtlsSctp(protocol) || IsDtlsRtp(protocol) ||
|
||||
IsPlainRtp(protocol);
|
||||
return IsDtlsSctp(protocol);
|
||||
} else {
|
||||
return IsPlainSctp(protocol) || IsPlainRtp(protocol);
|
||||
return IsPlainSctp(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,13 +47,6 @@ typedef std::vector<VideoCodec> VideoCodecs;
|
||||
typedef std::vector<CryptoParams> CryptoParamsVec;
|
||||
typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
|
||||
|
||||
// RTC4585 RTP/AVPF
|
||||
extern const char kMediaProtocolAvpf[];
|
||||
// RFC5124 RTP/SAVPF
|
||||
extern const char kMediaProtocolSavpf[];
|
||||
|
||||
extern const char kMediaProtocolDtlsSavpf[];
|
||||
|
||||
// Options to control how session descriptions are generated.
|
||||
const int kAutoBandwidth = -1;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user