Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information. This CL was reviewed and approved in pieces in the following CLs: https://webrtc-codereview.appspot.com/24209004/ https://webrtc-codereview.appspot.com/24229004/ https://webrtc-codereview.appspot.com/24259004/ https://webrtc-codereview.appspot.com/25109004/ https://webrtc-codereview.appspot.com/26099004/ https://webrtc-codereview.appspot.com/27069004/ https://webrtc-codereview.appspot.com/27969004/ https://webrtc-codereview.appspot.com/27989004/ https://webrtc-codereview.appspot.com/29009004/ https://webrtc-codereview.appspot.com/30929004/ https://webrtc-codereview.appspot.com/30939004/ https://webrtc-codereview.appspot.com/31999004/ Committing as TBR to the original reviewers. BUG=chromium:81439 TEST=none TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom Review URL: https://webrtc-codereview.appspot.com/23129004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -120,7 +121,7 @@ int16_t WebRtcCng_Encode(CNG_enc_inst* cng_inst, int16_t* speech,
|
||||
* -1 - Error
|
||||
*/
|
||||
int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID,
|
||||
int16_t length);
|
||||
size_t length);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcCng_Generate(...)
|
||||
|
||||
@@ -411,7 +411,7 @@ int16_t WebRtcCng_Encode(CNG_enc_inst* cng_inst, int16_t* speech,
|
||||
* -1 - Error
|
||||
*/
|
||||
int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID,
|
||||
int16_t length) {
|
||||
size_t length) {
|
||||
|
||||
WebRtcCngDecInst_t* inst = (WebRtcCngDecInst_t*) cng_inst;
|
||||
int16_t refCs[WEBRTC_CNG_MAX_LPC_ORDER];
|
||||
@@ -427,7 +427,7 @@ int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID,
|
||||
if (length > (WEBRTC_CNG_MAX_LPC_ORDER + 1))
|
||||
length = WEBRTC_CNG_MAX_LPC_ORDER + 1;
|
||||
|
||||
inst->dec_order = length - 1;
|
||||
inst->dec_order = (int16_t)length - 1;
|
||||
|
||||
if (SID[0] > 93)
|
||||
SID[0] = 93;
|
||||
|
||||
@@ -113,10 +113,9 @@ void AcmReceiveTest::Run() {
|
||||
header.header = packet->header();
|
||||
header.frameType = kAudioFrameSpeech;
|
||||
memset(&header.type.Audio, 0, sizeof(RTPAudioHeader));
|
||||
EXPECT_TRUE(
|
||||
acm_->InsertPacket(packet->payload(),
|
||||
static_cast<int32_t>(packet->payload_length_bytes()),
|
||||
header))
|
||||
EXPECT_TRUE(acm_->InsertPacket(packet->payload(),
|
||||
packet->payload_length_bytes(),
|
||||
header))
|
||||
<< "Failure when inserting packet:" << std::endl
|
||||
<< " PT = " << static_cast<int>(header.header.payloadType) << std::endl
|
||||
<< " TS = " << header.header.timestamp << std::endl
|
||||
|
||||
@@ -261,7 +261,7 @@ AudioPlayoutMode AcmReceiver::PlayoutMode() const {
|
||||
|
||||
int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
const uint8_t* incoming_payload,
|
||||
int length_payload) {
|
||||
size_t length_payload) {
|
||||
uint32_t receive_timestamp = 0;
|
||||
InitialDelayManager::PacketType packet_type =
|
||||
InitialDelayManager::kUndefinedPacket;
|
||||
|
||||
@@ -67,7 +67,7 @@ class AcmReceiver {
|
||||
//
|
||||
int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
const uint8_t* incoming_payload,
|
||||
int length_payload);
|
||||
size_t length_payload);
|
||||
|
||||
//
|
||||
// Asks NetEq for 10 milliseconds of decoded audio.
|
||||
|
||||
@@ -115,12 +115,12 @@ class AcmReceiverTest : public AudioPacketizationCallback,
|
||||
}
|
||||
}
|
||||
|
||||
virtual int SendData(
|
||||
virtual int32_t SendData(
|
||||
FrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE {
|
||||
if (frame_type == kFrameEmpty)
|
||||
return 0;
|
||||
|
||||
@@ -124,7 +124,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE {
|
||||
if (frame_type == kFrameEmpty)
|
||||
return 0;
|
||||
|
||||
@@ -94,7 +94,7 @@ int32_t AcmSendTest::SendData(FrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
// Store the packet locally.
|
||||
frame_type_ = frame_type;
|
||||
|
||||
@@ -49,7 +49,7 @@ class AcmSendTest : public AudioPacketizationCallback, public PacketSource {
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
@@ -98,7 +98,7 @@ int32_t AcmSendTestOldApi::SendData(
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
// Store the packet locally.
|
||||
frame_type_ = frame_type;
|
||||
|
||||
@@ -51,7 +51,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
@@ -314,7 +314,7 @@ int AudioCodingModuleImpl::EncodeFragmentation(int fragmentation_index,
|
||||
int AudioCodingModuleImpl::ProcessDualStream() {
|
||||
uint8_t stream[kMaxNumFragmentationVectors * MAX_PAYLOAD_SIZE_BYTE];
|
||||
uint32_t current_timestamp;
|
||||
int16_t length_bytes = 0;
|
||||
size_t length_bytes = 0;
|
||||
RTPFragmentationHeader my_fragmentation;
|
||||
|
||||
uint8_t my_red_payload_type;
|
||||
@@ -336,8 +336,7 @@ int AudioCodingModuleImpl::ProcessDualStream() {
|
||||
// Nothing to send.
|
||||
return 0;
|
||||
}
|
||||
int len_bytes_previous_secondary = static_cast<int>(
|
||||
fragmentation_.fragmentationLength[2]);
|
||||
size_t len_bytes_previous_secondary = fragmentation_.fragmentationLength[2];
|
||||
assert(len_bytes_previous_secondary <= MAX_PAYLOAD_SIZE_BYTE);
|
||||
bool has_previous_payload = len_bytes_previous_secondary > 0;
|
||||
|
||||
@@ -1689,13 +1688,8 @@ int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const {
|
||||
|
||||
// Incoming packet from network parsed and ready for decode.
|
||||
int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload,
|
||||
const int payload_length,
|
||||
const size_t payload_length,
|
||||
const WebRtcRTPHeader& rtp_header) {
|
||||
if (payload_length < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
|
||||
"IncomingPacket() Error, payload-length cannot be negative");
|
||||
return -1;
|
||||
}
|
||||
int last_audio_pltype = receiver_.last_audio_payload_type();
|
||||
if (receiver_.InsertPacket(rtp_header, incoming_payload, payload_length) <
|
||||
0) {
|
||||
@@ -1797,16 +1791,9 @@ int AudioCodingModuleImpl::RegisterVADCallback(ACMVADCallback* vad_callback) {
|
||||
|
||||
// TODO(tlegrand): Modify this function to work for stereo, and add tests.
|
||||
int AudioCodingModuleImpl::IncomingPayload(const uint8_t* incoming_payload,
|
||||
int payload_length,
|
||||
size_t payload_length,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp) {
|
||||
if (payload_length < 0) {
|
||||
// Log error in trace file.
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
|
||||
"IncomingPacket() Error, payload-length cannot be negative");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We are not acquiring any lock when interacting with |aux_rtp_header_| no
|
||||
// other method uses this member variable.
|
||||
if (aux_rtp_header_ == NULL) {
|
||||
@@ -1960,7 +1947,7 @@ int AudioCodingModuleImpl::REDPayloadISAC(int isac_rate,
|
||||
}
|
||||
|
||||
void AudioCodingModuleImpl::ResetFragmentation(int vector_size) {
|
||||
for (int n = 0; n < kMaxNumFragmentationVectors; n++) {
|
||||
for (size_t n = 0; n < kMaxNumFragmentationVectors; n++) {
|
||||
fragmentation_.fragmentationOffset[n] = n * MAX_PAYLOAD_SIZE_BYTE;
|
||||
}
|
||||
memset(fragmentation_.fragmentationLength, 0, kMaxNumFragmentationVectors *
|
||||
@@ -2116,14 +2103,14 @@ bool AudioCodingImpl::RegisterReceiveCodec(int decoder_type,
|
||||
}
|
||||
|
||||
bool AudioCodingImpl::InsertPacket(const uint8_t* incoming_payload,
|
||||
int32_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const WebRtcRTPHeader& rtp_info) {
|
||||
return acm_old_->IncomingPacket(
|
||||
incoming_payload, payload_len_bytes, rtp_info) == 0;
|
||||
}
|
||||
|
||||
bool AudioCodingImpl::InsertPayload(const uint8_t* incoming_payload,
|
||||
int32_t payload_len_byte,
|
||||
size_t payload_len_byte,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp) {
|
||||
FATAL() << "Not implemented yet.";
|
||||
|
||||
@@ -156,13 +156,13 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
|
||||
// Incoming packet from network parsed and ready for decode.
|
||||
virtual int IncomingPacket(const uint8_t* incoming_payload,
|
||||
int payload_length,
|
||||
const size_t payload_length,
|
||||
const WebRtcRTPHeader& rtp_info) OVERRIDE;
|
||||
|
||||
// Incoming payloads, without rtp-info, the rtp-info will be created in ACM.
|
||||
// One usage for this API is when pre-encoded files are pushed in ACM.
|
||||
virtual int IncomingPayload(const uint8_t* incoming_payload,
|
||||
int payload_length,
|
||||
const size_t payload_length,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp) OVERRIDE;
|
||||
|
||||
@@ -423,11 +423,11 @@ class AudioCodingImpl : public AudioCoding {
|
||||
uint8_t payload_type) OVERRIDE;
|
||||
|
||||
virtual bool InsertPacket(const uint8_t* incoming_payload,
|
||||
int32_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const WebRtcRTPHeader& rtp_info) OVERRIDE;
|
||||
|
||||
virtual bool InsertPayload(const uint8_t* incoming_payload,
|
||||
int32_t payload_len_byte,
|
||||
size_t payload_len_byte,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp) OVERRIDE;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ const int kSampleRateHz = 16000;
|
||||
const int kNumSamples10ms = kSampleRateHz / 100;
|
||||
const int kFrameSizeMs = 10; // Multiple of 10.
|
||||
const int kFrameSizeSamples = kFrameSizeMs / 10 * kNumSamples10ms;
|
||||
const int kPayloadSizeBytes = kFrameSizeSamples * sizeof(int16_t);
|
||||
const size_t kPayloadSizeBytes = kFrameSizeSamples * sizeof(int16_t);
|
||||
const uint8_t kPayloadType = 111;
|
||||
|
||||
class RtpUtility {
|
||||
@@ -87,7 +87,7 @@ class PacketizationCallbackStub : public AudioPacketizationCallback {
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
++num_calls_;
|
||||
|
||||
@@ -87,7 +87,7 @@ class PacketizationCallbackStub : public AudioPacketizationCallback {
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
++num_calls_;
|
||||
|
||||
@@ -36,13 +36,12 @@ class AudioPacketizationCallback {
|
||||
public:
|
||||
virtual ~AudioPacketizationCallback() {}
|
||||
|
||||
virtual int32_t SendData(
|
||||
FrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) = 0;
|
||||
virtual int32_t SendData(FrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) = 0;
|
||||
};
|
||||
|
||||
// Callback class used for inband Dtmf detection
|
||||
@@ -668,8 +667,8 @@ class AudioCodingModule: public Module {
|
||||
// 0 if payload is successfully pushed in.
|
||||
//
|
||||
virtual int32_t IncomingPacket(const uint8_t* incoming_payload,
|
||||
const int32_t payload_len_bytes,
|
||||
const WebRtcRTPHeader& rtp_info) = 0;
|
||||
const size_t payload_len_bytes,
|
||||
const WebRtcRTPHeader& rtp_info) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int32_t IncomingPayload()
|
||||
@@ -696,9 +695,9 @@ class AudioCodingModule: public Module {
|
||||
// 0 if payload is successfully pushed in.
|
||||
//
|
||||
virtual int32_t IncomingPayload(const uint8_t* incoming_payload,
|
||||
const int32_t payload_len_byte,
|
||||
const uint8_t payload_type,
|
||||
const uint32_t timestamp = 0) = 0;
|
||||
const size_t payload_len_byte,
|
||||
const uint8_t payload_type,
|
||||
const uint32_t timestamp = 0) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int SetMinimumPlayoutDelay()
|
||||
@@ -1090,12 +1089,12 @@ class AudioCoding {
|
||||
// |incoming_payload| contains the RTP payload after the RTP header. Return
|
||||
// true if successful, false if not.
|
||||
virtual bool InsertPacket(const uint8_t* incoming_payload,
|
||||
int32_t payload_len_bytes,
|
||||
size_t payload_len_bytes,
|
||||
const WebRtcRTPHeader& rtp_info) = 0;
|
||||
|
||||
// TODO(henrik.lundin): Remove this method?
|
||||
virtual bool InsertPayload(const uint8_t* incoming_payload,
|
||||
int32_t payload_len_byte,
|
||||
size_t payload_len_byte,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp) = 0;
|
||||
|
||||
|
||||
@@ -13,18 +13,21 @@
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType,
|
||||
const uint32_t timeStamp, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize,
|
||||
int32_t Channel::SendData(FrameType frameType,
|
||||
uint8_t payloadType,
|
||||
uint32_t timeStamp,
|
||||
const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
WebRtcRTPHeader rtpInfo;
|
||||
int32_t status;
|
||||
uint16_t payloadDataSize = payloadSize;
|
||||
size_t payloadDataSize = payloadSize;
|
||||
|
||||
rtpInfo.header.markerBit = false;
|
||||
rtpInfo.header.ssrc = 0;
|
||||
@@ -52,8 +55,8 @@ int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType,
|
||||
(fragmentation->fragmentationVectorSize == 2)) {
|
||||
// only 0x80 if we have multiple blocks
|
||||
_payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1];
|
||||
uint32_t REDheader = (((uint32_t) fragmentation->fragmentationTimeDiff[1])
|
||||
<< 10) + fragmentation->fragmentationLength[1];
|
||||
size_t REDheader = (fragmentation->fragmentationTimeDiff[1] << 10) +
|
||||
fragmentation->fragmentationLength[1];
|
||||
_payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF);
|
||||
_payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF);
|
||||
_payloadData[3] = uint8_t(REDheader & 0x000000FF);
|
||||
@@ -72,7 +75,7 @@ int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType,
|
||||
// single block (newest one)
|
||||
memcpy(_payloadData, payloadData + fragmentation->fragmentationOffset[0],
|
||||
fragmentation->fragmentationLength[0]);
|
||||
payloadDataSize = uint16_t(fragmentation->fragmentationLength[0]);
|
||||
payloadDataSize = fragmentation->fragmentationLength[0];
|
||||
rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0];
|
||||
}
|
||||
} else {
|
||||
@@ -121,7 +124,7 @@ int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType,
|
||||
}
|
||||
|
||||
// TODO(turajs): rewite this method.
|
||||
void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize) {
|
||||
void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
|
||||
int n;
|
||||
if ((rtpInfo.header.payloadType != _lastPayloadType)
|
||||
&& (_lastPayloadType != -1)) {
|
||||
@@ -371,7 +374,7 @@ void Channel::PrintStats(CodecInst& codecInst) {
|
||||
payloadStats.frameSizeStats[k].frameSizeSample);
|
||||
printf("Average Rate.................. %.0f bits/sec\n",
|
||||
payloadStats.frameSizeStats[k].rateBitPerSec);
|
||||
printf("Maximum Payload-Size.......... %d Bytes\n",
|
||||
printf("Maximum Payload-Size.......... %" PRIuS " Bytes\n",
|
||||
payloadStats.frameSizeStats[k].maxPayloadLen);
|
||||
printf(
|
||||
"Maximum Instantaneous Rate.... %.0f bits/sec\n",
|
||||
|
||||
@@ -27,7 +27,7 @@ class CriticalSectionWrapper;
|
||||
// TODO(turajs): Write constructor for this structure.
|
||||
struct ACMTestFrameSizeStats {
|
||||
uint16_t frameSizeSample;
|
||||
int16_t maxPayloadLen;
|
||||
size_t maxPayloadLen;
|
||||
uint32_t numPackets;
|
||||
uint64_t totalPayloadLenByte;
|
||||
uint64_t totalEncodedSamples;
|
||||
@@ -39,7 +39,7 @@ struct ACMTestFrameSizeStats {
|
||||
struct ACMTestPayloadStats {
|
||||
bool newPacket;
|
||||
int16_t payloadType;
|
||||
int16_t lastPayloadLenByte;
|
||||
size_t lastPayloadLenByte;
|
||||
uint32_t lastTimestamp;
|
||||
ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
|
||||
};
|
||||
@@ -51,9 +51,11 @@ class Channel : public AudioPacketizationCallback {
|
||||
~Channel();
|
||||
|
||||
virtual int32_t SendData(
|
||||
const FrameType frameType, const uint8_t payloadType,
|
||||
const uint32_t timeStamp, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize,
|
||||
FrameType frameType,
|
||||
uint8_t payloadType,
|
||||
uint32_t timeStamp,
|
||||
const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE;
|
||||
|
||||
void RegisterReceiverACM(AudioCodingModule *acm);
|
||||
@@ -93,7 +95,7 @@ class Channel : public AudioPacketizationCallback {
|
||||
}
|
||||
|
||||
private:
|
||||
void CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize);
|
||||
void CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize);
|
||||
|
||||
AudioCodingModule* _receiverACM;
|
||||
uint16_t _seqNo;
|
||||
|
||||
@@ -37,7 +37,7 @@ TestPacketization::~TestPacketization() {
|
||||
int32_t TestPacketization::SendData(
|
||||
const FrameType /* frameType */, const uint8_t payloadType,
|
||||
const uint32_t timeStamp, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize,
|
||||
const size_t payloadSize,
|
||||
const RTPFragmentationHeader* /* fragmentation */) {
|
||||
_rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize,
|
||||
_frequency);
|
||||
|
||||
@@ -30,9 +30,11 @@ class TestPacketization : public AudioPacketizationCallback {
|
||||
TestPacketization(RTPStream *rtpStream, uint16_t frequency);
|
||||
~TestPacketization();
|
||||
virtual int32_t SendData(
|
||||
const FrameType frameType, const uint8_t payloadType,
|
||||
const uint32_t timeStamp, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize,
|
||||
const FrameType frameType,
|
||||
const uint8_t payloadType,
|
||||
const uint32_t timeStamp,
|
||||
const uint8_t* payloadData,
|
||||
const size_t payloadSize,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE;
|
||||
|
||||
private:
|
||||
@@ -92,8 +94,8 @@ class Receiver {
|
||||
uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
|
||||
RTPStream* _rtpStream;
|
||||
WebRtcRTPHeader _rtpInfo;
|
||||
uint16_t _realPayloadSizeBytes;
|
||||
uint16_t _payloadSizeBytes;
|
||||
size_t _realPayloadSizeBytes;
|
||||
size_t _payloadSizeBytes;
|
||||
uint32_t _nextTime;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "RTPFile.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <Winsock2.h>
|
||||
@@ -60,7 +61,7 @@ void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType,
|
||||
}
|
||||
|
||||
RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
|
||||
const uint8_t* payloadData, uint16_t payloadSize,
|
||||
const uint8_t* payloadData, size_t payloadSize,
|
||||
uint32_t frequency)
|
||||
: payloadType(payloadType),
|
||||
timeStamp(timeStamp),
|
||||
@@ -87,7 +88,7 @@ RTPBuffer::~RTPBuffer() {
|
||||
|
||||
void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||
const int16_t seqNo, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize, uint32_t frequency) {
|
||||
const size_t payloadSize, uint32_t frequency) {
|
||||
RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData,
|
||||
payloadSize, frequency);
|
||||
_queueRWLock->AcquireLockExclusive();
|
||||
@@ -95,8 +96,8 @@ void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||
_queueRWLock->ReleaseLockExclusive();
|
||||
}
|
||||
|
||||
uint16_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
uint16_t payloadSize, uint32_t* offset) {
|
||||
size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
size_t payloadSize, uint32_t* offset) {
|
||||
_queueRWLock->AcquireLockShared();
|
||||
RTPPacket *packet = _rtpQueue.front();
|
||||
_rtpQueue.pop();
|
||||
@@ -143,21 +144,11 @@ void RTPFile::WriteHeader() {
|
||||
fprintf(_rtpFile, "#!RTPencode%s\n", "1.0");
|
||||
uint32_t dummy_variable = 0;
|
||||
// should be converted to network endian format, but does not matter when 0
|
||||
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile));
|
||||
EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile));
|
||||
EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile));
|
||||
EXPECT_EQ(1u, fwrite(&dummy_variable, 2, 1, _rtpFile));
|
||||
EXPECT_EQ(1u, fwrite(&dummy_variable, 2, 1, _rtpFile));
|
||||
fflush(_rtpFile);
|
||||
}
|
||||
|
||||
@@ -180,35 +171,26 @@ void RTPFile::ReadHeader() {
|
||||
|
||||
void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||
const int16_t seqNo, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize, uint32_t frequency) {
|
||||
const size_t payloadSize, uint32_t frequency) {
|
||||
/* write RTP packet to file */
|
||||
uint8_t rtpHeader[12];
|
||||
MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0);
|
||||
uint16_t lengthBytes = htons(12 + payloadSize + 8);
|
||||
uint16_t plen = htons(12 + payloadSize);
|
||||
ASSERT_LE(12 + payloadSize + 8, std::numeric_limits<u_short>::max());
|
||||
uint16_t lengthBytes = htons(static_cast<u_short>(12 + payloadSize + 8));
|
||||
uint16_t plen = htons(static_cast<u_short>(12 + payloadSize));
|
||||
uint32_t offsetMs;
|
||||
|
||||
offsetMs = (timeStamp / (frequency / 1000));
|
||||
offsetMs = htonl(offsetMs);
|
||||
if (fwrite(&lengthBytes, 2, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(&plen, 2, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(&offsetMs, 4, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(rtpHeader, 12, 1, _rtpFile) != 1) {
|
||||
return;
|
||||
}
|
||||
if (fwrite(payloadData, 1, payloadSize, _rtpFile) != payloadSize) {
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(1u, fwrite(&lengthBytes, 2, 1, _rtpFile));
|
||||
EXPECT_EQ(1u, fwrite(&plen, 2, 1, _rtpFile));
|
||||
EXPECT_EQ(1u, fwrite(&offsetMs, 4, 1, _rtpFile));
|
||||
EXPECT_EQ(1u, fwrite(&rtpHeader, 12, 1, _rtpFile));
|
||||
EXPECT_EQ(payloadSize, fwrite(payloadData, 1, payloadSize, _rtpFile));
|
||||
}
|
||||
|
||||
uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
uint16_t payloadSize, uint32_t* offset) {
|
||||
size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
size_t payloadSize, uint32_t* offset) {
|
||||
uint16_t lengthBytes;
|
||||
uint16_t plen;
|
||||
uint8_t rtpHeader[12];
|
||||
@@ -237,7 +219,7 @@ uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
if (lengthBytes < 20) {
|
||||
return 0;
|
||||
}
|
||||
if (payloadSize < (lengthBytes - 20)) {
|
||||
if (payloadSize < static_cast<size_t>((lengthBytes - 20))) {
|
||||
return 0;
|
||||
}
|
||||
lengthBytes -= 20;
|
||||
|
||||
@@ -28,12 +28,12 @@ class RTPStream {
|
||||
|
||||
virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||
const int16_t seqNo, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize, uint32_t frequency) = 0;
|
||||
const size_t payloadSize, uint32_t 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 uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
uint16_t payloadSize, uint32_t* offset) = 0;
|
||||
virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
size_t payloadSize, uint32_t* offset) = 0;
|
||||
virtual bool EndOfFile() const = 0;
|
||||
|
||||
protected:
|
||||
@@ -46,7 +46,7 @@ class RTPStream {
|
||||
class RTPPacket {
|
||||
public:
|
||||
RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
|
||||
const uint8_t* payloadData, uint16_t payloadSize,
|
||||
const uint8_t* payloadData, size_t payloadSize,
|
||||
uint32_t frequency);
|
||||
|
||||
~RTPPacket();
|
||||
@@ -55,7 +55,7 @@ class RTPPacket {
|
||||
uint32_t timeStamp;
|
||||
int16_t seqNo;
|
||||
uint8_t* payloadData;
|
||||
uint16_t payloadSize;
|
||||
size_t payloadSize;
|
||||
uint32_t frequency;
|
||||
};
|
||||
|
||||
@@ -67,10 +67,10 @@ class RTPBuffer : public RTPStream {
|
||||
|
||||
virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||
const int16_t seqNo, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize, uint32_t frequency) OVERRIDE;
|
||||
const size_t payloadSize, uint32_t frequency) OVERRIDE;
|
||||
|
||||
virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
uint16_t payloadSize, uint32_t* offset) OVERRIDE;
|
||||
virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
size_t payloadSize, uint32_t* offset) OVERRIDE;
|
||||
|
||||
virtual bool EndOfFile() const OVERRIDE;
|
||||
|
||||
@@ -99,10 +99,10 @@ class RTPFile : public RTPStream {
|
||||
|
||||
virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||
const int16_t seqNo, const uint8_t* payloadData,
|
||||
const uint16_t payloadSize, uint32_t frequency) OVERRIDE;
|
||||
const size_t payloadSize, uint32_t frequency) OVERRIDE;
|
||||
|
||||
virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
uint16_t payloadSize, uint32_t* offset) OVERRIDE;
|
||||
virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||
size_t payloadSize, uint32_t* offset) OVERRIDE;
|
||||
|
||||
virtual bool EndOfFile() const OVERRIDE {
|
||||
return _rtpEOF;
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/test/TestAllCodecs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@@ -32,6 +33,10 @@
|
||||
// The test loops through all available mono codecs, encode at "a" sends over
|
||||
// the channel, and decodes at "b".
|
||||
|
||||
namespace {
|
||||
const size_t kVariableSize = std::numeric_limits<size_t>::max();
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Class for simulating packet handling.
|
||||
@@ -54,7 +59,7 @@ void TestPack::RegisterReceiverACM(AudioCodingModule* acm) {
|
||||
|
||||
int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type,
|
||||
uint32_t timestamp, const uint8_t* payload_data,
|
||||
uint16_t payload_size,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
WebRtcRTPHeader rtp_info;
|
||||
int32_t status;
|
||||
@@ -87,7 +92,7 @@ int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type,
|
||||
return status;
|
||||
}
|
||||
|
||||
uint16_t TestPack::payload_size() {
|
||||
size_t TestPack::payload_size() {
|
||||
return payload_size_;
|
||||
}
|
||||
|
||||
@@ -459,13 +464,13 @@ void TestAllCodecs::Perform() {
|
||||
test_count_++;
|
||||
OpenOutFile(test_count_);
|
||||
char codec_isac[] = "ISAC";
|
||||
RegisterSendCodec('A', codec_isac, 16000, -1, 480, -1);
|
||||
RegisterSendCodec('A', codec_isac, 16000, -1, 480, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 16000, -1, 960, -1);
|
||||
RegisterSendCodec('A', codec_isac, 16000, -1, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 16000, 15000, 480, -1);
|
||||
RegisterSendCodec('A', codec_isac, 16000, 15000, 480, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 16000, 32000, 960, -1);
|
||||
RegisterSendCodec('A', codec_isac, 16000, 32000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
outfile_b_.Close();
|
||||
#endif
|
||||
@@ -475,13 +480,13 @@ void TestAllCodecs::Perform() {
|
||||
}
|
||||
test_count_++;
|
||||
OpenOutFile(test_count_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, -1, 960, -1);
|
||||
RegisterSendCodec('A', codec_isac, 32000, -1, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 56000, 960, -1);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 56000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 37000, 960, -1);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 37000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 32000, 960, -1);
|
||||
RegisterSendCodec('A', codec_isac, 32000, 32000, 960, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
outfile_b_.Close();
|
||||
#endif
|
||||
@@ -611,19 +616,19 @@ void TestAllCodecs::Perform() {
|
||||
test_count_++;
|
||||
OpenOutFile(test_count_);
|
||||
char codec_opus[] = "OPUS";
|
||||
RegisterSendCodec('A', codec_opus, 48000, 6000, 480, -1);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 6000, 480, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, -1);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, -1);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 48000, 480, -1);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 48000, 480, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, -1);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, -1);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, -1);
|
||||
RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, kVariableSize);
|
||||
Run(channel_a_to_b_);
|
||||
outfile_b_.Close();
|
||||
#endif
|
||||
@@ -686,10 +691,11 @@ void TestAllCodecs::Perform() {
|
||||
// packet_size - packet size in samples
|
||||
// extra_byte - if extra bytes needed compared to the bitrate
|
||||
// used when registering, can be an internal header
|
||||
// set to -1 if the codec is a variable rate codec
|
||||
// set to kVariableSize if the codec is a variable
|
||||
// rate codec
|
||||
void TestAllCodecs::RegisterSendCodec(char side, char* codec_name,
|
||||
int32_t sampling_freq_hz, int rate,
|
||||
int packet_size, int extra_byte) {
|
||||
int packet_size, size_t extra_byte) {
|
||||
if (test_mode_ != 0) {
|
||||
// Print out codec and settings.
|
||||
printf("codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name,
|
||||
@@ -711,14 +717,14 @@ void TestAllCodecs::RegisterSendCodec(char side, char* codec_name,
|
||||
|
||||
// Store the expected packet size in bytes, used to validate the received
|
||||
// packet. If variable rate codec (extra_byte == -1), set to -1.
|
||||
if (extra_byte != -1) {
|
||||
if (extra_byte != kVariableSize) {
|
||||
// Add 0.875 to always round up to a whole byte
|
||||
packet_size_bytes_ = static_cast<int>(static_cast<float>(packet_size
|
||||
* rate) / static_cast<float>(sampling_freq_hz * 8) + 0.875)
|
||||
+ extra_byte;
|
||||
packet_size_bytes_ = static_cast<size_t>(
|
||||
static_cast<float>(packet_size * rate) /
|
||||
static_cast<float>(sampling_freq_hz * 8) + 0.875) + extra_byte;
|
||||
} else {
|
||||
// Packets will have a variable size.
|
||||
packet_size_bytes_ = -1;
|
||||
packet_size_bytes_ = kVariableSize;
|
||||
}
|
||||
|
||||
// Set pointer to the ACM where to register the codec.
|
||||
@@ -751,7 +757,7 @@ void TestAllCodecs::Run(TestPack* channel) {
|
||||
AudioFrame audio_frame;
|
||||
|
||||
int32_t out_freq_hz = outfile_b_.SamplingFrequency();
|
||||
uint16_t receive_size;
|
||||
size_t receive_size;
|
||||
uint32_t timestamp_diff;
|
||||
channel->reset_payload_size();
|
||||
int error_count = 0;
|
||||
@@ -768,8 +774,8 @@ void TestAllCodecs::Run(TestPack* channel) {
|
||||
// Verify that the received packet size matches the settings.
|
||||
receive_size = channel->payload_size();
|
||||
if (receive_size) {
|
||||
if ((static_cast<int>(receive_size) != packet_size_bytes_) &&
|
||||
(packet_size_bytes_ > -1)) {
|
||||
if ((receive_size != packet_size_bytes_) &&
|
||||
(packet_size_bytes_ != kVariableSize)) {
|
||||
error_count++;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,14 @@ class TestPack : public AudioPacketizationCallback {
|
||||
void RegisterReceiverACM(AudioCodingModule* acm);
|
||||
|
||||
virtual int32_t SendData(
|
||||
FrameType frame_type, uint8_t payload_type,
|
||||
uint32_t timestamp, const uint8_t* payload_data,
|
||||
uint16_t payload_size,
|
||||
FrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE;
|
||||
|
||||
uint16_t payload_size();
|
||||
size_t payload_size();
|
||||
uint32_t timestamp_diff();
|
||||
void reset_payload_size();
|
||||
|
||||
@@ -45,7 +47,7 @@ class TestPack : public AudioPacketizationCallback {
|
||||
uint32_t timestamp_diff_;
|
||||
uint32_t last_in_timestamp_;
|
||||
uint64_t total_bytes_;
|
||||
uint16_t payload_size_;
|
||||
size_t payload_size_;
|
||||
};
|
||||
|
||||
class TestAllCodecs : public ACMTest {
|
||||
@@ -61,7 +63,7 @@ class TestAllCodecs : public ACMTest {
|
||||
// This is useful for codecs which support several sampling frequency.
|
||||
// Note! Only mono mode is tested in this test.
|
||||
void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz,
|
||||
int rate, int packet_size, int extra_byte);
|
||||
int rate, int packet_size, size_t extra_byte);
|
||||
|
||||
void Run(TestPack* channel);
|
||||
void OpenOutFile(int test_number);
|
||||
@@ -75,7 +77,7 @@ class TestAllCodecs : public ACMTest {
|
||||
PCMFile outfile_b_;
|
||||
int test_count_;
|
||||
int packet_size_samples_;
|
||||
int packet_size_bytes_;
|
||||
size_t packet_size_bytes_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -48,7 +48,7 @@ int32_t TestPackStereo::SendData(const FrameType frame_type,
|
||||
const uint8_t payload_type,
|
||||
const uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
const uint16_t payload_size,
|
||||
const size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
WebRtcRTPHeader rtp_info;
|
||||
int32_t status = 0;
|
||||
@@ -114,18 +114,26 @@ TestStereo::TestStereo(int test_mode)
|
||||
test_cntr_(0),
|
||||
pack_size_samp_(0),
|
||||
pack_size_bytes_(0),
|
||||
counter_(0),
|
||||
g722_pltype_(0),
|
||||
l16_8khz_pltype_(-1),
|
||||
l16_16khz_pltype_(-1),
|
||||
l16_32khz_pltype_(-1),
|
||||
pcma_pltype_(-1),
|
||||
pcmu_pltype_(-1),
|
||||
celt_pltype_(-1),
|
||||
opus_pltype_(-1),
|
||||
cn_8khz_pltype_(-1),
|
||||
cn_16khz_pltype_(-1),
|
||||
cn_32khz_pltype_(-1) {
|
||||
counter_(0)
|
||||
#ifdef WEBRTC_CODEC_G722
|
||||
, g722_pltype_(0)
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_PCM16
|
||||
, l16_8khz_pltype_(-1)
|
||||
, l16_16khz_pltype_(-1)
|
||||
, l16_32khz_pltype_(-1)
|
||||
#endif
|
||||
#ifdef PCMA_AND_PCMU
|
||||
, pcma_pltype_(-1)
|
||||
, pcmu_pltype_(-1)
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
, celt_pltype_(-1)
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
, opus_pltype_(-1)
|
||||
#endif
|
||||
{
|
||||
// test_mode = 0 for silent test (auto test)
|
||||
test_mode_ = test_mode;
|
||||
}
|
||||
@@ -302,7 +310,6 @@ void TestStereo::Perform() {
|
||||
Run(channel_a2b_, audio_channels, codec_channels);
|
||||
out_file_.Close();
|
||||
#endif
|
||||
#define PCMA_AND_PCMU
|
||||
#ifdef PCMA_AND_PCMU
|
||||
if (test_mode_ != 0) {
|
||||
printf("===========================================================\n");
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "webrtc/modules/audio_coding/main/test/Channel.h"
|
||||
#include "webrtc/modules/audio_coding/main/test/PCMFile.h"
|
||||
|
||||
#define PCMA_AND_PCMU
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
enum StereoMonoMode {
|
||||
@@ -38,7 +40,7 @@ class TestPackStereo : public AudioPacketizationCallback {
|
||||
const uint8_t payload_type,
|
||||
const uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
const uint16_t payload_size,
|
||||
const size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE;
|
||||
|
||||
uint16_t payload_size();
|
||||
@@ -78,11 +80,6 @@ class TestStereo : public ACMTest {
|
||||
void OpenOutFile(int16_t test_number);
|
||||
void DisplaySendReceiveCodec();
|
||||
|
||||
int32_t SendData(const FrameType frame_type, const uint8_t payload_type,
|
||||
const uint32_t timestamp, const uint8_t* payload_data,
|
||||
const uint16_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation);
|
||||
|
||||
int test_mode_;
|
||||
|
||||
scoped_ptr<AudioCodingModule> acm_a_;
|
||||
@@ -100,17 +97,24 @@ class TestStereo : public ACMTest {
|
||||
char* send_codec_name_;
|
||||
|
||||
// Payload types for stereo codecs and CNG
|
||||
#ifdef WEBRTC_CODEC_G722
|
||||
int g722_pltype_;
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_PCM16
|
||||
int l16_8khz_pltype_;
|
||||
int l16_16khz_pltype_;
|
||||
int l16_32khz_pltype_;
|
||||
#endif
|
||||
#ifdef PCMA_AND_PCMU
|
||||
int pcma_pltype_;
|
||||
int pcmu_pltype_;
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_CELT
|
||||
int celt_pltype_;
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
int opus_pltype_;
|
||||
int cn_8khz_pltype_;
|
||||
int cn_16khz_pltype_;
|
||||
int cn_32khz_pltype_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -36,9 +36,11 @@ class DualStreamTest : public AudioPacketizationCallback,
|
||||
void ApiTest();
|
||||
|
||||
virtual int32_t SendData(
|
||||
FrameType frameType, uint8_t payload_type,
|
||||
uint32_t timestamp, const uint8_t* payload_data,
|
||||
uint16_t payload_size,
|
||||
FrameType frameType,
|
||||
uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) OVERRIDE;
|
||||
|
||||
void Perform(bool start_in_sync, int num_channels_input);
|
||||
@@ -49,9 +51,9 @@ class DualStreamTest : public AudioPacketizationCallback,
|
||||
void PopulateCodecInstances(int frame_size_primary_ms,
|
||||
int num_channels_primary, int sampling_rate);
|
||||
|
||||
void Validate(bool start_in_sync, int tolerance);
|
||||
void Validate(bool start_in_sync, size_t tolerance);
|
||||
bool EqualTimestamp(int stream, int position);
|
||||
int EqualPayloadLength(int stream, int position);
|
||||
size_t EqualPayloadLength(int stream, int position);
|
||||
bool EqualPayloadData(int stream, int position);
|
||||
|
||||
static const int kMaxNumStoredPayloads = 2;
|
||||
@@ -77,8 +79,8 @@ class DualStreamTest : public AudioPacketizationCallback,
|
||||
uint32_t timestamp_ref_[kMaxNumStreams][kMaxNumStoredPayloads];
|
||||
uint32_t timestamp_dual_[kMaxNumStreams][kMaxNumStoredPayloads];
|
||||
|
||||
int payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads];
|
||||
int payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads];
|
||||
size_t payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads];
|
||||
size_t payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads];
|
||||
|
||||
uint8_t payload_data_ref_[kMaxNumStreams][MAX_PAYLOAD_SIZE_BYTE
|
||||
* kMaxNumStoredPayloads];
|
||||
@@ -174,7 +176,7 @@ void DualStreamTest::Perform(bool start_in_sync, int num_channels_input) {
|
||||
pcm_file.ReadStereo(num_channels_input == 2);
|
||||
AudioFrame audio_frame;
|
||||
|
||||
int tolerance = 0;
|
||||
size_t tolerance = 0;
|
||||
if (num_channels_input == 2 && primary_encoder_.channels == 2
|
||||
&& secondary_encoder_.channels == 1) {
|
||||
tolerance = 12;
|
||||
@@ -253,10 +255,10 @@ bool DualStreamTest::EqualTimestamp(int stream_index, int position) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int DualStreamTest::EqualPayloadLength(int stream_index, int position) {
|
||||
return abs(
|
||||
payload_len_dual_[stream_index][position]
|
||||
- payload_len_ref_[stream_index][position]);
|
||||
size_t DualStreamTest::EqualPayloadLength(int stream_index, int position) {
|
||||
size_t dual = payload_len_dual_[stream_index][position];
|
||||
size_t ref = payload_len_ref_[stream_index][position];
|
||||
return (dual > ref) ? (dual - ref) : (ref - dual);
|
||||
}
|
||||
|
||||
bool DualStreamTest::EqualPayloadData(int stream_index, int position) {
|
||||
@@ -264,7 +266,7 @@ bool DualStreamTest::EqualPayloadData(int stream_index, int position) {
|
||||
payload_len_dual_[stream_index][position]
|
||||
== payload_len_ref_[stream_index][position]);
|
||||
int offset = position * MAX_PAYLOAD_SIZE_BYTE;
|
||||
for (int n = 0; n < payload_len_dual_[stream_index][position]; n++) {
|
||||
for (size_t n = 0; n < payload_len_dual_[stream_index][position]; n++) {
|
||||
if (payload_data_dual_[stream_index][offset + n]
|
||||
!= payload_data_ref_[stream_index][offset + n]) {
|
||||
return false;
|
||||
@@ -273,9 +275,9 @@ bool DualStreamTest::EqualPayloadData(int stream_index, int position) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DualStreamTest::Validate(bool start_in_sync, int tolerance) {
|
||||
void DualStreamTest::Validate(bool start_in_sync, size_t tolerance) {
|
||||
for (int stream_index = 0; stream_index < kMaxNumStreams; stream_index++) {
|
||||
int my_tolerance = stream_index == kPrimary ? 0 : tolerance;
|
||||
size_t my_tolerance = stream_index == kPrimary ? 0 : tolerance;
|
||||
for (int position = 0; position < kMaxNumStoredPayloads; position++) {
|
||||
if (payload_ref_is_stored_[stream_index][position] == 1
|
||||
&& payload_dual_is_stored_[stream_index][position] == 1) {
|
||||
@@ -296,7 +298,7 @@ void DualStreamTest::Validate(bool start_in_sync, int tolerance) {
|
||||
int32_t DualStreamTest::SendData(FrameType frameType, uint8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
const uint8_t* payload_data,
|
||||
uint16_t payload_size,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
int position;
|
||||
int stream_index;
|
||||
|
||||
@@ -46,7 +46,7 @@ class TargetDelayTest : public ::testing::Test {
|
||||
|
||||
int16_t audio[kFrameSizeSamples];
|
||||
const int kRange = 0x7FF; // 2047, easy for masking.
|
||||
for (int n = 0; n < kFrameSizeSamples; ++n)
|
||||
for (size_t n = 0; n < kFrameSizeSamples; ++n)
|
||||
audio[n] = (rand() & kRange) - kRange / 2;
|
||||
WebRtcPcm16b_Encode(audio, kFrameSizeSamples, payload_);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class TargetDelayTest : public ::testing::Test {
|
||||
private:
|
||||
static const int kSampleRateHz = 16000;
|
||||
static const int kNum10msPerFrame = 2;
|
||||
static const int kFrameSizeSamples = 320; // 20 ms @ 16 kHz.
|
||||
static const size_t kFrameSizeSamples = 320; // 20 ms @ 16 kHz.
|
||||
// payload-len = frame-samples * 2 bytes/sample.
|
||||
static const int kPayloadLenBytes = 320 * 2;
|
||||
// Inter-arrival time in number of packets in a jittery channel. One is no
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace webrtc {
|
||||
//
|
||||
int DtmfBuffer::ParseEvent(uint32_t rtp_timestamp,
|
||||
const uint8_t* payload,
|
||||
int payload_length_bytes,
|
||||
size_t payload_length_bytes,
|
||||
DtmfEvent* event) {
|
||||
if (!payload || !event) {
|
||||
return kInvalidPointer;
|
||||
|
||||
@@ -69,7 +69,7 @@ class DtmfBuffer {
|
||||
// |rtp_timestamp| is simply copied into the struct.
|
||||
static int ParseEvent(uint32_t rtp_timestamp,
|
||||
const uint8_t* payload,
|
||||
int payload_length_bytes,
|
||||
size_t payload_length_bytes,
|
||||
DtmfEvent* event);
|
||||
|
||||
// Inserts |event| into the buffer. The method looks for a matching event and
|
||||
|
||||
@@ -132,7 +132,7 @@ class NetEq {
|
||||
// Returns 0 on success, -1 on failure.
|
||||
virtual int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
const uint8_t* payload,
|
||||
int length_bytes,
|
||||
size_t length_bytes,
|
||||
uint32_t receive_timestamp) = 0;
|
||||
|
||||
// Inserts a sync-packet into packet queue. Sync-packets are decoded to
|
||||
|
||||
@@ -28,11 +28,11 @@ class MockPayloadSplitter : public PayloadSplitter {
|
||||
MOCK_METHOD2(SplitAudio,
|
||||
int(PacketList* packet_list, const DecoderDatabase& decoder_database));
|
||||
MOCK_METHOD4(SplitBySamples,
|
||||
void(const Packet* packet, int bytes_per_ms, int timestamps_per_ms,
|
||||
PacketList* new_packets));
|
||||
void(const Packet* packet, size_t bytes_per_ms,
|
||||
uint32_t timestamps_per_ms, PacketList* new_packets));
|
||||
MOCK_METHOD4(SplitByFrames,
|
||||
int(const Packet* packet, int bytes_per_frame, int timestamps_per_frame,
|
||||
PacketList* new_packets));
|
||||
int(const Packet* packet, size_t bytes_per_frame,
|
||||
uint32_t timestamps_per_frame, PacketList* new_packets));
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -203,7 +203,7 @@ class NetEqExternalDecoderTest : public ::testing::Test {
|
||||
int sample_rate_hz_;
|
||||
int samples_per_ms_;
|
||||
const int frame_size_ms_;
|
||||
int frame_size_samples_;
|
||||
size_t frame_size_samples_;
|
||||
int output_size_samples_;
|
||||
NetEq* neteq_external_;
|
||||
NetEq* neteq_;
|
||||
@@ -214,7 +214,7 @@ class NetEqExternalDecoderTest : public ::testing::Test {
|
||||
int16_t output_[kMaxBlockSize];
|
||||
int16_t output_external_[kMaxBlockSize];
|
||||
WebRtcRTPHeader rtp_header_;
|
||||
int payload_size_bytes_;
|
||||
size_t payload_size_bytes_;
|
||||
int last_send_time_;
|
||||
int last_arrival_time_;
|
||||
scoped_ptr<test::InputAudioFile> input_file_;
|
||||
|
||||
@@ -117,7 +117,7 @@ NetEqImpl::~NetEqImpl() {
|
||||
|
||||
int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
const uint8_t* payload,
|
||||
int length_bytes,
|
||||
size_t length_bytes,
|
||||
uint32_t receive_timestamp) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
LOG(LS_VERBOSE) << "InsertPacket: ts=" << rtp_header.header.timestamp <<
|
||||
@@ -399,7 +399,7 @@ const SyncBuffer* NetEqImpl::sync_buffer_for_test() const {
|
||||
|
||||
int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
||||
const uint8_t* payload,
|
||||
int length_bytes,
|
||||
size_t length_bytes,
|
||||
uint32_t receive_timestamp,
|
||||
bool is_sync_packet) {
|
||||
if (!payload) {
|
||||
@@ -1241,7 +1241,7 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list, Operations* operation,
|
||||
assert(*operation == kNormal || *operation == kAccelerate ||
|
||||
*operation == kMerge || *operation == kPreemptiveExpand);
|
||||
packet_list->pop_front();
|
||||
int payload_length = packet->payload_length;
|
||||
size_t payload_length = packet->payload_length;
|
||||
int16_t decode_length;
|
||||
if (packet->sync_packet) {
|
||||
// Decode to silence with the same frame size as the last decode.
|
||||
|
||||
@@ -81,7 +81,7 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
// Returns 0 on success, -1 on failure.
|
||||
virtual int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
const uint8_t* payload,
|
||||
int length_bytes,
|
||||
size_t length_bytes,
|
||||
uint32_t receive_timestamp) OVERRIDE;
|
||||
|
||||
// Inserts a sync-packet into packet queue. Sync-packets are decoded to
|
||||
@@ -210,7 +210,7 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
// TODO(hlundin): Merge this with InsertPacket above?
|
||||
int InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
||||
const uint8_t* payload,
|
||||
int length_bytes,
|
||||
size_t length_bytes,
|
||||
uint32_t receive_timestamp,
|
||||
bool is_sync_packet)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||
|
||||
@@ -253,7 +253,7 @@ TEST_F(NetEqImplTest, RemovePayloadType) {
|
||||
|
||||
TEST_F(NetEqImplTest, InsertPacket) {
|
||||
CreateInstance();
|
||||
const int kPayloadLength = 100;
|
||||
const size_t kPayloadLength = 100;
|
||||
const uint8_t kPayloadType = 0;
|
||||
const uint16_t kFirstSequenceNumber = 0x1234;
|
||||
const uint32_t kFirstTimestamp = 0x12345678;
|
||||
|
||||
@@ -192,7 +192,7 @@ class NetEqDecodingTest : public ::testing::Test {
|
||||
static const int kBlockSize8kHz = kTimeStepMs * 8;
|
||||
static const int kBlockSize16kHz = kTimeStepMs * 16;
|
||||
static const int kBlockSize32kHz = kTimeStepMs * 32;
|
||||
static const int kMaxBlockSize = kBlockSize32kHz;
|
||||
static const size_t kMaxBlockSize = kBlockSize32kHz;
|
||||
static const int kInitSampleRateHz = 8000;
|
||||
|
||||
NetEqDecodingTest();
|
||||
@@ -213,7 +213,7 @@ class NetEqDecodingTest : public ::testing::Test {
|
||||
int timestamp,
|
||||
WebRtcRTPHeader* rtp_info,
|
||||
uint8_t* payload,
|
||||
int* payload_len);
|
||||
size_t* payload_len);
|
||||
|
||||
void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp,
|
||||
const std::set<uint16_t>& drop_seq_numbers,
|
||||
@@ -244,7 +244,7 @@ const int NetEqDecodingTest::kTimeStepMs;
|
||||
const int NetEqDecodingTest::kBlockSize8kHz;
|
||||
const int NetEqDecodingTest::kBlockSize16kHz;
|
||||
const int NetEqDecodingTest::kBlockSize32kHz;
|
||||
const int NetEqDecodingTest::kMaxBlockSize;
|
||||
const size_t NetEqDecodingTest::kMaxBlockSize;
|
||||
const int NetEqDecodingTest::kInitSampleRateHz;
|
||||
|
||||
NetEqDecodingTest::NetEqDecodingTest()
|
||||
@@ -396,7 +396,7 @@ void NetEqDecodingTest::PopulateCng(int frame_index,
|
||||
int timestamp,
|
||||
WebRtcRTPHeader* rtp_info,
|
||||
uint8_t* payload,
|
||||
int* payload_len) {
|
||||
size_t* payload_len) {
|
||||
rtp_info->header.sequenceNumber = frame_index;
|
||||
rtp_info->header.timestamp = timestamp;
|
||||
rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC.
|
||||
@@ -448,8 +448,8 @@ class NetEqDecodingTestFaxMode : public NetEqDecodingTest {
|
||||
TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) {
|
||||
// Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio.
|
||||
size_t num_frames = 30;
|
||||
const int kSamples = 10 * 16;
|
||||
const int kPayloadBytes = kSamples * 2;
|
||||
const size_t kSamples = 10 * 16;
|
||||
const size_t kPayloadBytes = kSamples * 2;
|
||||
for (size_t i = 0; i < num_frames; ++i) {
|
||||
uint16_t payload[kSamples] = {0};
|
||||
WebRtcRTPHeader rtp_info;
|
||||
@@ -518,8 +518,8 @@ TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) {
|
||||
TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) {
|
||||
const int kNumFrames = 3000; // Needed for convergence.
|
||||
int frame_index = 0;
|
||||
const int kSamples = 10 * 16;
|
||||
const int kPayloadBytes = kSamples * 2;
|
||||
const size_t kSamples = 10 * 16;
|
||||
const size_t kPayloadBytes = kSamples * 2;
|
||||
while (frame_index < kNumFrames) {
|
||||
// Insert one packet each time, except every 10th time where we insert two
|
||||
// packets at once. This will create a negative clock-drift of approx. 10%.
|
||||
@@ -549,8 +549,8 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) {
|
||||
TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) {
|
||||
const int kNumFrames = 5000; // Needed for convergence.
|
||||
int frame_index = 0;
|
||||
const int kSamples = 10 * 16;
|
||||
const int kPayloadBytes = kSamples * 2;
|
||||
const size_t kSamples = 10 * 16;
|
||||
const size_t kPayloadBytes = kSamples * 2;
|
||||
for (int i = 0; i < kNumFrames; ++i) {
|
||||
// Insert one packet each time, except every 10th time where we don't insert
|
||||
// any packet. This will create a positive clock-drift of approx. 11%.
|
||||
@@ -585,8 +585,8 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
||||
uint16_t seq_no = 0;
|
||||
uint32_t timestamp = 0;
|
||||
const int kFrameSizeMs = 30;
|
||||
const int kSamples = kFrameSizeMs * 16;
|
||||
const int kPayloadBytes = kSamples * 2;
|
||||
const size_t kSamples = kFrameSizeMs * 16;
|
||||
const size_t kPayloadBytes = kSamples * 2;
|
||||
double next_input_time_ms = 0.0;
|
||||
double t_ms;
|
||||
int out_len;
|
||||
@@ -625,7 +625,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
||||
while (next_input_time_ms <= t_ms) {
|
||||
// Insert one CNG frame each 100 ms.
|
||||
uint8_t payload[kPayloadBytes];
|
||||
int payload_len;
|
||||
size_t payload_len;
|
||||
WebRtcRTPHeader rtp_info;
|
||||
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
||||
@@ -672,7 +672,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
||||
}
|
||||
// Insert one CNG frame each 100 ms.
|
||||
uint8_t payload[kPayloadBytes];
|
||||
int payload_len;
|
||||
size_t payload_len;
|
||||
WebRtcRTPHeader rtp_info;
|
||||
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
||||
@@ -797,7 +797,7 @@ TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) {
|
||||
}
|
||||
|
||||
TEST_F(NetEqDecodingTest, UnknownPayloadType) {
|
||||
const int kPayloadBytes = 100;
|
||||
const size_t kPayloadBytes = 100;
|
||||
uint8_t payload[kPayloadBytes] = {0};
|
||||
WebRtcRTPHeader rtp_info;
|
||||
PopulateRtpInfo(0, 0, &rtp_info);
|
||||
@@ -808,7 +808,7 @@ TEST_F(NetEqDecodingTest, UnknownPayloadType) {
|
||||
}
|
||||
|
||||
TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) {
|
||||
const int kPayloadBytes = 100;
|
||||
const size_t kPayloadBytes = 100;
|
||||
uint8_t payload[kPayloadBytes] = {0};
|
||||
WebRtcRTPHeader rtp_info;
|
||||
PopulateRtpInfo(0, 0, &rtp_info);
|
||||
@@ -817,7 +817,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) {
|
||||
NetEqOutputType type;
|
||||
// Set all of |out_data_| to 1, and verify that it was set to 0 by the call
|
||||
// to GetAudio.
|
||||
for (int i = 0; i < kMaxBlockSize; ++i) {
|
||||
for (size_t i = 0; i < kMaxBlockSize; ++i) {
|
||||
out_data_[i] = 1;
|
||||
}
|
||||
int num_channels;
|
||||
@@ -838,7 +838,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) {
|
||||
SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
|
||||
EXPECT_EQ(0, out_data_[i]);
|
||||
}
|
||||
for (int i = kExpectedOutputLength; i < kMaxBlockSize; ++i) {
|
||||
for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) {
|
||||
std::ostringstream ss;
|
||||
ss << "i = " << i;
|
||||
SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
|
||||
@@ -850,7 +850,7 @@ TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) {
|
||||
NetEqOutputType type;
|
||||
// Set all of |out_data_| to 1, and verify that it was set to 0 by the call
|
||||
// to GetAudio.
|
||||
for (int i = 0; i < kMaxBlockSize; ++i) {
|
||||
for (size_t i = 0; i < kMaxBlockSize; ++i) {
|
||||
out_data_[i] = 1;
|
||||
}
|
||||
int num_channels;
|
||||
@@ -875,7 +875,7 @@ class NetEqBgnTest : public NetEqDecodingTest {
|
||||
bool should_be_faded) = 0;
|
||||
|
||||
void CheckBgn(int sampling_rate_hz) {
|
||||
int expected_samples_per_channel = 0;
|
||||
int16_t expected_samples_per_channel = 0;
|
||||
uint8_t payload_type = 0xFF; // Invalid.
|
||||
if (sampling_rate_hz == 8000) {
|
||||
expected_samples_per_channel = kBlockSize8kHz;
|
||||
@@ -899,7 +899,7 @@ class NetEqBgnTest : public NetEqDecodingTest {
|
||||
ASSERT_TRUE(input.Init(
|
||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
|
||||
10 * sampling_rate_hz, // Max 10 seconds loop length.
|
||||
expected_samples_per_channel));
|
||||
static_cast<size_t>(expected_samples_per_channel)));
|
||||
|
||||
// Payload of 10 ms of PCM16 32 kHz.
|
||||
uint8_t payload[kBlockSize32kHz * sizeof(int16_t)];
|
||||
@@ -912,7 +912,7 @@ class NetEqBgnTest : public NetEqDecodingTest {
|
||||
|
||||
uint32_t receive_timestamp = 0;
|
||||
for (int n = 0; n < 10; ++n) { // Insert few packets and get audio.
|
||||
int enc_len_bytes =
|
||||
int16_t enc_len_bytes =
|
||||
WebRtcPcm16b_EncodeW16(input.GetNextBlock(),
|
||||
expected_samples_per_channel,
|
||||
reinterpret_cast<int16_t*>(payload));
|
||||
@@ -921,8 +921,9 @@ class NetEqBgnTest : public NetEqDecodingTest {
|
||||
number_channels = 0;
|
||||
samples_per_channel = 0;
|
||||
ASSERT_EQ(0,
|
||||
neteq_->InsertPacket(
|
||||
rtp_info, payload, enc_len_bytes, receive_timestamp));
|
||||
neteq_->InsertPacket(rtp_info, payload,
|
||||
static_cast<size_t>(enc_len_bytes),
|
||||
receive_timestamp));
|
||||
ASSERT_EQ(0,
|
||||
neteq_->GetAudio(kBlockSize32kHz,
|
||||
output,
|
||||
@@ -1074,7 +1075,7 @@ TEST_F(NetEqDecodingTest, SyncPacketInsert) {
|
||||
EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
|
||||
|
||||
// Payload length of 10 ms PCM16 16 kHz.
|
||||
const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
||||
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
||||
uint8_t payload[kPayloadBytes] = {0};
|
||||
ASSERT_EQ(0, neteq_->InsertPacket(
|
||||
rtp_info, payload, kPayloadBytes, receive_timestamp));
|
||||
@@ -1125,11 +1126,11 @@ TEST_F(NetEqDecodingTest, SyncPacketInsert) {
|
||||
TEST_F(NetEqDecodingTest, SyncPacketDecode) {
|
||||
WebRtcRTPHeader rtp_info;
|
||||
PopulateRtpInfo(0, 0, &rtp_info);
|
||||
const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
||||
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
||||
uint8_t payload[kPayloadBytes];
|
||||
int16_t decoded[kBlockSize16kHz];
|
||||
int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1;
|
||||
for (int n = 0; n < kPayloadBytes; ++n) {
|
||||
for (size_t n = 0; n < kPayloadBytes; ++n) {
|
||||
payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence.
|
||||
}
|
||||
// Insert some packets which decode to noise. We are not interested in
|
||||
@@ -1204,10 +1205,10 @@ TEST_F(NetEqDecodingTest, SyncPacketDecode) {
|
||||
TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
|
||||
WebRtcRTPHeader rtp_info;
|
||||
PopulateRtpInfo(0, 0, &rtp_info);
|
||||
const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
||||
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
||||
uint8_t payload[kPayloadBytes];
|
||||
int16_t decoded[kBlockSize16kHz];
|
||||
for (int n = 0; n < kPayloadBytes; ++n) {
|
||||
for (size_t n = 0; n < kPayloadBytes; ++n) {
|
||||
payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence.
|
||||
}
|
||||
// Insert some packets which decode to noise. We are not interested in
|
||||
@@ -1279,7 +1280,7 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no,
|
||||
const int kBlocksPerFrame = 3; // Number of 10 ms blocks per frame.
|
||||
const int kFrameSizeMs = kBlocksPerFrame * kTimeStepMs;
|
||||
const int kSamples = kBlockSize16kHz * kBlocksPerFrame;
|
||||
const int kPayloadBytes = kSamples * sizeof(int16_t);
|
||||
const size_t kPayloadBytes = kSamples * sizeof(int16_t);
|
||||
double next_input_time_ms = 0.0;
|
||||
int16_t decoded[kBlockSize16kHz];
|
||||
int num_channels;
|
||||
@@ -1380,7 +1381,7 @@ void NetEqDecodingTest::DuplicateCng() {
|
||||
const int kFrameSizeMs = 10;
|
||||
const int kSampleRateKhz = 16;
|
||||
const int kSamples = kFrameSizeMs * kSampleRateKhz;
|
||||
const int kPayloadBytes = kSamples * 2;
|
||||
const size_t kPayloadBytes = kSamples * 2;
|
||||
|
||||
const int algorithmic_delay_samples = std::max(
|
||||
algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8);
|
||||
@@ -1409,7 +1410,7 @@ void NetEqDecodingTest::DuplicateCng() {
|
||||
// Insert same CNG packet twice.
|
||||
const int kCngPeriodMs = 100;
|
||||
const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz;
|
||||
int payload_len;
|
||||
size_t payload_len;
|
||||
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
||||
// This is the first time this CNG packet is inserted.
|
||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace webrtc {
|
||||
struct Packet {
|
||||
RTPHeader header;
|
||||
uint8_t* payload; // Datagram excluding RTP header and header extension.
|
||||
int payload_length;
|
||||
size_t payload_length;
|
||||
bool primary; // Primary, i.e., not redundant payload.
|
||||
int waiting_time;
|
||||
bool sync_packet;
|
||||
|
||||
@@ -46,7 +46,7 @@ int PayloadSplitter::SplitRed(PacketList* packet_list) {
|
||||
// +-+-+-+-+-+-+-+-+
|
||||
|
||||
bool last_block = false;
|
||||
int sum_length = 0;
|
||||
size_t sum_length = 0;
|
||||
while (!last_block) {
|
||||
Packet* new_packet = new Packet;
|
||||
new_packet->header = red_packet->header;
|
||||
@@ -82,7 +82,7 @@ int PayloadSplitter::SplitRed(PacketList* packet_list) {
|
||||
// |payload_ptr| now points at the first payload byte.
|
||||
PacketList::iterator new_it;
|
||||
for (new_it = new_packets.begin(); new_it != new_packets.end(); ++new_it) {
|
||||
int payload_length = (*new_it)->payload_length;
|
||||
size_t payload_length = (*new_it)->payload_length;
|
||||
if (payload_ptr + payload_length >
|
||||
red_packet->payload + red_packet->payload_length) {
|
||||
// The block lengths in the RED headers do not match the overall packet
|
||||
@@ -291,11 +291,12 @@ int PayloadSplitter::SplitAudio(PacketList* packet_list,
|
||||
break;
|
||||
}
|
||||
case kDecoderILBC: {
|
||||
int bytes_per_frame;
|
||||
size_t bytes_per_frame;
|
||||
int timestamps_per_frame;
|
||||
if (packet->payload_length >= 950) {
|
||||
return kTooLargePayload;
|
||||
} else if (packet->payload_length % 38 == 0) {
|
||||
}
|
||||
if (packet->payload_length % 38 == 0) {
|
||||
// 20 ms frames.
|
||||
bytes_per_frame = 38;
|
||||
timestamps_per_frame = 160;
|
||||
@@ -345,28 +346,28 @@ int PayloadSplitter::SplitAudio(PacketList* packet_list,
|
||||
}
|
||||
|
||||
void PayloadSplitter::SplitBySamples(const Packet* packet,
|
||||
int bytes_per_ms,
|
||||
int timestamps_per_ms,
|
||||
size_t bytes_per_ms,
|
||||
uint32_t timestamps_per_ms,
|
||||
PacketList* new_packets) {
|
||||
assert(packet);
|
||||
assert(new_packets);
|
||||
|
||||
int split_size_bytes = packet->payload_length;
|
||||
size_t split_size_bytes = packet->payload_length;
|
||||
|
||||
// Find a "chunk size" >= 20 ms and < 40 ms.
|
||||
int min_chunk_size = bytes_per_ms * 20;
|
||||
size_t min_chunk_size = bytes_per_ms * 20;
|
||||
// Reduce the split size by half as long as |split_size_bytes| is at least
|
||||
// twice the minimum chunk size (so that the resulting size is at least as
|
||||
// large as the minimum chunk size).
|
||||
while (split_size_bytes >= 2 * min_chunk_size) {
|
||||
split_size_bytes >>= 1;
|
||||
}
|
||||
int timestamps_per_chunk =
|
||||
split_size_bytes * timestamps_per_ms / bytes_per_ms;
|
||||
uint32_t timestamps_per_chunk = static_cast<uint32_t>(
|
||||
split_size_bytes * timestamps_per_ms / bytes_per_ms);
|
||||
uint32_t timestamp = packet->header.timestamp;
|
||||
|
||||
uint8_t* payload_ptr = packet->payload;
|
||||
int len = packet->payload_length;
|
||||
size_t len = packet->payload_length;
|
||||
while (len >= (2 * split_size_bytes)) {
|
||||
Packet* new_packet = new Packet;
|
||||
new_packet->payload_length = split_size_bytes;
|
||||
@@ -394,22 +395,21 @@ void PayloadSplitter::SplitBySamples(const Packet* packet,
|
||||
}
|
||||
|
||||
int PayloadSplitter::SplitByFrames(const Packet* packet,
|
||||
int bytes_per_frame,
|
||||
int timestamps_per_frame,
|
||||
size_t bytes_per_frame,
|
||||
uint32_t timestamps_per_frame,
|
||||
PacketList* new_packets) {
|
||||
if (packet->payload_length % bytes_per_frame != 0) {
|
||||
return kFrameSplitError;
|
||||
}
|
||||
|
||||
int num_frames = packet->payload_length / bytes_per_frame;
|
||||
if (num_frames == 1) {
|
||||
if (packet->payload_length == bytes_per_frame) {
|
||||
// Special case. Do not split the payload.
|
||||
return kNoSplit;
|
||||
}
|
||||
|
||||
uint32_t timestamp = packet->header.timestamp;
|
||||
uint8_t* payload_ptr = packet->payload;
|
||||
int len = packet->payload_length;
|
||||
size_t len = packet->payload_length;
|
||||
while (len > 0) {
|
||||
assert(len >= bytes_per_frame);
|
||||
Packet* new_packet = new Packet;
|
||||
|
||||
@@ -71,16 +71,16 @@ class PayloadSplitter {
|
||||
// Splits the payload in |packet|. The payload is assumed to be from a
|
||||
// sample-based codec.
|
||||
virtual void SplitBySamples(const Packet* packet,
|
||||
int bytes_per_ms,
|
||||
int timestamps_per_ms,
|
||||
size_t bytes_per_ms,
|
||||
uint32_t timestamps_per_ms,
|
||||
PacketList* new_packets);
|
||||
|
||||
// Splits the payload in |packet|. The payload will be split into chunks of
|
||||
// size |bytes_per_frame|, corresponding to a |timestamps_per_frame|
|
||||
// RTP timestamps.
|
||||
virtual int SplitByFrames(const Packet* packet,
|
||||
int bytes_per_frame,
|
||||
int timestamps_per_frame,
|
||||
size_t bytes_per_frame,
|
||||
uint32_t timestamps_per_frame,
|
||||
PacketList* new_packets);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PayloadSplitter);
|
||||
|
||||
@@ -27,8 +27,8 @@ using ::testing::ReturnNull;
|
||||
namespace webrtc {
|
||||
|
||||
static const int kRedPayloadType = 100;
|
||||
static const int kPayloadLength = 10;
|
||||
static const int kRedHeaderLength = 4; // 4 bytes RED header.
|
||||
static const size_t kPayloadLength = 10;
|
||||
static const size_t kRedHeaderLength = 4; // 4 bytes RED header.
|
||||
static const uint16_t kSequenceNumber = 0;
|
||||
static const uint32_t kBaseTimestamp = 0x12345678;
|
||||
|
||||
@@ -50,7 +50,7 @@ static const uint32_t kBaseTimestamp = 0x12345678;
|
||||
// by the values in array |payload_types| (which must be of length
|
||||
// |num_payloads|). Each redundant payload is |timestamp_offset| samples
|
||||
// "behind" the the previous payload.
|
||||
Packet* CreateRedPayload(int num_payloads,
|
||||
Packet* CreateRedPayload(size_t num_payloads,
|
||||
uint8_t* payload_types,
|
||||
int timestamp_offset) {
|
||||
Packet* packet = new Packet;
|
||||
@@ -61,7 +61,7 @@ Packet* CreateRedPayload(int num_payloads,
|
||||
(num_payloads - 1) * (kPayloadLength + kRedHeaderLength);
|
||||
uint8_t* payload = new uint8_t[packet->payload_length];
|
||||
uint8_t* payload_ptr = payload;
|
||||
for (int i = 0; i < num_payloads; ++i) {
|
||||
for (size_t i = 0; i < num_payloads; ++i) {
|
||||
// Write the RED headers.
|
||||
if (i == num_payloads - 1) {
|
||||
// Special case for last payload.
|
||||
@@ -82,9 +82,9 @@ Packet* CreateRedPayload(int num_payloads,
|
||||
*payload_ptr = kPayloadLength & 0xFF;
|
||||
++payload_ptr;
|
||||
}
|
||||
for (int i = 0; i < num_payloads; ++i) {
|
||||
for (size_t i = 0; i < num_payloads; ++i) {
|
||||
// Write |i| to all bytes in each payload.
|
||||
memset(payload_ptr, i, kPayloadLength);
|
||||
memset(payload_ptr, static_cast<int>(i), kPayloadLength);
|
||||
payload_ptr += kPayloadLength;
|
||||
}
|
||||
packet->payload = payload;
|
||||
@@ -104,7 +104,7 @@ Packet* CreateRedPayload(int num_payloads,
|
||||
// : |
|
||||
// | |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
Packet* CreateOpusFecPacket(uint8_t payload_type, int payload_length,
|
||||
Packet* CreateOpusFecPacket(uint8_t payload_type, size_t payload_length,
|
||||
uint8_t payload_value) {
|
||||
Packet* packet = new Packet;
|
||||
packet->header.payloadType = payload_type;
|
||||
@@ -120,7 +120,7 @@ Packet* CreateOpusFecPacket(uint8_t payload_type, int payload_length,
|
||||
}
|
||||
|
||||
// Create a packet with all payload bytes set to |payload_value|.
|
||||
Packet* CreatePacket(uint8_t payload_type, int payload_length,
|
||||
Packet* CreatePacket(uint8_t payload_type, size_t payload_length,
|
||||
uint8_t payload_value) {
|
||||
Packet* packet = new Packet;
|
||||
packet->header.payloadType = payload_type;
|
||||
@@ -135,7 +135,7 @@ Packet* CreatePacket(uint8_t payload_type, int payload_length,
|
||||
|
||||
// Checks that |packet| has the attributes given in the remaining parameters.
|
||||
void VerifyPacket(const Packet* packet,
|
||||
int payload_length,
|
||||
size_t payload_length,
|
||||
uint8_t payload_type,
|
||||
uint16_t sequence_number,
|
||||
uint32_t timestamp,
|
||||
@@ -147,7 +147,7 @@ void VerifyPacket(const Packet* packet,
|
||||
EXPECT_EQ(timestamp, packet->header.timestamp);
|
||||
EXPECT_EQ(primary, packet->primary);
|
||||
ASSERT_FALSE(packet->payload == NULL);
|
||||
for (int i = 0; i < packet->payload_length; ++i) {
|
||||
for (size_t i = 0; i < packet->payload_length; ++i) {
|
||||
EXPECT_EQ(payload_value, packet->payload[i]);
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ TEST(RedPayloadSplitter, TwoPacketsThreePayloads) {
|
||||
// found in the list (which is PCMu).
|
||||
TEST(RedPayloadSplitter, CheckRedPayloads) {
|
||||
PacketList packet_list;
|
||||
for (int i = 0; i <= 3; ++i) {
|
||||
for (uint8_t i = 0; i <= 3; ++i) {
|
||||
// Create packet with payload type |i|, payload length 10 bytes, all 0.
|
||||
Packet* packet = CreatePacket(i, 10, 0);
|
||||
packet_list.push_back(packet);
|
||||
@@ -357,7 +357,7 @@ TEST(AudioPayloadSplitter, NonSplittable) {
|
||||
// Set up packets with different RTP payload types. The actual values do not
|
||||
// matter, since we are mocking the decoder database anyway.
|
||||
PacketList packet_list;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
for (uint8_t i = 0; i < 6; ++i) {
|
||||
// Let the payload type be |i|, and the payload value 10 * |i|.
|
||||
packet_list.push_back(CreatePacket(i, kPayloadLength, 10 * i));
|
||||
}
|
||||
@@ -415,7 +415,7 @@ TEST(AudioPayloadSplitter, NonSplittable) {
|
||||
TEST(AudioPayloadSplitter, UnknownPayloadType) {
|
||||
PacketList packet_list;
|
||||
static const uint8_t kPayloadType = 17; // Just a random number.
|
||||
int kPayloadLengthBytes = 4711; // Random number.
|
||||
size_t kPayloadLengthBytes = 4711; // Random number.
|
||||
packet_list.push_back(CreatePacket(kPayloadType, kPayloadLengthBytes, 0));
|
||||
|
||||
MockDecoderDatabase decoder_database;
|
||||
@@ -502,7 +502,7 @@ class SplitBySamplesTest : public ::testing::TestWithParam<NetEqDecoder> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int bytes_per_ms_;
|
||||
size_t bytes_per_ms_;
|
||||
int samples_per_ms_;
|
||||
NetEqDecoder decoder_type_;
|
||||
};
|
||||
@@ -514,7 +514,7 @@ TEST_P(SplitBySamplesTest, PayloadSizes) {
|
||||
for (int payload_size_ms = 10; payload_size_ms <= 60; payload_size_ms += 10) {
|
||||
// The payload values are set to be the same as the payload_size, so that
|
||||
// one can distinguish from which packet the split payloads come from.
|
||||
int payload_size_bytes = payload_size_ms * bytes_per_ms_;
|
||||
size_t payload_size_bytes = payload_size_ms * bytes_per_ms_;
|
||||
packet_list.push_back(CreatePacket(kPayloadType, payload_size_bytes,
|
||||
payload_size_ms));
|
||||
}
|
||||
@@ -548,7 +548,7 @@ TEST_P(SplitBySamplesTest, PayloadSizes) {
|
||||
PacketList::iterator it = packet_list.begin();
|
||||
int i = 0;
|
||||
while (it != packet_list.end()) {
|
||||
int length_bytes = expected_size_ms[i] * bytes_per_ms_;
|
||||
size_t length_bytes = expected_size_ms[i] * bytes_per_ms_;
|
||||
uint32_t expected_timestamp = kBaseTimestamp +
|
||||
expected_timestamp_offset_ms[i] * samples_per_ms_;
|
||||
VerifyPacket((*it), length_bytes, kPayloadType, kSequenceNumber,
|
||||
@@ -583,7 +583,7 @@ class SplitIlbcTest : public ::testing::TestWithParam<std::pair<int, int> > {
|
||||
}
|
||||
size_t num_frames_;
|
||||
int frame_length_ms_;
|
||||
int frame_length_bytes_;
|
||||
size_t frame_length_bytes_;
|
||||
};
|
||||
|
||||
// Test splitting sample-based payloads.
|
||||
@@ -591,10 +591,10 @@ TEST_P(SplitIlbcTest, NumFrames) {
|
||||
PacketList packet_list;
|
||||
static const uint8_t kPayloadType = 17; // Just a random number.
|
||||
const int frame_length_samples = frame_length_ms_ * 8;
|
||||
int payload_length_bytes = frame_length_bytes_ * num_frames_;
|
||||
size_t payload_length_bytes = frame_length_bytes_ * num_frames_;
|
||||
Packet* packet = CreatePacket(kPayloadType, payload_length_bytes, 0);
|
||||
// Fill payload with increasing integers {0, 1, 2, ...}.
|
||||
for (int i = 0; i < packet->payload_length; ++i) {
|
||||
for (size_t i = 0; i < packet->payload_length; ++i) {
|
||||
packet->payload[i] = static_cast<uint8_t>(i);
|
||||
}
|
||||
packet_list.push_back(packet);
|
||||
@@ -624,7 +624,7 @@ TEST_P(SplitIlbcTest, NumFrames) {
|
||||
EXPECT_EQ(kSequenceNumber, packet->header.sequenceNumber);
|
||||
EXPECT_EQ(true, packet->primary);
|
||||
ASSERT_FALSE(packet->payload == NULL);
|
||||
for (int i = 0; i < packet->payload_length; ++i) {
|
||||
for (size_t i = 0; i < packet->payload_length; ++i) {
|
||||
EXPECT_EQ(payload_value, packet->payload[i]);
|
||||
++payload_value;
|
||||
}
|
||||
@@ -661,7 +661,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
TEST(IlbcPayloadSplitter, TooLargePayload) {
|
||||
PacketList packet_list;
|
||||
static const uint8_t kPayloadType = 17; // Just a random number.
|
||||
int kPayloadLengthBytes = 950;
|
||||
size_t kPayloadLengthBytes = 950;
|
||||
Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0);
|
||||
packet_list.push_back(packet);
|
||||
|
||||
@@ -692,7 +692,7 @@ TEST(IlbcPayloadSplitter, TooLargePayload) {
|
||||
TEST(IlbcPayloadSplitter, UnevenPayload) {
|
||||
PacketList packet_list;
|
||||
static const uint8_t kPayloadType = 17; // Just a random number.
|
||||
int kPayloadLengthBytes = 39; // Not an even number of frames.
|
||||
size_t kPayloadLengthBytes = 39; // Not an even number of frames.
|
||||
Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0);
|
||||
packet_list.push_back(packet);
|
||||
|
||||
@@ -744,7 +744,7 @@ TEST(FecPayloadSplitter, MixedPayload) {
|
||||
packet = packet_list.front();
|
||||
EXPECT_EQ(0, packet->header.payloadType);
|
||||
EXPECT_EQ(kBaseTimestamp - 20 * 48, packet->header.timestamp);
|
||||
EXPECT_EQ(10, packet->payload_length);
|
||||
EXPECT_EQ(10U, packet->payload_length);
|
||||
EXPECT_FALSE(packet->primary);
|
||||
delete [] packet->payload;
|
||||
delete packet;
|
||||
@@ -754,7 +754,7 @@ TEST(FecPayloadSplitter, MixedPayload) {
|
||||
packet = packet_list.front();
|
||||
EXPECT_EQ(0, packet->header.payloadType);
|
||||
EXPECT_EQ(kBaseTimestamp, packet->header.timestamp);
|
||||
EXPECT_EQ(10, packet->payload_length);
|
||||
EXPECT_EQ(10U, packet->payload_length);
|
||||
EXPECT_TRUE(packet->primary);
|
||||
delete [] packet->payload;
|
||||
delete packet;
|
||||
|
||||
@@ -329,7 +329,7 @@ uint8_t * NETEQTEST_RTPpacket::payload() const
|
||||
}
|
||||
}
|
||||
|
||||
int16_t NETEQTEST_RTPpacket::payloadLen()
|
||||
size_t NETEQTEST_RTPpacket::payloadLen()
|
||||
{
|
||||
parseHeader();
|
||||
return _payloadLen;
|
||||
@@ -752,7 +752,7 @@ void NETEQTEST_RTPpacket::splitStereoSample(NETEQTEST_RTPpacket* slaveRtp,
|
||||
int stride)
|
||||
{
|
||||
if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
|
||||
|| _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
|
||||
|| _payloadLen == 0 || slaveRtp->_memSize < _memSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -761,7 +761,7 @@ void NETEQTEST_RTPpacket::splitStereoSample(NETEQTEST_RTPpacket* slaveRtp,
|
||||
uint8_t *writeDataPtr = _payloadPtr;
|
||||
uint8_t *slaveData = slaveRtp->_payloadPtr;
|
||||
|
||||
while (readDataPtr - _payloadPtr < _payloadLen)
|
||||
while (readDataPtr - _payloadPtr < static_cast<ptrdiff_t>(_payloadLen))
|
||||
{
|
||||
// master data
|
||||
for (int ix = 0; ix < stride; ix++) {
|
||||
@@ -786,7 +786,7 @@ void NETEQTEST_RTPpacket::splitStereoSample(NETEQTEST_RTPpacket* slaveRtp,
|
||||
void NETEQTEST_RTPpacket::splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp)
|
||||
{
|
||||
if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
|
||||
|| _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
|
||||
|| _payloadLen == 0 || slaveRtp->_memSize < _memSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -799,7 +799,7 @@ void NETEQTEST_RTPpacket::splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp)
|
||||
void NETEQTEST_RTPpacket::splitStereoDouble(NETEQTEST_RTPpacket* slaveRtp)
|
||||
{
|
||||
if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
|
||||
|| _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
|
||||
|| _payloadLen == 0 || slaveRtp->_memSize < _memSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -868,7 +868,7 @@ void NETEQTEST_RTPpacket::scramblePayload(void)
|
||||
{
|
||||
parseHeader();
|
||||
|
||||
for (int i = 0; i < _payloadLen; ++i)
|
||||
for (size_t i = 0; i < _payloadLen; ++i)
|
||||
{
|
||||
_payloadPtr[i] = static_cast<uint8_t>(rand());
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
const webrtc::WebRtcRTPHeader* RTPinfo() const;
|
||||
uint8_t * datagram() const;
|
||||
uint8_t * payload() const;
|
||||
int16_t payloadLen();
|
||||
size_t payloadLen();
|
||||
int16_t dataLen() const;
|
||||
bool isParsed() const;
|
||||
bool isLost() const;
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
uint8_t * _payloadPtr;
|
||||
int _memSize;
|
||||
int16_t _datagramLen;
|
||||
int16_t _payloadLen;
|
||||
size_t _payloadLen;
|
||||
webrtc::WebRtcRTPHeader _rtpInfo;
|
||||
bool _rtpParsed;
|
||||
uint32_t _receiveTime;
|
||||
|
||||
@@ -64,9 +64,9 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms,
|
||||
const int16_t* input_samples = audio_loop.GetNextBlock();
|
||||
if (!input_samples) exit(1);
|
||||
uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)];
|
||||
int payload_len = WebRtcPcm16b_Encode(const_cast<int16_t*>(input_samples),
|
||||
kInputBlockSizeSamples,
|
||||
input_payload);
|
||||
size_t payload_len = WebRtcPcm16b_Encode(const_cast<int16_t*>(input_samples),
|
||||
kInputBlockSizeSamples,
|
||||
input_payload);
|
||||
assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t));
|
||||
|
||||
// Main loop.
|
||||
|
||||
@@ -118,7 +118,7 @@ class NetEqQualityTest : public ::testing::Test {
|
||||
// Expected output number of samples per channel in a frame.
|
||||
const int out_size_samples_;
|
||||
|
||||
int payload_size_bytes_;
|
||||
size_t payload_size_bytes_;
|
||||
int max_payload_bytes_;
|
||||
|
||||
scoped_ptr<InputAudioFile> in_file_;
|
||||
@@ -134,7 +134,7 @@ class NetEqQualityTest : public ::testing::Test {
|
||||
scoped_ptr<int16_t[]> out_data_;
|
||||
WebRtcRTPHeader rtp_header_;
|
||||
|
||||
long total_payload_size_bytes_;
|
||||
size_t total_payload_size_bytes_;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
|
||||
@@ -286,7 +286,7 @@ int main(int argc, char* argv[]) {
|
||||
int error =
|
||||
neteq->InsertPacket(rtp_header,
|
||||
payload_ptr,
|
||||
static_cast<int>(payload_len),
|
||||
payload_len,
|
||||
packet->time_ms() * sample_rate_hz / 1000);
|
||||
if (error != NetEq::kOK) {
|
||||
if (neteq->LastError() == NetEq::kUnknownRtpPayloadType) {
|
||||
|
||||
Reference in New Issue
Block a user