danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 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 | */ |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 10 | #ifndef MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |
| 11 | #define MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 12 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 13 | #include <stddef.h> |
pbos | c7c26a0 | 2017-01-02 08:42:32 -0800 | [diff] [blame] | 14 | #include <stdint.h> |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 15 | #include <string> |
pbos | c7c26a0 | 2017-01-02 08:42:32 -0800 | [diff] [blame] | 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "api/array_view.h" |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 18 | #include "api/rtp_headers.h" |
Johannes Kron | 09d6588 | 2018-11-27 14:36:41 +0100 | [diff] [blame] | 19 | #include "api/video/color_space.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "api/video/video_content_type.h" |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 21 | #include "api/video/video_frame_marking.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "api/video/video_rotation.h" |
| 23 | #include "api/video/video_timing.h" |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 24 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 26 | |
| 27 | namespace webrtc { |
| 28 | |
| 29 | class AbsoluteSendTime { |
| 30 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 31 | using value_type = uint32_t; |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 32 | static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime; |
| 33 | static constexpr uint8_t kValueSizeBytes = 3; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 34 | static constexpr const char kUri[] = |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 35 | "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 36 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 37 | static bool Parse(rtc::ArrayView<const uint8_t> data, uint32_t* time_24bits); |
Danil Chapovalov | f3ba648 | 2017-06-12 15:43:55 +0200 | [diff] [blame] | 38 | static size_t ValueSize(uint32_t time_24bits) { return kValueSizeBytes; } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 39 | static bool Write(rtc::ArrayView<uint8_t> data, uint32_t time_24bits); |
danilchap | a897f26 | 2016-08-26 05:42:41 -0700 | [diff] [blame] | 40 | |
| 41 | static constexpr uint32_t MsTo24Bits(int64_t time_ms) { |
| 42 | return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF; |
| 43 | } |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | class AudioLevel { |
| 47 | public: |
| 48 | static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel; |
| 49 | static constexpr uint8_t kValueSizeBytes = 1; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 50 | static constexpr const char kUri[] = |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 51 | "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 52 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 53 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 54 | bool* voice_activity, |
| 55 | uint8_t* audio_level); |
erikvarga | e6b1619 | 2017-05-11 02:36:32 -0700 | [diff] [blame] | 56 | static size_t ValueSize(bool voice_activity, uint8_t audio_level) { |
| 57 | return kValueSizeBytes; |
| 58 | } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 59 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 60 | bool voice_activity, |
| 61 | uint8_t audio_level); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | class TransmissionOffset { |
| 65 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 66 | using value_type = int32_t; |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 67 | static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset; |
| 68 | static constexpr uint8_t kValueSizeBytes = 3; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 69 | static constexpr const char kUri[] = "urn:ietf:params:rtp-hdrext:toffset"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 70 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 71 | static bool Parse(rtc::ArrayView<const uint8_t> data, int32_t* rtp_time); |
erikvarga | e6b1619 | 2017-05-11 02:36:32 -0700 | [diff] [blame] | 72 | static size_t ValueSize(int32_t rtp_time) { return kValueSizeBytes; } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 73 | static bool Write(rtc::ArrayView<uint8_t> data, int32_t rtp_time); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | class TransportSequenceNumber { |
| 77 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 78 | using value_type = uint16_t; |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 79 | static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber; |
| 80 | static constexpr uint8_t kValueSizeBytes = 2; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 81 | static constexpr const char kUri[] = |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 82 | "http://www.ietf.org/id/" |
| 83 | "draft-holmer-rmcat-transport-wide-cc-extensions-01"; |
Johannes Kron | 54047be | 2019-02-21 14:09:20 +0000 | [diff] [blame^] | 84 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 85 | uint16_t* transport_sequence_number); |
| 86 | static size_t ValueSize(uint16_t /*transport_sequence_number*/) { |
| 87 | return kValueSizeBytes; |
| 88 | } |
| 89 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 90 | uint16_t transport_sequence_number); |
| 91 | }; |
| 92 | |
| 93 | class TransportSequenceNumberV2 { |
| 94 | public: |
| 95 | static constexpr RTPExtensionType kId = |
| 96 | kRtpExtensionTransportSequenceNumber02; |
| 97 | static constexpr uint8_t kValueSizeBytesWithFeedbackRequest = 4; |
| 98 | static constexpr const char kUri[] = |
| 99 | "http://www.ietf.org/id/" |
| 100 | "draft-holmer-rmcat-transport-wide-cc-extensions-02"; |
| 101 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 102 | uint16_t* transport_sequence_number, |
| 103 | absl::optional<FeedbackRequest>* feedback_request); |
| 104 | static size_t ValueSize( |
| 105 | uint16_t /*transport_sequence_number*/, |
| 106 | const absl::optional<FeedbackRequest>& feedback_request) { |
| 107 | return feedback_request ? kValueSizeBytesWithFeedbackRequest |
| 108 | : TransportSequenceNumber::kValueSizeBytes; |
| 109 | } |
| 110 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 111 | uint16_t transport_sequence_number, |
| 112 | const absl::optional<FeedbackRequest>& feedback_request); |
| 113 | |
| 114 | private: |
| 115 | static constexpr uint16_t kIncludeTimestampsBit = 1 << 15; |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | class VideoOrientation { |
| 119 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 120 | using value_type = VideoRotation; |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 121 | static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation; |
| 122 | static constexpr uint8_t kValueSizeBytes = 1; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 123 | static constexpr const char kUri[] = "urn:3gpp:video-orientation"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 124 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 125 | static bool Parse(rtc::ArrayView<const uint8_t> data, VideoRotation* value); |
erikvarga | e6b1619 | 2017-05-11 02:36:32 -0700 | [diff] [blame] | 126 | static size_t ValueSize(VideoRotation) { return kValueSizeBytes; } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 127 | static bool Write(rtc::ArrayView<uint8_t> data, VideoRotation value); |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 128 | static bool Parse(rtc::ArrayView<const uint8_t> data, uint8_t* value); |
erikvarga | e6b1619 | 2017-05-11 02:36:32 -0700 | [diff] [blame] | 129 | static size_t ValueSize(uint8_t value) { return kValueSizeBytes; } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 130 | static bool Write(rtc::ArrayView<uint8_t> data, uint8_t value); |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
Danil Chapovalov | 08b0351 | 2016-09-07 15:08:13 +0200 | [diff] [blame] | 133 | class PlayoutDelayLimits { |
| 134 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 135 | using value_type = PlayoutDelay; |
Danil Chapovalov | 08b0351 | 2016-09-07 15:08:13 +0200 | [diff] [blame] | 136 | static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay; |
| 137 | static constexpr uint8_t kValueSizeBytes = 3; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 138 | static constexpr const char kUri[] = |
danilchap | 6ba58d6 | 2016-11-09 05:46:39 -0800 | [diff] [blame] | 139 | "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
danilchap | e2a0177 | 2016-10-28 07:08:58 -0700 | [diff] [blame] | 140 | |
Danil Chapovalov | 08b0351 | 2016-09-07 15:08:13 +0200 | [diff] [blame] | 141 | // Playout delay in milliseconds. A playout delay limit (min or max) |
| 142 | // has 12 bits allocated. This allows a range of 0-4095 values which |
| 143 | // translates to a range of 0-40950 in milliseconds. |
| 144 | static constexpr int kGranularityMs = 10; |
| 145 | // Maximum playout delay value in milliseconds. |
| 146 | static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950. |
| 147 | |
danilchap | 978504e | 2017-04-06 01:03:53 -0700 | [diff] [blame] | 148 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 149 | PlayoutDelay* playout_delay); |
erikvarga | e6b1619 | 2017-05-11 02:36:32 -0700 | [diff] [blame] | 150 | static size_t ValueSize(const PlayoutDelay&) { |
| 151 | return kValueSizeBytes; |
| 152 | } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 153 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 154 | const PlayoutDelay& playout_delay); |
Danil Chapovalov | 08b0351 | 2016-09-07 15:08:13 +0200 | [diff] [blame] | 155 | }; |
| 156 | |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 157 | class VideoContentTypeExtension { |
| 158 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 159 | using value_type = VideoContentType; |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 160 | static constexpr RTPExtensionType kId = kRtpExtensionVideoContentType; |
| 161 | static constexpr uint8_t kValueSizeBytes = 1; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 162 | static constexpr const char kUri[] = |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 163 | "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"; |
| 164 | |
| 165 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 166 | VideoContentType* content_type); |
erikvarga | e6b1619 | 2017-05-11 02:36:32 -0700 | [diff] [blame] | 167 | static size_t ValueSize(VideoContentType) { |
| 168 | return kValueSizeBytes; |
| 169 | } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 170 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 171 | VideoContentType content_type); |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 172 | }; |
| 173 | |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 174 | class VideoTimingExtension { |
| 175 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 176 | using value_type = VideoSendTiming; |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 177 | static constexpr RTPExtensionType kId = kRtpExtensionVideoTiming; |
sprang | ba050a6 | 2017-08-18 02:51:12 -0700 | [diff] [blame] | 178 | static constexpr uint8_t kValueSizeBytes = 13; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 179 | static constexpr const char kUri[] = |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 180 | "http://www.webrtc.org/experiments/rtp-hdrext/video-timing"; |
| 181 | |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 182 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 183 | VideoSendTiming* timing); |
| 184 | static size_t ValueSize(const VideoSendTiming&) { return kValueSizeBytes; } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 185 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 186 | const VideoSendTiming& timing); |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 187 | |
| 188 | static size_t ValueSize(uint16_t time_delta_ms, uint8_t idx) { |
| 189 | return kValueSizeBytes; |
| 190 | } |
| 191 | // Writes only single time delta to position idx. |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 192 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 193 | uint16_t time_delta_ms, |
| 194 | uint8_t idx); |
ilnik | 04f4d12 | 2017-06-19 07:18:55 -0700 | [diff] [blame] | 195 | }; |
| 196 | |
Johnny Lee | e0c8b23 | 2018-09-11 16:50:49 -0400 | [diff] [blame] | 197 | class FrameMarkingExtension { |
| 198 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 199 | using value_type = FrameMarking; |
Johnny Lee | e0c8b23 | 2018-09-11 16:50:49 -0400 | [diff] [blame] | 200 | static constexpr RTPExtensionType kId = kRtpExtensionFrameMarking; |
| 201 | static constexpr const char kUri[] = |
| 202 | "http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07"; |
| 203 | |
| 204 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 205 | FrameMarking* frame_marking); |
| 206 | static size_t ValueSize(const FrameMarking& frame_marking); |
| 207 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 208 | const FrameMarking& frame_marking); |
| 209 | |
| 210 | private: |
| 211 | static bool IsScalable(uint8_t temporal_id, uint8_t layer_id); |
| 212 | }; |
| 213 | |
Johannes Kron | 09d6588 | 2018-11-27 14:36:41 +0100 | [diff] [blame] | 214 | class ColorSpaceExtension { |
Johannes Kron | ad1d9f0 | 2018-11-09 11:12:36 +0100 | [diff] [blame] | 215 | public: |
Johannes Kron | 09d6588 | 2018-11-27 14:36:41 +0100 | [diff] [blame] | 216 | using value_type = ColorSpace; |
| 217 | static constexpr RTPExtensionType kId = kRtpExtensionColorSpace; |
Johannes Kron | c13f4be | 2018-12-12 09:52:53 +0100 | [diff] [blame] | 218 | static constexpr uint8_t kValueSizeBytes = 28; |
Johannes Kron | 09d6588 | 2018-11-27 14:36:41 +0100 | [diff] [blame] | 219 | static constexpr uint8_t kValueSizeBytesWithoutHdrMetadata = 4; |
Johannes Kron | d0b69a8 | 2018-12-03 14:18:53 +0100 | [diff] [blame] | 220 | static constexpr const char kUri[] = |
| 221 | "http://www.webrtc.org/experiments/rtp-hdrext/color-space"; |
Johannes Kron | ad1d9f0 | 2018-11-09 11:12:36 +0100 | [diff] [blame] | 222 | |
| 223 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
Johannes Kron | 09d6588 | 2018-11-27 14:36:41 +0100 | [diff] [blame] | 224 | ColorSpace* color_space); |
| 225 | static size_t ValueSize(const ColorSpace& color_space) { |
| 226 | return color_space.hdr_metadata() ? kValueSizeBytes |
| 227 | : kValueSizeBytesWithoutHdrMetadata; |
| 228 | } |
Johannes Kron | ad1d9f0 | 2018-11-09 11:12:36 +0100 | [diff] [blame] | 229 | static bool Write(rtc::ArrayView<uint8_t> data, |
Johannes Kron | 09d6588 | 2018-11-27 14:36:41 +0100 | [diff] [blame] | 230 | const ColorSpace& color_space); |
Johannes Kron | ad1d9f0 | 2018-11-09 11:12:36 +0100 | [diff] [blame] | 231 | |
| 232 | private: |
Johannes Kron | c13f4be | 2018-12-12 09:52:53 +0100 | [diff] [blame] | 233 | static constexpr int kChromaticityDenominator = 50000; // 0.00002 resolution. |
| 234 | static constexpr int kLuminanceMaxDenominator = 1; // 1 resolution. |
Johannes Kron | ad1d9f0 | 2018-11-09 11:12:36 +0100 | [diff] [blame] | 235 | static constexpr int kLuminanceMinDenominator = 10000; // 0.0001 resolution. |
Johannes Kron | c13f4be | 2018-12-12 09:52:53 +0100 | [diff] [blame] | 236 | |
| 237 | static uint8_t CombineRangeAndChromaSiting( |
| 238 | ColorSpace::RangeID range, |
| 239 | ColorSpace::ChromaSiting chroma_siting_horizontal, |
| 240 | ColorSpace::ChromaSiting chroma_siting_vertical); |
| 241 | static size_t ParseHdrMetadata(rtc::ArrayView<const uint8_t> data, |
| 242 | HdrMetadata* hdr_metadata); |
Johannes Kron | ad1d9f0 | 2018-11-09 11:12:36 +0100 | [diff] [blame] | 243 | static size_t ParseChromaticity(const uint8_t* data, |
| 244 | HdrMasteringMetadata::Chromaticity* p); |
| 245 | static size_t ParseLuminance(const uint8_t* data, float* f, int denominator); |
Johannes Kron | c13f4be | 2018-12-12 09:52:53 +0100 | [diff] [blame] | 246 | static size_t WriteHdrMetadata(rtc::ArrayView<uint8_t> data, |
| 247 | const HdrMetadata& hdr_metadata); |
Johannes Kron | ad1d9f0 | 2018-11-09 11:12:36 +0100 | [diff] [blame] | 248 | static size_t WriteChromaticity(uint8_t* data, |
| 249 | const HdrMasteringMetadata::Chromaticity& p); |
| 250 | static size_t WriteLuminance(uint8_t* data, float f, int denominator); |
| 251 | }; |
| 252 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 253 | // Base extension class for RTP header extensions which are strings. |
| 254 | // Subclasses must defined kId and kUri static constexpr members. |
| 255 | class BaseRtpStringExtension { |
| 256 | public: |
Danil Chapovalov | c5dd300 | 2018-11-08 15:12:45 +0100 | [diff] [blame] | 257 | using value_type = std::string; |
Steve Anton | f0482ea | 2018-04-09 13:33:52 -0700 | [diff] [blame] | 258 | // String RTP header extensions are limited to 16 bytes because it is the |
| 259 | // maximum length that can be encoded with one-byte header extensions. |
| 260 | static constexpr uint8_t kMaxValueSizeBytes = 16; |
| 261 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 262 | static bool Parse(rtc::ArrayView<const uint8_t> data, |
| 263 | StringRtpHeaderExtension* str); |
| 264 | static size_t ValueSize(const StringRtpHeaderExtension& str) { |
| 265 | return str.size(); |
| 266 | } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 267 | static bool Write(rtc::ArrayView<uint8_t> data, |
| 268 | const StringRtpHeaderExtension& str); |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 269 | |
| 270 | static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* str); |
| 271 | static size_t ValueSize(const std::string& str) { return str.size(); } |
Danil Chapovalov | 9bf3158 | 2018-06-18 13:48:20 +0200 | [diff] [blame] | 272 | static bool Write(rtc::ArrayView<uint8_t> data, const std::string& str); |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 273 | }; |
| 274 | |
| 275 | class RtpStreamId : public BaseRtpStringExtension { |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 276 | public: |
| 277 | static constexpr RTPExtensionType kId = kRtpExtensionRtpStreamId; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 278 | static constexpr const char kUri[] = |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 279 | "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"; |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 280 | }; |
| 281 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 282 | class RepairedRtpStreamId : public BaseRtpStringExtension { |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 283 | public: |
| 284 | static constexpr RTPExtensionType kId = kRtpExtensionRepairedRtpStreamId; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 285 | static constexpr const char kUri[] = |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 286 | "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"; |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 287 | }; |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 288 | |
Steve Anton | a3251dd | 2017-07-21 09:58:31 -0700 | [diff] [blame] | 289 | class RtpMid : public BaseRtpStringExtension { |
| 290 | public: |
| 291 | static constexpr RTPExtensionType kId = kRtpExtensionMid; |
Steve Anton | d14d9f7 | 2017-07-21 10:59:39 -0700 | [diff] [blame] | 292 | static constexpr const char kUri[] = "urn:ietf:params:rtp-hdrext:sdes:mid"; |
danilchap | ef8d773 | 2017-04-19 02:59:48 -0700 | [diff] [blame] | 293 | }; |
| 294 | |
danilchap | 1edb7ab | 2016-04-20 05:25:10 -0700 | [diff] [blame] | 295 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 296 | #endif // MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |