OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <string.h> |
14 #include <math.h> // ceil | |
15 #include <string.h> // memcpy | |
16 | |
17 #if defined(_WIN32) | |
18 // Order for these headers are important | |
19 #include <winsock2.h> // timeval | |
20 #include <windows.h> // FILETIME NOLINT(build/include_alpha) | |
21 #include <MMSystem.h> // timeGetTime | |
22 #elif ((defined WEBRTC_LINUX) || (defined WEBRTC_MAC)) | |
23 #include <sys/time.h> // gettimeofday | |
24 #include <time.h> | |
25 #endif | |
26 #if (!defined(NDEBUG) && defined(_WIN32) && (_MSC_VER >= 1400)) | |
27 #include <stdio.h> | |
28 #endif | |
29 | 14 |
30 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
31 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 16 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
32 #include "webrtc/system_wrappers/include/tick_util.h" | |
33 | |
34 #if (!defined(NDEBUG) && defined(_WIN32) && (_MSC_VER >= 1400)) | |
35 #define DEBUG_PRINT(...) \ | |
36 { \ | |
37 char msg[256]; \ | |
38 sprintf(msg, __VA_ARGS__); \ | |
39 OutputDebugString(msg); \ | |
40 } | |
41 #else | |
42 // special fix for visual 2003 | |
43 #define DEBUG_PRINT(exp) ((void)0) | |
44 #endif // !defined(NDEBUG) && defined(_WIN32) | |
45 | 17 |
46 namespace webrtc { | 18 namespace webrtc { |
47 | 19 |
48 RtpData* NullObjectRtpData() { | 20 RtpData* NullObjectRtpData() { |
49 static NullRtpData null_rtp_data; | 21 static NullRtpData null_rtp_data; |
50 return &null_rtp_data; | 22 return &null_rtp_data; |
51 } | 23 } |
52 | 24 |
53 RtpFeedback* NullObjectRtpFeedback() { | 25 RtpFeedback* NullObjectRtpFeedback() { |
54 static NullRtpFeedback null_rtp_feedback; | 26 static NullRtpFeedback null_rtp_feedback; |
(...skipping 21 matching lines...) Expand all Loading... |
76 kRtpMinParseLength = 12 | 48 kRtpMinParseLength = 12 |
77 }; | 49 }; |
78 | 50 |
79 /* | 51 /* |
80 * Misc utility routines | 52 * Misc utility routines |
81 */ | 53 */ |
82 | 54 |
83 #if defined(_WIN32) | 55 #if defined(_WIN32) |
84 bool StringCompare(const char* str1, const char* str2, | 56 bool StringCompare(const char* str1, const char* str2, |
85 const uint32_t length) { | 57 const uint32_t length) { |
86 return (_strnicmp(str1, str2, length) == 0) ? true : false; | 58 return _strnicmp(str1, str2, length) == 0; |
87 } | 59 } |
88 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) | 60 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) |
89 bool StringCompare(const char* str1, const char* str2, | 61 bool StringCompare(const char* str1, const char* str2, |
90 const uint32_t length) { | 62 const uint32_t length) { |
91 return (strncasecmp(str1, str2, length) == 0) ? true : false; | 63 return strncasecmp(str1, str2, length) == 0; |
92 } | 64 } |
93 #endif | 65 #endif |
94 | 66 |
95 size_t Word32Align(size_t size) { | 67 size_t Word32Align(size_t size) { |
96 uint32_t remainder = size % 4; | 68 uint32_t remainder = size % 4; |
97 if (remainder != 0) | 69 if (remainder != 0) |
98 return size + 4 - remainder; | 70 return size + 4 - remainder; |
99 return size; | 71 return size; |
100 } | 72 } |
101 | 73 |
102 uint32_t pow2(uint8_t exp) { | |
103 return 1 << exp; | |
104 } | |
105 | |
106 RtpHeaderParser::RtpHeaderParser(const uint8_t* rtpData, | 74 RtpHeaderParser::RtpHeaderParser(const uint8_t* rtpData, |
107 const size_t rtpDataLength) | 75 const size_t rtpDataLength) |
108 : _ptrRTPDataBegin(rtpData), | 76 : _ptrRTPDataBegin(rtpData), |
109 _ptrRTPDataEnd(rtpData ? (rtpData + rtpDataLength) : NULL) { | 77 _ptrRTPDataEnd(rtpData ? (rtpData + rtpDataLength) : NULL) { |
110 } | 78 } |
111 | 79 |
112 RtpHeaderParser::~RtpHeaderParser() { | 80 RtpHeaderParser::~RtpHeaderParser() { |
113 } | 81 } |
114 | 82 |
115 bool RtpHeaderParser::RTCP() const { | 83 bool RtpHeaderParser::RTCP() const { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 uint32_t SSRC = ByteReader<uint32_t>::ReadBigEndian(ptr); | 173 uint32_t SSRC = ByteReader<uint32_t>::ReadBigEndian(ptr); |
206 ptr += 4; | 174 ptr += 4; |
207 | 175 |
208 header->payloadType = PT; | 176 header->payloadType = PT; |
209 header->ssrc = SSRC; | 177 header->ssrc = SSRC; |
210 header->headerLength = 4 + (len << 2); | 178 header->headerLength = 4 + (len << 2); |
211 | 179 |
212 return true; | 180 return true; |
213 } | 181 } |
214 | 182 |
215 bool RtpHeaderParser::Parse(RTPHeader& header, | 183 bool RtpHeaderParser::Parse(RTPHeader* header, |
216 RtpHeaderExtensionMap* ptrExtensionMap) const { | 184 RtpHeaderExtensionMap* ptrExtensionMap) const { |
217 const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin; | 185 const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin; |
218 if (length < kRtpMinParseLength) { | 186 if (length < kRtpMinParseLength) { |
219 return false; | 187 return false; |
220 } | 188 } |
221 | 189 |
222 // Version | 190 // Version |
223 const uint8_t V = _ptrRTPDataBegin[0] >> 6; | 191 const uint8_t V = _ptrRTPDataBegin[0] >> 6; |
224 // Padding | 192 // Padding |
225 const bool P = ((_ptrRTPDataBegin[0] & 0x20) == 0) ? false : true; | 193 const bool P = ((_ptrRTPDataBegin[0] & 0x20) == 0) ? false : true; |
(...skipping 18 matching lines...) Expand all Loading... |
244 if (V != kRtpExpectedVersion) { | 212 if (V != kRtpExpectedVersion) { |
245 return false; | 213 return false; |
246 } | 214 } |
247 | 215 |
248 const size_t CSRCocts = CC * 4; | 216 const size_t CSRCocts = CC * 4; |
249 | 217 |
250 if ((ptr + CSRCocts) > _ptrRTPDataEnd) { | 218 if ((ptr + CSRCocts) > _ptrRTPDataEnd) { |
251 return false; | 219 return false; |
252 } | 220 } |
253 | 221 |
254 header.markerBit = M; | 222 header->markerBit = M; |
255 header.payloadType = PT; | 223 header->payloadType = PT; |
256 header.sequenceNumber = sequenceNumber; | 224 header->sequenceNumber = sequenceNumber; |
257 header.timestamp = RTPTimestamp; | 225 header->timestamp = RTPTimestamp; |
258 header.ssrc = SSRC; | 226 header->ssrc = SSRC; |
259 header.numCSRCs = CC; | 227 header->numCSRCs = CC; |
260 header.paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0; | 228 header->paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0; |
261 | 229 |
262 for (uint8_t i = 0; i < CC; ++i) { | 230 for (uint8_t i = 0; i < CC; ++i) { |
263 uint32_t CSRC = ByteReader<uint32_t>::ReadBigEndian(ptr); | 231 uint32_t CSRC = ByteReader<uint32_t>::ReadBigEndian(ptr); |
264 ptr += 4; | 232 ptr += 4; |
265 header.arrOfCSRCs[i] = CSRC; | 233 header->arrOfCSRCs[i] = CSRC; |
266 } | 234 } |
267 | 235 |
268 header.headerLength = 12 + CSRCocts; | 236 header->headerLength = 12 + CSRCocts; |
269 | 237 |
270 // If in effect, MAY be omitted for those packets for which the offset | 238 // If in effect, MAY be omitted for those packets for which the offset |
271 // is zero. | 239 // is zero. |
272 header.extension.hasTransmissionTimeOffset = false; | 240 header->extension.hasTransmissionTimeOffset = false; |
273 header.extension.transmissionTimeOffset = 0; | 241 header->extension.transmissionTimeOffset = 0; |
274 | 242 |
275 // May not be present in packet. | 243 // May not be present in packet. |
276 header.extension.hasAbsoluteSendTime = false; | 244 header->extension.hasAbsoluteSendTime = false; |
277 header.extension.absoluteSendTime = 0; | 245 header->extension.absoluteSendTime = 0; |
278 | 246 |
279 // May not be present in packet. | 247 // May not be present in packet. |
280 header.extension.hasAudioLevel = false; | 248 header->extension.hasAudioLevel = false; |
281 header.extension.voiceActivity = false; | 249 header->extension.voiceActivity = false; |
282 header.extension.audioLevel = 0; | 250 header->extension.audioLevel = 0; |
283 | 251 |
284 // May not be present in packet. | 252 // May not be present in packet. |
285 header.extension.hasVideoRotation = false; | 253 header->extension.hasVideoRotation = false; |
286 header.extension.videoRotation = 0; | 254 header->extension.videoRotation = 0; |
287 | 255 |
288 if (X) { | 256 if (X) { |
289 /* RTP header extension, RFC 3550. | 257 /* RTP header extension, RFC 3550. |
290 0 1 2 3 | 258 0 1 2 3 |
291 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 | 259 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 |
292 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 260 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
293 | defined by profile | length | | 261 | defined by profile | length | |
294 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 262 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
295 | header extension | | 263 | header extension | |
296 | .... | | 264 | .... | |
297 */ | 265 */ |
298 const ptrdiff_t remain = _ptrRTPDataEnd - ptr; | 266 const ptrdiff_t remain = _ptrRTPDataEnd - ptr; |
299 if (remain < 4) { | 267 if (remain < 4) { |
300 return false; | 268 return false; |
301 } | 269 } |
302 | 270 |
303 header.headerLength += 4; | 271 header->headerLength += 4; |
304 | 272 |
305 uint16_t definedByProfile = ByteReader<uint16_t>::ReadBigEndian(ptr); | 273 uint16_t definedByProfile = ByteReader<uint16_t>::ReadBigEndian(ptr); |
306 ptr += 2; | 274 ptr += 2; |
307 | 275 |
308 // in 32 bit words | 276 // in 32 bit words |
309 size_t XLen = ByteReader<uint16_t>::ReadBigEndian(ptr); | 277 size_t XLen = ByteReader<uint16_t>::ReadBigEndian(ptr); |
310 ptr += 2; | 278 ptr += 2; |
311 XLen *= 4; // in bytes | 279 XLen *= 4; // in bytes |
312 | 280 |
313 if (static_cast<size_t>(remain) < (4 + XLen)) { | 281 if (static_cast<size_t>(remain) < (4 + XLen)) { |
314 return false; | 282 return false; |
315 } | 283 } |
316 if (definedByProfile == kRtpOneByteHeaderExtensionId) { | 284 if (definedByProfile == kRtpOneByteHeaderExtensionId) { |
317 const uint8_t* ptrRTPDataExtensionEnd = ptr + XLen; | 285 const uint8_t* ptrRTPDataExtensionEnd = ptr + XLen; |
318 ParseOneByteExtensionHeader(header, | 286 ParseOneByteExtensionHeader(header, |
319 ptrExtensionMap, | 287 ptrExtensionMap, |
320 ptrRTPDataExtensionEnd, | 288 ptrRTPDataExtensionEnd, |
321 ptr); | 289 ptr); |
322 } | 290 } |
323 header.headerLength += XLen; | 291 header->headerLength += XLen; |
324 } | 292 } |
325 if (header.headerLength + header.paddingLength > static_cast<size_t>(length)) | 293 if (header->headerLength + header->paddingLength > |
| 294 static_cast<size_t>(length)) |
326 return false; | 295 return false; |
327 return true; | 296 return true; |
328 } | 297 } |
329 | 298 |
330 void RtpHeaderParser::ParseOneByteExtensionHeader( | 299 void RtpHeaderParser::ParseOneByteExtensionHeader( |
331 RTPHeader& header, | 300 RTPHeader* header, |
332 const RtpHeaderExtensionMap* ptrExtensionMap, | 301 const RtpHeaderExtensionMap* ptrExtensionMap, |
333 const uint8_t* ptrRTPDataExtensionEnd, | 302 const uint8_t* ptrRTPDataExtensionEnd, |
334 const uint8_t* ptr) const { | 303 const uint8_t* ptr) const { |
335 if (!ptrExtensionMap) { | 304 if (!ptrExtensionMap) { |
336 return; | 305 return; |
337 } | 306 } |
338 | 307 |
339 while (ptrRTPDataExtensionEnd - ptr > 0) { | 308 while (ptrRTPDataExtensionEnd - ptr > 0) { |
340 // 0 | 309 // 0 |
341 // 0 1 2 3 4 5 6 7 | 310 // 0 1 2 3 4 5 6 7 |
(...skipping 25 matching lines...) Expand all Loading... |
367 LOG(LS_WARNING) << "Incorrect transmission time offset len: " | 336 LOG(LS_WARNING) << "Incorrect transmission time offset len: " |
368 << len; | 337 << len; |
369 return; | 338 return; |
370 } | 339 } |
371 // 0 1 2 3 | 340 // 0 1 2 3 |
372 // 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 | 341 // 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 |
373 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 342 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
374 // | ID | len=2 | transmission offset | | 343 // | ID | len=2 | transmission offset | |
375 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 344 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
376 | 345 |
377 header.extension.transmissionTimeOffset = | 346 header->extension.transmissionTimeOffset = |
378 ByteReader<int32_t, 3>::ReadBigEndian(ptr); | 347 ByteReader<int32_t, 3>::ReadBigEndian(ptr); |
379 header.extension.hasTransmissionTimeOffset = true; | 348 header->extension.hasTransmissionTimeOffset = true; |
380 break; | 349 break; |
381 } | 350 } |
382 case kRtpExtensionAudioLevel: { | 351 case kRtpExtensionAudioLevel: { |
383 if (len != 0) { | 352 if (len != 0) { |
384 LOG(LS_WARNING) << "Incorrect audio level len: " << len; | 353 LOG(LS_WARNING) << "Incorrect audio level len: " << len; |
385 return; | 354 return; |
386 } | 355 } |
387 // 0 1 | 356 // 0 1 |
388 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | 357 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
389 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 358 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
390 // | ID | len=0 |V| level | | 359 // | ID | len=0 |V| level | |
391 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 360 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
392 // | 361 // |
393 header.extension.audioLevel = ptr[0] & 0x7f; | 362 header->extension.audioLevel = ptr[0] & 0x7f; |
394 header.extension.voiceActivity = (ptr[0] & 0x80) != 0; | 363 header->extension.voiceActivity = (ptr[0] & 0x80) != 0; |
395 header.extension.hasAudioLevel = true; | 364 header->extension.hasAudioLevel = true; |
396 break; | 365 break; |
397 } | 366 } |
398 case kRtpExtensionAbsoluteSendTime: { | 367 case kRtpExtensionAbsoluteSendTime: { |
399 if (len != 2) { | 368 if (len != 2) { |
400 LOG(LS_WARNING) << "Incorrect absolute send time len: " << len; | 369 LOG(LS_WARNING) << "Incorrect absolute send time len: " << len; |
401 return; | 370 return; |
402 } | 371 } |
403 // 0 1 2 3 | 372 // 0 1 2 3 |
404 // 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 | 373 // 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 |
405 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 374 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
406 // | ID | len=2 | absolute send time | | 375 // | ID | len=2 | absolute send time | |
407 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 376 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
408 | 377 |
409 header.extension.absoluteSendTime = | 378 header->extension.absoluteSendTime = |
410 ByteReader<uint32_t, 3>::ReadBigEndian(ptr); | 379 ByteReader<uint32_t, 3>::ReadBigEndian(ptr); |
411 header.extension.hasAbsoluteSendTime = true; | 380 header->extension.hasAbsoluteSendTime = true; |
412 break; | 381 break; |
413 } | 382 } |
414 case kRtpExtensionVideoRotation: { | 383 case kRtpExtensionVideoRotation: { |
415 if (len != 0) { | 384 if (len != 0) { |
416 LOG(LS_WARNING) | 385 LOG(LS_WARNING) |
417 << "Incorrect coordination of video coordination len: " << len; | 386 << "Incorrect coordination of video coordination len: " << len; |
418 return; | 387 return; |
419 } | 388 } |
420 // 0 1 | 389 // 0 1 |
421 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | 390 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 |
422 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 391 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
423 // | ID | len=0 |0 0 0 0 C F R R| | 392 // | ID | len=0 |0 0 0 0 C F R R| |
424 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 393 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
425 header.extension.hasVideoRotation = true; | 394 header->extension.hasVideoRotation = true; |
426 header.extension.videoRotation = ptr[0]; | 395 header->extension.videoRotation = ptr[0]; |
427 break; | 396 break; |
428 } | 397 } |
429 case kRtpExtensionTransportSequenceNumber: { | 398 case kRtpExtensionTransportSequenceNumber: { |
430 if (len != 1) { | 399 if (len != 1) { |
431 LOG(LS_WARNING) | 400 LOG(LS_WARNING) |
432 << "Incorrect peer connection sequence number len: " << len; | 401 << "Incorrect peer connection sequence number len: " << len; |
433 return; | 402 return; |
434 } | 403 } |
435 // 0 1 2 | 404 // 0 1 2 |
436 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 | 405 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 |
437 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 406 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
438 // | ID | L=1 |transport wide sequence number | | 407 // | ID | L=1 |transport wide sequence number | |
439 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 408 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
440 | 409 |
441 uint16_t sequence_number = ptr[0] << 8; | 410 uint16_t sequence_number = ptr[0] << 8; |
442 sequence_number += ptr[1]; | 411 sequence_number += ptr[1]; |
443 header.extension.transportSequenceNumber = sequence_number; | 412 header->extension.transportSequenceNumber = sequence_number; |
444 header.extension.hasTransportSequenceNumber = true; | 413 header->extension.hasTransportSequenceNumber = true; |
445 break; | 414 break; |
446 } | 415 } |
447 default: { | 416 default: { |
448 LOG(LS_WARNING) << "Extension type not implemented: " << type; | 417 LOG(LS_WARNING) << "Extension type not implemented: " << type; |
449 return; | 418 return; |
450 } | 419 } |
451 } | 420 } |
452 } | 421 } |
453 ptr += (len + 1); | 422 ptr += (len + 1); |
454 uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr); | 423 uint8_t num_bytes = ParsePaddingBytes(ptrRTPDataExtensionEnd, ptr); |
455 ptr += num_bytes; | 424 ptr += num_bytes; |
456 } | 425 } |
457 } | 426 } |
458 | 427 |
459 uint8_t RtpHeaderParser::ParsePaddingBytes( | 428 uint8_t RtpHeaderParser::ParsePaddingBytes( |
460 const uint8_t* ptrRTPDataExtensionEnd, | 429 const uint8_t* ptrRTPDataExtensionEnd, |
461 const uint8_t* ptr) const { | 430 const uint8_t* ptr) const { |
462 uint8_t num_zero_bytes = 0; | 431 uint8_t num_zero_bytes = 0; |
463 while (ptrRTPDataExtensionEnd - ptr > 0) { | 432 while (ptrRTPDataExtensionEnd - ptr > 0) { |
464 if (*ptr != 0) { | 433 if (*ptr != 0) { |
465 return num_zero_bytes; | 434 return num_zero_bytes; |
466 } | 435 } |
467 ptr++; | 436 ptr++; |
468 num_zero_bytes++; | 437 num_zero_bytes++; |
469 } | 438 } |
470 return num_zero_bytes; | 439 return num_zero_bytes; |
471 } | 440 } |
472 } // namespace RtpUtility | 441 } // namespace RtpUtility |
473 | |
474 } // namespace webrtc | 442 } // namespace webrtc |
OLD | NEW |