Clean up 32 byte mid support from the demuxer
the SDP parser is restricting this to 16 bytes already BUG=webrtc:42222663 Change-Id: I26f8f15a3f15cb5a5c8eab64f9dc3e26c0ea1bbb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/359780 Reviewed-by: Florent Castelli <orphis@webrtc.org> Commit-Queue: Philipp Hancke <phancke@meta.com> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42809}
This commit is contained in:
parent
b1ffa9bd4e
commit
37c406a1fd
@ -40,25 +40,14 @@ size_t RemoveFromMapByValue(Map* map, const Value& value) {
|
||||
return EraseIf(*map, [&](const auto& elem) { return elem.second == value; });
|
||||
}
|
||||
|
||||
// Temp fix: MID in SDP is allowed to be slightly longer than what's allowed
|
||||
// in the RTP demuxer. Truncate if needed; this won't match, but it only
|
||||
// makes sense in places that wouldn't use this for matching anyway.
|
||||
// TODO(bugs.webrtc.org/12517): remove when length 16 is policed by parser.
|
||||
std::string CheckMidLength(absl::string_view mid) {
|
||||
std::string new_mid(mid);
|
||||
if (new_mid.length() > BaseRtpStringExtension::kMaxValueSizeBytes) {
|
||||
RTC_LOG(LS_WARNING) << "`mid` attribute too long. Truncating.";
|
||||
new_mid.resize(BaseRtpStringExtension::kMaxValueSizeBytes);
|
||||
}
|
||||
return new_mid;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RtpDemuxerCriteria::RtpDemuxerCriteria(
|
||||
absl::string_view mid,
|
||||
absl::string_view rsid /*= absl::string_view()*/)
|
||||
: mid_(CheckMidLength(mid)), rsid_(rsid) {}
|
||||
: mid_(mid), rsid_(rsid) {
|
||||
RTC_DCHECK(mid.length() <= BaseRtpStringExtension::kMaxValueSizeBytes);
|
||||
}
|
||||
|
||||
RtpDemuxerCriteria::RtpDemuxerCriteria() = default;
|
||||
RtpDemuxerCriteria::~RtpDemuxerCriteria() = default;
|
||||
|
||||
@ -1238,26 +1238,14 @@ TEST_F(RtpDemuxerTest, PacketWithMidAndUnknownRsidIsNotRoutedByPayloadType) {
|
||||
EXPECT_FALSE(demuxer_.OnRtpPacket(*packet));
|
||||
}
|
||||
|
||||
TEST_F(RtpDemuxerTest, MidMustNotExceedMaximumLength) {
|
||||
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
|
||||
|
||||
TEST_F(RtpDemuxerDeathTest, MidMustNotExceedMaximumLength) {
|
||||
MockRtpPacketSink sink1;
|
||||
std::string mid1(BaseRtpStringExtension::kMaxValueSizeBytes + 1, 'a');
|
||||
// Adding the sink should pass even though the supplied mid is too long.
|
||||
// The mid will be truncated though.
|
||||
EXPECT_TRUE(AddSinkOnlyMid(mid1, &sink1));
|
||||
|
||||
// Adding a second sink with a mid that matches the truncated mid that was
|
||||
// just added, should fail.
|
||||
MockRtpPacketSink sink2;
|
||||
std::string mid2(mid1.substr(0, BaseRtpStringExtension::kMaxValueSizeBytes));
|
||||
EXPECT_FALSE(AddSinkOnlyMid(mid2, &sink2));
|
||||
EXPECT_FALSE(RemoveSink(&sink2));
|
||||
|
||||
// Remove the original sink.
|
||||
EXPECT_TRUE(RemoveSink(&sink1));
|
||||
EXPECT_DEATH(AddSinkOnlyMid(mid1, &sink1), "");
|
||||
}
|
||||
|
||||
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
|
||||
|
||||
TEST_F(RtpDemuxerDeathTest, CriteriaMustBeNonEmpty) {
|
||||
MockRtpPacketSink sink;
|
||||
RtpDemuxerCriteria criteria;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user