Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 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 | */ |
Tommi | 25eb47c | 2019-08-29 16:39:05 +0200 | [diff] [blame] | 10 | #ifndef TEST_RTP_HEADER_PARSER_H_ |
| 11 | #define TEST_RTP_HEADER_PARSER_H_ |
| 12 | |
| 13 | #include <memory> |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 14 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 15 | #include "api/rtp_parameters.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | struct RTPHeader; |
| 21 | |
| 22 | class RtpHeaderParser { |
| 23 | public: |
Tommi | 25eb47c | 2019-08-29 16:39:05 +0200 | [diff] [blame] | 24 | static std::unique_ptr<RtpHeaderParser> CreateForTest(); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 25 | virtual ~RtpHeaderParser() {} |
| 26 | |
| 27 | // Returns true if the packet is an RTCP packet, false otherwise. |
| 28 | static bool IsRtcp(const uint8_t* packet, size_t length); |
Sebastian Jansson | 1e42761 | 2019-03-05 14:25:03 +0100 | [diff] [blame] | 29 | static absl::optional<uint32_t> GetSsrc(const uint8_t* packet, size_t length); |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 30 | |
| 31 | // Parses the packet and stores the parsed packet in |header|. Returns true on |
| 32 | // success, false otherwise. |
| 33 | // This method is thread-safe in the sense that it can parse multiple packets |
| 34 | // at once. |
| 35 | virtual bool Parse(const uint8_t* packet, |
| 36 | size_t length, |
| 37 | RTPHeader* header) const = 0; |
| 38 | |
| 39 | // Registers an RTP header extension and binds it to |id|. |
| 40 | virtual bool RegisterRtpHeaderExtension(RTPExtensionType type, |
| 41 | uint8_t id) = 0; |
| 42 | |
Sebastian Jansson | fd20171 | 2018-11-12 16:44:16 +0100 | [diff] [blame] | 43 | // Registers an RTP header extension. |
| 44 | virtual bool RegisterRtpHeaderExtension(RtpExtension extension) = 0; |
| 45 | |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 46 | // De-registers an RTP header extension. |
| 47 | virtual bool DeregisterRtpHeaderExtension(RTPExtensionType type) = 0; |
Sebastian Jansson | fd20171 | 2018-11-12 16:44:16 +0100 | [diff] [blame] | 48 | |
| 49 | // De-registers an RTP header extension. |
| 50 | virtual bool DeregisterRtpHeaderExtension(RtpExtension extension) = 0; |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 51 | }; |
| 52 | } // namespace webrtc |
Tommi | 25eb47c | 2019-08-29 16:39:05 +0200 | [diff] [blame] | 53 | #endif // TEST_RTP_HEADER_PARSER_H_ |