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