blob: 0afcb71fd66b8b395aa66d66e966b418d2e7453a [file] [log] [blame]
Henrik Kjellanderff761fb2015-11-04 08:31:52 +01001/*
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 */
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_
11#define MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010012
Steve Anton10542f22019-01-11 09:11:00 -080013#include "api/rtp_parameters.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010015
16namespace webrtc {
17
18struct RTPHeader;
19
20class RtpHeaderParser {
21 public:
22 static RtpHeaderParser* Create();
23 virtual ~RtpHeaderParser() {}
24
25 // Returns true if the packet is an RTCP packet, false otherwise.
26 static bool IsRtcp(const uint8_t* packet, size_t length);
Sebastian Jansson1e427612019-03-05 14:25:03 +010027 static absl::optional<uint32_t> GetSsrc(const uint8_t* packet, size_t length);
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010028
29 // Parses the packet and stores the parsed packet in |header|. Returns true on
30 // success, false otherwise.
31 // This method is thread-safe in the sense that it can parse multiple packets
32 // at once.
33 virtual bool Parse(const uint8_t* packet,
34 size_t length,
35 RTPHeader* header) const = 0;
36
37 // Registers an RTP header extension and binds it to |id|.
38 virtual bool RegisterRtpHeaderExtension(RTPExtensionType type,
39 uint8_t id) = 0;
40
Sebastian Janssonfd201712018-11-12 16:44:16 +010041 // Registers an RTP header extension.
42 virtual bool RegisterRtpHeaderExtension(RtpExtension extension) = 0;
43
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010044 // De-registers an RTP header extension.
45 virtual bool DeregisterRtpHeaderExtension(RTPExtensionType type) = 0;
Sebastian Janssonfd201712018-11-12 16:44:16 +010046
47 // De-registers an RTP header extension.
48 virtual bool DeregisterRtpHeaderExtension(RtpExtension extension) = 0;
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010049};
50} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020051#endif // MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_