blob: 23c175356af2ddb13acb7d50da27e25dc02b53e8 [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
11#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_
13
danilchapb8b6fbb2015-12-10 05:05:27 -080014#include <map>
15
danilchap2df2ba72015-12-29 01:12:06 -080016#include "webrtc/base/deprecation.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010017#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
danilchapb8b6fbb2015-12-10 05:05:27 -080018#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000019#include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
20#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
21#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000024
pbos@webrtc.org2f446732013-04-08 11:08:41 +000025const uint8_t kRtpMarkerBitMask = 0x80;
niklase@google.com470e71d2011-07-07 08:21:25 +000026
wu@webrtc.org822fbd82013-08-15 23:38:54 +000027RtpData* NullObjectRtpData();
28RtpFeedback* NullObjectRtpFeedback();
29RtpAudioFeedback* NullObjectRtpAudioFeedback();
stefan@webrtc.org286fe0b2013-08-21 20:58:21 +000030ReceiveStatistics* NullObjectReceiveStatistics();
wu@webrtc.org822fbd82013-08-15 23:38:54 +000031
pbos@webrtc.org62bafae2014-07-08 12:10:51 +000032namespace RtpUtility {
pwestin@webrtc.org0644b1d2011-12-01 15:42:31 +000033
danilchapf6975f42015-12-28 10:18:46 -080034struct Payload {
35 char name[RTP_PAYLOAD_NAME_SIZE];
36 bool audio;
37 PayloadUnion typeSpecific;
38};
pwestin@webrtc.org0644b1d2011-12-01 15:42:31 +000039
danilchapf6975f42015-12-28 10:18:46 -080040typedef std::map<int8_t, Payload*> PayloadTypeMap;
niklase@google.com470e71d2011-07-07 08:21:25 +000041
danilchapf6975f42015-12-28 10:18:46 -080042bool StringCompare(const char* str1, const char* str2, const uint32_t length);
phoglund@webrtc.org07bf43c2012-12-18 15:40:53 +000043
danilchapf6975f42015-12-28 10:18:46 -080044// Round up to the nearest size that is a multiple of 4.
45size_t Word32Align(size_t size);
niklase@google.com470e71d2011-07-07 08:21:25 +000046
danilchapf6975f42015-12-28 10:18:46 -080047class RtpHeaderParser {
48 public:
49 RtpHeaderParser(const uint8_t* rtpData, size_t rtpDataLength);
50 ~RtpHeaderParser();
marpan@webrtc.org57353a32011-12-16 17:21:09 +000051
danilchapf6975f42015-12-28 10:18:46 -080052 bool RTCP() const;
53 bool ParseRtcp(RTPHeader* header) const;
54 bool Parse(RTPHeader* parsedPacket,
55 RtpHeaderExtensionMap* ptrExtensionMap = nullptr) const;
danilchap2df2ba72015-12-29 01:12:06 -080056 RTC_DEPRECATED bool Parse(
57 RTPHeader& parsedPacket, // NOLINT(runtime/references)
58 RtpHeaderExtensionMap* ptrExtensionMap = nullptr) const {
59 return Parse(&parsedPacket, ptrExtensionMap);
60 }
niklase@google.com470e71d2011-07-07 08:21:25 +000061
danilchapf6975f42015-12-28 10:18:46 -080062 private:
63 void ParseOneByteExtensionHeader(RTPHeader* parsedPacket,
64 const RtpHeaderExtensionMap* ptrExtensionMap,
65 const uint8_t* ptrRTPDataExtensionEnd,
66 const uint8_t* ptr) const;
sprang@webrtc.org30933902015-03-17 14:33:12 +000067
danilchapf6975f42015-12-28 10:18:46 -080068 uint8_t ParsePaddingBytes(const uint8_t* ptrRTPDataExtensionEnd,
69 const uint8_t* ptr) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000070
danilchapf6975f42015-12-28 10:18:46 -080071 const uint8_t* const _ptrRTPDataBegin;
72 const uint8_t* const _ptrRTPDataEnd;
73};
stefan@webrtc.org5a098c52014-09-17 11:58:20 +000074} // namespace RtpUtility
henrike@webrtc.orgd5657c22012-02-08 23:41:49 +000075} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000076
danilchapf6975f42015-12-28 10:18:46 -080077#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_