blob: 5aa2a3c6048fe3935f0c3a800f12f48bc1eff19a [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 }
philipel1a4746a2018-07-09 15:52:29 +020058
59 uint16_t width;
60 uint16_t height;
61 VideoRotation rotation;
62 PlayoutDelay playout_delay;
63 VideoContentType content_type;
64 VideoSendTiming video_timing;
65 bool is_first_packet_in_frame;
66 uint8_t simulcastIdx;
67 VideoCodecType codec;
68 // TODO(philipel): remove mutable when downstream projects have been updated.
69 mutable RTPVideoTypeHeader video_type_header;
70};
71
72} // namespace webrtc
73
74#endif // MODULES_RTP_RTCP_SOURCE_RTP_VIDEO_HEADER_H_