rtp_header_parser.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2013 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 TEST_RTP_HEADER_PARSER_H_
  11. #define TEST_RTP_HEADER_PARSER_H_
  12. #include <memory>
  13. #include "api/rtp_parameters.h"
  14. #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
  15. namespace webrtc {
  16. struct RTPHeader;
  17. class RtpHeaderParser {
  18. public:
  19. static std::unique_ptr<RtpHeaderParser> CreateForTest();
  20. virtual ~RtpHeaderParser() {}
  21. // Returns true if the packet is an RTCP packet, false otherwise.
  22. static bool IsRtcp(const uint8_t* packet, size_t length);
  23. static absl::optional<uint32_t> GetSsrc(const uint8_t* packet, size_t length);
  24. // Parses the packet and stores the parsed packet in |header|. Returns true on
  25. // success, false otherwise.
  26. // This method is thread-safe in the sense that it can parse multiple packets
  27. // at once.
  28. virtual bool Parse(const uint8_t* packet,
  29. size_t length,
  30. RTPHeader* header) const = 0;
  31. // Registers an RTP header extension and binds it to |id|.
  32. virtual bool RegisterRtpHeaderExtension(RTPExtensionType type,
  33. uint8_t id) = 0;
  34. // Registers an RTP header extension.
  35. virtual bool RegisterRtpHeaderExtension(RtpExtension extension) = 0;
  36. // De-registers an RTP header extension.
  37. virtual bool DeregisterRtpHeaderExtension(RTPExtensionType type) = 0;
  38. // De-registers an RTP header extension.
  39. virtual bool DeregisterRtpHeaderExtension(RtpExtension extension) = 0;
  40. };
  41. } // namespace webrtc
  42. #endif // TEST_RTP_HEADER_PARSER_H_