Add functions IsLegalMidName and IsLegalRsidName
This is a preparation for deleting the class StringRtpHeaderExtension. Bug: webrtc:10440 Change-Id: I3480e58d96e67d10c4d78597c8ab7f01b63e37ca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128761 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27228}
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#include "api/rtp_headers.h"
|
||||
#include "call/rtcp_packet_sink_interface.h"
|
||||
#include "call/rtp_rtcp_demuxer_helper.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -39,7 +40,7 @@ void RtcpDemuxer::AddSink(uint32_t sender_ssrc, RtcpPacketSinkInterface* sink) {
|
||||
|
||||
void RtcpDemuxer::AddSink(const std::string& rsid,
|
||||
RtcpPacketSinkInterface* sink) {
|
||||
RTC_DCHECK(StreamId::IsLegalRsidName(rsid));
|
||||
RTC_DCHECK(IsLegalRsidName(rsid));
|
||||
RTC_DCHECK(sink);
|
||||
RTC_DCHECK(!ContainerHasKey(broadcast_sinks_, sink));
|
||||
RTC_DCHECK(!MultimapAssociationExists(rsid_sinks_, rsid, sink));
|
||||
|
@ -38,8 +38,8 @@ bool RtpDemuxer::AddSink(const RtpDemuxerCriteria& criteria,
|
||||
RtpPacketSinkInterface* sink) {
|
||||
RTC_DCHECK(!criteria.payload_types.empty() || !criteria.ssrcs.empty() ||
|
||||
!criteria.mid.empty() || !criteria.rsid.empty());
|
||||
RTC_DCHECK(criteria.mid.empty() || Mid::IsLegalMidName(criteria.mid));
|
||||
RTC_DCHECK(criteria.rsid.empty() || StreamId::IsLegalRsidName(criteria.rsid));
|
||||
RTC_DCHECK(criteria.mid.empty() || IsLegalMidName(criteria.mid));
|
||||
RTC_DCHECK(criteria.rsid.empty() || IsLegalRsidName(criteria.rsid));
|
||||
RTC_DCHECK(sink);
|
||||
|
||||
// We return false instead of DCHECKing for logical conflicts with the new
|
||||
|
@ -104,6 +104,7 @@ rtc_source_set("rtp_rtcp_format") {
|
||||
"../../rtc_base/system:unused",
|
||||
"../../system_wrappers",
|
||||
"../video_coding:codec_globals_headers",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
"//third_party/abseil-cpp/absl/types:variant",
|
||||
]
|
||||
|
@ -20,9 +20,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {}
|
||||
|
||||
constexpr size_t StreamId::kMaxSize;
|
||||
namespace {
|
||||
constexpr size_t kMidRsidMaxSize = 16;
|
||||
|
||||
// Check if passed character is a "token-char" from RFC 4566.
|
||||
static bool IsTokenChar(char ch) {
|
||||
@ -31,16 +30,30 @@ static bool IsTokenChar(char ch) {
|
||||
(ch >= 0x41 && ch <= 0x5a) || (ch >= 0x5e && ch <= 0x7e);
|
||||
}
|
||||
|
||||
bool StreamId::IsLegalMidName(rtc::ArrayView<const char> name) {
|
||||
return (name.size() <= kMaxSize && name.size() > 0 &&
|
||||
} // namespace
|
||||
|
||||
StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {}
|
||||
|
||||
constexpr size_t StreamId::kMaxSize;
|
||||
|
||||
bool IsLegalMidName(absl::string_view name) {
|
||||
return (name.size() <= kMidRsidMaxSize && name.size() > 0 &&
|
||||
std::all_of(name.data(), name.data() + name.size(), IsTokenChar));
|
||||
}
|
||||
|
||||
bool StreamId::IsLegalRsidName(rtc::ArrayView<const char> name) {
|
||||
return (name.size() <= kMaxSize && name.size() > 0 &&
|
||||
bool StreamId::IsLegalMidName(rtc::ArrayView<const char> name) {
|
||||
return ::webrtc::IsLegalMidName(absl::string_view(name.data(), name.size()));
|
||||
}
|
||||
|
||||
bool IsLegalRsidName(absl::string_view name) {
|
||||
return (name.size() <= kMidRsidMaxSize && name.size() > 0 &&
|
||||
std::all_of(name.data(), name.data() + name.size(), isalnum));
|
||||
}
|
||||
|
||||
bool StreamId::IsLegalRsidName(rtc::ArrayView<const char> name) {
|
||||
return ::webrtc::IsLegalRsidName(absl::string_view(name.data(), name.size()));
|
||||
}
|
||||
|
||||
void StreamId::Set(const char* data, size_t size) {
|
||||
// If |data| contains \0, the stream id size might become less than |size|.
|
||||
RTC_CHECK_LE(size, kMaxSize);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/variant.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/rtp_headers.h"
|
||||
@ -45,6 +46,9 @@ enum ProtectionType { kUnprotectedPacket, kProtectedPacket };
|
||||
|
||||
enum StorageType { kDontRetransmit, kAllowRetransmission };
|
||||
|
||||
bool IsLegalMidName(absl::string_view name);
|
||||
bool IsLegalRsidName(absl::string_view name);
|
||||
|
||||
// This enum must not have any gaps, i.e., all integers between
|
||||
// kRtpExtensionNone and kRtpExtensionNumberOfExtensions must be valid enum
|
||||
// entries.
|
||||
|
Reference in New Issue
Block a user