xref: /aosp_15_r20/external/webrtc/modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2019 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 #ifndef MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_EXTENSION_H_
11 #define MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_EXTENSION_H_
12 
13 #include <bitset>
14 #include <cstdint>
15 
16 #include "absl/strings/string_view.h"
17 #include "api/array_view.h"
18 #include "api/rtp_parameters.h"
19 #include "api/transport/rtp/dependency_descriptor.h"
20 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
21 
22 namespace webrtc {
23 // Trait to read/write the dependency descriptor extension as described in
24 // https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension
25 // While the format is still in design, the code might change without backward
26 // compatibility.
27 class RtpDependencyDescriptorExtension {
28  public:
29   static constexpr RTPExtensionType kId = kRtpExtensionGenericFrameDescriptor02;
Uri()30   static constexpr absl::string_view Uri() {
31     return RtpExtension::kDependencyDescriptorUri;
32   }
33 
34   static bool Parse(rtc::ArrayView<const uint8_t> data,
35                     const FrameDependencyStructure* structure,
36                     DependencyDescriptor* descriptor);
37 
ValueSize(const FrameDependencyStructure & structure,const DependencyDescriptor & descriptor)38   static size_t ValueSize(const FrameDependencyStructure& structure,
39                           const DependencyDescriptor& descriptor) {
40     return ValueSize(structure, kAllChainsAreActive, descriptor);
41   }
42   static size_t ValueSize(const FrameDependencyStructure& structure,
43                           std::bitset<32> active_chains,
44                           const DependencyDescriptor& descriptor);
Write(rtc::ArrayView<uint8_t> data,const FrameDependencyStructure & structure,const DependencyDescriptor & descriptor)45   static bool Write(rtc::ArrayView<uint8_t> data,
46                     const FrameDependencyStructure& structure,
47                     const DependencyDescriptor& descriptor) {
48     return Write(data, structure, kAllChainsAreActive, descriptor);
49   }
50   static bool Write(rtc::ArrayView<uint8_t> data,
51                     const FrameDependencyStructure& structure,
52                     std::bitset<32> active_chains,
53                     const DependencyDescriptor& descriptor);
54 
55  private:
56   static constexpr std::bitset<32> kAllChainsAreActive = ~uint32_t{0};
57 };
58 
59 }  // namespace webrtc
60 
61 #endif  // MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_EXTENSION_H_
62