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 13 matching lines...) Expand all Loading... | |
24 // containing the sender's current time in seconds as a fixed point number | 24 // containing the sender's current time in seconds as a fixed point number |
25 // with 18 bits fractional part. | 25 // with 18 bits fractional part. |
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 const char* AbsoluteSendTime::kName = | 34 constexpr RTPExtensionType AbsoluteSendTime::kId; |
35 constexpr uint8_t AbsoluteSendTime::kValueSizeBytes; | |
brandtr
2016/10/28 13:26:56
Are the declarations above just for documentation,
danilchap
2016/10/28 13:32:03
presence of these declaration allows to use consta
| |
36 const char* const AbsoluteSendTime::kUri = | |
35 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; | 37 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; |
36 bool AbsoluteSendTime::IsSupportedFor(MediaType type) { | |
37 return true; | |
38 } | |
39 | 38 |
40 bool AbsoluteSendTime::Parse(const uint8_t* data, uint32_t* time_24bits) { | 39 bool AbsoluteSendTime::Parse(const uint8_t* data, uint32_t* time_24bits) { |
41 *time_24bits = ByteReader<uint32_t, 3>::ReadBigEndian(data); | 40 *time_24bits = ByteReader<uint32_t, 3>::ReadBigEndian(data); |
42 return true; | 41 return true; |
43 } | 42 } |
44 | 43 |
45 bool AbsoluteSendTime::Write(uint8_t* data, int64_t time_ms) { | 44 bool AbsoluteSendTime::Write(uint8_t* data, int64_t time_ms) { |
46 ByteWriter<uint32_t, 3>::WriteBigEndian(data, MsTo24Bits(time_ms)); | 45 ByteWriter<uint32_t, 3>::WriteBigEndian(data, MsTo24Bits(time_ms)); |
47 return true; | 46 return true; |
48 } | 47 } |
49 | 48 |
50 // An RTP Header Extension for Client-to-Mixer Audio Level Indication | 49 // An RTP Header Extension for Client-to-Mixer Audio Level Indication |
51 // | 50 // |
52 // 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/ |
53 // | 52 // |
54 // The form of the audio level extension block: | 53 // The form of the audio level extension block: |
55 // | 54 // |
56 // 0 1 | 55 // 0 1 |
57 // 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 |
58 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 57 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
59 // | ID | len=0 |V| level | | 58 // | ID | len=0 |V| level | |
60 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 59 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
61 // | 60 // |
62 const char* AudioLevel::kName = "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; | 61 constexpr RTPExtensionType AudioLevel::kId; |
63 bool AudioLevel::IsSupportedFor(MediaType type) { | 62 constexpr uint8_t AudioLevel::kValueSizeBytes; |
brandtr
2016/10/28 13:26:56
Same here, and below.
| |
64 switch (type) { | 63 const char* const AudioLevel::kUri = |
65 case MediaType::ANY: | 64 "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; |
66 case MediaType::AUDIO: | |
67 return true; | |
68 case MediaType::VIDEO: | |
69 case MediaType::DATA: | |
70 return false; | |
71 } | |
72 RTC_NOTREACHED(); | |
73 return false; | |
74 } | |
75 | 65 |
76 bool AudioLevel::Parse(const uint8_t* data, | 66 bool AudioLevel::Parse(const uint8_t* data, |
77 bool* voice_activity, | 67 bool* voice_activity, |
78 uint8_t* audio_level) { | 68 uint8_t* audio_level) { |
79 *voice_activity = (data[0] & 0x80) != 0; | 69 *voice_activity = (data[0] & 0x80) != 0; |
80 *audio_level = data[0] & 0x7F; | 70 *audio_level = data[0] & 0x7F; |
81 return true; | 71 return true; |
82 } | 72 } |
83 | 73 |
84 bool AudioLevel::Write(uint8_t* data, | 74 bool AudioLevel::Write(uint8_t* data, |
(...skipping 13 matching lines...) Expand all Loading... | |
98 // "effective" RTP transmission time of the packet, on the RTP | 88 // "effective" RTP transmission time of the packet, on the RTP |
99 // timescale. | 89 // timescale. |
100 // | 90 // |
101 // The form of the transmission offset extension block: | 91 // The form of the transmission offset extension block: |
102 // | 92 // |
103 // 0 1 2 3 | 93 // 0 1 2 3 |
104 // 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 |
105 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 95 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
106 // | ID | len=2 | transmission offset | | 96 // | ID | len=2 | transmission offset | |
107 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 97 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
108 const char* TransmissionOffset::kName = "urn:ietf:params:rtp-hdrext:toffset"; | 98 constexpr RTPExtensionType TransmissionOffset::kId; |
109 bool TransmissionOffset::IsSupportedFor(MediaType type) { | 99 constexpr uint8_t TransmissionOffset::kValueSizeBytes; |
110 switch (type) { | 100 const char* const TransmissionOffset::kUri = |
111 case MediaType::ANY: | 101 "urn:ietf:params:rtp-hdrext:toffset"; |
112 case MediaType::VIDEO: | |
113 return true; | |
114 case MediaType::AUDIO: | |
115 case MediaType::DATA: | |
116 return false; | |
117 } | |
118 RTC_NOTREACHED(); | |
119 return false; | |
120 } | |
121 | 102 |
122 bool TransmissionOffset::Parse(const uint8_t* data, int32_t* rtp_time) { | 103 bool TransmissionOffset::Parse(const uint8_t* data, int32_t* rtp_time) { |
123 *rtp_time = ByteReader<int32_t, 3>::ReadBigEndian(data); | 104 *rtp_time = ByteReader<int32_t, 3>::ReadBigEndian(data); |
124 return true; | 105 return true; |
125 } | 106 } |
126 | 107 |
127 bool TransmissionOffset::Write(uint8_t* data, int32_t rtp_time) { | 108 bool TransmissionOffset::Write(uint8_t* data, int32_t rtp_time) { |
128 RTC_DCHECK_LE(rtp_time, 0x00ffffff); | 109 RTC_DCHECK_LE(rtp_time, 0x00ffffff); |
129 ByteWriter<int32_t, 3>::WriteBigEndian(data, rtp_time); | 110 ByteWriter<int32_t, 3>::WriteBigEndian(data, rtp_time); |
130 return true; | 111 return true; |
131 } | 112 } |
132 | 113 |
133 // 0 1 2 | 114 // 0 1 2 |
134 // 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 |
135 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 116 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
136 // | ID | L=1 |transport wide sequence number | | 117 // | ID | L=1 |transport wide sequence number | |
137 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 118 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
138 const char* TransportSequenceNumber::kName = | 119 constexpr RTPExtensionType TransportSequenceNumber::kId; |
120 constexpr uint8_t TransportSequenceNumber::kValueSizeBytes; | |
121 const char* const TransportSequenceNumber::kUri = | |
139 "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions"; | 122 "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions"; |
140 bool TransportSequenceNumber::IsSupportedFor(MediaType type) { | |
141 return true; | |
142 } | |
143 | 123 |
144 bool TransportSequenceNumber::Parse(const uint8_t* data, uint16_t* value) { | 124 bool TransportSequenceNumber::Parse(const uint8_t* data, uint16_t* value) { |
145 *value = ByteReader<uint16_t>::ReadBigEndian(data); | 125 *value = ByteReader<uint16_t>::ReadBigEndian(data); |
146 return true; | 126 return true; |
147 } | 127 } |
148 | 128 |
149 bool TransportSequenceNumber::Write(uint8_t* data, uint16_t value) { | 129 bool TransportSequenceNumber::Write(uint8_t* data, uint16_t value) { |
150 ByteWriter<uint16_t>::WriteBigEndian(data, value); | 130 ByteWriter<uint16_t>::WriteBigEndian(data, value); |
151 return true; | 131 return true; |
152 } | 132 } |
153 | 133 |
154 // Coordination of Video Orientation in RTP streams. | 134 // Coordination of Video Orientation in RTP streams. |
155 // | 135 // |
156 // Coordination of Video Orientation consists in signaling of the current | 136 // Coordination of Video Orientation consists in signaling of the current |
157 // 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 |
158 // appropriate rendering and displaying. | 138 // appropriate rendering and displaying. |
159 // | 139 // |
160 // 0 1 | 140 // 0 1 |
161 // 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 |
162 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 142 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
163 // | ID | len=0 |0 0 0 0 C F R R| | 143 // | ID | len=0 |0 0 0 0 C F R R| |
164 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 144 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
165 const char* VideoOrientation::kName = "urn:3gpp:video-orientation"; | 145 constexpr RTPExtensionType VideoOrientation::kId; |
166 bool VideoOrientation::IsSupportedFor(MediaType type) { | 146 constexpr uint8_t VideoOrientation::kValueSizeBytes; |
167 switch (type) { | 147 const char* const VideoOrientation::kUri = "urn:3gpp:video-orientation"; |
168 case MediaType::ANY: | |
169 case MediaType::VIDEO: | |
170 return true; | |
171 case MediaType::AUDIO: | |
172 case MediaType::DATA: | |
173 return false; | |
174 } | |
175 RTC_NOTREACHED(); | |
176 return false; | |
177 } | |
178 | 148 |
179 bool VideoOrientation::Parse(const uint8_t* data, VideoRotation* rotation) { | 149 bool VideoOrientation::Parse(const uint8_t* data, VideoRotation* rotation) { |
180 *rotation = ConvertCVOByteToVideoRotation(data[0]); | 150 *rotation = ConvertCVOByteToVideoRotation(data[0]); |
181 return true; | 151 return true; |
182 } | 152 } |
183 | 153 |
184 bool VideoOrientation::Write(uint8_t* data, VideoRotation rotation) { | 154 bool VideoOrientation::Write(uint8_t* data, VideoRotation rotation) { |
185 data[0] = ConvertVideoRotationToCVOByte(rotation); | 155 data[0] = ConvertVideoRotationToCVOByte(rotation); |
186 return true; | 156 return true; |
187 } | 157 } |
188 | 158 |
189 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) { | 159 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) { |
190 *value = data[0]; | 160 *value = data[0]; |
191 return true; | 161 return true; |
192 } | 162 } |
193 | 163 |
194 bool VideoOrientation::Write(uint8_t* data, uint8_t value) { | 164 bool VideoOrientation::Write(uint8_t* data, uint8_t value) { |
195 data[0] = value; | 165 data[0] = value; |
196 return true; | 166 return true; |
197 } | 167 } |
198 | 168 |
199 // 0 1 2 3 | 169 // 0 1 2 3 |
200 // 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 |
201 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 171 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
202 // | ID | len=2 | MIN delay | MAX delay | | 172 // | ID | len=2 | MIN delay | MAX delay | |
203 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 173 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
204 constexpr RTPExtensionType PlayoutDelayLimits::kId; | 174 constexpr RTPExtensionType PlayoutDelayLimits::kId; |
205 constexpr uint8_t PlayoutDelayLimits::kValueSizeBytes; | 175 constexpr uint8_t PlayoutDelayLimits::kValueSizeBytes; |
206 const char* PlayoutDelayLimits::kName = | 176 const char* const PlayoutDelayLimits::kUri = |
207 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; | 177 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
208 bool PlayoutDelayLimits::IsSupportedFor(MediaType type) { | |
209 switch (type) { | |
210 case MediaType::ANY: | |
211 case MediaType::VIDEO: | |
212 return true; | |
213 case MediaType::AUDIO: | |
214 case MediaType::DATA: | |
215 return false; | |
216 } | |
217 RTC_NOTREACHED(); | |
218 return false; | |
219 } | |
220 | 178 |
221 bool PlayoutDelayLimits::Parse(const uint8_t* data, | 179 bool PlayoutDelayLimits::Parse(const uint8_t* data, |
222 PlayoutDelay* playout_delay) { | 180 PlayoutDelay* playout_delay) { |
223 RTC_DCHECK(playout_delay); | 181 RTC_DCHECK(playout_delay); |
224 uint32_t raw = ByteReader<uint32_t, 3>::ReadBigEndian(data); | 182 uint32_t raw = ByteReader<uint32_t, 3>::ReadBigEndian(data); |
225 uint16_t min_raw = (raw >> 12); | 183 uint16_t min_raw = (raw >> 12); |
226 uint16_t max_raw = (raw & 0xfff); | 184 uint16_t max_raw = (raw & 0xfff); |
227 if (min_raw > max_raw) | 185 if (min_raw > max_raw) |
228 return false; | 186 return false; |
229 playout_delay->min_ms = min_raw * kGranularityMs; | 187 playout_delay->min_ms = min_raw * kGranularityMs; |
230 playout_delay->max_ms = max_raw * kGranularityMs; | 188 playout_delay->max_ms = max_raw * kGranularityMs; |
231 return true; | 189 return true; |
232 } | 190 } |
233 | 191 |
234 bool PlayoutDelayLimits::Write(uint8_t* data, | 192 bool PlayoutDelayLimits::Write(uint8_t* data, |
235 const PlayoutDelay& playout_delay) { | 193 const PlayoutDelay& playout_delay) { |
236 RTC_DCHECK_LE(0, playout_delay.min_ms); | 194 RTC_DCHECK_LE(0, playout_delay.min_ms); |
237 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms); | 195 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms); |
238 RTC_DCHECK_LE(playout_delay.max_ms, kMaxMs); | 196 RTC_DCHECK_LE(playout_delay.max_ms, kMaxMs); |
239 // Convert MS to value to be sent on extension header. | 197 // Convert MS to value to be sent on extension header. |
240 uint32_t min_delay = playout_delay.min_ms / kGranularityMs; | 198 uint32_t min_delay = playout_delay.min_ms / kGranularityMs; |
241 uint32_t max_delay = playout_delay.max_ms / kGranularityMs; | 199 uint32_t max_delay = playout_delay.max_ms / kGranularityMs; |
242 ByteWriter<uint32_t, 3>::WriteBigEndian(data, (min_delay << 12) | max_delay); | 200 ByteWriter<uint32_t, 3>::WriteBigEndian(data, (min_delay << 12) | max_delay); |
243 return true; | 201 return true; |
244 } | 202 } |
245 | 203 |
246 } // namespace webrtc | 204 } // namespace webrtc |
OLD | NEW |