blob: 49e2d2978c8ab4439dc20ad30f9ec6d7385b6489 [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
13#include "absl/types/variant.h"
14#include "api/video/video_content_type.h"
15#include "api/video/video_rotation.h"
16#include "api/video/video_timing.h"
17#include "common_types.h" // NOLINT(build/include)
18#include "modules/video_coding/codecs/h264/include/h264_globals.h"
19#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
20#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
21
22namespace webrtc {
23using RTPVideoTypeHeader =
24 absl::variant<RTPVideoHeaderVP8, RTPVideoHeaderVP9, RTPVideoHeaderH264>;
25
26struct RTPVideoHeader {
27 RTPVideoHeader();
28 RTPVideoHeader(const RTPVideoHeader& other);
29
30 // TODO(philipel): Remove when downstream projects have been updated.
31 RTPVideoHeaderVP8& vp8() {
32 if (!absl::holds_alternative<RTPVideoHeaderVP8>(video_type_header))
33 video_type_header.emplace<RTPVideoHeaderVP8>();
34
35 return absl::get<RTPVideoHeaderVP8>(video_type_header);
36 }
37 // TODO(philipel): Remove when downstream projects have been updated.
38 const RTPVideoHeaderVP8& vp8() const {
39 if (!absl::holds_alternative<RTPVideoHeaderVP8>(video_type_header))
40 video_type_header.emplace<RTPVideoHeaderVP8>();
41
42 return absl::get<RTPVideoHeaderVP8>(video_type_header);
43 }
44 // TODO(philipel): Remove when downstream projects have been updated.
45 RTPVideoHeaderVP9& vp9() {
46 if (!absl::holds_alternative<RTPVideoHeaderVP9>(video_type_header))
47 video_type_header.emplace<RTPVideoHeaderVP9>();
48
49 return absl::get<RTPVideoHeaderVP9>(video_type_header);
50 }
51 // TODO(philipel): Remove when downstream projects have been updated.
52 const RTPVideoHeaderVP9& vp9() const {
53 if (!absl::holds_alternative<RTPVideoHeaderVP9>(video_type_header))
54 video_type_header.emplace<RTPVideoHeaderVP9>();
55
56 return absl::get<RTPVideoHeaderVP9>(video_type_header);
57 }
58 // TODO(philipel): Remove when downstream projects have been updated.
59 RTPVideoHeaderH264& h264() {
60 if (!absl::holds_alternative<RTPVideoHeaderH264>(video_type_header))
61 video_type_header.emplace<RTPVideoHeaderH264>();
62
63 return absl::get<RTPVideoHeaderH264>(video_type_header);
64 }
65 // TODO(philipel): Remove when downstream projects have been updated.
66 const RTPVideoHeaderH264& h264() const {
67 if (!absl::holds_alternative<RTPVideoHeaderH264>(video_type_header))
68 video_type_header.emplace<RTPVideoHeaderH264>();
69
70 return absl::get<RTPVideoHeaderH264>(video_type_header);
71 }
72
73 uint16_t width;
74 uint16_t height;
75 VideoRotation rotation;
76 PlayoutDelay playout_delay;
77 VideoContentType content_type;
78 VideoSendTiming video_timing;
79 bool is_first_packet_in_frame;
80 uint8_t simulcastIdx;
81 VideoCodecType codec;
82 // TODO(philipel): remove mutable when downstream projects have been updated.
83 mutable RTPVideoTypeHeader video_type_header;
84};
85
86} // namespace webrtc
87
88#endif // MODULES_RTP_RTCP_SOURCE_RTP_VIDEO_HEADER_H_