OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 30 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
32 // | ID | len=2 | absolute send time | | 32 // | ID | len=2 | absolute send time | |
33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
34 const char* AbsoluteSendTime::kName = | 34 const char* AbsoluteSendTime::kName = |
35 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; | 35 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; |
36 bool AbsoluteSendTime::IsSupportedFor(MediaType type) { | 36 bool AbsoluteSendTime::IsSupportedFor(MediaType type) { |
37 return true; | 37 return true; |
38 } | 38 } |
39 | 39 |
40 bool AbsoluteSendTime::Parse(const uint8_t* data, uint32_t* time_24bits) { | 40 bool AbsoluteSendTime::Parse(const uint8_t* data, uint32_t* value) { |
41 *time_24bits = ByteReader<uint32_t, 3>::ReadBigEndian(data); | 41 *value = ByteReader<uint32_t, 3>::ReadBigEndian(data); |
42 return true; | 42 return true; |
43 } | 43 } |
44 | 44 |
45 bool AbsoluteSendTime::Write(uint8_t* data, int64_t time_ms) { | 45 bool AbsoluteSendTime::Write(uint8_t* data, int64_t time_ms) { |
46 ByteWriter<uint32_t, 3>::WriteBigEndian(data, MsTo24Bits(time_ms)); | 46 const uint32_t kAbsSendTimeFraction = 18; |
| 47 uint32_t time_24_bits = |
| 48 static_cast<uint32_t>(((time_ms << kAbsSendTimeFraction) + 500) / 1000) & |
| 49 0x00FFFFFF; |
| 50 |
| 51 ByteWriter<uint32_t, 3>::WriteBigEndian(data, time_24_bits); |
47 return true; | 52 return true; |
48 } | 53 } |
49 | 54 |
50 // An RTP Header Extension for Client-to-Mixer Audio Level Indication | 55 // An RTP Header Extension for Client-to-Mixer Audio Level Indication |
51 // | 56 // |
52 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ | 57 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ |
53 // | 58 // |
54 // The form of the audio level extension block: | 59 // The form of the audio level extension block: |
55 // | 60 // |
56 // 0 1 | 61 // 0 1 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 193 |
189 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) { | 194 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) { |
190 *value = data[0]; | 195 *value = data[0]; |
191 return true; | 196 return true; |
192 } | 197 } |
193 | 198 |
194 bool VideoOrientation::Write(uint8_t* data, uint8_t value) { | 199 bool VideoOrientation::Write(uint8_t* data, uint8_t value) { |
195 data[0] = value; | 200 data[0] = value; |
196 return true; | 201 return true; |
197 } | 202 } |
| 203 |
| 204 // 0 1 2 3 |
| 205 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 206 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 207 // | ID | len=2 | MIN delay | MAX delay | |
| 208 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 209 constexpr RTPExtensionType PlayoutDelayLimits::kId; |
| 210 constexpr uint8_t PlayoutDelayLimits::kValueSizeBytes; |
| 211 const char* PlayoutDelayLimits::kName = |
| 212 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
| 213 bool PlayoutDelayLimits::IsSupportedFor(MediaType type) { |
| 214 switch (type) { |
| 215 case MediaType::ANY: |
| 216 case MediaType::VIDEO: |
| 217 return true; |
| 218 case MediaType::AUDIO: |
| 219 case MediaType::DATA: |
| 220 return false; |
| 221 } |
| 222 RTC_NOTREACHED(); |
| 223 return false; |
| 224 } |
| 225 |
| 226 bool PlayoutDelayLimits::Parse(const uint8_t* data, |
| 227 PlayoutDelay* playout_delay) { |
| 228 RTC_DCHECK(playout_delay); |
| 229 uint32_t raw = ByteReader<uint32_t, 3>::ReadBigEndian(data); |
| 230 uint16_t min_raw = (raw >> 12); |
| 231 uint16_t max_raw = (raw & 0xfff); |
| 232 if (min_raw > max_raw) |
| 233 return false; |
| 234 playout_delay->min_ms = min_raw * kGranularityMs; |
| 235 playout_delay->max_ms = max_raw * kGranularityMs; |
| 236 return true; |
| 237 } |
| 238 |
| 239 bool PlayoutDelayLimits::Write(uint8_t* data, |
| 240 const PlayoutDelay& playout_delay) { |
| 241 RTC_DCHECK_LE(0, playout_delay.min_ms); |
| 242 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms); |
| 243 RTC_DCHECK_LE(playout_delay.max_ms, kMaxMs); |
| 244 // Convert MS to value to be sent on extension header. |
| 245 uint32_t min_delay = playout_delay.min_ms / kGranularityMs; |
| 246 uint32_t max_delay = playout_delay.max_ms / kGranularityMs; |
| 247 ByteWriter<uint32_t, 3>::WriteBigEndian(data, (min_delay << 12) | max_delay); |
| 248 return true; |
| 249 } |
| 250 |
198 } // namespace webrtc | 251 } // namespace webrtc |
OLD | NEW |