| 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 15 matching lines...) Expand all Loading... |
| 26 // | 26 // |
| 27 // The form of the absolute send time extension block: | 27 // The form of the absolute send time extension block: |
| 28 // | 28 // |
| 29 // 0 1 2 3 | 29 // 0 1 2 3 |
| 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 constexpr RTPExtensionType AbsoluteSendTime::kId; | 34 constexpr RTPExtensionType AbsoluteSendTime::kId; |
| 35 constexpr uint8_t AbsoluteSendTime::kValueSizeBytes; | 35 constexpr uint8_t AbsoluteSendTime::kValueSizeBytes; |
| 36 const char* const AbsoluteSendTime::kUri = | 36 constexpr const char* AbsoluteSendTime::kUri; |
| 37 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; | |
| 38 | 37 |
| 39 bool AbsoluteSendTime::Parse(const uint8_t* data, uint32_t* time_24bits) { | 38 bool AbsoluteSendTime::Parse(const uint8_t* data, uint32_t* time_24bits) { |
| 40 *time_24bits = ByteReader<uint32_t, 3>::ReadBigEndian(data); | 39 *time_24bits = ByteReader<uint32_t, 3>::ReadBigEndian(data); |
| 41 return true; | 40 return true; |
| 42 } | 41 } |
| 43 | 42 |
| 44 bool AbsoluteSendTime::Write(uint8_t* data, int64_t time_ms) { | 43 bool AbsoluteSendTime::Write(uint8_t* data, int64_t time_ms) { |
| 45 ByteWriter<uint32_t, 3>::WriteBigEndian(data, MsTo24Bits(time_ms)); | 44 ByteWriter<uint32_t, 3>::WriteBigEndian(data, MsTo24Bits(time_ms)); |
| 46 return true; | 45 return true; |
| 47 } | 46 } |
| 48 | 47 |
| 49 // An RTP Header Extension for Client-to-Mixer Audio Level Indication | 48 // An RTP Header Extension for Client-to-Mixer Audio Level Indication |
| 50 // | 49 // |
| 51 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ | 50 // https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/ |
| 52 // | 51 // |
| 53 // The form of the audio level extension block: | 52 // The form of the audio level extension block: |
| 54 // | 53 // |
| 55 // 0 1 | 54 // 0 1 |
| 56 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | 55 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
| 57 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 56 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 58 // | ID | len=0 |V| level | | 57 // | ID | len=0 |V| level | |
| 59 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 58 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 60 // | 59 // |
| 61 constexpr RTPExtensionType AudioLevel::kId; | 60 constexpr RTPExtensionType AudioLevel::kId; |
| 62 constexpr uint8_t AudioLevel::kValueSizeBytes; | 61 constexpr uint8_t AudioLevel::kValueSizeBytes; |
| 63 const char* const AudioLevel::kUri = | 62 constexpr const char* AudioLevel::kUri; |
| 64 "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; | |
| 65 | 63 |
| 66 bool AudioLevel::Parse(const uint8_t* data, | 64 bool AudioLevel::Parse(const uint8_t* data, |
| 67 bool* voice_activity, | 65 bool* voice_activity, |
| 68 uint8_t* audio_level) { | 66 uint8_t* audio_level) { |
| 69 *voice_activity = (data[0] & 0x80) != 0; | 67 *voice_activity = (data[0] & 0x80) != 0; |
| 70 *audio_level = data[0] & 0x7F; | 68 *audio_level = data[0] & 0x7F; |
| 71 return true; | 69 return true; |
| 72 } | 70 } |
| 73 | 71 |
| 74 bool AudioLevel::Write(uint8_t* data, | 72 bool AudioLevel::Write(uint8_t* data, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 90 // | 88 // |
| 91 // The form of the transmission offset extension block: | 89 // The form of the transmission offset extension block: |
| 92 // | 90 // |
| 93 // 0 1 2 3 | 91 // 0 1 2 3 |
| 94 // 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 | 92 // 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 |
| 95 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 93 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 96 // | ID | len=2 | transmission offset | | 94 // | ID | len=2 | transmission offset | |
| 97 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 95 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 98 constexpr RTPExtensionType TransmissionOffset::kId; | 96 constexpr RTPExtensionType TransmissionOffset::kId; |
| 99 constexpr uint8_t TransmissionOffset::kValueSizeBytes; | 97 constexpr uint8_t TransmissionOffset::kValueSizeBytes; |
| 100 const char* const TransmissionOffset::kUri = | 98 constexpr const char* TransmissionOffset::kUri; |
| 101 "urn:ietf:params:rtp-hdrext:toffset"; | |
| 102 | 99 |
| 103 bool TransmissionOffset::Parse(const uint8_t* data, int32_t* rtp_time) { | 100 bool TransmissionOffset::Parse(const uint8_t* data, int32_t* rtp_time) { |
| 104 *rtp_time = ByteReader<int32_t, 3>::ReadBigEndian(data); | 101 *rtp_time = ByteReader<int32_t, 3>::ReadBigEndian(data); |
| 105 return true; | 102 return true; |
| 106 } | 103 } |
| 107 | 104 |
| 108 bool TransmissionOffset::Write(uint8_t* data, int32_t rtp_time) { | 105 bool TransmissionOffset::Write(uint8_t* data, int32_t rtp_time) { |
| 109 RTC_DCHECK_LE(rtp_time, 0x00ffffff); | 106 RTC_DCHECK_LE(rtp_time, 0x00ffffff); |
| 110 ByteWriter<int32_t, 3>::WriteBigEndian(data, rtp_time); | 107 ByteWriter<int32_t, 3>::WriteBigEndian(data, rtp_time); |
| 111 return true; | 108 return true; |
| 112 } | 109 } |
| 113 | 110 |
| 114 // 0 1 2 | 111 // 0 1 2 |
| 115 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 | 112 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 |
| 116 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 113 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 117 // | ID | L=1 |transport wide sequence number | | 114 // | ID | L=1 |transport wide sequence number | |
| 118 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 115 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 119 constexpr RTPExtensionType TransportSequenceNumber::kId; | 116 constexpr RTPExtensionType TransportSequenceNumber::kId; |
| 120 constexpr uint8_t TransportSequenceNumber::kValueSizeBytes; | 117 constexpr uint8_t TransportSequenceNumber::kValueSizeBytes; |
| 121 const char* const TransportSequenceNumber::kUri = | 118 constexpr const char* TransportSequenceNumber::kUri; |
| 122 "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions"; | |
| 123 | 119 |
| 124 bool TransportSequenceNumber::Parse(const uint8_t* data, uint16_t* value) { | 120 bool TransportSequenceNumber::Parse(const uint8_t* data, uint16_t* value) { |
| 125 *value = ByteReader<uint16_t>::ReadBigEndian(data); | 121 *value = ByteReader<uint16_t>::ReadBigEndian(data); |
| 126 return true; | 122 return true; |
| 127 } | 123 } |
| 128 | 124 |
| 129 bool TransportSequenceNumber::Write(uint8_t* data, uint16_t value) { | 125 bool TransportSequenceNumber::Write(uint8_t* data, uint16_t value) { |
| 130 ByteWriter<uint16_t>::WriteBigEndian(data, value); | 126 ByteWriter<uint16_t>::WriteBigEndian(data, value); |
| 131 return true; | 127 return true; |
| 132 } | 128 } |
| 133 | 129 |
| 134 // Coordination of Video Orientation in RTP streams. | 130 // Coordination of Video Orientation in RTP streams. |
| 135 // | 131 // |
| 136 // Coordination of Video Orientation consists in signaling of the current | 132 // Coordination of Video Orientation consists in signaling of the current |
| 137 // orientation of the image captured on the sender side to the receiver for | 133 // orientation of the image captured on the sender side to the receiver for |
| 138 // appropriate rendering and displaying. | 134 // appropriate rendering and displaying. |
| 139 // | 135 // |
| 140 // 0 1 | 136 // 0 1 |
| 141 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | 137 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
| 142 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 138 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 143 // | ID | len=0 |0 0 0 0 C F R R| | 139 // | ID | len=0 |0 0 0 0 C F R R| |
| 144 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 140 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 145 constexpr RTPExtensionType VideoOrientation::kId; | 141 constexpr RTPExtensionType VideoOrientation::kId; |
| 146 constexpr uint8_t VideoOrientation::kValueSizeBytes; | 142 constexpr uint8_t VideoOrientation::kValueSizeBytes; |
| 147 const char* const VideoOrientation::kUri = "urn:3gpp:video-orientation"; | 143 constexpr const char* VideoOrientation::kUri; |
| 148 | 144 |
| 149 bool VideoOrientation::Parse(const uint8_t* data, VideoRotation* rotation) { | 145 bool VideoOrientation::Parse(const uint8_t* data, VideoRotation* rotation) { |
| 150 *rotation = ConvertCVOByteToVideoRotation(data[0]); | 146 *rotation = ConvertCVOByteToVideoRotation(data[0]); |
| 151 return true; | 147 return true; |
| 152 } | 148 } |
| 153 | 149 |
| 154 bool VideoOrientation::Write(uint8_t* data, VideoRotation rotation) { | 150 bool VideoOrientation::Write(uint8_t* data, VideoRotation rotation) { |
| 155 data[0] = ConvertVideoRotationToCVOByte(rotation); | 151 data[0] = ConvertVideoRotationToCVOByte(rotation); |
| 156 return true; | 152 return true; |
| 157 } | 153 } |
| 158 | 154 |
| 159 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) { | 155 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) { |
| 160 *value = data[0]; | 156 *value = data[0]; |
| 161 return true; | 157 return true; |
| 162 } | 158 } |
| 163 | 159 |
| 164 bool VideoOrientation::Write(uint8_t* data, uint8_t value) { | 160 bool VideoOrientation::Write(uint8_t* data, uint8_t value) { |
| 165 data[0] = value; | 161 data[0] = value; |
| 166 return true; | 162 return true; |
| 167 } | 163 } |
| 168 | 164 |
| 169 // 0 1 2 3 | 165 // 0 1 2 3 |
| 170 // 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 | 166 // 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 |
| 171 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 167 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 172 // | ID | len=2 | MIN delay | MAX delay | | 168 // | ID | len=2 | MIN delay | MAX delay | |
| 173 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 169 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 174 constexpr RTPExtensionType PlayoutDelayLimits::kId; | 170 constexpr RTPExtensionType PlayoutDelayLimits::kId; |
| 175 constexpr uint8_t PlayoutDelayLimits::kValueSizeBytes; | 171 constexpr uint8_t PlayoutDelayLimits::kValueSizeBytes; |
| 176 const char* const PlayoutDelayLimits::kUri = | 172 constexpr const char* PlayoutDelayLimits::kUri; |
| 177 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; | |
| 178 | 173 |
| 179 bool PlayoutDelayLimits::Parse(const uint8_t* data, | 174 bool PlayoutDelayLimits::Parse(const uint8_t* data, |
| 180 PlayoutDelay* playout_delay) { | 175 PlayoutDelay* playout_delay) { |
| 181 RTC_DCHECK(playout_delay); | 176 RTC_DCHECK(playout_delay); |
| 182 uint32_t raw = ByteReader<uint32_t, 3>::ReadBigEndian(data); | 177 uint32_t raw = ByteReader<uint32_t, 3>::ReadBigEndian(data); |
| 183 uint16_t min_raw = (raw >> 12); | 178 uint16_t min_raw = (raw >> 12); |
| 184 uint16_t max_raw = (raw & 0xfff); | 179 uint16_t max_raw = (raw & 0xfff); |
| 185 if (min_raw > max_raw) | 180 if (min_raw > max_raw) |
| 186 return false; | 181 return false; |
| 187 playout_delay->min_ms = min_raw * kGranularityMs; | 182 playout_delay->min_ms = min_raw * kGranularityMs; |
| 188 playout_delay->max_ms = max_raw * kGranularityMs; | 183 playout_delay->max_ms = max_raw * kGranularityMs; |
| 189 return true; | 184 return true; |
| 190 } | 185 } |
| 191 | 186 |
| 192 bool PlayoutDelayLimits::Write(uint8_t* data, | 187 bool PlayoutDelayLimits::Write(uint8_t* data, |
| 193 const PlayoutDelay& playout_delay) { | 188 const PlayoutDelay& playout_delay) { |
| 194 RTC_DCHECK_LE(0, playout_delay.min_ms); | 189 RTC_DCHECK_LE(0, playout_delay.min_ms); |
| 195 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms); | 190 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms); |
| 196 RTC_DCHECK_LE(playout_delay.max_ms, kMaxMs); | 191 RTC_DCHECK_LE(playout_delay.max_ms, kMaxMs); |
| 197 // Convert MS to value to be sent on extension header. | 192 // Convert MS to value to be sent on extension header. |
| 198 uint32_t min_delay = playout_delay.min_ms / kGranularityMs; | 193 uint32_t min_delay = playout_delay.min_ms / kGranularityMs; |
| 199 uint32_t max_delay = playout_delay.max_ms / kGranularityMs; | 194 uint32_t max_delay = playout_delay.max_ms / kGranularityMs; |
| 200 ByteWriter<uint32_t, 3>::WriteBigEndian(data, (min_delay << 12) | max_delay); | 195 ByteWriter<uint32_t, 3>::WriteBigEndian(data, (min_delay << 12) | max_delay); |
| 201 return true; | 196 return true; |
| 202 } | 197 } |
| 203 | 198 |
| 204 } // namespace webrtc | 199 } // namespace webrtc |
| OLD | NEW |