niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Karl Wiberg | 83d3ec1 | 2017-09-28 19:54:38 +0200 | [diff] [blame] | 14 | #include <cstring> |
danilchap | b8b6fbb | 2015-12-10 05:05:27 -0800 | [diff] [blame] | 15 | #include <map> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #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 Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 22 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 26 | const uint8_t kRtpMarkerBitMask = 0x80; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 28 | RtpFeedback* NullObjectRtpFeedback(); |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 29 | |
pbos@webrtc.org | 62bafae | 2014-07-08 12:10:51 +0000 | [diff] [blame] | 30 | namespace RtpUtility { |
pwestin@webrtc.org | 0644b1d | 2011-12-01 15:42:31 +0000 | [diff] [blame] | 31 | |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 32 | struct Payload { |
Karl Wiberg | 884e49f | 2017-10-02 09:54:48 +0200 | [diff] [blame] | 33 | Payload(const char* name, const PayloadUnion& pu) : typeSpecific(pu) { |
Karl Wiberg | 83d3ec1 | 2017-09-28 19:54:38 +0200 | [diff] [blame] | 34 | std::strncpy(this->name, name, sizeof(this->name) - 1); |
| 35 | this->name[sizeof(this->name) - 1] = '\0'; |
| 36 | } |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 37 | char name[RTP_PAYLOAD_NAME_SIZE]; |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 38 | PayloadUnion typeSpecific; |
| 39 | }; |
pwestin@webrtc.org | 0644b1d | 2011-12-01 15:42:31 +0000 | [diff] [blame] | 40 | |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 41 | bool StringCompare(const char* str1, const char* str2, const uint32_t length); |
phoglund@webrtc.org | 07bf43c | 2012-12-18 15:40:53 +0000 | [diff] [blame] | 42 | |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 43 | // Round up to the nearest size that is a multiple of 4. |
| 44 | size_t Word32Align(size_t size); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 46 | class RtpHeaderParser { |
| 47 | public: |
| 48 | RtpHeaderParser(const uint8_t* rtpData, size_t rtpDataLength); |
| 49 | ~RtpHeaderParser(); |
marpan@webrtc.org | 57353a3 | 2011-12-16 17:21:09 +0000 | [diff] [blame] | 50 | |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 51 | bool RTCP() const; |
| 52 | bool ParseRtcp(RTPHeader* header) const; |
| 53 | bool Parse(RTPHeader* parsedPacket, |
| 54 | RtpHeaderExtensionMap* ptrExtensionMap = nullptr) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 56 | private: |
| 57 | void ParseOneByteExtensionHeader(RTPHeader* parsedPacket, |
| 58 | const RtpHeaderExtensionMap* ptrExtensionMap, |
| 59 | const uint8_t* ptrRTPDataExtensionEnd, |
| 60 | const uint8_t* ptr) const; |
sprang@webrtc.org | 3093390 | 2015-03-17 14:33:12 +0000 | [diff] [blame] | 61 | |
danilchap | f6975f4 | 2015-12-28 10:18:46 -0800 | [diff] [blame] | 62 | const uint8_t* const _ptrRTPDataBegin; |
| 63 | const uint8_t* const _ptrRTPDataEnd; |
| 64 | }; |
stefan@webrtc.org | 5a098c5 | 2014-09-17 11:58:20 +0000 | [diff] [blame] | 65 | } // namespace RtpUtility |
henrike@webrtc.org | d5657c2 | 2012-02-08 23:41:49 +0000 | [diff] [blame] | 66 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 68 | #endif // MODULES_RTP_RTCP_SOURCE_RTP_UTILITY_H_ |