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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_utility.h

Issue 1307663004: Add a ParseHeader method to RtcpPacket, for parsing common RTCP header. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments, rebase Created 5 years, 3 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) 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
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 struct RTCPRawPacket { 299 struct RTCPRawPacket {
300 const uint8_t* _ptrPacketBegin; 300 const uint8_t* _ptrPacketBegin;
301 const uint8_t* _ptrPacketEnd; 301 const uint8_t* _ptrPacketEnd;
302 }; 302 };
303 303
304 struct RTCPModRawPacket { 304 struct RTCPModRawPacket {
305 uint8_t* _ptrPacketBegin; 305 uint8_t* _ptrPacketBegin;
306 uint8_t* _ptrPacketEnd; 306 uint8_t* _ptrPacketEnd;
307 }; 307 };
308 308
309 struct RTCPCommonHeader { 309 struct RtcpCommonHeader {
310 uint8_t V; // Version 310 static const uint8_t kHeaderSizeBytes = 4;
311 bool P; // Padding 311 RtcpCommonHeader()
312 uint8_t IC; // Item count/subtype 312 : version(2),
313 uint8_t PT; // Packet Type 313 count_or_format(0),
314 uint16_t LengthInOctets; 314 packet_type(0),
315 payload_size_bytes(0),
316 padding_bytes(0) {}
317
318 uint32_t BlockSize() const {
319 return kHeaderSizeBytes + payload_size_bytes + padding_bytes;
320 }
321
322 uint8_t version;
323 uint8_t count_or_format;
324 uint8_t packet_type;
325 uint32_t payload_size_bytes;
326 uint8_t padding_bytes;
315 }; 327 };
316 328
317 enum RTCPPT : uint8_t { 329 enum RTCPPT : uint8_t {
318 PT_IJ = 195, 330 PT_IJ = 195,
319 PT_SR = 200, 331 PT_SR = 200,
320 PT_RR = 201, 332 PT_RR = 201,
321 PT_SDES = 202, 333 PT_SDES = 202,
322 PT_BYE = 203, 334 PT_BYE = 203,
323 PT_APP = 204, 335 PT_APP = 204,
324 PT_RTPFB = 205, 336 PT_RTPFB = 205,
325 PT_PSFB = 206, 337 PT_PSFB = 206,
326 PT_XR = 207 338 PT_XR = 207
327 }; 339 };
328 340
329 // Extended report blocks, RFC 3611. 341 // Extended report blocks, RFC 3611.
330 enum RtcpXrBlockType : uint8_t { 342 enum RtcpXrBlockType : uint8_t {
331 kBtReceiverReferenceTime = 4, 343 kBtReceiverReferenceTime = 4,
332 kBtDlrr = 5, 344 kBtDlrr = 5,
333 kBtVoipMetric = 7 345 kBtVoipMetric = 7
334 }; 346 };
335 347
336 bool RTCPParseCommonHeader(const uint8_t* ptrDataBegin, 348 bool RtcpParseCommonHeader(const uint8_t* buffer,
337 const uint8_t* ptrDataEnd, 349 size_t size_bytes,
338 RTCPCommonHeader& parsedHeader); 350 RtcpCommonHeader* parsed_header);
339 351
340 class RTCPParserV2 { 352 class RTCPParserV2 {
341 public: 353 public:
342 RTCPParserV2( 354 RTCPParserV2(
343 const uint8_t* rtcpData, 355 const uint8_t* rtcpData,
344 size_t rtcpDataLength, 356 size_t rtcpDataLength,
345 bool rtcpReducedSizeEnable); // Set to true, to allow non-compound RTCP! 357 bool rtcpReducedSizeEnable); // Set to true, to allow non-compound RTCP!
346 ~RTCPParserV2(); 358 ~RTCPParserV2();
347 359
348 RTCPPacketTypes PacketType() const; 360 RTCPPacketTypes PacketType() const;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 bool ParseIJItem(); 423 bool ParseIJItem();
412 424
413 bool ParseXr(); 425 bool ParseXr();
414 bool ParseXrItem(); 426 bool ParseXrItem();
415 bool ParseXrReceiverReferenceTimeItem(int block_length_4bytes); 427 bool ParseXrReceiverReferenceTimeItem(int block_length_4bytes);
416 bool ParseXrDlrr(int block_length_4bytes); 428 bool ParseXrDlrr(int block_length_4bytes);
417 bool ParseXrDlrrItem(); 429 bool ParseXrDlrrItem();
418 bool ParseXrVoipMetricItem(int block_length_4bytes); 430 bool ParseXrVoipMetricItem(int block_length_4bytes);
419 bool ParseXrUnsupportedBlockType(int block_length_4bytes); 431 bool ParseXrUnsupportedBlockType(int block_length_4bytes);
420 432
421 bool ParseFBCommon(const RTCPCommonHeader& header); 433 bool ParseFBCommon(const RtcpCommonHeader& header);
422 bool ParseNACKItem(); 434 bool ParseNACKItem();
423 bool ParseTMMBRItem(); 435 bool ParseTMMBRItem();
424 bool ParseTMMBNItem(); 436 bool ParseTMMBNItem();
425 bool ParseSLIItem(); 437 bool ParseSLIItem();
426 bool ParseRPSIItem(); 438 bool ParseRPSIItem();
427 bool ParseFIRItem(); 439 bool ParseFIRItem();
428 bool ParsePsfbAppItem(); 440 bool ParsePsfbAppItem();
429 bool ParsePsfbREMBItem(); 441 bool ParsePsfbREMBItem();
430 442
431 bool ParseAPP(const RTCPCommonHeader& header); 443 bool ParseAPP(const RtcpCommonHeader& header);
432 bool ParseAPPItem(); 444 bool ParseAPPItem();
433 445
434 private: 446 private:
435 const uint8_t* const _ptrRTCPDataBegin; 447 const uint8_t* const _ptrRTCPDataBegin;
436 const bool _RTCPReducedSizeEnable; 448 const bool _RTCPReducedSizeEnable;
437 const uint8_t* const _ptrRTCPDataEnd; 449 const uint8_t* const _ptrRTCPDataEnd;
438 450
439 bool _validPacket; 451 bool _validPacket;
440 const uint8_t* _ptrRTCPData; 452 const uint8_t* _ptrRTCPData;
441 const uint8_t* _ptrRTCPBlockEnd; 453 const uint8_t* _ptrRTCPBlockEnd;
442 454
443 ParseState _state; 455 ParseState _state;
444 uint8_t _numberOfBlocks; 456 uint8_t _numberOfBlocks;
445 457
446 RTCPPacketTypes _packetType; 458 RTCPPacketTypes _packetType;
447 RTCPPacket _packet; 459 RTCPPacket _packet;
448 }; 460 };
449 461
450 class RTCPPacketIterator { 462 class RTCPPacketIterator {
451 public: 463 public:
452 RTCPPacketIterator(uint8_t* rtcpData, size_t rtcpDataLength); 464 RTCPPacketIterator(uint8_t* rtcpData, size_t rtcpDataLength);
453 ~RTCPPacketIterator(); 465 ~RTCPPacketIterator();
454 466
455 const RTCPCommonHeader* Begin(); 467 const RtcpCommonHeader* Begin();
456 const RTCPCommonHeader* Iterate(); 468 const RtcpCommonHeader* Iterate();
457 const RTCPCommonHeader* Current(); 469 const RtcpCommonHeader* Current();
458 470
459 private: 471 private:
460 uint8_t* const _ptrBegin; 472 uint8_t* const _ptrBegin;
461 uint8_t* const _ptrEnd; 473 uint8_t* const _ptrEnd;
462 474
463 uint8_t* _ptrBlock; 475 uint8_t* _ptrBlock;
464 476
465 RTCPCommonHeader _header; 477 RtcpCommonHeader _header;
466 }; 478 };
467 } // RTCPUtility 479 } // RTCPUtility
468 } // namespace webrtc 480 } // namespace webrtc
469 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_UTILITY_H_ 481 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_UTILITY_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.cc ('k') | webrtc/modules/rtp_rtcp/source/rtcp_utility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698