mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Add RtpPacket
test for the abs-capture-time extension
Clarify when the RTP header extension can be set depending on the value of the `extmap-allow-mixed` option and on whether the header extension ID is for one-byte or two-bytes extensions. Bug: b/270541827 Change-Id: I4b939f6862d1f19cbfea11518a1cc1507beb2362 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294920 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39399}
This commit is contained in:
parent
72b11a407a
commit
ba3a1e2c26
1 changed files with 21 additions and 11 deletions
|
@ -37,6 +37,7 @@ constexpr uint8_t kAudioLevelExtensionId = 9;
|
|||
constexpr uint8_t kRtpStreamIdExtensionId = 0xa;
|
||||
constexpr uint8_t kRtpMidExtensionId = 0xb;
|
||||
constexpr uint8_t kVideoTimingExtensionId = 0xc;
|
||||
// ID for two-bytes header extensions. See RFC8285 section 4.3.
|
||||
constexpr uint8_t kTwoByteExtensionId = 0xf0;
|
||||
constexpr int32_t kTimeOffset = 0x56ce;
|
||||
constexpr bool kVoiceActive = true;
|
||||
|
@ -45,6 +46,7 @@ constexpr char kStreamId[] = "streamid";
|
|||
constexpr char kMid[] = "mid";
|
||||
constexpr char kLongMid[] = "extra-long string to test two-byte header";
|
||||
constexpr size_t kMaxPaddingSize = 224u;
|
||||
|
||||
// clang-format off
|
||||
constexpr uint8_t kMinimumPacket[] = {
|
||||
0x80, kPayloadType, kSeqNumFirstByte, kSeqNumSecondByte,
|
||||
|
@ -189,7 +191,7 @@ constexpr uint8_t kPacketWithLegacyTimingExtension[] = {
|
|||
|
||||
void TestCreateAndParseColorSpaceExtension(bool with_hdr_metadata) {
|
||||
// Create packet with extension.
|
||||
RtpPacket::ExtensionManager extensions(/*extmap-allow-mixed=*/true);
|
||||
RtpPacket::ExtensionManager extensions(/*extmap_allow_mixed=*/true);
|
||||
extensions.Register<ColorSpaceExtension>(1);
|
||||
RtpPacket packet(&extensions);
|
||||
const ColorSpace kColorSpace = CreateTestColorSpace(with_hdr_metadata);
|
||||
|
@ -241,7 +243,7 @@ TEST(RtpPacketTest, CreateWith2Extensions) {
|
|||
}
|
||||
|
||||
TEST(RtpPacketTest, CreateWithTwoByteHeaderExtensionFirst) {
|
||||
RtpPacketToSend::ExtensionManager extensions(true);
|
||||
RtpPacketToSend::ExtensionManager extensions(/*extmap_allow_mixed=*/true);
|
||||
extensions.Register<TransmissionOffset>(kTransmissionOffsetExtensionId);
|
||||
extensions.Register<AudioLevel>(kAudioLevelExtensionId);
|
||||
extensions.Register<PlayoutDelayLimits>(kTwoByteExtensionId);
|
||||
|
@ -261,7 +263,7 @@ TEST(RtpPacketTest, CreateWithTwoByteHeaderExtensionFirst) {
|
|||
|
||||
TEST(RtpPacketTest, CreateWithTwoByteHeaderExtensionLast) {
|
||||
// This test will trigger RtpPacket::PromoteToTwoByteHeaderExtension().
|
||||
RtpPacketToSend::ExtensionManager extensions(true);
|
||||
RtpPacketToSend::ExtensionManager extensions(/*extmap_allow_mixed=*/true);
|
||||
extensions.Register<TransmissionOffset>(kTransmissionOffsetExtensionId);
|
||||
extensions.Register<AudioLevel>(kAudioLevelExtensionId);
|
||||
extensions.Register<PlayoutDelayLimits>(kTwoByteExtensionId);
|
||||
|
@ -333,6 +335,14 @@ TEST(RtpPacketTest, TryToCreateTwoByteHeaderNotSupported) {
|
|||
EXPECT_FALSE(packet.SetExtension<AudioLevel>(kVoiceActive, kAudioLevel));
|
||||
}
|
||||
|
||||
TEST(RtpPacketTest, CreateTwoByteHeaderSupportedIfExtmapAllowMixed) {
|
||||
RtpPacketToSend::ExtensionManager extensions(/*extmap_allow_mixed=*/true);
|
||||
extensions.Register<AudioLevel>(kTwoByteExtensionId);
|
||||
RtpPacketToSend packet(&extensions);
|
||||
// Set extension that requires two-byte header.
|
||||
EXPECT_TRUE(packet.SetExtension<AudioLevel>(kVoiceActive, kAudioLevel));
|
||||
}
|
||||
|
||||
TEST(RtpPacketTest, CreateWithMaxSizeHeaderExtension) {
|
||||
const std::string kValue = "123456789abcdef";
|
||||
RtpPacket::ExtensionManager extensions;
|
||||
|
@ -954,9 +964,8 @@ TEST(RtpPacketTest, CreateAndParseColorSpaceExtensionWithoutHdrMetadata) {
|
|||
|
||||
TEST(RtpPacketTest, CreateAndParseAbsoluteCaptureTime) {
|
||||
// Create a packet with absolute capture time extension populated.
|
||||
RtpPacketToSend::ExtensionManager extensions;
|
||||
constexpr int kExtensionId = 1;
|
||||
extensions.Register<AbsoluteCaptureTimeExtension>(kExtensionId);
|
||||
RtpPacketToSend::ExtensionManager extensions(/*extmap_allow_mixed=*/true);
|
||||
extensions.Register<AbsoluteCaptureTimeExtension>(kTwoByteExtensionId);
|
||||
RtpPacketToSend send_packet(&extensions);
|
||||
send_packet.SetPayloadType(kPayloadType);
|
||||
send_packet.SetSequenceNumber(kSeqNum);
|
||||
|
@ -966,7 +975,8 @@ TEST(RtpPacketTest, CreateAndParseAbsoluteCaptureTime) {
|
|||
constexpr AbsoluteCaptureTime kAbsoluteCaptureTime{
|
||||
/*absolute_capture_timestamp=*/9876543210123456789ULL,
|
||||
/*estimated_capture_clock_offset=*/-1234567890987654321LL};
|
||||
send_packet.SetExtension<AbsoluteCaptureTimeExtension>(kAbsoluteCaptureTime);
|
||||
ASSERT_TRUE(send_packet.SetExtension<AbsoluteCaptureTimeExtension>(
|
||||
kAbsoluteCaptureTime));
|
||||
|
||||
// Serialize the packet and then parse it again.
|
||||
RtpPacketReceived receive_packet(&extensions);
|
||||
|
@ -984,9 +994,8 @@ TEST(RtpPacketTest, CreateAndParseAbsoluteCaptureTime) {
|
|||
TEST(RtpPacketTest,
|
||||
CreateAndParseAbsoluteCaptureTimeWithoutEstimatedCaptureClockOffset) {
|
||||
// Create a packet with absolute capture time extension populated.
|
||||
RtpPacketToSend::ExtensionManager extensions;
|
||||
constexpr int kExtensionId = 1;
|
||||
extensions.Register<AbsoluteCaptureTimeExtension>(kExtensionId);
|
||||
RtpPacketToSend::ExtensionManager extensions(/*extmap_allow_mixed=*/true);
|
||||
extensions.Register<AbsoluteCaptureTimeExtension>(kTwoByteExtensionId);
|
||||
RtpPacketToSend send_packet(&extensions);
|
||||
send_packet.SetPayloadType(kPayloadType);
|
||||
send_packet.SetSequenceNumber(kSeqNum);
|
||||
|
@ -996,7 +1005,8 @@ TEST(RtpPacketTest,
|
|||
constexpr AbsoluteCaptureTime kAbsoluteCaptureTime{
|
||||
/*absolute_capture_timestamp=*/9876543210123456789ULL,
|
||||
/*estimated_capture_clock_offset=*/absl::nullopt};
|
||||
send_packet.SetExtension<AbsoluteCaptureTimeExtension>(kAbsoluteCaptureTime);
|
||||
ASSERT_TRUE(send_packet.SetExtension<AbsoluteCaptureTimeExtension>(
|
||||
kAbsoluteCaptureTime));
|
||||
|
||||
// Serialize the packet and then parse it again.
|
||||
RtpPacketReceived receive_packet(&extensions);
|
||||
|
|
Loading…
Reference in a new issue