blob: 533a0dd2c1293376da621716e2a0c3a0b31e69a3 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_
12#define MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stdint.h>
Karl Wiberg83d3ec12017-09-28 19:54:38 +020015#include <cstring>
danilchapb8b6fbb2015-12-10 05:05:27 -080016
Yves Gerey988cc082018-10-23 12:03:01 +020017#include "api/rtp_headers.h"
18#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
20#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
pbos@webrtc.org2f446732013-04-08 11:08:41 +000024const uint8_t kRtpMarkerBitMask = 0x80;
niklase@google.com470e71d2011-07-07 08:21:25 +000025
pbos@webrtc.org62bafae2014-07-08 12:10:51 +000026namespace RtpUtility {
pwestin@webrtc.org0644b1d2011-12-01 15:42:31 +000027
danilchapf6975f42015-12-28 10:18:46 -080028struct Payload {
Karl Wiberg884e49f2017-10-02 09:54:48 +020029 Payload(const char* name, const PayloadUnion& pu) : typeSpecific(pu) {
Karl Wiberg83d3ec12017-09-28 19:54:38 +020030 std::strncpy(this->name, name, sizeof(this->name) - 1);
31 this->name[sizeof(this->name) - 1] = '\0';
32 }
danilchapf6975f42015-12-28 10:18:46 -080033 char name[RTP_PAYLOAD_NAME_SIZE];
danilchapf6975f42015-12-28 10:18:46 -080034 PayloadUnion typeSpecific;
35};
pwestin@webrtc.org0644b1d2011-12-01 15:42:31 +000036
danilchapf6975f42015-12-28 10:18:46 -080037bool StringCompare(const char* str1, const char* str2, const uint32_t length);
phoglund@webrtc.org07bf43c2012-12-18 15:40:53 +000038
danilchapf6975f42015-12-28 10:18:46 -080039// Round up to the nearest size that is a multiple of 4.
40size_t Word32Align(size_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +000041
danilchapf6975f42015-12-28 10:18:46 -080042class RtpHeaderParser {
43 public:
44 RtpHeaderParser(const uint8_t* rtpData, size_t rtpDataLength);
45 ~RtpHeaderParser();
marpan@webrtc.org57353a32011-12-16 17:21:09 +000046
danilchapf6975f42015-12-28 10:18:46 -080047 bool RTCP() const;
48 bool ParseRtcp(RTPHeader* header) const;
49 bool Parse(RTPHeader* parsedPacket,
Bjorn Tereliusb2bfba62018-03-05 20:52:04 +010050 const RtpHeaderExtensionMap* ptrExtensionMap = nullptr) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000051
danilchapf6975f42015-12-28 10:18:46 -080052 private:
53 void ParseOneByteExtensionHeader(RTPHeader* parsedPacket,
54 const RtpHeaderExtensionMap* ptrExtensionMap,
55 const uint8_t* ptrRTPDataExtensionEnd,
56 const uint8_t* ptr) const;
sprang@webrtc.org30933902015-03-17 14:33:12 +000057
danilchapf6975f42015-12-28 10:18:46 -080058 const uint8_t* const _ptrRTPDataBegin;
59 const uint8_t* const _ptrRTPDataEnd;
60};
stefan@webrtc.org5a098c52014-09-17 11:58:20 +000061} // namespace RtpUtility
henrike@webrtc.orgd5657c22012-02-08 23:41:49 +000062} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000063
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020064#endif // MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_