1 /*
2  *  Copyright (c) 2018 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_VIDEO_HEADER_H_
11 #define MODULES_RTP_RTCP_SOURCE_RTP_VIDEO_HEADER_H_
12 
13 #include <bitset>
14 #include <cstdint>
15 
16 #include "absl/container/inlined_vector.h"
17 #include "absl/types/optional.h"
18 #include "absl/types/variant.h"
19 #include "api/transport/rtp/dependency_descriptor.h"
20 #include "api/video/color_space.h"
21 #include "api/video/video_codec_type.h"
22 #include "api/video/video_content_type.h"
23 #include "api/video/video_frame_type.h"
24 #include "api/video/video_rotation.h"
25 #include "api/video/video_timing.h"
26 #include "common_types.h"  // NOLINT(build/include_directory)
27 #include "modules/video_coding/codecs/h264/include/h264_globals.h"
28 #include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
29 #include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
30 
31 namespace webrtc {
32 // Details passed in the rtp payload for legacy generic rtp packetizer.
33 // TODO(bugs.webrtc.org/9772): Deprecate in favor of passing generic video
34 // details in an rtp header extension.
35 struct RTPVideoHeaderLegacyGeneric {
36   uint16_t picture_id;
37 };
38 
39 using RTPVideoTypeHeader = absl::variant<absl::monostate,
40                                          RTPVideoHeaderVP8,
41                                          RTPVideoHeaderVP9,
42                                          RTPVideoHeaderH264,
43                                          RTPVideoHeaderLegacyGeneric>;
44 
45 struct RTPVideoHeader {
46   struct GenericDescriptorInfo {
47     GenericDescriptorInfo();
48     GenericDescriptorInfo(const GenericDescriptorInfo& other);
49     ~GenericDescriptorInfo();
50 
51     int64_t frame_id = 0;
52     int spatial_index = 0;
53     int temporal_index = 0;
54     absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications;
55     absl::InlinedVector<int64_t, 5> dependencies;
56     absl::InlinedVector<int, 4> chain_diffs;
57     std::bitset<32> active_decode_targets = ~uint32_t{0};
58   };
59 
60   RTPVideoHeader();
61   RTPVideoHeader(const RTPVideoHeader& other);
62 
63   ~RTPVideoHeader();
64 
65   absl::optional<GenericDescriptorInfo> generic;
66 
67   VideoFrameType frame_type = VideoFrameType::kEmptyFrame;
68   uint16_t width = 0;
69   uint16_t height = 0;
70   VideoRotation rotation = VideoRotation::kVideoRotation_0;
71   VideoContentType content_type = VideoContentType::UNSPECIFIED;
72   bool is_first_packet_in_frame = false;
73   bool is_last_packet_in_frame = false;
74   uint8_t simulcastIdx = 0;
75   VideoCodecType codec = VideoCodecType::kVideoCodecGeneric;
76 
77   PlayoutDelay playout_delay = {-1, -1};
78   VideoSendTiming video_timing;
79   absl::optional<ColorSpace> color_space;
80   RTPVideoTypeHeader video_type_header;
81 };
82 
83 }  // namespace webrtc
84 
85 #endif  // MODULES_RTP_RTCP_SOURCE_RTP_VIDEO_HEADER_H_
86