From 0e9da451063950ba1d5e7e9daebdf2c374371d75 Mon Sep 17 00:00:00 2001 From: Abraham Corea Diaz Date: Fri, 9 Jul 2021 20:38:37 +0000 Subject: Add a new constant for AV1 codec. This patch adds a new constant representing the AV1 video codec and a unit test for it. It also adds AV1 and VP9 constants to RtpPayloadType. Change-Id: I3233ea97c3fb9759805b9c8f3d6faecbf9fa3e30 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/3012119 Reviewed-by: Jordan Bayles Reviewed-by: mark a. foltz --- cast/streaming/constants.h | 2 +- cast/streaming/message_fields.cc | 5 ++-- cast/streaming/offer_messages_unittest.cc | 44 ++++++++++++++++++++++++++++--- cast/streaming/rtp_defines.cc | 2 ++ cast/streaming/rtp_defines.h | 4 ++- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/cast/streaming/constants.h b/cast/streaming/constants.h index 668b6bca..03026620 100644 --- a/cast/streaming/constants.h +++ b/cast/streaming/constants.h @@ -109,7 +109,7 @@ constexpr int kSupportedRemotingVersion = 2; // remoted and is not specified as part of the OFFER message (indicated as // "REMOTE_AUDIO" or "REMOTE_VIDEO"). enum class AudioCodec { kAac, kOpus, kNotSpecified }; -enum class VideoCodec { kH264, kVp8, kHevc, kVp9, kNotSpecified }; +enum class VideoCodec { kH264, kVp8, kHevc, kNotSpecified, kVp9, kAv1 }; enum class CastMode : uint8_t { kMirroring, kRemoting }; diff --git a/cast/streaming/message_fields.cc b/cast/streaming/message_fields.cc index 9eb40bf3..4411c80d 100644 --- a/cast/streaming/message_fields.cc +++ b/cast/streaming/message_fields.cc @@ -19,12 +19,13 @@ constexpr EnumNameTable kAudioCodecNames{ {"opus", AudioCodec::kOpus}, {"REMOTE_AUDIO", AudioCodec::kNotSpecified}}}; -constexpr EnumNameTable kVideoCodecNames{ +constexpr EnumNameTable kVideoCodecNames{ {{"h264", VideoCodec::kH264}, {"vp8", VideoCodec::kVp8}, {"hevc", VideoCodec::kHevc}, + {"REMOTE_VIDEO", VideoCodec::kNotSpecified}, {"vp9", VideoCodec::kVp9}, - {"REMOTE_VIDEO", VideoCodec::kNotSpecified}}}; + {"av1", VideoCodec::kAv1}}}; } // namespace diff --git a/cast/streaming/offer_messages_unittest.cc b/cast/streaming/offer_messages_unittest.cc index 038d2f80..3bad54d0 100644 --- a/cast/streaming/offer_messages_unittest.cc +++ b/cast/streaming/offer_messages_unittest.cc @@ -81,6 +81,22 @@ constexpr char kValidOffer[] = R"({ "channels": 2, "aesKey": "51027e4e2347cbcb49d57ef10177aebc", "aesIvMask": "7f12a19be62a36c04ae4116caaeff6d1" + }, + { + "index": 3, + "type": "video_source", + "codecName": "av1", + "rtpProfile": "cast", + "rtpPayloadType": 104, + "ssrc": 19088744, + "maxFrameRate": "30000/1001", + "targetDelay": 1000, + "timeBase": "1/90000", + "maxBitRate": 5000000, + "profile": "main", + "level": "5", + "aesKey": "bbf109bf84513b456b13a184453b66ce", + "aesIvMask": "edaf9e4536e2b66191f560d9c04b2a69" } ] })"; @@ -103,12 +119,13 @@ void ExpectEqualsValidOffer(const Offer& offer) { EXPECT_EQ(CastMode::kMirroring, offer.cast_mode); // Verify list of video streams. - EXPECT_EQ(2u, offer.video_streams.size()); + EXPECT_EQ(3u, offer.video_streams.size()); const auto& video_streams = offer.video_streams; const bool flipped = video_streams[0].stream.index != 0; - const VideoStream& vs_one = flipped ? video_streams[1] : video_streams[0]; - const VideoStream& vs_two = flipped ? video_streams[0] : video_streams[1]; + const VideoStream& vs_one = flipped ? video_streams[2] : video_streams[0]; + const VideoStream& vs_two = video_streams[1]; + const VideoStream& vs_three = flipped ? video_streams[0] : video_streams[2]; EXPECT_EQ(0, vs_one.stream.index); EXPECT_EQ(1, vs_one.stream.channels); @@ -163,6 +180,27 @@ void ExpectEqualsValidOffer(const Offer& offer) { const auto& resolutions_two = vs_two.resolutions; EXPECT_EQ(0u, resolutions_two.size()); + EXPECT_EQ(3, vs_three.stream.index); + EXPECT_EQ(1, vs_three.stream.channels); + EXPECT_EQ(Stream::Type::kVideoSource, vs_three.stream.type); + EXPECT_EQ(VideoCodec::kAv1, vs_three.codec); + EXPECT_EQ(RtpPayloadType::kVideoAv1, vs_three.stream.rtp_payload_type); + EXPECT_EQ(19088744u, vs_three.stream.ssrc); + EXPECT_EQ((SimpleFraction{30000, 1001}), vs_three.max_frame_rate); + EXPECT_EQ(90000, vs_three.stream.rtp_timebase); + EXPECT_EQ(5000000, vs_three.max_bit_rate); + EXPECT_EQ("main", vs_three.profile); + EXPECT_EQ("5", vs_three.level); + EXPECT_THAT(vs_three.stream.aes_key, + ElementsAre(0xbb, 0xf1, 0x09, 0xbf, 0x84, 0x51, 0x3b, 0x45, 0x6b, + 0x13, 0xa1, 0x84, 0x45, 0x3b, 0x66, 0xce)); + EXPECT_THAT(vs_three.stream.aes_iv_mask, + ElementsAre(0xed, 0xaf, 0x9e, 0x45, 0x36, 0xe2, 0xb6, 0x61, 0x91, + 0xf5, 0x60, 0xd9, 0xc0, 0x4b, 0x2a, 0x69)); + + const auto& resolutions_three = vs_three.resolutions; + EXPECT_EQ(0u, resolutions_three.size()); + // Verify list of audio streams. EXPECT_EQ(1u, offer.audio_streams.size()); const AudioStream& as = offer.audio_streams[0]; diff --git a/cast/streaming/rtp_defines.cc b/cast/streaming/rtp_defines.cc index e07b590f..4a811a7a 100644 --- a/cast/streaming/rtp_defines.cc +++ b/cast/streaming/rtp_defines.cc @@ -61,6 +61,8 @@ bool IsRtpPayloadType(uint8_t raw_byte) { case RtpPayloadType::kAudioVarious: case RtpPayloadType::kVideoVp8: case RtpPayloadType::kVideoH264: + case RtpPayloadType::kVideoVp9: + case RtpPayloadType::kVideoAv1: case RtpPayloadType::kVideoVarious: case RtpPayloadType::kAudioHackForAndroidTV: // Note: RtpPayloadType::kVideoHackForAndroidTV has the same value as diff --git a/cast/streaming/rtp_defines.h b/cast/streaming/rtp_defines.h index 1f9cc43f..43005714 100644 --- a/cast/streaming/rtp_defines.h +++ b/cast/streaming/rtp_defines.h @@ -92,7 +92,9 @@ enum class RtpPayloadType : uint8_t { kVideoVp8 = 100, kVideoH264 = 101, kVideoVarious = 102, // Codec being used is not fixed. - kVideoLast = 102, + kVideoVp9 = 103, + kVideoAv1 = 104, + kVideoLast = kVideoAv1, // Some AndroidTV receivers require the payload type for audio to be 127, and // video to be 96; regardless of the codecs actually being used. This is -- cgit v1.2.3