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