Reformat the WebRTC code base
Running clang-format with chromium's style guide.
The goal is n-fold:
* providing consistency and readability (that's what code guidelines are for)
* preventing noise with presubmit checks and git cl format
* building on the previous point: making it easier to automatically fix format issues
* you name it
Please consider using git-hyper-blame to ignore this commit.
Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
diff --git a/modules/audio_coding/test/Channel.cc b/modules/audio_coding/test/Channel.cc
index 7d5e6e2..8fdb677 100644
--- a/modules/audio_coding/test/Channel.cc
+++ b/modules/audio_coding/test/Channel.cc
@@ -30,11 +30,15 @@
rtpInfo.header.markerBit = false;
rtpInfo.header.ssrc = 0;
- rtpInfo.header.sequenceNumber = (external_sequence_number_ < 0) ?
- _seqNo++ : static_cast<uint16_t>(external_sequence_number_);
+ rtpInfo.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_);
+ rtpInfo.header.timestamp =
+ (external_send_timestamp_ < 0)
+ ? timeStamp
+ : static_cast<uint32_t>(external_send_timestamp_);
if (frameType == kAudioFrameCN) {
rtpInfo.type.Audio.isCNG = true;
@@ -57,7 +61,7 @@
// only 0x80 if we have multiple blocks
_payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1];
size_t REDheader = (fragmentation->fragmentationTimeDiff[1] << 10) +
- fragmentation->fragmentationLength[1];
+ fragmentation->fragmentationLength[1];
_payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF);
_payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF);
_payloadData[3] = uint8_t(REDheader & 0x000000FF);
@@ -96,7 +100,7 @@
_channelCritSect.Enter();
if (_saveBitStream) {
- //fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
+ // fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
}
if (!_isStereo) {
@@ -128,8 +132,8 @@
// TODO(turajs): rewite this method.
void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
int n;
- if ((rtpInfo.header.payloadType != _lastPayloadType)
- && (_lastPayloadType != -1)) {
+ if ((rtpInfo.header.payloadType != _lastPayloadType) &&
+ (_lastPayloadType != -1)) {
// payload-type is changed.
// we have to terminate the calculations on the previous payload type
// we ignore the last packet in that payload type just to make things
@@ -156,14 +160,15 @@
if (!newPayload) {
if (!currentPayloadStr->newPacket) {
if (!_useLastFrameSize) {
- _lastFrameSizeSample = (uint32_t) ((uint32_t) rtpInfo.header.timestamp -
- (uint32_t) currentPayloadStr->lastTimestamp);
+ _lastFrameSizeSample =
+ (uint32_t)((uint32_t)rtpInfo.header.timestamp -
+ (uint32_t)currentPayloadStr->lastTimestamp);
}
assert(_lastFrameSizeSample > 0);
int k = 0;
for (; k < MAX_NUM_FRAMESIZES; ++k) {
if ((currentPayloadStr->frameSizeStats[k].frameSizeSample ==
- _lastFrameSizeSample) ||
+ _lastFrameSizeSample) ||
(currentPayloadStr->frameSizeStats[k].frameSizeSample == 0)) {
break;
}
@@ -174,9 +179,9 @@
_lastPayloadType, _lastFrameSizeSample);
return;
}
- ACMTestFrameSizeStats* currentFrameSizeStats = &(currentPayloadStr
- ->frameSizeStats[k]);
- currentFrameSizeStats->frameSizeSample = (int16_t) _lastFrameSizeSample;
+ ACMTestFrameSizeStats* currentFrameSizeStats =
+ &(currentPayloadStr->frameSizeStats[k]);
+ currentFrameSizeStats->frameSizeSample = (int16_t)_lastFrameSizeSample;
// increment the number of encoded samples.
currentFrameSizeStats->totalEncodedSamples += _lastFrameSizeSample;
@@ -185,15 +190,15 @@
// increment the total number of bytes (this is based on
// the previous payload we don't know the frame-size of
// the current payload.
- currentFrameSizeStats->totalPayloadLenByte += currentPayloadStr
- ->lastPayloadLenByte;
+ currentFrameSizeStats->totalPayloadLenByte +=
+ currentPayloadStr->lastPayloadLenByte;
// store the maximum payload-size (this is based on
// the previous payload we don't know the frame-size of
// the current payload.
- if (currentFrameSizeStats->maxPayloadLen
- < currentPayloadStr->lastPayloadLenByte) {
- currentFrameSizeStats->maxPayloadLen = currentPayloadStr
- ->lastPayloadLenByte;
+ if (currentFrameSizeStats->maxPayloadLen <
+ currentPayloadStr->lastPayloadLenByte) {
+ currentFrameSizeStats->maxPayloadLen =
+ currentPayloadStr->lastPayloadLenByte;
}
// store the current values for the next time
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
@@ -203,8 +208,8 @@
currentPayloadStr->lastPayloadLenByte = payloadSize;
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
currentPayloadStr->payloadType = rtpInfo.header.payloadType;
- memset(currentPayloadStr->frameSizeStats, 0, MAX_NUM_FRAMESIZES *
- sizeof(ACMTestFrameSizeStats));
+ memset(currentPayloadStr->frameSizeStats, 0,
+ MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats));
}
} else {
n = 0;
@@ -216,8 +221,8 @@
_payloadStats[n].lastPayloadLenByte = payloadSize;
_payloadStats[n].lastTimestamp = rtpInfo.header.timestamp;
_payloadStats[n].payloadType = rtpInfo.header.payloadType;
- memset(_payloadStats[n].frameSizeStats, 0, MAX_NUM_FRAMESIZES *
- sizeof(ACMTestFrameSizeStats));
+ memset(_payloadStats[n].frameSizeStats, 0,
+ MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats));
}
}
@@ -262,8 +267,7 @@
}
}
-Channel::~Channel() {
-}
+Channel::~Channel() {}
void Channel::RegisterReceiverACM(AudioCodingModule* acm) {
_receiverACM = acm;
@@ -311,13 +315,13 @@
_channelCritSect.Leave();
return 0;
}
- payloadStats.frameSizeStats[n].usageLenSec = (double) payloadStats
- .frameSizeStats[n].totalEncodedSamples / (double) codecInst.plfreq;
+ payloadStats.frameSizeStats[n].usageLenSec =
+ (double)payloadStats.frameSizeStats[n].totalEncodedSamples /
+ (double)codecInst.plfreq;
payloadStats.frameSizeStats[n].rateBitPerSec =
- payloadStats.frameSizeStats[n].totalPayloadLenByte * 8
- / payloadStats.frameSizeStats[n].usageLenSec;
-
+ payloadStats.frameSizeStats[n].totalPayloadLenByte * 8 /
+ payloadStats.frameSizeStats[n].usageLenSec;
}
_channelCritSect.Leave();
return 0;
@@ -353,14 +357,14 @@
if (_payloadStats[k].payloadType == -1) {
break;
}
- payloadType[k] = (uint8_t) _payloadStats[k].payloadType;
+ payloadType[k] = (uint8_t)_payloadStats[k].payloadType;
payloadLenByte[k] = 0;
for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) {
break;
}
- payloadLenByte[k] += (uint16_t) _payloadStats[k].frameSizeStats[n]
- .totalPayloadLenByte;
+ payloadLenByte[k] +=
+ (uint16_t)_payloadStats[k].frameSizeStats[n].totalPayloadLenByte;
}
}
@@ -387,18 +391,15 @@
payloadStats.frameSizeStats[k].rateBitPerSec);
printf("Maximum Payload-Size.......... %" PRIuS " Bytes\n",
payloadStats.frameSizeStats[k].maxPayloadLen);
- printf(
- "Maximum Instantaneous Rate.... %.0f bits/sec\n",
- ((double) payloadStats.frameSizeStats[k].maxPayloadLen * 8.0
- * (double) codecInst.plfreq)
- / (double) payloadStats.frameSizeStats[k].frameSizeSample);
+ printf("Maximum Instantaneous Rate.... %.0f bits/sec\n",
+ ((double)payloadStats.frameSizeStats[k].maxPayloadLen * 8.0 *
+ (double)codecInst.plfreq) /
+ (double)payloadStats.frameSizeStats[k].frameSizeSample);
printf("Number of Packets............. %u\n",
- (unsigned int) payloadStats.frameSizeStats[k].numPackets);
+ (unsigned int)payloadStats.frameSizeStats[k].numPackets);
printf("Duration...................... %0.3f sec\n\n",
payloadStats.frameSizeStats[k].usageLenSec);
-
}
-
}
uint32_t Channel::LastInTimestamp() {
@@ -413,7 +414,7 @@
double rate;
uint64_t currTime = rtc::TimeMillis();
_channelCritSect.Enter();
- rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime);
+ rate = ((double)_totalBytes * 8.0) / (double)(currTime - _beginTime);
_channelCritSect.Leave();
return rate;
}
diff --git a/modules/audio_coding/test/Channel.h b/modules/audio_coding/test/Channel.h
index e01e33e..e5f5b54 100644
--- a/modules/audio_coding/test/Channel.h
+++ b/modules/audio_coding/test/Channel.h
@@ -20,8 +20,8 @@
namespace webrtc {
-#define MAX_NUM_PAYLOADS 50
-#define MAX_NUM_FRAMESIZES 6
+#define MAX_NUM_PAYLOADS 50
+#define MAX_NUM_FRAMESIZES 6
// TODO(turajs): Write constructor for this structure.
struct ACMTestFrameSizeStats {
@@ -45,7 +45,6 @@
class Channel : public AudioPacketizationCallback {
public:
-
Channel(int16_t chID = -1);
~Channel() override;
@@ -56,7 +55,7 @@
size_t payloadSize,
const RTPFragmentationHeader* fragmentation) override;
- void RegisterReceiverACM(AudioCodingModule *acm);
+ void RegisterReceiverACM(AudioCodingModule* acm);
void ResetStats();
@@ -68,9 +67,7 @@
void PrintStats(CodecInst& codecInst);
- void SetIsStereo(bool isStereo) {
- _isStereo = isStereo;
- }
+ void SetIsStereo(bool isStereo) { _isStereo = isStereo; }
uint32_t LastInTimestamp();
diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc
index 0bf4de5..4e16dc8 100644
--- a/modules/audio_coding/test/EncodeDecodeTest.cc
+++ b/modules/audio_coding/test/EncodeDecodeTest.cc
@@ -10,10 +10,10 @@
#include "modules/audio_coding/test/EncodeDecodeTest.h"
-#include <memory>
-#include <sstream>
#include <stdio.h>
#include <stdlib.h>
+#include <memory>
+#include <sstream> // no-presubmit-check TODO(webrtc:8982)
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "common_types.h" // NOLINT(build/include)
diff --git a/modules/audio_coding/test/PCMFile.cc b/modules/audio_coding/test/PCMFile.cc
index 2b2f1f0..659f968 100644
--- a/modules/audio_coding/test/PCMFile.cc
+++ b/modules/audio_coding/test/PCMFile.cc
@@ -30,8 +30,8 @@
rewinded_(false),
read_stereo_(false),
save_stereo_(false) {
- timestamp_ = (((uint32_t) rand() & 0x0000FFFF) << 16) |
- ((uint32_t) rand() & 0x0000FFFF);
+ timestamp_ =
+ (((uint32_t)rand() & 0x0000FFFF) << 16) | ((uint32_t)rand() & 0x0000FFFF);
}
PCMFile::PCMFile(uint32_t timestamp)
@@ -52,7 +52,8 @@
}
}
-int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len,
+int16_t PCMFile::ChooseFile(std::string* file_name,
+ int16_t max_len,
uint16_t* frequency_hz) {
char tmp_name[MAX_FILE_NAME_LENGTH_BYTE];
@@ -61,8 +62,8 @@
int16_t n = 0;
// Removing trailing spaces.
- while ((isspace(tmp_name[n]) || iscntrl(tmp_name[n])) && (tmp_name[n] != 0)
- && (n < MAX_FILE_NAME_LENGTH_BYTE)) {
+ while ((isspace(tmp_name[n]) || iscntrl(tmp_name[n])) && (tmp_name[n] != 0) &&
+ (n < MAX_FILE_NAME_LENGTH_BYTE)) {
n++;
}
if (n > 0) {
@@ -80,7 +81,7 @@
tmp_name[n + 1] = '\0';
}
- int16_t len = (int16_t) strlen(tmp_name);
+ int16_t len = (int16_t)strlen(tmp_name);
if (len > max_len) {
return -1;
}
@@ -91,15 +92,17 @@
printf("Enter the sampling frequency (in Hz) of the above file [%u]: ",
*frequency_hz);
EXPECT_TRUE(fgets(tmp_name, 10, stdin) != NULL);
- uint16_t tmp_frequency = (uint16_t) atoi(tmp_name);
+ uint16_t tmp_frequency = (uint16_t)atoi(tmp_name);
if (tmp_frequency > 0) {
*frequency_hz = tmp_frequency;
}
return 0;
}
-void PCMFile::Open(const std::string& file_name, uint16_t frequency,
- const char* mode, bool auto_rewind) {
+void PCMFile::Open(const std::string& file_name,
+ uint16_t frequency,
+ const char* mode,
+ bool auto_rewind) {
if ((pcm_file_ = fopen(file_name.c_str(), mode)) == NULL) {
printf("Cannot open file %s.\n", file_name.c_str());
ADD_FAILURE() << "Unable to read file";
@@ -125,9 +128,9 @@
channels = 2;
}
- int32_t payload_size = (int32_t) fread(audio_frame.mutable_data(),
- sizeof(uint16_t),
- samples_10ms_ * channels, pcm_file_);
+ int32_t payload_size =
+ (int32_t)fread(audio_frame.mutable_data(), sizeof(uint16_t),
+ samples_10ms_ * channels, pcm_file_);
if (payload_size < samples_10ms_ * channels) {
int16_t* frame_data = audio_frame.mutable_data();
for (int k = payload_size; k < samples_10ms_ * channels; k++) {
diff --git a/modules/audio_coding/test/PCMFile.h b/modules/audio_coding/test/PCMFile.h
index 05b9828..dc7a4fc 100644
--- a/modules/audio_coding/test/PCMFile.h
+++ b/modules/audio_coding/test/PCMFile.h
@@ -28,26 +28,27 @@
PCMFile(uint32_t timestamp);
~PCMFile();
- void Open(const std::string& filename, uint16_t frequency, const char* mode,
+ void Open(const std::string& filename,
+ uint16_t frequency,
+ const char* mode,
bool auto_rewind = false);
int32_t Read10MsData(AudioFrame& audio_frame);
- void Write10MsData(const int16_t *playout_buffer, size_t length_smpls);
+ void Write10MsData(const int16_t* playout_buffer, size_t length_smpls);
void Write10MsData(const AudioFrame& audio_frame);
uint16_t PayloadLength10Ms() const;
int32_t SamplingFrequency() const;
void Close();
- bool EndOfFile() const {
- return end_of_file_;
- }
+ bool EndOfFile() const { return end_of_file_; }
// Moves forward the specified number of 10 ms blocks. If a limit has been set
// with SetNum10MsBlocksToRead, fast-forwarding does not count towards this
// limit.
void FastForward(int num_10ms_blocks);
void Rewind();
- static int16_t ChooseFile(std::string* file_name, int16_t max_len,
+ static int16_t ChooseFile(std::string* file_name,
+ int16_t max_len,
uint16_t* frequency_hz);
bool Rewinded();
void SaveStereo(bool is_stereo = true);
diff --git a/modules/audio_coding/test/PacketLossTest.cc b/modules/audio_coding/test/PacketLossTest.cc
index d5fbfd1..c5cb396 100644
--- a/modules/audio_coding/test/PacketLossTest.cc
+++ b/modules/audio_coding/test/PacketLossTest.cc
@@ -23,11 +23,10 @@
burst_length_(1),
packet_counter_(0),
lost_packet_counter_(0),
- burst_lost_counter_(burst_length_) {
-}
+ burst_lost_counter_(burst_length_) {}
-void ReceiverWithPacketLoss::Setup(AudioCodingModule *acm,
- RTPStream *rtpStream,
+void ReceiverWithPacketLoss::Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
std::string out_file_name,
int channels,
int loss_rate,
@@ -84,13 +83,14 @@
return false;
}
-SenderWithFEC::SenderWithFEC()
- : expected_loss_rate_(0) {
-}
+SenderWithFEC::SenderWithFEC() : expected_loss_rate_(0) {}
-void SenderWithFEC::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
- std::string in_file_name, int sample_rate,
- int channels, int expected_loss_rate) {
+void SenderWithFEC::Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
+ std::string in_file_name,
+ int sample_rate,
+ int channels,
+ int expected_loss_rate) {
Sender::Setup(acm, rtpStream, in_file_name, sample_rate, channels);
EXPECT_TRUE(SetFEC(true));
EXPECT_TRUE(SetPacketLossRate(expected_loss_rate));
@@ -111,18 +111,19 @@
return false;
}
-PacketLossTest::PacketLossTest(int channels, int expected_loss_rate,
- int actual_loss_rate, int burst_length)
+PacketLossTest::PacketLossTest(int channels,
+ int expected_loss_rate,
+ int actual_loss_rate,
+ int burst_length)
: channels_(channels),
- in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" :
- "audio_coding/teststereo32kHz"),
+ in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz"
+ : "audio_coding/teststereo32kHz"),
sample_rate_hz_(32000),
sender_(new SenderWithFEC),
receiver_(new ReceiverWithPacketLoss),
expected_loss_rate_(expected_loss_rate),
actual_loss_rate_(actual_loss_rate),
- burst_length_(burst_length) {
-}
+ burst_length_(burst_length) {}
void PacketLossTest::Perform() {
#ifndef WEBRTC_CODEC_OPUS
diff --git a/modules/audio_coding/test/PacketLossTest.h b/modules/audio_coding/test/PacketLossTest.h
index 7eab442..f6f92db 100644
--- a/modules/audio_coding/test/PacketLossTest.h
+++ b/modules/audio_coding/test/PacketLossTest.h
@@ -20,8 +20,11 @@
class ReceiverWithPacketLoss : public Receiver {
public:
ReceiverWithPacketLoss();
- void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
- std::string out_file_name, int channels, int loss_rate,
+ void Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
+ std::string out_file_name,
+ int channels,
+ int loss_rate,
int burst_length);
bool IncomingPacket() override;
@@ -37,20 +40,27 @@
class SenderWithFEC : public Sender {
public:
SenderWithFEC();
- void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
- std::string in_file_name, int sample_rate, int channels,
+ void Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
+ std::string in_file_name,
+ int sample_rate,
+ int channels,
int expected_loss_rate);
bool SetPacketLossRate(int expected_loss_rate);
bool SetFEC(bool enable_fec);
+
protected:
int expected_loss_rate_;
};
class PacketLossTest : public ACMTest {
public:
- PacketLossTest(int channels, int expected_loss_rate_, int actual_loss_rate,
+ PacketLossTest(int channels,
+ int expected_loss_rate_,
+ int actual_loss_rate,
int burst_length);
void Perform();
+
protected:
int channels_;
std::string in_file_name_;
diff --git a/modules/audio_coding/test/RTPFile.cc b/modules/audio_coding/test/RTPFile.cc
index 8cc5bd9..a1329e7 100644
--- a/modules/audio_coding/test/RTPFile.cc
+++ b/modules/audio_coding/test/RTPFile.cc
@@ -14,9 +14,9 @@
#include <limits>
#ifdef WIN32
-# include <Winsock2.h>
+#include <Winsock2.h>
#else
-# include <arpa/inet.h>
+#include <arpa/inet.h>
#endif
#include "modules/include/module_common_types.h"
@@ -29,18 +29,22 @@
void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo,
const uint8_t* rtpHeader) {
rtpInfo->header.payloadType = rtpHeader[1];
- rtpInfo->header.sequenceNumber = (static_cast<uint16_t>(rtpHeader[2]) << 8) |
- rtpHeader[3];
+ rtpInfo->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];
+ (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];
+ (static_cast<uint32_t>(rtpHeader[9]) << 16) |
+ (static_cast<uint32_t>(rtpHeader[10]) << 8) |
+ rtpHeader[11];
}
-void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType,
- int16_t seqNo, uint32_t timeStamp,
+void RTPStream::MakeRTPheader(uint8_t* rtpHeader,
+ uint8_t payloadType,
+ int16_t seqNo,
+ uint32_t timeStamp,
uint32_t ssrc) {
rtpHeader[0] = 0x80;
rtpHeader[1] = payloadType;
@@ -56,8 +60,11 @@
rtpHeader[11] = ssrc & 0xFF;
}
-RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
- const uint8_t* payloadData, size_t payloadSize,
+RTPPacket::RTPPacket(uint8_t payloadType,
+ uint32_t timeStamp,
+ int16_t seqNo,
+ const uint8_t* payloadData,
+ size_t payloadSize,
uint32_t frequency)
: payloadType(payloadType),
timeStamp(timeStamp),
@@ -82,20 +89,25 @@
delete _queueRWLock;
}
-void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp,
- const int16_t seqNo, const uint8_t* payloadData,
- const size_t payloadSize, uint32_t frequency) {
- RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData,
+void RTPBuffer::Write(const uint8_t payloadType,
+ const uint32_t timeStamp,
+ const int16_t seqNo,
+ const uint8_t* payloadData,
+ const size_t payloadSize,
+ uint32_t frequency) {
+ RTPPacket* packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData,
payloadSize, frequency);
_queueRWLock->AcquireLockExclusive();
_rtpQueue.push(packet);
_queueRWLock->ReleaseLockExclusive();
}
-size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
- size_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();
+ RTPPacket* packet = _rtpQueue.front();
_rtpQueue.pop();
_queueRWLock->ReleaseLockShared();
rtpInfo->header.markerBit = 1;
@@ -120,7 +132,7 @@
return eof;
}
-void RTPFile::Open(const char *filename, const char *mode) {
+void RTPFile::Open(const char* filename, const char* mode) {
if ((_rtpFile = fopen(filename, mode)) == NULL) {
printf("Cannot write file %s.\n", filename);
ADD_FAILURE() << "Unable to write file";
@@ -165,9 +177,12 @@
padding = ntohs(padding);
}
-void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp,
- const int16_t seqNo, const uint8_t* payloadData,
- const size_t payloadSize, uint32_t frequency) {
+void RTPFile::Write(const uint8_t payloadType,
+ const uint32_t timeStamp,
+ const int16_t seqNo,
+ const uint8_t* payloadData,
+ const size_t payloadSize,
+ uint32_t frequency) {
/* write RTP packet to file */
uint8_t rtpHeader[12];
MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0);
@@ -185,8 +200,10 @@
EXPECT_EQ(payloadSize, fwrite(payloadData, 1, payloadSize, _rtpFile));
}
-size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
- size_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];
diff --git a/modules/audio_coding/test/RTPFile.h b/modules/audio_coding/test/RTPFile.h
index b9afe2f..73e97dd 100644
--- a/modules/audio_coding/test/RTPFile.h
+++ b/modules/audio_coding/test/RTPFile.h
@@ -22,30 +22,40 @@
class RTPStream {
public:
- virtual ~RTPStream() {
- }
+ virtual ~RTPStream() {}
- virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
- const int16_t seqNo, const uint8_t* payloadData,
- const size_t payloadSize, uint32_t frequency) = 0;
+ virtual void Write(const uint8_t payloadType,
+ const uint32_t timeStamp,
+ const int16_t seqNo,
+ const uint8_t* payloadData,
+ 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 size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
- size_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:
- void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, int16_t seqNo,
- uint32_t timeStamp, uint32_t ssrc);
+ void MakeRTPheader(uint8_t* rtpHeader,
+ uint8_t payloadType,
+ int16_t seqNo,
+ uint32_t timeStamp,
+ uint32_t ssrc);
void ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader);
};
class RTPPacket {
public:
- RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
- const uint8_t* payloadData, size_t payloadSize,
+ RTPPacket(uint8_t payloadType,
+ uint32_t timeStamp,
+ int16_t seqNo,
+ const uint8_t* payloadData,
+ size_t payloadSize,
uint32_t frequency);
~RTPPacket();
@@ -80,20 +90,16 @@
private:
RWLockWrapper* _queueRWLock;
- std::queue<RTPPacket *> _rtpQueue;
+ std::queue<RTPPacket*> _rtpQueue;
};
class RTPFile : public RTPStream {
public:
- ~RTPFile() {
- }
+ ~RTPFile() {}
- RTPFile()
- : _rtpFile(NULL),
- _rtpEOF(false) {
- }
+ RTPFile() : _rtpFile(NULL), _rtpEOF(false) {}
- void Open(const char *outFilename, const char *mode);
+ void Open(const char* outFilename, const char* mode);
void Close();
diff --git a/modules/audio_coding/test/TestAllCodecs.cc b/modules/audio_coding/test/TestAllCodecs.cc
index f8debe9..df9c731 100644
--- a/modules/audio_coding/test/TestAllCodecs.cc
+++ b/modules/audio_coding/test/TestAllCodecs.cc
@@ -46,19 +46,19 @@
timestamp_diff_(0),
last_in_timestamp_(0),
total_bytes_(0),
- payload_size_(0) {
-}
+ payload_size_(0) {}
-TestPack::~TestPack() {
-}
+TestPack::~TestPack() {}
void TestPack::RegisterReceiverACM(AudioCodingModule* acm) {
receiver_acm_ = acm;
return;
}
-int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type,
- uint32_t timestamp, const uint8_t* payload_data,
+int32_t TestPack::SendData(FrameType frame_type,
+ uint8_t payload_type,
+ uint32_t timestamp,
+ const uint8_t* payload_data,
size_t payload_size,
const RTPFragmentationHeader* fragmentation) {
WebRtcRTPHeader rtp_info;
@@ -125,8 +125,8 @@
}
void TestAllCodecs::Perform() {
- const std::string file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ const std::string file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
infile_a_.Open(file_name, 32000, "rb");
if (test_mode_ == 0) {
@@ -306,17 +306,17 @@
char codec_opus[] = "OPUS";
RegisterSendCodec('A', codec_opus, 48000, 6000, 480, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 20000, 480 * 2, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 32000, 480 * 4, kVariableSize);
Run(channel_a_to_b_);
RegisterSendCodec('A', codec_opus, 48000, 48000, 480, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 4, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 96000, 480 * 6, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 500000, 480 * 2, kVariableSize);
Run(channel_a_to_b_);
outfile_b_.Close();
#endif
@@ -351,9 +351,12 @@
// used when registering, can be an internal header
// 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, size_t extra_byte) {
+void TestAllCodecs::RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t sampling_freq_hz,
+ int rate,
+ 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,
@@ -377,9 +380,11 @@
// packet. If variable rate codec (extra_byte == -1), set to -1.
if (extra_byte != kVariableSize) {
// Add 0.875 to always round up to a whole 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;
+ 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_ = kVariableSize;
@@ -396,9 +401,7 @@
my_acm = acm_b_.get();
break;
}
- default: {
- break;
- }
+ default: { break; }
}
ASSERT_TRUE(my_acm != NULL);
diff --git a/modules/audio_coding/test/TestAllCodecs.h b/modules/audio_coding/test/TestAllCodecs.h
index e0285e9..36269a9 100644
--- a/modules/audio_coding/test/TestAllCodecs.h
+++ b/modules/audio_coding/test/TestAllCodecs.h
@@ -60,8 +60,12 @@
// codec name, and a sampling frequency matching is not required.
// 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, size_t extra_byte);
+ void RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t sampling_freq_hz,
+ int rate,
+ int packet_size,
+ size_t extra_byte);
void Run(TestPack* channel);
void OpenOutFile(int test_number);
diff --git a/modules/audio_coding/test/TestRedFec.h b/modules/audio_coding/test/TestRedFec.h
index 98aa008..1d9dead 100644
--- a/modules/audio_coding/test/TestRedFec.h
+++ b/modules/audio_coding/test/TestRedFec.h
@@ -26,11 +26,13 @@
~TestRedFec();
void Perform();
+
private:
// The default value of '-1' indicates that the registration is based only on
// codec name and a sampling frequency matching is not required. This is
// useful for codecs which support several sampling frequency.
- int16_t RegisterSendCodec(char side, const char* codecName,
+ int16_t RegisterSendCodec(char side,
+ const char* codecName,
int32_t sampFreqHz = -1);
void Run();
void OpenOutFile(int16_t testNumber);
diff --git a/modules/audio_coding/test/TestStereo.cc b/modules/audio_coding/test/TestStereo.cc
index 2002068..2704d3d 100644
--- a/modules/audio_coding/test/TestStereo.cc
+++ b/modules/audio_coding/test/TestStereo.cc
@@ -34,11 +34,9 @@
total_bytes_(0),
payload_size_(0),
codec_mode_(kNotSet),
- lost_packet_(false) {
-}
+ lost_packet_(false) {}
-TestPackStereo::~TestPackStereo() {
-}
+TestPackStereo::~TestPackStereo() {}
void TestPackStereo::RegisterReceiverACM(AudioCodingModule* acm) {
receiver_acm_ = acm;
@@ -72,8 +70,8 @@
rtp_info.type.Audio.isCNG = true;
rtp_info.type.Audio.channel = static_cast<int>(kMono);
}
- status = receiver_acm_->IncomingPacket(payload_data, payload_size,
- rtp_info);
+ status =
+ receiver_acm_->IncomingPacket(payload_data, payload_size, rtp_info);
if (frame_type != kAudioFrameCN) {
payload_size_ = static_cast<int>(payload_size);
@@ -152,10 +150,10 @@
ACMVADMode vad_mode;
// Open both mono and stereo test files in 32 kHz.
- const std::string file_name_stereo = webrtc::test::ResourcePath(
- "audio_coding/teststereo32kHz", "pcm");
- const std::string file_name_mono = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ const std::string file_name_stereo =
+ webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm");
+ const std::string file_name_mono =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequency_hz = 32000;
in_file_stereo_ = new PCMFile();
in_file_mono_ = new PCMFile();
@@ -230,22 +228,22 @@
OpenOutFile(test_cntr_);
char codec_g722[] = "G722";
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 320, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 480, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 640, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 800, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 960, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -259,16 +257,16 @@
OpenOutFile(test_cntr_);
char codec_l16[] = "L16";
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 8000, 128000, 160, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 8000, 128000, 240, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 8000, 128000, 320, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -280,16 +278,16 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 16000, 256000, 320, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 16000, 256000, 480, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 16000, 256000, 640, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -301,10 +299,10 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 32000, 512000, 640, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#ifdef PCMA_AND_PCMU
@@ -392,26 +390,26 @@
char codec_opus[] = "opus";
// Run Opus with 10 ms frame size.
RegisterSendCodec('A', codec_opus, 48000, 64000, 480, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 20 ms frame size.
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*2, codec_channels,
- opus_pltype_);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 2, codec_channels,
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 40 ms frame size.
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, codec_channels,
- opus_pltype_);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 4, codec_channels,
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 60 ms frame size.
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*6, codec_channels,
- opus_pltype_);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 6, codec_channels,
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 20 ms frame size and different bitrates.
RegisterSendCodec('A', codec_opus, 48000, 40000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_opus, 48000, 510000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
@@ -430,7 +428,7 @@
channel_a2b_->set_codec_mode(kStereo);
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -443,7 +441,7 @@
channel_a2b_->set_codec_mode(kStereo);
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -454,7 +452,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -465,7 +463,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#ifdef PCMA_AND_PCMU
@@ -497,7 +495,7 @@
channel_a2b_->set_codec_mode(kStereo);
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_opus, 48000, 64000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Encode in mono, decode in stereo mode.
@@ -522,7 +520,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
- g722_pltype_);
+ g722_pltype_);
// Make sure it is possible to set VAD/CNG, now that we are sending mono
// again.
@@ -542,7 +540,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -553,7 +551,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -564,7 +562,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#ifdef PCMA_AND_PCMU
@@ -593,7 +591,7 @@
OpenOutFile(test_cntr_);
// Encode and decode in mono.
RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
CodecInst opus_codec_param;
for (uint8_t n = 0; n < num_encoders; n++) {
EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param));
@@ -620,8 +618,10 @@
OpenOutFile(test_cntr_);
if (test_mode_ != 0) {
// Print out codec and settings
- printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
- " Decode: mono\n", test_cntr_);
+ printf(
+ "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
+ " Decode: mono\n",
+ test_cntr_);
}
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -630,8 +630,10 @@
OpenOutFile(test_cntr_);
if (test_mode_ != 0) {
// Print out codec and settings
- printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
- " Decode: stereo\n", test_cntr_);
+ printf(
+ "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
+ " Decode: stereo\n",
+ test_cntr_);
}
opus_codec_param.channels = 2;
EXPECT_EQ(true,
@@ -644,8 +646,10 @@
OpenOutFile(test_cntr_);
if (test_mode_ != 0) {
// Print out codec and settings
- printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
- " Decode: mono\n", test_cntr_);
+ printf(
+ "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
+ " Decode: mono\n",
+ test_cntr_);
}
opus_codec_param.channels = 1;
EXPECT_EQ(true,
@@ -665,9 +669,10 @@
#ifdef WEBRTC_CODEC_OPUS
printf(" Opus\n");
#endif
- printf("\nTo complete the test, listen to the %d number of output "
- "files.\n",
- test_cntr_);
+ printf(
+ "\nTo complete the test, listen to the %d number of output "
+ "files.\n",
+ test_cntr_);
}
// Delete the file pointers.
@@ -684,9 +689,12 @@
// pack_size - packet size in samples
// channels - number of channels; 1 for mono, 2 for stereo
// payload_type - payload type for the codec
-void TestStereo::RegisterSendCodec(char side, char* codec_name,
- int32_t sampling_freq_hz, int rate,
- int pack_size, int channels,
+void TestStereo::RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t sampling_freq_hz,
+ int rate,
+ int pack_size,
+ int channels,
int payload_type) {
if (test_mode_ != 0) {
// Print out codec and settings
@@ -722,7 +730,8 @@
CodecInst my_codec_param;
// Get all codec parameters before registering
EXPECT_GT(AudioCodingModule::Codec(codec_name, &my_codec_param,
- sampling_freq_hz, channels), -1);
+ sampling_freq_hz, channels),
+ -1);
my_codec_param.rate = rate;
my_codec_param.pacsize = pack_size;
EXPECT_EQ(0, my_acm->RegisterSendCodec(my_codec_param));
@@ -730,7 +739,9 @@
send_codec_name_ = codec_name;
}
-void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
+void TestStereo::Run(TestPackStereo* channel,
+ int in_channels,
+ int out_channels,
int percent_loss) {
AudioFrame audio_frame;
@@ -785,8 +796,8 @@
variable_packets++;
} else {
// For fixed rate codecs, check that packet size is correct.
- if ((rec_size != pack_size_bytes_ * out_channels)
- && (pack_size_bytes_ < 65535)) {
+ if ((rec_size != pack_size_bytes_ * out_channels) &&
+ (pack_size_bytes_ < 65535)) {
error_count++;
}
}
@@ -831,7 +842,7 @@
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath() << "teststereo_out_" << test_number
- << ".pcm";
+ << ".pcm";
file_name = file_stream.str();
out_file_.Open(file_name, 32000, "wb");
}
diff --git a/modules/audio_coding/test/TestStereo.h b/modules/audio_coding/test/TestStereo.h
index a454f25..6fd7d6f 100644
--- a/modules/audio_coding/test/TestStereo.h
+++ b/modules/audio_coding/test/TestStereo.h
@@ -23,11 +23,7 @@
namespace webrtc {
-enum StereoMonoMode {
- kNotSet,
- kMono,
- kStereo
-};
+enum StereoMonoMode { kNotSet, kMono, kStereo };
class TestPackStereo : public AudioPacketizationCallback {
public:
@@ -72,11 +68,17 @@
// The default value of '-1' indicates that the registration is based only on
// codec name and a sampling frequncy matching is not required. This is useful
// for codecs which support several sampling frequency.
- void RegisterSendCodec(char side, char* codec_name, int32_t samp_freq_hz,
- int rate, int pack_size, int channels,
+ void RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t samp_freq_hz,
+ int rate,
+ int pack_size,
+ int channels,
int payload_type);
- void Run(TestPackStereo* channel, int in_channels, int out_channels,
+ void Run(TestPackStereo* channel,
+ int in_channels,
+ int out_channels,
int percent_loss = 0);
void OpenOutFile(int16_t test_number);
void DisplaySendReceiveCodec();
diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc
index 5865638..d211a6b 100644
--- a/modules/audio_coding/test/TestVADDTX.cc
+++ b/modules/audio_coding/test/TestVADDTX.cc
@@ -84,8 +84,11 @@
// Encoding a file and see if the numbers that various packets occur follow
// the expectation.
-void TestVadDtx::Run(std::string in_filename, int frequency, int channels,
- std::string out_filename, bool append,
+void TestVadDtx::Run(std::string in_filename,
+ int frequency,
+ int channels,
+ std::string out_filename,
+ bool append,
const int* expects) {
monitor_->ResetStatistics();
@@ -146,13 +149,10 @@
// Following is the implementation of TestWebRtcVadDtx.
TestWebRtcVadDtx::TestWebRtcVadDtx()
- : vad_enabled_(false),
- dtx_enabled_(false),
- output_file_num_(0) {
-}
+ : vad_enabled_(false), dtx_enabled_(false), output_file_num_(0) {}
void TestWebRtcVadDtx::Perform() {
- // Go through various test cases.
+// Go through various test cases.
#ifdef WEBRTC_CODEC_ISAC
// Register iSAC WB as send codec
RegisterCodec(kIsacWb);
@@ -206,15 +206,14 @@
output_file_num_++;
}
std::stringstream out_filename;
- out_filename << webrtc::test::OutputPath()
- << "testWebRtcVadDtx_outFile_"
- << output_file_num_
- << ".pcm";
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename.str(), !new_outfile, expects);
+ out_filename << webrtc::test::OutputPath() << "testWebRtcVadDtx_outFile_"
+ << output_file_num_ << ".pcm";
+ Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1,
+ out_filename.str(), !new_outfile, expects);
}
-void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad,
+void TestWebRtcVadDtx::SetVAD(bool enable_dtx,
+ bool enable_vad,
ACMVADMode vad_mode) {
ACMVADMode mode;
EXPECT_EQ(0, acm_send_->SetVAD(enable_dtx, enable_vad, vad_mode));
@@ -227,10 +226,10 @@
enable_dtx = enable_vad = false;
}
- EXPECT_EQ(dtx_enabled_ , enable_dtx); // DTX should be set as expected.
+ EXPECT_EQ(dtx_enabled_, enable_dtx); // DTX should be set as expected.
if (dtx_enabled_) {
- EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD.
+ EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD.
} else {
// Using no DTX should not affect setting of VAD.
EXPECT_EQ(enable_vad, vad_enabled_);
@@ -250,19 +249,19 @@
int expects[] = {0, 1, 0, 0, 0};
// Register Opus as send codec
- std::string out_filename = webrtc::test::OutputPath() +
- "testOpusDtx_outFile_mono.pcm";
+ std::string out_filename =
+ webrtc::test::OutputPath() + "testOpusDtx_outFile_mono.pcm";
RegisterCodec(kOpus);
EXPECT_EQ(0, acm_send_->DisableOpusDtx());
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename, false, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1,
+ out_filename, false, expects);
EXPECT_EQ(0, acm_send_->EnableOpusDtx());
expects[kEmptyFrame] = 1;
expects[kAudioFrameCN] = 1;
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename, true, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1,
+ out_filename, true, expects);
// Register stereo Opus as send codec
out_filename = webrtc::test::OutputPath() + "testOpusDtx_outFile_stereo.pcm";
@@ -270,15 +269,15 @@
EXPECT_EQ(0, acm_send_->DisableOpusDtx());
expects[kEmptyFrame] = 0;
expects[kAudioFrameCN] = 0;
- Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
- 32000, 2, out_filename, false, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000,
+ 2, out_filename, false, expects);
EXPECT_EQ(0, acm_send_->EnableOpusDtx());
expects[kEmptyFrame] = 1;
expects[kAudioFrameCN] = 1;
- Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
- 32000, 2, out_filename, true, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000,
+ 2, out_filename, true, expects);
#endif
}
diff --git a/modules/audio_coding/test/TestVADDTX.h b/modules/audio_coding/test/TestVADDTX.h
index 8cd4444..e3840f7 100644
--- a/modules/audio_coding/test/TestVADDTX.h
+++ b/modules/audio_coding/test/TestVADDTX.h
@@ -28,6 +28,7 @@
void PrintStatistics();
void ResetStatistics();
void GetStatistics(uint32_t* stats);
+
private:
// 0 - kEmptyFrame
// 1 - kAudioFrameSpeech
@@ -37,7 +38,6 @@
uint32_t counter_[5];
};
-
// TestVadDtx is to verify that VAD/DTX perform as they should. It runs through
// an audio file and check if the occurrence of various packet types follows
// expectation. TestVadDtx needs its derived class to implement the Perform()
@@ -65,8 +65,12 @@
// 2 - kAudioFrameCN
// 3 - kVideoFrameKey (not used by audio)
// 4 - kVideoFrameDelta (not used by audio)
- void Run(std::string in_filename, int frequency, int channels,
- std::string out_filename, bool append, const int* expects);
+ void Run(std::string in_filename,
+ int frequency,
+ int channels,
+ std::string out_filename,
+ bool append,
+ const int* expects);
std::unique_ptr<AudioCodingModule> acm_send_;
std::unique_ptr<AudioCodingModule> acm_receive_;
diff --git a/modules/audio_coding/test/Tester.cc b/modules/audio_coding/test/Tester.cc
index 1124222..8ce50a4 100644
--- a/modules/audio_coding/test/Tester.cc
+++ b/modules/audio_coding/test/Tester.cc
@@ -115,7 +115,7 @@
#if defined(WEBRTC_IOS)
TEST(AudioCodingModuleTest, DISABLED_TestPacketLossStereo) {
#else
- TEST(AudioCodingModuleTest, TestPacketLossStereo) {
+TEST(AudioCodingModuleTest, TestPacketLossStereo) {
#endif
webrtc::PacketLossTest(2, 10, 10, 1).Perform();
}
@@ -128,3 +128,11 @@
#endif
webrtc::PacketLossTest(2, 10, 10, 2).Perform();
}
+
+// The full API test is too long to run automatically on bots, but can be used
+// for offline testing. User interaction is needed.
+#ifdef ACM_TEST_FULL_API
+TEST(AudioCodingModuleTest, TestAPI) {
+ webrtc::APITest().Perform();
+}
+#endif
diff --git a/modules/audio_coding/test/TwoWayCommunication.cc b/modules/audio_coding/test/TwoWayCommunication.cc
index 1ed5a72..5a78c11 100644
--- a/modules/audio_coding/test/TwoWayCommunication.cc
+++ b/modules/audio_coding/test/TwoWayCommunication.cc
@@ -60,8 +60,7 @@
_outFileRefB.Close();
}
-void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
- uint8_t* codecID_B) {
+void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B) {
std::unique_ptr<AudioCodingModule> tmpACM(AudioCodingModule::Create(
AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory())));
uint8_t noCodec = tmpACM->NumberOfCodecs();
@@ -75,11 +74,11 @@
printf("\nChoose a send codec for side A [0]: ");
char myStr[15] = "";
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
- *codecID_A = (uint8_t) atoi(myStr);
+ *codecID_A = (uint8_t)atoi(myStr);
printf("\nChoose a send codec for side B [0]: ");
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
- *codecID_B = (uint8_t) atoi(myStr);
+ *codecID_B = (uint8_t)atoi(myStr);
printf("\n");
}
@@ -118,8 +117,8 @@
uint16_t frequencyHz;
//--- Input A
- std::string in_file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ std::string in_file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000;
printf("Enter input file at side A [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
@@ -134,8 +133,8 @@
_outFileRefA.Open(ref_file_name, frequencyHz, "wb");
//--- Input B
- in_file_name = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
- "pcm");
+ in_file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000;
printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
@@ -200,8 +199,8 @@
uint16_t frequencyHz;
//--- Input A and B
- std::string in_file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ std::string in_file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 16000;
_inFileA.Open(in_file_name, frequencyHz, "rb");
_inFileB.Open(in_file_name, frequencyHz, "rb");
@@ -210,16 +209,16 @@
std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm";
frequencyHz = 16000;
_outFileA.Open(output_file_a, frequencyHz, "wb");
- std::string output_ref_file_a = webrtc::test::OutputPath()
- + "ref_outAutotestA.pcm";
+ std::string output_ref_file_a =
+ webrtc::test::OutputPath() + "ref_outAutotestA.pcm";
_outFileRefA.Open(output_ref_file_a, frequencyHz, "wb");
//--- Output B
std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm";
frequencyHz = 16000;
_outFileB.Open(output_file_b, frequencyHz, "wb");
- std::string output_ref_file_b = webrtc::test::OutputPath()
- + "ref_outAutotestB.pcm";
+ std::string output_ref_file_b =
+ webrtc::test::OutputPath() + "ref_outAutotestB.pcm";
_outFileRefB.Open(output_ref_file_b, frequencyHz, "wb");
//--- Set A-to-B channel
diff --git a/modules/audio_coding/test/TwoWayCommunication.h b/modules/audio_coding/test/TwoWayCommunication.h
index fb23275..f0becae 100644
--- a/modules/audio_coding/test/TwoWayCommunication.h
+++ b/modules/audio_coding/test/TwoWayCommunication.h
@@ -27,6 +27,7 @@
~TwoWayCommunication();
void Perform();
+
private:
void ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B);
void SetUp();
diff --git a/modules/audio_coding/test/delay_test.cc b/modules/audio_coding/test/delay_test.cc
index 532a8eb..3c20a54 100644
--- a/modules/audio_coding/test/delay_test.cc
+++ b/modules/audio_coding/test/delay_test.cc
@@ -83,26 +83,25 @@
void Initialize() {
test_cntr_ = 0;
- std::string file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ std::string file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
if (strlen(FLAG_input_file) > 0)
file_name = FLAG_input_file;
in_file_a_.Open(file_name, 32000, "rb");
- ASSERT_EQ(0, acm_a_->InitializeReceiver()) <<
- "Couldn't initialize receiver.\n";
- ASSERT_EQ(0, acm_b_->InitializeReceiver()) <<
- "Couldn't initialize receiver.\n";
+ ASSERT_EQ(0, acm_a_->InitializeReceiver())
+ << "Couldn't initialize receiver.\n";
+ ASSERT_EQ(0, acm_b_->InitializeReceiver())
+ << "Couldn't initialize receiver.\n";
if (FLAG_delay > 0) {
- ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay)) <<
- "Failed to set minimum delay.\n";
+ ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay))
+ << "Failed to set minimum delay.\n";
}
int num_encoders = acm_a_->NumberOfCodecs();
CodecInst my_codec_param;
for (int n = 0; n < num_encoders; n++) {
- EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)) <<
- "Failed to get codec.";
+ EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)) << "Failed to get codec.";
if (STR_CASE_CMP(my_codec_param.plname, "opus") == 0)
my_codec_param.channels = 1;
else if (my_codec_param.channels > 1)
@@ -118,12 +117,14 @@
}
// Create and connect the channel
- ASSERT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)) <<
- "Couldn't register Transport callback.\n";
+ ASSERT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_))
+ << "Couldn't register Transport callback.\n";
channel_a2b_->RegisterReceiverACM(acm_b_.get());
}
- void Perform(const TestSettings* config, size_t num_tests, int duration_sec,
+ void Perform(const TestSettings* config,
+ size_t num_tests,
+ int duration_sec,
const char* output_prefix) {
for (size_t n = 0; n < num_tests; ++n) {
ApplyConfig(config[n]);
@@ -134,14 +135,15 @@
private:
void ApplyConfig(const TestSettings& config) {
printf("====================================\n");
- printf("Test %d \n"
- "Codec: %s, %d kHz, %d channel(s)\n"
- "ACM: DTX %s, FEC %s\n"
- "Channel: %s\n",
- ++test_cntr_, config.codec.name, config.codec.sample_rate_hz,
- config.codec.num_channels, config.acm.dtx ? "on" : "off",
- config.acm.fec ? "on" : "off",
- config.packet_loss ? "with packet-loss" : "no packet-loss");
+ printf(
+ "Test %d \n"
+ "Codec: %s, %d kHz, %d channel(s)\n"
+ "ACM: DTX %s, FEC %s\n"
+ "Channel: %s\n",
+ ++test_cntr_, config.codec.name, config.codec.sample_rate_hz,
+ config.codec.num_channels, config.acm.dtx ? "on" : "off",
+ config.acm.fec ? "on" : "off",
+ config.packet_loss ? "with packet-loss" : "no packet-loss");
SendCodec(config.codec);
ConfigAcm(config.acm);
ConfigChannel(config.packet_loss);
@@ -149,20 +151,20 @@
void SendCodec(const CodecSettings& config) {
CodecInst my_codec_param;
- ASSERT_EQ(0, AudioCodingModule::Codec(
- config.name, &my_codec_param, config.sample_rate_hz,
- config.num_channels)) << "Specified codec is not supported.\n";
+ ASSERT_EQ(
+ 0, AudioCodingModule::Codec(config.name, &my_codec_param,
+ config.sample_rate_hz, config.num_channels))
+ << "Specified codec is not supported.\n";
encoding_sample_rate_hz_ = my_codec_param.plfreq;
- ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param)) <<
- "Failed to register send-codec.\n";
+ ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param))
+ << "Failed to register send-codec.\n";
}
void ConfigAcm(const AcmSettings& config) {
- ASSERT_EQ(0, acm_a_->SetVAD(config.dtx, config.dtx, VADAggr)) <<
- "Failed to set VAD.\n";
- ASSERT_EQ(0, acm_a_->SetREDStatus(config.fec)) <<
- "Failed to set RED.\n";
+ ASSERT_EQ(0, acm_a_->SetVAD(config.dtx, config.dtx, VADAggr))
+ << "Failed to set VAD.\n";
+ ASSERT_EQ(0, acm_a_->SetREDStatus(config.fec)) << "Failed to set RED.\n";
}
void ConfigChannel(bool packet_loss) {
@@ -172,7 +174,8 @@
void OpenOutFile(const char* output_id) {
std::stringstream file_stream;
file_stream << "delay_test_" << FLAG_codec << "_" << FLAG_sample_rate_hz
- << "Hz" << "_" << FLAG_delay << "ms.pcm";
+ << "Hz"
+ << "_" << FLAG_delay << "ms.pcm";
std::cout << "Output file: " << file_stream.str() << std::endl << std::endl;
std::string file_name = webrtc::test::OutputPath() + file_stream.str();
out_file_b_.Open(file_name.c_str(), 32000, "wb");
@@ -197,14 +200,15 @@
if ((num_frames & 0x3F) == 0x3F) {
NetworkStatistics statistics;
acm_b_->GetNetworkStatistics(&statistics);
- fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d"
+ fprintf(stdout,
+ "delay: min=%3d max=%3d mean=%3d median=%3d"
" ts-based average = %6.3f, "
"curr buff-lev = %4u opt buff-lev = %4u \n",
statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs,
statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs,
average_delay, statistics.currentBufferSize,
statistics.preferredBufferSize);
- fflush (stdout);
+ fflush(stdout);
}
in_file_a_.Read10MsData(audio_frame);
@@ -256,10 +260,8 @@
webrtc::TestSettings test_setting;
strcpy(test_setting.codec.name, FLAG_codec);
- if (FLAG_sample_rate_hz != 8000 &&
- FLAG_sample_rate_hz != 16000 &&
- FLAG_sample_rate_hz != 32000 &&
- FLAG_sample_rate_hz != 48000) {
+ if (FLAG_sample_rate_hz != 8000 && FLAG_sample_rate_hz != 16000 &&
+ FLAG_sample_rate_hz != 32000 && FLAG_sample_rate_hz != 48000) {
std::cout << "Invalid sampling rate.\n";
return 1;
}
diff --git a/modules/audio_coding/test/iSACTest.cc b/modules/audio_coding/test/iSACTest.cc
index a847132..e9fd867 100644
--- a/modules/audio_coding/test/iSACTest.cc
+++ b/modules/audio_coding/test/iSACTest.cc
@@ -41,11 +41,11 @@
return;
}
-int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
+int16_t SetISAConfig(ACMTestISACConfig& isacConfig,
+ AudioCodingModule* acm,
int testMode) {
-
- if ((isacConfig.currentRateBitPerSec != 0)
- || (isacConfig.currentFrameSizeMsec != 0)) {
+ if ((isacConfig.currentRateBitPerSec != 0) ||
+ (isacConfig.currentFrameSizeMsec != 0)) {
auto sendCodec = acm->SendCodec();
EXPECT_TRUE(sendCodec);
if (isacConfig.currentRateBitPerSec < 0) {
@@ -57,8 +57,8 @@
sendCodec->rate = isacConfig.currentRateBitPerSec;
}
if (isacConfig.currentFrameSizeMsec != 0) {
- sendCodec->pacsize = isacConfig.currentFrameSizeMsec
- * (sendCodec->plfreq / 1000);
+ sendCodec->pacsize =
+ isacConfig.currentFrameSizeMsec * (sendCodec->plfreq / 1000);
}
EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
}
@@ -81,15 +81,15 @@
CodecInst codecParam;
for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
- codecCntr++) {
+ codecCntr++) {
EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));
- if (!STR_CASE_CMP(codecParam.plname, "ISAC")
- && codecParam.plfreq == 16000) {
+ if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
+ codecParam.plfreq == 16000) {
memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
_idISAC16kHz = codecCntr;
}
- if (!STR_CASE_CMP(codecParam.plname, "ISAC")
- && codecParam.plfreq == 32000) {
+ if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
+ codecParam.plfreq == 32000) {
memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
_idISAC32kHz = codecCntr;
}
@@ -115,8 +115,8 @@
EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get()));
_channel_B2A->RegisterReceiverACM(_acmA.get());
- file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
- "pcm");
+ file_name_swb_ =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
@@ -213,7 +213,8 @@
_outFileB.Write10MsData(audioFrame);
}
-void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
+void ISACTest::EncodeDecode(int testNr,
+ ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig) {
// Files in Side A and B
_inFileA.Open(file_name_swb_, 32000, "rb", true);
@@ -241,8 +242,8 @@
SetISAConfig(wbISACConfig, _acmB.get(), _testMode);
bool adaptiveMode = false;
- if ((swbISACConfig.currentRateBitPerSec == -1)
- || (wbISACConfig.currentRateBitPerSec == -1)) {
+ if ((swbISACConfig.currentRateBitPerSec == -1) ||
+ (wbISACConfig.currentRateBitPerSec == -1)) {
adaptiveMode = true;
}
_myTimer.Reset();
diff --git a/modules/audio_coding/test/iSACTest.h b/modules/audio_coding/test/iSACTest.h
index d0e7d59..22c85b4 100644
--- a/modules/audio_coding/test/iSACTest.h
+++ b/modules/audio_coding/test/iSACTest.h
@@ -23,7 +23,7 @@
#include "modules/audio_coding/test/utility.h"
#define MAX_FILE_NAME_LENGTH_BYTE 500
-#define NO_OF_CLIENTS 15
+#define NO_OF_CLIENTS 15
namespace webrtc {
@@ -42,12 +42,14 @@
~ISACTest();
void Perform();
+
private:
void Setup();
void Run10ms();
- void EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
+ void EncodeDecode(int testNr,
+ ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig);
void SwitchingSamplingRate(int testNr, int maxSampRateChange);
diff --git a/modules/audio_coding/test/opus_test.cc b/modules/audio_coding/test/opus_test.cc
index d3afd6b..40b5147 100644
--- a/modules/audio_coding/test/opus_test.cc
+++ b/modules/audio_coding/test/opus_test.cc
@@ -211,8 +211,11 @@
#endif
}
-void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate,
- size_t frame_length, int percent_loss) {
+void OpusTest::Run(TestPackStereo* channel,
+ size_t channels,
+ int bitrate,
+ size_t frame_length,
+ int percent_loss) {
AudioFrame audio_frame;
int32_t out_freq_hz_b = out_file_.SamplingFrequency();
const size_t kBufferSizeSamples = 480 * 12 * 2; // 120 ms stereo audio.
@@ -237,8 +240,8 @@
// default.
const int kOpusComplexity5 = 5;
EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_mono_encoder_, kOpusComplexity5));
- EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_stereo_encoder_,
- kOpusComplexity5));
+ EXPECT_EQ(0,
+ WebRtcOpus_SetComplexity(opus_stereo_encoder_, kOpusComplexity5));
#endif
// Fast-forward 1 second (100 blocks) since the files start with silence.
@@ -263,19 +266,16 @@
}
// If input audio is sampled at 32 kHz, resampling to 48 kHz is required.
- EXPECT_EQ(480,
- resampler_.Resample10Msec(audio_frame.data(),
- audio_frame.sample_rate_hz_,
- 48000,
- channels,
- kBufferSizeSamples - written_samples,
- &audio[written_samples]));
+ EXPECT_EQ(480, resampler_.Resample10Msec(
+ audio_frame.data(), audio_frame.sample_rate_hz_, 48000,
+ channels, kBufferSizeSamples - written_samples,
+ &audio[written_samples]));
written_samples += 480 * channels;
// Sometimes we need to loop over the audio vector to produce the right
// number of packets.
- size_t loop_encode = (written_samples - read_samples) /
- (channels * frame_length);
+ size_t loop_encode =
+ (written_samples - read_samples) / (channels * frame_length);
if (loop_encode > 0) {
const size_t kMaxBytes = 1000; // Maximum number of bytes for one packet.
@@ -319,9 +319,9 @@
opus_stereo_decoder_, bitstream, bitstream_len_byte,
&out_audio[decoded_samples * channels], &audio_type);
} else {
- decoded_samples += WebRtcOpus_DecodePlc(
- opus_stereo_decoder_, &out_audio[decoded_samples * channels],
- 1);
+ decoded_samples +=
+ WebRtcOpus_DecodePlc(opus_stereo_decoder_,
+ &out_audio[decoded_samples * channels], 1);
}
}
@@ -377,14 +377,14 @@
void OpusTest::OpenOutFile(int test_number) {
std::string file_name;
std::stringstream file_stream;
- file_stream << webrtc::test::OutputPath() << "opustest_out_"
- << test_number << ".pcm";
+ file_stream << webrtc::test::OutputPath() << "opustest_out_" << test_number
+ << ".pcm";
file_name = file_stream.str();
out_file_.Open(file_name, 48000, "wb");
file_stream.str("");
file_name = file_stream.str();
file_stream << webrtc::test::OutputPath() << "opusstandalone_out_"
- << test_number << ".pcm";
+ << test_number << ".pcm";
file_name = file_stream.str();
out_file_standalone_.Open(file_name, 48000, "wb");
}
diff --git a/modules/audio_coding/test/opus_test.h b/modules/audio_coding/test/opus_test.h
index 3e9d9a7..1356f27 100644
--- a/modules/audio_coding/test/opus_test.h
+++ b/modules/audio_coding/test/opus_test.h
@@ -15,8 +15,8 @@
#include <memory>
-#include "modules/audio_coding/codecs/opus/opus_interface.h"
#include "modules/audio_coding/acm2/acm_resampler.h"
+#include "modules/audio_coding/codecs/opus/opus_interface.h"
#include "modules/audio_coding/test/ACMTest.h"
#include "modules/audio_coding/test/Channel.h"
#include "modules/audio_coding/test/PCMFile.h"
diff --git a/modules/audio_coding/test/target_delay_unittest.cc b/modules/audio_coding/test/target_delay_unittest.cc
index 89bf34f..7579d62 100644
--- a/modules/audio_coding/test/target_delay_unittest.cc
+++ b/modules/audio_coding/test/target_delay_unittest.cc
@@ -73,8 +73,8 @@
void WithTargetDelayBufferNotChanging() {
// A target delay that is one packet larger than jitter.
- const int kTargetDelayMs = (kInterarrivalJitterPacket + 1) *
- kNum10msPerFrame * 10;
+ const int kTargetDelayMs =
+ (kInterarrivalJitterPacket + 1) * kNum10msPerFrame * 10;
ASSERT_EQ(0, SetMinimumDelay(kTargetDelayMs));
for (int n = 0; n < 30; ++n) // Run enough iterations to fill the buffer.
Run(true);
@@ -91,8 +91,8 @@
int clean_optimal_delay = GetCurrentOptimalDelayMs();
// A relatively large delay.
- const int kTargetDelayMs = (kInterarrivalJitterPacket + 10) *
- kNum10msPerFrame * 10;
+ const int kTargetDelayMs =
+ (kInterarrivalJitterPacket + 10) * kNum10msPerFrame * 10;
ASSERT_EQ(0, SetMinimumDelay(kTargetDelayMs));
for (int n = 0; n < 300; ++n) // Run enough iterations to fill the buffer.
Run(true);
@@ -146,8 +146,8 @@
void Push() {
rtp_info_.header.timestamp += kFrameSizeSamples;
rtp_info_.header.sequenceNumber++;
- ASSERT_EQ(0, acm_->IncomingPacket(payload_, kFrameSizeSamples * 2,
- rtp_info_));
+ ASSERT_EQ(0,
+ acm_->IncomingPacket(payload_, kFrameSizeSamples * 2, rtp_info_));
}
// Pull audio equivalent to the amount of audio in one RTP packet.
@@ -195,9 +195,7 @@
return stats.preferredBufferSize;
}
- int RequiredDelay() {
- return acm_->LeastRequiredDelayMs();
- }
+ int RequiredDelay() { return acm_->LeastRequiredDelayMs(); }
std::unique_ptr<AudioCodingModule> acm_;
WebRtcRTPHeader rtp_info_;
diff --git a/modules/audio_coding/test/utility.cc b/modules/audio_coding/test/utility.cc
index 3c64620..83c25b5 100644
--- a/modules/audio_coding/test/utility.cc
+++ b/modules/audio_coding/test/utility.cc
@@ -23,11 +23,7 @@
namespace webrtc {
-ACMTestTimer::ACMTestTimer()
- : _msec(0),
- _sec(0),
- _min(0),
- _hour(0) {
+ACMTestTimer::ACMTestTimer() : _msec(0), _sec(0), _min(0), _hour(0) {
return;
}
@@ -68,12 +64,14 @@
void ACMTestTimer::CurrentTimeHMS(char* currTime) {
sprintf(currTime, "%4lu:%02u:%06.3f", _hour, _min,
- (double) _sec + (double) _msec / 1000.);
+ (double)_sec + (double)_msec / 1000.);
return;
}
-void ACMTestTimer::CurrentTime(unsigned long& h, unsigned char& m,
- unsigned char& s, unsigned short& ms) {
+void ACMTestTimer::CurrentTime(unsigned long& h,
+ unsigned char& m,
+ unsigned char& s,
+ unsigned short& ms) {
h = _hour;
m = _min;
s = _sec;
@@ -101,9 +99,8 @@
}
int16_t ChooseCodec(CodecInst& codecInst) {
-
PrintCodecs();
- //AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
+ // AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
uint8_t noCodec = AudioCodingModule::NumberOfCodecs();
int8_t codecID;
bool outOfRange = false;
@@ -118,7 +115,7 @@
}
} while (outOfRange);
- CHECK_ERROR(AudioCodingModule::Codec((uint8_t )codecID, &codecInst));
+ CHECK_ERROR(AudioCodingModule::Codec((uint8_t)codecID, &codecInst));
return 0;
}
@@ -132,7 +129,6 @@
printf("%2d- %-18s %5d %6d\n", codecCntr, codecInst.plname,
codecInst.plfreq, codecInst.rate);
}
-
}
namespace test {
@@ -192,7 +188,7 @@
if (_calcVar) {
// to calculate variance we have to update
// the sum of squares
- _sumSqr += (double) (newVal - oldVal) * (double) (newVal + oldVal);
+ _sumSqr += (double)(newVal - oldVal) * (double)(newVal + oldVal);
}
}
@@ -236,17 +232,15 @@
assert(_buffLen > 0);
if (_buffIsFull) {
-
- mean = _sum / (double) _buffLen;
+ mean = _sum / (double)_buffLen;
return 0;
} else {
if (_idx > 0) {
- mean = _sum / (double) _idx;
+ mean = _sum / (double)_idx;
return 0;
} else {
return -1;
}
-
}
}
@@ -254,11 +248,11 @@
assert(_buffLen > 0);
if (_buffIsFull) {
- var = _sumSqr / (double) _buffLen;
+ var = _sumSqr / (double)_buffLen;
return 0;
} else {
if (_idx > 0) {
- var = _sumSqr / (double) _idx;
+ var = _sumSqr / (double)_idx;
return 0;
} else {
return -1;
@@ -269,9 +263,9 @@
} // namespace test
bool FixedPayloadTypeCodec(const char* payloadName) {
- char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = { "PCMU",
- "PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA", "G722", "QCELP", "CN",
- "MPA", "G728", "G729" };
+ char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = {
+ "PCMU", "PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA",
+ "G722", "QCELP", "CN", "MPA", "G728", "G729"};
for (int n = 0; n < NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE; n++) {
if (!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n])) {
diff --git a/modules/audio_coding/test/utility.h b/modules/audio_coding/test/utility.h
index 07cbe71..6f17df5 100644
--- a/modules/audio_coding/test/utility.h
+++ b/modules/audio_coding/test/utility.h
@@ -17,48 +17,48 @@
namespace webrtc {
//-----------------------------
-#define CHECK_ERROR(f) \
- do { \
- EXPECT_GE(f, 0) << "Error Calling API"; \
- } while(0)
+#define CHECK_ERROR(f) \
+ do { \
+ EXPECT_GE(f, 0) << "Error Calling API"; \
+ } while (0)
//-----------------------------
-#define CHECK_PROTECTED(f) \
- do { \
- if (f >= 0) { \
- ADD_FAILURE() << "Error Calling API"; \
- } else { \
- printf("An expected error is caught.\n"); \
- } \
- } while(0)
+#define CHECK_PROTECTED(f) \
+ do { \
+ if (f >= 0) { \
+ ADD_FAILURE() << "Error Calling API"; \
+ } else { \
+ printf("An expected error is caught.\n"); \
+ } \
+ } while (0)
//----------------------------
-#define CHECK_ERROR_MT(f) \
- do { \
- if (f < 0) { \
- fprintf(stderr, "Error Calling API in file %s at line %d \n", \
- __FILE__, __LINE__); \
- } \
- } while(0)
+#define CHECK_ERROR_MT(f) \
+ do { \
+ if (f < 0) { \
+ fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \
+ __LINE__); \
+ } \
+ } while (0)
//----------------------------
-#define CHECK_PROTECTED_MT(f) \
- do { \
- if (f >= 0) { \
- fprintf(stderr, "Error Calling API in file %s at line %d \n", \
- __FILE__, __LINE__); \
- } else { \
- printf("An expected error is caught.\n"); \
- } \
- } while(0)
+#define CHECK_PROTECTED_MT(f) \
+ do { \
+ if (f >= 0) { \
+ fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \
+ __LINE__); \
+ } else { \
+ printf("An expected error is caught.\n"); \
+ } \
+ } while (0)
-#define DELETE_POINTER(p) \
- do { \
- if (p != NULL) { \
- delete p; \
- p = NULL; \
- } \
- } while(0)
+#define DELETE_POINTER(p) \
+ do { \
+ if (p != NULL) { \
+ delete p; \
+ p = NULL; \
+ } \
+ } while (0)
class ACMTestTimer {
public:
@@ -71,7 +71,9 @@
void Tick100ms();
void Tick1sec();
void CurrentTimeHMS(char* currTime);
- void CurrentTime(unsigned long& h, unsigned char& m, unsigned char& s,
+ void CurrentTime(unsigned long& h,
+ unsigned char& m,
+ unsigned char& s,
unsigned short& ms);
private: