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/rtp_headers.h" 20 #include "api/transport/rtp/dependency_descriptor.h" 21 #include "api/video/color_space.h" 22 #include "api/video/video_codec_type.h" 23 #include "api/video/video_content_type.h" 24 #include "api/video/video_frame_metadata.h" 25 #include "api/video/video_frame_type.h" 26 #include "api/video/video_rotation.h" 27 #include "api/video/video_timing.h" 28 #include "modules/video_coding/codecs/h264/include/h264_globals.h" 29 #include "modules/video_coding/codecs/vp8/include/vp8_globals.h" 30 #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" 31 32 namespace webrtc { 33 // Details passed in the rtp payload for legacy generic rtp packetizer. 34 // TODO(bugs.webrtc.org/9772): Deprecate in favor of passing generic video 35 // details in an rtp header extension. 36 struct RTPVideoHeaderLegacyGeneric { 37 uint16_t picture_id; 38 }; 39 40 using RTPVideoTypeHeader = absl::variant<absl::monostate, 41 RTPVideoHeaderVP8, 42 RTPVideoHeaderVP9, 43 RTPVideoHeaderH264, 44 RTPVideoHeaderLegacyGeneric>; 45 46 struct RTPVideoHeader { 47 struct GenericDescriptorInfo { 48 GenericDescriptorInfo(); 49 GenericDescriptorInfo(const GenericDescriptorInfo& other); 50 ~GenericDescriptorInfo(); 51 52 int64_t frame_id = 0; 53 int spatial_index = 0; 54 int temporal_index = 0; 55 absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications; 56 absl::InlinedVector<int64_t, 5> dependencies; 57 absl::InlinedVector<int, 4> chain_diffs; 58 std::bitset<32> active_decode_targets = ~uint32_t{0}; 59 }; 60 61 RTPVideoHeader(); 62 RTPVideoHeader(const RTPVideoHeader& other); 63 64 ~RTPVideoHeader(); 65 66 // The subset of RTPVideoHeader that is exposed in the Insertable Streams API. 67 VideoFrameMetadata GetAsMetadata() const; 68 69 absl::optional<GenericDescriptorInfo> generic; 70 71 VideoFrameType frame_type = VideoFrameType::kEmptyFrame; 72 uint16_t width = 0; 73 uint16_t height = 0; 74 VideoRotation rotation = VideoRotation::kVideoRotation_0; 75 VideoContentType content_type = VideoContentType::UNSPECIFIED; 76 bool is_first_packet_in_frame = false; 77 bool is_last_packet_in_frame = false; 78 bool is_last_frame_in_picture = true; 79 uint8_t simulcastIdx = 0; 80 VideoCodecType codec = VideoCodecType::kVideoCodecGeneric; 81 82 VideoPlayoutDelay playout_delay; 83 VideoSendTiming video_timing; 84 absl::optional<ColorSpace> color_space; 85 // This field is meant for media quality testing purpose only. When enabled it 86 // carries the webrtc::VideoFrame id field from the sender to the receiver. 87 absl::optional<uint16_t> video_frame_tracking_id; 88 RTPVideoTypeHeader video_type_header; 89 90 // When provided, is sent as is as an RTP header extension according to 91 // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time. 92 // Otherwise, it is derived from other relevant information. 93 absl::optional<AbsoluteCaptureTime> absolute_capture_time; 94 }; 95 96 } // namespace webrtc 97 98 #endif // MODULES_RTP_RTCP_SOURCE_RTP_VIDEO_HEADER_H_ 99