Update remaining audio test code to not use WebRtcRTPHeader.
Bug: webrtc:5876 Change-Id: I5b1abcec4a0ef52b6dd36d1fe94dbfd3f88f28a7 Reviewed-on: https://webrtc-review.googlesource.com/c/123235 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26736}
This commit is contained in:
parent
a0b1fb9ac7
commit
bf47495979
@ -24,21 +24,20 @@ int32_t Channel::SendData(FrameType frameType,
|
||||
const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
WebRtcRTPHeader rtpInfo;
|
||||
RTPHeader rtp_header;
|
||||
int32_t status;
|
||||
size_t payloadDataSize = payloadSize;
|
||||
|
||||
rtpInfo.header.markerBit = false;
|
||||
rtpInfo.header.ssrc = 0;
|
||||
rtpInfo.header.sequenceNumber =
|
||||
rtp_header.markerBit = false;
|
||||
rtp_header.ssrc = 0;
|
||||
rtp_header.sequenceNumber =
|
||||
(external_sequence_number_ < 0)
|
||||
? _seqNo++
|
||||
: static_cast<uint16_t>(external_sequence_number_);
|
||||
rtpInfo.header.payloadType = payloadType;
|
||||
rtpInfo.header.timestamp =
|
||||
(external_send_timestamp_ < 0)
|
||||
? timeStamp
|
||||
: static_cast<uint32_t>(external_send_timestamp_);
|
||||
rtp_header.payloadType = payloadType;
|
||||
rtp_header.timestamp = (external_send_timestamp_ < 0)
|
||||
? timeStamp
|
||||
: static_cast<uint32_t>(external_send_timestamp_);
|
||||
|
||||
if (frameType == kEmptyFrame) {
|
||||
// When frame is empty, we should not transmit it. The frame size of the
|
||||
@ -75,16 +74,16 @@ int32_t Channel::SendData(FrameType frameType,
|
||||
memcpy(_payloadData, payloadData + fragmentation->fragmentationOffset[0],
|
||||
fragmentation->fragmentationLength[0]);
|
||||
payloadDataSize = fragmentation->fragmentationLength[0];
|
||||
rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0];
|
||||
rtp_header.payloadType = fragmentation->fragmentationPlType[0];
|
||||
}
|
||||
} else {
|
||||
memcpy(_payloadData, payloadData, payloadDataSize);
|
||||
if (_isStereo) {
|
||||
if (_leftChannel) {
|
||||
memcpy(&_rtpInfo, &rtpInfo, sizeof(WebRtcRTPHeader));
|
||||
_rtp_header = rtp_header;
|
||||
_leftChannel = false;
|
||||
} else {
|
||||
memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcRTPHeader));
|
||||
rtp_header = _rtp_header;
|
||||
_leftChannel = true;
|
||||
}
|
||||
}
|
||||
@ -96,7 +95,7 @@ int32_t Channel::SendData(FrameType frameType,
|
||||
}
|
||||
|
||||
if (!_isStereo) {
|
||||
CalcStatistics(rtpInfo, payloadSize);
|
||||
CalcStatistics(rtp_header, payloadSize);
|
||||
}
|
||||
_useLastFrameSize = false;
|
||||
_lastInTimestamp = timeStamp;
|
||||
@ -116,16 +115,16 @@ int32_t Channel::SendData(FrameType frameType,
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = _receiverACM->IncomingPacket(_payloadData, payloadDataSize,
|
||||
rtpInfo.header);
|
||||
status =
|
||||
_receiverACM->IncomingPacket(_payloadData, payloadDataSize, rtp_header);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// TODO(turajs): rewite this method.
|
||||
void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
|
||||
void Channel::CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize) {
|
||||
int n;
|
||||
if ((rtpInfo.header.payloadType != _lastPayloadType) &&
|
||||
if ((rtp_header.payloadType != _lastPayloadType) &&
|
||||
(_lastPayloadType != -1)) {
|
||||
// payload-type is changed.
|
||||
// we have to terminate the calculations on the previous payload type
|
||||
@ -138,12 +137,12 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
|
||||
}
|
||||
}
|
||||
}
|
||||
_lastPayloadType = rtpInfo.header.payloadType;
|
||||
_lastPayloadType = rtp_header.payloadType;
|
||||
|
||||
bool newPayload = true;
|
||||
ACMTestPayloadStats* currentPayloadStr = NULL;
|
||||
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||
if (rtpInfo.header.payloadType == _payloadStats[n].payloadType) {
|
||||
if (rtp_header.payloadType == _payloadStats[n].payloadType) {
|
||||
newPayload = false;
|
||||
currentPayloadStr = &_payloadStats[n];
|
||||
break;
|
||||
@ -154,7 +153,7 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
|
||||
if (!currentPayloadStr->newPacket) {
|
||||
if (!_useLastFrameSize) {
|
||||
_lastFrameSizeSample =
|
||||
(uint32_t)((uint32_t)rtpInfo.header.timestamp -
|
||||
(uint32_t)((uint32_t)rtp_header.timestamp -
|
||||
(uint32_t)currentPayloadStr->lastTimestamp);
|
||||
}
|
||||
assert(_lastFrameSizeSample > 0);
|
||||
@ -194,13 +193,13 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
|
||||
currentPayloadStr->lastPayloadLenByte;
|
||||
}
|
||||
// store the current values for the next time
|
||||
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
|
||||
currentPayloadStr->lastTimestamp = rtp_header.timestamp;
|
||||
currentPayloadStr->lastPayloadLenByte = payloadSize;
|
||||
} else {
|
||||
currentPayloadStr->newPacket = false;
|
||||
currentPayloadStr->lastPayloadLenByte = payloadSize;
|
||||
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
|
||||
currentPayloadStr->payloadType = rtpInfo.header.payloadType;
|
||||
currentPayloadStr->lastTimestamp = rtp_header.timestamp;
|
||||
currentPayloadStr->payloadType = rtp_header.payloadType;
|
||||
memset(currentPayloadStr->frameSizeStats, 0,
|
||||
MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats));
|
||||
}
|
||||
@ -212,8 +211,8 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
|
||||
// first packet
|
||||
_payloadStats[n].newPacket = false;
|
||||
_payloadStats[n].lastPayloadLenByte = payloadSize;
|
||||
_payloadStats[n].lastTimestamp = rtpInfo.header.timestamp;
|
||||
_payloadStats[n].payloadType = rtpInfo.header.payloadType;
|
||||
_payloadStats[n].lastTimestamp = rtp_header.timestamp;
|
||||
_payloadStats[n].payloadType = rtp_header.payloadType;
|
||||
memset(_payloadStats[n].frameSizeStats, 0,
|
||||
MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats));
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class Channel : public AudioPacketizationCallback {
|
||||
}
|
||||
|
||||
private:
|
||||
void CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize);
|
||||
void CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize);
|
||||
|
||||
AudioCodingModule* _receiverACM;
|
||||
uint16_t _seqNo;
|
||||
@ -94,7 +94,7 @@ class Channel : public AudioPacketizationCallback {
|
||||
int16_t _lastPayloadType;
|
||||
ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS];
|
||||
bool _isStereo;
|
||||
WebRtcRTPHeader _rtpInfo;
|
||||
RTPHeader _rtp_header;
|
||||
bool _leftChannel;
|
||||
uint32_t _lastInTimestamp;
|
||||
bool _useLastFrameSize;
|
||||
|
||||
@ -155,7 +155,7 @@ bool Receiver::IncomingPacket() {
|
||||
if (!_rtpStream->EndOfFile()) {
|
||||
if (_firstTime) {
|
||||
_firstTime = false;
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
||||
_payloadSizeBytes, &_nextTime);
|
||||
if (_realPayloadSizeBytes == 0) {
|
||||
if (_rtpStream->EndOfFile()) {
|
||||
@ -168,8 +168,8 @@ bool Receiver::IncomingPacket() {
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
|
||||
_rtpInfo.header));
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
|
||||
_rtpHeader));
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
||||
_payloadSizeBytes, &_nextTime);
|
||||
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
|
||||
_firstTime = true;
|
||||
|
||||
@ -84,7 +84,7 @@ class Receiver {
|
||||
AudioCodingModule* _acm;
|
||||
uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
|
||||
RTPStream* _rtpStream;
|
||||
WebRtcRTPHeader _rtpInfo;
|
||||
RTPHeader _rtpHeader;
|
||||
size_t _realPayloadSizeBytes;
|
||||
size_t _payloadSizeBytes;
|
||||
uint32_t _nextTime;
|
||||
|
||||
@ -44,7 +44,7 @@ void ReceiverWithPacketLoss::Setup(AudioCodingModule* acm,
|
||||
bool ReceiverWithPacketLoss::IncomingPacket() {
|
||||
if (!_rtpStream->EndOfFile()) {
|
||||
if (packet_counter_ == 0) {
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
||||
_payloadSizeBytes, &_nextTime);
|
||||
if (_realPayloadSizeBytes == 0) {
|
||||
if (_rtpStream->EndOfFile()) {
|
||||
@ -57,11 +57,10 @@ bool ReceiverWithPacketLoss::IncomingPacket() {
|
||||
}
|
||||
|
||||
if (!PacketLost()) {
|
||||
_acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
|
||||
_rtpInfo.header);
|
||||
_acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes, _rtpHeader);
|
||||
}
|
||||
packet_counter_++;
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
|
||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
||||
_payloadSizeBytes, &_nextTime);
|
||||
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
|
||||
packet_counter_ = 0;
|
||||
|
||||
@ -25,19 +25,19 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo,
|
||||
void RTPStream::ParseRTPHeader(RTPHeader* rtp_header,
|
||||
const uint8_t* rtpHeader) {
|
||||
rtpInfo->header.payloadType = rtpHeader[1];
|
||||
rtpInfo->header.sequenceNumber =
|
||||
rtp_header->payloadType = rtpHeader[1];
|
||||
rtp_header->sequenceNumber =
|
||||
(static_cast<uint16_t>(rtpHeader[2]) << 8) | rtpHeader[3];
|
||||
rtpInfo->header.timestamp = (static_cast<uint32_t>(rtpHeader[4]) << 24) |
|
||||
(static_cast<uint32_t>(rtpHeader[5]) << 16) |
|
||||
(static_cast<uint32_t>(rtpHeader[6]) << 8) |
|
||||
rtpHeader[7];
|
||||
rtpInfo->header.ssrc = (static_cast<uint32_t>(rtpHeader[8]) << 24) |
|
||||
(static_cast<uint32_t>(rtpHeader[9]) << 16) |
|
||||
(static_cast<uint32_t>(rtpHeader[10]) << 8) |
|
||||
rtpHeader[11];
|
||||
rtp_header->timestamp = (static_cast<uint32_t>(rtpHeader[4]) << 24) |
|
||||
(static_cast<uint32_t>(rtpHeader[5]) << 16) |
|
||||
(static_cast<uint32_t>(rtpHeader[6]) << 8) |
|
||||
rtpHeader[7];
|
||||
rtp_header->ssrc = (static_cast<uint32_t>(rtpHeader[8]) << 24) |
|
||||
(static_cast<uint32_t>(rtpHeader[9]) << 16) |
|
||||
(static_cast<uint32_t>(rtpHeader[10]) << 8) |
|
||||
rtpHeader[11];
|
||||
}
|
||||
|
||||
void RTPStream::MakeRTPheader(uint8_t* rtpHeader,
|
||||
@ -101,7 +101,7 @@ void RTPBuffer::Write(const uint8_t payloadType,
|
||||
_queueRWLock->ReleaseLockExclusive();
|
||||
}
|
||||
|
||||
size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo,
|
||||
size_t RTPBuffer::Read(RTPHeader* rtp_header,
|
||||
uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
uint32_t* offset) {
|
||||
@ -109,11 +109,11 @@ size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo,
|
||||
RTPPacket* packet = _rtpQueue.front();
|
||||
_rtpQueue.pop();
|
||||
_queueRWLock->ReleaseLockShared();
|
||||
rtpInfo->header.markerBit = 1;
|
||||
rtpInfo->header.payloadType = packet->payloadType;
|
||||
rtpInfo->header.sequenceNumber = packet->seqNo;
|
||||
rtpInfo->header.ssrc = 0;
|
||||
rtpInfo->header.timestamp = packet->timeStamp;
|
||||
rtp_header->markerBit = 1;
|
||||
rtp_header->payloadType = packet->payloadType;
|
||||
rtp_header->sequenceNumber = packet->seqNo;
|
||||
rtp_header->ssrc = 0;
|
||||
rtp_header->timestamp = packet->timeStamp;
|
||||
if (packet->payloadSize > 0 && payloadSize >= packet->payloadSize) {
|
||||
memcpy(payloadData, packet->payloadData, packet->payloadSize);
|
||||
} else {
|
||||
@ -199,7 +199,7 @@ void RTPFile::Write(const uint8_t payloadType,
|
||||
EXPECT_EQ(payloadSize, fwrite(payloadData, 1, payloadSize, _rtpFile));
|
||||
}
|
||||
|
||||
size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo,
|
||||
size_t RTPFile::Read(RTPHeader* rtp_header,
|
||||
uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
uint32_t* offset) {
|
||||
@ -220,7 +220,7 @@ size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo,
|
||||
EXPECT_GT(plen, 11);
|
||||
|
||||
EXPECT_EQ(1u, fread(rtpHeader, 12, 1, _rtpFile));
|
||||
ParseRTPHeader(rtpInfo, rtpHeader);
|
||||
ParseRTPHeader(rtp_header, rtpHeader);
|
||||
EXPECT_EQ(lengthBytes, plen + 8);
|
||||
|
||||
if (plen == 0) {
|
||||
|
||||
@ -33,7 +33,7 @@ class RTPStream {
|
||||
|
||||
// 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 size_t Read(WebRtcRTPHeader* rtpInfo,
|
||||
virtual size_t Read(RTPHeader* rtp_Header,
|
||||
uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
uint32_t* offset) = 0;
|
||||
@ -46,7 +46,7 @@ class RTPStream {
|
||||
uint32_t timeStamp,
|
||||
uint32_t ssrc);
|
||||
|
||||
void ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader);
|
||||
void ParseRTPHeader(RTPHeader* rtp_header, const uint8_t* rtpHeader);
|
||||
};
|
||||
|
||||
class RTPPacket {
|
||||
@ -81,7 +81,7 @@ class RTPBuffer : public RTPStream {
|
||||
const size_t payloadSize,
|
||||
uint32_t frequency) override;
|
||||
|
||||
size_t Read(WebRtcRTPHeader* rtpInfo,
|
||||
size_t Read(RTPHeader* rtp_header,
|
||||
uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
uint32_t* offset) override;
|
||||
@ -114,7 +114,7 @@ class RTPFile : public RTPStream {
|
||||
const size_t payloadSize,
|
||||
uint32_t frequency) override;
|
||||
|
||||
size_t Read(WebRtcRTPHeader* rtpInfo,
|
||||
size_t Read(RTPHeader* rtp_header,
|
||||
uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
uint32_t* offset) override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user