From afe5d2f7583f49fd2641154897f38ebceb6be80e Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Tue, 10 Dec 2024 12:47:47 +0000 Subject: [PATCH] Add test for payload type H.264 profile-level-id behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:360058654 Change-Id: I055af71c455e398af88c77584734d66a207d43b2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/370844 Reviewed-by: Henrik Boström Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#43537} --- call/payload_type_picker_unittest.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/call/payload_type_picker_unittest.cc b/call/payload_type_picker_unittest.cc index bc5913f450..6e4666ed8a 100644 --- a/call/payload_type_picker_unittest.cc +++ b/call/payload_type_picker_unittest.cc @@ -13,10 +13,14 @@ #include "call/payload_type.h" #include "media/base/codec.h" #include "media/base/media_constants.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { +using testing::Eq; +using testing::Ne; + TEST(PayloadTypePicker, PayloadTypeAssignmentWorks) { // Note: This behavior is due to be deprecated and removed. PayloadType pt_a(1); @@ -174,4 +178,27 @@ TEST(PayloadTypePicker, RecordedValueExcluded) { EXPECT_NE(47, result.value()); } +TEST(PayloadTypePicker, ChoosingH264Profiles) { + // No opinion on whether these are right or wrong, just that their + // behavior is consistent. + PayloadTypePicker picker; + cricket::Codec h264_constrained = cricket::CreateVideoCodec(SdpVideoFormat( + cricket::kH264CodecName, {{cricket::kH264FmtpProfileLevelId, "42e01f"}, + {cricket::kH264FmtpLevelAsymmetryAllowed, "1"}, + {cricket::kH264FmtpPacketizationMode, "1"}})); + cricket::Codec h264_high_1f = cricket::CreateVideoCodec(SdpVideoFormat( + cricket::kH264CodecName, {{cricket::kH264FmtpProfileLevelId, "640c1f"}, + {cricket::kH264FmtpLevelAsymmetryAllowed, "1"}, + {cricket::kH264FmtpPacketizationMode, "1"}})); + cricket::Codec h264_high_2a = cricket::CreateVideoCodec(SdpVideoFormat( + cricket::kH264CodecName, {{cricket::kH264FmtpProfileLevelId, "640c2a"}, + {cricket::kH264FmtpLevelAsymmetryAllowed, "1"}, + {cricket::kH264FmtpPacketizationMode, "1"}})); + PayloadType pt_constrained = + picker.SuggestMapping(h264_constrained, nullptr).value(); + PayloadType pt_high_1f = picker.SuggestMapping(h264_high_1f, nullptr).value(); + PayloadType pt_high_2a = picker.SuggestMapping(h264_high_2a, nullptr).value(); + EXPECT_THAT(pt_constrained, Ne(pt_high_1f)); + EXPECT_THAT(pt_high_1f, Eq(pt_high_2a)); +} } // namespace webrtc