Misc. cleanup split out of https://webrtc-codereview.appspot.com/37699004/ :
* Move constants into the files/functions that use them
* Declare variables in the narrowest scope possible
* Use correct (expected, actual) order for gtest macros
* Remove unused functions
* Untabify
* 80-column limit
* Avoid C-style casts
* Prefer true typed constants to "enum hack" constants
* Print size_t using the right format macro
* Shorten and simplify code
* Other random cleanup bits and style fixes
BUG=none
TEST=none
R=henrik.lundin@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/36179004
Cr-Commit-Position: refs/heads/master@{#8467}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8467 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
index 6e00361..7710046 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
@@ -448,20 +448,12 @@
// Checks if the bitrate is valid for the codec.
bool ACMCodecDB::IsRateValid(int codec_id, int rate) {
- if (database_[codec_id].rate == rate) {
- return true;
- } else {
- return false;
- }
+ return database_[codec_id].rate == rate;
}
// Checks if the bitrate is valid for iSAC.
bool ACMCodecDB::IsISACRateValid(int rate) {
- if ((rate == -1) || ((rate <= 56000) && (rate >= 10000))) {
- return true;
- } else {
- return false;
- }
+ return (rate == -1) || ((rate <= 56000) && (rate >= 10000));
}
// Checks if the bitrate is valid for iLBC.
@@ -541,27 +533,17 @@
// Checks if the bitrate is valid for Speex.
bool ACMCodecDB::IsSpeexRateValid(int rate) {
- if (rate > 2000) {
- return true;
- } else {
- return false;
- }
+ return rate > 2000;
}
// Checks if the bitrate is valid for Opus.
bool ACMCodecDB::IsOpusRateValid(int rate) {
- if ((rate < 6000) || (rate > 510000)) {
- return false;
- }
- return true;
+ return (rate >= 6000) && (rate <= 510000);
}
// Checks if the payload type is in the valid range.
bool ACMCodecDB::ValidPayloadType(int payload_type) {
- if ((payload_type < 0) || (payload_type > 127)) {
- return false;
- }
- return true;
+ return (payload_type >= 0) && (payload_type <= 127);
}
bool ACMCodecDB::OwnsDecoder(int codec_id) {
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index 5d78625..7acb45a 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -507,8 +507,8 @@
// First unregister. Then register with new payload-type/channels.
if (neteq_->RemovePayloadType(decoders_[acm_codec_id].payload_type) !=
NetEq::kOK) {
- LOG_F(LS_ERROR) << "Cannot remover payload "
- << static_cast<int>(decoders_[acm_codec_id].payload_type);
+ LOG_F(LS_ERROR) << "Cannot remove payload "
+ << static_cast<int>(decoders_[acm_codec_id].payload_type);
return -1;
}
}
@@ -562,7 +562,7 @@
decoders_[n].registered = false;
} else {
LOG_F(LS_ERROR) << "Cannot remove payload "
- << static_cast<int>(decoders_[n].payload_type);
+ << static_cast<int>(decoders_[n].payload_type);
ret_val = -1;
}
}
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
index 72e1e75..07daf58 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
@@ -240,8 +240,6 @@
AudioDecodingCallStats* stats) const OVERRIDE;
private:
- int UnregisterReceiveCodecSafe(int payload_type);
-
ACMGenericCodec* CreateCodec(const CodecInst& codec);
int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
diff --git a/webrtc/modules/audio_coding/main/acm2/initial_delay_manager_unittest.cc b/webrtc/modules/audio_coding/main/acm2/initial_delay_manager_unittest.cc
index 4bf9437..6585946 100644
--- a/webrtc/modules/audio_coding/main/acm2/initial_delay_manager_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/initial_delay_manager_unittest.cc
@@ -332,7 +332,6 @@
// Second packet as CNG.
NextRtpHeader(&rtp_info_, &rtp_receive_timestamp_);
- const uint8_t kCngPayloadType = 1; // Arbitrary.
rtp_info_.header.payloadType = kCngPayloadType;
manager_->UpdateLastReceivedPacket(rtp_info_, rtp_receive_timestamp_,
InitialDelayManager::kCngPacket, false,
diff --git a/webrtc/modules/audio_coding/main/test/Channel.h b/webrtc/modules/audio_coding/main/test/Channel.h
index 4ab32b9..5ec78b2 100644
--- a/webrtc/modules/audio_coding/main/test/Channel.h
+++ b/webrtc/modules/audio_coding/main/test/Channel.h
@@ -66,7 +66,7 @@
void Stats(uint32_t* numPackets);
- void Stats(uint8_t* payloadLenByte, uint32_t* payloadType);
+ void Stats(uint8_t* payloadType, uint32_t* payloadLenByte);
void PrintStats(CodecInst& codecInst);
diff --git a/webrtc/modules/audio_coding/main/test/RTPFile.cc b/webrtc/modules/audio_coding/main/test/RTPFile.cc
index e403020..4e81943 100644
--- a/webrtc/modules/audio_coding/main/test/RTPFile.cc
+++ b/webrtc/modules/audio_coding/main/test/RTPFile.cc
@@ -43,21 +43,18 @@
void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType,
int16_t seqNo, uint32_t timeStamp,
uint32_t ssrc) {
- rtpHeader[0] = (unsigned char) 0x80;
- rtpHeader[1] = (unsigned char) (payloadType & 0xFF);
- rtpHeader[2] = (unsigned char) ((seqNo >> 8) & 0xFF);
- rtpHeader[3] = (unsigned char) ((seqNo) & 0xFF);
- rtpHeader[4] = (unsigned char) ((timeStamp >> 24) & 0xFF);
- rtpHeader[5] = (unsigned char) ((timeStamp >> 16) & 0xFF);
-
- rtpHeader[6] = (unsigned char) ((timeStamp >> 8) & 0xFF);
- rtpHeader[7] = (unsigned char) (timeStamp & 0xFF);
-
- rtpHeader[8] = (unsigned char) ((ssrc >> 24) & 0xFF);
- rtpHeader[9] = (unsigned char) ((ssrc >> 16) & 0xFF);
-
- rtpHeader[10] = (unsigned char) ((ssrc >> 8) & 0xFF);
- rtpHeader[11] = (unsigned char) (ssrc & 0xFF);
+ rtpHeader[0] = 0x80;
+ rtpHeader[1] = payloadType;
+ rtpHeader[2] = (seqNo >> 8) & 0xFF;
+ rtpHeader[3] = seqNo & 0xFF;
+ rtpHeader[4] = timeStamp >> 24;
+ rtpHeader[5] = (timeStamp >> 16) & 0xFF;
+ rtpHeader[6] = (timeStamp >> 8) & 0xFF;
+ rtpHeader[7] = timeStamp & 0xFF;
+ rtpHeader[8] = ssrc >> 24;
+ rtpHeader[9] = (ssrc >> 16) & 0xFF;
+ rtpHeader[10] = (ssrc >> 8) & 0xFF;
+ rtpHeader[11] = ssrc & 0xFF;
}
RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.cc b/webrtc/modules/audio_coding/neteq/decoder_database.cc
index 69c7b7b..b9097b0 100644
--- a/webrtc/modules/audio_coding/neteq/decoder_database.cc
+++ b/webrtc/modules/audio_coding/neteq/decoder_database.cc
@@ -38,7 +38,7 @@
int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type,
NetEqDecoder codec_type) {
- if (rtp_payload_type > kMaxRtpPayloadType) {
+ if (rtp_payload_type > 0x7F) {
return kInvalidRtpPayloadType;
}
if (!CodecSupported(codec_type)) {
@@ -74,8 +74,7 @@
decoder->Init();
std::pair<DecoderMap::iterator, bool> ret;
DecoderInfo info(codec_type, fs_hz, decoder, true);
- ret = decoders_.insert(
- std::pair<uint8_t, DecoderInfo>(rtp_payload_type, info));
+ ret = decoders_.insert(std::make_pair(rtp_payload_type, info));
if (ret.second == false) {
// Database already contains a decoder with type |rtp_payload_type|.
return kDecoderExists;
diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.h b/webrtc/modules/audio_coding/neteq/decoder_database.h
index cae1021..1dbc685 100644
--- a/webrtc/modules/audio_coding/neteq/decoder_database.h
+++ b/webrtc/modules/audio_coding/neteq/decoder_database.h
@@ -57,7 +57,6 @@
bool external;
};
- static const uint8_t kMaxRtpPayloadType = 0x7F; // Max for a 7-bit number.
// Maximum value for 8 bits, and an invalid RTP payload type (since it is
// only 7 bits).
static const uint8_t kRtpPayloadTypeError = 0xFF;
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index bfbf4b3..f1a3a90 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -414,7 +414,7 @@
decoder_database_->IsRed(rtp_header.header.payloadType) ||
decoder_database_->IsComfortNoise(rtp_header.header.payloadType)) {
LOG_F(LS_ERROR) << "Sync-packet with an unacceptable payload type "
- << static_cast<int>(rtp_header.header.payloadType);
+ << static_cast<int>(rtp_header.header.payloadType);
return kSyncPacketNotAccepted;
}
if (first_packet_ ||
@@ -422,8 +422,8 @@
rtp_header.header.ssrc != ssrc_) {
// Even if |current_rtp_payload_type_| is 0xFF, sync-packet isn't
// accepted.
- LOG_F(LS_ERROR) << "Changing codec, SSRC or first packet "
- "with sync-packet.";
+ LOG_F(LS_ERROR)
+ << "Changing codec, SSRC or first packet with sync-packet.";
return kSyncPacketNotAccepted;
}
}
diff --git a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc
index d4c2191..3d44fbc 100644
--- a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc
+++ b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc
@@ -352,82 +352,72 @@
uint8_t NETEQTEST_RTPpacket::payloadType() const
{
- webrtc::WebRtcRTPHeader tempRTPinfo;
-
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
+ webrtc::WebRtcRTPHeader tempRTPinfo;
parseRTPheader(&tempRTPinfo);
+ return tempRTPinfo.header.payloadType;
}
else
{
return 0;
}
-
- return tempRTPinfo.header.payloadType;
}
uint16_t NETEQTEST_RTPpacket::sequenceNumber() const
{
- webrtc::WebRtcRTPHeader tempRTPinfo;
-
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
+ webrtc::WebRtcRTPHeader tempRTPinfo;
parseRTPheader(&tempRTPinfo);
+ return tempRTPinfo.header.sequenceNumber;
}
else
{
return 0;
}
-
- return tempRTPinfo.header.sequenceNumber;
}
uint32_t NETEQTEST_RTPpacket::timeStamp() const
{
- webrtc::WebRtcRTPHeader tempRTPinfo;
-
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
+ webrtc::WebRtcRTPHeader tempRTPinfo;
parseRTPheader(&tempRTPinfo);
+ return tempRTPinfo.header.timestamp;
}
else
{
return 0;
}
-
- return tempRTPinfo.header.timestamp;
}
uint32_t NETEQTEST_RTPpacket::SSRC() const
{
- webrtc::WebRtcRTPHeader tempRTPinfo;
-
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
+ webrtc::WebRtcRTPHeader tempRTPinfo;
parseRTPheader(&tempRTPinfo);
+ return tempRTPinfo.header.ssrc;
}
else
{
return 0;
}
-
- return tempRTPinfo.header.ssrc;
}
uint8_t NETEQTEST_RTPpacket::markerBit() const
{
- webrtc::WebRtcRTPHeader tempRTPinfo;
-
if(_datagram && _datagramLen >= _kBasicHeaderLen)
{
+ webrtc::WebRtcRTPHeader tempRTPinfo;
parseRTPheader(&tempRTPinfo);
+ return tempRTPinfo.header.markerBit;
}
else
{
return 0;
}
-
- return tempRTPinfo.header.markerBit;
}
@@ -445,7 +435,7 @@
_rtpInfo.header.payloadType = pt;
}
- _datagram[1]=(unsigned char)(pt & 0xFF);
+ _datagram[1] = pt;
return 0;
@@ -624,38 +614,31 @@
}
-void NETEQTEST_RTPpacket::makeRTPheader(unsigned char* rtp_data, uint8_t payloadType, uint16_t seqNo, uint32_t timestamp, uint32_t ssrc, uint8_t markerBit) const
+void NETEQTEST_RTPpacket::makeRTPheader(unsigned char* rtp_data,
+ uint8_t payloadType,
+ uint16_t seqNo,
+ uint32_t timestamp,
+ uint32_t ssrc,
+ uint8_t markerBit) const
{
- rtp_data[0]=(unsigned char)0x80;
- if (markerBit)
- {
- rtp_data[0] |= 0x01;
- }
- else
- {
- rtp_data[0] &= 0xFE;
- }
- rtp_data[1]=(unsigned char)(payloadType & 0xFF);
- rtp_data[2]=(unsigned char)((seqNo>>8)&0xFF);
- rtp_data[3]=(unsigned char)((seqNo)&0xFF);
- rtp_data[4]=(unsigned char)((timestamp>>24)&0xFF);
- rtp_data[5]=(unsigned char)((timestamp>>16)&0xFF);
-
- rtp_data[6]=(unsigned char)((timestamp>>8)&0xFF);
- rtp_data[7]=(unsigned char)(timestamp & 0xFF);
-
- rtp_data[8]=(unsigned char)((ssrc>>24)&0xFF);
- rtp_data[9]=(unsigned char)((ssrc>>16)&0xFF);
-
- rtp_data[10]=(unsigned char)((ssrc>>8)&0xFF);
- rtp_data[11]=(unsigned char)(ssrc & 0xFF);
+ rtp_data[0] = markerBit ? 0x81 : 0x80;
+ rtp_data[1] = payloadType;
+ rtp_data[2] = seqNo >> 8;
+ rtp_data[3] = seqNo & 0xFF;
+ rtp_data[4] = timestamp >> 24;
+ rtp_data[5] = (timestamp >> 16) & 0xFF;
+ rtp_data[6] = (timestamp >> 8) & 0xFF;
+ rtp_data[7] = timestamp & 0xFF;
+ rtp_data[8] = ssrc >> 24;
+ rtp_data[9] = (ssrc >> 16) & 0xFF;
+ rtp_data[10] = (ssrc >> 8) & 0xFF;
+ rtp_data[11] = ssrc & 0xFF;
}
-uint16_t
- NETEQTEST_RTPpacket::parseRTPheader(webrtc::WebRtcRTPHeader* RTPinfo,
- uint8_t **payloadPtr) const
+uint16_t NETEQTEST_RTPpacket::parseRTPheader(webrtc::WebRtcRTPHeader* RTPinfo,
+ uint8_t **payloadPtr) const
{
- int16_t *rtp_data = (int16_t *) _datagram;
+ uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
int i_P, i_X, i_CC;
assert(_datagramLen >= 12);
@@ -667,61 +650,54 @@
if (payloadPtr)
{
- *payloadPtr = (uint8_t*) &rtp_data[i_startPosition >> 1];
+ *payloadPtr =
+ reinterpret_cast<uint8_t*>(&rtp_data[i_startPosition >> 1]);
}
- return (uint16_t) (_datagramLen - i_startPosition - i_padlength);
+ return static_cast<uint16_t>(_datagramLen - i_startPosition - i_padlength);
}
void NETEQTEST_RTPpacket::parseBasicHeader(webrtc::WebRtcRTPHeader* RTPinfo,
int *i_P, int *i_X, int *i_CC) const
{
- int16_t *rtp_data = (int16_t *) _datagram;
+ uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
if (_datagramLen < 12)
{
assert(false);
return;
}
- *i_P=(((uint16_t)(rtp_data[0] & 0x20))>>5); /* Extract the P bit */
- *i_X=(((uint16_t)(rtp_data[0] & 0x10))>>4); /* Extract the X bit */
- *i_CC=(uint16_t)(rtp_data[0] & 0xF); /* Get the CC number */
- /* Get the marker bit */
- RTPinfo->header.markerBit = (uint8_t) ((rtp_data[0] >> 15) & 0x01);
- /* Get the coder type */
- RTPinfo->header.payloadType = (uint8_t) ((rtp_data[0] >> 8) & 0x7F);
- /* Get the packet number */
+ *i_P = (rtp_data[0] >> 5) & 0x01;
+ *i_X = (rtp_data[0] >> 4) & 0x01;
+ *i_CC = rtp_data[0] & 0xF;
+ RTPinfo->header.markerBit = (rtp_data[0] >> 15) & 0x01;
+ RTPinfo->header.payloadType = (rtp_data[0] >> 8) & 0x7F;
RTPinfo->header.sequenceNumber =
- ((( ((uint16_t)rtp_data[1]) >> 8) & 0xFF) |
- ( ((uint16_t)(rtp_data[1] & 0xFF)) << 8));
- /* Get timestamp */
- RTPinfo->header.timestamp = ((((uint16_t)rtp_data[2]) & 0xFF) << 24) |
- ((((uint16_t)rtp_data[2]) & 0xFF00) << 8) |
- ((((uint16_t)rtp_data[3]) >> 8) & 0xFF) |
- ((((uint16_t)rtp_data[3]) & 0xFF) << 8);
- /* Get the SSRC */
- RTPinfo->header.ssrc = ((((uint16_t)rtp_data[4]) & 0xFF) << 24) |
- ((((uint16_t)rtp_data[4]) & 0xFF00) << 8) |
- ((((uint16_t)rtp_data[5]) >> 8) & 0xFF) |
- ((((uint16_t)rtp_data[5]) & 0xFF) << 8);
+ (rtp_data[1] >> 8) | ((rtp_data[1] & 0xFF) << 8);
+ RTPinfo->header.timestamp =
+ ((rtp_data[2] & 0xFF) << 24) | ((rtp_data[2] & 0xFF00) << 8) |
+ (rtp_data[3] >> 8) | ((rtp_data[3] & 0xFF) << 8);
+ RTPinfo->header.ssrc =
+ ((rtp_data[4] & 0xFF) << 24) | ((rtp_data[4] & 0xFF00) << 8) |
+ (rtp_data[5] >> 8) | ((rtp_data[5] & 0xFF) << 8);
}
int NETEQTEST_RTPpacket::calcHeaderLength(int i_X, int i_CC) const
{
int i_extlength = 0;
- int16_t *rtp_data = (int16_t *) _datagram;
+ uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
if (i_X == 1)
{
// Extension header exists.
// Find out how many int32_t it consists of.
- assert(_datagramLen > 2 * (7 + 2 * i_CC));
- if (_datagramLen > 2 * (7 + 2 * i_CC))
+ int offset = 7 + 2 * i_CC;
+ assert(_datagramLen > 2 * offset);
+ if (_datagramLen > 2 * offset)
{
- i_extlength = (((((uint16_t) rtp_data[7 + 2 * i_CC]) >> 8)
- & 0xFF) | (((uint16_t) (rtp_data[7 + 2 * i_CC] & 0xFF))
- << 8)) + 1;
+ i_extlength = 1 +
+ (((rtp_data[offset]) >> 8) | ((rtp_data[offset] & 0xFF) << 8));
}
}
@@ -730,7 +706,7 @@
int NETEQTEST_RTPpacket::calcPadLength(int i_P) const
{
- int16_t *rtp_data = (int16_t *) _datagram;
+ uint16_t* rtp_data = reinterpret_cast<uint16_t*>(_datagram);
if (i_P == 1)
{
/* Padding exists. Find out how many bytes the padding consists of. */
@@ -742,7 +718,7 @@
else
{
/* even number of bytes => last byte in lower byte */
- return ((uint16_t) rtp_data[(_datagramLen >> 1) - 1]) >> 8;
+ return rtp_data[(_datagramLen >> 1) - 1] >> 8;
}
}
return 0;
@@ -838,7 +814,7 @@
{
// Header found.
red.header.payloadType = ptr[0] & 0x7F;
- uint32_t offset = (ptr[1] << 6) + ((ptr[2] & 0xFC) >> 2);
+ uint32_t offset = (ptr[1] << 6) + (ptr[2] >> 2);
red.header.sequenceNumber = sequenceNumber();
red.header.timestamp = timeStamp() - offset;
red.header.markerBit = markerBit();
diff --git a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h
index 86bf3b0..3fbce8b 100644
--- a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h
+++ b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h
@@ -36,7 +36,6 @@
int readFixedFromFile(FILE *fp, size_t len);
virtual int writeToFile(FILE *fp);
void blockPT(uint8_t pt);
- //int16_t payloadType();
virtual void parseHeader();
void parseHeader(webrtc::WebRtcRTPHeader* rtp_header);
const webrtc::WebRtcRTPHeader* RTPinfo() const;
diff --git a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc
index e6d8f2e..4e779b4 100644
--- a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc
+++ b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc
@@ -71,15 +71,47 @@
/* Function declarations */
/*************************/
-void NetEQTest_GetCodec_and_PT(char * name, webrtc::NetEqDecoder *codec, int *PT, int frameLen, int *fs, int *bitrate, int *useRed);
-int NetEQTest_init_coders(webrtc::NetEqDecoder coder, int enc_frameSize, int bitrate, int sampfreq , int vad, int numChannels);
-void defineCodecs(webrtc::NetEqDecoder *usedCodec, int *noOfCodecs );
+void NetEQTest_GetCodec_and_PT(char* name,
+ webrtc::NetEqDecoder* codec,
+ int* PT,
+ int frameLen,
+ int* fs,
+ int* bitrate,
+ int* useRed);
+int NetEQTest_init_coders(webrtc::NetEqDecoder coder,
+ int enc_frameSize,
+ int bitrate,
+ int sampfreq,
+ int vad,
+ int numChannels);
+void defineCodecs(webrtc::NetEqDecoder* usedCodec, int* noOfCodecs);
int NetEQTest_free_coders(webrtc::NetEqDecoder coder, int numChannels);
-int NetEQTest_encode(int coder, int16_t *indata, int frameLen, unsigned char * encoded,int sampleRate , int * vad, int useVAD, int bitrate, int numChannels);
-void makeRTPheader(unsigned char* rtp_data, int payloadType, int seqNo, uint32_t timestamp, uint32_t ssrc);
-int makeRedundantHeader(unsigned char* rtp_data, int *payloadType, int numPayloads, uint32_t *timestamp, uint16_t *blockLen,
- int seqNo, uint32_t ssrc);
-int makeDTMFpayload(unsigned char* payload_data, int Event, int End, int Volume, int Duration);
+int NetEQTest_encode(int coder,
+ int16_t* indata,
+ int frameLen,
+ unsigned char* encoded,
+ int sampleRate,
+ int* vad,
+ int useVAD,
+ int bitrate,
+ int numChannels);
+void makeRTPheader(unsigned char* rtp_data,
+ int payloadType,
+ int seqNo,
+ uint32_t timestamp,
+ uint32_t ssrc);
+int makeRedundantHeader(unsigned char* rtp_data,
+ int* payloadType,
+ int numPayloads,
+ uint32_t* timestamp,
+ uint16_t* blockLen,
+ int seqNo,
+ uint32_t ssrc);
+int makeDTMFpayload(unsigned char* payload_data,
+ int Event,
+ int End,
+ int Volume,
+ int Duration);
void stereoDeInterleave(int16_t* audioSamples, int numSamples);
void stereoInterleave(unsigned char* data, int dataLen, int stride);
@@ -231,37 +263,37 @@
int main(int argc, char* argv[])
{
- int packet_size, fs;
- webrtc::NetEqDecoder usedCodec;
- int payloadType;
- int bitrate = 0;
- int useVAD, vad;
+ int packet_size, fs;
+ webrtc::NetEqDecoder usedCodec;
+ int payloadType;
+ int bitrate = 0;
+ int useVAD, vad;
int useRed=0;
- int len, enc_len;
- int16_t org_data[4000];
- unsigned char rtp_data[8000];
- int16_t seqNo=0xFFF;
- uint32_t ssrc=1235412312;
- uint32_t timestamp=0xAC1245;
- uint16_t length, plen;
- uint32_t offset;
- double sendtime = 0;
+ int len, enc_len;
+ int16_t org_data[4000];
+ unsigned char rtp_data[8000];
+ int16_t seqNo=0xFFF;
+ uint32_t ssrc=1235412312;
+ uint32_t timestamp=0xAC1245;
+ uint16_t length, plen;
+ uint32_t offset;
+ double sendtime = 0;
int red_PT[2] = {0};
uint32_t red_TS[2] = {0};
uint16_t red_len[2] = {0};
int RTPheaderLen=12;
uint8_t red_data[8000];
#ifdef INSERT_OLD_PACKETS
- uint16_t old_length, old_plen;
- int old_enc_len;
- int first_old_packet=1;
- unsigned char old_rtp_data[8000];
- int packet_age=0;
+ uint16_t old_length, old_plen;
+ int old_enc_len;
+ int first_old_packet=1;
+ unsigned char old_rtp_data[8000];
+ int packet_age=0;
#endif
#ifdef INSERT_DTMF_PACKETS
- int NTone = 1;
- int DTMFfirst = 1;
- uint32_t DTMFtimestamp;
+ int NTone = 1;
+ int DTMFfirst = 1;
+ uint32_t DTMFtimestamp;
bool dtmfSent = false;
#endif
bool usingStereo = false;
@@ -789,7 +821,13 @@
/* Subfunctions */
/****************/
-void NetEQTest_GetCodec_and_PT(char * name, webrtc::NetEqDecoder *codec, int *PT, int frameLen, int *fs, int *bitrate, int *useRed) {
+void NetEQTest_GetCodec_and_PT(char* name,
+ webrtc::NetEqDecoder* codec,
+ int* PT,
+ int frameLen,
+ int* fs,
+ int* bitrate,
+ int* useRed) {
*bitrate = 0; /* Default bitrate setting */
*useRed = 0; /* Default no redundancy */
@@ -1626,59 +1664,71 @@
-void makeRTPheader(unsigned char* rtp_data, int payloadType, int seqNo, uint32_t timestamp, uint32_t ssrc){
-
- rtp_data[0]=(unsigned char)0x80;
- rtp_data[1]=(unsigned char)(payloadType & 0xFF);
- rtp_data[2]=(unsigned char)((seqNo>>8)&0xFF);
- rtp_data[3]=(unsigned char)((seqNo)&0xFF);
- rtp_data[4]=(unsigned char)((timestamp>>24)&0xFF);
- rtp_data[5]=(unsigned char)((timestamp>>16)&0xFF);
-
- rtp_data[6]=(unsigned char)((timestamp>>8)&0xFF);
- rtp_data[7]=(unsigned char)(timestamp & 0xFF);
-
- rtp_data[8]=(unsigned char)((ssrc>>24)&0xFF);
- rtp_data[9]=(unsigned char)((ssrc>>16)&0xFF);
-
- rtp_data[10]=(unsigned char)((ssrc>>8)&0xFF);
- rtp_data[11]=(unsigned char)(ssrc & 0xFF);
+void makeRTPheader(unsigned char* rtp_data,
+ int payloadType,
+ int seqNo,
+ uint32_t timestamp,
+ uint32_t ssrc) {
+ rtp_data[0] = 0x80;
+ rtp_data[1] = payloadType & 0xFF;
+ rtp_data[2] = (seqNo >> 8) & 0xFF;
+ rtp_data[3] = seqNo & 0xFF;
+ rtp_data[4] = timestamp >> 24;
+ rtp_data[5] = (timestamp >> 16) & 0xFF;
+ rtp_data[6] = (timestamp >> 8) & 0xFF;
+ rtp_data[7] = timestamp & 0xFF;
+ rtp_data[8] = ssrc >> 24;
+ rtp_data[9] = (ssrc >> 16) & 0xFF;
+ rtp_data[10] = (ssrc >> 8) & 0xFF;
+ rtp_data[11] = ssrc & 0xFF;
}
-int makeRedundantHeader(unsigned char* rtp_data, int *payloadType, int numPayloads, uint32_t *timestamp, uint16_t *blockLen,
- int seqNo, uint32_t ssrc)
+int makeRedundantHeader(unsigned char* rtp_data,
+ int* payloadType,
+ int numPayloads,
+ uint32_t* timestamp,
+ uint16_t* blockLen,
+ int seqNo,
+ uint32_t ssrc)
{
-
int i;
- unsigned char *rtpPointer;
+ unsigned char* rtpPointer;
uint16_t offset;
/* first create "standard" RTP header */
- makeRTPheader(rtp_data, NETEQ_CODEC_RED_PT, seqNo, timestamp[numPayloads-1], ssrc);
+ makeRTPheader(rtp_data, NETEQ_CODEC_RED_PT, seqNo, timestamp[numPayloads-1],
+ ssrc);
rtpPointer = &rtp_data[12];
/* add one sub-header for each redundant payload (not the primary) */
- for(i=0; i<numPayloads-1; i++) { /* |0 1 2 3 4 5 6 7| */
- if(blockLen[i] > 0) {
- offset = (uint16_t) (timestamp[numPayloads-1] - timestamp[i]);
+ for (i = 0; i < numPayloads - 1; i++) {
+ if (blockLen[i] > 0) {
+ offset = static_cast<uint16_t>(
+ timestamp[numPayloads - 1] - timestamp[i]);
- rtpPointer[0] = (unsigned char) ( 0x80 | (0x7F & payloadType[i]) ); /* |F| block PT | */
- rtpPointer[1] = (unsigned char) ((offset >> 6) & 0xFF); /* | timestamp- | */
- rtpPointer[2] = (unsigned char) ( ((offset & 0x3F)<<2) |
- ( (blockLen[i]>>8) & 0x03 ) ); /* | -offset |bl-| */
- rtpPointer[3] = (unsigned char) ( blockLen[i] & 0xFF ); /* | -ock length | */
+ // Byte |0| |1 2 | 3 |
+ // Bit |0|1234567|01234567012345|6701234567|
+ // |F|payload| timestamp | block |
+ // | | type | offset | length |
+ rtpPointer[0] = (payloadType[i] & 0x7F) | 0x80;
+ rtpPointer[1] = (offset >> 6) & 0xFF;
+ rtpPointer[2] =
+ ((offset & 0x3F) << 2) | ((blockLen[i] >> 8) & 0x03);
+ rtpPointer[3] = blockLen[i] & 0xFF;
rtpPointer += 4;
}
}
- /* last sub-header */
- rtpPointer[0]= (unsigned char) (0x00 | (0x7F&payloadType[numPayloads-1]));/* |F| block PT | */
- rtpPointer += 1;
+ // Bit |0|1234567|
+ // |0|payload|
+ // | | type |
+ rtpPointer[0] = payloadType[numPayloads - 1] & 0x7F;
+ ++rtpPointer;
- return(rtpPointer - rtp_data); /* length of header in bytes */
+ return rtpPointer - rtp_data; // length of header in bytes
}
diff --git a/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc b/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc
index 3942c13..65c4e9d 100644
--- a/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc
@@ -51,14 +51,14 @@
void ConstantPcmPacketSource::WriteHeader(uint8_t* packet_memory) {
packet_memory[0] = 0x80;
- packet_memory[1] = payload_type_ & 0xFF;
- packet_memory[2] = (seq_number_ >> 8) & 0xFF;
+ packet_memory[1] = static_cast<uint8_t>(payload_type_);
+ packet_memory[2] = seq_number_ >> 8;
packet_memory[3] = seq_number_ & 0xFF;
- packet_memory[4] = (timestamp_ >> 24) & 0xFF;
+ packet_memory[4] = timestamp_ >> 24;
packet_memory[5] = (timestamp_ >> 16) & 0xFF;
packet_memory[6] = (timestamp_ >> 8) & 0xFF;
packet_memory[7] = timestamp_ & 0xFF;
- packet_memory[8] = (payload_ssrc_ >> 24) & 0xFF;
+ packet_memory[8] = payload_ssrc_ >> 24;
packet_memory[9] = (payload_ssrc_ >> 16) & 0xFF;
packet_memory[10] = (payload_ssrc_ >> 8) & 0xFF;
packet_memory[11] = payload_ssrc_ & 0xFF;
diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
index bc07063..efa86d8 100644
--- a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
@@ -183,214 +183,90 @@
}
}
+void RegisterPayloadType(NetEq* neteq,
+ webrtc::NetEqDecoder codec,
+ google::int32 flag) {
+ if (neteq->RegisterPayloadType(codec, static_cast<uint8_t>(flag))) {
+ std::cerr << "Cannot register payload type " << flag << " as "
+ << CodecName(codec) << std::endl;
+ exit(1);
+ }
+}
+
// Registers all decoders in |neteq|.
void RegisterPayloadTypes(NetEq* neteq) {
assert(neteq);
- int error;
- error = neteq->RegisterPayloadType(webrtc::kDecoderPCMu,
- static_cast<uint8_t>(FLAGS_pcmu));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_pcmu <<
- " as " << CodecName(webrtc::kDecoderPCMu).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderPCMa,
- static_cast<uint8_t>(FLAGS_pcma));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_pcma <<
- " as " << CodecName(webrtc::kDecoderPCMa).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderILBC,
- static_cast<uint8_t>(FLAGS_ilbc));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_ilbc <<
- " as " << CodecName(webrtc::kDecoderILBC).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderISAC,
- static_cast<uint8_t>(FLAGS_isac));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_isac <<
- " as " << CodecName(webrtc::kDecoderISAC).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderISACswb,
- static_cast<uint8_t>(FLAGS_isac_swb));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_isac_swb <<
- " as " << CodecName(webrtc::kDecoderISACswb).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderOpus,
- static_cast<uint8_t>(FLAGS_opus));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_opus << " as "
- << CodecName(webrtc::kDecoderOpus).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16B,
- static_cast<uint8_t>(FLAGS_pcm16b));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_pcm16b <<
- " as " << CodecName(webrtc::kDecoderPCM16B).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16Bwb,
- static_cast<uint8_t>(FLAGS_pcm16b_wb));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_pcm16b_wb <<
- " as " << CodecName(webrtc::kDecoderPCM16Bwb).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16Bswb32kHz,
- static_cast<uint8_t>(FLAGS_pcm16b_swb32));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_pcm16b_swb32 <<
- " as " << CodecName(webrtc::kDecoderPCM16Bswb32kHz).c_str() <<
- std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16Bswb48kHz,
- static_cast<uint8_t>(FLAGS_pcm16b_swb48));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_pcm16b_swb48 <<
- " as " << CodecName(webrtc::kDecoderPCM16Bswb48kHz).c_str() <<
- std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderG722,
- static_cast<uint8_t>(FLAGS_g722));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_g722 <<
- " as " << CodecName(webrtc::kDecoderG722).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderAVT,
- static_cast<uint8_t>(FLAGS_avt));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_avt <<
- " as " << CodecName(webrtc::kDecoderAVT).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderRED,
- static_cast<uint8_t>(FLAGS_red));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_red <<
- " as " << CodecName(webrtc::kDecoderRED).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderCNGnb,
- static_cast<uint8_t>(FLAGS_cn_nb));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_cn_nb <<
- " as " << CodecName(webrtc::kDecoderCNGnb).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderCNGwb,
- static_cast<uint8_t>(FLAGS_cn_wb));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_cn_wb <<
- " as " << CodecName(webrtc::kDecoderCNGwb).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderCNGswb32kHz,
- static_cast<uint8_t>(FLAGS_cn_swb32));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_cn_swb32 <<
- " as " << CodecName(webrtc::kDecoderCNGswb32kHz).c_str() << std::endl;
- exit(1);
- }
- error = neteq->RegisterPayloadType(webrtc::kDecoderCNGswb48kHz,
- static_cast<uint8_t>(FLAGS_cn_swb48));
- if (error) {
- std::cerr << "Cannot register payload type " << FLAGS_cn_swb48 <<
- " as " << CodecName(webrtc::kDecoderCNGswb48kHz).c_str() << std::endl;
- exit(1);
- }
+ RegisterPayloadType(neteq, webrtc::kDecoderPCMu, FLAGS_pcmu);
+ RegisterPayloadType(neteq, webrtc::kDecoderPCMa, FLAGS_pcma);
+ RegisterPayloadType(neteq, webrtc::kDecoderILBC, FLAGS_ilbc);
+ RegisterPayloadType(neteq, webrtc::kDecoderISAC, FLAGS_isac);
+ RegisterPayloadType(neteq, webrtc::kDecoderISACswb, FLAGS_isac_swb);
+ RegisterPayloadType(neteq, webrtc::kDecoderOpus, FLAGS_opus);
+ RegisterPayloadType(neteq, webrtc::kDecoderPCM16B, FLAGS_pcm16b);
+ RegisterPayloadType(neteq, webrtc::kDecoderPCM16Bwb, FLAGS_pcm16b_wb);
+ RegisterPayloadType(neteq, webrtc::kDecoderPCM16Bswb32kHz,
+ FLAGS_pcm16b_swb32);
+ RegisterPayloadType(neteq, webrtc::kDecoderPCM16Bswb48kHz,
+ FLAGS_pcm16b_swb48);
+ RegisterPayloadType(neteq, webrtc::kDecoderG722, FLAGS_g722);
+ RegisterPayloadType(neteq, webrtc::kDecoderAVT, FLAGS_avt);
+ RegisterPayloadType(neteq, webrtc::kDecoderRED, FLAGS_red);
+ RegisterPayloadType(neteq, webrtc::kDecoderCNGnb, FLAGS_cn_nb);
+ RegisterPayloadType(neteq, webrtc::kDecoderCNGwb, FLAGS_cn_wb);
+ RegisterPayloadType(neteq, webrtc::kDecoderCNGswb32kHz, FLAGS_cn_swb32);
+ RegisterPayloadType(neteq, webrtc::kDecoderCNGswb48kHz, FLAGS_cn_swb48);
+}
+
+void PrintCodecMappingEntry(webrtc::NetEqDecoder codec, google::int32 flag) {
+ std::cout << CodecName(codec) << ": " << flag << std::endl;
}
void PrintCodecMapping() {
- std::cout << CodecName(webrtc::kDecoderPCMu).c_str() << ": " << FLAGS_pcmu <<
- std::endl;
- std::cout << CodecName(webrtc::kDecoderPCMa).c_str() << ": " << FLAGS_pcma <<
- std::endl;
- std::cout << CodecName(webrtc::kDecoderILBC).c_str() << ": " << FLAGS_ilbc <<
- std::endl;
- std::cout << CodecName(webrtc::kDecoderISAC).c_str() << ": " << FLAGS_isac <<
- std::endl;
- std::cout << CodecName(webrtc::kDecoderISACswb).c_str() << ": " <<
- FLAGS_isac_swb << std::endl;
- std::cout << CodecName(webrtc::kDecoderOpus).c_str() << ": " << FLAGS_opus
- << std::endl;
- std::cout << CodecName(webrtc::kDecoderPCM16B).c_str() << ": " <<
- FLAGS_pcm16b << std::endl;
- std::cout << CodecName(webrtc::kDecoderPCM16Bwb).c_str() << ": " <<
- FLAGS_pcm16b_wb << std::endl;
- std::cout << CodecName(webrtc::kDecoderPCM16Bswb32kHz).c_str() << ": " <<
- FLAGS_pcm16b_swb32 << std::endl;
- std::cout << CodecName(webrtc::kDecoderPCM16Bswb48kHz).c_str() << ": " <<
- FLAGS_pcm16b_swb48 << std::endl;
- std::cout << CodecName(webrtc::kDecoderG722).c_str() << ": " << FLAGS_g722 <<
- std::endl;
- std::cout << CodecName(webrtc::kDecoderAVT).c_str() << ": " << FLAGS_avt <<
- std::endl;
- std::cout << CodecName(webrtc::kDecoderRED).c_str() << ": " << FLAGS_red <<
- std::endl;
- std::cout << CodecName(webrtc::kDecoderCNGnb).c_str() << ": " <<
- FLAGS_cn_nb << std::endl;
- std::cout << CodecName(webrtc::kDecoderCNGwb).c_str() << ": " <<
- FLAGS_cn_wb << std::endl;
- std::cout << CodecName(webrtc::kDecoderCNGswb32kHz).c_str() << ": " <<
- FLAGS_cn_swb32 << std::endl;
- std::cout << CodecName(webrtc::kDecoderCNGswb48kHz).c_str() << ": " <<
- FLAGS_cn_swb48 << std::endl;
+ PrintCodecMappingEntry(webrtc::kDecoderPCMu, FLAGS_pcmu);
+ PrintCodecMappingEntry(webrtc::kDecoderPCMa, FLAGS_pcma);
+ PrintCodecMappingEntry(webrtc::kDecoderILBC, FLAGS_ilbc);
+ PrintCodecMappingEntry(webrtc::kDecoderISAC, FLAGS_isac);
+ PrintCodecMappingEntry(webrtc::kDecoderISACswb, FLAGS_isac_swb);
+ PrintCodecMappingEntry(webrtc::kDecoderOpus, FLAGS_opus);
+ PrintCodecMappingEntry(webrtc::kDecoderPCM16B, FLAGS_pcm16b);
+ PrintCodecMappingEntry(webrtc::kDecoderPCM16Bwb, FLAGS_pcm16b_wb);
+ PrintCodecMappingEntry(webrtc::kDecoderPCM16Bswb32kHz, FLAGS_pcm16b_swb32);
+ PrintCodecMappingEntry(webrtc::kDecoderPCM16Bswb48kHz, FLAGS_pcm16b_swb48);
+ PrintCodecMappingEntry(webrtc::kDecoderG722, FLAGS_g722);
+ PrintCodecMappingEntry(webrtc::kDecoderAVT, FLAGS_avt);
+ PrintCodecMappingEntry(webrtc::kDecoderRED, FLAGS_red);
+ PrintCodecMappingEntry(webrtc::kDecoderCNGnb, FLAGS_cn_nb);
+ PrintCodecMappingEntry(webrtc::kDecoderCNGwb, FLAGS_cn_wb);
+ PrintCodecMappingEntry(webrtc::kDecoderCNGswb32kHz, FLAGS_cn_swb32);
+ PrintCodecMappingEntry(webrtc::kDecoderCNGswb48kHz, FLAGS_cn_swb48);
}
-bool IsComfortNosie(uint8_t payload_type) {
- if (payload_type == FLAGS_cn_nb ||
- payload_type == FLAGS_cn_wb ||
- payload_type == FLAGS_cn_swb32 ||
- payload_type == FLAGS_cn_swb48) {
- return true;
- } else {
- return false;
- }
+bool IsComfortNoise(uint8_t payload_type) {
+ return payload_type == FLAGS_cn_nb || payload_type == FLAGS_cn_wb ||
+ payload_type == FLAGS_cn_swb32 || payload_type == FLAGS_cn_swb48;
}
int CodecSampleRate(uint8_t payload_type) {
- if (payload_type == FLAGS_pcmu ||
- payload_type == FLAGS_pcma ||
- payload_type == FLAGS_ilbc ||
- payload_type == FLAGS_pcm16b ||
- payload_type == FLAGS_cn_nb) {
+ if (payload_type == FLAGS_pcmu || payload_type == FLAGS_pcma ||
+ payload_type == FLAGS_ilbc || payload_type == FLAGS_pcm16b ||
+ payload_type == FLAGS_cn_nb)
return 8000;
- } else if (payload_type == FLAGS_isac ||
- payload_type == FLAGS_pcm16b_wb ||
- payload_type == FLAGS_g722 ||
- payload_type == FLAGS_cn_wb) {
+ if (payload_type == FLAGS_isac || payload_type == FLAGS_pcm16b_wb ||
+ payload_type == FLAGS_g722 || payload_type == FLAGS_cn_wb)
return 16000;
- } else if (payload_type == FLAGS_isac_swb ||
- payload_type == FLAGS_pcm16b_swb32 ||
- payload_type == FLAGS_cn_swb32) {
+ if (payload_type == FLAGS_isac_swb || payload_type == FLAGS_pcm16b_swb32 ||
+ payload_type == FLAGS_cn_swb32)
return 32000;
- } else if (payload_type == FLAGS_opus || payload_type == FLAGS_pcm16b_swb48 ||
- payload_type == FLAGS_cn_swb48) {
+ if (payload_type == FLAGS_opus || payload_type == FLAGS_pcm16b_swb48 ||
+ payload_type == FLAGS_cn_swb48)
return 48000;
- } else if (payload_type == FLAGS_avt ||
- payload_type == FLAGS_red) {
- return 0;
- } else {
- return -1;
- }
+ if (payload_type == FLAGS_avt || payload_type == FLAGS_red)
+ return 0;
+ return -1;
}
int CodecTimestampRate(uint8_t payload_type) {
- if (payload_type == FLAGS_g722) {
- return 8000;
- } else {
- return CodecSampleRate(payload_type);
- }
+ return (payload_type == FLAGS_g722) ? 8000 : CodecSampleRate(payload_type);
}
size_t ReplacePayload(webrtc::test::InputAudioFile* replacement_audio_file,
@@ -402,7 +278,7 @@
const webrtc::test::Packet* next_packet) {
size_t payload_len = 0;
// Check for CNG.
- if (IsComfortNosie(rtp_header->header.payloadType)) {
+ if (IsComfortNoise(rtp_header->header.payloadType)) {
// If CNG, simply insert a zero-energy one-byte payload.
if (*payload_mem_size_bytes < 1) {
(*payload).reset(new uint8_t[1]);
diff --git a/webrtc/modules/audio_coding/neteq/tools/packet_unittest.cc b/webrtc/modules/audio_coding/neteq/tools/packet_unittest.cc
index 10bcc5c..b32f54e 100644
--- a/webrtc/modules/audio_coding/neteq/tools/packet_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/packet_unittest.cc
@@ -26,14 +26,14 @@
uint32_t ssrc,
uint8_t* rtp_data) {
rtp_data[0] = 0x80;
- rtp_data[1] = payload_type & 0xFF;
+ rtp_data[1] = static_cast<uint8_t>(payload_type);
rtp_data[2] = (seq_number >> 8) & 0xFF;
rtp_data[3] = (seq_number) & 0xFF;
- rtp_data[4] = (timestamp >> 24) & 0xFF;
+ rtp_data[4] = timestamp >> 24;
rtp_data[5] = (timestamp >> 16) & 0xFF;
rtp_data[6] = (timestamp >> 8) & 0xFF;
rtp_data[7] = timestamp & 0xFF;
- rtp_data[8] = (ssrc >> 24) & 0xFF;
+ rtp_data[8] = ssrc >> 24;
rtp_data[9] = (ssrc >> 16) & 0xFF;
rtp_data[10] = (ssrc >> 8) & 0xFF;
rtp_data[11] = ssrc & 0xFF;