1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_ 12 #define MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_ 13 14 #include <stdint.h> 15 16 #include <algorithm> 17 18 #include "absl/strings/string_view.h" 19 #include "api/rtp_headers.h" 20 #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" 21 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 22 23 namespace webrtc { 24 25 const uint8_t kRtpMarkerBitMask = 0x80; 26 27 namespace RtpUtility { 28 29 // Round up to the nearest size that is a multiple of 4. 30 size_t Word32Align(size_t size); 31 32 class RtpHeaderParser { 33 public: 34 RtpHeaderParser(const uint8_t* rtpData, size_t rtpDataLength); 35 ~RtpHeaderParser(); 36 37 bool RTCP() const; 38 bool ParseRtcp(RTPHeader* header) const; 39 bool Parse(RTPHeader* parsedPacket, 40 const RtpHeaderExtensionMap* ptrExtensionMap = nullptr, 41 bool header_only = false) const; 42 43 private: 44 void ParseOneByteExtensionHeader(RTPHeader* parsedPacket, 45 const RtpHeaderExtensionMap* ptrExtensionMap, 46 const uint8_t* ptrRTPDataExtensionEnd, 47 const uint8_t* ptr) const; 48 49 const uint8_t* const _ptrRTPDataBegin; 50 const uint8_t* const _ptrRTPDataEnd; 51 }; 52 } // namespace RtpUtility 53 } // namespace webrtc 54 55 #endif // MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_ 56