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