rtp_utility.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_
  11. #define MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_
  12. #include <stdint.h>
  13. #include <algorithm>
  14. #include "absl/strings/string_view.h"
  15. #include "api/rtp_headers.h"
  16. #include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
  17. #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
  18. namespace webrtc {
  19. const uint8_t kRtpMarkerBitMask = 0x80;
  20. namespace RtpUtility {
  21. // Round up to the nearest size that is a multiple of 4.
  22. size_t Word32Align(size_t size);
  23. class RtpHeaderParser {
  24. public:
  25. RtpHeaderParser(const uint8_t* rtpData, size_t rtpDataLength);
  26. ~RtpHeaderParser();
  27. bool RTCP() const;
  28. bool ParseRtcp(RTPHeader* header) const;
  29. bool Parse(RTPHeader* parsedPacket,
  30. const RtpHeaderExtensionMap* ptrExtensionMap = nullptr,
  31. bool header_only = false) const;
  32. private:
  33. void ParseOneByteExtensionHeader(RTPHeader* parsedPacket,
  34. const RtpHeaderExtensionMap* ptrExtensionMap,
  35. const uint8_t* ptrRTPDataExtensionEnd,
  36. const uint8_t* ptr) const;
  37. const uint8_t* const _ptrRTPDataBegin;
  38. const uint8_t* const _ptrRTPDataEnd;
  39. };
  40. } // namespace RtpUtility
  41. } // namespace webrtc
  42. #endif // MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_