xref: /aosp_15_r20/external/webrtc/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.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_READER_H_
11 #define MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_
12 
13 #include <cstdint>
14 #include <memory>
15 #include <vector>
16 
17 #include "api/array_view.h"
18 #include "api/transport/rtp/dependency_descriptor.h"
19 #include "rtc_base/bitstream_reader.h"
20 
21 namespace webrtc {
22 // Deserializes DependencyDescriptor rtp header extension.
23 class RtpDependencyDescriptorReader {
24  public:
25   // Parses the dependency descriptor.
26   RtpDependencyDescriptorReader(rtc::ArrayView<const uint8_t> raw_data,
27                                 const FrameDependencyStructure* structure,
28                                 DependencyDescriptor* descriptor);
29   RtpDependencyDescriptorReader(const RtpDependencyDescriptorReader&) = delete;
30   RtpDependencyDescriptorReader& operator=(
31       const RtpDependencyDescriptorReader&) = delete;
32 
33   // Returns true if parse was successful.
ParseSuccessful()34   bool ParseSuccessful() { return buffer_.Ok(); }
35 
36  private:
37   // Functions to read template dependency structure.
38   void ReadTemplateDependencyStructure();
39   void ReadTemplateLayers();
40   void ReadTemplateDtis();
41   void ReadTemplateFdiffs();
42   void ReadTemplateChains();
43   void ReadResolutions();
44 
45   // Function to read details for the current frame.
46   void ReadMandatoryFields();
47   void ReadExtendedFields();
48   void ReadFrameDependencyDefinition();
49 
50   void ReadFrameDtis();
51   void ReadFrameFdiffs();
52   void ReadFrameChains();
53 
54   // Output.
55   DependencyDescriptor* const descriptor_;
56   // Values that are needed while reading the descriptor, but can be discarded
57   // when reading is complete.
58   BitstreamReader buffer_;
59   int frame_dependency_template_id_ = 0;
60   bool active_decode_targets_present_flag_ = false;
61   bool custom_dtis_flag_ = false;
62   bool custom_fdiffs_flag_ = false;
63   bool custom_chains_flag_ = false;
64   const FrameDependencyStructure* structure_ = nullptr;
65 };
66 
67 }  // namespace webrtc
68 
69 #endif  // MODULES_RTP_RTCP_SOURCE_RTP_DEPENDENCY_DESCRIPTOR_READER_H_
70