1 /* 2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKETIZER_AV1_TEST_HELPER_H_ 12 #define MODULES_RTP_RTCP_SOURCE_RTP_PACKETIZER_AV1_TEST_HELPER_H_ 13 14 #include <stdint.h> 15 16 #include <initializer_list> 17 #include <utility> 18 #include <vector> 19 20 namespace webrtc { 21 // All obu types offset by 3 to take correct position in the obu_header. 22 constexpr uint8_t kAv1ObuTypeSequenceHeader = 1 << 3; 23 constexpr uint8_t kAv1ObuTypeTemporalDelimiter = 2 << 3; 24 constexpr uint8_t kAv1ObuTypeFrameHeader = 3 << 3; 25 constexpr uint8_t kAv1ObuTypeTileGroup = 4 << 3; 26 constexpr uint8_t kAv1ObuTypeMetadata = 5 << 3; 27 constexpr uint8_t kAv1ObuTypeFrame = 6 << 3; 28 constexpr uint8_t kAv1ObuTypeTileList = 8 << 3; 29 constexpr uint8_t kAv1ObuExtensionPresentBit = 0b0'0000'100; 30 constexpr uint8_t kAv1ObuSizePresentBit = 0b0'0000'010; 31 constexpr uint8_t kAv1ObuExtensionS1T1 = 0b001'01'000; 32 33 class Av1Obu { 34 public: 35 explicit Av1Obu(uint8_t obu_type); 36 37 Av1Obu& WithExtension(uint8_t extension); 38 Av1Obu& WithoutSize(); 39 Av1Obu& WithPayload(std::vector<uint8_t> payload); 40 41 private: 42 friend std::vector<uint8_t> BuildAv1Frame(std::initializer_list<Av1Obu> obus); 43 uint8_t header_; 44 uint8_t extension_ = 0; 45 std::vector<uint8_t> payload_; 46 }; 47 48 std::vector<uint8_t> BuildAv1Frame(std::initializer_list<Av1Obu> obus); 49 50 } // namespace webrtc 51 #endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKETIZER_AV1_TEST_HELPER_H_ 52