2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef NETEQTEST_RTPPACKET_H
12 #define NETEQTEST_RTPPACKET_H
16 #include "webrtc/typedefs.h"
17 #include "webrtc/modules/interface/module_common_types.h"
27 class NETEQTEST_RTPpacket
30 NETEQTEST_RTPpacket();
31 bool operator !() const { return (dataLen() < 0); };
32 virtual ~NETEQTEST_RTPpacket();
34 static int skipFileHeader(FILE *fp);
35 virtual int readFromFile(FILE *fp);
36 int readFixedFromFile(FILE *fp, size_t len);
37 virtual int writeToFile(FILE *fp);
38 void blockPT(uint8_t pt);
39 //int16_t payloadType();
40 virtual void parseHeader();
41 void parseHeader(webrtc::WebRtcRTPHeader* rtp_header);
42 const webrtc::WebRtcRTPHeader* RTPinfo() const;
43 uint8_t * datagram() const;
44 uint8_t * payload() const;
46 int16_t dataLen() const;
47 bool isParsed() const;
49 uint32_t time() const { return _receiveTime; };
51 uint8_t payloadType() const;
52 uint16_t sequenceNumber() const;
53 uint32_t timeStamp() const;
54 uint32_t SSRC() const;
55 uint8_t markerBit() const;
57 int setPayloadType(uint8_t pt);
58 int setSequenceNumber(uint16_t sn);
59 int setTimeStamp(uint32_t ts);
60 int setSSRC(uint32_t ssrc);
61 int setMarkerBit(uint8_t mb);
62 void setTime(uint32_t receiveTime) { _receiveTime = receiveTime; };
64 int setRTPheader(const webrtc::WebRtcRTPHeader* RTPinfo);
66 int splitStereo(NETEQTEST_RTPpacket* slaveRtp, enum stereoModes mode);
68 int extractRED(int index, webrtc::WebRtcRTPHeader& red);
70 void scramblePayload(void);
73 uint8_t * _payloadPtr;
77 webrtc::WebRtcRTPHeader _rtpInfo;
79 uint32_t _receiveTime;
81 std::map<uint8_t, bool> _blockList;
84 static const int _kRDHeaderLen;
85 static const int _kBasicHeaderLen;
87 void parseBasicHeader(webrtc::WebRtcRTPHeader* RTPinfo, int *i_P, int *i_X,
89 int calcHeaderLength(int i_X, int i_CC) const;
92 void makeRTPheader(unsigned char* rtp_data, uint8_t payloadType,
93 uint16_t seqNo, uint32_t timestamp,
94 uint32_t ssrc, uint8_t markerBit) const;
95 uint16_t parseRTPheader(webrtc::WebRtcRTPHeader* RTPinfo,
96 uint8_t **payloadPtr = NULL) const;
97 uint16_t parseRTPheader(uint8_t **payloadPtr = NULL)
98 { return parseRTPheader(&_rtpInfo, payloadPtr);};
99 int calcPadLength(int i_P) const;
100 void splitStereoSample(NETEQTEST_RTPpacket* slaveRtp, int stride);
101 void splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp);
102 void splitStereoDouble(NETEQTEST_RTPpacket* slaveRtp);
105 #endif //NETEQTEST_RTPPACKET_H