blob: e59de20903a417ea48071b150aa18ee9d4941986 [file] [log] [blame]
philipel1a4746a2018-07-09 15:52:29 +02001/*
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
philipelf8d81d32018-08-01 17:13:08 +020013#include "absl/container/inlined_vector.h"
philipel1a4746a2018-07-09 15:52:29 +020014#include "absl/types/variant.h"
15#include "api/video/video_content_type.h"
16#include "api/video/video_rotation.h"
17#include "api/video/video_timing.h"
18#include "common_types.h" // NOLINT(build/include)
19#include "modules/video_coding/codecs/h264/include/h264_globals.h"
20#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
21#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
22
23namespace webrtc {
24using RTPVideoTypeHeader =
25 absl::variant<RTPVideoHeaderVP8, RTPVideoHeaderVP9, RTPVideoHeaderH264>;
26
27struct RTPVideoHeader {
28 RTPVideoHeader();
29 RTPVideoHeader(const RTPVideoHeader& other);
30
philipelf8d81d32018-08-01 17:13:08 +020031 ~RTPVideoHeader();
32
philipel1a4746a2018-07-09 15:52:29 +020033 // TODO(philipel): Remove when downstream projects have been updated.
34 RTPVideoHeaderVP8& vp8() {
35 if (!absl::holds_alternative<RTPVideoHeaderVP8>(video_type_header))
36 video_type_header.emplace<RTPVideoHeaderVP8>();
37
38 return absl::get<RTPVideoHeaderVP8>(video_type_header);
39 }
40 // TODO(philipel): Remove when downstream projects have been updated.
41 const RTPVideoHeaderVP8& vp8() const {
42 if (!absl::holds_alternative<RTPVideoHeaderVP8>(video_type_header))
43 video_type_header.emplace<RTPVideoHeaderVP8>();
44
45 return absl::get<RTPVideoHeaderVP8>(video_type_header);
46 }
47 // TODO(philipel): Remove when downstream projects have been updated.
48 RTPVideoHeaderVP9& vp9() {
49 if (!absl::holds_alternative<RTPVideoHeaderVP9>(video_type_header))
50 video_type_header.emplace<RTPVideoHeaderVP9>();
51
52 return absl::get<RTPVideoHeaderVP9>(video_type_header);
53 }
54 // TODO(philipel): Remove when downstream projects have been updated.
55 const RTPVideoHeaderVP9& vp9() const {
56 if (!absl::holds_alternative<RTPVideoHeaderVP9>(video_type_header))
57 video_type_header.emplace<RTPVideoHeaderVP9>();
58
59 return absl::get<RTPVideoHeaderVP9>(video_type_header);
60 }
JT Teh5daeff92018-07-16 17:17:17 +000061 // TODO(philipel): Remove when downstream projects have been updated.
62 RTPVideoHeaderH264& h264() {
63 if (!absl::holds_alternative<RTPVideoHeaderH264>(video_type_header))
64 video_type_header.emplace<RTPVideoHeaderH264>();
65
66 return absl::get<RTPVideoHeaderH264>(video_type_header);
67 }
68 // TODO(philipel): Remove when downstream projects have been updated.
69 const RTPVideoHeaderH264& h264() const {
70 if (!absl::holds_alternative<RTPVideoHeaderH264>(video_type_header))
71 video_type_header.emplace<RTPVideoHeaderH264>();
72
73 return absl::get<RTPVideoHeaderH264>(video_type_header);
74 }
philipel1a4746a2018-07-09 15:52:29 +020075
philipelf8d81d32018-08-01 17:13:08 +020076 // Information for generic codec descriptor.
77 int64_t frame_id = 0;
78 int spatial_index = 0;
79 int temporal_index = 0;
80 absl::InlinedVector<int64_t, 5> dependencies;
81 absl::InlinedVector<int, 5> higher_spatial_layers;
82
83 uint16_t width = 0;
84 uint16_t height = 0;
85 VideoRotation rotation = VideoRotation::kVideoRotation_0;
86 VideoContentType content_type = VideoContentType::UNSPECIFIED;
87 bool is_first_packet_in_frame = false;
88 uint8_t simulcastIdx = 0;
89 VideoCodecType codec = VideoCodecType::kVideoCodecUnknown;
90
philipel1a4746a2018-07-09 15:52:29 +020091 PlayoutDelay playout_delay;
philipel1a4746a2018-07-09 15:52:29 +020092 VideoSendTiming video_timing;
philipel1a4746a2018-07-09 15:52:29 +020093 // TODO(philipel): remove mutable when downstream projects have been updated.
94 mutable RTPVideoTypeHeader video_type_header;
95};
96
97} // namespace webrtc
98
99#endif // MODULES_RTP_RTCP_SOURCE_RTP_VIDEO_HEADER_H_