diff --git a/src/modules/audio_coding/main/test/EncodeDecodeTest.cc b/src/modules/audio_coding/main/test/EncodeDecodeTest.cc index 4afab37c8..02d1c126b 100644 --- a/src/modules/audio_coding/main/test/EncodeDecodeTest.cc +++ b/src/modules/audio_coding/main/test/EncodeDecodeTest.cc @@ -198,14 +198,15 @@ bool Receiver::IncomingPacket() { _firstTime = false; _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload, _payloadSizeBytes, &_nextTime); - if (_realPayloadSizeBytes < 0) { - printf("Error in reading incoming payload.\n"); - return false; + if (_realPayloadSizeBytes == 0) { + if (_rtpStream->EndOfFile()) { + _firstTime = true; + return true; + } else { + printf("Error in reading incoming payload.\n"); + return false; + } } - if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) { - _firstTime = true; - return true; - } } WebRtc_Word32 ok = _acm->IncomingPacket(_incomingPayload, diff --git a/src/modules/audio_coding/main/test/RTPFile.cc b/src/modules/audio_coding/main/test/RTPFile.cc index 4c71ed749..29d6a1d53 100644 --- a/src/modules/audio_coding/main/test/RTPFile.cc +++ b/src/modules/audio_coding/main/test/RTPFile.cc @@ -106,7 +106,7 @@ RTPBuffer::Write(const WebRtc_UWord8 payloadType, const WebRtc_UWord32 timeStamp WebRtc_UWord16 RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, - WebRtc_Word8* payloadData, + WebRtc_Word8* payloadData, WebRtc_UWord16 payloadSize, WebRtc_UWord32* offset) { @@ -125,7 +125,7 @@ RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, } else { - return -1; + return 0; } *offset = (packet->timeStamp/(packet->frequency/1000)); @@ -248,11 +248,11 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo, { return -1; } - lengthBytes -= 20; - if (lengthBytes < 0) + if (lengthBytes < 20) { return -1; } + lengthBytes -= 20; EXPECT_EQ(lengthBytes, fread(payloadData, 1, lengthBytes, _rtpFile)); return lengthBytes; } diff --git a/src/modules/audio_coding/main/test/RTPFile.h b/src/modules/audio_coding/main/test/RTPFile.h index 86c99a3fc..e11b16061 100644 --- a/src/modules/audio_coding/main/test/RTPFile.h +++ b/src/modules/audio_coding/main/test/RTPFile.h @@ -24,12 +24,15 @@ class RTPStream { public: virtual ~RTPStream(){} - + virtual void Write(const WebRtc_UWord8 payloadType, const WebRtc_UWord32 timeStamp, const WebRtc_Word16 seqNo, const WebRtc_UWord8* payloadData, const WebRtc_UWord16 payloadSize, WebRtc_UWord32 frequency) = 0; + + // Returns the packet's payload size. Zero should be treated as an + // end-of-stream (in the case that EndOfFile() is true) or an error. virtual WebRtc_UWord16 Read(WebRtcRTPHeader* rtpInfo, - WebRtc_Word8* payloadData, + WebRtc_Word8* payloadData, WebRtc_UWord16 payloadSize, WebRtc_UWord32* offset) = 0; virtual bool EndOfFile() const = 0; @@ -65,7 +68,7 @@ public: const WebRtc_Word16 seqNo, const WebRtc_UWord8* payloadData, const WebRtc_UWord16 payloadSize, WebRtc_UWord32 frequency); WebRtc_UWord16 Read(WebRtcRTPHeader* rtpInfo, - WebRtc_Word8* payloadData, + WebRtc_Word8* payloadData, WebRtc_UWord16 payloadSize, WebRtc_UWord32* offset); virtual bool EndOfFile() const;