Do not use recursive calling in NetEq test tools

This CL removes recursive calling in:
- NETEQTEST_DummyRTPpacket::readFromFile,
- NETEQTEST_RTPpacket::readFromFile.

The files currently exist for both NetEq3 and NetEq4, and all are
changed with this CL.

R=turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/4699004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5200 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2013-12-03 08:26:49 +00:00
parent e0034557a7
commit 5ecdef11cc
4 changed files with 256 additions and 238 deletions

View File

@@ -31,7 +31,11 @@ int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
uint16_t length, plen;
uint32_t offset;
int packetLen;
bool readNextPacket = true;
while (readNextPacket) {
readNextPacket = false;
if (fread(&length, 2, 1, fp) == 0)
{
reset();
@@ -44,7 +48,7 @@ int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
reset();
return -1;
}
int packetLen = ntohs(plen);
packetLen = ntohs(plen);
if (fread(&offset, 4, 1, fp) == 0)
{
@@ -134,13 +138,14 @@ int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
if (!_blockList.empty() && _blockList.count(payloadType()) > 0)
{
// discard this payload
return readFromFile(fp);
readNextPacket = true;
}
if (_filterSSRC && _selectSSRC != SSRC())
{
// Discard this payload.
return(readFromFile(fp));
readNextPacket = true;
}
}
return packetLen;

View File

@@ -107,7 +107,11 @@ int NETEQTEST_RTPpacket::readFromFile(FILE *fp)
uint16_t length, plen;
uint32_t offset;
int packetLen;
bool readNextPacket = true;
while (readNextPacket) {
readNextPacket = false;
if (fread(&length,2,1,fp)==0)
{
reset();
@@ -120,14 +124,15 @@ int NETEQTEST_RTPpacket::readFromFile(FILE *fp)
reset();
return(-1);
}
int packetLen = ntohs(plen);
packetLen = ntohs(plen);
if (fread(&offset,4,1,fp)==0)
{
reset();
return(-1);
}
uint32_t receiveTime = ntohl(offset); // store in local variable until we have passed the reset below
// store in local variable until we have passed the reset below
uint32_t receiveTime = ntohl(offset);
// Use length here because a plen of 0 specifies rtcp
length = (uint16_t) (length - _kRDHeaderLen);
@@ -155,14 +160,13 @@ int NETEQTEST_RTPpacket::readFromFile(FILE *fp)
if (!_blockList.empty() && _blockList.count(payloadType()) > 0)
{
// discard this payload
return(readFromFile(fp));
readNextPacket = true;
}
if (_filterSSRC && _selectSSRC != SSRC())
{
// Discard this payload.
return(readFromFile(fp));
readNextPacket = true;
}
}
return(packetLen);

View File

@@ -29,7 +29,11 @@ int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
uint16_t length, plen;
uint32_t offset;
int packetLen;
bool readNextPacket = true;
while (readNextPacket) {
readNextPacket = false;
if (fread(&length, 2, 1, fp) == 0)
{
reset();
@@ -42,7 +46,7 @@ int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
reset();
return -1;
}
int packetLen = ntohs(plen);
packetLen = ntohs(plen);
if (fread(&offset, 4, 1, fp) == 0)
{
@@ -98,8 +102,8 @@ int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
// Read extension from file
size_t readLen = newLen - _kBasicHeaderLen;
if (fread((unsigned short *) _datagram + _kBasicHeaderLen, 1, readLen,
fp) != readLen)
if (fread((unsigned short *) _datagram + _kBasicHeaderLen, 1,
readLen, fp) != readLen)
{
reset();
return -1;
@@ -126,8 +130,8 @@ int NETEQTEST_DummyRTPpacket::readFromFile(FILE *fp)
if (!_blockList.empty() && _blockList.count(payloadType()) > 0)
{
// discard this payload
return readFromFile(fp);
readNextPacket = true;
}
}
_rtpParsed = false;

View File

@@ -105,7 +105,11 @@ int NETEQTEST_RTPpacket::readFromFile(FILE *fp)
uint16_t length, plen;
uint32_t offset;
int packetLen;
bool readNextPacket = true;
while (readNextPacket) {
readNextPacket = false;
if (fread(&length,2,1,fp)==0)
{
reset();
@@ -118,14 +122,15 @@ int NETEQTEST_RTPpacket::readFromFile(FILE *fp)
reset();
return(-1);
}
int packetLen = ntohs(plen);
packetLen = ntohs(plen);
if (fread(&offset,4,1,fp)==0)
{
reset();
return(-1);
}
uint32_t receiveTime = ntohl(offset); // store in local variable until we have passed the reset below
// store in local variable until we have passed the reset below
uint32_t receiveTime = ntohl(offset);
// Use length here because a plen of 0 specifies rtcp
length = (uint16_t) (length - _kRDHeaderLen);
@@ -153,8 +158,8 @@ int NETEQTEST_RTPpacket::readFromFile(FILE *fp)
if (!_blockList.empty() && _blockList.count(payloadType()) > 0)
{
// discard this payload
return(readFromFile(fp));
readNextPacket = true;
}
}
_rtpParsed = false;