blob: 04eb4383d3c3a51b80555e3075b845a4bf3c048b [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
Karl Wiberg83d3ec12017-09-28 19:54:38 +020014#include <cstring>
danilchapb8b6fbb2015-12-10 05:05:27 -080015#include <map>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/rtp_rtcp/include/receive_statistics.h"
18#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
19#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
20#include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
21#include "rtc_base/deprecation.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020022#include "typedefs.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000025
pbos@webrtc.org2f446732013-04-08 11:08:41 +000026const uint8_t kRtpMarkerBitMask = 0x80;
niklase@google.com470e71d2011-07-07 08:21:25 +000027
wu@webrtc.org822fbd82013-08-15 23:38:54 +000028RtpFeedback* NullObjectRtpFeedback();
wu@webrtc.org822fbd82013-08-15 23:38:54 +000029
pbos@webrtc.org62bafae2014-07-08 12:10:51 +000030namespace RtpUtility {
pwestin@webrtc.org0644b1d2011-12-01 15:42:31 +000031
danilchapf6975f42015-12-28 10:18:46 -080032struct Payload {
Karl Wiberg83d3ec12017-09-28 19:54:38 +020033 Payload(const char* name, const PayloadUnion& pu)
34 : audio(pu.is_audio()), typeSpecific(pu) {
35 std::strncpy(this->name, name, sizeof(this->name) - 1);
36 this->name[sizeof(this->name) - 1] = '\0';
37 }
danilchapf6975f42015-12-28 10:18:46 -080038 char name[RTP_PAYLOAD_NAME_SIZE];
39 bool audio;
40 PayloadUnion typeSpecific;
41};
pwestin@webrtc.org0644b1d2011-12-01 15:42:31 +000042
danilchapf6975f42015-12-28 10:18:46 -080043bool StringCompare(const char* str1, const char* str2, const uint32_t length);
phoglund@webrtc.org07bf43c2012-12-18 15:40:53 +000044
danilchapf6975f42015-12-28 10:18:46 -080045// Round up to the nearest size that is a multiple of 4.
46size_t Word32Align(size_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +000047
danilchapf6975f42015-12-28 10:18:46 -080048class RtpHeaderParser {
49 public:
50 RtpHeaderParser(const uint8_t* rtpData, size_t rtpDataLength);
51 ~RtpHeaderParser();
marpan@webrtc.org57353a32011-12-16 17:21:09 +000052
danilchapf6975f42015-12-28 10:18:46 -080053 bool RTCP() const;
54 bool ParseRtcp(RTPHeader* header) const;
55 bool Parse(RTPHeader* parsedPacket,
56 RtpHeaderExtensionMap* ptrExtensionMap = nullptr) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000057
danilchapf6975f42015-12-28 10:18:46 -080058 private:
59 void ParseOneByteExtensionHeader(RTPHeader* parsedPacket,
60 const RtpHeaderExtensionMap* ptrExtensionMap,
61 const uint8_t* ptrRTPDataExtensionEnd,
62 const uint8_t* ptr) const;
sprang@webrtc.org30933902015-03-17 14:33:12 +000063
danilchapf6975f42015-12-28 10:18:46 -080064 const uint8_t* const _ptrRTPDataBegin;
65 const uint8_t* const _ptrRTPDataEnd;
66};
stefan@webrtc.org5a098c52014-09-17 11:58:20 +000067} // namespace RtpUtility
henrike@webrtc.orgd5657c22012-02-08 23:41:49 +000068} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000069
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020070#endif // MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_