Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc

Issue 2224063004: Implement PlayoutDelay extension as a trait (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) { 194 bool VideoOrientation::Parse(const uint8_t* data, uint8_t* value) {
195 *value = data[0]; 195 *value = data[0];
196 return true; 196 return true;
197 } 197 }
198 198
199 bool VideoOrientation::Write(uint8_t* data, uint8_t value) { 199 bool VideoOrientation::Write(uint8_t* data, uint8_t value) {
200 data[0] = value; 200 data[0] = value;
201 return true; 201 return true;
202 } 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
203 } // namespace webrtc 251 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h ('k') | webrtc/test/fuzzers/rtp_packet_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698