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