Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/modules/rtp_rtcp/test/testAPI/test_api_video.cc b/modules/rtp_rtcp/test/testAPI/test_api_video.cc
index 4c4944d..ddcfa96 100644
--- a/modules/rtp_rtcp/test/testAPI/test_api_video.cc
+++ b/modules/rtp_rtcp/test/testAPI/test_api_video.cc
@@ -73,43 +73,42 @@
payload_data_length_ = sizeof(video_frame_);
- for (int n = 0; n < payload_data_length_; n++) {
+ for (size_t n = 0; n < payload_data_length_; n++) {
video_frame_[n] = n%10;
}
}
- int32_t BuildRTPheader(uint8_t* dataBuffer,
- uint32_t timestamp,
- uint32_t sequence_number) {
+ size_t BuildRTPheader(uint8_t* dataBuffer,
+ uint32_t timestamp,
+ uint32_t sequence_number) {
dataBuffer[0] = static_cast<uint8_t>(0x80); // version 2
dataBuffer[1] = static_cast<uint8_t>(kPayloadType);
RtpUtility::AssignUWord16ToBuffer(dataBuffer + 2, sequence_number);
RtpUtility::AssignUWord32ToBuffer(dataBuffer + 4, timestamp);
RtpUtility::AssignUWord32ToBuffer(dataBuffer + 8, 0x1234); // SSRC.
- int32_t rtpHeaderLength = 12;
+ size_t rtpHeaderLength = 12;
return rtpHeaderLength;
}
- int PaddingPacket(uint8_t* buffer,
- uint32_t timestamp,
- uint32_t sequence_number,
- int32_t bytes) {
+ size_t PaddingPacket(uint8_t* buffer,
+ uint32_t timestamp,
+ uint32_t sequence_number,
+ size_t bytes) {
// Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
- int max_length = 224;
+ size_t max_length = 224;
- int padding_bytes_in_packet = max_length;
+ size_t padding_bytes_in_packet = max_length;
if (bytes < max_length) {
padding_bytes_in_packet = (bytes + 16) & 0xffe0; // Keep our modulus 32.
}
// Correct seq num, timestamp and payload type.
- int header_length = BuildRTPheader(buffer, timestamp,
- sequence_number);
+ size_t header_length = BuildRTPheader(buffer, timestamp, sequence_number);
buffer[0] |= 0x20; // Set padding bit.
int32_t* data =
reinterpret_cast<int32_t*>(&(buffer[header_length]));
// Fill data buffer with random data.
- for (int j = 0; j < (padding_bytes_in_packet >> 2); j++) {
+ for (size_t j = 0; j < (padding_bytes_in_packet >> 2); j++) {
data[j] = rand(); // NOLINT
}
// Set number of padding bytes in the last byte of the packet.
@@ -135,7 +134,7 @@
uint32_t test_timestamp_;
uint16_t test_sequence_number_;
uint8_t video_frame_[65000];
- int payload_data_length_;
+ size_t payload_data_length_;
SimulatedClock fake_clock;
enum { kPayloadType = 100 };
};
@@ -150,7 +149,7 @@
}
TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) {
- const int kPadSize = 255;
+ const size_t kPadSize = 255;
uint8_t padding_packet[kPadSize];
uint32_t seq_num = 0;
uint32_t timestamp = 3000;
@@ -165,8 +164,8 @@
codec.maxBitrate));
for (int frame_idx = 0; frame_idx < 10; ++frame_idx) {
for (int packet_idx = 0; packet_idx < 5; ++packet_idx) {
- int packet_size = PaddingPacket(padding_packet, timestamp, seq_num,
- kPadSize);
+ size_t packet_size = PaddingPacket(padding_packet, timestamp, seq_num,
+ kPadSize);
++seq_num;
RTPHeader header;
scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
@@ -175,11 +174,11 @@
EXPECT_TRUE(rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
&payload_specific));
const uint8_t* payload = padding_packet + header.headerLength;
- const int payload_length = packet_size - header.headerLength;
+ const size_t payload_length = packet_size - header.headerLength;
EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(header, payload,
payload_length,
payload_specific, true));
- EXPECT_EQ(0, receiver_->payload_size());
+ EXPECT_EQ(0u, receiver_->payload_size());
EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength);
}
timestamp += 3000;