Misc. cleanup split out of https://webrtc-codereview.appspot.com/37699004/ :
* Move constants into the files/functions that use them * Declare variables in the narrowest scope possible * Use correct (expected, actual) order for gtest macros * Remove unused functions * Untabify * 80-column limit * Avoid C-style casts * Prefer true typed constants to "enum hack" constants * Print size_t using the right format macro * Shorten and simplify code * Other random cleanup bits and style fixes BUG=none TEST=none R=henrik.lundin@webrtc.org, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/36179004 Cr-Commit-Position: refs/heads/master@{#8467} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8467 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -352,82 +352,72 @@ bool NETEQTEST_RTPpacket::isLost() const
|
||||
|
||||
uint8_t NETEQTEST_RTPpacket::payloadType() const
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
|
||||
if(_datagram && _datagramLen >= _kBasicHeaderLen)
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
parseRTPheader(&tempRTPinfo);
|
||||
return tempRTPinfo.header.payloadType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tempRTPinfo.header.payloadType;
|
||||
}
|
||||
|
||||
uint16_t NETEQTEST_RTPpacket::sequenceNumber() const
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
|
||||
if(_datagram && _datagramLen >= _kBasicHeaderLen)
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
parseRTPheader(&tempRTPinfo);
|
||||
return tempRTPinfo.header.sequenceNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tempRTPinfo.header.sequenceNumber;
|
||||
}
|
||||
|
||||
uint32_t NETEQTEST_RTPpacket::timeStamp() const
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
|
||||
if(_datagram && _datagramLen >= _kBasicHeaderLen)
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
parseRTPheader(&tempRTPinfo);
|
||||
return tempRTPinfo.header.timestamp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tempRTPinfo.header.timestamp;
|
||||
}
|
||||
|
||||
uint32_t NETEQTEST_RTPpacket::SSRC() const
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
|
||||
if(_datagram && _datagramLen >= _kBasicHeaderLen)
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
parseRTPheader(&tempRTPinfo);
|
||||
return tempRTPinfo.header.ssrc;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tempRTPinfo.header.ssrc;
|
||||
}
|
||||
|
||||
uint8_t NETEQTEST_RTPpacket::markerBit() const
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
|
||||
if(_datagram && _datagramLen >= _kBasicHeaderLen)
|
||||
{
|
||||
webrtc::WebRtcRTPHeader tempRTPinfo;
|
||||
parseRTPheader(&tempRTPinfo);
|
||||
return tempRTPinfo.header.markerBit;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tempRTPinfo.header.markerBit;
|
||||
}
|
||||
|
||||
|
||||
@ -445,7 +435,7 @@ int NETEQTEST_RTPpacket::setPayloadType(uint8_t pt)
|
||||
_rtpInfo.header.payloadType = pt;
|
||||
}
|
||||
|
||||
_datagram[1]=(unsigned char)(pt & 0xFF);
|
||||
_datagram[1] = pt;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -624,38 +614,31 @@ int NETEQTEST_RTPpacket::splitStereo(NETEQTEST_RTPpacket* slaveRtp,
|
||||
}
|
||||
|
||||
|
||||
void NETEQTEST_RTPpacket::makeRTPheader(unsigned char* rtp_data, uint8_t payloadType, uint16_t seqNo, uint32_t timestamp, uint32_t ssrc, uint8_t markerBit) const
|
||||
void NETEQTEST_RTPpacket::makeRTPheader(unsigned char* rtp_data,
|
||||
uint8_t payloadType,
|
||||
uint16_t seqNo,
|
||||
uint32_t timestamp,
|
||||
uint32_t ssrc,
|
||||
uint8_t markerBit) const
|
||||
{
|
||||
rtp_data[0]=(unsigned char)0x80;
|
||||
if (markerBit)
|
||||
{
|
||||
rtp_data[0] |= 0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
rtp_data[0] &= 0xFE;
|
||||
}
|
||||
rtp_data[1]=(unsigned char)(payloadType & 0xFF);
|
||||
rtp_data[2]=(unsigned char)((seqNo>>8)&0xFF);
|
||||
rtp_data[3]=(unsigned char)((seqNo)&0xFF);
|
||||
rtp_data[4]=(unsigned char)((timestamp>>24)&0xFF);
|
||||
rtp_data[5]=(unsigned char)((timestamp>>16)&0xFF);
|
||||
|
||||
rtp_data[6]=(unsigned char)((timestamp>>8)&0xFF);
|
||||
rtp_data[7]=(unsigned char)(timestamp & 0xFF);
|
||||
|
||||
rtp_data[8]=(unsigned char)((ssrc>>24)&0xFF);
|
||||
rtp_data[9]=(unsigned char)((ssrc>>16)&0xFF);
|
||||
|
||||
rtp_data[10]=(unsigned char)((ssrc>>8)&0xFF);
|
||||
rtp_data[11]=(unsigned char)(ssrc & 0xFF);
|
||||
rtp_data[0] = markerBit ? 0x81 : 0x80;
|
||||
rtp_data[1] = payloadType;
|
||||
rtp_data[2] = seqNo >> 8;
|
||||
rtp_data[3] = seqNo & 0xFF;
|
||||
rtp_data[4] = timestamp >> 24;
|
||||
rtp_data[5] = (timestamp >> 16) & 0xFF;
|
||||
rtp_data[6] = (timestamp >> 8) & 0xFF;
|
||||
rtp_data[7] = timestamp & 0xFF;
|
||||
rtp_data[8] = ssrc >> 24;
|
||||
rtp_data[9] = (ssrc >> 16) & 0xFF;
|
||||
rtp_data[10] = (ssrc >> 8) & 0xFF;
|
||||
rtp_data[11] = ssrc & 0xFF;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
NETEQTEST_RTPpacket::parseRTPheader(webrtc::WebRtcRTPHeader* RTPinfo,
|
||||
uint8_t **payloadPtr) const
|
||||
uint16_t NETEQTEST_RTPpacket::parseRTPheader(webrtc::WebRtcRTPHeader* RTPinfo,
|
||||
uint8_t **payloadPtr) const
|
||||
{
|
||||
int16_t *rtp_data = (int16_t *) _datagram;
|
||||
uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
|
||||
int i_P, i_X, i_CC;
|
||||
|
||||
assert(_datagramLen >= 12);
|
||||
@ -667,61 +650,54 @@ uint16_t
|
||||
|
||||
if (payloadPtr)
|
||||
{
|
||||
*payloadPtr = (uint8_t*) &rtp_data[i_startPosition >> 1];
|
||||
*payloadPtr =
|
||||
reinterpret_cast<uint8_t*>(&rtp_data[i_startPosition >> 1]);
|
||||
}
|
||||
|
||||
return (uint16_t) (_datagramLen - i_startPosition - i_padlength);
|
||||
return static_cast<uint16_t>(_datagramLen - i_startPosition - i_padlength);
|
||||
}
|
||||
|
||||
|
||||
void NETEQTEST_RTPpacket::parseBasicHeader(webrtc::WebRtcRTPHeader* RTPinfo,
|
||||
int *i_P, int *i_X, int *i_CC) const
|
||||
{
|
||||
int16_t *rtp_data = (int16_t *) _datagram;
|
||||
uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
|
||||
if (_datagramLen < 12)
|
||||
{
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
*i_P=(((uint16_t)(rtp_data[0] & 0x20))>>5); /* Extract the P bit */
|
||||
*i_X=(((uint16_t)(rtp_data[0] & 0x10))>>4); /* Extract the X bit */
|
||||
*i_CC=(uint16_t)(rtp_data[0] & 0xF); /* Get the CC number */
|
||||
/* Get the marker bit */
|
||||
RTPinfo->header.markerBit = (uint8_t) ((rtp_data[0] >> 15) & 0x01);
|
||||
/* Get the coder type */
|
||||
RTPinfo->header.payloadType = (uint8_t) ((rtp_data[0] >> 8) & 0x7F);
|
||||
/* Get the packet number */
|
||||
*i_P = (rtp_data[0] >> 5) & 0x01;
|
||||
*i_X = (rtp_data[0] >> 4) & 0x01;
|
||||
*i_CC = rtp_data[0] & 0xF;
|
||||
RTPinfo->header.markerBit = (rtp_data[0] >> 15) & 0x01;
|
||||
RTPinfo->header.payloadType = (rtp_data[0] >> 8) & 0x7F;
|
||||
RTPinfo->header.sequenceNumber =
|
||||
((( ((uint16_t)rtp_data[1]) >> 8) & 0xFF) |
|
||||
( ((uint16_t)(rtp_data[1] & 0xFF)) << 8));
|
||||
/* Get timestamp */
|
||||
RTPinfo->header.timestamp = ((((uint16_t)rtp_data[2]) & 0xFF) << 24) |
|
||||
((((uint16_t)rtp_data[2]) & 0xFF00) << 8) |
|
||||
((((uint16_t)rtp_data[3]) >> 8) & 0xFF) |
|
||||
((((uint16_t)rtp_data[3]) & 0xFF) << 8);
|
||||
/* Get the SSRC */
|
||||
RTPinfo->header.ssrc = ((((uint16_t)rtp_data[4]) & 0xFF) << 24) |
|
||||
((((uint16_t)rtp_data[4]) & 0xFF00) << 8) |
|
||||
((((uint16_t)rtp_data[5]) >> 8) & 0xFF) |
|
||||
((((uint16_t)rtp_data[5]) & 0xFF) << 8);
|
||||
(rtp_data[1] >> 8) | ((rtp_data[1] & 0xFF) << 8);
|
||||
RTPinfo->header.timestamp =
|
||||
((rtp_data[2] & 0xFF) << 24) | ((rtp_data[2] & 0xFF00) << 8) |
|
||||
(rtp_data[3] >> 8) | ((rtp_data[3] & 0xFF) << 8);
|
||||
RTPinfo->header.ssrc =
|
||||
((rtp_data[4] & 0xFF) << 24) | ((rtp_data[4] & 0xFF00) << 8) |
|
||||
(rtp_data[5] >> 8) | ((rtp_data[5] & 0xFF) << 8);
|
||||
}
|
||||
|
||||
int NETEQTEST_RTPpacket::calcHeaderLength(int i_X, int i_CC) const
|
||||
{
|
||||
int i_extlength = 0;
|
||||
int16_t *rtp_data = (int16_t *) _datagram;
|
||||
uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
|
||||
|
||||
if (i_X == 1)
|
||||
{
|
||||
// Extension header exists.
|
||||
// Find out how many int32_t it consists of.
|
||||
assert(_datagramLen > 2 * (7 + 2 * i_CC));
|
||||
if (_datagramLen > 2 * (7 + 2 * i_CC))
|
||||
int offset = 7 + 2 * i_CC;
|
||||
assert(_datagramLen > 2 * offset);
|
||||
if (_datagramLen > 2 * offset)
|
||||
{
|
||||
i_extlength = (((((uint16_t) rtp_data[7 + 2 * i_CC]) >> 8)
|
||||
& 0xFF) | (((uint16_t) (rtp_data[7 + 2 * i_CC] & 0xFF))
|
||||
<< 8)) + 1;
|
||||
i_extlength = 1 +
|
||||
(((rtp_data[offset]) >> 8) | ((rtp_data[offset] & 0xFF) << 8));
|
||||
}
|
||||
}
|
||||
|
||||
@ -730,7 +706,7 @@ int NETEQTEST_RTPpacket::calcHeaderLength(int i_X, int i_CC) const
|
||||
|
||||
int NETEQTEST_RTPpacket::calcPadLength(int i_P) const
|
||||
{
|
||||
int16_t *rtp_data = (int16_t *) _datagram;
|
||||
uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
|
||||
if (i_P == 1)
|
||||
{
|
||||
/* Padding exists. Find out how many bytes the padding consists of. */
|
||||
@ -742,7 +718,7 @@ int NETEQTEST_RTPpacket::calcPadLength(int i_P) const
|
||||
else
|
||||
{
|
||||
/* even number of bytes => last byte in lower byte */
|
||||
return ((uint16_t) rtp_data[(_datagramLen >> 1) - 1]) >> 8;
|
||||
return rtp_data[(_datagramLen >> 1) - 1] >> 8;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -838,7 +814,7 @@ int NETEQTEST_RTPpacket::extractRED(int index, webrtc::WebRtcRTPHeader& red)
|
||||
{
|
||||
// Header found.
|
||||
red.header.payloadType = ptr[0] & 0x7F;
|
||||
uint32_t offset = (ptr[1] << 6) + ((ptr[2] & 0xFC) >> 2);
|
||||
uint32_t offset = (ptr[1] << 6) + (ptr[2] >> 2);
|
||||
red.header.sequenceNumber = sequenceNumber();
|
||||
red.header.timestamp = timeStamp() - offset;
|
||||
red.header.markerBit = markerBit();
|
||||
|
||||
@ -36,7 +36,6 @@ public:
|
||||
int readFixedFromFile(FILE *fp, size_t len);
|
||||
virtual int writeToFile(FILE *fp);
|
||||
void blockPT(uint8_t pt);
|
||||
//int16_t payloadType();
|
||||
virtual void parseHeader();
|
||||
void parseHeader(webrtc::WebRtcRTPHeader* rtp_header);
|
||||
const webrtc::WebRtcRTPHeader* RTPinfo() const;
|
||||
|
||||
@ -71,15 +71,47 @@
|
||||
/* Function declarations */
|
||||
/*************************/
|
||||
|
||||
void NetEQTest_GetCodec_and_PT(char * name, webrtc::NetEqDecoder *codec, int *PT, int frameLen, int *fs, int *bitrate, int *useRed);
|
||||
int NetEQTest_init_coders(webrtc::NetEqDecoder coder, int enc_frameSize, int bitrate, int sampfreq , int vad, int numChannels);
|
||||
void defineCodecs(webrtc::NetEqDecoder *usedCodec, int *noOfCodecs );
|
||||
void NetEQTest_GetCodec_and_PT(char* name,
|
||||
webrtc::NetEqDecoder* codec,
|
||||
int* PT,
|
||||
int frameLen,
|
||||
int* fs,
|
||||
int* bitrate,
|
||||
int* useRed);
|
||||
int NetEQTest_init_coders(webrtc::NetEqDecoder coder,
|
||||
int enc_frameSize,
|
||||
int bitrate,
|
||||
int sampfreq,
|
||||
int vad,
|
||||
int numChannels);
|
||||
void defineCodecs(webrtc::NetEqDecoder* usedCodec, int* noOfCodecs);
|
||||
int NetEQTest_free_coders(webrtc::NetEqDecoder coder, int numChannels);
|
||||
int NetEQTest_encode(int coder, int16_t *indata, int frameLen, unsigned char * encoded,int sampleRate , int * vad, int useVAD, int bitrate, int numChannels);
|
||||
void makeRTPheader(unsigned char* rtp_data, int payloadType, int seqNo, uint32_t timestamp, uint32_t ssrc);
|
||||
int makeRedundantHeader(unsigned char* rtp_data, int *payloadType, int numPayloads, uint32_t *timestamp, uint16_t *blockLen,
|
||||
int seqNo, uint32_t ssrc);
|
||||
int makeDTMFpayload(unsigned char* payload_data, int Event, int End, int Volume, int Duration);
|
||||
int NetEQTest_encode(int coder,
|
||||
int16_t* indata,
|
||||
int frameLen,
|
||||
unsigned char* encoded,
|
||||
int sampleRate,
|
||||
int* vad,
|
||||
int useVAD,
|
||||
int bitrate,
|
||||
int numChannels);
|
||||
void makeRTPheader(unsigned char* rtp_data,
|
||||
int payloadType,
|
||||
int seqNo,
|
||||
uint32_t timestamp,
|
||||
uint32_t ssrc);
|
||||
int makeRedundantHeader(unsigned char* rtp_data,
|
||||
int* payloadType,
|
||||
int numPayloads,
|
||||
uint32_t* timestamp,
|
||||
uint16_t* blockLen,
|
||||
int seqNo,
|
||||
uint32_t ssrc);
|
||||
int makeDTMFpayload(unsigned char* payload_data,
|
||||
int Event,
|
||||
int End,
|
||||
int Volume,
|
||||
int Duration);
|
||||
void stereoDeInterleave(int16_t* audioSamples, int numSamples);
|
||||
void stereoInterleave(unsigned char* data, int dataLen, int stride);
|
||||
|
||||
@ -231,37 +263,37 @@ WebRtcVadInst *VAD_inst[2];
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int packet_size, fs;
|
||||
webrtc::NetEqDecoder usedCodec;
|
||||
int payloadType;
|
||||
int bitrate = 0;
|
||||
int useVAD, vad;
|
||||
int packet_size, fs;
|
||||
webrtc::NetEqDecoder usedCodec;
|
||||
int payloadType;
|
||||
int bitrate = 0;
|
||||
int useVAD, vad;
|
||||
int useRed=0;
|
||||
int len, enc_len;
|
||||
int16_t org_data[4000];
|
||||
unsigned char rtp_data[8000];
|
||||
int16_t seqNo=0xFFF;
|
||||
uint32_t ssrc=1235412312;
|
||||
uint32_t timestamp=0xAC1245;
|
||||
uint16_t length, plen;
|
||||
uint32_t offset;
|
||||
double sendtime = 0;
|
||||
int len, enc_len;
|
||||
int16_t org_data[4000];
|
||||
unsigned char rtp_data[8000];
|
||||
int16_t seqNo=0xFFF;
|
||||
uint32_t ssrc=1235412312;
|
||||
uint32_t timestamp=0xAC1245;
|
||||
uint16_t length, plen;
|
||||
uint32_t offset;
|
||||
double sendtime = 0;
|
||||
int red_PT[2] = {0};
|
||||
uint32_t red_TS[2] = {0};
|
||||
uint16_t red_len[2] = {0};
|
||||
int RTPheaderLen=12;
|
||||
uint8_t red_data[8000];
|
||||
#ifdef INSERT_OLD_PACKETS
|
||||
uint16_t old_length, old_plen;
|
||||
int old_enc_len;
|
||||
int first_old_packet=1;
|
||||
unsigned char old_rtp_data[8000];
|
||||
int packet_age=0;
|
||||
uint16_t old_length, old_plen;
|
||||
int old_enc_len;
|
||||
int first_old_packet=1;
|
||||
unsigned char old_rtp_data[8000];
|
||||
int packet_age=0;
|
||||
#endif
|
||||
#ifdef INSERT_DTMF_PACKETS
|
||||
int NTone = 1;
|
||||
int DTMFfirst = 1;
|
||||
uint32_t DTMFtimestamp;
|
||||
int NTone = 1;
|
||||
int DTMFfirst = 1;
|
||||
uint32_t DTMFtimestamp;
|
||||
bool dtmfSent = false;
|
||||
#endif
|
||||
bool usingStereo = false;
|
||||
@ -789,7 +821,13 @@ int main(int argc, char* argv[])
|
||||
/* Subfunctions */
|
||||
/****************/
|
||||
|
||||
void NetEQTest_GetCodec_and_PT(char * name, webrtc::NetEqDecoder *codec, int *PT, int frameLen, int *fs, int *bitrate, int *useRed) {
|
||||
void NetEQTest_GetCodec_and_PT(char* name,
|
||||
webrtc::NetEqDecoder* codec,
|
||||
int* PT,
|
||||
int frameLen,
|
||||
int* fs,
|
||||
int* bitrate,
|
||||
int* useRed) {
|
||||
|
||||
*bitrate = 0; /* Default bitrate setting */
|
||||
*useRed = 0; /* Default no redundancy */
|
||||
@ -1626,59 +1664,71 @@ int NetEQTest_encode(int coder, int16_t *indata, int frameLen, unsigned char * e
|
||||
|
||||
|
||||
|
||||
void makeRTPheader(unsigned char* rtp_data, int payloadType, int seqNo, uint32_t timestamp, uint32_t ssrc){
|
||||
|
||||
rtp_data[0]=(unsigned char)0x80;
|
||||
rtp_data[1]=(unsigned char)(payloadType & 0xFF);
|
||||
rtp_data[2]=(unsigned char)((seqNo>>8)&0xFF);
|
||||
rtp_data[3]=(unsigned char)((seqNo)&0xFF);
|
||||
rtp_data[4]=(unsigned char)((timestamp>>24)&0xFF);
|
||||
rtp_data[5]=(unsigned char)((timestamp>>16)&0xFF);
|
||||
|
||||
rtp_data[6]=(unsigned char)((timestamp>>8)&0xFF);
|
||||
rtp_data[7]=(unsigned char)(timestamp & 0xFF);
|
||||
|
||||
rtp_data[8]=(unsigned char)((ssrc>>24)&0xFF);
|
||||
rtp_data[9]=(unsigned char)((ssrc>>16)&0xFF);
|
||||
|
||||
rtp_data[10]=(unsigned char)((ssrc>>8)&0xFF);
|
||||
rtp_data[11]=(unsigned char)(ssrc & 0xFF);
|
||||
void makeRTPheader(unsigned char* rtp_data,
|
||||
int payloadType,
|
||||
int seqNo,
|
||||
uint32_t timestamp,
|
||||
uint32_t ssrc) {
|
||||
rtp_data[0] = 0x80;
|
||||
rtp_data[1] = payloadType & 0xFF;
|
||||
rtp_data[2] = (seqNo >> 8) & 0xFF;
|
||||
rtp_data[3] = seqNo & 0xFF;
|
||||
rtp_data[4] = timestamp >> 24;
|
||||
rtp_data[5] = (timestamp >> 16) & 0xFF;
|
||||
rtp_data[6] = (timestamp >> 8) & 0xFF;
|
||||
rtp_data[7] = timestamp & 0xFF;
|
||||
rtp_data[8] = ssrc >> 24;
|
||||
rtp_data[9] = (ssrc >> 16) & 0xFF;
|
||||
rtp_data[10] = (ssrc >> 8) & 0xFF;
|
||||
rtp_data[11] = ssrc & 0xFF;
|
||||
}
|
||||
|
||||
|
||||
int makeRedundantHeader(unsigned char* rtp_data, int *payloadType, int numPayloads, uint32_t *timestamp, uint16_t *blockLen,
|
||||
int seqNo, uint32_t ssrc)
|
||||
int makeRedundantHeader(unsigned char* rtp_data,
|
||||
int* payloadType,
|
||||
int numPayloads,
|
||||
uint32_t* timestamp,
|
||||
uint16_t* blockLen,
|
||||
int seqNo,
|
||||
uint32_t ssrc)
|
||||
{
|
||||
|
||||
int i;
|
||||
unsigned char *rtpPointer;
|
||||
unsigned char* rtpPointer;
|
||||
uint16_t offset;
|
||||
|
||||
/* first create "standard" RTP header */
|
||||
makeRTPheader(rtp_data, NETEQ_CODEC_RED_PT, seqNo, timestamp[numPayloads-1], ssrc);
|
||||
makeRTPheader(rtp_data, NETEQ_CODEC_RED_PT, seqNo, timestamp[numPayloads-1],
|
||||
ssrc);
|
||||
|
||||
rtpPointer = &rtp_data[12];
|
||||
|
||||
/* add one sub-header for each redundant payload (not the primary) */
|
||||
for(i=0; i<numPayloads-1; i++) { /* |0 1 2 3 4 5 6 7| */
|
||||
if(blockLen[i] > 0) {
|
||||
offset = (uint16_t) (timestamp[numPayloads-1] - timestamp[i]);
|
||||
for (i = 0; i < numPayloads - 1; i++) {
|
||||
if (blockLen[i] > 0) {
|
||||
offset = static_cast<uint16_t>(
|
||||
timestamp[numPayloads - 1] - timestamp[i]);
|
||||
|
||||
rtpPointer[0] = (unsigned char) ( 0x80 | (0x7F & payloadType[i]) ); /* |F| block PT | */
|
||||
rtpPointer[1] = (unsigned char) ((offset >> 6) & 0xFF); /* | timestamp- | */
|
||||
rtpPointer[2] = (unsigned char) ( ((offset & 0x3F)<<2) |
|
||||
( (blockLen[i]>>8) & 0x03 ) ); /* | -offset |bl-| */
|
||||
rtpPointer[3] = (unsigned char) ( blockLen[i] & 0xFF ); /* | -ock length | */
|
||||
// Byte |0| |1 2 | 3 |
|
||||
// Bit |0|1234567|01234567012345|6701234567|
|
||||
// |F|payload| timestamp | block |
|
||||
// | | type | offset | length |
|
||||
rtpPointer[0] = (payloadType[i] & 0x7F) | 0x80;
|
||||
rtpPointer[1] = (offset >> 6) & 0xFF;
|
||||
rtpPointer[2] =
|
||||
((offset & 0x3F) << 2) | ((blockLen[i] >> 8) & 0x03);
|
||||
rtpPointer[3] = blockLen[i] & 0xFF;
|
||||
|
||||
rtpPointer += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* last sub-header */
|
||||
rtpPointer[0]= (unsigned char) (0x00 | (0x7F&payloadType[numPayloads-1]));/* |F| block PT | */
|
||||
rtpPointer += 1;
|
||||
// Bit |0|1234567|
|
||||
// |0|payload|
|
||||
// | | type |
|
||||
rtpPointer[0] = payloadType[numPayloads - 1] & 0x7F;
|
||||
++rtpPointer;
|
||||
|
||||
return(rtpPointer - rtp_data); /* length of header in bytes */
|
||||
return rtpPointer - rtp_data; // length of header in bytes
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user