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