* 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
This commit is contained in:
pkasting@chromium.org
2015-02-23 21:28:22 +00:00
parent 722739108a
commit d324546ced
43 changed files with 393 additions and 541 deletions

View File

@ -16,15 +16,9 @@
namespace webrtc {
enum {
kFecPayloadType = 96
};
enum {
kRedPayloadType = 97
};
enum {
kVp8PayloadType = 120
};
const uint8_t kFecPayloadType = 96;
const uint8_t kRedPayloadType = 97;
const uint8_t kVp8PayloadType = 120;
typedef ForwardErrorCorrection::Packet Packet;

View File

@ -185,23 +185,23 @@ TEST(NACKStringBuilderTest, TestCase13) {
EXPECT_EQ(std::string("5-6,9"), builder.GetResult());
}
void CreateRtpPacket(const bool marker_bit, const uint8_t payload,
void CreateRtpPacket(const bool marker_bit, const uint8_t payload_type,
const uint16_t seq_num, const uint32_t timestamp,
const uint32_t ssrc, uint8_t* array,
size_t* cur_pos) {
ASSERT_TRUE(payload <= 127);
ASSERT_LE(payload_type, 127);
array[(*cur_pos)++] = 0x80;
array[(*cur_pos)++] = payload | (marker_bit ? 0x80 : 0);
array[(*cur_pos)++] = payload_type | (marker_bit ? 0x80 : 0);
array[(*cur_pos)++] = seq_num >> 8;
array[(*cur_pos)++] = seq_num;
array[(*cur_pos)++] = seq_num & 0xFF;
array[(*cur_pos)++] = timestamp >> 24;
array[(*cur_pos)++] = timestamp >> 16;
array[(*cur_pos)++] = timestamp >> 8;
array[(*cur_pos)++] = timestamp;
array[(*cur_pos)++] = (timestamp >> 16) & 0xFF;
array[(*cur_pos)++] = (timestamp >> 8) & 0xFF;
array[(*cur_pos)++] = timestamp & 0xFF;
array[(*cur_pos)++] = ssrc >> 24;
array[(*cur_pos)++] = ssrc >> 16;
array[(*cur_pos)++] = ssrc >> 8;
array[(*cur_pos)++] = ssrc;
array[(*cur_pos)++] = (ssrc >> 16) & 0xFF;
array[(*cur_pos)++] = (ssrc >> 8) & 0xFF;
array[(*cur_pos)++] = ssrc & 0xFF;
// VP8 payload header
array[(*cur_pos)++] = 0x90; // X bit = 1
array[(*cur_pos)++] = 0x20; // T bit = 1
@ -353,19 +353,19 @@ TEST_F(RtcpSenderTest, IJStatus) {
TEST_F(RtcpSenderTest, TestCompound) {
const bool marker_bit = false;
const uint8_t payload = 100;
const uint8_t payload_type = 100;
const uint16_t seq_num = 11111;
const uint32_t timestamp = 1234567;
const uint32_t ssrc = 0x11111111;
size_t packet_length = 0;
CreateRtpPacket(marker_bit, payload, seq_num, timestamp, ssrc, packet_,
CreateRtpPacket(marker_bit, payload_type, seq_num, timestamp, ssrc, packet_,
&packet_length);
EXPECT_EQ(25u, packet_length);
VideoCodec codec_inst;
strncpy(codec_inst.plName, "VP8", webrtc::kPayloadNameSize - 1);
codec_inst.codecType = webrtc::kVideoCodecVP8;
codec_inst.plType = payload;
codec_inst.plType = payload_type;
EXPECT_EQ(0, rtp_receiver_->RegisterReceivePayload(codec_inst.plName,
codec_inst.plType,
90000,

View File

@ -225,8 +225,7 @@ TEST_P(ParameterizedRtpPayloadRegistryTest,
bool ignored;
EXPECT_EQ(-1, rtp_payload_registry_->RegisterReceivePayload(
"whatever", static_cast<uint8_t>(payload_type), 19, 1, 17,
&ignored));
"whatever", static_cast<uint8_t>(payload_type), 19, 1, 17, &ignored));
}
INSTANTIATE_TEST_CASE_P(TestKnownBadPayloadTypes,

View File

@ -64,7 +64,7 @@ bool RTPReceiverAudio::TelephoneEventForwardToDecoder() const {
bool RTPReceiverAudio::TelephoneEventPayloadType(
int8_t payload_type) const {
CriticalSectionScoped lock(crit_sect_.get());
return (telephone_event_payload_type_ == payload_type) ? true : false;
return telephone_event_payload_type_ == payload_type;
}
bool RTPReceiverAudio::CNGPayloadType(int8_t payload_type,

View File

@ -1614,9 +1614,9 @@ int32_t RTPSender::SetGenericFECStatus(bool enable,
payload_type_fec);
}
int32_t RTPSender::GenericFECStatus(
bool *enable, uint8_t *payload_type_red,
uint8_t *payload_type_fec) const {
int32_t RTPSender::GenericFECStatus(bool* enable,
uint8_t* payload_type_red,
uint8_t* payload_type_fec) const {
if (audio_configured_) {
return -1;
}

View File

@ -242,21 +242,19 @@ bool RtpHeaderParser::RTCP() const {
return false;
}
const uint8_t V = _ptrRTPDataBegin[0] >> 6;
const uint8_t V = _ptrRTPDataBegin[0] >> 6;
if (V != kRtcpExpectedVersion) {
return false;
}
const uint8_t payloadType = _ptrRTPDataBegin[1];
bool RTCP = false;
const uint8_t payloadType = _ptrRTPDataBegin[1];
switch (payloadType) {
case 192:
RTCP = true;
break;
return true;
case 193:
// not supported
// pass through and check for a potential RTP packet
break;
return false;
case 195:
case 200:
case 201:
@ -266,10 +264,10 @@ bool RtpHeaderParser::RTCP() const {
case 205:
case 206:
case 207:
RTCP = true;
break;
return true;
default:
return false;
}
return RTCP;
}
bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const {