diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc index fb36cf82e6..a6ba799cc6 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -1258,7 +1258,7 @@ class MediaCodecVideoEncoder : public webrtc::VideoEncoder, // |codec_thread_| for execution. virtual int32_t InitEncode(const webrtc::VideoCodec* codec_settings, int32_t /* number_of_cores */, - uint32_t /* max_payload_size */) OVERRIDE; + size_t /* max_payload_size */) OVERRIDE; virtual int32_t Encode( const webrtc::I420VideoFrame& input_image, const webrtc::CodecSpecificInfo* /* codec_specific_info */, @@ -1433,7 +1433,7 @@ MediaCodecVideoEncoder::MediaCodecVideoEncoder(JNIEnv* jni) int32_t MediaCodecVideoEncoder::InitEncode( const webrtc::VideoCodec* codec_settings, int32_t /* number_of_cores */, - uint32_t /* max_payload_size */) { + size_t /* max_payload_size */) { // Factory should guard against other codecs being used with us. CHECK(codec_settings->codecType == kVideoCodecVP8) << "Unsupported codec"; diff --git a/talk/media/webrtc/fakewebrtcvideoengine.h b/talk/media/webrtc/fakewebrtcvideoengine.h index 677f899bd7..f729ddd1c2 100644 --- a/talk/media/webrtc/fakewebrtcvideoengine.h +++ b/talk/media/webrtc/fakewebrtcvideoengine.h @@ -152,7 +152,7 @@ class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder { virtual int32 InitEncode(const webrtc::VideoCodec* codecSettings, int32 numberOfCores, - uint32 maxPayloadSize) { + size_t maxPayloadSize) { return WEBRTC_VIDEO_CODEC_OK; } @@ -351,7 +351,7 @@ class FakeWebRtcVideoEngine // From ViEExternalCapture virtual int IncomingFrame(unsigned char* videoFrame, - unsigned int videoFrameLength, + size_t videoFrameLength, unsigned short width, unsigned short height, webrtc::RawVideoType videoType, @@ -890,7 +890,7 @@ class FakeWebRtcVideoEngine WEBRTC_FUNC(ReceivedRTPPacket, (const int channel, const void* packet, - const int length, + const size_t length, const webrtc::PacketTime& packet_time)) { WEBRTC_ASSERT_CHANNEL(channel); ASSERT(length > 1); @@ -899,11 +899,11 @@ class FakeWebRtcVideoEngine return 0; } - WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const int)); + WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const size_t)); // Not using WEBRTC_STUB due to bool return value virtual bool IsIPv6Enabled(int channel) { return true; } WEBRTC_STUB(SetMTU, (int, unsigned int)); - WEBRTC_STUB(ReceivedBWEPacket, (const int, int64_t, int, + WEBRTC_STUB(ReceivedBWEPacket, (const int, int64_t, size_t, const webrtc::RTPHeader&)); virtual bool SetBandwidthEstimationConfig(int, const webrtc::Config&) { return true; @@ -1140,8 +1140,8 @@ class FakeWebRtcVideoEngine unsigned int&, unsigned int&, unsigned int&, int&)); WEBRTC_STUB_CONST(GetSentRTCPStatistics, (const int, unsigned short&, unsigned int&, unsigned int&, unsigned int&, int&)); - WEBRTC_STUB_CONST(GetRTPStatistics, (const int, unsigned int&, unsigned int&, - unsigned int&, unsigned int&)); + WEBRTC_STUB_CONST(GetRTPStatistics, (const int, size_t&, unsigned int&, + size_t&, unsigned int&)); WEBRTC_STUB_CONST(GetReceiveChannelRtcpStatistics, (const int, webrtc::RtcpStatistics&, int&)); WEBRTC_STUB_CONST(GetSendChannelRtcpStatistics, (const int, diff --git a/talk/media/webrtc/fakewebrtcvoiceengine.h b/talk/media/webrtc/fakewebrtcvoiceengine.h index 222ce4becf..dc27e969b8 100644 --- a/talk/media/webrtc/fakewebrtcvoiceengine.h +++ b/talk/media/webrtc/fakewebrtcvoiceengine.h @@ -858,7 +858,7 @@ class FakeWebRtcVoiceEngine return 0; } WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, - unsigned int length)) { + size_t length)) { WEBRTC_CHECK_CHANNEL(channel); if (!channels_[channel]->external_transport) return -1; channels_[channel]->packets.push_back( @@ -866,7 +866,7 @@ class FakeWebRtcVoiceEngine return 0; } WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, - unsigned int length, + size_t length, const webrtc::PacketTime& packet_time)) { WEBRTC_CHECK_CHANNEL(channel); if (ReceivedRTPPacket(channel, data, length) == -1) { @@ -877,7 +877,7 @@ class FakeWebRtcVoiceEngine } WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data, - unsigned int length)); + size_t length)); // webrtc::VoERTP_RTCP WEBRTC_STUB(RegisterRTPObserver, (int channel, diff --git a/talk/media/webrtc/webrtcvideocapturer.cc b/talk/media/webrtc/webrtcvideocapturer.cc index ea8b61a1b9..32f105dc11 100644 --- a/talk/media/webrtc/webrtcvideocapturer.cc +++ b/talk/media/webrtc/webrtcvideocapturer.cc @@ -36,6 +36,7 @@ #include "talk/media/webrtc/webrtcvideoframefactory.h" #include "webrtc/base/criticalsection.h" #include "webrtc/base/logging.h" +#include "webrtc/base/safe_conversions.h" #include "webrtc/base/thread.h" #include "webrtc/base/timeutils.h" @@ -351,8 +352,8 @@ void WebRtcVideoCapturer::OnIncomingCapturedFrame(const int32_t id, // Signal down stream components on captured frame. // The CapturedFrame class doesn't support planes. We have to ExtractBuffer // to one block for it. - int length = webrtc::CalcBufferSize(webrtc::kI420, - sample.width(), sample.height()); + size_t length = + webrtc::CalcBufferSize(webrtc::kI420, sample.width(), sample.height()); capture_buffer_.resize(length); // TODO(ronghuawu): Refactor the WebRtcCapturedFrame to avoid memory copy. webrtc::ExtractBuffer(sample, length, &capture_buffer_[0]); @@ -368,7 +369,7 @@ void WebRtcVideoCapturer::OnCaptureDelayChanged(const int32_t id, // WebRtcCapturedFrame WebRtcCapturedFrame::WebRtcCapturedFrame(const webrtc::I420VideoFrame& sample, void* buffer, - int length) { + size_t length) { width = sample.width(); height = sample.height(); fourcc = FOURCC_I420; @@ -378,7 +379,7 @@ WebRtcCapturedFrame::WebRtcCapturedFrame(const webrtc::I420VideoFrame& sample, // Convert units from VideoFrame RenderTimeMs to CapturedFrame (nanoseconds). elapsed_time = sample.render_time_ms() * rtc::kNumNanosecsPerMillisec; time_stamp = elapsed_time; - data_size = length; + data_size = rtc::checked_cast(length); data = buffer; } diff --git a/talk/media/webrtc/webrtcvideocapturer.h b/talk/media/webrtc/webrtcvideocapturer.h index 39a71f81c7..7d0904038a 100644 --- a/talk/media/webrtc/webrtcvideocapturer.h +++ b/talk/media/webrtc/webrtcvideocapturer.h @@ -98,7 +98,7 @@ class WebRtcVideoCapturer : public VideoCapturer, struct WebRtcCapturedFrame : public CapturedFrame { public: WebRtcCapturedFrame(const webrtc::I420VideoFrame& frame, - void* buffer, int length); + void* buffer, size_t length); }; } // namespace cricket diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc index 88acc3f5a9..1e8c43b2fa 100644 --- a/talk/media/webrtc/webrtcvideoengine.cc +++ b/talk/media/webrtc/webrtcvideoengine.cc @@ -305,7 +305,7 @@ class WebRtcRenderAdapter : public webrtc::ExternalRenderer { } virtual int DeliverFrame(unsigned char* buffer, - int buffer_size, + size_t buffer_size, uint32_t rtp_time_stamp, int64_t ntp_time_ms, int64_t render_time, @@ -347,14 +347,14 @@ class WebRtcRenderAdapter : public webrtc::ExternalRenderer { virtual bool IsTextureSupported() { return true; } - int DeliverBufferFrame(unsigned char* buffer, int buffer_size, + int DeliverBufferFrame(unsigned char* buffer, size_t buffer_size, int64 time_stamp, int64 elapsed_time) { WebRtcVideoFrame video_frame; video_frame.Alias(buffer, buffer_size, width_, height_, 1, 1, elapsed_time, time_stamp, 0); // Sanity check on decoded frame size. - if (buffer_size != static_cast(VideoFrame::SizeOf(width_, height_))) { + if (buffer_size != VideoFrame::SizeOf(width_, height_)) { LOG(LS_WARNING) << "WebRtcRenderAdapter (channel " << channel_id_ << ") received a strange frame size: " << buffer_size; @@ -2499,7 +2499,8 @@ bool WebRtcVideoMediaChannel::GetStats(const StatsOptions& options, ASSERT(channel_id == default_channel_id_); continue; } - unsigned int bytes_sent, packets_sent, bytes_recv, packets_recv; + size_t bytes_sent, bytes_recv; + unsigned int packets_sent, packets_recv; if (engine_->vie()->rtp()->GetRTPStatistics(channel_id, bytes_sent, packets_sent, bytes_recv, packets_recv) != 0) { @@ -2829,7 +2830,7 @@ void WebRtcVideoMediaChannel::OnPacketReceived( engine()->vie()->network()->ReceivedRTPPacket( processing_channel_id, packet->data(), - static_cast(packet->length()), + packet->length(), webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); } @@ -2858,7 +2859,7 @@ void WebRtcVideoMediaChannel::OnRtcpReceived( engine_->vie()->network()->ReceivedRTCPPacket( recv_channel_id, packet->data(), - static_cast(packet->length())); + packet->length()); } } // SR may continue RR and any RR entry may correspond to any one of the send @@ -2871,7 +2872,7 @@ void WebRtcVideoMediaChannel::OnRtcpReceived( engine_->vie()->network()->ReceivedRTCPPacket( channel_id, packet->data(), - static_cast(packet->length())); + packet->length()); } } @@ -4022,16 +4023,16 @@ void WebRtcVideoMediaChannel::OnMessage(rtc::Message* msg) { } int WebRtcVideoMediaChannel::SendPacket(int channel, const void* data, - int len) { + size_t len) { rtc::Buffer packet(data, len, kMaxRtpPacketLen); - return MediaChannel::SendPacket(&packet) ? len : -1; + return MediaChannel::SendPacket(&packet) ? static_cast(len) : -1; } int WebRtcVideoMediaChannel::SendRTCPPacket(int channel, const void* data, - int len) { + size_t len) { rtc::Buffer packet(data, len, kMaxRtpPacketLen); - return MediaChannel::SendRtcp(&packet) ? len : -1; + return MediaChannel::SendRtcp(&packet) ? static_cast(len) : -1; } void WebRtcVideoMediaChannel::QueueBlackFrame(uint32 ssrc, int64 timestamp, diff --git a/talk/media/webrtc/webrtcvideoengine.h b/talk/media/webrtc/webrtcvideoengine.h index db091aface..d1ace7dbf7 100644 --- a/talk/media/webrtc/webrtcvideoengine.h +++ b/talk/media/webrtc/webrtcvideoengine.h @@ -331,8 +331,10 @@ class WebRtcVideoMediaChannel : public rtc::MessageHandler, int GetLastEngineError() { return engine()->GetLastEngineError(); } // webrtc::Transport: - virtual int SendPacket(int channel, const void* data, int len) OVERRIDE; - virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE; + virtual int SendPacket(int channel, const void* data, size_t len) OVERRIDE; + virtual int SendRTCPPacket(int channel, + const void* data, + size_t len) OVERRIDE; bool ConferenceModeIsEnabled() const { return options_.conference_mode.GetWithDefaultIfUnset(false); diff --git a/talk/media/webrtc/webrtcvideoframe.cc b/talk/media/webrtc/webrtcvideoframe.cc index 9e4ea06c89..9dbf5a5a85 100644 --- a/talk/media/webrtc/webrtcvideoframe.cc +++ b/talk/media/webrtc/webrtcvideoframe.cc @@ -71,8 +71,8 @@ WebRtcVideoFrame::FrameBuffer::~FrameBuffer() { // Make sure that |video_frame_| doesn't delete the buffer, as |owned_data_| // will release the buffer if this FrameBuffer owns it. uint8_t* new_memory = NULL; - uint32_t new_length = 0; - uint32_t new_size = 0; + size_t new_length = 0; + size_t new_size = 0; video_frame_.Swap(new_memory, new_length, new_size); } @@ -84,8 +84,8 @@ void WebRtcVideoFrame::FrameBuffer::Attach(uint8* data, size_t length) { void WebRtcVideoFrame::FrameBuffer::Alias(uint8* data, size_t length) { owned_data_.reset(); uint8_t* new_memory = reinterpret_cast(data); - uint32_t new_length = static_cast(length); - uint32_t new_size = static_cast(length); + size_t new_length = length; + size_t new_size = length; video_frame_.Swap(new_memory, new_length, new_size); } diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc index c335626dc2..9f5d3067b2 100644 --- a/talk/media/webrtc/webrtcvoiceengine.cc +++ b/talk/media/webrtc/webrtcvoiceengine.cc @@ -3154,7 +3154,7 @@ void WebRtcVoiceMediaChannel::OnPacketReceived( engine()->voe()->network()->ReceivedRTPPacket( which_channel, packet->data(), - static_cast(packet->length()), + packet->length(), webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); } @@ -3179,7 +3179,7 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived( engine()->voe()->network()->ReceivedRTCPPacket( which_channel, packet->data(), - static_cast(packet->length())); + packet->length()); if (IsDefaultChannel(which_channel)) has_sent_to_default_channel = true; @@ -3199,7 +3199,7 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived( engine()->voe()->network()->ReceivedRTCPPacket( iter->second->channel(), packet->data(), - static_cast(packet->length())); + packet->length()); } } @@ -3730,7 +3730,7 @@ bool WebRtcVoiceMediaChannel::SetupSharedBweOnChannel(int voe_channel) { return true; } -int WebRtcSoundclipStream::Read(void *buf, int len) { +int WebRtcSoundclipStream::Read(void *buf, size_t len) { size_t res = 0; mem_.Read(buf, len, &res, NULL); return static_cast(res); diff --git a/talk/media/webrtc/webrtcvoiceengine.h b/talk/media/webrtc/webrtcvoiceengine.h index 67fadc5e35..6dc1f25a8f 100644 --- a/talk/media/webrtc/webrtcvoiceengine.h +++ b/talk/media/webrtc/webrtcvoiceengine.h @@ -69,7 +69,7 @@ class WebRtcSoundclipStream : public webrtc::InStream { } void set_loop(bool loop) { loop_ = loop; } - virtual int Read(void* buf, int len) OVERRIDE; + virtual int Read(void* buf, size_t len) OVERRIDE; virtual int Rewind() OVERRIDE; private: @@ -80,7 +80,7 @@ class WebRtcSoundclipStream : public webrtc::InStream { // WebRtcMonitorStream is used to monitor a stream coming from WebRtc. // For now we just dump the data. class WebRtcMonitorStream : public webrtc::OutStream { - virtual bool Write(const void *buf, int len) OVERRIDE { + virtual bool Write(const void *buf, size_t len) OVERRIDE { return true; } }; @@ -315,17 +315,16 @@ class WebRtcMediaChannel : public T, public webrtc::Transport { protected: // implements Transport interface - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE { rtc::Buffer packet(data, len, kMaxRtpPacketLen); - if (!T::SendPacket(&packet)) { - return -1; - } - return len; + return T::SendPacket(&packet) ? static_cast(len) : -1; } - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendRTCPPacket(int channel, + const void* data, + size_t len) OVERRIDE { rtc::Buffer packet(data, len, kMaxRtpPacketLen); - return T::SendRtcp(&packet) ? len : -1; + return T::SendRtcp(&packet) ? static_cast(len) : -1; } private: diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index 1c2527af51..5ded359d98 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -184,6 +184,7 @@ static_library("webrtc_base") { "firewallsocketserver.h", "flags.cc", "flags.h", + "format_macros.h", "gunit_prod.h", "helpers.cc", "helpers.h", diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp index 2fd64ba5e2..380eee6ed5 100644 --- a/webrtc/base/base.gyp +++ b/webrtc/base/base.gyp @@ -127,6 +127,7 @@ 'firewallsocketserver.h', 'flags.cc', 'flags.h', + 'format_macros.h', 'gunit_prod.h', 'helpers.cc', 'helpers.h', diff --git a/webrtc/base/format_macros.h b/webrtc/base/format_macros.h new file mode 100644 index 0000000000..5d7dcc36b9 --- /dev/null +++ b/webrtc/base/format_macros.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_BASE_FORMAT_MACROS_H_ +#define WEBRTC_BASE_FORMAT_MACROS_H_ + +// This file defines the format macros for some integer types and is derived +// from Chromium's base/format_macros.h. + +// To print a 64-bit value in a portable way: +// int64_t value; +// printf("xyz:%" PRId64, value); +// The "d" in the macro corresponds to %d; you can also use PRIu64 etc. +// +// To print a size_t value in a portable way: +// size_t size; +// printf("xyz: %" PRIuS, size); +// The "u" in the macro corresponds to %u, and S is for "size". + +#include "webrtc/typedefs.h" + +#if defined(WEBRTC_POSIX) + +#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64) +#error "inttypes.h has already been included before this header file, but " +#error "without __STDC_FORMAT_MACROS defined." +#endif + +#if !defined(__STDC_FORMAT_MACROS) +#define __STDC_FORMAT_MACROS +#endif + +#include + +#if !defined(PRIuS) +#define PRIuS "zu" +#endif + +// The size of NSInteger and NSUInteger varies between 32-bit and 64-bit +// architectures and Apple does not provides standard format macros and +// recommends casting. This has many drawbacks, so instead define macros +// for formatting those types. +#if defined(WEBRTC_MAC) +#if defined(WEBRTC_ARCH_64_BITS) +#if !defined(PRIdNS) +#define PRIdNS "ld" +#endif +#if !defined(PRIuNS) +#define PRIuNS "lu" +#endif +#if !defined(PRIxNS) +#define PRIxNS "lx" +#endif +#else // defined(WEBRTC_ARCH_64_BITS) +#if !defined(PRIdNS) +#define PRIdNS "d" +#endif +#if !defined(PRIuNS) +#define PRIuNS "u" +#endif +#if !defined(PRIxNS) +#define PRIxNS "x" +#endif +#endif +#endif // defined(WEBRTC_MAC) + +#else // WEBRTC_WIN + +#if !defined(PRId64) +#define PRId64 "I64d" +#endif + +#if !defined(PRIu64) +#define PRIu64 "I64u" +#endif + +#if !defined(PRIx64) +#define PRIx64 "I64x" +#endif + +#if !defined(PRIuS) +#define PRIuS "Iu" +#endif + +#endif + +#endif // WEBRTC_BASE_FORMAT_MACROS_H_ diff --git a/webrtc/common_types.h b/webrtc/common_types.h index 0b4af26e6a..aa6f319928 100644 --- a/webrtc/common_types.h +++ b/webrtc/common_types.h @@ -56,7 +56,7 @@ class Config; class InStream { public: - virtual int Read(void *buf,int len) = 0; + virtual int Read(void *buf, size_t len) = 0; virtual int Rewind() {return -1;} virtual ~InStream() {} protected: @@ -66,7 +66,7 @@ protected: class OutStream { public: - virtual bool Write(const void *buf,int len) = 0; + virtual bool Write(const void *buf, size_t len) = 0; virtual int Rewind() {return -1;} virtual ~OutStream() {} protected: @@ -166,8 +166,8 @@ enum FrameType class Transport { public: - virtual int SendPacket(int channel, const void *data, int len) = 0; - virtual int SendRTCPPacket(int channel, const void *data, int len) = 0; + virtual int SendPacket(int channel, const void *data, size_t len) = 0; + virtual int SendRTCPPacket(int channel, const void *data, size_t len) = 0; protected: virtual ~Transport() {} @@ -240,9 +240,9 @@ struct StreamDataCounters { fec_packets(0) {} // TODO(pbos): Rename bytes -> media_bytes. - uint32_t bytes; // Payload bytes, excluding RTP headers and padding. - uint32_t header_bytes; // Number of bytes used by RTP headers. - uint32_t padding_bytes; // Number of padding bytes. + size_t bytes; // Payload bytes, excluding RTP headers and padding. + size_t header_bytes; // Number of bytes used by RTP headers. + size_t padding_bytes; // Number of padding bytes. uint32_t packets; // Number of packets. uint32_t retransmitted_packets; // Number of retransmitted packets. uint32_t fec_packets; // Number of redundancy packets. @@ -828,8 +828,8 @@ struct RTPHeader { uint32_t ssrc; uint8_t numCSRCs; uint32_t arrOfCSRCs[kRtpCsrcSize]; - uint8_t paddingLength; - uint16_t headerLength; + size_t paddingLength; + size_t headerLength; int payload_type_frequency; RTPHeaderExtension extension; }; diff --git a/webrtc/common_video/libyuv/include/webrtc_libyuv.h b/webrtc/common_video/libyuv/include/webrtc_libyuv.h index 70d8e2ae5f..8f6e0311ee 100644 --- a/webrtc/common_video/libyuv/include/webrtc_libyuv.h +++ b/webrtc/common_video/libyuv/include/webrtc_libyuv.h @@ -81,8 +81,8 @@ void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv); // - width :frame width in pixels. // - height :frame height in pixels. // Return value: :The required size in bytes to accommodate the specified -// video frame or -1 in case of an error . -int CalcBufferSize(VideoType type, int width, int height); +// video frame. +size_t CalcBufferSize(VideoType type, int width, int height); // TODO(mikhal): Add unit test for these two functions and determine location. // Print I420VideoFrame to file @@ -101,7 +101,7 @@ int PrintI420VideoFrame(const I420VideoFrame& frame, FILE* file); // - buffer : Pointer to buffer // Return value: length of buffer if OK, < 0 otherwise. int ExtractBuffer(const I420VideoFrame& input_frame, - int size, uint8_t* buffer); + size_t size, uint8_t* buffer); // Convert To I420 // Input: // - src_video_type : Type of input video. @@ -119,7 +119,7 @@ int ConvertToI420(VideoType src_video_type, const uint8_t* src_frame, int crop_x, int crop_y, int src_width, int src_height, - int sample_size, + size_t sample_size, VideoRotationMode rotation, I420VideoFrame* dst_frame); diff --git a/webrtc/common_video/libyuv/libyuv_unittest.cc b/webrtc/common_video/libyuv/libyuv_unittest.cc index 0abe7f3cc0..c9c3b1c607 100644 --- a/webrtc/common_video/libyuv/libyuv_unittest.cc +++ b/webrtc/common_video/libyuv/libyuv_unittest.cc @@ -89,7 +89,7 @@ class TestLibYuv : public ::testing::Test { const int height_; const int size_y_; const int size_uv_; - const int frame_length_; + const size_t frame_length_; }; TestLibYuv::TestLibYuv() @@ -110,8 +110,8 @@ void TestLibYuv::SetUp() { ASSERT_TRUE(source_file_ != NULL) << "Cannot read file: "<< input_file_name << "\n"; - EXPECT_EQ(fread(orig_buffer_.get(), 1, frame_length_, source_file_), - static_cast(frame_length_)); + EXPECT_EQ(frame_length_, + fread(orig_buffer_.get(), 1, frame_length_, source_file_)); EXPECT_EQ(0, orig_frame_.CreateFrame(size_y_, orig_buffer_.get(), size_uv_, orig_buffer_.get() + size_y_, size_uv_, orig_buffer_.get() + @@ -206,8 +206,8 @@ TEST_F(TestLibYuv, ConvertTest) { width_, height_, width_, (width_ + 1) / 2, (width_ + 1) / 2); EXPECT_EQ(0, ConvertFromYV12(yv12_frame, kI420, 0, res_i420_buffer.get())); - if (fwrite(res_i420_buffer.get(), 1, frame_length_, - output_file) != static_cast(frame_length_)) { + if (fwrite(res_i420_buffer.get(), 1, frame_length_, output_file) != + frame_length_) { return; } diff --git a/webrtc/common_video/libyuv/scaler_unittest.cc b/webrtc/common_video/libyuv/scaler_unittest.cc index f186d82d89..a3fbc48290 100644 --- a/webrtc/common_video/libyuv/scaler_unittest.cc +++ b/webrtc/common_video/libyuv/scaler_unittest.cc @@ -44,7 +44,7 @@ class TestScaler : public ::testing::Test { const int half_height_; const int size_y_; const int size_uv_; - const int frame_length_; + const size_t frame_length_; }; TestScaler::TestScaler() @@ -392,7 +392,7 @@ double TestScaler::ComputeAvgSequencePSNR(FILE* input_file, rewind(input_file); rewind(output_file); - int required_size = CalcBufferSize(kI420, width, height); + size_t required_size = CalcBufferSize(kI420, width, height); uint8_t* input_buffer = new uint8_t[required_size]; uint8_t* output_buffer = new uint8_t[required_size]; @@ -400,12 +400,10 @@ double TestScaler::ComputeAvgSequencePSNR(FILE* input_file, double avg_psnr = 0; I420VideoFrame in_frame, out_frame; while (feof(input_file) == 0) { - if ((size_t)required_size != - fread(input_buffer, 1, required_size, input_file)) { + if (fread(input_buffer, 1, required_size, input_file) != required_size) { break; } - if ((size_t)required_size != - fread(output_buffer, 1, required_size, output_file)) { + if (fread(output_buffer, 1, required_size, output_file) != required_size) { break; } frame_count++; @@ -441,15 +439,15 @@ void TestScaler::ScaleSequence(ScaleMethod method, int64_t start_clock, total_clock; total_clock = 0; int frame_count = 0; - int src_required_size = CalcBufferSize(kI420, src_width, src_height); + size_t src_required_size = CalcBufferSize(kI420, src_width, src_height); scoped_ptr frame_buffer(new uint8_t[src_required_size]); int size_y = src_width * src_height; int size_uv = ((src_width + 1) / 2) * ((src_height + 1) / 2); // Running through entire sequence. while (feof(source_file) == 0) { - if ((size_t)src_required_size != - fread(frame_buffer.get(), 1, src_required_size, source_file)) + if (fread(frame_buffer.get(), 1, src_required_size, source_file) != + src_required_size) break; input_frame.CreateFrame(size_y, frame_buffer.get(), diff --git a/webrtc/common_video/libyuv/webrtc_libyuv.cc b/webrtc/common_video/libyuv/webrtc_libyuv.cc index 0094525b5c..2c509b2c41 100644 --- a/webrtc/common_video/libyuv/webrtc_libyuv.cc +++ b/webrtc/common_video/libyuv/webrtc_libyuv.cc @@ -66,8 +66,10 @@ void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) { *stride_uv = AlignInt((width + 1) / 2, k16ByteAlignment); } -int CalcBufferSize(VideoType type, int width, int height) { - int buffer_size = 0; +size_t CalcBufferSize(VideoType type, int width, int height) { + assert(width >= 0); + assert(height >= 0); + size_t buffer_size = 0; switch (type) { case kI420: case kNV12: @@ -95,7 +97,7 @@ int CalcBufferSize(VideoType type, int width, int height) { break; default: assert(false); - return -1; + break; } return buffer_size; } @@ -122,11 +124,12 @@ int PrintI420VideoFrame(const I420VideoFrame& frame, FILE* file) { } int ExtractBuffer(const I420VideoFrame& input_frame, - int size, uint8_t* buffer) { + size_t size, uint8_t* buffer) { assert(buffer); if (input_frame.IsZeroSize()) return -1; - int length = CalcBufferSize(kI420, input_frame.width(), input_frame.height()); + size_t length = + CalcBufferSize(kI420, input_frame.width(), input_frame.height()); if (size < length) { return -1; } @@ -147,7 +150,7 @@ int ExtractBuffer(const I420VideoFrame& input_frame, plane_ptr += input_frame.stride(static_cast(plane)); } } - return length; + return static_cast(length); } @@ -230,7 +233,7 @@ int ConvertToI420(VideoType src_video_type, const uint8_t* src_frame, int crop_x, int crop_y, int src_width, int src_height, - int sample_size, + size_t sample_size, VideoRotationMode rotation, I420VideoFrame* dst_frame) { int dst_width = dst_frame->width(); diff --git a/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h b/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h index d90a269191..b016f4017f 100644 --- a/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h +++ b/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h @@ -12,6 +12,7 @@ #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_ #define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_ +#include #include "webrtc/typedefs.h" #ifdef __cplusplus @@ -120,7 +121,7 @@ int16_t WebRtcCng_Encode(CNG_enc_inst* cng_inst, int16_t* speech, * -1 - Error */ int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID, - int16_t length); + size_t length); /**************************************************************************** * WebRtcCng_Generate(...) diff --git a/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c index 28bfaae807..614a3df343 100644 --- a/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c +++ b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c @@ -411,7 +411,7 @@ int16_t WebRtcCng_Encode(CNG_enc_inst* cng_inst, int16_t* speech, * -1 - Error */ int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID, - int16_t length) { + size_t length) { WebRtcCngDecInst_t* inst = (WebRtcCngDecInst_t*) cng_inst; int16_t refCs[WEBRTC_CNG_MAX_LPC_ORDER]; @@ -427,7 +427,7 @@ int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID, if (length > (WEBRTC_CNG_MAX_LPC_ORDER + 1)) length = WEBRTC_CNG_MAX_LPC_ORDER + 1; - inst->dec_order = length - 1; + inst->dec_order = (int16_t)length - 1; if (SID[0] > 93) SID[0] = 93; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc index 7e41328e6d..08ece69b6f 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc @@ -113,10 +113,9 @@ void AcmReceiveTest::Run() { header.header = packet->header(); header.frameType = kAudioFrameSpeech; memset(&header.type.Audio, 0, sizeof(RTPAudioHeader)); - EXPECT_TRUE( - acm_->InsertPacket(packet->payload(), - static_cast(packet->payload_length_bytes()), - header)) + EXPECT_TRUE(acm_->InsertPacket(packet->payload(), + packet->payload_length_bytes(), + header)) << "Failure when inserting packet:" << std::endl << " PT = " << static_cast(header.header.payloadType) << std::endl << " TS = " << header.header.timestamp << std::endl diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc index 074475411c..bbe5a16008 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc @@ -261,7 +261,7 @@ AudioPlayoutMode AcmReceiver::PlayoutMode() const { int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header, const uint8_t* incoming_payload, - int length_payload) { + size_t length_payload) { uint32_t receive_timestamp = 0; InitialDelayManager::PacketType packet_type = InitialDelayManager::kUndefinedPacket; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h index 6d31b9a5c8..057cb5ae9c 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h @@ -67,7 +67,7 @@ class AcmReceiver { // int InsertPacket(const WebRtcRTPHeader& rtp_header, const uint8_t* incoming_payload, - int length_payload); + size_t length_payload); // // Asks NetEq for 10 milliseconds of decoded audio. diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc index 9cfef3a8f7..ff43899a3a 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc @@ -115,12 +115,12 @@ class AcmReceiverTest : public AudioPacketizationCallback, } } - virtual int SendData( + virtual int32_t SendData( FrameType frame_type, uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) OVERRIDE { if (frame_type == kFrameEmpty) return 0; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc index ef890ecb3f..8c37c96416 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc @@ -124,7 +124,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback, uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) OVERRIDE { if (frame_type == kFrameEmpty) return 0; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc b/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc index ec3c254060..d2ecb1685a 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc @@ -94,7 +94,7 @@ int32_t AcmSendTest::SendData(FrameType frame_type, uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) { // Store the packet locally. frame_type_ = frame_type; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test.h b/webrtc/modules/audio_coding/main/acm2/acm_send_test.h index 8bc0cde072..ac20cc7bef 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_send_test.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test.h @@ -49,7 +49,7 @@ class AcmSendTest : public AudioPacketizationCallback, public PacketSource { uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) OVERRIDE; private: diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc index 2f5178e05a..42dc628047 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc @@ -98,7 +98,7 @@ int32_t AcmSendTestOldApi::SendData( uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) { // Store the packet locally. frame_type_ = frame_type; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h index ff229a0a54..e9902842f8 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h @@ -51,7 +51,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback, uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) OVERRIDE; private: diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc index bee1f663dc..458e5c8e18 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc @@ -314,7 +314,7 @@ int AudioCodingModuleImpl::EncodeFragmentation(int fragmentation_index, int AudioCodingModuleImpl::ProcessDualStream() { uint8_t stream[kMaxNumFragmentationVectors * MAX_PAYLOAD_SIZE_BYTE]; uint32_t current_timestamp; - int16_t length_bytes = 0; + size_t length_bytes = 0; RTPFragmentationHeader my_fragmentation; uint8_t my_red_payload_type; @@ -336,8 +336,7 @@ int AudioCodingModuleImpl::ProcessDualStream() { // Nothing to send. return 0; } - int len_bytes_previous_secondary = static_cast( - fragmentation_.fragmentationLength[2]); + size_t len_bytes_previous_secondary = fragmentation_.fragmentationLength[2]; assert(len_bytes_previous_secondary <= MAX_PAYLOAD_SIZE_BYTE); bool has_previous_payload = len_bytes_previous_secondary > 0; @@ -1689,13 +1688,8 @@ int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const { // Incoming packet from network parsed and ready for decode. int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload, - const int payload_length, + const size_t payload_length, const WebRtcRTPHeader& rtp_header) { - if (payload_length < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "IncomingPacket() Error, payload-length cannot be negative"); - return -1; - } int last_audio_pltype = receiver_.last_audio_payload_type(); if (receiver_.InsertPacket(rtp_header, incoming_payload, payload_length) < 0) { @@ -1797,16 +1791,9 @@ int AudioCodingModuleImpl::RegisterVADCallback(ACMVADCallback* vad_callback) { // TODO(tlegrand): Modify this function to work for stereo, and add tests. int AudioCodingModuleImpl::IncomingPayload(const uint8_t* incoming_payload, - int payload_length, + size_t payload_length, uint8_t payload_type, uint32_t timestamp) { - if (payload_length < 0) { - // Log error in trace file. - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "IncomingPacket() Error, payload-length cannot be negative"); - return -1; - } - // We are not acquiring any lock when interacting with |aux_rtp_header_| no // other method uses this member variable. if (aux_rtp_header_ == NULL) { @@ -1960,7 +1947,7 @@ int AudioCodingModuleImpl::REDPayloadISAC(int isac_rate, } void AudioCodingModuleImpl::ResetFragmentation(int vector_size) { - for (int n = 0; n < kMaxNumFragmentationVectors; n++) { + for (size_t n = 0; n < kMaxNumFragmentationVectors; n++) { fragmentation_.fragmentationOffset[n] = n * MAX_PAYLOAD_SIZE_BYTE; } memset(fragmentation_.fragmentationLength, 0, kMaxNumFragmentationVectors * @@ -2116,14 +2103,14 @@ bool AudioCodingImpl::RegisterReceiveCodec(int decoder_type, } bool AudioCodingImpl::InsertPacket(const uint8_t* incoming_payload, - int32_t payload_len_bytes, + size_t payload_len_bytes, const WebRtcRTPHeader& rtp_info) { return acm_old_->IncomingPacket( incoming_payload, payload_len_bytes, rtp_info) == 0; } bool AudioCodingImpl::InsertPayload(const uint8_t* incoming_payload, - int32_t payload_len_byte, + size_t payload_len_byte, uint8_t payload_type, uint32_t timestamp) { FATAL() << "Not implemented yet."; 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 b8d128fe54..949ce333bb 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 @@ -156,13 +156,13 @@ class AudioCodingModuleImpl : public AudioCodingModule { // Incoming packet from network parsed and ready for decode. virtual int IncomingPacket(const uint8_t* incoming_payload, - int payload_length, + const size_t payload_length, const WebRtcRTPHeader& rtp_info) OVERRIDE; // Incoming payloads, without rtp-info, the rtp-info will be created in ACM. // One usage for this API is when pre-encoded files are pushed in ACM. virtual int IncomingPayload(const uint8_t* incoming_payload, - int payload_length, + const size_t payload_length, uint8_t payload_type, uint32_t timestamp) OVERRIDE; @@ -423,11 +423,11 @@ class AudioCodingImpl : public AudioCoding { uint8_t payload_type) OVERRIDE; virtual bool InsertPacket(const uint8_t* incoming_payload, - int32_t payload_len_bytes, + size_t payload_len_bytes, const WebRtcRTPHeader& rtp_info) OVERRIDE; virtual bool InsertPayload(const uint8_t* incoming_payload, - int32_t payload_len_byte, + size_t payload_len_byte, uint8_t payload_type, uint32_t timestamp) OVERRIDE; diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc index 828b772e1e..b64c74da1b 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc @@ -42,7 +42,7 @@ const int kSampleRateHz = 16000; const int kNumSamples10ms = kSampleRateHz / 100; const int kFrameSizeMs = 10; // Multiple of 10. const int kFrameSizeSamples = kFrameSizeMs / 10 * kNumSamples10ms; -const int kPayloadSizeBytes = kFrameSizeSamples * sizeof(int16_t); +const size_t kPayloadSizeBytes = kFrameSizeSamples * sizeof(int16_t); const uint8_t kPayloadType = 111; class RtpUtility { @@ -87,7 +87,7 @@ class PacketizationCallbackStub : public AudioPacketizationCallback { uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) OVERRIDE { CriticalSectionScoped lock(crit_sect_.get()); ++num_calls_; diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc index d9ed32c1ec..e887317c3a 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc @@ -87,7 +87,7 @@ class PacketizationCallbackStub : public AudioPacketizationCallback { uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_len_bytes, + size_t payload_len_bytes, const RTPFragmentationHeader* fragmentation) OVERRIDE { CriticalSectionScoped lock(crit_sect_.get()); ++num_calls_; diff --git a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h index 8d73285a53..8dd5cdcc82 100644 --- a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h +++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h @@ -36,13 +36,12 @@ class AudioPacketizationCallback { public: virtual ~AudioPacketizationCallback() {} - virtual int32_t SendData( - FrameType frame_type, - uint8_t payload_type, - uint32_t timestamp, - const uint8_t* payload_data, - uint16_t payload_len_bytes, - const RTPFragmentationHeader* fragmentation) = 0; + virtual int32_t SendData(FrameType frame_type, + uint8_t payload_type, + uint32_t timestamp, + const uint8_t* payload_data, + size_t payload_len_bytes, + const RTPFragmentationHeader* fragmentation) = 0; }; // Callback class used for inband Dtmf detection @@ -668,8 +667,8 @@ class AudioCodingModule: public Module { // 0 if payload is successfully pushed in. // virtual int32_t IncomingPacket(const uint8_t* incoming_payload, - const int32_t payload_len_bytes, - const WebRtcRTPHeader& rtp_info) = 0; + const size_t payload_len_bytes, + const WebRtcRTPHeader& rtp_info) = 0; /////////////////////////////////////////////////////////////////////////// // int32_t IncomingPayload() @@ -696,9 +695,9 @@ class AudioCodingModule: public Module { // 0 if payload is successfully pushed in. // virtual int32_t IncomingPayload(const uint8_t* incoming_payload, - const int32_t payload_len_byte, - const uint8_t payload_type, - const uint32_t timestamp = 0) = 0; + const size_t payload_len_byte, + const uint8_t payload_type, + const uint32_t timestamp = 0) = 0; /////////////////////////////////////////////////////////////////////////// // int SetMinimumPlayoutDelay() @@ -1090,12 +1089,12 @@ class AudioCoding { // |incoming_payload| contains the RTP payload after the RTP header. Return // true if successful, false if not. virtual bool InsertPacket(const uint8_t* incoming_payload, - int32_t payload_len_bytes, + size_t payload_len_bytes, const WebRtcRTPHeader& rtp_info) = 0; // TODO(henrik.lundin): Remove this method? virtual bool InsertPayload(const uint8_t* incoming_payload, - int32_t payload_len_byte, + size_t payload_len_byte, uint8_t payload_type, uint32_t timestamp) = 0; diff --git a/webrtc/modules/audio_coding/main/test/Channel.cc b/webrtc/modules/audio_coding/main/test/Channel.cc index 20ecf3a357..aa9e6cdf40 100644 --- a/webrtc/modules/audio_coding/main/test/Channel.cc +++ b/webrtc/modules/audio_coding/main/test/Channel.cc @@ -13,18 +13,21 @@ #include #include +#include "webrtc/base/format_macros.h" #include "webrtc/system_wrappers/interface/tick_util.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" namespace webrtc { -int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType, - const uint32_t timeStamp, const uint8_t* payloadData, - const uint16_t payloadSize, +int32_t Channel::SendData(FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, + const uint8_t* payloadData, + size_t payloadSize, const RTPFragmentationHeader* fragmentation) { WebRtcRTPHeader rtpInfo; int32_t status; - uint16_t payloadDataSize = payloadSize; + size_t payloadDataSize = payloadSize; rtpInfo.header.markerBit = false; rtpInfo.header.ssrc = 0; @@ -52,8 +55,8 @@ int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType, (fragmentation->fragmentationVectorSize == 2)) { // only 0x80 if we have multiple blocks _payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1]; - uint32_t REDheader = (((uint32_t) fragmentation->fragmentationTimeDiff[1]) - << 10) + fragmentation->fragmentationLength[1]; + size_t REDheader = (fragmentation->fragmentationTimeDiff[1] << 10) + + fragmentation->fragmentationLength[1]; _payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF); _payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF); _payloadData[3] = uint8_t(REDheader & 0x000000FF); @@ -72,7 +75,7 @@ int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType, // single block (newest one) memcpy(_payloadData, payloadData + fragmentation->fragmentationOffset[0], fragmentation->fragmentationLength[0]); - payloadDataSize = uint16_t(fragmentation->fragmentationLength[0]); + payloadDataSize = fragmentation->fragmentationLength[0]; rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0]; } } else { @@ -121,7 +124,7 @@ int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType, } // TODO(turajs): rewite this method. -void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize) { +void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) { int n; if ((rtpInfo.header.payloadType != _lastPayloadType) && (_lastPayloadType != -1)) { @@ -371,7 +374,7 @@ void Channel::PrintStats(CodecInst& codecInst) { payloadStats.frameSizeStats[k].frameSizeSample); printf("Average Rate.................. %.0f bits/sec\n", payloadStats.frameSizeStats[k].rateBitPerSec); - printf("Maximum Payload-Size.......... %d Bytes\n", + printf("Maximum Payload-Size.......... %" PRIuS " Bytes\n", payloadStats.frameSizeStats[k].maxPayloadLen); printf( "Maximum Instantaneous Rate.... %.0f bits/sec\n", diff --git a/webrtc/modules/audio_coding/main/test/Channel.h b/webrtc/modules/audio_coding/main/test/Channel.h index cdb99c03e2..4ab32b9d32 100644 --- a/webrtc/modules/audio_coding/main/test/Channel.h +++ b/webrtc/modules/audio_coding/main/test/Channel.h @@ -27,7 +27,7 @@ class CriticalSectionWrapper; // TODO(turajs): Write constructor for this structure. struct ACMTestFrameSizeStats { uint16_t frameSizeSample; - int16_t maxPayloadLen; + size_t maxPayloadLen; uint32_t numPackets; uint64_t totalPayloadLenByte; uint64_t totalEncodedSamples; @@ -39,7 +39,7 @@ struct ACMTestFrameSizeStats { struct ACMTestPayloadStats { bool newPacket; int16_t payloadType; - int16_t lastPayloadLenByte; + size_t lastPayloadLenByte; uint32_t lastTimestamp; ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES]; }; @@ -51,9 +51,11 @@ class Channel : public AudioPacketizationCallback { ~Channel(); virtual int32_t SendData( - const FrameType frameType, const uint8_t payloadType, - const uint32_t timeStamp, const uint8_t* payloadData, - const uint16_t payloadSize, + FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, + const uint8_t* payloadData, + size_t payloadSize, const RTPFragmentationHeader* fragmentation) OVERRIDE; void RegisterReceiverACM(AudioCodingModule *acm); @@ -93,7 +95,7 @@ class Channel : public AudioPacketizationCallback { } private: - void CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize); + void CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize); AudioCodingModule* _receiverACM; uint16_t _seqNo; diff --git a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc index 66fd220ba5..27f5500c69 100644 --- a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc +++ b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc @@ -37,7 +37,7 @@ TestPacketization::~TestPacketization() { int32_t TestPacketization::SendData( const FrameType /* frameType */, const uint8_t payloadType, const uint32_t timeStamp, const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* /* fragmentation */) { _rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize, _frequency); diff --git a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h index f6b55538fe..4ee4fa2757 100644 --- a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h +++ b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h @@ -30,9 +30,11 @@ class TestPacketization : public AudioPacketizationCallback { TestPacketization(RTPStream *rtpStream, uint16_t frequency); ~TestPacketization(); virtual int32_t SendData( - const FrameType frameType, const uint8_t payloadType, - const uint32_t timeStamp, const uint8_t* payloadData, - const uint16_t payloadSize, + const FrameType frameType, + const uint8_t payloadType, + const uint32_t timeStamp, + const uint8_t* payloadData, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation) OVERRIDE; private: @@ -92,8 +94,8 @@ class Receiver { uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD]; RTPStream* _rtpStream; WebRtcRTPHeader _rtpInfo; - uint16_t _realPayloadSizeBytes; - uint16_t _payloadSizeBytes; + size_t _realPayloadSizeBytes; + size_t _payloadSizeBytes; uint32_t _nextTime; }; diff --git a/webrtc/modules/audio_coding/main/test/RTPFile.cc b/webrtc/modules/audio_coding/main/test/RTPFile.cc index b7f587b862..6f0c74ef45 100644 --- a/webrtc/modules/audio_coding/main/test/RTPFile.cc +++ b/webrtc/modules/audio_coding/main/test/RTPFile.cc @@ -11,6 +11,7 @@ #include "RTPFile.h" #include +#include #ifdef WIN32 # include @@ -60,7 +61,7 @@ void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, } RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo, - const uint8_t* payloadData, uint16_t payloadSize, + const uint8_t* payloadData, size_t payloadSize, uint32_t frequency) : payloadType(payloadType), timeStamp(timeStamp), @@ -87,7 +88,7 @@ RTPBuffer::~RTPBuffer() { void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp, const int16_t seqNo, const uint8_t* payloadData, - const uint16_t payloadSize, uint32_t frequency) { + const size_t payloadSize, uint32_t frequency) { RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData, payloadSize, frequency); _queueRWLock->AcquireLockExclusive(); @@ -95,8 +96,8 @@ void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp, _queueRWLock->ReleaseLockExclusive(); } -uint16_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - uint16_t payloadSize, uint32_t* offset) { +size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, + size_t payloadSize, uint32_t* offset) { _queueRWLock->AcquireLockShared(); RTPPacket *packet = _rtpQueue.front(); _rtpQueue.pop(); @@ -143,21 +144,11 @@ void RTPFile::WriteHeader() { fprintf(_rtpFile, "#!RTPencode%s\n", "1.0"); uint32_t dummy_variable = 0; // should be converted to network endian format, but does not matter when 0 - if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) { - return; - } - if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) { - return; - } - if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) { - return; - } - if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) { - return; - } - if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) { - return; - } + EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile)); + EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile)); + EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile)); + EXPECT_EQ(1u, fwrite(&dummy_variable, 2, 1, _rtpFile)); + EXPECT_EQ(1u, fwrite(&dummy_variable, 2, 1, _rtpFile)); fflush(_rtpFile); } @@ -180,35 +171,26 @@ void RTPFile::ReadHeader() { void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp, const int16_t seqNo, const uint8_t* payloadData, - const uint16_t payloadSize, uint32_t frequency) { + const size_t payloadSize, uint32_t frequency) { /* write RTP packet to file */ uint8_t rtpHeader[12]; MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0); - uint16_t lengthBytes = htons(12 + payloadSize + 8); - uint16_t plen = htons(12 + payloadSize); + ASSERT_LE(12 + payloadSize + 8, std::numeric_limits::max()); + uint16_t lengthBytes = htons(static_cast(12 + payloadSize + 8)); + uint16_t plen = htons(static_cast(12 + payloadSize)); uint32_t offsetMs; offsetMs = (timeStamp / (frequency / 1000)); offsetMs = htonl(offsetMs); - if (fwrite(&lengthBytes, 2, 1, _rtpFile) != 1) { - return; - } - if (fwrite(&plen, 2, 1, _rtpFile) != 1) { - return; - } - if (fwrite(&offsetMs, 4, 1, _rtpFile) != 1) { - return; - } - if (fwrite(rtpHeader, 12, 1, _rtpFile) != 1) { - return; - } - if (fwrite(payloadData, 1, payloadSize, _rtpFile) != payloadSize) { - return; - } + EXPECT_EQ(1u, fwrite(&lengthBytes, 2, 1, _rtpFile)); + EXPECT_EQ(1u, fwrite(&plen, 2, 1, _rtpFile)); + EXPECT_EQ(1u, fwrite(&offsetMs, 4, 1, _rtpFile)); + EXPECT_EQ(1u, fwrite(&rtpHeader, 12, 1, _rtpFile)); + EXPECT_EQ(payloadSize, fwrite(payloadData, 1, payloadSize, _rtpFile)); } -uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - uint16_t payloadSize, uint32_t* offset) { +size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, + size_t payloadSize, uint32_t* offset) { uint16_t lengthBytes; uint16_t plen; uint8_t rtpHeader[12]; @@ -237,7 +219,7 @@ uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, if (lengthBytes < 20) { return 0; } - if (payloadSize < (lengthBytes - 20)) { + if (payloadSize < static_cast((lengthBytes - 20))) { return 0; } lengthBytes -= 20; diff --git a/webrtc/modules/audio_coding/main/test/RTPFile.h b/webrtc/modules/audio_coding/main/test/RTPFile.h index 460553bebd..9a2d43a14b 100644 --- a/webrtc/modules/audio_coding/main/test/RTPFile.h +++ b/webrtc/modules/audio_coding/main/test/RTPFile.h @@ -28,12 +28,12 @@ class RTPStream { virtual void Write(const uint8_t payloadType, const uint32_t timeStamp, const int16_t seqNo, const uint8_t* payloadData, - const uint16_t payloadSize, uint32_t frequency) = 0; + const size_t payloadSize, uint32_t frequency) = 0; // Returns the packet's payload size. Zero should be treated as an // end-of-stream (in the case that EndOfFile() is true) or an error. - virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - uint16_t payloadSize, uint32_t* offset) = 0; + virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, + size_t payloadSize, uint32_t* offset) = 0; virtual bool EndOfFile() const = 0; protected: @@ -46,7 +46,7 @@ class RTPStream { class RTPPacket { public: RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo, - const uint8_t* payloadData, uint16_t payloadSize, + const uint8_t* payloadData, size_t payloadSize, uint32_t frequency); ~RTPPacket(); @@ -55,7 +55,7 @@ class RTPPacket { uint32_t timeStamp; int16_t seqNo; uint8_t* payloadData; - uint16_t payloadSize; + size_t payloadSize; uint32_t frequency; }; @@ -67,10 +67,10 @@ class RTPBuffer : public RTPStream { virtual void Write(const uint8_t payloadType, const uint32_t timeStamp, const int16_t seqNo, const uint8_t* payloadData, - const uint16_t payloadSize, uint32_t frequency) OVERRIDE; + const size_t payloadSize, uint32_t frequency) OVERRIDE; - virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - uint16_t payloadSize, uint32_t* offset) OVERRIDE; + virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, + size_t payloadSize, uint32_t* offset) OVERRIDE; virtual bool EndOfFile() const OVERRIDE; @@ -99,10 +99,10 @@ class RTPFile : public RTPStream { virtual void Write(const uint8_t payloadType, const uint32_t timeStamp, const int16_t seqNo, const uint8_t* payloadData, - const uint16_t payloadSize, uint32_t frequency) OVERRIDE; + const size_t payloadSize, uint32_t frequency) OVERRIDE; - virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, - uint16_t payloadSize, uint32_t* offset) OVERRIDE; + virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData, + size_t payloadSize, uint32_t* offset) OVERRIDE; virtual bool EndOfFile() const OVERRIDE { return _rtpEOF; diff --git a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc index 9b7667b5fc..cd5a94e113 100644 --- a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc +++ b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc @@ -10,7 +10,8 @@ #include "webrtc/modules/audio_coding/main/test/TestAllCodecs.h" -#include +#include +#include #include #include "testing/gtest/include/gtest/gtest.h" @@ -32,6 +33,10 @@ // The test loops through all available mono codecs, encode at "a" sends over // the channel, and decodes at "b". +namespace { +const size_t kVariableSize = std::numeric_limits::max(); +} + namespace webrtc { // Class for simulating packet handling. @@ -54,7 +59,7 @@ void TestPack::RegisterReceiverACM(AudioCodingModule* acm) { int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_size, + size_t payload_size, const RTPFragmentationHeader* fragmentation) { WebRtcRTPHeader rtp_info; int32_t status; @@ -87,7 +92,7 @@ int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type, return status; } -uint16_t TestPack::payload_size() { +size_t TestPack::payload_size() { return payload_size_; } @@ -459,13 +464,13 @@ void TestAllCodecs::Perform() { test_count_++; OpenOutFile(test_count_); char codec_isac[] = "ISAC"; - RegisterSendCodec('A', codec_isac, 16000, -1, 480, -1); + RegisterSendCodec('A', codec_isac, 16000, -1, 480, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_isac, 16000, -1, 960, -1); + RegisterSendCodec('A', codec_isac, 16000, -1, 960, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_isac, 16000, 15000, 480, -1); + RegisterSendCodec('A', codec_isac, 16000, 15000, 480, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_isac, 16000, 32000, 960, -1); + RegisterSendCodec('A', codec_isac, 16000, 32000, 960, kVariableSize); Run(channel_a_to_b_); outfile_b_.Close(); #endif @@ -475,13 +480,13 @@ void TestAllCodecs::Perform() { } test_count_++; OpenOutFile(test_count_); - RegisterSendCodec('A', codec_isac, 32000, -1, 960, -1); + RegisterSendCodec('A', codec_isac, 32000, -1, 960, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_isac, 32000, 56000, 960, -1); + RegisterSendCodec('A', codec_isac, 32000, 56000, 960, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_isac, 32000, 37000, 960, -1); + RegisterSendCodec('A', codec_isac, 32000, 37000, 960, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_isac, 32000, 32000, 960, -1); + RegisterSendCodec('A', codec_isac, 32000, 32000, 960, kVariableSize); Run(channel_a_to_b_); outfile_b_.Close(); #endif @@ -611,19 +616,19 @@ void TestAllCodecs::Perform() { test_count_++; OpenOutFile(test_count_); char codec_opus[] = "OPUS"; - RegisterSendCodec('A', codec_opus, 48000, 6000, 480, -1); + RegisterSendCodec('A', codec_opus, 48000, 6000, 480, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, -1); + RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, -1); + RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 48000, 480, -1); + RegisterSendCodec('A', codec_opus, 48000, 48000, 480, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, -1); + RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, -1); + RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, kVariableSize); Run(channel_a_to_b_); - RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, -1); + RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, kVariableSize); Run(channel_a_to_b_); outfile_b_.Close(); #endif @@ -686,10 +691,11 @@ void TestAllCodecs::Perform() { // packet_size - packet size in samples // extra_byte - if extra bytes needed compared to the bitrate // used when registering, can be an internal header -// set to -1 if the codec is a variable rate codec +// set to kVariableSize if the codec is a variable +// rate codec void TestAllCodecs::RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz, int rate, - int packet_size, int extra_byte) { + int packet_size, size_t extra_byte) { if (test_mode_ != 0) { // Print out codec and settings. printf("codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name, @@ -711,14 +717,14 @@ void TestAllCodecs::RegisterSendCodec(char side, char* codec_name, // Store the expected packet size in bytes, used to validate the received // packet. If variable rate codec (extra_byte == -1), set to -1. - if (extra_byte != -1) { + if (extra_byte != kVariableSize) { // Add 0.875 to always round up to a whole byte - packet_size_bytes_ = static_cast(static_cast(packet_size - * rate) / static_cast(sampling_freq_hz * 8) + 0.875) - + extra_byte; + packet_size_bytes_ = static_cast( + static_cast(packet_size * rate) / + static_cast(sampling_freq_hz * 8) + 0.875) + extra_byte; } else { // Packets will have a variable size. - packet_size_bytes_ = -1; + packet_size_bytes_ = kVariableSize; } // Set pointer to the ACM where to register the codec. @@ -751,7 +757,7 @@ void TestAllCodecs::Run(TestPack* channel) { AudioFrame audio_frame; int32_t out_freq_hz = outfile_b_.SamplingFrequency(); - uint16_t receive_size; + size_t receive_size; uint32_t timestamp_diff; channel->reset_payload_size(); int error_count = 0; @@ -768,8 +774,8 @@ void TestAllCodecs::Run(TestPack* channel) { // Verify that the received packet size matches the settings. receive_size = channel->payload_size(); if (receive_size) { - if ((static_cast(receive_size) != packet_size_bytes_) && - (packet_size_bytes_ > -1)) { + if ((receive_size != packet_size_bytes_) && + (packet_size_bytes_ != kVariableSize)) { error_count++; } diff --git a/webrtc/modules/audio_coding/main/test/TestAllCodecs.h b/webrtc/modules/audio_coding/main/test/TestAllCodecs.h index 2fbf9ef0f3..42d65a1467 100644 --- a/webrtc/modules/audio_coding/main/test/TestAllCodecs.h +++ b/webrtc/modules/audio_coding/main/test/TestAllCodecs.h @@ -29,12 +29,14 @@ class TestPack : public AudioPacketizationCallback { void RegisterReceiverACM(AudioCodingModule* acm); virtual int32_t SendData( - FrameType frame_type, uint8_t payload_type, - uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_size, + FrameType frame_type, + uint8_t payload_type, + uint32_t timestamp, + const uint8_t* payload_data, + size_t payload_size, const RTPFragmentationHeader* fragmentation) OVERRIDE; - uint16_t payload_size(); + size_t payload_size(); uint32_t timestamp_diff(); void reset_payload_size(); @@ -45,7 +47,7 @@ class TestPack : public AudioPacketizationCallback { uint32_t timestamp_diff_; uint32_t last_in_timestamp_; uint64_t total_bytes_; - uint16_t payload_size_; + size_t payload_size_; }; class TestAllCodecs : public ACMTest { @@ -61,7 +63,7 @@ class TestAllCodecs : public ACMTest { // This is useful for codecs which support several sampling frequency. // Note! Only mono mode is tested in this test. void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz, - int rate, int packet_size, int extra_byte); + int rate, int packet_size, size_t extra_byte); void Run(TestPack* channel); void OpenOutFile(int test_number); @@ -75,7 +77,7 @@ class TestAllCodecs : public ACMTest { PCMFile outfile_b_; int test_count_; int packet_size_samples_; - int packet_size_bytes_; + size_t packet_size_bytes_; }; } // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/test/TestStereo.cc b/webrtc/modules/audio_coding/main/test/TestStereo.cc index 9c22548a6a..86a75e5b6a 100644 --- a/webrtc/modules/audio_coding/main/test/TestStereo.cc +++ b/webrtc/modules/audio_coding/main/test/TestStereo.cc @@ -48,7 +48,7 @@ int32_t TestPackStereo::SendData(const FrameType frame_type, const uint8_t payload_type, const uint32_t timestamp, const uint8_t* payload_data, - const uint16_t payload_size, + const size_t payload_size, const RTPFragmentationHeader* fragmentation) { WebRtcRTPHeader rtp_info; int32_t status = 0; @@ -114,18 +114,26 @@ TestStereo::TestStereo(int test_mode) test_cntr_(0), pack_size_samp_(0), pack_size_bytes_(0), - counter_(0), - g722_pltype_(0), - l16_8khz_pltype_(-1), - l16_16khz_pltype_(-1), - l16_32khz_pltype_(-1), - pcma_pltype_(-1), - pcmu_pltype_(-1), - celt_pltype_(-1), - opus_pltype_(-1), - cn_8khz_pltype_(-1), - cn_16khz_pltype_(-1), - cn_32khz_pltype_(-1) { + counter_(0) +#ifdef WEBRTC_CODEC_G722 + , g722_pltype_(0) +#endif +#ifdef WEBRTC_CODEC_PCM16 + , l16_8khz_pltype_(-1) + , l16_16khz_pltype_(-1) + , l16_32khz_pltype_(-1) +#endif +#ifdef PCMA_AND_PCMU + , pcma_pltype_(-1) + , pcmu_pltype_(-1) +#endif +#ifdef WEBRTC_CODEC_CELT + , celt_pltype_(-1) +#endif +#ifdef WEBRTC_CODEC_OPUS + , opus_pltype_(-1) +#endif + { // test_mode = 0 for silent test (auto test) test_mode_ = test_mode; } @@ -302,7 +310,6 @@ void TestStereo::Perform() { Run(channel_a2b_, audio_channels, codec_channels); out_file_.Close(); #endif -#define PCMA_AND_PCMU #ifdef PCMA_AND_PCMU if (test_mode_ != 0) { printf("===========================================================\n"); diff --git a/webrtc/modules/audio_coding/main/test/TestStereo.h b/webrtc/modules/audio_coding/main/test/TestStereo.h index 8aefa7fc40..0eb0e52752 100644 --- a/webrtc/modules/audio_coding/main/test/TestStereo.h +++ b/webrtc/modules/audio_coding/main/test/TestStereo.h @@ -18,6 +18,8 @@ #include "webrtc/modules/audio_coding/main/test/Channel.h" #include "webrtc/modules/audio_coding/main/test/PCMFile.h" +#define PCMA_AND_PCMU + namespace webrtc { enum StereoMonoMode { @@ -38,7 +40,7 @@ class TestPackStereo : public AudioPacketizationCallback { const uint8_t payload_type, const uint32_t timestamp, const uint8_t* payload_data, - const uint16_t payload_size, + const size_t payload_size, const RTPFragmentationHeader* fragmentation) OVERRIDE; uint16_t payload_size(); @@ -78,11 +80,6 @@ class TestStereo : public ACMTest { void OpenOutFile(int16_t test_number); void DisplaySendReceiveCodec(); - int32_t SendData(const FrameType frame_type, const uint8_t payload_type, - const uint32_t timestamp, const uint8_t* payload_data, - const uint16_t payload_size, - const RTPFragmentationHeader* fragmentation); - int test_mode_; scoped_ptr acm_a_; @@ -100,17 +97,24 @@ class TestStereo : public ACMTest { char* send_codec_name_; // Payload types for stereo codecs and CNG +#ifdef WEBRTC_CODEC_G722 int g722_pltype_; +#endif +#ifdef WEBRTC_CODEC_PCM16 int l16_8khz_pltype_; int l16_16khz_pltype_; int l16_32khz_pltype_; +#endif +#ifdef PCMA_AND_PCMU int pcma_pltype_; int pcmu_pltype_; +#endif +#ifdef WEBRTC_CODEC_CELT int celt_pltype_; +#endif +#ifdef WEBRTC_CODEC_OPUS int opus_pltype_; - int cn_8khz_pltype_; - int cn_16khz_pltype_; - int cn_32khz_pltype_; +#endif }; } // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc b/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc index 7cd2466f68..9b960afa82 100644 --- a/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc +++ b/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc @@ -36,9 +36,11 @@ class DualStreamTest : public AudioPacketizationCallback, void ApiTest(); virtual int32_t SendData( - FrameType frameType, uint8_t payload_type, - uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_size, + FrameType frameType, + uint8_t payload_type, + uint32_t timestamp, + const uint8_t* payload_data, + size_t payload_size, const RTPFragmentationHeader* fragmentation) OVERRIDE; void Perform(bool start_in_sync, int num_channels_input); @@ -49,9 +51,9 @@ class DualStreamTest : public AudioPacketizationCallback, void PopulateCodecInstances(int frame_size_primary_ms, int num_channels_primary, int sampling_rate); - void Validate(bool start_in_sync, int tolerance); + void Validate(bool start_in_sync, size_t tolerance); bool EqualTimestamp(int stream, int position); - int EqualPayloadLength(int stream, int position); + size_t EqualPayloadLength(int stream, int position); bool EqualPayloadData(int stream, int position); static const int kMaxNumStoredPayloads = 2; @@ -77,8 +79,8 @@ class DualStreamTest : public AudioPacketizationCallback, uint32_t timestamp_ref_[kMaxNumStreams][kMaxNumStoredPayloads]; uint32_t timestamp_dual_[kMaxNumStreams][kMaxNumStoredPayloads]; - int payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads]; - int payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads]; + size_t payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads]; + size_t payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads]; uint8_t payload_data_ref_[kMaxNumStreams][MAX_PAYLOAD_SIZE_BYTE * kMaxNumStoredPayloads]; @@ -174,7 +176,7 @@ void DualStreamTest::Perform(bool start_in_sync, int num_channels_input) { pcm_file.ReadStereo(num_channels_input == 2); AudioFrame audio_frame; - int tolerance = 0; + size_t tolerance = 0; if (num_channels_input == 2 && primary_encoder_.channels == 2 && secondary_encoder_.channels == 1) { tolerance = 12; @@ -253,10 +255,10 @@ bool DualStreamTest::EqualTimestamp(int stream_index, int position) { return true; } -int DualStreamTest::EqualPayloadLength(int stream_index, int position) { - return abs( - payload_len_dual_[stream_index][position] - - payload_len_ref_[stream_index][position]); +size_t DualStreamTest::EqualPayloadLength(int stream_index, int position) { + size_t dual = payload_len_dual_[stream_index][position]; + size_t ref = payload_len_ref_[stream_index][position]; + return (dual > ref) ? (dual - ref) : (ref - dual); } bool DualStreamTest::EqualPayloadData(int stream_index, int position) { @@ -264,7 +266,7 @@ bool DualStreamTest::EqualPayloadData(int stream_index, int position) { payload_len_dual_[stream_index][position] == payload_len_ref_[stream_index][position]); int offset = position * MAX_PAYLOAD_SIZE_BYTE; - for (int n = 0; n < payload_len_dual_[stream_index][position]; n++) { + for (size_t n = 0; n < payload_len_dual_[stream_index][position]; n++) { if (payload_data_dual_[stream_index][offset + n] != payload_data_ref_[stream_index][offset + n]) { return false; @@ -273,9 +275,9 @@ bool DualStreamTest::EqualPayloadData(int stream_index, int position) { return true; } -void DualStreamTest::Validate(bool start_in_sync, int tolerance) { +void DualStreamTest::Validate(bool start_in_sync, size_t tolerance) { for (int stream_index = 0; stream_index < kMaxNumStreams; stream_index++) { - int my_tolerance = stream_index == kPrimary ? 0 : tolerance; + size_t my_tolerance = stream_index == kPrimary ? 0 : tolerance; for (int position = 0; position < kMaxNumStoredPayloads; position++) { if (payload_ref_is_stored_[stream_index][position] == 1 && payload_dual_is_stored_[stream_index][position] == 1) { @@ -296,7 +298,7 @@ void DualStreamTest::Validate(bool start_in_sync, int tolerance) { int32_t DualStreamTest::SendData(FrameType frameType, uint8_t payload_type, uint32_t timestamp, const uint8_t* payload_data, - uint16_t payload_size, + size_t payload_size, const RTPFragmentationHeader* fragmentation) { int position; int stream_index; diff --git a/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc b/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc index 02b8467b86..a90249907d 100644 --- a/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc +++ b/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc @@ -46,7 +46,7 @@ class TargetDelayTest : public ::testing::Test { int16_t audio[kFrameSizeSamples]; const int kRange = 0x7FF; // 2047, easy for masking. - for (int n = 0; n < kFrameSizeSamples; ++n) + for (size_t n = 0; n < kFrameSizeSamples; ++n) audio[n] = (rand() & kRange) - kRange / 2; WebRtcPcm16b_Encode(audio, kFrameSizeSamples, payload_); } @@ -133,7 +133,7 @@ class TargetDelayTest : public ::testing::Test { private: static const int kSampleRateHz = 16000; static const int kNum10msPerFrame = 2; - static const int kFrameSizeSamples = 320; // 20 ms @ 16 kHz. + static const size_t kFrameSizeSamples = 320; // 20 ms @ 16 kHz. // payload-len = frame-samples * 2 bytes/sample. static const int kPayloadLenBytes = 320 * 2; // Inter-arrival time in number of packets in a jittery channel. One is no diff --git a/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc b/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc index 91debee14e..b07d561993 100644 --- a/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc +++ b/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc @@ -55,7 +55,7 @@ namespace webrtc { // int DtmfBuffer::ParseEvent(uint32_t rtp_timestamp, const uint8_t* payload, - int payload_length_bytes, + size_t payload_length_bytes, DtmfEvent* event) { if (!payload || !event) { return kInvalidPointer; diff --git a/webrtc/modules/audio_coding/neteq/dtmf_buffer.h b/webrtc/modules/audio_coding/neteq/dtmf_buffer.h index 5dd31c2d2e..5da3a16a2d 100644 --- a/webrtc/modules/audio_coding/neteq/dtmf_buffer.h +++ b/webrtc/modules/audio_coding/neteq/dtmf_buffer.h @@ -69,7 +69,7 @@ class DtmfBuffer { // |rtp_timestamp| is simply copied into the struct. static int ParseEvent(uint32_t rtp_timestamp, const uint8_t* payload, - int payload_length_bytes, + size_t payload_length_bytes, DtmfEvent* event); // Inserts |event| into the buffer. The method looks for a matching event and diff --git a/webrtc/modules/audio_coding/neteq/interface/neteq.h b/webrtc/modules/audio_coding/neteq/interface/neteq.h index 560e77ba8a..b630e867aa 100644 --- a/webrtc/modules/audio_coding/neteq/interface/neteq.h +++ b/webrtc/modules/audio_coding/neteq/interface/neteq.h @@ -132,7 +132,7 @@ class NetEq { // Returns 0 on success, -1 on failure. virtual int InsertPacket(const WebRtcRTPHeader& rtp_header, const uint8_t* payload, - int length_bytes, + size_t length_bytes, uint32_t receive_timestamp) = 0; // Inserts a sync-packet into packet queue. Sync-packets are decoded to diff --git a/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h b/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h index 09fa4e1235..9fa05e9cce 100644 --- a/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h +++ b/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h @@ -28,11 +28,11 @@ class MockPayloadSplitter : public PayloadSplitter { MOCK_METHOD2(SplitAudio, int(PacketList* packet_list, const DecoderDatabase& decoder_database)); MOCK_METHOD4(SplitBySamples, - void(const Packet* packet, int bytes_per_ms, int timestamps_per_ms, - PacketList* new_packets)); + void(const Packet* packet, size_t bytes_per_ms, + uint32_t timestamps_per_ms, PacketList* new_packets)); MOCK_METHOD4(SplitByFrames, - int(const Packet* packet, int bytes_per_frame, int timestamps_per_frame, - PacketList* new_packets)); + int(const Packet* packet, size_t bytes_per_frame, + uint32_t timestamps_per_frame, PacketList* new_packets)); }; } // namespace webrtc diff --git a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc index d41bc54358..ae2d1aeb20 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc @@ -203,7 +203,7 @@ class NetEqExternalDecoderTest : public ::testing::Test { int sample_rate_hz_; int samples_per_ms_; const int frame_size_ms_; - int frame_size_samples_; + size_t frame_size_samples_; int output_size_samples_; NetEq* neteq_external_; NetEq* neteq_; @@ -214,7 +214,7 @@ class NetEqExternalDecoderTest : public ::testing::Test { int16_t output_[kMaxBlockSize]; int16_t output_external_[kMaxBlockSize]; WebRtcRTPHeader rtp_header_; - int payload_size_bytes_; + size_t payload_size_bytes_; int last_send_time_; int last_arrival_time_; scoped_ptr input_file_; diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc index 7e8af3c9b7..958eb769ab 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -117,7 +117,7 @@ NetEqImpl::~NetEqImpl() { int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header, const uint8_t* payload, - int length_bytes, + size_t length_bytes, uint32_t receive_timestamp) { CriticalSectionScoped lock(crit_sect_.get()); LOG(LS_VERBOSE) << "InsertPacket: ts=" << rtp_header.header.timestamp << @@ -399,7 +399,7 @@ const SyncBuffer* NetEqImpl::sync_buffer_for_test() const { int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header, const uint8_t* payload, - int length_bytes, + size_t length_bytes, uint32_t receive_timestamp, bool is_sync_packet) { if (!payload) { @@ -1241,7 +1241,7 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list, Operations* operation, assert(*operation == kNormal || *operation == kAccelerate || *operation == kMerge || *operation == kPreemptiveExpand); packet_list->pop_front(); - int payload_length = packet->payload_length; + size_t payload_length = packet->payload_length; int16_t decode_length; if (packet->sync_packet) { // Decode to silence with the same frame size as the last decode. diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.h b/webrtc/modules/audio_coding/neteq/neteq_impl.h index 348f483c94..fa96512b3c 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.h +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.h @@ -81,7 +81,7 @@ class NetEqImpl : public webrtc::NetEq { // Returns 0 on success, -1 on failure. virtual int InsertPacket(const WebRtcRTPHeader& rtp_header, const uint8_t* payload, - int length_bytes, + size_t length_bytes, uint32_t receive_timestamp) OVERRIDE; // Inserts a sync-packet into packet queue. Sync-packets are decoded to @@ -210,7 +210,7 @@ class NetEqImpl : public webrtc::NetEq { // TODO(hlundin): Merge this with InsertPacket above? int InsertPacketInternal(const WebRtcRTPHeader& rtp_header, const uint8_t* payload, - int length_bytes, + size_t length_bytes, uint32_t receive_timestamp, bool is_sync_packet) EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc index 56ea425441..89a4d429eb 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -253,7 +253,7 @@ TEST_F(NetEqImplTest, RemovePayloadType) { TEST_F(NetEqImplTest, InsertPacket) { CreateInstance(); - const int kPayloadLength = 100; + const size_t kPayloadLength = 100; const uint8_t kPayloadType = 0; const uint16_t kFirstSequenceNumber = 0x1234; const uint32_t kFirstTimestamp = 0x12345678; diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc index 7ed9a87c68..0ee1d06634 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc @@ -192,7 +192,7 @@ class NetEqDecodingTest : public ::testing::Test { static const int kBlockSize8kHz = kTimeStepMs * 8; static const int kBlockSize16kHz = kTimeStepMs * 16; static const int kBlockSize32kHz = kTimeStepMs * 32; - static const int kMaxBlockSize = kBlockSize32kHz; + static const size_t kMaxBlockSize = kBlockSize32kHz; static const int kInitSampleRateHz = 8000; NetEqDecodingTest(); @@ -213,7 +213,7 @@ class NetEqDecodingTest : public ::testing::Test { int timestamp, WebRtcRTPHeader* rtp_info, uint8_t* payload, - int* payload_len); + size_t* payload_len); void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp, const std::set& drop_seq_numbers, @@ -244,7 +244,7 @@ const int NetEqDecodingTest::kTimeStepMs; const int NetEqDecodingTest::kBlockSize8kHz; const int NetEqDecodingTest::kBlockSize16kHz; const int NetEqDecodingTest::kBlockSize32kHz; -const int NetEqDecodingTest::kMaxBlockSize; +const size_t NetEqDecodingTest::kMaxBlockSize; const int NetEqDecodingTest::kInitSampleRateHz; NetEqDecodingTest::NetEqDecodingTest() @@ -396,7 +396,7 @@ void NetEqDecodingTest::PopulateCng(int frame_index, int timestamp, WebRtcRTPHeader* rtp_info, uint8_t* payload, - int* payload_len) { + size_t* payload_len) { rtp_info->header.sequenceNumber = frame_index; rtp_info->header.timestamp = timestamp; rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. @@ -448,8 +448,8 @@ class NetEqDecodingTestFaxMode : public NetEqDecodingTest { TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { // Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio. size_t num_frames = 30; - const int kSamples = 10 * 16; - const int kPayloadBytes = kSamples * 2; + const size_t kSamples = 10 * 16; + const size_t kPayloadBytes = kSamples * 2; for (size_t i = 0; i < num_frames; ++i) { uint16_t payload[kSamples] = {0}; WebRtcRTPHeader rtp_info; @@ -518,8 +518,8 @@ TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { const int kNumFrames = 3000; // Needed for convergence. int frame_index = 0; - const int kSamples = 10 * 16; - const int kPayloadBytes = kSamples * 2; + const size_t kSamples = 10 * 16; + const size_t kPayloadBytes = kSamples * 2; while (frame_index < kNumFrames) { // Insert one packet each time, except every 10th time where we insert two // packets at once. This will create a negative clock-drift of approx. 10%. @@ -549,8 +549,8 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) { const int kNumFrames = 5000; // Needed for convergence. int frame_index = 0; - const int kSamples = 10 * 16; - const int kPayloadBytes = kSamples * 2; + const size_t kSamples = 10 * 16; + const size_t kPayloadBytes = kSamples * 2; for (int i = 0; i < kNumFrames; ++i) { // Insert one packet each time, except every 10th time where we don't insert // any packet. This will create a positive clock-drift of approx. 11%. @@ -585,8 +585,8 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, uint16_t seq_no = 0; uint32_t timestamp = 0; const int kFrameSizeMs = 30; - const int kSamples = kFrameSizeMs * 16; - const int kPayloadBytes = kSamples * 2; + const size_t kSamples = kFrameSizeMs * 16; + const size_t kPayloadBytes = kSamples * 2; double next_input_time_ms = 0.0; double t_ms; int out_len; @@ -625,7 +625,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, while (next_input_time_ms <= t_ms) { // Insert one CNG frame each 100 ms. uint8_t payload[kPayloadBytes]; - int payload_len; + size_t payload_len; WebRtcRTPHeader rtp_info; PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); @@ -672,7 +672,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, } // Insert one CNG frame each 100 ms. uint8_t payload[kPayloadBytes]; - int payload_len; + size_t payload_len; WebRtcRTPHeader rtp_info; PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); @@ -797,7 +797,7 @@ TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) { } TEST_F(NetEqDecodingTest, UnknownPayloadType) { - const int kPayloadBytes = 100; + const size_t kPayloadBytes = 100; uint8_t payload[kPayloadBytes] = {0}; WebRtcRTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); @@ -808,7 +808,7 @@ TEST_F(NetEqDecodingTest, UnknownPayloadType) { } TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) { - const int kPayloadBytes = 100; + const size_t kPayloadBytes = 100; uint8_t payload[kPayloadBytes] = {0}; WebRtcRTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); @@ -817,7 +817,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) { NetEqOutputType type; // Set all of |out_data_| to 1, and verify that it was set to 0 by the call // to GetAudio. - for (int i = 0; i < kMaxBlockSize; ++i) { + for (size_t i = 0; i < kMaxBlockSize; ++i) { out_data_[i] = 1; } int num_channels; @@ -838,7 +838,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) { SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. EXPECT_EQ(0, out_data_[i]); } - for (int i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { + for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { std::ostringstream ss; ss << "i = " << i; SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. @@ -850,7 +850,7 @@ TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { NetEqOutputType type; // Set all of |out_data_| to 1, and verify that it was set to 0 by the call // to GetAudio. - for (int i = 0; i < kMaxBlockSize; ++i) { + for (size_t i = 0; i < kMaxBlockSize; ++i) { out_data_[i] = 1; } int num_channels; @@ -875,7 +875,7 @@ class NetEqBgnTest : public NetEqDecodingTest { bool should_be_faded) = 0; void CheckBgn(int sampling_rate_hz) { - int expected_samples_per_channel = 0; + int16_t expected_samples_per_channel = 0; uint8_t payload_type = 0xFF; // Invalid. if (sampling_rate_hz == 8000) { expected_samples_per_channel = kBlockSize8kHz; @@ -899,7 +899,7 @@ class NetEqBgnTest : public NetEqDecodingTest { ASSERT_TRUE(input.Init( webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 10 * sampling_rate_hz, // Max 10 seconds loop length. - expected_samples_per_channel)); + static_cast(expected_samples_per_channel))); // Payload of 10 ms of PCM16 32 kHz. uint8_t payload[kBlockSize32kHz * sizeof(int16_t)]; @@ -912,7 +912,7 @@ class NetEqBgnTest : public NetEqDecodingTest { uint32_t receive_timestamp = 0; for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. - int enc_len_bytes = + int16_t enc_len_bytes = WebRtcPcm16b_EncodeW16(input.GetNextBlock(), expected_samples_per_channel, reinterpret_cast(payload)); @@ -921,8 +921,9 @@ class NetEqBgnTest : public NetEqDecodingTest { number_channels = 0; samples_per_channel = 0; ASSERT_EQ(0, - neteq_->InsertPacket( - rtp_info, payload, enc_len_bytes, receive_timestamp)); + neteq_->InsertPacket(rtp_info, payload, + static_cast(enc_len_bytes), + receive_timestamp)); ASSERT_EQ(0, neteq_->GetAudio(kBlockSize32kHz, output, @@ -1074,7 +1075,7 @@ TEST_F(NetEqDecodingTest, SyncPacketInsert) { EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); // Payload length of 10 ms PCM16 16 kHz. - const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); + const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); uint8_t payload[kPayloadBytes] = {0}; ASSERT_EQ(0, neteq_->InsertPacket( rtp_info, payload, kPayloadBytes, receive_timestamp)); @@ -1125,11 +1126,11 @@ TEST_F(NetEqDecodingTest, SyncPacketInsert) { TEST_F(NetEqDecodingTest, SyncPacketDecode) { WebRtcRTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); - const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); + const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); uint8_t payload[kPayloadBytes]; int16_t decoded[kBlockSize16kHz]; int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1; - for (int n = 0; n < kPayloadBytes; ++n) { + for (size_t n = 0; n < kPayloadBytes; ++n) { payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. } // Insert some packets which decode to noise. We are not interested in @@ -1204,10 +1205,10 @@ TEST_F(NetEqDecodingTest, SyncPacketDecode) { TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) { WebRtcRTPHeader rtp_info; PopulateRtpInfo(0, 0, &rtp_info); - const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); + const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); uint8_t payload[kPayloadBytes]; int16_t decoded[kBlockSize16kHz]; - for (int n = 0; n < kPayloadBytes; ++n) { + for (size_t n = 0; n < kPayloadBytes; ++n) { payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. } // Insert some packets which decode to noise. We are not interested in @@ -1279,7 +1280,7 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no, const int kBlocksPerFrame = 3; // Number of 10 ms blocks per frame. const int kFrameSizeMs = kBlocksPerFrame * kTimeStepMs; const int kSamples = kBlockSize16kHz * kBlocksPerFrame; - const int kPayloadBytes = kSamples * sizeof(int16_t); + const size_t kPayloadBytes = kSamples * sizeof(int16_t); double next_input_time_ms = 0.0; int16_t decoded[kBlockSize16kHz]; int num_channels; @@ -1380,7 +1381,7 @@ void NetEqDecodingTest::DuplicateCng() { const int kFrameSizeMs = 10; const int kSampleRateKhz = 16; const int kSamples = kFrameSizeMs * kSampleRateKhz; - const int kPayloadBytes = kSamples * 2; + const size_t kPayloadBytes = kSamples * 2; const int algorithmic_delay_samples = std::max( algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); @@ -1409,7 +1410,7 @@ void NetEqDecodingTest::DuplicateCng() { // Insert same CNG packet twice. const int kCngPeriodMs = 100; const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; - int payload_len; + size_t payload_len; PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); // This is the first time this CNG packet is inserted. ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); diff --git a/webrtc/modules/audio_coding/neteq/packet.h b/webrtc/modules/audio_coding/neteq/packet.h index 89ddda782c..723ed8b0a3 100644 --- a/webrtc/modules/audio_coding/neteq/packet.h +++ b/webrtc/modules/audio_coding/neteq/packet.h @@ -22,7 +22,7 @@ namespace webrtc { struct Packet { RTPHeader header; uint8_t* payload; // Datagram excluding RTP header and header extension. - int payload_length; + size_t payload_length; bool primary; // Primary, i.e., not redundant payload. int waiting_time; bool sync_packet; diff --git a/webrtc/modules/audio_coding/neteq/payload_splitter.cc b/webrtc/modules/audio_coding/neteq/payload_splitter.cc index 1d61ef0cf4..118556b172 100644 --- a/webrtc/modules/audio_coding/neteq/payload_splitter.cc +++ b/webrtc/modules/audio_coding/neteq/payload_splitter.cc @@ -46,7 +46,7 @@ int PayloadSplitter::SplitRed(PacketList* packet_list) { // +-+-+-+-+-+-+-+-+ bool last_block = false; - int sum_length = 0; + size_t sum_length = 0; while (!last_block) { Packet* new_packet = new Packet; new_packet->header = red_packet->header; @@ -82,7 +82,7 @@ int PayloadSplitter::SplitRed(PacketList* packet_list) { // |payload_ptr| now points at the first payload byte. PacketList::iterator new_it; for (new_it = new_packets.begin(); new_it != new_packets.end(); ++new_it) { - int payload_length = (*new_it)->payload_length; + size_t payload_length = (*new_it)->payload_length; if (payload_ptr + payload_length > red_packet->payload + red_packet->payload_length) { // The block lengths in the RED headers do not match the overall packet @@ -291,11 +291,12 @@ int PayloadSplitter::SplitAudio(PacketList* packet_list, break; } case kDecoderILBC: { - int bytes_per_frame; + size_t bytes_per_frame; int timestamps_per_frame; if (packet->payload_length >= 950) { return kTooLargePayload; - } else if (packet->payload_length % 38 == 0) { + } + if (packet->payload_length % 38 == 0) { // 20 ms frames. bytes_per_frame = 38; timestamps_per_frame = 160; @@ -345,28 +346,28 @@ int PayloadSplitter::SplitAudio(PacketList* packet_list, } void PayloadSplitter::SplitBySamples(const Packet* packet, - int bytes_per_ms, - int timestamps_per_ms, + size_t bytes_per_ms, + uint32_t timestamps_per_ms, PacketList* new_packets) { assert(packet); assert(new_packets); - int split_size_bytes = packet->payload_length; + size_t split_size_bytes = packet->payload_length; // Find a "chunk size" >= 20 ms and < 40 ms. - int min_chunk_size = bytes_per_ms * 20; + size_t min_chunk_size = bytes_per_ms * 20; // Reduce the split size by half as long as |split_size_bytes| is at least // twice the minimum chunk size (so that the resulting size is at least as // large as the minimum chunk size). while (split_size_bytes >= 2 * min_chunk_size) { split_size_bytes >>= 1; } - int timestamps_per_chunk = - split_size_bytes * timestamps_per_ms / bytes_per_ms; + uint32_t timestamps_per_chunk = static_cast( + split_size_bytes * timestamps_per_ms / bytes_per_ms); uint32_t timestamp = packet->header.timestamp; uint8_t* payload_ptr = packet->payload; - int len = packet->payload_length; + size_t len = packet->payload_length; while (len >= (2 * split_size_bytes)) { Packet* new_packet = new Packet; new_packet->payload_length = split_size_bytes; @@ -394,22 +395,21 @@ void PayloadSplitter::SplitBySamples(const Packet* packet, } int PayloadSplitter::SplitByFrames(const Packet* packet, - int bytes_per_frame, - int timestamps_per_frame, + size_t bytes_per_frame, + uint32_t timestamps_per_frame, PacketList* new_packets) { if (packet->payload_length % bytes_per_frame != 0) { return kFrameSplitError; } - int num_frames = packet->payload_length / bytes_per_frame; - if (num_frames == 1) { + if (packet->payload_length == bytes_per_frame) { // Special case. Do not split the payload. return kNoSplit; } uint32_t timestamp = packet->header.timestamp; uint8_t* payload_ptr = packet->payload; - int len = packet->payload_length; + size_t len = packet->payload_length; while (len > 0) { assert(len >= bytes_per_frame); Packet* new_packet = new Packet; diff --git a/webrtc/modules/audio_coding/neteq/payload_splitter.h b/webrtc/modules/audio_coding/neteq/payload_splitter.h index a3dd77e5a5..6023d4e007 100644 --- a/webrtc/modules/audio_coding/neteq/payload_splitter.h +++ b/webrtc/modules/audio_coding/neteq/payload_splitter.h @@ -71,16 +71,16 @@ class PayloadSplitter { // Splits the payload in |packet|. The payload is assumed to be from a // sample-based codec. virtual void SplitBySamples(const Packet* packet, - int bytes_per_ms, - int timestamps_per_ms, + size_t bytes_per_ms, + uint32_t timestamps_per_ms, PacketList* new_packets); // Splits the payload in |packet|. The payload will be split into chunks of // size |bytes_per_frame|, corresponding to a |timestamps_per_frame| // RTP timestamps. virtual int SplitByFrames(const Packet* packet, - int bytes_per_frame, - int timestamps_per_frame, + size_t bytes_per_frame, + uint32_t timestamps_per_frame, PacketList* new_packets); DISALLOW_COPY_AND_ASSIGN(PayloadSplitter); diff --git a/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc b/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc index cf29581ab7..d397a076bc 100644 --- a/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc @@ -27,8 +27,8 @@ using ::testing::ReturnNull; namespace webrtc { static const int kRedPayloadType = 100; -static const int kPayloadLength = 10; -static const int kRedHeaderLength = 4; // 4 bytes RED header. +static const size_t kPayloadLength = 10; +static const size_t kRedHeaderLength = 4; // 4 bytes RED header. static const uint16_t kSequenceNumber = 0; static const uint32_t kBaseTimestamp = 0x12345678; @@ -50,7 +50,7 @@ static const uint32_t kBaseTimestamp = 0x12345678; // by the values in array |payload_types| (which must be of length // |num_payloads|). Each redundant payload is |timestamp_offset| samples // "behind" the the previous payload. -Packet* CreateRedPayload(int num_payloads, +Packet* CreateRedPayload(size_t num_payloads, uint8_t* payload_types, int timestamp_offset) { Packet* packet = new Packet; @@ -61,7 +61,7 @@ Packet* CreateRedPayload(int num_payloads, (num_payloads - 1) * (kPayloadLength + kRedHeaderLength); uint8_t* payload = new uint8_t[packet->payload_length]; uint8_t* payload_ptr = payload; - for (int i = 0; i < num_payloads; ++i) { + for (size_t i = 0; i < num_payloads; ++i) { // Write the RED headers. if (i == num_payloads - 1) { // Special case for last payload. @@ -82,9 +82,9 @@ Packet* CreateRedPayload(int num_payloads, *payload_ptr = kPayloadLength & 0xFF; ++payload_ptr; } - for (int i = 0; i < num_payloads; ++i) { + for (size_t i = 0; i < num_payloads; ++i) { // Write |i| to all bytes in each payload. - memset(payload_ptr, i, kPayloadLength); + memset(payload_ptr, static_cast(i), kPayloadLength); payload_ptr += kPayloadLength; } packet->payload = payload; @@ -104,7 +104,7 @@ Packet* CreateRedPayload(int num_payloads, // : | // | | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -Packet* CreateOpusFecPacket(uint8_t payload_type, int payload_length, +Packet* CreateOpusFecPacket(uint8_t payload_type, size_t payload_length, uint8_t payload_value) { Packet* packet = new Packet; packet->header.payloadType = payload_type; @@ -120,7 +120,7 @@ Packet* CreateOpusFecPacket(uint8_t payload_type, int payload_length, } // Create a packet with all payload bytes set to |payload_value|. -Packet* CreatePacket(uint8_t payload_type, int payload_length, +Packet* CreatePacket(uint8_t payload_type, size_t payload_length, uint8_t payload_value) { Packet* packet = new Packet; packet->header.payloadType = payload_type; @@ -135,7 +135,7 @@ Packet* CreatePacket(uint8_t payload_type, int payload_length, // Checks that |packet| has the attributes given in the remaining parameters. void VerifyPacket(const Packet* packet, - int payload_length, + size_t payload_length, uint8_t payload_type, uint16_t sequence_number, uint32_t timestamp, @@ -147,7 +147,7 @@ void VerifyPacket(const Packet* packet, EXPECT_EQ(timestamp, packet->header.timestamp); EXPECT_EQ(primary, packet->primary); ASSERT_FALSE(packet->payload == NULL); - for (int i = 0; i < packet->payload_length; ++i) { + for (size_t i = 0; i < packet->payload_length; ++i) { EXPECT_EQ(payload_value, packet->payload[i]); } } @@ -295,7 +295,7 @@ TEST(RedPayloadSplitter, TwoPacketsThreePayloads) { // found in the list (which is PCMu). TEST(RedPayloadSplitter, CheckRedPayloads) { PacketList packet_list; - for (int i = 0; i <= 3; ++i) { + for (uint8_t i = 0; i <= 3; ++i) { // Create packet with payload type |i|, payload length 10 bytes, all 0. Packet* packet = CreatePacket(i, 10, 0); packet_list.push_back(packet); @@ -357,7 +357,7 @@ TEST(AudioPayloadSplitter, NonSplittable) { // Set up packets with different RTP payload types. The actual values do not // matter, since we are mocking the decoder database anyway. PacketList packet_list; - for (int i = 0; i < 6; ++i) { + for (uint8_t i = 0; i < 6; ++i) { // Let the payload type be |i|, and the payload value 10 * |i|. packet_list.push_back(CreatePacket(i, kPayloadLength, 10 * i)); } @@ -415,7 +415,7 @@ TEST(AudioPayloadSplitter, NonSplittable) { TEST(AudioPayloadSplitter, UnknownPayloadType) { PacketList packet_list; static const uint8_t kPayloadType = 17; // Just a random number. - int kPayloadLengthBytes = 4711; // Random number. + size_t kPayloadLengthBytes = 4711; // Random number. packet_list.push_back(CreatePacket(kPayloadType, kPayloadLengthBytes, 0)); MockDecoderDatabase decoder_database; @@ -502,7 +502,7 @@ class SplitBySamplesTest : public ::testing::TestWithParam { break; } } - int bytes_per_ms_; + size_t bytes_per_ms_; int samples_per_ms_; NetEqDecoder decoder_type_; }; @@ -514,7 +514,7 @@ TEST_P(SplitBySamplesTest, PayloadSizes) { for (int payload_size_ms = 10; payload_size_ms <= 60; payload_size_ms += 10) { // The payload values are set to be the same as the payload_size, so that // one can distinguish from which packet the split payloads come from. - int payload_size_bytes = payload_size_ms * bytes_per_ms_; + size_t payload_size_bytes = payload_size_ms * bytes_per_ms_; packet_list.push_back(CreatePacket(kPayloadType, payload_size_bytes, payload_size_ms)); } @@ -548,7 +548,7 @@ TEST_P(SplitBySamplesTest, PayloadSizes) { PacketList::iterator it = packet_list.begin(); int i = 0; while (it != packet_list.end()) { - int length_bytes = expected_size_ms[i] * bytes_per_ms_; + size_t length_bytes = expected_size_ms[i] * bytes_per_ms_; uint32_t expected_timestamp = kBaseTimestamp + expected_timestamp_offset_ms[i] * samples_per_ms_; VerifyPacket((*it), length_bytes, kPayloadType, kSequenceNumber, @@ -583,7 +583,7 @@ class SplitIlbcTest : public ::testing::TestWithParam > { } size_t num_frames_; int frame_length_ms_; - int frame_length_bytes_; + size_t frame_length_bytes_; }; // Test splitting sample-based payloads. @@ -591,10 +591,10 @@ TEST_P(SplitIlbcTest, NumFrames) { PacketList packet_list; static const uint8_t kPayloadType = 17; // Just a random number. const int frame_length_samples = frame_length_ms_ * 8; - int payload_length_bytes = frame_length_bytes_ * num_frames_; + size_t payload_length_bytes = frame_length_bytes_ * num_frames_; Packet* packet = CreatePacket(kPayloadType, payload_length_bytes, 0); // Fill payload with increasing integers {0, 1, 2, ...}. - for (int i = 0; i < packet->payload_length; ++i) { + for (size_t i = 0; i < packet->payload_length; ++i) { packet->payload[i] = static_cast(i); } packet_list.push_back(packet); @@ -624,7 +624,7 @@ TEST_P(SplitIlbcTest, NumFrames) { EXPECT_EQ(kSequenceNumber, packet->header.sequenceNumber); EXPECT_EQ(true, packet->primary); ASSERT_FALSE(packet->payload == NULL); - for (int i = 0; i < packet->payload_length; ++i) { + for (size_t i = 0; i < packet->payload_length; ++i) { EXPECT_EQ(payload_value, packet->payload[i]); ++payload_value; } @@ -661,7 +661,7 @@ INSTANTIATE_TEST_CASE_P( TEST(IlbcPayloadSplitter, TooLargePayload) { PacketList packet_list; static const uint8_t kPayloadType = 17; // Just a random number. - int kPayloadLengthBytes = 950; + size_t kPayloadLengthBytes = 950; Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0); packet_list.push_back(packet); @@ -692,7 +692,7 @@ TEST(IlbcPayloadSplitter, TooLargePayload) { TEST(IlbcPayloadSplitter, UnevenPayload) { PacketList packet_list; static const uint8_t kPayloadType = 17; // Just a random number. - int kPayloadLengthBytes = 39; // Not an even number of frames. + size_t kPayloadLengthBytes = 39; // Not an even number of frames. Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0); packet_list.push_back(packet); @@ -744,7 +744,7 @@ TEST(FecPayloadSplitter, MixedPayload) { packet = packet_list.front(); EXPECT_EQ(0, packet->header.payloadType); EXPECT_EQ(kBaseTimestamp - 20 * 48, packet->header.timestamp); - EXPECT_EQ(10, packet->payload_length); + EXPECT_EQ(10U, packet->payload_length); EXPECT_FALSE(packet->primary); delete [] packet->payload; delete packet; @@ -754,7 +754,7 @@ TEST(FecPayloadSplitter, MixedPayload) { packet = packet_list.front(); EXPECT_EQ(0, packet->header.payloadType); EXPECT_EQ(kBaseTimestamp, packet->header.timestamp); - EXPECT_EQ(10, packet->payload_length); + EXPECT_EQ(10U, packet->payload_length); EXPECT_TRUE(packet->primary); delete [] packet->payload; delete packet; diff --git a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc index 7f94851ca5..d4c2191a56 100644 --- a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc +++ b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc @@ -329,7 +329,7 @@ uint8_t * NETEQTEST_RTPpacket::payload() const } } -int16_t NETEQTEST_RTPpacket::payloadLen() +size_t NETEQTEST_RTPpacket::payloadLen() { parseHeader(); return _payloadLen; @@ -752,7 +752,7 @@ void NETEQTEST_RTPpacket::splitStereoSample(NETEQTEST_RTPpacket* slaveRtp, int stride) { if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr - || _payloadLen <= 0 || slaveRtp->_memSize < _memSize) + || _payloadLen == 0 || slaveRtp->_memSize < _memSize) { return; } @@ -761,7 +761,7 @@ void NETEQTEST_RTPpacket::splitStereoSample(NETEQTEST_RTPpacket* slaveRtp, uint8_t *writeDataPtr = _payloadPtr; uint8_t *slaveData = slaveRtp->_payloadPtr; - while (readDataPtr - _payloadPtr < _payloadLen) + while (readDataPtr - _payloadPtr < static_cast(_payloadLen)) { // master data for (int ix = 0; ix < stride; ix++) { @@ -786,7 +786,7 @@ void NETEQTEST_RTPpacket::splitStereoSample(NETEQTEST_RTPpacket* slaveRtp, void NETEQTEST_RTPpacket::splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp) { if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr - || _payloadLen <= 0 || slaveRtp->_memSize < _memSize) + || _payloadLen == 0 || slaveRtp->_memSize < _memSize) { return; } @@ -799,7 +799,7 @@ void NETEQTEST_RTPpacket::splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp) void NETEQTEST_RTPpacket::splitStereoDouble(NETEQTEST_RTPpacket* slaveRtp) { if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr - || _payloadLen <= 0 || slaveRtp->_memSize < _memSize) + || _payloadLen == 0 || slaveRtp->_memSize < _memSize) { return; } @@ -868,7 +868,7 @@ void NETEQTEST_RTPpacket::scramblePayload(void) { parseHeader(); - for (int i = 0; i < _payloadLen; ++i) + for (size_t i = 0; i < _payloadLen; ++i) { _payloadPtr[i] = static_cast(rand()); } diff --git a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h index 8a31274aba..86bf3b0182 100644 --- a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h +++ b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h @@ -42,7 +42,7 @@ public: const webrtc::WebRtcRTPHeader* RTPinfo() const; uint8_t * datagram() const; uint8_t * payload() const; - int16_t payloadLen(); + size_t payloadLen(); int16_t dataLen() const; bool isParsed() const; bool isLost() const; @@ -73,7 +73,7 @@ public: uint8_t * _payloadPtr; int _memSize; int16_t _datagramLen; - int16_t _payloadLen; + size_t _payloadLen; webrtc::WebRtcRTPHeader _rtpInfo; bool _rtpParsed; uint32_t _receiveTime; diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc index 433546fbcb..ebe078425b 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc @@ -64,9 +64,9 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, const int16_t* input_samples = audio_loop.GetNextBlock(); if (!input_samples) exit(1); uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)]; - int payload_len = WebRtcPcm16b_Encode(const_cast(input_samples), - kInputBlockSizeSamples, - input_payload); + size_t payload_len = WebRtcPcm16b_Encode(const_cast(input_samples), + kInputBlockSizeSamples, + input_payload); assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t)); // Main loop. diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h index e0a43b6f48..00a24993ec 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h @@ -118,7 +118,7 @@ class NetEqQualityTest : public ::testing::Test { // Expected output number of samples per channel in a frame. const int out_size_samples_; - int payload_size_bytes_; + size_t payload_size_bytes_; int max_payload_bytes_; scoped_ptr in_file_; @@ -134,7 +134,7 @@ class NetEqQualityTest : public ::testing::Test { scoped_ptr out_data_; WebRtcRTPHeader rtp_header_; - long total_payload_size_bytes_; + size_t total_payload_size_bytes_; }; } // namespace test diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc index ef2c0b6b55..4247807b38 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc @@ -286,7 +286,7 @@ int main(int argc, char* argv[]) { int error = neteq->InsertPacket(rtp_header, payload_ptr, - static_cast(payload_len), + payload_len, packet->time_ms() * sample_rate_hz / 1000); if (error != NetEq::kOK) { if (neteq->LastError() == NetEq::kUnknownRtpPayloadType) { diff --git a/webrtc/modules/interface/module_common_types.h b/webrtc/modules/interface/module_common_types.h index 60bb7ab4ce..fea76ce449 100644 --- a/webrtc/modules/interface/module_common_types.h +++ b/webrtc/modules/interface/module_common_types.h @@ -136,10 +136,10 @@ class RTPFragmentationHeader { if (src.fragmentationVectorSize > 0) { // allocate new if (src.fragmentationOffset) { - fragmentationOffset = new uint32_t[src.fragmentationVectorSize]; + fragmentationOffset = new size_t[src.fragmentationVectorSize]; } if (src.fragmentationLength) { - fragmentationLength = new uint32_t[src.fragmentationVectorSize]; + fragmentationLength = new size_t[src.fragmentationVectorSize]; } if (src.fragmentationTimeDiff) { fragmentationTimeDiff = new uint16_t[src.fragmentationVectorSize]; @@ -156,11 +156,11 @@ class RTPFragmentationHeader { // copy values if (src.fragmentationOffset) { memcpy(fragmentationOffset, src.fragmentationOffset, - src.fragmentationVectorSize * sizeof(uint32_t)); + src.fragmentationVectorSize * sizeof(size_t)); } if (src.fragmentationLength) { memcpy(fragmentationLength, src.fragmentationLength, - src.fragmentationVectorSize * sizeof(uint32_t)); + src.fragmentationVectorSize * sizeof(size_t)); } if (src.fragmentationTimeDiff) { memcpy(fragmentationTimeDiff, src.fragmentationTimeDiff, @@ -178,23 +178,23 @@ class RTPFragmentationHeader { uint16_t oldVectorSize = fragmentationVectorSize; { // offset - uint32_t* oldOffsets = fragmentationOffset; - fragmentationOffset = new uint32_t[size]; + size_t* oldOffsets = fragmentationOffset; + fragmentationOffset = new size_t[size]; memset(fragmentationOffset + oldVectorSize, 0, - sizeof(uint32_t) * (size - oldVectorSize)); + sizeof(size_t) * (size - oldVectorSize)); // copy old values memcpy(fragmentationOffset, oldOffsets, - sizeof(uint32_t) * oldVectorSize); + sizeof(size_t) * oldVectorSize); delete[] oldOffsets; } // length { - uint32_t* oldLengths = fragmentationLength; - fragmentationLength = new uint32_t[size]; + size_t* oldLengths = fragmentationLength; + fragmentationLength = new size_t[size]; memset(fragmentationLength + oldVectorSize, 0, - sizeof(uint32_t) * (size - oldVectorSize)); + sizeof(size_t) * (size - oldVectorSize)); memcpy(fragmentationLength, oldLengths, - sizeof(uint32_t) * oldVectorSize); + sizeof(size_t) * oldVectorSize); delete[] oldLengths; } // time diff @@ -222,11 +222,12 @@ class RTPFragmentationHeader { } uint16_t fragmentationVectorSize; // Number of fragmentations - uint32_t* fragmentationOffset; // Offset of pointer to data for each fragm. - uint32_t* fragmentationLength; // Data size for each fragmentation - uint16_t* fragmentationTimeDiff; // Timestamp difference relative "now" for - // each fragmentation - uint8_t* fragmentationPlType; // Payload type of each fragmentation + size_t* fragmentationOffset; // Offset of pointer to data for each + // fragmentation + size_t* fragmentationLength; // Data size for each fragmentation + uint16_t* fragmentationTimeDiff; // Timestamp difference relative "now" for + // each fragmentation + uint8_t* fragmentationPlType; // Payload type of each fragmentation private: DISALLOW_COPY_AND_ASSIGN(RTPFragmentationHeader); @@ -348,7 +349,7 @@ class EncodedVideoData { } return *this; }; - void VerifyAndAllocate(const uint32_t size) { + void VerifyAndAllocate(const size_t size) { if (bufferSize < size) { uint8_t* oldPayload = payloadData; payloadData = new uint8_t[size]; @@ -367,8 +368,8 @@ class EncodedVideoData { bool completeFrame; bool missingFrame; uint8_t* payloadData; - uint32_t payloadSize; - uint32_t bufferSize; + size_t payloadSize; + size_t bufferSize; RTPFragmentationHeader fragmentationHeader; FrameType frameType; VideoCodecType codec; @@ -414,17 +415,17 @@ class VideoFrame { * is copied to the new buffer. * Buffer size is updated to minimumSize. */ - int32_t VerifyAndAllocate(const uint32_t minimumSize); + int32_t VerifyAndAllocate(const size_t minimumSize); /** * Update length of data buffer in frame. Function verifies that new length * is less or * equal to allocated size. */ - int32_t SetLength(const uint32_t newLength); + int32_t SetLength(const size_t newLength); /* * Swap buffer and size data */ - int32_t Swap(uint8_t*& newMemory, uint32_t& newLength, uint32_t& newSize); + int32_t Swap(uint8_t*& newMemory, size_t& newLength, size_t& newSize); /* * Swap buffer and size data */ @@ -440,7 +441,7 @@ class VideoFrame { * size length * is allocated. */ - int32_t CopyFrame(uint32_t length, const uint8_t* sourceBuffer); + int32_t CopyFrame(size_t length, const uint8_t* sourceBuffer); /** * Delete VideoFrame and resets members to zero */ @@ -459,11 +460,11 @@ class VideoFrame { /** * Get allocated buffer size */ - uint32_t Size() const { return _bufferSize; } + size_t Size() const { return _bufferSize; } /** * Get frame length */ - uint32_t Length() const { return _bufferLength; } + size_t Length() const { return _bufferLength; } /** * Get frame timestamp (90kHz) */ @@ -498,10 +499,10 @@ class VideoFrame { private: void Set(uint8_t* buffer, uint32_t size, uint32_t length, uint32_t timeStamp); - uint8_t* _buffer; // Pointer to frame buffer - uint32_t _bufferSize; // Allocated buffer size - uint32_t _bufferLength; // Length (in bytes) of buffer - uint32_t _timeStamp; // Timestamp of frame (90kHz) + uint8_t* _buffer; // Pointer to frame buffer + size_t _bufferSize; // Allocated buffer size + size_t _bufferLength; // Length (in bytes) of buffer + uint32_t _timeStamp; // Timestamp of frame (90kHz) uint32_t _width; uint32_t _height; int64_t _renderTimeMs; @@ -525,7 +526,7 @@ inline VideoFrame::~VideoFrame() { } } -inline int32_t VideoFrame::VerifyAndAllocate(const uint32_t minimumSize) { +inline int32_t VideoFrame::VerifyAndAllocate(const size_t minimumSize) { if (minimumSize < 1) { return -1; } @@ -545,7 +546,7 @@ inline int32_t VideoFrame::VerifyAndAllocate(const uint32_t minimumSize) { return 0; } -inline int32_t VideoFrame::SetLength(const uint32_t newLength) { +inline int32_t VideoFrame::SetLength(const size_t newLength) { if (newLength > _bufferSize) { // can't accomodate new value return -1; } @@ -573,21 +574,15 @@ inline int32_t VideoFrame::SwapFrame(VideoFrame& videoFrame) { videoFrame._bufferSize); } -inline int32_t VideoFrame::Swap(uint8_t*& newMemory, uint32_t& newLength, - uint32_t& newSize) { - uint8_t* tmpBuffer = _buffer; - uint32_t tmpLength = _bufferLength; - uint32_t tmpSize = _bufferSize; - _buffer = newMemory; - _bufferLength = newLength; - _bufferSize = newSize; - newMemory = tmpBuffer; - newLength = tmpLength; - newSize = tmpSize; +inline int32_t VideoFrame::Swap(uint8_t*& newMemory, size_t& newLength, + size_t& newSize) { + std::swap(_buffer, newMemory); + std::swap(_bufferLength, newLength); + std::swap(_bufferSize, newSize); return 0; } -inline int32_t VideoFrame::CopyFrame(uint32_t length, +inline int32_t VideoFrame::CopyFrame(size_t length, const uint8_t* sourceBuffer) { if (length > _bufferSize) { int32_t ret = VerifyAndAllocate(length); diff --git a/webrtc/modules/media_file/interface/media_file.h b/webrtc/modules/media_file/interface/media_file.h index 5413b4425d..3fb849f259 100644 --- a/webrtc/modules/media_file/interface/media_file.h +++ b/webrtc/modules/media_file/interface/media_file.h @@ -39,7 +39,7 @@ public: // mono). virtual int32_t PlayoutAudioData( int8_t* audioBuffer, - uint32_t& dataLengthInBytes) = 0; + size_t& dataLengthInBytes) = 0; // Put one video frame into videoBuffer. dataLengthInBytes is both an input // and output parameter. As input parameter it indicates the size of @@ -47,7 +47,7 @@ public: // to videoBuffer. virtual int32_t PlayoutAVIVideoData( int8_t* videoBuffer, - uint32_t& dataLengthInBytes) = 0; + size_t& dataLengthInBytes) = 0; // Put 10-60ms, depending on codec frame size, of audio data from file into // audioBufferLeft and audioBufferRight. The buffers contain the left and @@ -61,7 +61,7 @@ public: virtual int32_t PlayoutStereoData( int8_t* audioBufferLeft, int8_t* audioBufferRight, - uint32_t& dataLengthInBytes) = 0; + size_t& dataLengthInBytes) = 0; // Open the file specified by fileName (relative path is allowed) for // reading. FileCallback::PlayNotification(..) will be called after @@ -130,8 +130,8 @@ public: // parameter of the last sucessfull StartRecordingAudioFile(..) call. // Note: bufferLength must be exactly one frame. virtual int32_t IncomingAudioData( - const int8_t* audioBuffer, - const uint32_t bufferLength) = 0; + const int8_t* audioBuffer, + const size_t bufferLength) = 0; // Write one video frame, i.e. the bufferLength first bytes of videoBuffer, // to file. @@ -140,8 +140,8 @@ public: // StartRecordingVideoFile(..) call. The videoBuffer must contain exactly // one video frame. virtual int32_t IncomingAVIVideoData( - const int8_t* videoBuffer, - const uint32_t bufferLength) = 0; + const int8_t* videoBuffer, + const size_t bufferLength) = 0; // Open/creates file specified by fileName for writing (relative path is // allowed). FileCallback::RecordNotification(..) will be called after diff --git a/webrtc/modules/media_file/source/avi_file.cc b/webrtc/modules/media_file/source/avi_file.cc index 19baaa3b21..0d0fefdf7d 100644 --- a/webrtc/modules/media_file/source/avi_file.cc +++ b/webrtc/modules/media_file/source/avi_file.cc @@ -360,7 +360,7 @@ int32_t AviFile::GetAudioStreamInfo(WAVEFORMATEX& waveHeader) return 0; } -int32_t AviFile::WriteAudio(const uint8_t* data, int32_t length) +int32_t AviFile::WriteAudio(const uint8_t* data, size_t length) { _crit->Enter(); size_t newBytesWritten = _bytesWritten; @@ -410,7 +410,7 @@ int32_t AviFile::WriteAudio(const uint8_t* data, int32_t length) return static_cast(newBytesWritten); } -int32_t AviFile::WriteVideo(const uint8_t* data, int32_t length) +int32_t AviFile::WriteVideo(const uint8_t* data, size_t length) { _crit->Enter(); size_t newBytesWritten = _bytesWritten; @@ -482,7 +482,7 @@ int32_t AviFile::PrepareDataChunkHeaders() return 0; } -int32_t AviFile::ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1, +int32_t AviFile::ReadMoviSubChunk(uint8_t* data, size_t& length, uint32_t tag1, uint32_t tag2) { if (!_reading) @@ -563,7 +563,7 @@ int32_t AviFile::ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1, _bytesRead += size; } - if (static_cast(size) > length) + if (size > length) { WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1, "AviFile::ReadMoviSubChunk(): AVI read buffer too small!"); @@ -589,7 +589,7 @@ int32_t AviFile::ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1, return 0; } -int32_t AviFile::ReadAudio(uint8_t* data, int32_t& length) +int32_t AviFile::ReadAudio(uint8_t* data, size_t& length) { _crit->Enter(); WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1, "AviFile::ReadAudio()"); @@ -616,7 +616,7 @@ int32_t AviFile::ReadAudio(uint8_t* data, int32_t& length) return ret; } -int32_t AviFile::ReadVideo(uint8_t* data, int32_t& length) +int32_t AviFile::ReadVideo(uint8_t* data, size_t& length) { WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1, "AviFile::ReadVideo()"); diff --git a/webrtc/modules/media_file/source/avi_file.h b/webrtc/modules/media_file/source/avi_file.h index d8b10626df..1b5b746e2f 100644 --- a/webrtc/modules/media_file/source/avi_file.h +++ b/webrtc/modules/media_file/source/avi_file.h @@ -104,8 +104,8 @@ public: const WAVEFORMATEX& waveFormatHeader); int32_t Create(const char* fileName); - int32_t WriteAudio(const uint8_t* data, int32_t length); - int32_t WriteVideo(const uint8_t* data, int32_t length); + int32_t WriteAudio(const uint8_t* data, size_t length); + int32_t WriteVideo(const uint8_t* data, size_t length); int32_t GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader, BITMAPINFOHEADER& bitmapInfo, @@ -116,8 +116,8 @@ public: int32_t GetAudioStreamInfo(WAVEFORMATEX& waveHeader); - int32_t ReadAudio(uint8_t* data, int32_t& length); - int32_t ReadVideo(uint8_t* data, int32_t& length); + int32_t ReadAudio(uint8_t* data, size_t& length); + int32_t ReadVideo(uint8_t* data, size_t& length); int32_t Close(); @@ -145,7 +145,7 @@ private: int32_t PrepareDataChunkHeaders(); - int32_t ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1, + int32_t ReadMoviSubChunk(uint8_t* data, size_t& length, uint32_t tag1, uint32_t tag2 = 0); int32_t WriteRIFF(); diff --git a/webrtc/modules/media_file/source/media_file_impl.cc b/webrtc/modules/media_file/source/media_file_impl.cc index e832791aa2..06df17136f 100644 --- a/webrtc/modules/media_file/source/media_file_impl.cc +++ b/webrtc/modules/media_file/source/media_file_impl.cc @@ -10,6 +10,7 @@ #include +#include "webrtc/base/format_macros.h" #include "webrtc/modules/media_file/source/media_file_impl.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/file_wrapper.h" @@ -109,25 +110,25 @@ int32_t MediaFileImpl::Process() int32_t MediaFileImpl::PlayoutAVIVideoData( int8_t* buffer, - uint32_t& dataLengthInBytes) + size_t& dataLengthInBytes) { return PlayoutData( buffer, dataLengthInBytes, true); } int32_t MediaFileImpl::PlayoutAudioData(int8_t* buffer, - uint32_t& dataLengthInBytes) + size_t& dataLengthInBytes) { return PlayoutData( buffer, dataLengthInBytes, false); } -int32_t MediaFileImpl::PlayoutData(int8_t* buffer, uint32_t& dataLengthInBytes, +int32_t MediaFileImpl::PlayoutData(int8_t* buffer, size_t& dataLengthInBytes, bool video) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, - "MediaFileImpl::PlayoutData(buffer= 0x%x, bufLen= %ld)", + "MediaFileImpl::PlayoutData(buffer= 0x%x, bufLen= %" PRIuS ")", buffer, dataLengthInBytes); - const uint32_t bufferLengthInBytes = dataLengthInBytes; + const size_t bufferLengthInBytes = dataLengthInBytes; dataLengthInBytes = 0; if(buffer == NULL || bufferLengthInBytes == 0) @@ -185,7 +186,7 @@ int32_t MediaFileImpl::PlayoutData(int8_t* buffer, uint32_t& dataLengthInBytes, bufferLengthInBytes); if(bytesRead > 0) { - dataLengthInBytes = bytesRead; + dataLengthInBytes = static_cast(bytesRead); return 0; } break; @@ -216,7 +217,7 @@ int32_t MediaFileImpl::PlayoutData(int8_t* buffer, uint32_t& dataLengthInBytes, if( bytesRead > 0) { - dataLengthInBytes =(uint32_t) bytesRead; + dataLengthInBytes = static_cast(bytesRead); } } HandlePlayCallbacks(bytesRead); @@ -266,16 +267,16 @@ void MediaFileImpl::HandlePlayCallbacks(int32_t bytesRead) int32_t MediaFileImpl::PlayoutStereoData( int8_t* bufferLeft, int8_t* bufferRight, - uint32_t& dataLengthInBytes) + size_t& dataLengthInBytes) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, - "MediaFileImpl::PlayoutStereoData(Left = 0x%x, Right = 0x%x,\ - Len= %ld)", + "MediaFileImpl::PlayoutStereoData(Left = 0x%x, Right = 0x%x," + " Len= %" PRIuS ")", bufferLeft, bufferRight, dataLengthInBytes); - const uint32_t bufferLengthInBytes = dataLengthInBytes; + const size_t bufferLengthInBytes = dataLengthInBytes; dataLengthInBytes = 0; if(bufferLeft == NULL || bufferRight == NULL || bufferLengthInBytes == 0) @@ -328,7 +329,7 @@ int32_t MediaFileImpl::PlayoutStereoData( if(bytesRead > 0) { - dataLengthInBytes = bytesRead; + dataLengthInBytes = static_cast(bytesRead); // Check if it's time for PlayNotification(..). _playoutPositionMs = _ptrFileUtilityObj->PlayoutPositionMs(); @@ -690,25 +691,25 @@ bool MediaFileImpl::IsPlaying() int32_t MediaFileImpl::IncomingAudioData( const int8_t* buffer, - const uint32_t bufferLengthInBytes) + const size_t bufferLengthInBytes) { return IncomingAudioVideoData( buffer, bufferLengthInBytes, false); } int32_t MediaFileImpl::IncomingAVIVideoData( const int8_t* buffer, - const uint32_t bufferLengthInBytes) + const size_t bufferLengthInBytes) { return IncomingAudioVideoData( buffer, bufferLengthInBytes, true); } int32_t MediaFileImpl::IncomingAudioVideoData( const int8_t* buffer, - const uint32_t bufferLengthInBytes, + const size_t bufferLengthInBytes, const bool video) { WEBRTC_TRACE(kTraceStream, kTraceFile, _id, - "MediaFile::IncomingData(buffer= 0x%x, bufLen= %hd", + "MediaFile::IncomingData(buffer= 0x%x, bufLen= %" PRIuS, buffer, bufferLengthInBytes); if(buffer == NULL || bufferLengthInBytes == 0) @@ -803,7 +804,7 @@ int32_t MediaFileImpl::IncomingAudioVideoData( { if(_ptrOutStream->Write(buffer, bufferLengthInBytes)) { - bytesWritten = bufferLengthInBytes; + bytesWritten = static_cast(bufferLengthInBytes); } } } diff --git a/webrtc/modules/media_file/source/media_file_impl.h b/webrtc/modules/media_file/source/media_file_impl.h index eaec128b2f..fc5799df1f 100644 --- a/webrtc/modules/media_file/source/media_file_impl.h +++ b/webrtc/modules/media_file/source/media_file_impl.h @@ -32,12 +32,12 @@ public: // MediaFile functions virtual int32_t PlayoutAudioData(int8_t* audioBuffer, - uint32_t& dataLengthInBytes) OVERRIDE; + size_t& dataLengthInBytes) OVERRIDE; virtual int32_t PlayoutAVIVideoData(int8_t* videoBuffer, - uint32_t& dataLengthInBytes) OVERRIDE; + size_t& dataLengthInBytes) OVERRIDE; virtual int32_t PlayoutStereoData(int8_t* audioBufferLeft, int8_t* audioBufferRight, - uint32_t& dataLengthInBytes) OVERRIDE; + size_t& dataLengthInBytes) OVERRIDE; virtual int32_t StartPlayingAudioFile( const char* fileName, const uint32_t notificationTimeMs = 0, @@ -58,10 +58,10 @@ public: virtual int32_t StopPlaying() OVERRIDE; virtual bool IsPlaying() OVERRIDE; virtual int32_t PlayoutPositionMs(uint32_t& positionMs) const OVERRIDE; - virtual int32_t IncomingAudioData(const int8_t* audioBuffer, - const uint32_t bufferLength) OVERRIDE; - virtual int32_t IncomingAVIVideoData(const int8_t* audioBuffer, - const uint32_t bufferLength) OVERRIDE; + virtual int32_t IncomingAudioData(const int8_t* audioBuffer, + const size_t bufferLength) OVERRIDE; + virtual int32_t IncomingAVIVideoData(const int8_t* audioBuffer, + const size_t bufferLength) OVERRIDE; virtual int32_t StartRecordingAudioFile( const char* fileName, const FileFormats format, @@ -157,14 +157,14 @@ private: // audioBuffer. As output parameter it indicates the number of bytes // written to audioBuffer. If video is true the data written is a video // frame otherwise it is an audio frame. - int32_t PlayoutData(int8_t* dataBuffer, uint32_t& dataLengthInBytes, + int32_t PlayoutData(int8_t* dataBuffer, size_t& dataLengthInBytes, bool video); // Write one frame, i.e. the bufferLength first bytes of audioBuffer, // to file. The frame is an audio frame if video is true otherwise it is an // audio frame. - int32_t IncomingAudioVideoData(const int8_t* buffer, - const uint32_t bufferLength, + int32_t IncomingAudioVideoData(const int8_t* buffer, + const size_t bufferLength, const bool video); // Open/creates file specified by fileName for writing (relative path is diff --git a/webrtc/modules/media_file/source/media_file_unittest.cc b/webrtc/modules/media_file/source/media_file_unittest.cc index 56d3544c64..15c529b1a1 100644 --- a/webrtc/modules/media_file/source/media_file_unittest.cc +++ b/webrtc/modules/media_file/source/media_file_unittest.cc @@ -49,9 +49,11 @@ TEST_F(MediaFileTest, DISABLED_ON_ANDROID(StartPlayingAudioFileWithoutError)) { TEST_F(MediaFileTest, WriteWavFile) { // Write file. - static const int kHeaderSize = 44; - static const int kPayloadSize = 320; - webrtc::CodecInst codec = {0, "L16", 16000, kPayloadSize, 1}; + static const size_t kHeaderSize = 44; + static const size_t kPayloadSize = 320; + webrtc::CodecInst codec = { + 0, "L16", 16000, static_cast(kPayloadSize), 1 + }; std::string outfile = webrtc::test::OutputPath() + "wavtest.wav"; ASSERT_EQ(0, media_file_->StartRecordingAudioFile( @@ -78,8 +80,7 @@ TEST_F(MediaFileTest, WriteWavFile) { }; COMPILE_ASSERT(sizeof(kExpectedHeader) == kHeaderSize, header_size); - EXPECT_EQ(size_t(kHeaderSize + kPayloadSize), - webrtc::test::GetFileSize(outfile)); + EXPECT_EQ(kHeaderSize + kPayloadSize, webrtc::test::GetFileSize(outfile)); FILE* f = fopen(outfile.c_str(), "rb"); ASSERT_TRUE(f); diff --git a/webrtc/modules/media_file/source/media_file_utility.cc b/webrtc/modules/media_file/source/media_file_utility.cc index 71d62a19d9..7bffd0a3a3 100644 --- a/webrtc/modules/media_file/source/media_file_utility.cc +++ b/webrtc/modules/media_file/source/media_file_utility.cc @@ -13,7 +13,9 @@ #include #include #include +#include +#include "webrtc/base/format_macros.h" #include "webrtc/common_audio/wav_header.h" #include "webrtc/common_types.h" #include "webrtc/engine_configurations.h" @@ -234,7 +236,7 @@ int32_t ModuleFileUtility::InitAviWriting( int32_t ModuleFileUtility::WriteAviAudioData( const int8_t* buffer, - uint32_t bufferLengthInBytes) + size_t bufferLengthInBytes) { if( _aviOutFile != 0) { @@ -251,7 +253,7 @@ int32_t ModuleFileUtility::WriteAviAudioData( int32_t ModuleFileUtility::WriteAviVideoData( const int8_t* buffer, - uint32_t bufferLengthInBytes) + size_t bufferLengthInBytes) { if( _aviOutFile != 0) { @@ -370,7 +372,7 @@ int32_t ModuleFileUtility::InitAviReading(const char* filename, bool videoOnly, int32_t ModuleFileUtility::ReadAviAudioData( int8_t* outBuffer, - const uint32_t bufferLengthInBytes) + size_t bufferLengthInBytes) { if(_aviAudioInFile == 0) { @@ -378,22 +380,20 @@ int32_t ModuleFileUtility::ReadAviAudioData( return -1; } - int32_t length = bufferLengthInBytes; - if(_aviAudioInFile->ReadAudio( - reinterpret_cast(outBuffer), - length) != 0) + if(_aviAudioInFile->ReadAudio(reinterpret_cast(outBuffer), + bufferLengthInBytes) != 0) { return -1; } else { - return length; + return static_cast(bufferLengthInBytes); } } int32_t ModuleFileUtility::ReadAviVideoData( int8_t* outBuffer, - const uint32_t bufferLengthInBytes) + size_t bufferLengthInBytes) { if(_aviVideoInFile == 0) { @@ -401,14 +401,12 @@ int32_t ModuleFileUtility::ReadAviVideoData( return -1; } - int32_t length = bufferLengthInBytes; - if( _aviVideoInFile->ReadVideo( - reinterpret_cast(outBuffer), - length) != 0) + if(_aviVideoInFile->ReadVideo(reinterpret_cast(outBuffer), + bufferLengthInBytes) != 0) { return -1; } else { - return length; + return static_cast(bufferLengthInBytes); } } @@ -774,14 +772,14 @@ int32_t ModuleFileUtility::InitWavReading(InStream& wav, int32_t ModuleFileUtility::ReadWavDataAsMono( InStream& wav, int8_t* outData, - const uint32_t bufferSize) + const size_t bufferSize) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::ReadWavDataAsMono(wav= 0x%x, outData= 0x%d,\ - bufSize= %ld)", + "ModuleFileUtility::ReadWavDataAsMono(wav= 0x%x, outData= 0x%d, " + "bufSize= %" PRIuS ")", &wav, outData, bufferSize); @@ -853,14 +851,14 @@ int32_t ModuleFileUtility::ReadWavDataAsStereo( InStream& wav, int8_t* outDataLeft, int8_t* outDataRight, - const uint32_t bufferSize) + const size_t bufferSize) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::ReadWavDataAsStereo(wav= 0x%x, outLeft= 0x%x,\ - outRight= 0x%x, bufSize= %ld)", + "ModuleFileUtility::ReadWavDataAsStereo(wav= 0x%x, outLeft= 0x%x, " + "outRight= 0x%x, bufSize= %" PRIuS ")", &wav, outDataLeft, outDataRight, @@ -1083,13 +1081,14 @@ int32_t ModuleFileUtility::InitWavWriting(OutStream& wav, int32_t ModuleFileUtility::WriteWavData(OutStream& out, const int8_t* buffer, - const uint32_t dataLength) + const size_t dataLength) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::WriteWavData(out= 0x%x, buf= 0x%x, dataLen= %d)", + "ModuleFileUtility::WriteWavData(out= 0x%x, buf= 0x%x, dataLen= %" PRIuS + ")", &out, buffer, dataLength); @@ -1106,7 +1105,7 @@ int32_t ModuleFileUtility::WriteWavData(OutStream& out, return -1; } _bytesWritten += dataLength; - return dataLength; + return static_cast(dataLength); } @@ -1192,14 +1191,14 @@ int32_t ModuleFileUtility::InitPreEncodedReading(InStream& in, int32_t ModuleFileUtility::ReadPreEncodedData( InStream& in, int8_t* outData, - const uint32_t bufferSize) + const size_t bufferSize) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::ReadPreEncodedData(in= 0x%x, outData= 0x%x,\ - bufferSize= %d)", + "ModuleFileUtility::ReadPreEncodedData(in= 0x%x, outData= 0x%x, " + "bufferSize= %" PRIuS ")", &in, outData, bufferSize); @@ -1259,14 +1258,14 @@ int32_t ModuleFileUtility::InitPreEncodedWriting( int32_t ModuleFileUtility::WritePreEncodedData( OutStream& out, const int8_t* buffer, - const uint32_t dataLength) + const size_t dataLength) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::WritePreEncodedData(out= 0x%x, inData= 0x%x,\ - dataLen= %d)", + "ModuleFileUtility::WritePreEncodedData(out= 0x%x, inData= 0x%x, " + "dataLen= %" PRIuS ")", &out, buffer, dataLength); @@ -1276,11 +1275,12 @@ int32_t ModuleFileUtility::WritePreEncodedData( WEBRTC_TRACE(kTraceError, kTraceFile, _id,"buffer NULL"); } - int32_t bytesWritten = 0; + size_t bytesWritten = 0; // The first two bytes is the size of the frame. int16_t lengthBuf; lengthBuf = (int16_t)dataLength; - if(!out.Write(&lengthBuf, 2)) + if(dataLength > static_cast(std::numeric_limits::max()) || + !out.Write(&lengthBuf, 2)) { return -1; } @@ -1291,7 +1291,7 @@ int32_t ModuleFileUtility::WritePreEncodedData( return -1; } bytesWritten += dataLength; - return bytesWritten; + return static_cast(bytesWritten); } int32_t ModuleFileUtility::InitCompressedReading( @@ -1495,14 +1495,14 @@ int32_t ModuleFileUtility::InitCompressedReading( int32_t ModuleFileUtility::ReadCompressedData(InStream& in, int8_t* outData, - uint32_t bufferSize) + size_t bufferSize) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::ReadCompressedData(in=0x%x, outData=0x%x,\ - bytes=%ld)", + "ModuleFileUtility::ReadCompressedData(in=0x%x, outData=0x%x, bytes=%" + PRIuS ")", &in, outData, bufferSize); @@ -1554,7 +1554,7 @@ int32_t ModuleFileUtility::ReadCompressedData(InStream& in, } if(mode != 15) { - if(bufferSize < AMRmode2bytes[mode] + 1) + if(bufferSize < static_cast(AMRmode2bytes[mode] + 1)) { WEBRTC_TRACE( kTraceError, @@ -1612,7 +1612,7 @@ int32_t ModuleFileUtility::ReadCompressedData(InStream& in, } if(mode != 15) { - if(bufferSize < AMRWBmode2bytes[mode] + 1) + if(bufferSize < static_cast(AMRWBmode2bytes[mode] + 1)) { WEBRTC_TRACE(kTraceError, kTraceFile, _id, "output buffer is too short to read AMRWB\ @@ -1770,14 +1770,14 @@ int32_t ModuleFileUtility::InitCompressedWriting( int32_t ModuleFileUtility::WriteCompressedData( OutStream& out, const int8_t* buffer, - const uint32_t dataLength) + const size_t dataLength) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::WriteCompressedData(out= 0x%x, buf= 0x%x,\ - dataLen= %d)", + "ModuleFileUtility::WriteCompressedData(out= 0x%x, buf= 0x%x, " + "dataLen= %" PRIuS ")", &out, buffer, dataLength); @@ -1791,7 +1791,7 @@ int32_t ModuleFileUtility::WriteCompressedData( { return -1; } - return dataLength; + return static_cast(dataLength); } int32_t ModuleFileUtility::InitPCMReading(InStream& pcm, @@ -1872,13 +1872,14 @@ int32_t ModuleFileUtility::InitPCMReading(InStream& pcm, int32_t ModuleFileUtility::ReadPCMData(InStream& pcm, int8_t* outData, - uint32_t bufferSize) + size_t bufferSize) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::ReadPCMData(pcm= 0x%x, outData= 0x%x, bufSize= %d)", + "ModuleFileUtility::ReadPCMData(pcm= 0x%x, outData= 0x%x, bufSize= %" + PRIuS ")", &pcm, outData, bufferSize); @@ -2006,13 +2007,14 @@ int32_t ModuleFileUtility::InitPCMWriting(OutStream& out, uint32_t freq) int32_t ModuleFileUtility::WritePCMData(OutStream& out, const int8_t* buffer, - const uint32_t dataLength) + const size_t dataLength) { WEBRTC_TRACE( kTraceStream, kTraceFile, _id, - "ModuleFileUtility::WritePCMData(out= 0x%x, buf= 0x%x, dataLen= %d)", + "ModuleFileUtility::WritePCMData(out= 0x%x, buf= 0x%x, dataLen= %" PRIuS + ")", &out, buffer, dataLength); @@ -2028,7 +2030,7 @@ int32_t ModuleFileUtility::WritePCMData(OutStream& out, } _bytesWritten += dataLength; - return dataLength; + return static_cast(dataLength); } int32_t ModuleFileUtility::codec_info(CodecInst& codecInst) diff --git a/webrtc/modules/media_file/source/media_file_utility.h b/webrtc/modules/media_file/source/media_file_utility.h index 5fc9ef428d..d8fefccf99 100644 --- a/webrtc/modules/media_file/source/media_file_utility.h +++ b/webrtc/modules/media_file/source/media_file_utility.h @@ -43,13 +43,13 @@ public: // audio with more channels (in which case the audio will be coverted to // mono). int32_t ReadAviAudioData(int8_t* outBuffer, - const uint32_t bufferLengthInBytes); + size_t bufferLengthInBytes); // Put one video frame into outBuffer. bufferLengthInBytes indicates the // size of outBuffer. // The return value is the number of bytes written to videoBuffer. int32_t ReadAviVideoData(int8_t* videoBuffer, - const uint32_t bufferLengthInBytes); + size_t bufferLengthInBytes); // Open/create the file specified by fileName for writing audio/video data // (relative path is allowed). codecInst specifies the encoding of the audio @@ -66,7 +66,7 @@ public: // InitAviWriting(..) call. // Note: bufferLength must be exactly one frame. int32_t WriteAviAudioData(const int8_t* audioBuffer, - uint32_t bufferLengthInBytes); + size_t bufferLengthInBytes); // Write one video frame, i.e. the bufferLength first bytes of videoBuffer, @@ -76,7 +76,7 @@ public: // InitAviWriting(..) call. The videoBuffer must contain exactly // one video frame. int32_t WriteAviVideoData(const int8_t* videoBuffer, - uint32_t bufferLengthInBytes); + size_t bufferLengthInBytes); // Stop recording to file or stream. int32_t CloseAviFile(); @@ -98,7 +98,7 @@ public: // audio with more channels (in which case the audio will be converted to // mono). int32_t ReadWavDataAsMono(InStream& stream, int8_t* audioBuffer, - const uint32_t dataLengthInBytes); + const size_t dataLengthInBytes); // Put 10-60ms, depending on codec frame size, of audio data from file into // audioBufferLeft and audioBufferRight. The buffers contain the left and @@ -111,7 +111,7 @@ public: int32_t ReadWavDataAsStereo(InStream& wav, int8_t* audioBufferLeft, int8_t* audioBufferRight, - const uint32_t bufferLength); + const size_t bufferLength); // Prepare for recording audio to stream. // codecInst specifies the encoding of the audio data. @@ -125,7 +125,7 @@ public: // The return value is the number of bytes written to audioBuffer. int32_t WriteWavData(OutStream& stream, const int8_t* audioBuffer, - const uint32_t bufferLength); + const size_t bufferLength); // Finalizes the WAV header so that it is correct if nothing more will be // written to stream. @@ -148,7 +148,7 @@ public: // codec frame size. dataLengthInBytes indicates the size of audioBuffer. // The return value is the number of bytes written to audioBuffer. int32_t ReadPCMData(InStream& stream, int8_t* audioBuffer, - const uint32_t dataLengthInBytes); + const size_t dataLengthInBytes); // Prepare for recording audio to stream. // freqInHz is the PCM sampling frequency. @@ -161,7 +161,7 @@ public: // The return value is the number of bytes written to audioBuffer. int32_t WritePCMData(OutStream& stream, const int8_t* audioBuffer, - uint32_t bufferLength); + size_t bufferLength); // Prepare for playing audio from stream. // startPointMs and stopPointMs, unless zero, specify what part of the file @@ -175,7 +175,7 @@ public: // The return value is the number of bytes written to audioBuffer. int32_t ReadCompressedData(InStream& stream, int8_t* audioBuffer, - const uint32_t dataLengthInBytes); + const size_t dataLengthInBytes); // Prepare for recording audio to stream. // codecInst specifies the encoding of the audio data. @@ -189,7 +189,7 @@ public: // Note: bufferLength must be exactly one frame. int32_t WriteCompressedData(OutStream& stream, const int8_t* audioBuffer, - const uint32_t bufferLength); + const size_t bufferLength); // Prepare for playing audio from stream. // codecInst specifies the encoding of the audio data. @@ -201,7 +201,7 @@ public: // The return value is the number of bytes written to audioBuffer. int32_t ReadPreEncodedData(InStream& stream, int8_t* audioBuffer, - const uint32_t dataLengthInBytes); + const size_t dataLengthInBytes); // Prepare for recording audio to stream. // codecInst specifies the encoding of the audio data. @@ -215,7 +215,7 @@ public: // Note: bufferLength must be exactly one frame. int32_t WritePreEncodedData(OutStream& stream, const int8_t* inData, - const uint32_t dataLengthInBytes); + const size_t dataLengthInBytes); // Set durationMs to the size of the file (in ms) specified by fileName. // freqInHz specifies the sampling frequency of the file. @@ -320,7 +320,7 @@ private: uint32_t _stopPointInMs; uint32_t _startPointInMs; uint32_t _playoutPositionMs; - uint32_t _bytesWritten; + size_t _bytesWritten; CodecInst codec_info_; MediaFileUtility_CodecType _codecId; diff --git a/webrtc/modules/pacing/include/mock/mock_paced_sender.h b/webrtc/modules/pacing/include/mock/mock_paced_sender.h index 0c9e354d20..bff6a5debd 100644 --- a/webrtc/modules/pacing/include/mock/mock_paced_sender.h +++ b/webrtc/modules/pacing/include/mock/mock_paced_sender.h @@ -27,7 +27,7 @@ class MockPacedSender : public PacedSender { uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, - int bytes, + size_t bytes, bool retransmission)); MOCK_CONST_METHOD0(QueueInMs, int()); MOCK_CONST_METHOD0(QueueInPackets, int()); diff --git a/webrtc/modules/pacing/include/paced_sender.h b/webrtc/modules/pacing/include/paced_sender.h index 6a420e4c3f..f0e98e8745 100644 --- a/webrtc/modules/pacing/include/paced_sender.h +++ b/webrtc/modules/pacing/include/paced_sender.h @@ -52,7 +52,7 @@ class PacedSender : public Module { bool retransmission) = 0; // Called when it's a good time to send a padding data. // Returns the number of bytes sent. - virtual int TimeToSendPadding(int bytes) = 0; + virtual size_t TimeToSendPadding(size_t bytes) = 0; protected: virtual ~Callback() {} @@ -102,7 +102,7 @@ class PacedSender : public Module { uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, - int bytes, + size_t bytes, bool retransmission); // Returns the time since the oldest queued packet was enqueued. @@ -131,7 +131,7 @@ class PacedSender : public Module { bool SendPacket(const paced_sender::Packet& packet) EXCLUSIVE_LOCKS_REQUIRED(critsect_); - void SendPadding(int padding_needed) EXCLUSIVE_LOCKS_REQUIRED(critsect_); + void SendPadding(size_t padding_needed) EXCLUSIVE_LOCKS_REQUIRED(critsect_); Clock* const clock_; Callback* const callback_; diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc index 98f508ccc5..890955e33f 100644 --- a/webrtc/modules/pacing/paced_sender.cc +++ b/webrtc/modules/pacing/paced_sender.cc @@ -42,7 +42,7 @@ struct Packet { uint16_t seq_number, int64_t capture_time_ms, int64_t enqueue_time_ms, - int length_in_bytes, + size_t length_in_bytes, bool retransmission, uint64_t enqueue_order) : priority(priority), @@ -59,7 +59,7 @@ struct Packet { uint16_t sequence_number; int64_t capture_time_ms; int64_t enqueue_time_ms; - int bytes; + size_t bytes; bool retransmission; uint64_t enqueue_order; std::list::iterator this_it; @@ -189,8 +189,8 @@ class IntervalBudget { } } - void UseBudget(int bytes) { - bytes_remaining_ = std::max(bytes_remaining_ - bytes, + void UseBudget(size_t bytes) { + bytes_remaining_ = std::max(bytes_remaining_ - static_cast(bytes), -500 * target_rate_kbps_ / 8); } @@ -258,7 +258,7 @@ void PacedSender::UpdateBitrate(int bitrate_kbps, } bool PacedSender::SendPacket(Priority priority, uint32_t ssrc, - uint16_t sequence_number, int64_t capture_time_ms, int bytes, + uint16_t sequence_number, int64_t capture_time_ms, size_t bytes, bool retransmission) { CriticalSectionScoped cs(critsect_.get()); @@ -353,7 +353,7 @@ int32_t PacedSender::Process() { int padding_needed = padding_budget_->bytes_remaining(); if (padding_needed > 0) { - SendPadding(padding_needed); + SendPadding(static_cast(padding_needed)); } } return 0; @@ -377,9 +377,9 @@ bool PacedSender::SendPacket(const paced_sender::Packet& packet) { return success; } -void PacedSender::SendPadding(int padding_needed) { +void PacedSender::SendPadding(size_t padding_needed) { critsect_->Leave(); - int bytes_sent = callback_->TimeToSendPadding(padding_needed); + size_t bytes_sent = callback_->TimeToSendPadding(padding_needed); critsect_->Enter(); // Update padding bytes sent. diff --git a/webrtc/modules/pacing/paced_sender_unittest.cc b/webrtc/modules/pacing/paced_sender_unittest.cc index ac713c8898..4303b6474c 100644 --- a/webrtc/modules/pacing/paced_sender_unittest.cc +++ b/webrtc/modules/pacing/paced_sender_unittest.cc @@ -32,7 +32,7 @@ class MockPacedSenderCallback : public PacedSender::Callback { int64_t capture_time_ms, bool retransmission)); MOCK_METHOD1(TimeToSendPadding, - int(int bytes)); + size_t(size_t bytes)); }; class PacedSenderPadding : public PacedSender::Callback { @@ -46,17 +46,17 @@ class PacedSenderPadding : public PacedSender::Callback { return true; } - int TimeToSendPadding(int bytes) { - const int kPaddingPacketSize = 224; - int num_packets = (bytes + kPaddingPacketSize - 1) / kPaddingPacketSize; + size_t TimeToSendPadding(size_t bytes) { + const size_t kPaddingPacketSize = 224; + size_t num_packets = (bytes + kPaddingPacketSize - 1) / kPaddingPacketSize; padding_sent_ += kPaddingPacketSize * num_packets; return kPaddingPacketSize * num_packets; } - int padding_sent() { return padding_sent_; } + size_t padding_sent() { return padding_sent_; } private: - int padding_sent_; + size_t padding_sent_; }; class PacedSenderProbing : public PacedSender::Callback { @@ -84,7 +84,7 @@ class PacedSenderProbing : public PacedSender::Callback { return true; } - int TimeToSendPadding(int bytes) { + size_t TimeToSendPadding(size_t bytes) { EXPECT_TRUE(false); return bytes; } @@ -114,7 +114,7 @@ class PacedSenderTest : public ::testing::Test { uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, - int size, + size_t size, bool retransmission) { EXPECT_FALSE(send_bucket_->SendPacket(priority, ssrc, sequence_number, capture_time_ms, size, retransmission)); @@ -421,9 +421,9 @@ TEST_F(PacedSenderTest, VerifyAverageBitrateVaryingMediaPayload) { send_bucket_->UpdateBitrate( kTargetBitrate, kPaceMultiplier * kTargetBitrate, kTargetBitrate); int64_t start_time = clock_.TimeInMilliseconds(); - int media_bytes = 0; + size_t media_bytes = 0; while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) { - int media_payload = rand() % 100 + 200; // [200, 300] bytes. + size_t media_payload = rand() % 100 + 200; // [200, 300] bytes. EXPECT_FALSE(send_bucket_->SendPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, capture_time_ms, media_payload, false)); @@ -431,8 +431,9 @@ TEST_F(PacedSenderTest, VerifyAverageBitrateVaryingMediaPayload) { clock_.AdvanceTimeMilliseconds(kTimeStep); send_bucket_->Process(); } - EXPECT_NEAR(kTargetBitrate, 8 * (media_bytes + callback.padding_sent()) / - kBitrateWindow, 1); + EXPECT_NEAR(kTargetBitrate, + static_cast(8 * (media_bytes + callback.padding_sent()) / + kBitrateWindow), 1); } TEST_F(PacedSenderTest, Priority) { @@ -642,19 +643,20 @@ TEST_F(PacedSenderTest, ResendPacket) { TEST_F(PacedSenderTest, ExpectedQueueTimeMs) { uint32_t ssrc = 12346; uint16_t sequence_number = 1234; - const int32_t kNumPackets = 60; - const int32_t kPacketSize = 1200; + const size_t kNumPackets = 60; + const size_t kPacketSize = 1200; const int32_t kMaxBitrate = kPaceMultiplier * 30; EXPECT_EQ(0, send_bucket_->ExpectedQueueTimeMs()); send_bucket_->UpdateBitrate(30, kMaxBitrate, 0); - for (int i = 0; i < kNumPackets; ++i) { + for (size_t i = 0; i < kNumPackets; ++i) { SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, clock_.TimeInMilliseconds(), kPacketSize, false); } // Queue in ms = 1000 * (bytes in queue) / (kbit per second * 1000 / 8) - int64_t queue_in_ms = kNumPackets * kPacketSize * 8 / kMaxBitrate; + int64_t queue_in_ms = + static_cast(kNumPackets * kPacketSize * 8 / kMaxBitrate); EXPECT_EQ(queue_in_ms, send_bucket_->ExpectedQueueTimeMs()); int64_t time_start = clock_.TimeInMilliseconds(); @@ -672,7 +674,8 @@ TEST_F(PacedSenderTest, ExpectedQueueTimeMs) { // Allow for aliasing, duration should be in [expected(n - 1), expected(n)]. EXPECT_LE(duration, queue_in_ms); - EXPECT_GE(duration, queue_in_ms - (kPacketSize * 8 / kMaxBitrate)); + EXPECT_GE(duration, + queue_in_ms - static_cast(kPacketSize * 8 / kMaxBitrate)); } TEST_F(PacedSenderTest, QueueTimeGrowsOverTime) { @@ -713,7 +716,7 @@ class ProbingPacedSender : public PacedSender { TEST_F(PacedSenderTest, ProbingWithInitialFrame) { const int kNumPackets = 11; const int kNumDeltas = kNumPackets - 1; - const int kPacketSize = 1200; + const size_t kPacketSize = 1200; const int kInitialBitrateKbps = 300; uint32_t ssrc = 12346; uint16_t sequence_number = 1234; @@ -749,7 +752,7 @@ TEST_F(PacedSenderTest, ProbingWithInitialFrame) { TEST_F(PacedSenderTest, PriorityInversion) { uint32_t ssrc = 12346; uint16_t sequence_number = 1234; - const int32_t kPacketSize = 1200; + const size_t kPacketSize = 1200; EXPECT_FALSE(send_bucket_->SendPacket( PacedSender::kHighPriority, ssrc, sequence_number + 3, @@ -797,7 +800,7 @@ TEST_F(PacedSenderTest, PriorityInversion) { TEST_F(PacedSenderTest, PaddingOveruse) { uint32_t ssrc = 12346; uint16_t sequence_number = 1234; - const int32_t kPacketSize = 1200; + const size_t kPacketSize = 1200; // Min bitrate 0 => no padding, padding budget will stay at 0. send_bucket_->UpdateBitrate(60, 90, 0); diff --git a/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h b/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h index e61e903558..ede3c5d5fe 100644 --- a/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h +++ b/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h @@ -73,7 +73,7 @@ class RemoteBitrateEstimator : public CallStatsObserver, public Module { // packet size excluding headers. // Note that |arrival_time_ms| can be of an arbitrary time base. virtual void IncomingPacket(int64_t arrival_time_ms, - int payload_size, + size_t payload_size, const RTPHeader& header) = 0; // Removes all data for |ssrc|. diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc index 9baaa9c913..df98450a6d 100644 --- a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc +++ b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc @@ -46,7 +46,7 @@ OveruseDetector::~OveruseDetector() { ts_delta_hist_.clear(); } -void OveruseDetector::Update(uint16_t packet_size, +void OveruseDetector::Update(size_t packet_size, int64_t timestamp_ms, uint32_t timestamp, const int64_t arrival_time_ms) { @@ -157,8 +157,8 @@ double OveruseDetector::CurrentDrift() { void OveruseDetector::UpdateKalman(int64_t t_delta, double ts_delta, - uint32_t frame_size, - uint32_t prev_frame_size) { + size_t frame_size, + size_t prev_frame_size) { const double min_frame_period = UpdateMinFramePeriod(ts_delta); const double drift = CurrentDrift(); // Compensate for drift diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_detector.h b/webrtc/modules/remote_bitrate_estimator/overuse_detector.h index 9c565e45f1..f80c92c299 100644 --- a/webrtc/modules/remote_bitrate_estimator/overuse_detector.h +++ b/webrtc/modules/remote_bitrate_estimator/overuse_detector.h @@ -25,7 +25,7 @@ class OveruseDetector { public: explicit OveruseDetector(const OverUseDetectorOptions& options); ~OveruseDetector(); - void Update(uint16_t packet_size, + void Update(size_t packet_size, int64_t timestamp_ms, uint32_t rtp_timestamp, int64_t arrival_time_ms); @@ -41,7 +41,7 @@ class OveruseDetector { timestamp(-1), timestamp_ms(-1) {} - uint32_t size; + size_t size; int64_t complete_time_ms; int64_t timestamp; int64_t timestamp_ms; @@ -63,8 +63,8 @@ class OveruseDetector { double* ts_delta); void UpdateKalman(int64_t t_delta, double ts_elta, - uint32_t frame_size, - uint32_t prev_frame_size); + size_t frame_size, + size_t prev_frame_size); double UpdateMinFramePeriod(double ts_delta); void UpdateNoiseEstimate(double residual, double ts_delta, bool stable_state); BandwidthUsage Detect(double ts_delta); diff --git a/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc b/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc index 48485ffb55..c1b4c80cc6 100644 --- a/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc +++ b/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc @@ -16,7 +16,7 @@ namespace webrtc { RateStatistics::RateStatistics(uint32_t window_size_ms, float scale) : num_buckets_(window_size_ms + 1), // N ms in (N+1) buckets. - buckets_(new uint32_t[num_buckets_]()), + buckets_(new size_t[num_buckets_]()), accumulated_count_(0), oldest_time_(0), oldest_index_(0), @@ -35,7 +35,7 @@ void RateStatistics::Reset() { } } -void RateStatistics::Update(uint32_t count, int64_t now_ms) { +void RateStatistics::Update(size_t count, int64_t now_ms) { if (now_ms < oldest_time_) { // Too old data is ignored. return; @@ -65,7 +65,7 @@ void RateStatistics::EraseOld(int64_t now_ms) { } while (oldest_time_ < new_oldest_time) { - uint32_t count_in_oldest_bucket = buckets_[oldest_index_]; + size_t count_in_oldest_bucket = buckets_[oldest_index_]; assert(accumulated_count_ >= count_in_oldest_bucket); accumulated_count_ -= count_in_oldest_bucket; buckets_[oldest_index_] = 0; diff --git a/webrtc/modules/remote_bitrate_estimator/rate_statistics.h b/webrtc/modules/remote_bitrate_estimator/rate_statistics.h index f97371bd62..d1d4a6fe72 100644 --- a/webrtc/modules/remote_bitrate_estimator/rate_statistics.h +++ b/webrtc/modules/remote_bitrate_estimator/rate_statistics.h @@ -25,7 +25,7 @@ class RateStatistics { ~RateStatistics(); void Reset(); - void Update(uint32_t count, int64_t now_ms); + void Update(size_t count, int64_t now_ms); uint32_t Rate(int64_t now_ms); private: @@ -34,10 +34,10 @@ class RateStatistics { // Counters are kept in buckets (circular buffer), with one bucket // per millisecond. const int num_buckets_; - scoped_ptr buckets_; + scoped_ptr buckets_; // Total count recorded in buckets. - uint32_t accumulated_count_; + size_t accumulated_count_; // Oldest time recorded in buckets. int64_t oldest_time_; diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc index 08422d28b2..fd7de83b7a 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc @@ -35,7 +35,7 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator { // remote bitrate estimate will be updated. Note that |payload_size| is the // packet size excluding headers. virtual void IncomingPacket(int64_t arrival_time_ms, - int payload_size, + size_t payload_size, const RTPHeader& header) OVERRIDE; // Triggers a new estimate calculation. @@ -107,7 +107,7 @@ RemoteBitrateEstimatorSingleStream::RemoteBitrateEstimatorSingleStream( void RemoteBitrateEstimatorSingleStream::IncomingPacket( int64_t arrival_time_ms, - int payload_size, + size_t payload_size, const RTPHeader& header) { uint32_t ssrc = header.ssrc; uint32_t rtp_timestamp = header.timestamp + @@ -133,7 +133,7 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket( const BandwidthUsage prior_state = overuse_detector->State(); overuse_detector->Update(payload_size, -1, rtp_timestamp, arrival_time_ms); if (overuse_detector->State() == kBwOverusing) { - unsigned int incoming_bitrate = incoming_bitrate_.Rate(now_ms); + uint32_t incoming_bitrate = incoming_bitrate_.Rate(now_ms); if (prior_state != kBwOverusing || remote_rate_.TimeToReduceFurther(now_ms, incoming_bitrate)) { // The first overuse should immediately trigger a new estimate. diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc index 4f9e16c8db..9073617328 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc @@ -14,7 +14,8 @@ namespace webrtc { -enum { kMtu = 1200, kAcceptedBitrateErrorBps = 50000u }; +const size_t kMtu = 1200; +const unsigned int kAcceptedBitrateErrorBps = 50000; namespace testing { @@ -54,11 +55,11 @@ int64_t RtpStream::GenerateFrame(int64_t time_now_us, PacketList* packets) { return next_rtp_time_; } assert(packets != NULL); - int bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_; - int n_packets = std::max((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1); - int packet_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets); - assert(n_packets >= 0); - for (int i = 0; i < n_packets; ++i) { + size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_; + size_t n_packets = + std::max((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u); + size_t packet_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets); + for (size_t i = 0; i < n_packets; ++i) { RtpPacket* packet = new RtpPacket; packet->send_time = time_now_us + kSendSideOffsetUs; packet->size = packet_size; @@ -217,7 +218,7 @@ uint32_t RemoteBitrateEstimatorTest::AddAbsSendTime(uint32_t t1, uint32_t t2) { const unsigned int RemoteBitrateEstimatorTest::kDefaultSsrc = 1; void RemoteBitrateEstimatorTest::IncomingPacket(uint32_t ssrc, - uint32_t payload_size, + size_t payload_size, int64_t arrival_time, uint32_t rtp_timestamp, uint32_t absolute_send_time) { diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h index 2ef2f45c27..a935896aca 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h @@ -49,7 +49,7 @@ class RtpStream { int64_t send_time; int64_t arrival_time; uint32_t rtp_timestamp; - unsigned int size; + size_t size; unsigned int ssrc; }; @@ -165,7 +165,7 @@ class RemoteBitrateEstimatorTest : public ::testing::Test { // estimator (all other fields are cleared) and call IncomingPacket on the // estimator. void IncomingPacket(uint32_t ssrc, - uint32_t payload_size, + size_t payload_size, int64_t arrival_time, uint32_t rtp_timestamp, uint32_t absolute_send_time); diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc index f7a7197ebd..42b5d34fae 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc @@ -127,7 +127,7 @@ Packet::Packet() memset(&header_, 0, sizeof(header_)); } -Packet::Packet(int flow_id, int64_t send_time_us, uint32_t payload_size, +Packet::Packet(int flow_id, int64_t send_time_us, size_t payload_size, const RTPHeader& header) : flow_id_(flow_id), creation_time_us_(send_time_us), @@ -785,7 +785,7 @@ bool PacedVideoSender::TimeToSendPacket(uint32_t ssrc, return false; } -int PacedVideoSender::TimeToSendPadding(int bytes) { +size_t PacedVideoSender::TimeToSendPadding(size_t bytes) { return 0; } } // namespace bwe diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h index 60981976ae..a7d0ebcbde 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h @@ -153,7 +153,7 @@ class Random { class Packet { public: Packet(); - Packet(int flow_id, int64_t send_time_us, uint32_t payload_size, + Packet(int flow_id, int64_t send_time_us, size_t payload_size, const RTPHeader& header); Packet(int64_t send_time_us, uint32_t sequence_number); @@ -164,14 +164,14 @@ class Packet { void set_send_time_us(int64_t send_time_us); int64_t send_time_us() const { return send_time_us_; } void SetAbsSendTimeMs(int64_t abs_send_time_ms); - uint32_t payload_size() const { return payload_size_; } + size_t payload_size() const { return payload_size_; } const RTPHeader& header() const { return header_; } private: int flow_id_; int64_t creation_time_us_; // Time when the packet was created. int64_t send_time_us_; // Time the packet left last processor touching it. - uint32_t payload_size_; // Size of the (non-existent, simulated) payload. + size_t payload_size_; // Size of the (non-existent, simulated) payload. RTPHeader header_; // Actual contents. }; @@ -474,7 +474,7 @@ class PacedVideoSender : public PacketSender, public PacedSender::Callback { uint16_t sequence_number, int64_t capture_time_ms, bool retransmission) OVERRIDE; - virtual int TimeToSendPadding(int bytes) OVERRIDE; + virtual size_t TimeToSendPadding(size_t bytes) OVERRIDE; private: class ProbingPacedSender : public PacedSender { diff --git a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc index eb224f2e4a..45a03f9d9d 100644 --- a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc +++ b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc @@ -83,7 +83,7 @@ int main(int argc, char** argv) { if (header.extension.transmissionTimeOffset != 0) ++non_zero_ts_offsets; rbe->IncomingPacket(clock.TimeInMilliseconds(), - static_cast(packet.length - header.headerLength), + packet.length - header.headerLength, header); ++packet_counter; } diff --git a/webrtc/modules/rtp_rtcp/interface/fec_receiver.h b/webrtc/modules/rtp_rtcp/interface/fec_receiver.h index e2ef4b1e97..da54bf6927 100644 --- a/webrtc/modules/rtp_rtcp/interface/fec_receiver.h +++ b/webrtc/modules/rtp_rtcp/interface/fec_receiver.h @@ -24,7 +24,7 @@ class FecReceiver { virtual int32_t AddReceivedRedPacket(const RTPHeader& rtp_header, const uint8_t* incoming_rtp_packet, - int packet_length, + size_t packet_length, uint8_t ulpfec_payload_type) = 0; virtual int32_t ProcessReceivedFec() = 0; diff --git a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h index 6f2ea4fb3e..ae1fbb6776 100644 --- a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h +++ b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h @@ -26,7 +26,7 @@ class StreamStatistician { virtual ~StreamStatistician(); virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0; - virtual void GetDataCounters(uint32_t* bytes_received, + virtual void GetDataCounters(size_t* bytes_received, uint32_t* packets_received) const = 0; virtual uint32_t BitrateReceived() const = 0; diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h b/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h index 327ea165d5..bbdac6722c 100644 --- a/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h +++ b/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h @@ -83,7 +83,7 @@ class RTPPayloadRegistry { bool RestoreOriginalPacket(uint8_t** restored_packet, const uint8_t* packet, - int* packet_length, + size_t* packet_length, uint32_t original_ssrc, const RTPHeader& header) const; diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h b/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h index 00e5e5d2e7..62835667df 100644 --- a/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h +++ b/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h @@ -72,7 +72,7 @@ class RtpReceiver { // detected and acted upon. virtual bool IncomingRtpPacket(const RTPHeader& rtp_header, const uint8_t* payload, - int payload_length, + size_t payload_length, PayloadUnion payload_specific, bool in_order) = 0; diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h index ca686c08ee..c1250b9728 100644 --- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h +++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h @@ -83,7 +83,7 @@ class RtpRtcp : public Module { ***************************************************************************/ virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet, - uint16_t incoming_packet_length) = 0; + size_t incoming_packet_length) = 0; virtual void SetRemoteSSRC(const uint32_t ssrc) = 0; @@ -328,7 +328,7 @@ class RtpRtcp : public Module { const uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation = NULL, const RTPVideoHeader* rtpVideoHdr = NULL) = 0; @@ -337,7 +337,7 @@ class RtpRtcp : public Module { int64_t capture_time_ms, bool retransmission) = 0; - virtual int TimeToSendPadding(int bytes) = 0; + virtual size_t TimeToSendPadding(size_t bytes) = 0; virtual bool GetSendSideDelay(int* avg_send_delay_ms, int* max_send_delay_ms) const = 0; @@ -465,7 +465,7 @@ class RtpRtcp : public Module { * return -1 on failure else 0 */ virtual int32_t DataCountersRTP( - uint32_t* bytesSent, + size_t* bytesSent, uint32_t* packetsSent) const = 0; /* * Get received RTCP sender info diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h index dc51467ee1..e94be57af6 100644 --- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h +++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h @@ -143,7 +143,7 @@ enum RtxMode { // instead of padding. }; -const int kRtxHeaderSize = 2; +const size_t kRtxHeaderSize = 2; struct RTCPSenderInfo { @@ -220,11 +220,11 @@ public: virtual int32_t OnReceivedPayloadData( const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const WebRtcRTPHeader* rtpHeader) = 0; virtual bool OnRecoveredPacket(const uint8_t* packet, - int packet_length) = 0; + size_t packet_length) = 0; }; class RtpFeedback @@ -334,13 +334,13 @@ class NullRtpData : public RtpData { virtual int32_t OnReceivedPayloadData( const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const WebRtcRTPHeader* rtpHeader) OVERRIDE { return 0; } virtual bool OnRecoveredPacket(const uint8_t* packet, - int packet_length) OVERRIDE { + size_t packet_length) OVERRIDE { return true; } }; diff --git a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h index 584b9ad6b2..78806603fc 100644 --- a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h +++ b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h @@ -23,11 +23,11 @@ class MockRtpData : public RtpData { public: MOCK_METHOD3(OnReceivedPayloadData, int32_t(const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const WebRtcRTPHeader* rtpHeader)); MOCK_METHOD2(OnRecoveredPacket, - bool(const uint8_t* packet, int packet_length)); + bool(const uint8_t* packet, size_t packet_length)); }; class MockRtpRtcp : public RtpRtcp { @@ -47,7 +47,7 @@ class MockRtpRtcp : public RtpRtcp { MOCK_METHOD0(DeRegisterSyncModule, int32_t()); MOCK_METHOD2(IncomingRtcpPacket, - int32_t(const uint8_t* incomingPacket, uint16_t packetLength)); + int32_t(const uint8_t* incomingPacket, size_t packetLength)); MOCK_METHOD1(SetRemoteSSRC, void(const uint32_t ssrc)); MOCK_METHOD4(IncomingAudioNTP, int32_t(const uint32_t audioReceivedNTPsecs, @@ -126,14 +126,14 @@ class MockRtpRtcp : public RtpRtcp { const uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation, const RTPVideoHeader* rtpVideoHdr)); MOCK_METHOD4(TimeToSendPacket, bool(uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, bool retransmission)); MOCK_METHOD1(TimeToSendPadding, - int(int bytes)); + size_t(size_t bytes)); MOCK_CONST_METHOD2(GetSendSideDelay, bool(int* avg_send_delay_ms, int* max_send_delay_ms)); MOCK_METHOD2(RegisterRtcpObservers, @@ -172,7 +172,7 @@ class MockRtpRtcp : public RtpRtcp { MOCK_METHOD0(ResetSendDataCountersRTP, int32_t()); MOCK_CONST_METHOD2(DataCountersRTP, - int32_t(uint32_t *bytesSent, uint32_t *packetsSent)); + int32_t(size_t *bytesSent, uint32_t *packetsSent)); MOCK_METHOD1(RemoteRTCPStat, int32_t(RTCPSenderInfo* senderInfo)); MOCK_CONST_METHOD1(RemoteRTCPStat, diff --git a/webrtc/modules/rtp_rtcp/source/bitrate.cc b/webrtc/modules/rtp_rtcp/source/bitrate.cc index 11b3cb29d5..0d502213aa 100644 --- a/webrtc/modules/rtp_rtcp/source/bitrate.cc +++ b/webrtc/modules/rtp_rtcp/source/bitrate.cc @@ -32,7 +32,7 @@ Bitrate::Bitrate(Clock* clock, Observer* observer) Bitrate::~Bitrate() {} -void Bitrate::Update(const int32_t bytes) { +void Bitrate::Update(const size_t bytes) { CriticalSectionScoped cs(crit_.get()); bytes_count_ += bytes; packet_count_++; diff --git a/webrtc/modules/rtp_rtcp/source/bitrate.h b/webrtc/modules/rtp_rtcp/source/bitrate.h index 36fa1d3717..086db2abe5 100644 --- a/webrtc/modules/rtp_rtcp/source/bitrate.h +++ b/webrtc/modules/rtp_rtcp/source/bitrate.h @@ -35,7 +35,7 @@ class Bitrate { void Process(); // Update with a packet. - void Update(const int32_t bytes); + void Update(const size_t bytes); // Packet rate last second, updated roughly every 100 ms. uint32_t PacketRate() const; @@ -68,7 +68,7 @@ class Bitrate { int64_t bitrate_array_[10]; int64_t bitrate_diff_ms_[10]; int64_t time_last_rate_update_; - uint32_t bytes_count_; + size_t bytes_count_; uint32_t packet_count_; Observer* const observer_; }; diff --git a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc index e795841f1c..0fcb6f7c4c 100644 --- a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc +++ b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc @@ -71,10 +71,10 @@ FecReceiverImpl::~FecReceiverImpl() { int32_t FecReceiverImpl::AddReceivedRedPacket( const RTPHeader& header, const uint8_t* incoming_rtp_packet, - int packet_length, uint8_t ulpfec_payload_type) { + size_t packet_length, uint8_t ulpfec_payload_type) { CriticalSectionScoped cs(crit_sect_.get()); uint8_t REDHeaderLength = 1; - uint16_t payload_data_length = packet_length - header.headerLength; + size_t payload_data_length = packet_length - header.headerLength; // Add to list without RED header, aka a virtual RTP packet // we remove the RED header diff --git a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h index b876bedc9c..8dd02b35f8 100644 --- a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h +++ b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h @@ -30,7 +30,7 @@ class FecReceiverImpl : public FecReceiver { virtual int32_t AddReceivedRedPacket(const RTPHeader& rtp_header, const uint8_t* incoming_rtp_packet, - int packet_length, + size_t packet_length, uint8_t ulpfec_payload_type) OVERRIDE; virtual int32_t ProcessReceivedFec() OVERRIDE; diff --git a/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc b/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc index 0ffd5bf4fa..a85e749d28 100644 --- a/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc +++ b/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc @@ -44,7 +44,7 @@ RtpPacket* FrameGenerator::NextPacket(int offset, size_t length) { // Creates a new RtpPacket with the RED header added to the packet. RtpPacket* FrameGenerator::BuildMediaRedPacket(const RtpPacket* packet) { - const int kHeaderLength = packet->header.header.headerLength; + const size_t kHeaderLength = packet->header.header.headerLength; RtpPacket* red_packet = new RtpPacket; red_packet->header = packet->header; red_packet->length = packet->length + 1; // 1 byte RED header. @@ -65,7 +65,7 @@ RtpPacket* FrameGenerator::BuildFecRedPacket(const Packet* packet) { ++num_packets_; RtpPacket* red_packet = NextPacket(0, packet->length + 1); red_packet->data[1] &= ~0x80; // Clear marker bit. - const int kHeaderLength = red_packet->header.header.headerLength; + const size_t kHeaderLength = red_packet->header.header.headerLength; SetRedHeader(red_packet, kFecPayloadType, kHeaderLength); memcpy(red_packet->data + kHeaderLength + 1, packet->data, packet->length); red_packet->length = kHeaderLength + 1 + packet->length; @@ -73,7 +73,7 @@ RtpPacket* FrameGenerator::BuildFecRedPacket(const Packet* packet) { } void FrameGenerator::SetRedHeader(Packet* red_packet, uint8_t payload_type, - int header_length) const { + size_t header_length) const { // Replace pltype. red_packet->data[1] &= 0x80; // Reset. red_packet->data[1] += kRedPayloadType; // Replace. diff --git a/webrtc/modules/rtp_rtcp/source/fec_test_helper.h b/webrtc/modules/rtp_rtcp/source/fec_test_helper.h index e6426ea7ee..825396122a 100644 --- a/webrtc/modules/rtp_rtcp/source/fec_test_helper.h +++ b/webrtc/modules/rtp_rtcp/source/fec_test_helper.h @@ -51,7 +51,7 @@ class FrameGenerator { RtpPacket* BuildFecRedPacket(const Packet* packet); void SetRedHeader(Packet* red_packet, uint8_t payload_type, - int header_length) const; + size_t header_length) const; private: static void BuildRtpHeader(uint8_t* data, const RTPHeader* header); diff --git a/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc b/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc index b02ea08652..9010e7eaa7 100644 --- a/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc +++ b/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc @@ -693,7 +693,7 @@ void ForwardErrorCorrection::XorPackets(const Packet* src_packet, // XOR with RTP payload. // TODO(marpan/ajm): Are we doing more XORs than required here? - for (int32_t i = kRtpHeaderSize; i < src_packet->length; ++i) { + for (size_t i = kRtpHeaderSize; i < src_packet->length; ++i) { dst_packet->pkt->data[i] ^= src_packet->data[i]; } } @@ -816,7 +816,7 @@ int32_t ForwardErrorCorrection::DecodeFEC( return 0; } -uint16_t ForwardErrorCorrection::PacketOverhead() { +size_t ForwardErrorCorrection::PacketOverhead() { return kFecHeaderSize + kUlpHeaderSizeLBitSet; } } // namespace webrtc diff --git a/webrtc/modules/rtp_rtcp/source/forward_error_correction.h b/webrtc/modules/rtp_rtcp/source/forward_error_correction.h index bb790f356f..a3b3fa0e49 100644 --- a/webrtc/modules/rtp_rtcp/source/forward_error_correction.h +++ b/webrtc/modules/rtp_rtcp/source/forward_error_correction.h @@ -49,7 +49,7 @@ class ForwardErrorCorrection { // reaches zero. virtual int32_t Release(); - uint16_t length; // Length of packet in bytes. + size_t length; // Length of packet in bytes. uint8_t data[IP_PACKET_SIZE]; // Packet data. private: @@ -200,7 +200,7 @@ class ForwardErrorCorrection { // Gets the size in bytes of the FEC/ULP headers, which must be accounted for // as packet overhead. // \return Packet overhead in bytes. - static uint16_t PacketOverhead(); + static size_t PacketOverhead(); // Reset internal states from last frame and clear the recovered_packet_list. // Frees all memory allocated by this class. diff --git a/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc index b852205cc1..d6e557d67b 100644 --- a/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc @@ -40,7 +40,7 @@ class VerifyingRtxReceiver : public NullRtpData virtual int32_t OnReceivedPayloadData( const uint8_t* data, - const uint16_t size, + const size_t size, const webrtc::WebRtcRTPHeader* rtp_header) OVERRIDE { if (!sequence_numbers_.empty()) EXPECT_EQ(kTestSsrc, rtp_header->header.ssrc); @@ -95,7 +95,7 @@ class RtxLoopBackTransport : public webrtc::Transport { packet_loss_ = 0; } - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE { count_++; const unsigned char* ptr = static_cast(data); uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; @@ -105,13 +105,13 @@ class RtxLoopBackTransport : public webrtc::Transport { sequence_number); if (packet_loss_ > 0) { if ((count_ % packet_loss_) == 0) { - return len; + return static_cast(len); } } else if (count_ >= consecutive_drop_start_ && count_ < consecutive_drop_end_) { - return len; + return static_cast(len); } - int packet_length = len; + size_t packet_length = len; // TODO(pbos): Figure out why this needs to be initialized. Likely this // is hiding a bug either in test setup or other code. // https://code.google.com/p/webrtc/issues/detail?id=3183 @@ -143,12 +143,14 @@ class RtxLoopBackTransport : public webrtc::Transport { true)) { return -1; } - return len; + return static_cast(len); } - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE { if (module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0) { - return len; + return static_cast(len); } return -1; } @@ -214,7 +216,7 @@ class RtpRtcpRtxNackTest : public ::testing::Test { 0, video_codec.maxBitrate)); - for (int n = 0; n < payload_data_length; n++) { + for (size_t n = 0; n < payload_data_length; n++) { payload_data[n] = n % 10; } } @@ -292,7 +294,7 @@ class RtpRtcpRtxNackTest : public ::testing::Test { RtxLoopBackTransport transport_; VerifyingRtxReceiver receiver_; uint8_t payload_data[65000]; - int payload_data_length; + size_t payload_data_length; SimulatedClock fake_clock; }; diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.cc b/webrtc/modules/rtp_rtcp/source/producer_fec.cc index 747cd89e9c..a571a0130b 100644 --- a/webrtc/modules/rtp_rtcp/source/producer_fec.cc +++ b/webrtc/modules/rtp_rtcp/source/producer_fec.cc @@ -36,7 +36,7 @@ struct RtpPacket { ForwardErrorCorrection::Packet* pkt; }; -RedPacket::RedPacket(int length) +RedPacket::RedPacket(size_t length) : data_(new uint8_t[length]), length_(length), header_length_(0) { @@ -46,7 +46,7 @@ RedPacket::~RedPacket() { delete [] data_; } -void RedPacket::CreateHeader(const uint8_t* rtp_header, int header_length, +void RedPacket::CreateHeader(const uint8_t* rtp_header, size_t header_length, int red_pl_type, int pl_type) { assert(header_length + kREDForFECHeaderLength <= length_); memcpy(data_, rtp_header, header_length); @@ -64,7 +64,7 @@ void RedPacket::SetSeqNum(int seq_num) { RtpUtility::AssignUWord16ToBuffer(&data_[2], seq_num); } -void RedPacket::AssignPayload(const uint8_t* payload, int length) { +void RedPacket::AssignPayload(const uint8_t* payload, size_t length) { assert(header_length_ + length <= length_); memcpy(data_ + header_length_, payload, length); } @@ -77,7 +77,7 @@ uint8_t* RedPacket::data() const { return data_; } -int RedPacket::length() const { +size_t RedPacket::length() const { return length_; } @@ -120,8 +120,8 @@ void ProducerFec::SetFecParameters(const FecProtectionParams* params, } RedPacket* ProducerFec::BuildRedPacket(const uint8_t* data_buffer, - int payload_length, - int rtp_header_length, + size_t payload_length, + size_t rtp_header_length, int red_pl_type) { RedPacket* red_packet = new RedPacket(payload_length + kREDForFECHeaderLength + @@ -134,8 +134,8 @@ RedPacket* ProducerFec::BuildRedPacket(const uint8_t* data_buffer, } int ProducerFec::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, - int payload_length, - int rtp_header_length) { + size_t payload_length, + size_t rtp_header_length) { assert(fec_packets_.empty()); if (media_packets_fec_.empty()) { params_ = new_params_; @@ -210,7 +210,7 @@ bool ProducerFec::FecAvailable() const { RedPacket* ProducerFec::GetFecPacket(int red_pl_type, int fec_pl_type, uint16_t seq_num, - int rtp_header_length) { + size_t rtp_header_length) { if (fec_packets_.empty()) return NULL; // Build FEC packet. The FEC packets in |fec_packets_| doesn't diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.h b/webrtc/modules/rtp_rtcp/source/producer_fec.h index e3f9d1dfe2..ec58bcf629 100644 --- a/webrtc/modules/rtp_rtcp/source/producer_fec.h +++ b/webrtc/modules/rtp_rtcp/source/producer_fec.h @@ -21,20 +21,20 @@ struct RtpPacket; class RedPacket { public: - explicit RedPacket(int length); + explicit RedPacket(size_t length); ~RedPacket(); - void CreateHeader(const uint8_t* rtp_header, int header_length, + void CreateHeader(const uint8_t* rtp_header, size_t header_length, int red_pl_type, int pl_type); void SetSeqNum(int seq_num); - void AssignPayload(const uint8_t* payload, int length); + void AssignPayload(const uint8_t* payload, size_t length); void ClearMarkerBit(); uint8_t* data() const; - int length() const; + size_t length() const; private: uint8_t* data_; - int length_; - int header_length_; + size_t length_; + size_t header_length_; }; class ProducerFec { @@ -46,13 +46,13 @@ class ProducerFec { int max_fec_frames); RedPacket* BuildRedPacket(const uint8_t* data_buffer, - int payload_length, - int rtp_header_length, + size_t payload_length, + size_t rtp_header_length, int red_pl_type); int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, - int payload_length, - int rtp_header_length); + size_t payload_length, + size_t rtp_header_length); bool ExcessOverheadBelowMax(); @@ -63,7 +63,7 @@ class ProducerFec { RedPacket* GetFecPacket(int red_pl_type, int fec_pl_type, uint16_t seq_num, - int rtp_header_length); + size_t rtp_header_length); private: void DeletePackets(); diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc b/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc index baa3827949..d8b67a7628 100644 --- a/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc @@ -23,7 +23,7 @@ void VerifyHeader(uint16_t seq_num, int fec_pltype, RedPacket* packet, bool marker_bit) { - EXPECT_GT(packet->length(), static_cast(kRtpHeaderSize)); + EXPECT_GT(packet->length(), kRtpHeaderSize); EXPECT_TRUE(packet->data() != NULL); uint8_t* data = packet->data(); // Marker bit not set. diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc index f063ce38e2..eeb6e3176d 100644 --- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc +++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc @@ -123,7 +123,7 @@ void StreamStatisticianImpl::UpdateCounters(const RTPHeader& header, last_receive_time_ms_ = clock_->TimeInMilliseconds(); } - uint16_t packet_oh = header.headerLength + header.paddingLength; + size_t packet_oh = header.headerLength + header.paddingLength; // Our measured overhead. Filter from RFC 5104 4.2.1.2: // avg_OH (new) = 15/16*avg_OH (old) + 1/16*pckt_OH, @@ -303,7 +303,7 @@ RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics() { } void StreamStatisticianImpl::GetDataCounters( - uint32_t* bytes_received, uint32_t* packets_received) const { + size_t* bytes_received, uint32_t* packets_received) const { CriticalSectionScoped cs(stream_lock_.get()); if (bytes_received) { *bytes_received = receive_counters_.bytes + receive_counters_.header_bytes + diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h index 40ca285742..bef856fa35 100644 --- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h +++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h @@ -31,7 +31,7 @@ class StreamStatisticianImpl : public StreamStatistician { virtual ~StreamStatisticianImpl() {} virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) OVERRIDE; - virtual void GetDataCounters(uint32_t* bytes_received, + virtual void GetDataCounters(size_t* bytes_received, uint32_t* packets_received) const OVERRIDE; virtual uint32_t BitrateReceived() const OVERRIDE; virtual void ResetStatistics() OVERRIDE; @@ -80,7 +80,7 @@ class StreamStatisticianImpl : public StreamStatistician { uint16_t received_seq_wraps_; // Current counter values. - uint16_t received_packet_overhead_; + size_t received_packet_overhead_; StreamDataCounters receive_counters_; // Counter values when we sent the last report. diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc index 5b4d0ddd2d..808a88028b 100644 --- a/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc @@ -16,8 +16,8 @@ namespace webrtc { -const int kPacketSize1 = 100; -const int kPacketSize2 = 300; +const size_t kPacketSize1 = 100; +const size_t kPacketSize2 = 300; const uint32_t kSsrc1 = 1; const uint32_t kSsrc2 = 2; @@ -56,7 +56,7 @@ TEST_F(ReceiveStatisticsTest, TwoIncomingSsrcs) { receive_statistics_->GetStatistician(kSsrc1); ASSERT_TRUE(statistician != NULL); EXPECT_GT(statistician->BitrateReceived(), 0u); - uint32_t bytes_received = 0; + size_t bytes_received = 0; uint32_t packets_received = 0; statistician->GetDataCounters(&bytes_received, &packets_received); EXPECT_EQ(200u, bytes_received); @@ -125,7 +125,7 @@ TEST_F(ReceiveStatisticsTest, ActiveStatisticians) { StreamStatistician* statistician = receive_statistics_->GetStatistician(kSsrc1); ASSERT_TRUE(statistician != NULL); - uint32_t bytes_received = 0; + size_t bytes_received = 0; uint32_t packets_received = 0; statistician->GetDataCounters(&bytes_received, &packets_received); EXPECT_EQ(200u, bytes_received); @@ -234,8 +234,8 @@ class RtpTestCallback : public StreamDataCountersCallback { void ExpectMatches(uint32_t num_calls, uint32_t ssrc, - uint32_t bytes, - uint32_t padding, + size_t bytes, + size_t padding, uint32_t packets, uint32_t retransmits, uint32_t fec) { @@ -257,8 +257,8 @@ TEST_F(ReceiveStatisticsTest, RtpCallbacks) { RtpTestCallback callback; receive_statistics_->RegisterRtpStatisticsCallback(&callback); - const uint32_t kHeaderLength = 20; - const uint32_t kPaddingLength = 9; + const size_t kHeaderLength = 20; + const size_t kPaddingLength = 9; // One packet of size kPacketSize1. header1_.headerLength = kHeaderLength; diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc index 17671b70cf..6a7b7f9718 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc @@ -32,14 +32,14 @@ class TestTransport : public Transport { virtual int SendPacket(int /*channel*/, const void* /*data*/, - int /*len*/) OVERRIDE { + size_t /*len*/) OVERRIDE { return -1; } virtual int SendRTCPPacket(int /*channel*/, const void *packet, - int packetLength) OVERRIDE { + size_t packetLength) OVERRIDE { RTCPUtility::RTCPParserV2 rtcpParser((uint8_t*)packet, - (int32_t)packetLength, + packetLength, true); // Allow non-compound RTCP EXPECT_TRUE(rtcpParser.IsValid()); @@ -51,7 +51,7 @@ class TestTransport : public Transport { rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRemb); EXPECT_EQ((uint32_t)1234, rtcpPacketInformation.receiverEstimatedMaxBitrate); - return packetLength; + return static_cast(packetLength); } private: RTCPReceiver* rtcp_receiver_; diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index 2a615734ed..d65157d65a 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -41,7 +41,7 @@ class TestTransport : public Transport, } virtual int SendPacket(int /*ch*/, const void* /*data*/, - int /*len*/) OVERRIDE { + size_t /*len*/) OVERRIDE { ADD_FAILURE(); // FAIL() gives a compile error. return -1; } @@ -49,13 +49,13 @@ class TestTransport : public Transport, // Injects an RTCP packet into the receiver. virtual int SendRTCPPacket(int /* ch */, const void *packet, - int packet_len) OVERRIDE { + size_t packet_len) OVERRIDE { ADD_FAILURE(); return 0; } virtual int OnReceivedPayloadData(const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const WebRtcRTPHeader* rtpHeader) OVERRIDE { ADD_FAILURE(); return 0; diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc index 1752ab952a..9991992bc3 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -1633,7 +1633,7 @@ int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, { return -1; } - return SendToNetwork(rtcp_buffer, static_cast(rtcp_length)); + return SendToNetwork(rtcp_buffer, static_cast(rtcp_length)); } int RTCPSender::PrepareRTCP(const FeedbackState& feedback_state, @@ -2000,7 +2000,7 @@ bool RTCPSender::PrepareReport(const FeedbackState& feedback_state, int32_t RTCPSender::SendToNetwork(const uint8_t* dataBuffer, - const uint16_t length) + const size_t length) { CriticalSectionScoped lock(_criticalSectionTransport); if(_cbTransport) diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h index 668c7c772b..23f720fcf3 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h @@ -56,7 +56,7 @@ public: uint8_t send_payload_type; uint32_t frequency_hz; uint32_t packets_sent; - uint32_t media_bytes_sent; + size_t media_bytes_sent; uint32_t send_bitrate; uint32_t last_rr_ntp_secs; @@ -177,7 +177,7 @@ public: void GetPacketTypeCounter(RtcpPacketTypeCounter* packet_counter) const; private: - int32_t SendToNetwork(const uint8_t* dataBuffer, const uint16_t length); + int32_t SendToNetwork(const uint8_t* dataBuffer, const size_t length); int32_t WriteAllReportBlocksToBuffer(uint8_t* rtcpbuffer, int pos, diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc index 44d4a2b727..a72fe58ec6 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc @@ -188,7 +188,7 @@ TEST(NACKStringBuilderTest, TestCase13) { void CreateRtpPacket(const bool marker_bit, const uint8_t payload, const uint16_t seq_num, const uint32_t timestamp, const uint32_t ssrc, uint8_t* array, - uint16_t* cur_pos) { + size_t* cur_pos) { ASSERT_TRUE(payload <= 127); array[(*cur_pos)++] = 0x80; array[(*cur_pos)++] = payload | (marker_bit ? 0x80 : 0); @@ -229,15 +229,15 @@ class TestTransport : public Transport, } virtual int SendPacket(int /*ch*/, const void* /*data*/, - int /*len*/) OVERRIDE { + size_t /*len*/) OVERRIDE { return -1; } virtual int SendRTCPPacket(int /*ch*/, const void *packet, - int packet_len) OVERRIDE { + size_t packet_len) OVERRIDE { RTCPUtility::RTCPParserV2 rtcpParser((uint8_t*)packet, - (int32_t)packet_len, + packet_len, true); // Allow non-compound RTCP EXPECT_TRUE(rtcpParser.IsValid()); @@ -262,11 +262,11 @@ class TestTransport : public Transport, rtcp_packet_info_.ntp_frac = rtcpPacketInformation.ntp_frac; rtcp_packet_info_.rtp_timestamp = rtcpPacketInformation.rtp_timestamp; - return packet_len; + return static_cast(packet_len); } virtual int OnReceivedPayloadData(const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const WebRtcRTPHeader* rtpHeader) OVERRIDE { return 0; } @@ -357,10 +357,10 @@ TEST_F(RtcpSenderTest, TestCompound) { const uint16_t seq_num = 11111; const uint32_t timestamp = 1234567; const uint32_t ssrc = 0x11111111; - uint16_t packet_length = 0; + size_t packet_length = 0; CreateRtpPacket(marker_bit, payload, seq_num, timestamp, ssrc, packet_, &packet_length); - EXPECT_EQ(25, packet_length); + EXPECT_EQ(25u, packet_length); VideoCodec codec_inst; strncpy(codec_inst.plName, "VP8", webrtc::kPayloadNameSize - 1); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc index 9d19fde1a6..5a3eb392af 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc @@ -896,7 +896,7 @@ int RtpFecTest::ConstructMediaPacketsSeqNum(int num_media_packets, for (int i = 0; i < num_media_packets; ++i) { media_packet = new ForwardErrorCorrection::Packet; media_packet_list_.push_back(media_packet); - media_packet->length = static_cast( + media_packet->length = static_cast( (static_cast(rand()) / RAND_MAX) * (IP_PACKET_SIZE - kRtpHeaderSize - kTransportOverhead - ForwardErrorCorrection::PacketOverhead())); @@ -928,7 +928,7 @@ int RtpFecTest::ConstructMediaPacketsSeqNum(int num_media_packets, webrtc::RtpUtility::AssignUWord32ToBuffer(&media_packet->data[8], ssrc_); // Generate random values for payload. - for (int j = 12; j < media_packet->length; ++j) { + for (size_t j = 12; j < media_packet->length; ++j) { media_packet->data[j] = static_cast(rand() % 256); } sequence_number++; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc index ab210ecb19..1fa288acad 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc @@ -36,7 +36,7 @@ void RtpPacketizerGeneric::SetPayloadData( payload_size_ = payload_size; // Fragment packets more evenly by splitting the payload up evenly. - uint32_t num_packets = + size_t num_packets = (payload_size_ + max_payload_len_ - 1) / max_payload_len_; payload_length_ = (payload_size_ + num_packets - 1) / num_packets; assert(payload_length_ <= max_payload_len_); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h index 491cab5c53..2fd6aad1b8 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h @@ -57,7 +57,7 @@ class RtpPacketizerGeneric : public RtpPacketizer { size_t payload_size_; const size_t max_payload_len_; FrameType frame_type_; - uint32_t payload_length_; + size_t payload_length_; uint8_t generic_header_; DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc index d74e04f8eb..57ff74fe26 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc @@ -22,17 +22,17 @@ namespace webrtc { namespace { int ParseVP8PictureID(RTPVideoHeaderVP8* vp8, const uint8_t** data, - int* data_length, - int* parsed_bytes) { + size_t* data_length, + size_t* parsed_bytes) { assert(vp8 != NULL); - if (*data_length <= 0) + if (*data_length == 0) return -1; vp8->pictureId = (**data & 0x7F); if (**data & 0x80) { (*data)++; (*parsed_bytes)++; - if (--(*data_length) <= 0) + if (--(*data_length) == 0) return -1; // PictureId is 15 bits vp8->pictureId = (vp8->pictureId << 8) + **data; @@ -45,10 +45,10 @@ int ParseVP8PictureID(RTPVideoHeaderVP8* vp8, int ParseVP8Tl0PicIdx(RTPVideoHeaderVP8* vp8, const uint8_t** data, - int* data_length, - int* parsed_bytes) { + size_t* data_length, + size_t* parsed_bytes) { assert(vp8 != NULL); - if (*data_length <= 0) + if (*data_length == 0) return -1; vp8->tl0PicIdx = **data; @@ -60,12 +60,12 @@ int ParseVP8Tl0PicIdx(RTPVideoHeaderVP8* vp8, int ParseVP8TIDAndKeyIdx(RTPVideoHeaderVP8* vp8, const uint8_t** data, - int* data_length, - int* parsed_bytes, + size_t* data_length, + size_t* parsed_bytes, bool has_tid, bool has_key_idx) { assert(vp8 != NULL); - if (*data_length <= 0) + if (*data_length == 0) return -1; if (has_tid) { @@ -83,11 +83,10 @@ int ParseVP8TIDAndKeyIdx(RTPVideoHeaderVP8* vp8, int ParseVP8Extension(RTPVideoHeaderVP8* vp8, const uint8_t* data, - int data_length) { + size_t data_length) { assert(vp8 != NULL); - int parsed_bytes = 0; - if (data_length <= 0) - return -1; + assert(data_length > 0); + size_t parsed_bytes = 0; // Optional X field is present. bool has_picture_id = (*data & 0x80) ? true : false; // I bit bool has_tl0_pic_idx = (*data & 0x40) ? true : false; // L bit @@ -118,12 +117,12 @@ int ParseVP8Extension(RTPVideoHeaderVP8* vp8, return -1; } } - return parsed_bytes; + return static_cast(parsed_bytes); } int ParseVP8FrameSize(RtpDepacketizer::ParsedPayload* parsed_payload, const uint8_t* data, - int data_length) { + size_t data_length) { assert(parsed_payload != NULL); if (parsed_payload->frame_type != kVideoFrameKey) { // Included in payload header for I-frames. @@ -149,7 +148,7 @@ const bool RtpPacketizerVp8::separate_first_modes_[kNumModes] = {true, false, false}; RtpPacketizerVp8::RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, - int max_payload_len, + size_t max_payload_len, VP8PacketizerMode mode) : payload_data_(NULL), payload_size_(0), @@ -164,7 +163,7 @@ RtpPacketizerVp8::RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, } RtpPacketizerVp8::RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, - int max_payload_len) + size_t max_payload_len) : payload_data_(NULL), payload_size_(0), part_info_(), @@ -222,7 +221,7 @@ bool RtpPacketizerVp8::NextPacket(uint8_t* buffer, if (bytes < 0) { return false; } - *bytes_to_send = bytes; + *bytes_to_send = static_cast(bytes); *last_packet = packets_.empty(); return true; @@ -251,9 +250,9 @@ std::string RtpPacketizerVp8::ToString() { return "RtpPacketizerVp8"; } -int RtpPacketizerVp8::CalcNextSize(int max_payload_len, - int remaining_bytes, - bool split_payload) const { +size_t RtpPacketizerVp8::CalcNextSize(size_t max_payload_len, + size_t remaining_bytes, + bool split_payload) const { if (max_payload_len == 0 || remaining_bytes == 0) { return 0; } @@ -265,10 +264,10 @@ int RtpPacketizerVp8::CalcNextSize(int max_payload_len, // Balance payload sizes to produce (almost) equal size // fragments. // Number of fragments for remaining_bytes: - int num_frags = remaining_bytes / max_payload_len + 1; + size_t num_frags = remaining_bytes / max_payload_len + 1; // Number of bytes in this fragment: - return static_cast(static_cast(remaining_bytes) / num_frags + - 0.5); + return static_cast( + static_cast(remaining_bytes) / num_frags + 0.5); } else { return max_payload_len >= remaining_bytes ? remaining_bytes : max_payload_len; @@ -282,22 +281,22 @@ int RtpPacketizerVp8::GeneratePackets() { // descriptor and one payload byte. Return an error. return -1; } - int total_bytes_processed = 0; + size_t total_bytes_processed = 0; bool start_on_new_fragment = true; bool beginning = true; - int part_ix = 0; + size_t part_ix = 0; while (total_bytes_processed < payload_size_) { - int packet_bytes = 0; // How much data to send in this packet. + size_t packet_bytes = 0; // How much data to send in this packet. bool split_payload = true; // Splitting of partitions is initially allowed. - int remaining_in_partition = part_info_.fragmentationOffset[part_ix] - + size_t remaining_in_partition = part_info_.fragmentationOffset[part_ix] - total_bytes_processed + part_info_.fragmentationLength[part_ix]; - int rem_payload_len = + size_t rem_payload_len = max_payload_len_ - (vp8_fixed_payload_descriptor_bytes_ + PayloadDescriptorExtraLength()); - int first_partition_in_packet = part_ix; + size_t first_partition_in_packet = part_ix; - while (int next_size = CalcNextSize( + while (size_t next_size = CalcNextSize( rem_payload_len, remaining_in_partition, split_payload)) { packet_bytes += next_size; rem_payload_len -= next_size; @@ -348,44 +347,44 @@ int RtpPacketizerVp8::GeneratePacketsBalancedAggregates() { return -1; } std::vector partition_decision; - const int overhead = + const size_t overhead = vp8_fixed_payload_descriptor_bytes_ + PayloadDescriptorExtraLength(); - const uint32_t max_payload_len = max_payload_len_ - overhead; + const size_t max_payload_len = max_payload_len_ - overhead; int min_size, max_size; AggregateSmallPartitions(&partition_decision, &min_size, &max_size); - int total_bytes_processed = 0; - int part_ix = 0; + size_t total_bytes_processed = 0; + size_t part_ix = 0; while (part_ix < num_partitions_) { if (partition_decision[part_ix] == -1) { // Split large partitions. - int remaining_partition = part_info_.fragmentationLength[part_ix]; - int num_fragments = Vp8PartitionAggregator::CalcNumberOfFragments( + size_t remaining_partition = part_info_.fragmentationLength[part_ix]; + size_t num_fragments = Vp8PartitionAggregator::CalcNumberOfFragments( remaining_partition, max_payload_len, overhead, min_size, max_size); - const int packet_bytes = + const size_t packet_bytes = (remaining_partition + num_fragments - 1) / num_fragments; - for (int n = 0; n < num_fragments; ++n) { - const int this_packet_bytes = packet_bytes < remaining_partition - ? packet_bytes - : remaining_partition; + for (size_t n = 0; n < num_fragments; ++n) { + const size_t this_packet_bytes = packet_bytes < remaining_partition + ? packet_bytes + : remaining_partition; QueuePacket( total_bytes_processed, this_packet_bytes, part_ix, (n == 0)); remaining_partition -= this_packet_bytes; total_bytes_processed += this_packet_bytes; - if (this_packet_bytes < min_size) { + if (static_cast(this_packet_bytes) < min_size) { min_size = this_packet_bytes; } - if (this_packet_bytes > max_size) { + if (static_cast(this_packet_bytes) > max_size) { max_size = this_packet_bytes; } } assert(remaining_partition == 0); ++part_ix; } else { - int this_packet_bytes = 0; - const int first_partition_in_packet = part_ix; + size_t this_packet_bytes = 0; + const size_t first_partition_in_packet = part_ix; const int aggregation_index = partition_decision[part_ix]; - while (static_cast(part_ix) < partition_decision.size() && + while (part_ix < partition_decision.size() && partition_decision[part_ix] == aggregation_index) { // Collect all partitions that were aggregated into the same packet. this_packet_bytes += part_info_.fragmentationLength[part_ix]; @@ -410,11 +409,11 @@ void RtpPacketizerVp8::AggregateSmallPartitions(std::vector* partition_vec, *max_size = -1; assert(partition_vec); partition_vec->assign(num_partitions_, -1); - const int overhead = + const size_t overhead = vp8_fixed_payload_descriptor_bytes_ + PayloadDescriptorExtraLength(); - const uint32_t max_payload_len = max_payload_len_ - overhead; - int first_in_set = 0; - int last_in_set = 0; + const size_t max_payload_len = max_payload_len_ - overhead; + size_t first_in_set = 0; + size_t last_in_set = 0; int num_aggregate_packets = 0; // Find sets of partitions smaller than max_payload_len_. while (first_in_set < num_partitions_) { @@ -434,7 +433,7 @@ void RtpPacketizerVp8::AggregateSmallPartitions(std::vector* partition_vec, Vp8PartitionAggregator::ConfigVec optimal_config = aggregator.FindOptimalConfiguration(max_payload_len, overhead); aggregator.CalcMinMax(optimal_config, min_size, max_size); - for (int i = first_in_set, j = 0; i <= last_in_set; ++i, ++j) { + for (size_t i = first_in_set, j = 0; i <= last_in_set; ++i, ++j) { // Transfer configuration for this set of partitions to the joint // partition vector representing all partitions in the frame. (*partition_vec)[i] = num_aggregate_packets + optimal_config[j]; @@ -446,9 +445,9 @@ void RtpPacketizerVp8::AggregateSmallPartitions(std::vector* partition_vec, } } -void RtpPacketizerVp8::QueuePacket(int start_pos, - int packet_size, - int first_partition_in_packet, +void RtpPacketizerVp8::QueuePacket(size_t start_pos, + size_t packet_size, + size_t first_partition_in_packet, bool start_on_new_fragment) { // Write info to packet info struct and store in packet info queue. InfoStruct packet_info; @@ -461,7 +460,7 @@ void RtpPacketizerVp8::QueuePacket(int start_pos, int RtpPacketizerVp8::WriteHeaderAndPayload(const InfoStruct& packet_info, uint8_t* buffer, - int buffer_length) const { + size_t buffer_length) const { // Write the VP8 payload descriptor. // 0 // 0 1 2 3 4 5 6 7 8 @@ -488,6 +487,8 @@ int RtpPacketizerVp8::WriteHeaderAndPayload(const InfoStruct& packet_info, buffer[0] |= (packet_info.first_partition_ix & kPartIdField); const int extension_length = WriteExtensionFields(buffer, buffer_length); + if (extension_length < 0) + return -1; memcpy(&buffer[vp8_fixed_payload_descriptor_bytes_ + extension_length], &payload_data_[packet_info.payload_start_pos], @@ -499,8 +500,8 @@ int RtpPacketizerVp8::WriteHeaderAndPayload(const InfoStruct& packet_info, } int RtpPacketizerVp8::WriteExtensionFields(uint8_t* buffer, - int buffer_length) const { - int extension_length = 0; + size_t buffer_length) const { + size_t extension_length = 0; if (XFieldPresent()) { uint8_t* x_field = buffer + vp8_fixed_payload_descriptor_bytes_; *x_field = 0; @@ -525,14 +526,16 @@ int RtpPacketizerVp8::WriteExtensionFields(uint8_t* buffer, } assert(extension_length == PayloadDescriptorExtraLength()); } - return extension_length; + return static_cast(extension_length); } int RtpPacketizerVp8::WritePictureIDFields(uint8_t* x_field, uint8_t* buffer, - int buffer_length, - int* extension_length) const { + size_t buffer_length, + size_t* extension_length) const { *x_field |= kIBit; + assert(buffer_length >= + vp8_fixed_payload_descriptor_bytes_ + *extension_length); const int pic_id_length = WritePictureID( buffer + vp8_fixed_payload_descriptor_bytes_ + *extension_length, buffer_length - vp8_fixed_payload_descriptor_bytes_ - *extension_length); @@ -542,9 +545,10 @@ int RtpPacketizerVp8::WritePictureIDFields(uint8_t* x_field, return 0; } -int RtpPacketizerVp8::WritePictureID(uint8_t* buffer, int buffer_length) const { +int RtpPacketizerVp8::WritePictureID(uint8_t* buffer, + size_t buffer_length) const { const uint16_t pic_id = static_cast(hdr_info_.pictureId); - int picture_id_len = PictureIdLength(); + size_t picture_id_len = PictureIdLength(); if (picture_id_len > buffer_length) return -1; if (picture_id_len == 2) { @@ -553,13 +557,13 @@ int RtpPacketizerVp8::WritePictureID(uint8_t* buffer, int buffer_length) const { } else if (picture_id_len == 1) { buffer[0] = pic_id & 0x7F; } - return picture_id_len; + return static_cast(picture_id_len); } int RtpPacketizerVp8::WriteTl0PicIdxFields(uint8_t* x_field, uint8_t* buffer, - int buffer_length, - int* extension_length) const { + size_t buffer_length, + size_t* extension_length) const { if (buffer_length < vp8_fixed_payload_descriptor_bytes_ + *extension_length + 1) { return -1; @@ -573,8 +577,8 @@ int RtpPacketizerVp8::WriteTl0PicIdxFields(uint8_t* x_field, int RtpPacketizerVp8::WriteTIDAndKeyIdxFields(uint8_t* x_field, uint8_t* buffer, - int buffer_length, - int* extension_length) const { + size_t buffer_length, + size_t* extension_length) const { if (buffer_length < vp8_fixed_payload_descriptor_bytes_ + *extension_length + 1) { return -1; @@ -596,8 +600,8 @@ int RtpPacketizerVp8::WriteTIDAndKeyIdxFields(uint8_t* x_field, return 0; } -int RtpPacketizerVp8::PayloadDescriptorExtraLength() const { - int length_bytes = PictureIdLength(); +size_t RtpPacketizerVp8::PayloadDescriptorExtraLength() const { + size_t length_bytes = PictureIdLength(); if (TL0PicIdxFieldPresent()) ++length_bytes; if (TIDFieldPresent() || KeyIdxFieldPresent()) @@ -607,7 +611,7 @@ int RtpPacketizerVp8::PayloadDescriptorExtraLength() const { return length_bytes; } -int RtpPacketizerVp8::PictureIdLength() const { +size_t RtpPacketizerVp8::PictureIdLength() const { if (hdr_info_.pictureId == kNoPictureId) { return 0; } @@ -693,6 +697,10 @@ bool RtpDepacketizerVp8::Parse(ParsedPayload* parsed_payload, // Advance payload_data and decrease remaining payload size. payload_data++; + if (payload_data_length <= 1) { + LOG(LS_ERROR) << "Error parsing VP8 payload descriptor!"; + return false; + } payload_data_length--; if (extension) { @@ -704,15 +712,14 @@ bool RtpDepacketizerVp8::Parse(ParsedPayload* parsed_payload, return false; payload_data += parsed_bytes; payload_data_length -= parsed_bytes; - } - - if (payload_data_length <= 0) { - LOG(LS_ERROR) << "Error parsing VP8 payload descriptor!"; - return false; + if (payload_data_length == 0) { + LOG(LS_ERROR) << "Error parsing VP8 payload descriptor!"; + return false; + } } // Read P bit from payload header (only at beginning of first partition). - if (payload_data_length > 0 && beginning_of_partition && partition_id == 0) { + if (beginning_of_partition && partition_id == 0) { parsed_payload->frame_type = (*payload_data & 0x01) ? kVideoFrameDelta : kVideoFrameKey; } else { diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h index 4b7a6a2b9c..dab7921b09 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h @@ -51,12 +51,12 @@ class RtpPacketizerVp8 : public RtpPacketizer { // Initialize with payload from encoder and fragmentation info. // The payload_data must be exactly one encoded VP8 frame. RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, - int max_payload_len, + size_t max_payload_len, VP8PacketizerMode mode); // Initialize without fragmentation info. Mode kEqualSize will be used. // The payload_data must be exactly one encoded VP8 frame. - RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, int max_payload_len); + RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, size_t max_payload_len); virtual ~RtpPacketizerVp8(); @@ -88,10 +88,10 @@ class RtpPacketizerVp8 : public RtpPacketizer { private: typedef struct { - int payload_start_pos; - int size; + size_t payload_start_pos; + size_t size; bool first_fragment; - int first_partition_ix; + size_t first_partition_ix; } InfoStruct; typedef std::queue InfoQueue; enum AggregationMode { @@ -115,9 +115,9 @@ class RtpPacketizerVp8 : public RtpPacketizer { static const int kYBit = 0x20; // Calculate size of next chunk to send. Returns 0 if none can be sent. - int CalcNextSize(int max_payload_len, - int remaining_bytes, - bool split_payload) const; + size_t CalcNextSize(size_t max_payload_len, + size_t remaining_bytes, + bool split_payload) const; // Calculate all packet sizes and load to packet info queue. int GeneratePackets(); @@ -140,9 +140,9 @@ class RtpPacketizerVp8 : public RtpPacketizer { int* max_size); // Insert packet into packet queue. - void QueuePacket(int start_pos, - int packet_size, - int first_partition_in_packet, + void QueuePacket(size_t start_pos, + size_t packet_size, + size_t first_partition_in_packet, bool start_on_new_fragment); // Write the payload header and copy the payload to the buffer. @@ -150,47 +150,47 @@ class RtpPacketizerVp8 : public RtpPacketizer { // and what to write in the header fields. int WriteHeaderAndPayload(const InfoStruct& packet_info, uint8_t* buffer, - int buffer_length) const; + size_t buffer_length) const; // Write the X field and the appropriate extension fields to buffer. // The function returns the extension length (including X field), or -1 // on error. - int WriteExtensionFields(uint8_t* buffer, int buffer_length) const; + int WriteExtensionFields(uint8_t* buffer, size_t buffer_length) const; // Set the I bit in the x_field, and write PictureID to the appropriate // position in buffer. The function returns 0 on success, -1 otherwise. int WritePictureIDFields(uint8_t* x_field, uint8_t* buffer, - int buffer_length, - int* extension_length) const; + size_t buffer_length, + size_t* extension_length) const; // Set the L bit in the x_field, and write Tl0PicIdx to the appropriate // position in buffer. The function returns 0 on success, -1 otherwise. int WriteTl0PicIdxFields(uint8_t* x_field, uint8_t* buffer, - int buffer_length, - int* extension_length) const; + size_t buffer_length, + size_t* extension_length) const; // Set the T and K bits in the x_field, and write TID, Y and KeyIdx to the // appropriate position in buffer. The function returns 0 on success, // -1 otherwise. int WriteTIDAndKeyIdxFields(uint8_t* x_field, uint8_t* buffer, - int buffer_length, - int* extension_length) const; + size_t buffer_length, + size_t* extension_length) const; // Write the PictureID from codec_specific_info_ to buffer. One or two // bytes are written, depending on magnitude of PictureID. The function // returns the number of bytes written. - int WritePictureID(uint8_t* buffer, int buffer_length) const; + int WritePictureID(uint8_t* buffer, size_t buffer_length) const; // Calculate and return length (octets) of the variable header fields in // the next header (i.e., header length in addition to vp8_header_bytes_). - int PayloadDescriptorExtraLength() const; + size_t PayloadDescriptorExtraLength() const; // Calculate and return length (octets) of PictureID field in the next // header. Can be 0, 1, or 2. - int PictureIdLength() const; + size_t PictureIdLength() const; // Check whether each of the optional fields will be included in the header. bool XFieldPresent() const; @@ -200,16 +200,16 @@ class RtpPacketizerVp8 : public RtpPacketizer { bool PictureIdPresent() const { return (PictureIdLength() > 0); } const uint8_t* payload_data_; - int payload_size_; + size_t payload_size_; RTPFragmentationHeader part_info_; - const int vp8_fixed_payload_descriptor_bytes_; // Length of VP8 payload - // descriptors's fixed part. + const size_t vp8_fixed_payload_descriptor_bytes_; // Length of VP8 payload + // descriptors' fixed part. const AggregationMode aggr_mode_; const bool balance_; const bool separate_first_; const RTPVideoHeaderVP8 hdr_info_; - int num_partitions_; - const int max_payload_len_; + size_t num_partitions_; + const size_t max_payload_len_; InfoQueue packets_; bool packets_calculated_; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc index 549512b348..a62f4969c9 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc @@ -35,25 +35,25 @@ RtpFormatVp8TestHelper::~RtpFormatVp8TestHelper() { delete [] buffer_; } -bool RtpFormatVp8TestHelper::Init(const int* partition_sizes, - int num_partitions) { +bool RtpFormatVp8TestHelper::Init(const size_t* partition_sizes, + size_t num_partitions) { if (inited_) return false; fragmentation_ = new RTPFragmentationHeader; fragmentation_->VerifyAndAllocateFragmentationHeader(num_partitions); payload_size_ = 0; // Calculate sum payload size. - for (int p = 0; p < num_partitions; ++p) { + for (size_t p = 0; p < num_partitions; ++p) { payload_size_ += partition_sizes[p]; } buffer_size_ = payload_size_ + 6; // Add space for payload descriptor. payload_data_ = new uint8_t[payload_size_]; buffer_ = new uint8_t[buffer_size_]; - int j = 0; + size_t j = 0; // Loop through the partitions again. - for (int p = 0; p < num_partitions; ++p) { + for (size_t p = 0; p < num_partitions; ++p) { fragmentation_->fragmentationLength[p] = partition_sizes[p]; fragmentation_->fragmentationOffset[p] = j; - for (int i = 0; i < partition_sizes[p]; ++i) { + for (size_t i = 0; i < partition_sizes[p]; ++i) { assert(j < payload_size_); payload_data_[j++] = p; // Set the payload value to the partition index. } @@ -65,14 +65,14 @@ bool RtpFormatVp8TestHelper::Init(const int* partition_sizes, void RtpFormatVp8TestHelper::GetAllPacketsAndCheck( RtpPacketizerVp8* packetizer, - const int* expected_sizes, + const size_t* expected_sizes, const int* expected_part, const bool* expected_frag_start, - int expected_num_packets) { + size_t expected_num_packets) { ASSERT_TRUE(inited_); size_t send_bytes = 0; bool last = false; - for (int i = 0; i < expected_num_packets; ++i) { + for (size_t i = 0; i < expected_num_packets; ++i) { std::ostringstream ss; ss << "Checking packet " << i; SCOPED_TRACE(ss.str()); @@ -222,8 +222,8 @@ void RtpFormatVp8TestHelper::CheckTIDAndKeyIdx() { // Verify that the payload (i.e., after the headers) of the packet stored in // buffer_ is identical to the expected (as found in data_ptr_). -void RtpFormatVp8TestHelper::CheckPayload(int payload_end) { - for (int i = payload_start_; i < payload_end; ++i, ++data_ptr_) +void RtpFormatVp8TestHelper::CheckPayload(size_t payload_end) { + for (size_t i = payload_start_; i < payload_end; ++i, ++data_ptr_) EXPECT_EQ(buffer_[i], *data_ptr_); } @@ -236,8 +236,8 @@ void RtpFormatVp8TestHelper::CheckLast(bool last) const { // Verify the contents of a packet. Check the length versus expected_bytes, // the header, payload, and "last" flag. -void RtpFormatVp8TestHelper::CheckPacket(int send_bytes, - int expect_bytes, +void RtpFormatVp8TestHelper::CheckPacket(size_t send_bytes, + size_t expect_bytes, bool last, bool frag_start) { EXPECT_EQ(expect_bytes, send_bytes); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h index 22e68036f6..2454fb70cc 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h @@ -31,17 +31,17 @@ class RtpFormatVp8TestHelper { public: explicit RtpFormatVp8TestHelper(const RTPVideoHeaderVP8* hdr); ~RtpFormatVp8TestHelper(); - bool Init(const int* partition_sizes, int num_partitions); + bool Init(const size_t* partition_sizes, size_t num_partitions); void GetAllPacketsAndCheck(RtpPacketizerVp8* packetizer, - const int* expected_sizes, + const size_t* expected_sizes, const int* expected_part, const bool* expected_frag_start, - int expected_num_packets); + size_t expected_num_packets); uint8_t* payload_data() const { return payload_data_; } - int payload_size() const { return payload_size_; } + size_t payload_size() const { return payload_size_; } RTPFragmentationHeader* fragmentation() const { return fragmentation_; } - int buffer_size() const { return buffer_size_; } + size_t buffer_size() const { return buffer_size_; } void set_sloppy_partitioning(bool value) { sloppy_partitioning_ = value; } private: @@ -49,9 +49,9 @@ class RtpFormatVp8TestHelper { void CheckPictureID(); void CheckTl0PicIdx(); void CheckTIDAndKeyIdx(); - void CheckPayload(int payload_end); + void CheckPayload(size_t payload_end); void CheckLast(bool last) const; - void CheckPacket(int send_bytes, int expect_bytes, bool last, + void CheckPacket(size_t send_bytes, size_t expect_bytes, bool last, bool frag_start); uint8_t* payload_data_; @@ -60,8 +60,8 @@ class RtpFormatVp8TestHelper { RTPFragmentationHeader* fragmentation_; const RTPVideoHeaderVP8* hdr_info_; int payload_start_; - int payload_size_; - int buffer_size_; + size_t payload_size_; + size_t buffer_size_; bool sloppy_partitioning_; bool inited_; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc index 4382ac2cb1..84b880daad 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc @@ -80,7 +80,7 @@ class RtpPacketizerVp8Test : public ::testing::Test { protected: RtpPacketizerVp8Test() : helper_(NULL) {} virtual void TearDown() { delete helper_; } - bool Init(const int* partition_sizes, int num_partitions) { + bool Init(const size_t* partition_sizes, size_t num_partitions) { hdr_info_.pictureId = kNoPictureId; hdr_info_.nonReference = false; hdr_info_.temporalIdx = kNoTemporalIdx; @@ -98,23 +98,23 @@ class RtpPacketizerVp8Test : public ::testing::Test { }; TEST_F(RtpPacketizerVp8Test, TestStrictMode) { - const int kSizeVector[] = {10, 8, 27}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {10, 8, 27}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.pictureId = 200; // > 0x7F should produce 2-byte PictureID. - const int kMaxSize = 13; + const size_t kMaxSize = 13; RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kStrict); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // The expected sizes are obtained by running a verified good implementation. - const int kExpectedSizes[] = {9, 9, 12, 11, 11, 11, 10}; + const size_t kExpectedSizes[] = {9, 9, 12, 11, 11, 11, 10}; const int kExpectedPart[] = {0, 0, 1, 2, 2, 2, 2}; const bool kExpectedFragStart[] = {true, false, true, true, false, false, false}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -126,22 +126,22 @@ TEST_F(RtpPacketizerVp8Test, TestStrictMode) { } TEST_F(RtpPacketizerVp8Test, TestAggregateMode) { - const int kSizeVector[] = {60, 10, 10}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {60, 10, 10}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. - const int kMaxSize = 25; + const size_t kMaxSize = 25; RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // The expected sizes are obtained by running a verified good implementation. - const int kExpectedSizes[] = {23, 23, 23, 23}; + const size_t kExpectedSizes[] = {23, 23, 23, 23}; const int kExpectedPart[] = {0, 0, 0, 1}; const bool kExpectedFragStart[] = {true, false, false, true}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -153,22 +153,22 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateMode) { } TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions1) { - const int kSizeVector[] = {1600, 200, 200, 200, 200, 200, 200, 200, 200}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {1600, 200, 200, 200, 200, 200, 200, 200, 200}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. - const int kMaxSize = 1500; + const size_t kMaxSize = 1500; RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // The expected sizes are obtained by running a verified good implementation. - const int kExpectedSizes[] = {803, 803, 803, 803}; + const size_t kExpectedSizes[] = {803, 803, 803, 803}; const int kExpectedPart[] = {0, 0, 1, 5}; const bool kExpectedFragStart[] = {true, false, true, true}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -180,22 +180,22 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions1) { } TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions2) { - const int kSizeVector[] = {1599, 200, 200, 200, 1600, 200, 200, 200, 200}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {1599, 200, 200, 200, 1600, 200, 200, 200, 200}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. - const int kMaxSize = 1500; + const size_t kMaxSize = 1500; RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // The expected sizes are obtained by running a verified good implementation. - const int kExpectedSizes[] = {803, 802, 603, 803, 803, 803}; + const size_t kExpectedSizes[] = {803, 802, 603, 803, 803, 803}; const int kExpectedPart[] = {0, 0, 1, 4, 4, 5}; const bool kExpectedFragStart[] = {true, false, true, true, false, true}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -207,22 +207,22 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions2) { } TEST_F(RtpPacketizerVp8Test, TestAggregateModeTwoLargePartitions) { - const int kSizeVector[] = {1654, 2268}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {1654, 2268}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. - const int kMaxSize = 1460; + const size_t kMaxSize = 1460; RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // The expected sizes are obtained by running a verified good implementation. - const int kExpectedSizes[] = {830, 830, 1137, 1137}; + const size_t kExpectedSizes[] = {830, 830, 1137, 1137}; const int kExpectedPart[] = {0, 0, 1, 1}; const bool kExpectedFragStart[] = {true, false, true, false}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -235,22 +235,22 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateModeTwoLargePartitions) { // Verify that EqualSize mode is forced if fragmentation info is missing. TEST_F(RtpPacketizerVp8Test, TestEqualSizeModeFallback) { - const int kSizeVector[] = {10, 10, 10}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {10, 10, 10}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); - hdr_info_.pictureId = 200; // > 0x7F should produce 2-byte PictureID - const int kMaxSize = 12; // Small enough to produce 4 packets. + hdr_info_.pictureId = 200; // > 0x7F should produce 2-byte PictureID + const size_t kMaxSize = 12; // Small enough to produce 4 packets. RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize); packetizer.SetPayloadData( helper_->payload_data(), helper_->payload_size(), NULL); // Expecting three full packets, and one with the remainder. - const int kExpectedSizes[] = {12, 11, 12, 11}; + const size_t kExpectedSizes[] = {12, 11, 12, 11}; const int kExpectedPart[] = {0, 0, 0, 0}; // Always 0 for equal size mode. // Frag start only true for first packet in equal size mode. const bool kExpectedFragStart[] = {true, false, false, false}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -264,22 +264,22 @@ TEST_F(RtpPacketizerVp8Test, TestEqualSizeModeFallback) { // Verify that non-reference bit is set. EqualSize mode fallback is expected. TEST_F(RtpPacketizerVp8Test, TestNonReferenceBit) { - const int kSizeVector[] = {10, 10, 10}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {10, 10, 10}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.nonReference = true; - const int kMaxSize = 25; // Small enough to produce two packets. + const size_t kMaxSize = 25; // Small enough to produce two packets. RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize); packetizer.SetPayloadData( helper_->payload_data(), helper_->payload_size(), NULL); // EqualSize mode => First packet full; other not. - const int kExpectedSizes[] = {16, 16}; + const size_t kExpectedSizes[] = {16, 16}; const int kExpectedPart[] = {0, 0}; // Always 0 for equal size mode. // Frag start only true for first packet in equal size mode. const bool kExpectedFragStart[] = {true, false}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -293,25 +293,25 @@ TEST_F(RtpPacketizerVp8Test, TestNonReferenceBit) { // Verify Tl0PicIdx and TID fields, and layerSync bit. TEST_F(RtpPacketizerVp8Test, TestTl0PicIdxAndTID) { - const int kSizeVector[] = {10, 10, 10}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {10, 10, 10}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.tl0PicIdx = 117; hdr_info_.temporalIdx = 2; hdr_info_.layerSync = true; // kMaxSize is only limited by allocated buffer size. - const int kMaxSize = helper_->buffer_size(); + const size_t kMaxSize = helper_->buffer_size(); RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // Expect one single packet of payload_size() + 4 bytes header. - const int kExpectedSizes[1] = {helper_->payload_size() + 4}; + const size_t kExpectedSizes[1] = {helper_->payload_size() + 4}; const int kExpectedPart[1] = {0}; // Packet starts with partition 0. const bool kExpectedFragStart[1] = {true}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -324,23 +324,23 @@ TEST_F(RtpPacketizerVp8Test, TestTl0PicIdxAndTID) { // Verify KeyIdx field. TEST_F(RtpPacketizerVp8Test, TestKeyIdx) { - const int kSizeVector[] = {10, 10, 10}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {10, 10, 10}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.keyIdx = 17; // kMaxSize is only limited by allocated buffer size. - const int kMaxSize = helper_->buffer_size(); + const size_t kMaxSize = helper_->buffer_size(); RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // Expect one single packet of payload_size() + 3 bytes header. - const int kExpectedSizes[1] = {helper_->payload_size() + 3}; + const size_t kExpectedSizes[1] = {helper_->payload_size() + 3}; const int kExpectedPart[1] = {0}; // Packet starts with partition 0. const bool kExpectedFragStart[1] = {true}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); @@ -353,24 +353,24 @@ TEST_F(RtpPacketizerVp8Test, TestKeyIdx) { // Verify TID field and KeyIdx field in combination. TEST_F(RtpPacketizerVp8Test, TestTIDAndKeyIdx) { - const int kSizeVector[] = {10, 10, 10}; - const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]); + const size_t kSizeVector[] = {10, 10, 10}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); hdr_info_.temporalIdx = 1; hdr_info_.keyIdx = 5; // kMaxSize is only limited by allocated buffer size. - const int kMaxSize = helper_->buffer_size(); + const size_t kMaxSize = helper_->buffer_size(); RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate); packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), helper_->fragmentation()); // Expect one single packet of payload_size() + 3 bytes header. - const int kExpectedSizes[1] = {helper_->payload_size() + 3}; + const size_t kExpectedSizes[1] = {helper_->payload_size() + 3}; const int kExpectedPart[1] = {0}; // Packet starts with partition 0. const bool kExpectedFragStart[1] = {true}; - const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]); + const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc index 9a1836e14a..a19eeaa805 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc @@ -105,9 +105,9 @@ int32_t RtpHeaderExtensionMap::GetId(const RTPExtensionType type, return -1; } -uint16_t RtpHeaderExtensionMap::GetTotalLengthInBytes() const { +size_t RtpHeaderExtensionMap::GetTotalLengthInBytes() const { // Get length for each extension block. - uint16_t length = 0; + size_t length = 0; std::map::const_iterator it = extensionMap_.begin(); while (it != extensionMap_.end()) { diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h index edffe8aecb..335d0a1b8f 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h @@ -68,7 +68,7 @@ class RtpHeaderExtensionMap { int32_t GetId(const RTPExtensionType type, uint8_t* id) const; - uint16_t GetTotalLengthInBytes() const; + size_t GetTotalLengthInBytes() const; int32_t GetLengthUntilBlockStartInBytes(const RTPExtensionType type) const; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc index 90d3f64952..d8387e823c 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc @@ -59,7 +59,7 @@ TEST_F(RtpHeaderExtensionTest, NonUniqueId) { } TEST_F(RtpHeaderExtensionTest, GetTotalLength) { - EXPECT_EQ(0, map_.GetTotalLengthInBytes()); + EXPECT_EQ(0u, map_.GetTotalLengthInBytes()); EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength, map_.GetTotalLengthInBytes()); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc index e3515f4454..2546ac08df 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -94,7 +94,7 @@ bool RTPPacketHistory::StorePackets() const { } // private, lock should already be taken -void RTPPacketHistory::VerifyAndAllocatePacketLength(uint16_t packet_length) { +void RTPPacketHistory::VerifyAndAllocatePacketLength(size_t packet_length) { assert(packet_length > 0); if (!store_) { return; @@ -112,8 +112,8 @@ void RTPPacketHistory::VerifyAndAllocatePacketLength(uint16_t packet_length) { } int32_t RTPPacketHistory::PutRTPPacket(const uint8_t* packet, - uint16_t packet_length, - uint16_t max_packet_length, + size_t packet_length, + size_t max_packet_length, int64_t capture_time_ms, StorageType type) { if (type == kDontStore) { @@ -169,7 +169,7 @@ bool RTPPacketHistory::HasRTPPacket(uint16_t sequence_number) const { return false; } - uint16_t length = stored_lengths_.at(index); + size_t length = stored_lengths_.at(index); if (length == 0 || length > max_packet_length_) { // Invalid length. return false; @@ -181,7 +181,7 @@ bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number, uint32_t min_elapsed_time_ms, bool retransmit, uint8_t* packet, - uint16_t* packet_length, + size_t* packet_length, int64_t* stored_time_ms) { assert(*packet_length >= max_packet_length_); CriticalSectionScoped cs(critsect_); @@ -196,7 +196,7 @@ bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number, return false; } - uint16_t length = stored_lengths_.at(index); + size_t length = stored_lengths_.at(index); assert(length <= max_packet_length_); if (length == 0) { LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number @@ -223,10 +223,10 @@ bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number, void RTPPacketHistory::GetPacket(int index, uint8_t* packet, - uint16_t* packet_length, + size_t* packet_length, int64_t* stored_time_ms) const { // Get packet. - uint16_t length = stored_lengths_.at(index); + size_t length = stored_lengths_.at(index); std::vector >::const_iterator it_found_packet = stored_packets_.begin() + index; std::copy(it_found_packet->begin(), it_found_packet->begin() + length, @@ -236,7 +236,7 @@ void RTPPacketHistory::GetPacket(int index, } bool RTPPacketHistory::GetBestFittingPacket(uint8_t* packet, - uint16_t* packet_length, + size_t* packet_length, int64_t* stored_time_ms) { CriticalSectionScoped cs(critsect_); if (!store_) @@ -283,22 +283,21 @@ bool RTPPacketHistory::FindSeqNum(uint16_t sequence_number, return false; } -int RTPPacketHistory::FindBestFittingPacket(uint16_t size) const { +int RTPPacketHistory::FindBestFittingPacket(size_t size) const { if (size < kMinPacketRequestBytes || stored_lengths_.empty()) return -1; - int min_diff = -1; - size_t best_index = 0; + size_t min_diff = std::numeric_limits::max(); + int best_index = -1; // Returned unchanged if we don't find anything. for (size_t i = 0; i < stored_lengths_.size(); ++i) { if (stored_lengths_[i] == 0) continue; - int diff = abs(stored_lengths_[i] - size); - if (min_diff < 0 || diff < min_diff) { + size_t diff = (stored_lengths_[i] > size) ? + (stored_lengths_[i] - size) : (size - stored_lengths_[i]); + if (diff < min_diff) { min_diff = diff; - best_index = i; + best_index = static_cast(i); } } - if (min_diff < 0) - return -1; return best_index; } } // namespace webrtc diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h index 253f6d0a9e..eea3f123a4 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h @@ -36,8 +36,8 @@ class RTPPacketHistory { // Stores RTP packet. int32_t PutRTPPacket(const uint8_t* packet, - uint16_t packet_length, - uint16_t max_packet_length, + size_t packet_length, + size_t max_packet_length, int64_t capture_time_ms, StorageType type); @@ -56,33 +56,33 @@ class RTPPacketHistory { uint32_t min_elapsed_time_ms, bool retransmit, uint8_t* packet, - uint16_t* packet_length, + size_t* packet_length, int64_t* stored_time_ms); - bool GetBestFittingPacket(uint8_t* packet, uint16_t* packet_length, + bool GetBestFittingPacket(uint8_t* packet, size_t* packet_length, int64_t* stored_time_ms); bool HasRTPPacket(uint16_t sequence_number) const; private: - void GetPacket(int index, uint8_t* packet, uint16_t* packet_length, + void GetPacket(int index, uint8_t* packet, size_t* packet_length, int64_t* stored_time_ms) const; void Allocate(uint16_t number_to_store) EXCLUSIVE_LOCKS_REQUIRED(*critsect_); void Free() EXCLUSIVE_LOCKS_REQUIRED(*critsect_); - void VerifyAndAllocatePacketLength(uint16_t packet_length); + void VerifyAndAllocatePacketLength(size_t packet_length); bool FindSeqNum(uint16_t sequence_number, int32_t* index) const; - int FindBestFittingPacket(uint16_t size) const; + int FindBestFittingPacket(size_t size) const; private: Clock* clock_; CriticalSectionWrapper* critsect_; bool store_; uint32_t prev_index_; - uint16_t max_packet_length_; + size_t max_packet_length_; std::vector > stored_packets_; std::vector stored_seq_nums_; - std::vector stored_lengths_; + std::vector stored_lengths_; std::vector stored_times_; std::vector stored_send_times_; std::vector stored_types_; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc index 7eb22ff69d..76798b6829 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc @@ -40,7 +40,7 @@ class RtpPacketHistoryTest : public ::testing::Test { uint8_t packet_out_[kMaxPacketLength]; void CreateRtpPacket(uint16_t seq_num, uint32_t ssrc, uint8_t payload, - uint32_t timestamp, uint8_t* array, uint16_t* cur_pos) { + uint32_t timestamp, uint8_t* array, size_t* cur_pos) { array[(*cur_pos)++] = 0x80; array[(*cur_pos)++] = payload; array[(*cur_pos)++] = seq_num >> 8; @@ -66,7 +66,7 @@ TEST_F(RtpPacketHistoryTest, SetStoreStatus) { TEST_F(RtpPacketHistoryTest, NoStoreStatus) { EXPECT_FALSE(hist_->StorePackets()); - uint16_t len = 0; + size_t len = 0; int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength, @@ -80,7 +80,7 @@ TEST_F(RtpPacketHistoryTest, NoStoreStatus) { TEST_F(RtpPacketHistoryTest, DontStore) { hist_->SetStorePacketsStatus(true, 10); - uint16_t len = 0; + size_t len = 0; int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength, @@ -105,7 +105,7 @@ TEST_F(RtpPacketHistoryTest, PutRtpPacket_TooLargePacketLength) { TEST_F(RtpPacketHistoryTest, GetRtpPacket_NotStored) { hist_->SetStorePacketsStatus(true, 10); - uint16_t len = kMaxPacketLength; + size_t len = kMaxPacketLength; int64_t time; EXPECT_FALSE(hist_->GetPacketAndSetSendTime(0, 0, false, packet_, &len, &time)); @@ -113,7 +113,7 @@ TEST_F(RtpPacketHistoryTest, GetRtpPacket_NotStored) { TEST_F(RtpPacketHistoryTest, PutRtpPacket) { hist_->SetStorePacketsStatus(true, 10); - uint16_t len = 0; + size_t len = 0; CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); EXPECT_FALSE(hist_->HasRTPPacket(kSeqNum)); @@ -125,52 +125,52 @@ TEST_F(RtpPacketHistoryTest, PutRtpPacket) { TEST_F(RtpPacketHistoryTest, GetRtpPacket) { hist_->SetStorePacketsStatus(true, 10); - uint16_t len = 0; + size_t len = 0; int64_t capture_time_ms = 1; CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength, capture_time_ms, kAllowRetransmission)); - uint16_t len_out = kMaxPacketLength; + size_t len_out = kMaxPacketLength; int64_t time; EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_, &len_out, &time)); EXPECT_EQ(len, len_out); EXPECT_EQ(capture_time_ms, time); - for (int i = 0; i < len; i++) { + for (size_t i = 0; i < len; i++) { EXPECT_EQ(packet_[i], packet_out_[i]); } } TEST_F(RtpPacketHistoryTest, NoCaptureTime) { hist_->SetStorePacketsStatus(true, 10); - uint16_t len = 0; + size_t len = 0; fake_clock_.AdvanceTimeMilliseconds(1); int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength, -1, kAllowRetransmission)); - uint16_t len_out = kMaxPacketLength; + size_t len_out = kMaxPacketLength; int64_t time; EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_, &len_out, &time)); EXPECT_EQ(len, len_out); EXPECT_EQ(capture_time_ms, time); - for (int i = 0; i < len; i++) { + for (size_t i = 0; i < len; i++) { EXPECT_EQ(packet_[i], packet_out_[i]); } } TEST_F(RtpPacketHistoryTest, DontRetransmit) { hist_->SetStorePacketsStatus(true, 10); - uint16_t len = 0; + size_t len = 0; int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength, capture_time_ms, kDontRetransmit)); - uint16_t len_out = kMaxPacketLength; + size_t len_out = kMaxPacketLength; int64_t time; EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_, &len_out, &time)); @@ -180,7 +180,7 @@ TEST_F(RtpPacketHistoryTest, DontRetransmit) { TEST_F(RtpPacketHistoryTest, MinResendTime) { hist_->SetStorePacketsStatus(true, 10); - uint16_t len = 0; + size_t len = 0; int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len); EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength, @@ -195,7 +195,7 @@ TEST_F(RtpPacketHistoryTest, MinResendTime) { len = kMaxPacketLength; EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 100, false, packet_, &len, &time)); - EXPECT_GT(len, 0); + EXPECT_GT(len, 0u); EXPECT_EQ(capture_time_ms, time); // Time has not elapsed. Packet should be found, but no bytes copied. diff --git a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc index ec05a73bfd..6073016530 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc @@ -242,7 +242,7 @@ bool RTPPayloadRegistry::IsRtxInternal(const RTPHeader& header) const { bool RTPPayloadRegistry::RestoreOriginalPacket(uint8_t** restored_packet, const uint8_t* packet, - int* packet_length, + size_t* packet_length, uint32_t original_ssrc, const RTPHeader& header) const { if (kRtxHeaderSize + header.headerLength > *packet_length) { diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc index 05eefbe086..7e375280d2 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc @@ -184,7 +184,7 @@ int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header, const PayloadUnion& specific_payload, bool is_red, const uint8_t* payload, - uint16_t payload_length, + size_t payload_length, int64_t timestamp_ms, bool is_first_packet) { TRACE_EVENT2("webrtc_rtp", "Audio::ParseRtp", @@ -288,7 +288,7 @@ int32_t RTPReceiverAudio::InvokeOnInitializeDecoder( int32_t RTPReceiverAudio::ParseAudioCodecSpecific( WebRtcRTPHeader* rtp_header, const uint8_t* payload_data, - uint16_t payload_length, + size_t payload_length, const AudioPayload& audio_specific, bool is_red) { @@ -311,13 +311,13 @@ int32_t RTPReceiverAudio::ParseAudioCodecSpecific( if (payload_length % 4 != 0) { return -1; } - uint8_t number_of_events = payload_length / 4; + size_t number_of_events = payload_length / 4; // sanity if (number_of_events >= MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS) { number_of_events = MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS; } - for (int n = 0; n < number_of_events; ++n) { + for (size_t n = 0; n < number_of_events; ++n) { bool end = (payload_data[(4 * n) + 1] & 0x80) ? true : false; std::set::iterator event = diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h index 4fb7256d48..2c6af68578 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h @@ -53,13 +53,13 @@ class RTPReceiverAudio : public RTPReceiverStrategy, uint32_t* frequency, bool* cng_payload_type_has_changed); - int32_t ParseRtpPacket(WebRtcRTPHeader* rtp_header, - const PayloadUnion& specific_payload, - bool is_red, - const uint8_t* packet, - uint16_t packet_length, - int64_t timestamp_ms, - bool is_first_packet); + virtual int32_t ParseRtpPacket(WebRtcRTPHeader* rtp_header, + const PayloadUnion& specific_payload, + bool is_red, + const uint8_t* packet, + size_t payload_length, + int64_t timestamp_ms, + bool is_first_packet) OVERRIDE; int GetPayloadTypeFrequency() const OVERRIDE; @@ -104,7 +104,7 @@ class RTPReceiverAudio : public RTPReceiverStrategy, int32_t ParseAudioCodecSpecific( WebRtcRTPHeader* rtp_header, const uint8_t* payload_data, - uint16_t payload_length, + size_t payload_length, const AudioPayload& audio_specific, bool is_red); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc index 22fae10003..1cbc2acd3d 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc @@ -163,12 +163,9 @@ int32_t RtpReceiverImpl::Energy( bool RtpReceiverImpl::IncomingRtpPacket( const RTPHeader& rtp_header, const uint8_t* payload, - int payload_length, + size_t payload_length, PayloadUnion payload_specific, bool in_order) { - // Sanity check. - assert(payload_length >= 0); - // Trigger our callbacks. CheckSSRCChanged(rtp_header); @@ -198,7 +195,7 @@ bool RtpReceiverImpl::IncomingRtpPacket( webrtc_rtp_header.header = rtp_header; CheckCSRC(webrtc_rtp_header); - uint16_t payload_data_length = payload_length - rtp_header.paddingLength; + size_t payload_data_length = payload_length - rtp_header.paddingLength; bool is_first_packet_in_frame = false; { diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h index 60688118f5..9e58b1ac41 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h @@ -46,7 +46,7 @@ class RtpReceiverImpl : public RtpReceiver { virtual bool IncomingRtpPacket( const RTPHeader& rtp_header, const uint8_t* payload, - int payload_length, + size_t payload_length, PayloadUnion payload_specific, bool in_order) OVERRIDE; @@ -88,7 +88,7 @@ class RtpReceiverImpl : public RtpReceiver { scoped_ptr critical_section_rtp_receiver_; int64_t last_receive_time_; - uint16_t last_received_payload_length_; + size_t last_received_payload_length_; // SSRCs. uint32_t ssrc_; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h index 09c9b6fc30..0eb23e5aa2 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h @@ -43,7 +43,7 @@ class RTPReceiverStrategy { const PayloadUnion& specific_payload, bool is_red, const uint8_t* payload, - uint16_t payload_length, + size_t payload_length, int64_t timestamp_ms, bool is_first_packet) = 0; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc index 6f6d647088..6fe3e1d9ef 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc @@ -51,7 +51,7 @@ int32_t RTPReceiverVideo::ParseRtpPacket(WebRtcRTPHeader* rtp_header, const PayloadUnion& specific_payload, bool is_red, const uint8_t* payload, - uint16_t payload_length, + size_t payload_length, int64_t timestamp_ms, bool is_first_packet) { TRACE_EVENT2("webrtc_rtp", @@ -62,7 +62,7 @@ int32_t RTPReceiverVideo::ParseRtpPacket(WebRtcRTPHeader* rtp_header, rtp_header->header.timestamp); rtp_header->type.Video.codec = specific_payload.Video.videoCodecType; - const uint16_t payload_data_length = + const size_t payload_data_length = payload_length - rtp_header->header.paddingLength; if (payload == NULL || payload_data_length == 0) { diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h index 8fe4acb80e..177f3031ef 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h @@ -30,7 +30,7 @@ class RTPReceiverVideo : public RTPReceiverStrategy { const PayloadUnion& specific_payload, bool is_red, const uint8_t* packet, - uint16_t packet_length, + size_t packet_length, int64_t timestamp, bool is_first_packet) OVERRIDE; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 6446cb7c49..db10956772 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -259,7 +259,7 @@ void ModuleRtpRtcpImpl::SetRtxSendPayloadType(int payload_type) { int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket( const uint8_t* rtcp_packet, - const uint16_t length) { + const size_t length) { // Allow receive of non-compound RTCP packets. RTCPUtility::RTCPParserV2 rtcp_parser(rtcp_packet, length, true); @@ -504,7 +504,7 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData( uint32_t time_stamp, int64_t capture_time_ms, const uint8_t* payload_data, - uint32_t payload_size, + size_t payload_size, const RTPFragmentationHeader* fragmentation, const RTPVideoHeader* rtp_video_hdr) { rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); @@ -603,7 +603,7 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, return true; } -int ModuleRtpRtcpImpl::TimeToSendPadding(int bytes) { +size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes) { if (!IsDefaultModule()) { // Don't send from default module. return rtp_sender_.TimeToSendPadding(bytes); @@ -816,7 +816,7 @@ bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const { } int32_t ModuleRtpRtcpImpl::DataCountersRTP( - uint32_t* bytes_sent, + size_t* bytes_sent, uint32_t* packets_sent) const { StreamDataCounters rtp_stats; StreamDataCounters rtx_stats; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h index 4975812800..1b7db9f6d8 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -40,7 +40,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp { // Called when we receive an RTCP packet. virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet, - uint16_t incoming_packet_length) OVERRIDE; + size_t incoming_packet_length) OVERRIDE; virtual void SetRemoteSSRC(const uint32_t ssrc) OVERRIDE; @@ -120,7 +120,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp { const uint32_t time_stamp, int64_t capture_time_ms, const uint8_t* payload_data, - const uint32_t payload_size, + const size_t payload_size, const RTPFragmentationHeader* fragmentation = NULL, const RTPVideoHeader* rtp_video_hdr = NULL) OVERRIDE; @@ -130,7 +130,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp { bool retransmission) OVERRIDE; // Returns the number of padding bytes actually sent, which can be more or // less than |bytes|. - virtual int TimeToSendPadding(int bytes) OVERRIDE; + virtual size_t TimeToSendPadding(size_t bytes) OVERRIDE; virtual bool GetSendSideDelay(int* avg_send_delay_ms, int* max_send_delay_ms) const OVERRIDE; @@ -179,7 +179,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp { virtual int32_t ResetSendDataCountersRTP() OVERRIDE; // Statistics of the amount of data sent and received. - virtual int32_t DataCountersRTP(uint32_t* bytes_sent, + virtual int32_t DataCountersRTP(size_t* bytes_sent, uint32_t* packets_sent) const OVERRIDE; // Get received RTCP report, sender info. diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc index 24ff227aff..bf6ab395de 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc @@ -67,17 +67,17 @@ class SendTransport : public Transport, clock_ = clock; delay_ms_ = delay_ms; } - virtual int SendPacket(int /*ch*/, const void* data, int len) OVERRIDE { + virtual int SendPacket(int /*ch*/, const void* data, size_t len) OVERRIDE { RTPHeader header; scoped_ptr parser(RtpHeaderParser::Create()); - EXPECT_TRUE(parser->Parse(static_cast(data), - static_cast(len), - &header)); + EXPECT_TRUE(parser->Parse(static_cast(data), len, &header)); ++rtp_packets_sent_; last_rtp_header_ = header; - return len; + return static_cast(len); } - virtual int SendRTCPPacket(int /*ch*/, const void *data, int len) OVERRIDE { + virtual int SendRTCPPacket(int /*ch*/, + const void *data, + size_t len) OVERRIDE { test::RtcpPacketParser parser; parser.Parse(static_cast(data), len); last_nack_list_ = parser.nack_item()->last_nack_list(); @@ -88,7 +88,7 @@ class SendTransport : public Transport, EXPECT_TRUE(receiver_ != NULL); EXPECT_EQ(0, receiver_->IncomingRtcpPacket( static_cast(data), len)); - return len; + return static_cast(len); } ModuleRtpRtcpImpl* receiver_; SimulatedClock* clock_; @@ -398,7 +398,9 @@ class RtpSendingTestTransport : public Transport { public: void ResetCounters() { bytes_received_.clear(); } - virtual int SendPacket(int channel, const void* data, int length) OVERRIDE { + virtual int SendPacket(int channel, + const void* data, + size_t length) OVERRIDE { RTPHeader header; scoped_ptr parser(RtpHeaderParser::Create()); EXPECT_TRUE(parser->Parse(static_cast(data), @@ -406,13 +408,13 @@ class RtpSendingTestTransport : public Transport { &header)); bytes_received_[header.ssrc] += length; ++packets_received_[header.ssrc]; - return length; + return static_cast(length); } virtual int SendRTCPPacket(int channel, const void* data, - int length) OVERRIDE { - return length; + size_t length) OVERRIDE { + return static_cast(length); } int GetPacketsReceived(uint32_t ssrc) const { diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc index 677f3fc498..38ac859fd7 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc @@ -22,7 +22,7 @@ namespace webrtc { // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. -const int kMaxPaddingLength = 224; +const size_t kMaxPaddingLength = 224; const int kSendSideDelayWindowMs = 1000; namespace { @@ -272,7 +272,7 @@ int32_t RTPSender::DeregisterRtpHeaderExtension( return rtp_header_extension_map_.Deregister(type); } -uint16_t RTPSender::RtpHeaderExtensionTotalLength() const { +size_t RTPSender::RtpHeaderExtensionTotalLength() const { CriticalSectionScoped cs(send_critsect_); return rtp_header_extension_map_.GetTotalLengthInBytes(); } @@ -355,7 +355,7 @@ int RTPSender::SendPayloadFrequency() const { } int32_t RTPSender::SetMaxPayloadLength( - const uint16_t max_payload_length, + const size_t max_payload_length, const uint16_t packet_over_head) { // Sanity check. if (max_payload_length < 100 || max_payload_length > IP_PACKET_SIZE) { @@ -368,7 +368,7 @@ int32_t RTPSender::SetMaxPayloadLength( return 0; } -uint16_t RTPSender::MaxDataPayloadLength() const { +size_t RTPSender::MaxDataPayloadLength() const { int rtx; { CriticalSectionScoped rtx_lock(send_critsect_); @@ -383,7 +383,7 @@ uint16_t RTPSender::MaxDataPayloadLength() const { } } -uint16_t RTPSender::MaxPayloadLength() const { +size_t RTPSender::MaxPayloadLength() const { return max_payload_length_; } @@ -461,7 +461,7 @@ int32_t RTPSender::CheckPayloadType(const int8_t payload_type, int32_t RTPSender::SendOutgoingData( const FrameType frame_type, const int8_t payload_type, const uint32_t capture_timestamp, int64_t capture_time_ms, - const uint8_t *payload_data, const uint32_t payload_size, + const uint8_t *payload_data, const size_t payload_size, const RTPFragmentationHeader *fragmentation, VideoCodecInformation *codec_info, const RTPVideoTypeHeader *rtp_type_hdr) { uint32_t ssrc; @@ -513,7 +513,7 @@ int32_t RTPSender::SendOutgoingData( return ret_val; } -int RTPSender::TrySendRedundantPayloads(int bytes_to_send) { +size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) { { CriticalSectionScoped cs(send_critsect_); if ((rtx_ & kRtxRedundantPayloads) == 0) @@ -521,44 +521,41 @@ int RTPSender::TrySendRedundantPayloads(int bytes_to_send) { } uint8_t buffer[IP_PACKET_SIZE]; - int bytes_left = bytes_to_send; + int bytes_left = static_cast(bytes_to_send); while (bytes_left > 0) { - uint16_t length = bytes_left; + size_t length = bytes_left; int64_t capture_time_ms; if (!packet_history_.GetBestFittingPacket(buffer, &length, &capture_time_ms)) { break; } if (!PrepareAndSendPacket(buffer, length, capture_time_ms, true, false)) - return -1; + break; RtpUtility::RtpHeaderParser rtp_parser(buffer, length); RTPHeader rtp_header; rtp_parser.Parse(rtp_header); - bytes_left -= length - rtp_header.headerLength; + bytes_left -= static_cast(length - rtp_header.headerLength); } return bytes_to_send - bytes_left; } -int RTPSender::BuildPaddingPacket(uint8_t* packet, int header_length, - int32_t bytes) { - int padding_bytes_in_packet = kMaxPaddingLength; - if (bytes < kMaxPaddingLength) { - padding_bytes_in_packet = bytes; - } +size_t RTPSender::BuildPaddingPacket(uint8_t* packet, size_t header_length) { + size_t padding_bytes_in_packet = kMaxPaddingLength; packet[0] |= 0x20; // Set padding bit. int32_t *data = reinterpret_cast(&(packet[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. - packet[header_length + padding_bytes_in_packet - 1] = padding_bytes_in_packet; + packet[header_length + padding_bytes_in_packet - 1] = + static_cast(padding_bytes_in_packet); return padding_bytes_in_packet; } -int RTPSender::TrySendPadData(int bytes) { +size_t RTPSender::TrySendPadData(size_t bytes) { int64_t capture_time_ms; uint32_t timestamp; { @@ -575,11 +572,11 @@ int RTPSender::TrySendPadData(int bytes) { return SendPadData(timestamp, capture_time_ms, bytes); } -int RTPSender::SendPadData(uint32_t timestamp, - int64_t capture_time_ms, - int32_t bytes) { - int padding_bytes_in_packet = 0; - int bytes_sent = 0; +size_t RTPSender::SendPadData(uint32_t timestamp, + int64_t capture_time_ms, + size_t bytes) { + size_t padding_bytes_in_packet = 0; + size_t bytes_sent = 0; for (; bytes > 0; bytes -= padding_bytes_in_packet) { // Always send full padding packets. if (bytes < kMaxPaddingLength) @@ -618,17 +615,18 @@ int RTPSender::SendPadData(uint32_t timestamp, } uint8_t padding_packet[IP_PACKET_SIZE]; - int header_length = CreateRTPHeader(padding_packet, - payload_type, - ssrc, - false, - timestamp, - sequence_number, - NULL, - 0); - padding_bytes_in_packet = - BuildPaddingPacket(padding_packet, header_length, bytes); - int length = padding_bytes_in_packet + header_length; + size_t header_length = CreateRTPHeader(padding_packet, + payload_type, + ssrc, + false, + timestamp, + sequence_number, + NULL, + 0); + assert(header_length != static_cast(-1)); + padding_bytes_in_packet = BuildPaddingPacket(padding_packet, header_length); + assert(padding_bytes_in_packet <= bytes); + size_t length = padding_bytes_in_packet + header_length; int64_t now_ms = clock_->TimeInMilliseconds(); RtpUtility::RtpHeaderParser rtp_parser(padding_packet, length); @@ -660,7 +658,7 @@ bool RTPSender::StorePackets() const { } int32_t RTPSender::ReSendPacket(uint16_t packet_id, uint32_t min_resend_time) { - uint16_t length = IP_PACKET_SIZE; + size_t length = IP_PACKET_SIZE; uint8_t data_buffer[IP_PACKET_SIZE]; int64_t capture_time_ms; if (!packet_history_.GetPacketAndSetSendTime(packet_id, min_resend_time, true, @@ -695,10 +693,10 @@ int32_t RTPSender::ReSendPacket(uint16_t packet_id, uint32_t min_resend_time) { } return PrepareAndSendPacket(data_buffer, length, capture_time_ms, (rtx & kRtxRetransmitted) > 0, true) ? - length : -1; + static_cast(length) : -1; } -bool RTPSender::SendPacketToNetwork(const uint8_t *packet, uint32_t size) { +bool RTPSender::SendPacketToNetwork(const uint8_t *packet, size_t size) { int bytes_sent = -1; if (transport_) { bytes_sent = transport_->SendPacket(id_, packet, size); @@ -731,7 +729,7 @@ void RTPSender::OnReceivedNACK( TRACE_EVENT2("webrtc_rtp", "RTPSender::OnReceivedNACK", "num_seqnum", nack_sequence_numbers.size(), "avg_rtt", avg_rtt); const int64_t now = clock_->TimeInMilliseconds(); - uint32_t bytes_re_sent = 0; + size_t bytes_re_sent = 0; uint32_t target_bitrate = GetTargetBitrate(); // Enough bandwidth to send NACK? @@ -759,8 +757,8 @@ void RTPSender::OnReceivedNACK( // Delay bandwidth estimate (RTT * BW). if (target_bitrate != 0 && avg_rtt) { // kbits/s * ms = bits => bits/8 = bytes - uint32_t target_bytes = - (static_cast(target_bitrate / 1000) * avg_rtt) >> 3; + size_t target_bytes = + (static_cast(target_bitrate / 1000) * avg_rtt) >> 3; if (bytes_re_sent > target_bytes) { break; // Ignore the rest of the packets in the list. } @@ -775,7 +773,7 @@ void RTPSender::OnReceivedNACK( bool RTPSender::ProcessNACKBitRate(const uint32_t now) { uint32_t num = 0; - int byte_count = 0; + size_t byte_count = 0; const uint32_t kAvgIntervalMs = 1000; uint32_t target_bitrate = GetTargetBitrate(); @@ -800,11 +798,10 @@ bool RTPSender::ProcessNACKBitRate(const uint32_t now) { time_interval = now - nack_byte_count_times_[num - 1]; } } - return (byte_count * 8) < - static_cast(target_bitrate / 1000 * time_interval); + return (byte_count * 8) < (target_bitrate / 1000 * time_interval); } -void RTPSender::UpdateNACKBitRate(const uint32_t bytes, +void RTPSender::UpdateNACKBitRate(const size_t bytes, const uint32_t now) { CriticalSectionScoped cs(send_critsect_); @@ -833,7 +830,7 @@ void RTPSender::UpdateNACKBitRate(const uint32_t bytes, bool RTPSender::TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms, bool retransmission) { - uint16_t length = IP_PACKET_SIZE; + size_t length = IP_PACKET_SIZE; uint8_t data_buffer[IP_PACKET_SIZE]; int64_t stored_time_ms; @@ -862,7 +859,7 @@ bool RTPSender::TimeToSendPacket(uint16_t sequence_number, } bool RTPSender::PrepareAndSendPacket(uint8_t* buffer, - uint16_t length, + size_t length, int64_t capture_time_ms, bool send_over_rtx, bool is_retransmit) { @@ -901,7 +898,7 @@ bool RTPSender::PrepareAndSendPacket(uint8_t* buffer, } void RTPSender::UpdateRtpStats(const uint8_t* buffer, - uint32_t size, + size_t size, const RTPHeader& header, bool is_rtx, bool is_retransmit) { @@ -949,22 +946,22 @@ bool RTPSender::IsFecPacket(const uint8_t* buffer, buffer[header.headerLength] == pt_fec; } -int RTPSender::TimeToSendPadding(int bytes) { +size_t RTPSender::TimeToSendPadding(size_t bytes) { { CriticalSectionScoped cs(send_critsect_); if (!sending_media_) return 0; } - int available_bytes = bytes; - if (available_bytes > 0) - available_bytes -= TrySendRedundantPayloads(available_bytes); - if (available_bytes > 0) - available_bytes -= TrySendPadData(available_bytes); - return bytes - available_bytes; + if (bytes == 0) + return 0; + size_t bytes_sent = TrySendRedundantPayloads(bytes); + if (bytes_sent < bytes) + bytes_sent += TrySendPadData(bytes - bytes_sent); + return bytes_sent; } // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again. int32_t RTPSender::SendToNetwork( - uint8_t *buffer, int payload_length, int rtp_header_length, + uint8_t *buffer, size_t payload_length, size_t rtp_header_length, int64_t capture_time_ms, StorageType storage, PacedSender::Priority priority) { RtpUtility::RtpHeaderParser rtp_parser(buffer, @@ -1013,7 +1010,7 @@ int32_t RTPSender::SendToNetwork( if (capture_time_ms > 0) { UpdateDelayStatistics(capture_time_ms, now_ms); } - uint32_t length = payload_length + rtp_header_length; + size_t length = payload_length + rtp_header_length; if (!SendPacketToNetwork(buffer, length)) return -1; { @@ -1057,9 +1054,9 @@ void RTPSender::ProcessBitrate() { video_->ProcessBitrate(); } -uint16_t RTPSender::RTPHeaderLength() const { +size_t RTPSender::RTPHeaderLength() const { CriticalSectionScoped lock(send_critsect_); - uint16_t rtp_header_length = 12; + size_t rtp_header_length = 12; if (include_csrcs_) { rtp_header_length += sizeof(uint32_t) * num_csrcs_; } @@ -1326,7 +1323,7 @@ uint8_t RTPSender::BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const { } void RTPSender::UpdateTransmissionTimeOffset( - uint8_t *rtp_packet, const uint16_t rtp_packet_length, + uint8_t *rtp_packet, const size_t rtp_packet_length, const RTPHeader &rtp_header, const int64_t time_diff_ms) const { CriticalSectionScoped cs(send_critsect_); // Get id. @@ -1345,7 +1342,7 @@ void RTPSender::UpdateTransmissionTimeOffset( << "Failed to update transmission time offset, not registered."; return; } - int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos; + size_t block_pos = 12 + rtp_header.numCSRCs + extension_block_pos; if (rtp_packet_length < block_pos + kTransmissionTimeOffsetLength || rtp_header.headerLength < block_pos + kTransmissionTimeOffsetLength) { @@ -1372,7 +1369,7 @@ void RTPSender::UpdateTransmissionTimeOffset( } bool RTPSender::UpdateAudioLevel(uint8_t *rtp_packet, - const uint16_t rtp_packet_length, + const size_t rtp_packet_length, const RTPHeader &rtp_header, const bool is_voiced, const uint8_t dBov) const { @@ -1392,7 +1389,7 @@ bool RTPSender::UpdateAudioLevel(uint8_t *rtp_packet, // The feature is not enabled. return false; } - int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos; + size_t block_pos = 12 + rtp_header.numCSRCs + extension_block_pos; if (rtp_packet_length < block_pos + kAudioLevelLength || rtp_header.headerLength < block_pos + kAudioLevelLength) { LOG(LS_WARNING) << "Failed to update audio level, invalid length."; @@ -1415,7 +1412,7 @@ bool RTPSender::UpdateAudioLevel(uint8_t *rtp_packet, } void RTPSender::UpdateAbsoluteSendTime( - uint8_t *rtp_packet, const uint16_t rtp_packet_length, + uint8_t *rtp_packet, const size_t rtp_packet_length, const RTPHeader &rtp_header, const int64_t now_ms) const { CriticalSectionScoped cs(send_critsect_); @@ -1434,7 +1431,7 @@ void RTPSender::UpdateAbsoluteSendTime( // The feature is not enabled. return; } - int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos; + size_t block_pos = 12 + rtp_header.numCSRCs + extension_block_pos; if (rtp_packet_length < block_pos + kAbsoluteSendTimeLength || rtp_header.headerLength < block_pos + kAbsoluteSendTimeLength) { LOG(LS_WARNING) << "Failed to update absolute send time, invalid length."; @@ -1685,7 +1682,7 @@ int32_t RTPSender::SetFecParameters( return video_->SetFecParameters(delta_params, key_params); } -void RTPSender::BuildRtxPacket(uint8_t* buffer, uint16_t* length, +void RTPSender::BuildRtxPacket(uint8_t* buffer, size_t* length, uint8_t* buffer_rtx) { CriticalSectionScoped cs(send_critsect_); uint8_t* data_buffer_rtx = buffer_rtx; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.h b/webrtc/modules/rtp_rtcp/source/rtp_sender.h index 6564d47bc4..4781aae3a3 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.h @@ -52,16 +52,16 @@ class RTPSenderInterface { const bool timestamp_provided = true, const bool inc_sequence_number = true) = 0; - virtual uint16_t RTPHeaderLength() const = 0; + virtual size_t RTPHeaderLength() const = 0; virtual uint16_t IncrementSequenceNumber() = 0; virtual uint16_t SequenceNumber() const = 0; - virtual uint16_t MaxPayloadLength() const = 0; - virtual uint16_t MaxDataPayloadLength() const = 0; + virtual size_t MaxPayloadLength() const = 0; + virtual size_t MaxDataPayloadLength() const = 0; virtual uint16_t PacketOverHead() const = 0; virtual uint16_t ActualSendBitrateKbit() const = 0; virtual int32_t SendToNetwork( - uint8_t *data_buffer, int payload_length, int rtp_header_length, + uint8_t *data_buffer, size_t payload_length, size_t rtp_header_length, int64_t capture_time_ms, StorageType storage, PacedSender::Priority priority) = 0; }; @@ -91,8 +91,8 @@ class RTPSender : public RTPSenderInterface { void SetTargetBitrate(uint32_t bitrate); uint32_t GetTargetBitrate(); - virtual uint16_t MaxDataPayloadLength() const - OVERRIDE; // with RTP and FEC headers. + // Includes size of RTP and FEC headers. + virtual size_t MaxDataPayloadLength() const OVERRIDE; int32_t RegisterPayload( const char payload_name[RTP_PAYLOAD_NAME_SIZE], @@ -133,7 +133,7 @@ class RTPSender : public RTPSenderInterface { void SetCSRCs(const uint32_t arr_of_csrc[kRtpCsrcSize], const uint8_t arr_length); - int32_t SetMaxPayloadLength(const uint16_t length, + int32_t SetMaxPayloadLength(const size_t length, const uint16_t packet_over_head); int32_t SendOutgoingData(const FrameType frame_type, @@ -141,7 +141,7 @@ class RTPSender : public RTPSenderInterface { const uint32_t timestamp, int64_t capture_time_ms, const uint8_t* payload_data, - const uint32_t payload_size, + const size_t payload_size, const RTPFragmentationHeader* fragmentation, VideoCodecInformation* codec_info = NULL, const RTPVideoTypeHeader* rtp_type_hdr = NULL); @@ -157,7 +157,7 @@ class RTPSender : public RTPSenderInterface { int32_t DeregisterRtpHeaderExtension(const RTPExtensionType type); - uint16_t RtpHeaderExtensionTotalLength() const; + size_t RtpHeaderExtensionTotalLength() const; uint16_t BuildRTPHeaderExtension(uint8_t* data_buffer) const; @@ -166,14 +166,14 @@ class RTPSender : public RTPSenderInterface { uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const; bool UpdateAudioLevel(uint8_t *rtp_packet, - const uint16_t rtp_packet_length, + const size_t rtp_packet_length, const RTPHeader &rtp_header, const bool is_voiced, const uint8_t dBov) const; bool TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms, bool retransmission); - int TimeToSendPadding(int bytes); + size_t TimeToSendPadding(size_t bytes); // NACK. int SelectiveRetransmissions() const; @@ -210,9 +210,9 @@ class RTPSender : public RTPSenderInterface { const bool timestamp_provided = true, const bool inc_sequence_number = true) OVERRIDE; - virtual uint16_t RTPHeaderLength() const OVERRIDE; + virtual size_t RTPHeaderLength() const OVERRIDE; virtual uint16_t IncrementSequenceNumber() OVERRIDE; - virtual uint16_t MaxPayloadLength() const OVERRIDE; + virtual size_t MaxPayloadLength() const OVERRIDE; virtual uint16_t PacketOverHead() const OVERRIDE; // Current timestamp. @@ -220,7 +220,7 @@ class RTPSender : public RTPSenderInterface { virtual uint32_t SSRC() const OVERRIDE; virtual int32_t SendToNetwork( - uint8_t *data_buffer, int payload_length, int rtp_header_length, + uint8_t *data_buffer, size_t payload_length, size_t rtp_header_length, int64_t capture_time_ms, StorageType storage, PacedSender::Priority priority) OVERRIDE; @@ -267,9 +267,9 @@ class RTPSender : public RTPSenderInterface { int32_t SetFecParameters(const FecProtectionParams *delta_params, const FecProtectionParams *key_params); - int SendPadData(uint32_t timestamp, - int64_t capture_time_ms, - int32_t bytes); + size_t SendPadData(uint32_t timestamp, + int64_t capture_time_ms, + size_t bytes); // Called on update of RTP statistics. void RegisterRtpStatisticsCallback(StreamDataCountersCallback* callback); @@ -297,38 +297,39 @@ class RTPSender : public RTPSenderInterface { uint32_t timestamp, uint16_t sequence_number, const uint32_t* csrcs, uint8_t csrcs_length) const; - void UpdateNACKBitRate(const uint32_t bytes, const uint32_t now); + void UpdateNACKBitRate(const size_t bytes, const uint32_t now); bool PrepareAndSendPacket(uint8_t* buffer, - uint16_t length, + size_t length, int64_t capture_time_ms, bool send_over_rtx, bool is_retransmit); - // Return the number of bytes sent. - int TrySendRedundantPayloads(int bytes); - int TrySendPadData(int bytes); + // Return the number of bytes sent. Note that both of these functions may + // return a larger value that their argument. + size_t TrySendRedundantPayloads(size_t bytes); + size_t TrySendPadData(size_t bytes); - int BuildPaddingPacket(uint8_t* packet, int header_length, int32_t bytes); + size_t BuildPaddingPacket(uint8_t* packet, size_t header_length); - void BuildRtxPacket(uint8_t* buffer, uint16_t* length, + void BuildRtxPacket(uint8_t* buffer, size_t* length, uint8_t* buffer_rtx); - bool SendPacketToNetwork(const uint8_t *packet, uint32_t size); + bool SendPacketToNetwork(const uint8_t *packet, size_t size); void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); void UpdateTransmissionTimeOffset(uint8_t *rtp_packet, - const uint16_t rtp_packet_length, + const size_t rtp_packet_length, const RTPHeader &rtp_header, const int64_t time_diff_ms) const; void UpdateAbsoluteSendTime(uint8_t *rtp_packet, - const uint16_t rtp_packet_length, + const size_t rtp_packet_length, const RTPHeader &rtp_header, const int64_t now_ms) const; void UpdateRtpStats(const uint8_t* buffer, - uint32_t size, + size_t size, const RTPHeader& header, bool is_rtx, bool is_retransmit); @@ -352,7 +353,7 @@ class RTPSender : public RTPSenderInterface { Transport *transport_; bool sending_media_ GUARDED_BY(send_critsect_); - uint16_t max_payload_length_; + size_t max_payload_length_; uint16_t packet_over_head_; int8_t payload_type_ GUARDED_BY(send_critsect_); @@ -364,7 +365,7 @@ class RTPSender : public RTPSenderInterface { // NACK uint32_t nack_byte_count_times_[NACK_BYTECOUNT_SIZE]; - int32_t nack_byte_count_[NACK_BYTECOUNT_SIZE]; + size_t nack_byte_count_[NACK_BYTECOUNT_SIZE]; Bitrate nack_bitrate_; RTPPacketHistory packet_history_; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc index 7efe987114..084a39c3bd 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -233,11 +233,11 @@ int32_t RTPSenderAudio::SendAudio( const int8_t payloadType, const uint32_t captureTimeStamp, const uint8_t* payloadData, - const uint32_t dataSize, + const size_t dataSize, const RTPFragmentationHeader* fragmentation) { // TODO(pwestin) Breakup function in smaller functions. - uint16_t payloadSize = static_cast(dataSize); - uint16_t maxPayloadLength = _rtpSender->MaxPayloadLength(); + size_t payloadSize = dataSize; + size_t maxPayloadLength = _rtpSender->MaxPayloadLength(); bool dtmfToneStarted = false; uint16_t dtmfLengthMS = 0; uint8_t key = 0; @@ -383,7 +383,7 @@ int32_t RTPSenderAudio::SendAudio( // only 0x80 if we have multiple blocks dataBuffer[rtpHeaderLength++] = 0x80 + fragmentation->fragmentationPlType[1]; - uint32_t blockLength = fragmentation->fragmentationLength[1]; + size_t blockLength = fragmentation->fragmentationLength[1]; // sanity blockLength if(blockLength > 0x3ff) { // block length 10 bits 1023 bytes @@ -406,9 +406,8 @@ int32_t RTPSenderAudio::SendAudio( payloadData + fragmentation->fragmentationOffset[0], fragmentation->fragmentationLength[0]); - payloadSize = static_cast( - fragmentation->fragmentationLength[0] + - fragmentation->fragmentationLength[1]); + payloadSize = fragmentation->fragmentationLength[0] + + fragmentation->fragmentationLength[1]; } else { // silence for too long send only new data dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0]; @@ -416,8 +415,7 @@ int32_t RTPSenderAudio::SendAudio( payloadData + fragmentation->fragmentationOffset[0], fragmentation->fragmentationLength[0]); - payloadSize = static_cast( - fragmentation->fragmentationLength[0]); + payloadSize = fragmentation->fragmentationLength[0]; } } else { if (fragmentation && fragmentation->fragmentationVectorSize > 0) { @@ -427,8 +425,7 @@ int32_t RTPSenderAudio::SendAudio( payloadData + fragmentation->fragmentationOffset[0], fragmentation->fragmentationLength[0]); - payloadSize = static_cast( - fragmentation->fragmentationLength[0]); + payloadSize = fragmentation->fragmentationLength[0]; } else { memcpy(dataBuffer+rtpHeaderLength, payloadData, payloadSize); } @@ -437,7 +434,7 @@ int32_t RTPSenderAudio::SendAudio( // Update audio level extension, if included. { - uint16_t packetSize = payloadSize + rtpHeaderLength; + size_t packetSize = payloadSize + rtpHeaderLength; RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); RTPHeader rtp_header; rtp_parser.Parse(rtp_header); @@ -451,7 +448,7 @@ int32_t RTPSenderAudio::SendAudio( "seqnum", _rtpSender->SequenceNumber()); return _rtpSender->SendToNetwork(dataBuffer, payloadSize, - static_cast(rtpHeaderLength), + rtpHeaderLength, -1, kAllowRetransmission, PacedSender::kHighPriority); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h index d3f67e5edb..1affd2a0d1 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h @@ -37,7 +37,7 @@ public: const int8_t payloadType, const uint32_t captureTimeStamp, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation); // set audio packet size, used to determine when it's time to send a DTMF packet in silence (CNG) diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc index 2a49477883..905b55907f 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -49,11 +49,9 @@ const uint8_t* GetPayloadData(const RTPHeader& rtp_header, return packet + rtp_header.headerLength; } -uint16_t GetPayloadDataLength(const RTPHeader& rtp_header, - const uint16_t packet_length) { - uint16_t length = packet_length - rtp_header.headerLength - - rtp_header.paddingLength; - return static_cast(length); +size_t GetPayloadDataLength(const RTPHeader& rtp_header, + const size_t packet_length) { + return packet_length - rtp_header.headerLength - rtp_header.paddingLength; } uint64_t ConvertMsToAbsSendTime(int64_t time_ms) { @@ -64,18 +62,20 @@ class LoopbackTransportTest : public webrtc::Transport { public: LoopbackTransportTest() : packets_sent_(0), last_sent_packet_len_(0), total_bytes_sent_(0) {} - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE { packets_sent_++; memcpy(last_sent_packet_, data, len); last_sent_packet_len_ = len; - total_bytes_sent_ += static_cast(len); - return len; + total_bytes_sent_ += len; + return static_cast(len); } - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE { return -1; } int packets_sent_; - int last_sent_packet_len_; + size_t last_sent_packet_len_; size_t total_bytes_sent_; uint8_t last_sent_packet_[kMaxPacketLength]; }; @@ -114,7 +114,7 @@ class RtpSenderTest : public ::testing::Test { EXPECT_EQ(kTimestamp, rtp_header.timestamp); EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc); EXPECT_EQ(0, rtp_header.numCSRCs); - EXPECT_EQ(0, rtp_header.paddingLength); + EXPECT_EQ(0U, rtp_header.paddingLength); } void SendPacket(int64_t capture_time_ms, int payload_length) { @@ -124,6 +124,7 @@ class RtpSenderTest : public ::testing::Test { kMarkerBit, timestamp, capture_time_ms); + ASSERT_GE(rtp_length, 0); // Packet should be stored in a send bucket. EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, @@ -136,40 +137,40 @@ class RtpSenderTest : public ::testing::Test { }; TEST_F(RtpSenderTest, RegisterRtpTransmissionTimeOffsetHeaderExtension) { - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId)); EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( kRtpExtensionTransmissionTimeOffset)); - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); } TEST_F(RtpSenderTest, RegisterRtpAbsoluteSendTimeHeaderExtension) { - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId)); EXPECT_EQ(kRtpOneByteHeaderLength + kAbsoluteSendTimeLength, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( kRtpExtensionAbsoluteSendTime)); - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); } TEST_F(RtpSenderTest, RegisterRtpAudioLevelHeaderExtension) { - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionAudioLevel, kAudioLevelExtensionId)); EXPECT_EQ(kRtpOneByteHeaderLength + kAudioLevelLength, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( kRtpExtensionAudioLevel)); - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); } TEST_F(RtpSenderTest, RegisterRtpHeaderExtensions) { - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId)); EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength, @@ -193,16 +194,13 @@ TEST_F(RtpSenderTest, RegisterRtpHeaderExtensions) { rtp_sender_->RtpHeaderExtensionTotalLength()); EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( kRtpExtensionAudioLevel)); - EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength()); + EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); } TEST_F(RtpSenderTest, BuildRTPPacket) { - int32_t length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - 0); - EXPECT_EQ(kRtpHeaderSize, length); + size_t length = static_cast(rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, 0)); + ASSERT_EQ(kRtpHeaderSize, length); // Verify webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); @@ -227,13 +225,10 @@ TEST_F(RtpSenderTest, BuildRTPPacketWithTransmissionOffsetExtension) { EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId)); - int32_t length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - 0); - EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), - length); + size_t length = static_cast(rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, 0)); + ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), + length); // Verify webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); @@ -268,13 +263,10 @@ TEST_F(RtpSenderTest, BuildRTPPacketWithNegativeTransmissionOffsetExtension) { EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId)); - int32_t length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - 0); - EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), - length); + size_t length = static_cast(rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, 0)); + ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), + length); // Verify webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); @@ -298,13 +290,10 @@ TEST_F(RtpSenderTest, BuildRTPPacketWithAbsoluteSendTimeExtension) { EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId)); - int32_t length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - 0); - EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), - length); + size_t length = static_cast(rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, 0)); + ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), + length); // Verify webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); @@ -336,13 +325,10 @@ TEST_F(RtpSenderTest, BuildRTPPacketWithAudioLevelExtension) { EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionAudioLevel, kAudioLevelExtensionId)); - int32_t length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - 0); - EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), - length); + size_t length = static_cast(rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, 0)); + ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), + length); // Verify webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); @@ -386,13 +372,10 @@ TEST_F(RtpSenderTest, BuildRTPPacketWithHeaderExtensions) { EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionAudioLevel, kAudioLevelExtensionId)); - int32_t length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - 0); - EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), - length); + size_t length = static_cast(rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, 0)); + ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), + length); // Verify webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); @@ -447,11 +430,10 @@ TEST_F(RtpSenderTest, TrafficSmoothingWithExtensions) { kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId)); rtp_sender_->SetTargetBitrate(300000); int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); - int32_t rtp_length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - capture_time_ms); + int rtp_length_int = rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms); + ASSERT_NE(-1, rtp_length_int); + size_t rtp_length = static_cast(rtp_length_int); // Packet should be stored in a send bucket. EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, @@ -501,11 +483,10 @@ TEST_F(RtpSenderTest, TrafficSmoothingRetransmits) { kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId)); rtp_sender_->SetTargetBitrate(300000); int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); - int32_t rtp_length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - kTimestamp, - capture_time_ms); + int rtp_length_int = rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms); + ASSERT_NE(-1, rtp_length_int); + size_t rtp_length = static_cast(rtp_length_int); // Packet should be stored in a send bucket. EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, @@ -524,7 +505,7 @@ TEST_F(RtpSenderTest, TrafficSmoothingRetransmits) { const int kStoredTimeInMs = 100; fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs); - EXPECT_EQ(rtp_length, rtp_sender_->ReSendPacket(kSeqNum)); + EXPECT_EQ(rtp_length_int, rtp_sender_->ReSendPacket(kSeqNum)); EXPECT_EQ(0, transport_.packets_sent_); rtp_sender_->TimeToSendPacket(kSeqNum, capture_time_ms, false); @@ -562,7 +543,7 @@ TEST_F(RtpSenderTest, SendPadding) { uint16_t seq_num = kSeqNum; uint32_t timestamp = kTimestamp; rtp_sender_->SetStorePacketsStatus(true, 10); - int32_t rtp_header_len = kRtpHeaderSize; + size_t rtp_header_len = kRtpHeaderSize; EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId)); rtp_header_len += 4; // 4 bytes extension. @@ -583,11 +564,10 @@ TEST_F(RtpSenderTest, SendPadding) { rtp_sender_->SetTargetBitrate(300000); int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); - int32_t rtp_length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - timestamp, - capture_time_ms); + int rtp_length_int = rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, timestamp, capture_time_ms); + ASSERT_NE(-1, rtp_length_int); + size_t rtp_length = static_cast(rtp_length_int); // Packet should be stored in a send bucket. EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, @@ -611,8 +591,8 @@ TEST_F(RtpSenderTest, SendPadding) { // Send padding 4 times, waiting 50 ms between each. for (int i = 0; i < 4; ++i) { const int kPaddingPeriodMs = 50; - const int kPaddingBytes = 100; - const int kMaxPaddingLength = 224; // Value taken from rtp_sender.cc. + const size_t kPaddingBytes = 100; + const size_t kMaxPaddingLength = 224; // Value taken from rtp_sender.cc. // Padding will be forced to full packets. EXPECT_EQ(kMaxPaddingLength, rtp_sender_->TimeToSendPadding(kPaddingBytes)); @@ -638,11 +618,10 @@ TEST_F(RtpSenderTest, SendPadding) { // Send a regular video packet again. capture_time_ms = fake_clock_.TimeInMilliseconds(); - rtp_length = rtp_sender_->BuildRTPheader(packet_, - kPayload, - kMarkerBit, - timestamp, - capture_time_ms); + rtp_length_int = rtp_sender_->BuildRTPheader( + packet_, kPayload, kMarkerBit, timestamp, capture_time_ms); + ASSERT_NE(-1, rtp_length_int); + rtp_length = static_cast(rtp_length_int); // Packet should be stored in a send bucket. EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_, @@ -716,15 +695,12 @@ TEST_F(RtpSenderTest, SendRedundantPayloads) { EXPECT_CALL(transport, SendPacket(_, _, kMaxPaddingSize + rtp_header_len)) .WillOnce(testing::ReturnArg<2>()); - EXPECT_EQ(kMaxPaddingSize, - static_cast(rtp_sender_->TimeToSendPadding(49))); + EXPECT_EQ(kMaxPaddingSize, rtp_sender_->TimeToSendPadding(49)); - const int kRtxHeaderSize = 2; EXPECT_CALL(transport, SendPacket(_, _, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize)) .WillOnce(testing::ReturnArg<2>()); - EXPECT_EQ(kPayloadSizes[0], - static_cast(rtp_sender_->TimeToSendPadding(500))); + EXPECT_EQ(kPayloadSizes[0], rtp_sender_->TimeToSendPadding(500)); EXPECT_CALL(transport, SendPacket(_, _, kPayloadSizes[kNumPayloadSizes - 1] + rtp_header_len + kRtxHeaderSize)) @@ -732,7 +708,7 @@ TEST_F(RtpSenderTest, SendRedundantPayloads) { EXPECT_CALL(transport, SendPacket(_, _, kMaxPaddingSize + rtp_header_len)) .WillOnce(testing::ReturnArg<2>()); EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize, - static_cast(rtp_sender_->TimeToSendPadding(999))); + rtp_sender_->TimeToSendPadding(999)); } TEST_F(RtpSenderTest, SendGenericVideo) { @@ -951,8 +927,8 @@ TEST_F(RtpSenderTest, StreamDataCountersCallbacks) { uint32_t ssrc_; StreamDataCounters counters_; - bool Matches(uint32_t ssrc, uint32_t bytes, uint32_t header_bytes, - uint32_t padding, uint32_t packets, uint32_t retransmits, + bool Matches(uint32_t ssrc, size_t bytes, size_t header_bytes, + size_t padding, uint32_t packets, uint32_t retransmits, uint32_t fec) { return ssrc_ == ssrc && counters_.bytes == bytes && @@ -1034,8 +1010,8 @@ TEST_F(RtpSenderAudioTest, SendAudio) { const uint8_t* payload_data = GetPayloadData(rtp_header, transport_.last_sent_packet_); - ASSERT_EQ(sizeof(payload), GetPayloadDataLength(rtp_header, - transport_.last_sent_packet_len_)); + ASSERT_EQ(sizeof(payload), + GetPayloadDataLength(rtp_header, transport_.last_sent_packet_len_)); EXPECT_EQ(0, memcmp(payload, payload_data, sizeof(payload))); } @@ -1063,8 +1039,8 @@ TEST_F(RtpSenderAudioTest, SendAudioWithAudioLevelExtension) { const uint8_t* payload_data = GetPayloadData(rtp_header, transport_.last_sent_packet_); - ASSERT_EQ(sizeof(payload), GetPayloadDataLength( - rtp_header, transport_.last_sent_packet_len_)); + ASSERT_EQ(sizeof(payload), + GetPayloadDataLength(rtp_header, transport_.last_sent_packet_len_)); EXPECT_EQ(0, memcmp(payload, payload_data, sizeof(payload))); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc index ec031dfc86..4792dfa668 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -100,16 +100,16 @@ int32_t RTPSenderVideo::RegisterVideoPayload( } int32_t RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer, - const uint16_t payload_length, - const uint16_t rtp_header_length, + const size_t payload_length, + const size_t rtp_header_length, const uint32_t capture_timestamp, int64_t capture_time_ms, StorageType storage, bool protect) { if (_fecEnabled) { int ret = 0; - int fec_overhead_sent = 0; - int video_sent = 0; + size_t fec_overhead_sent = 0; + size_t video_sent = 0; RedPacket* red_packet = producer_fec_.BuildRedPacket( data_buffer, payload_length, rtp_header_length, _payloadTypeRED); @@ -202,7 +202,7 @@ int32_t RTPSenderVideo::SendRTPIntraRequest() { // RFC 2032 // 5.2.1. Full intra-frame Request (FIR) packet - uint16_t length = 8; + size_t length = 8; uint8_t data[8]; data[0] = 0x80; data[1] = 192; @@ -242,7 +242,7 @@ int32_t RTPSenderVideo::GenericFECStatus(bool& enable, return 0; } -uint16_t RTPSenderVideo::FECPacketOverhead() const { +size_t RTPSenderVideo::FECPacketOverhead() const { if (_fecEnabled) { // Overhead is FEC headers plus RED for FEC header plus anything in RTP // header beyond the 12 bytes base header (CSRC list, extensions...) @@ -271,7 +271,7 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, const uint32_t captureTimeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation, VideoCodecInformation* codecInfo, const RTPVideoTypeHeader* rtpTypeHdr) { @@ -320,11 +320,11 @@ bool RTPSenderVideo::Send(const RtpVideoCodecTypes videoType, const uint32_t captureTimeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation, const RTPVideoTypeHeader* rtpTypeHdr) { uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); - int32_t payload_bytes_to_send = payloadSize; + size_t payload_bytes_to_send = payloadSize; const uint8_t* data = payloadData; size_t max_payload_length = _rtpSender.MaxDataPayloadLength(); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h index 250e36b930..f043950b9e 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h @@ -35,7 +35,7 @@ class RTPSenderVideo { virtual RtpVideoCodecTypes VideoCodecType() const; - uint16_t FECPacketOverhead() const; + size_t FECPacketOverhead() const; int32_t RegisterVideoPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE], const int8_t payloadType, @@ -48,7 +48,7 @@ class RTPSenderVideo { const uint32_t captureTimeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation, VideoCodecInformation* codecInfo, const RTPVideoTypeHeader* rtpTypeHdr); @@ -85,8 +85,8 @@ class RTPSenderVideo { protected: virtual int32_t SendVideoPacket(uint8_t* dataBuffer, - const uint16_t payloadLength, - const uint16_t rtpHeaderLength, + const size_t payloadLength, + const size_t rtpHeaderLength, const uint32_t capture_timestamp, int64_t capture_time_ms, StorageType storage, @@ -99,7 +99,7 @@ class RTPSenderVideo { const uint32_t captureTimeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader* fragmentation, const RTPVideoTypeHeader* rtpTypeHdr); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc index 441a9c50c2..2897fac636 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc @@ -286,7 +286,7 @@ bool RtpHeaderParser::ParseRtcp(RTPHeader* header) const { } const uint8_t PT = _ptrRTPDataBegin[1]; - const uint16_t len = (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3]; + const size_t len = (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3]; const uint8_t* ptr = &_ptrRTPDataBegin[4]; uint32_t SSRC = *ptr++ << 24; @@ -338,7 +338,7 @@ bool RtpHeaderParser::Parse(RTPHeader& header, return false; } - const uint8_t CSRCocts = CC * 4; + const size_t CSRCocts = CC * 4; if ((ptr + CSRCocts) > _ptrRTPDataEnd) { return false; @@ -352,7 +352,7 @@ bool RtpHeaderParser::Parse(RTPHeader& header, header.numCSRCs = CC; header.paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0; - for (unsigned int i = 0; i < CC; ++i) { + for (uint8_t i = 0; i < CC; ++i) { uint32_t CSRC = *ptr++ << 24; CSRC += *ptr++ << 16; CSRC += *ptr++ << 8; @@ -395,11 +395,11 @@ bool RtpHeaderParser::Parse(RTPHeader& header, uint16_t definedByProfile = *ptr++ << 8; definedByProfile += *ptr++; - uint16_t XLen = *ptr++ << 8; + size_t XLen = *ptr++ << 8; XLen += *ptr++; // in 32 bit words XLen *= 4; // in octs - if (remain < (4 + XLen)) { + if (static_cast(remain) < (4 + XLen)) { return false; } if (definedByProfile == kRtpOneByteHeaderExtensionId) { diff --git a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc index e62df1f5db..feed784839 100644 --- a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc +++ b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc @@ -19,9 +19,9 @@ namespace webrtc { PartitionTreeNode::PartitionTreeNode(PartitionTreeNode* parent, - const int* size_vector, - int num_partitions, - int this_size) + const size_t* size_vector, + size_t num_partitions, + size_t this_size) : parent_(parent), this_size_(this_size), size_vector_(size_vector), @@ -29,13 +29,14 @@ PartitionTreeNode::PartitionTreeNode(PartitionTreeNode* parent, max_parent_size_(0), min_parent_size_(std::numeric_limits::max()), packet_start_(false) { - assert(num_partitions >= 0); + // If |this_size_| > INT_MAX, Cost() and CreateChildren() won't work properly. + assert(this_size_ <= static_cast(std::numeric_limits::max())); children_[kLeftChild] = NULL; children_[kRightChild] = NULL; } -PartitionTreeNode* PartitionTreeNode::CreateRootNode(const int* size_vector, - int num_partitions) { +PartitionTreeNode* PartitionTreeNode::CreateRootNode(const size_t* size_vector, + size_t num_partitions) { PartitionTreeNode* root_node = new PartitionTreeNode(NULL, &size_vector[1], num_partitions - 1, size_vector[0]); @@ -48,20 +49,19 @@ PartitionTreeNode::~PartitionTreeNode() { delete children_[kRightChild]; } -int PartitionTreeNode::Cost(int penalty) { - assert(penalty >= 0); +int PartitionTreeNode::Cost(size_t penalty) { int cost = 0; if (num_partitions_ == 0) { // This is a solution node. - cost = std::max(max_parent_size_, this_size_) - - std::min(min_parent_size_, this_size_); + cost = std::max(max_parent_size_, this_size_int()) - + std::min(min_parent_size_, this_size_int()); } else { - cost = std::max(max_parent_size_, this_size_) - min_parent_size_; + cost = std::max(max_parent_size_, this_size_int()) - min_parent_size_; } return cost + NumPackets() * penalty; } -bool PartitionTreeNode::CreateChildren(int max_size) { +bool PartitionTreeNode::CreateChildren(size_t max_size) { assert(max_size > 0); bool children_created = false; if (num_partitions_ > 0) { @@ -85,9 +85,9 @@ bool PartitionTreeNode::CreateChildren(int max_size) { num_partitions_ - 1, size_vector_[0]); children_[kRightChild]->set_max_parent_size( - std::max(max_parent_size_, this_size_)); + std::max(max_parent_size_, this_size_int())); children_[kRightChild]->set_min_parent_size( - std::min(min_parent_size_, this_size_)); + std::min(min_parent_size_, this_size_int())); // "Right" child starts a new packet. children_[kRightChild]->set_packet_start(true); children_created = true; @@ -96,7 +96,7 @@ bool PartitionTreeNode::CreateChildren(int max_size) { return children_created; } -int PartitionTreeNode::NumPackets() { +size_t PartitionTreeNode::NumPackets() { if (parent_ == NULL) { // Root node is a "right" child by definition. return 1; @@ -110,8 +110,8 @@ int PartitionTreeNode::NumPackets() { } } -PartitionTreeNode* PartitionTreeNode::GetOptimalNode(int max_size, - int penalty) { +PartitionTreeNode* PartitionTreeNode::GetOptimalNode(size_t max_size, + size_t penalty) { CreateChildren(max_size); PartitionTreeNode* left = children_[kLeftChild]; PartitionTreeNode* right = children_[kRightChild]; @@ -148,12 +148,11 @@ PartitionTreeNode* PartitionTreeNode::GetOptimalNode(int max_size, Vp8PartitionAggregator::Vp8PartitionAggregator( const RTPFragmentationHeader& fragmentation, - int first_partition_idx, int last_partition_idx) + size_t first_partition_idx, size_t last_partition_idx) : root_(NULL), num_partitions_(last_partition_idx - first_partition_idx + 1), - size_vector_(new int[num_partitions_]), + size_vector_(new size_t[num_partitions_]), largest_partition_size_(0) { - assert(first_partition_idx >= 0); assert(last_partition_idx >= first_partition_idx); assert(last_partition_idx < fragmentation.fragmentationVectorSize); for (size_t i = 0; i < num_partitions_; ++i) { @@ -179,17 +178,18 @@ void Vp8PartitionAggregator::SetPriorMinMax(int min_size, int max_size) { } Vp8PartitionAggregator::ConfigVec -Vp8PartitionAggregator::FindOptimalConfiguration(int max_size, int penalty) { +Vp8PartitionAggregator::FindOptimalConfiguration(size_t max_size, + size_t penalty) { assert(root_); assert(max_size >= largest_partition_size_); PartitionTreeNode* opt = root_->GetOptimalNode(max_size, penalty); ConfigVec config_vector(num_partitions_, 0); PartitionTreeNode* temp_node = opt; - int packet_index = opt->NumPackets() - 1; - for (int i = num_partitions_ - 1; i >= 0; --i) { - assert(packet_index >= 0); + size_t packet_index = opt->NumPackets(); + for (size_t i = num_partitions_; i > 0; --i) { + assert(packet_index > 0); assert(temp_node != NULL); - config_vector[i] = packet_index; + config_vector[i - 1] = packet_index - 1; if (temp_node->packet_start()) --packet_index; temp_node = temp_node->parent(); } @@ -204,51 +204,54 @@ void Vp8PartitionAggregator::CalcMinMax(const ConfigVec& config, if (*max_size < 0) { *max_size = 0; } - unsigned int i = 0; + size_t i = 0; while (i < config.size()) { - int this_size = 0; - unsigned int j = i; + size_t this_size = 0; + size_t j = i; while (j < config.size() && config[i] == config[j]) { this_size += size_vector_[j]; ++j; } i = j; - if (this_size < *min_size) { + if (this_size < static_cast(*min_size)) { *min_size = this_size; } - if (this_size > *max_size) { + if (this_size > static_cast(*max_size)) { *max_size = this_size; } } } -int Vp8PartitionAggregator::CalcNumberOfFragments(int large_partition_size, - int max_payload_size, - int penalty, - int min_size, - int max_size) { - assert(max_size <= max_payload_size); - assert(min_size <= max_size); +size_t Vp8PartitionAggregator::CalcNumberOfFragments( + size_t large_partition_size, + size_t max_payload_size, + size_t penalty, + int min_size, + int max_size) { + assert(large_partition_size > 0); assert(max_payload_size > 0); + assert(min_size != 0); + assert(min_size <= max_size); + assert(max_size <= static_cast(max_payload_size)); // Divisions with rounding up. - const int min_number_of_fragments = + const size_t min_number_of_fragments = (large_partition_size + max_payload_size - 1) / max_payload_size; if (min_size < 0 || max_size < 0) { // No aggregates produced, so we do not have any size boundaries. // Simply split in as few partitions as possible. return min_number_of_fragments; } - const int max_number_of_fragments = + const size_t max_number_of_fragments = (large_partition_size + min_size - 1) / min_size; int num_fragments = -1; - int best_cost = std::numeric_limits::max(); - for (int n = min_number_of_fragments; n <= max_number_of_fragments; ++n) { + size_t best_cost = std::numeric_limits::max(); + for (size_t n = min_number_of_fragments; n <= max_number_of_fragments; ++n) { // Round up so that we use the largest fragment. - int fragment_size = (large_partition_size + n - 1) / n; - int cost = 0; - if (fragment_size < min_size) { + size_t fragment_size = (large_partition_size + n - 1) / n; + size_t cost = 0; + if (fragment_size < static_cast(min_size)) { cost = min_size - fragment_size + n * penalty; - } else if (fragment_size > max_size) { + } else if (fragment_size > static_cast(max_size)) { cost = fragment_size - max_size + n * penalty; } else { cost = n * penalty; diff --git a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h index cbb1207b8e..67babcb330 100644 --- a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h +++ b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h @@ -24,13 +24,13 @@ class PartitionTreeNode { public: // Create a tree node. PartitionTreeNode(PartitionTreeNode* parent, - const int* size_vector, - int num_partitions, - int this_size); + const size_t* size_vector, + size_t num_partitions, + size_t this_size); // Create a root node. - static PartitionTreeNode* CreateRootNode(const int* size_vector, - int num_partitions); + static PartitionTreeNode* CreateRootNode(const size_t* size_vector, + size_t num_partitions); ~PartitionTreeNode(); @@ -38,18 +38,18 @@ class PartitionTreeNode { // will be the actual cost associated with that solution. If not, the cost // will be the cost accumulated so far along the current branch (which is a // lower bound for any solution along the branch). - int Cost(int penalty); + int Cost(size_t penalty); // Create the two children for this node. - bool CreateChildren(int max_size); + bool CreateChildren(size_t max_size); // Get the number of packets for the configuration that this node represents. - int NumPackets(); + size_t NumPackets(); // Find the optimal solution given a maximum packet size and a per-packet // penalty. The method will be recursively called while the solver is // probing down the tree of nodes. - PartitionTreeNode* GetOptimalNode(int max_size, int penalty); + PartitionTreeNode* GetOptimalNode(size_t max_size, size_t penalty); // Setters and getters. void set_max_parent_size(int size) { max_parent_size_ = size; } @@ -57,7 +57,7 @@ class PartitionTreeNode { PartitionTreeNode* parent() const { return parent_; } PartitionTreeNode* left_child() const { return children_[kLeftChild]; } PartitionTreeNode* right_child() const { return children_[kRightChild]; } - int this_size() const { return this_size_; } + size_t this_size() const { return this_size_; } bool packet_start() const { return packet_start_; } private: @@ -66,13 +66,14 @@ class PartitionTreeNode { kRightChild = 1 }; + int this_size_int() const { return static_cast(this_size_); } void set_packet_start(bool value) { packet_start_ = value; } PartitionTreeNode* parent_; PartitionTreeNode* children_[2]; - int this_size_; - const int* size_vector_; - int num_partitions_; + size_t this_size_; + const size_t* size_vector_; + size_t num_partitions_; int max_parent_size_; int min_parent_size_; bool packet_start_; @@ -84,13 +85,14 @@ class PartitionTreeNode { // the maximum packet size. class Vp8PartitionAggregator { public: - typedef std::vector ConfigVec; + typedef std::vector ConfigVec; // Constructor. All partitions in the fragmentation header from index // first_partition_idx to last_partition_idx must be smaller than // maximum packet size to be used in FindOptimalConfiguration. Vp8PartitionAggregator(const RTPFragmentationHeader& fragmentation, - int first_partition_idx, int last_partition_idx); + size_t first_partition_idx, + size_t last_partition_idx); ~Vp8PartitionAggregator(); @@ -103,7 +105,7 @@ class Vp8PartitionAggregator { // first_partition_idx + 1), where each element indicates the packet index // for that partition. Thus, the output vector starts at 0 and is increasing // up to the number of packets - 1. - ConfigVec FindOptimalConfiguration(int max_size, int penalty); + ConfigVec FindOptimalConfiguration(size_t max_size, size_t penalty); // Calculate minimum and maximum packet sizes for a given aggregation config. // The extreme packet sizes of the given aggregation are compared with the @@ -116,17 +118,17 @@ class Vp8PartitionAggregator { // be larger than max_payload_size. Each fragment comes at an overhead cost // of penalty bytes. If the size of the fragments fall outside the range // [min_size, max_size], an extra cost is inflicted. - static int CalcNumberOfFragments(int large_partition_size, - int max_payload_size, - int penalty, - int min_size, - int max_size); + static size_t CalcNumberOfFragments(size_t large_partition_size, + size_t max_payload_size, + size_t penalty, + int min_size, + int max_size); private: PartitionTreeNode* root_; size_t num_partitions_; - int* size_vector_; - int largest_partition_size_; + size_t* size_vector_; + size_t largest_partition_size_; DISALLOW_COPY_AND_ASSIGN(Vp8PartitionAggregator); }; diff --git a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc index d4ebd77b87..4650c94047 100644 --- a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc @@ -16,8 +16,8 @@ namespace webrtc { TEST(PartitionTreeNode, CreateAndDelete) { - const int kVector[] = {1, 2, 3}; - const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]); + const size_t kVector[] = {1, 2, 3}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector); PartitionTreeNode* node1 = PartitionTreeNode::CreateRootNode(kVector, kNumPartitions); PartitionTreeNode* node2 = @@ -27,17 +27,17 @@ TEST(PartitionTreeNode, CreateAndDelete) { } TEST(PartitionTreeNode, CreateChildrenAndDelete) { - const int kVector[] = {1, 2, 3}; - const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]); - const int kMaxSize = 10; - const int kPenalty = 5; + const size_t kVector[] = {1, 2, 3}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector); + const size_t kMaxSize = 10; + const size_t kPenalty = 5; PartitionTreeNode* root = PartitionTreeNode::CreateRootNode(kVector, kNumPartitions); EXPECT_TRUE(root->CreateChildren(kMaxSize)); ASSERT_TRUE(NULL != root->left_child()); ASSERT_TRUE(NULL != root->right_child()); - EXPECT_EQ(3, root->left_child()->this_size()); - EXPECT_EQ(2, root->right_child()->this_size()); + EXPECT_EQ(3u, root->left_child()->this_size()); + EXPECT_EQ(2u, root->right_child()->this_size()); EXPECT_EQ(11, root->right_child()->Cost(kPenalty)); EXPECT_FALSE(root->left_child()->packet_start()); EXPECT_TRUE(root->right_child()->packet_start()); @@ -45,17 +45,17 @@ TEST(PartitionTreeNode, CreateChildrenAndDelete) { } TEST(PartitionTreeNode, FindOptimalConfig) { - const int kVector[] = {197, 194, 213, 215, 184, 199, 197, 207}; - const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]); - const int kMaxSize = 1500; - const int kPenalty = 1; + const size_t kVector[] = {197, 194, 213, 215, 184, 199, 197, 207}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector); + const size_t kMaxSize = 1500; + const size_t kPenalty = 1; PartitionTreeNode* root = PartitionTreeNode::CreateRootNode(kVector, kNumPartitions); root->set_max_parent_size(500); root->set_min_parent_size(300); PartitionTreeNode* opt = root->GetOptimalNode(kMaxSize, kPenalty); ASSERT_TRUE(opt != NULL); - EXPECT_EQ(4, opt->NumPackets()); + EXPECT_EQ(4u, opt->NumPackets()); // Expect optimal sequence to be {1, 0, 1, 0, 1, 0, 1, 0}, which corresponds // to (right)-left-right-left-right-left-right-left, where the root node is // implicitly a "right" node by definition. @@ -76,23 +76,24 @@ TEST(PartitionTreeNode, FindOptimalConfig) { } TEST(PartitionTreeNode, FindOptimalConfigSinglePartition) { - const int kVector[] = {17}; - const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]); - const int kMaxSize = 1500; - const int kPenalty = 1; + const size_t kVector[] = {17}; + const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector); + const size_t kMaxSize = 1500; + const size_t kPenalty = 1; PartitionTreeNode* root = PartitionTreeNode::CreateRootNode(kVector, kNumPartitions); PartitionTreeNode* opt = root->GetOptimalNode(kMaxSize, kPenalty); ASSERT_TRUE(opt != NULL); - EXPECT_EQ(1, opt->NumPackets()); + EXPECT_EQ(1u, opt->NumPackets()); EXPECT_TRUE(opt == root); delete root; } -static void VerifyConfiguration(const int* expected_config, - size_t expected_config_len, - const std::vector& opt_config, - const RTPFragmentationHeader& fragmentation) { +static void VerifyConfiguration( + const size_t* expected_config, + size_t expected_config_len, + const Vp8PartitionAggregator::ConfigVec& opt_config, + const RTPFragmentationHeader& fragmentation) { ASSERT_EQ(expected_config_len, fragmentation.fragmentationVectorSize); EXPECT_EQ(expected_config_len, opt_config.size()); for (size_t i = 0; i < expected_config_len; ++i) { @@ -101,7 +102,7 @@ static void VerifyConfiguration(const int* expected_config, } static void VerifyMinMax(const Vp8PartitionAggregator& aggregator, - const std::vector& opt_config, + const Vp8PartitionAggregator::ConfigVec& opt_config, int expected_min, int expected_max) { int min_size = -1; @@ -133,13 +134,12 @@ TEST(Vp8PartitionAggregator, FindOptimalConfig) { Vp8PartitionAggregator* aggregator = new Vp8PartitionAggregator(fragmentation, 0, 7); aggregator->SetPriorMinMax(300, 500); - int kMaxSize = 1500; - int kPenalty = 1; - std::vector opt_config = aggregator->FindOptimalConfiguration(kMaxSize, - kPenalty); - const int kExpectedConfig[] = {0, 0, 1, 1, 2, 2, 3, 3}; - const size_t kExpectedConfigSize = - sizeof(kExpectedConfig) / sizeof(kExpectedConfig[0]); + size_t kMaxSize = 1500; + size_t kPenalty = 1; + Vp8PartitionAggregator::ConfigVec opt_config = + aggregator->FindOptimalConfiguration(kMaxSize, kPenalty); + const size_t kExpectedConfig[] = {0, 0, 1, 1, 2, 2, 3, 3}; + const size_t kExpectedConfigSize = GTEST_ARRAY_SIZE_(kExpectedConfig); VerifyConfiguration(kExpectedConfig, kExpectedConfigSize, opt_config, fragmentation); VerifyMinMax(*aggregator, opt_config, 383, 428); @@ -166,13 +166,12 @@ TEST(Vp8PartitionAggregator, FindOptimalConfigEqualFragments) { fragmentation.fragmentationLength[7] = 200; Vp8PartitionAggregator* aggregator = new Vp8PartitionAggregator(fragmentation, 0, 7); - int kMaxSize = 1500; - int kPenalty = 1; - std::vector opt_config = aggregator->FindOptimalConfiguration(kMaxSize, - kPenalty); - const int kExpectedConfig[] = {0, 0, 0, 0, 1, 1, 1, 1}; - const size_t kExpectedConfigSize = - sizeof(kExpectedConfig) / sizeof(kExpectedConfig[0]); + size_t kMaxSize = 1500; + size_t kPenalty = 1; + Vp8PartitionAggregator::ConfigVec opt_config = + aggregator->FindOptimalConfiguration(kMaxSize, kPenalty); + const size_t kExpectedConfig[] = {0, 0, 0, 0, 1, 1, 1, 1}; + const size_t kExpectedConfigSize = GTEST_ARRAY_SIZE_(kExpectedConfig); VerifyConfiguration(kExpectedConfig, kExpectedConfigSize, opt_config, fragmentation); VerifyMinMax(*aggregator, opt_config, 800, 800); @@ -185,13 +184,12 @@ TEST(Vp8PartitionAggregator, FindOptimalConfigSinglePartition) { fragmentation.fragmentationLength[0] = 17; Vp8PartitionAggregator* aggregator = new Vp8PartitionAggregator(fragmentation, 0, 0); - int kMaxSize = 1500; - int kPenalty = 1; - std::vector opt_config = aggregator->FindOptimalConfiguration(kMaxSize, - kPenalty); - const int kExpectedConfig[] = {0}; - const size_t kExpectedConfigSize = - sizeof(kExpectedConfig) / sizeof(kExpectedConfig[0]); + size_t kMaxSize = 1500; + size_t kPenalty = 1; + Vp8PartitionAggregator::ConfigVec opt_config = + aggregator->FindOptimalConfiguration(kMaxSize, kPenalty); + const size_t kExpectedConfig[] = {0}; + const size_t kExpectedConfigSize = GTEST_ARRAY_SIZE_(kExpectedConfig); VerifyConfiguration(kExpectedConfig, kExpectedConfigSize, opt_config, fragmentation); VerifyMinMax(*aggregator, opt_config, 17, 17); @@ -200,13 +198,13 @@ TEST(Vp8PartitionAggregator, FindOptimalConfigSinglePartition) { TEST(Vp8PartitionAggregator, TestCalcNumberOfFragments) { const int kMTU = 1500; - EXPECT_EQ(2, + EXPECT_EQ(2u, Vp8PartitionAggregator::CalcNumberOfFragments( 1600, kMTU, 1, 300, 900)); - EXPECT_EQ(3, + EXPECT_EQ(3u, Vp8PartitionAggregator::CalcNumberOfFragments( 1600, kMTU, 1, 300, 798)); - EXPECT_EQ(2, + EXPECT_EQ(2u, Vp8PartitionAggregator::CalcNumberOfFragments( 1600, kMTU, 1, 900, 1000)); } diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc index 9e706e7dd5..77ee6fb722 100644 --- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc +++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc @@ -33,12 +33,12 @@ public: protected: // Inherited from UdpTransportData virtual void IncomingRTPPacket(const int8_t* incomingRtpPacket, - const int32_t rtpPacketLength, + const size_t rtpPacketLength, const int8_t* fromIP, const uint16_t fromPort) OVERRIDE; virtual void IncomingRTCPPacket(const int8_t* incomingRtcpPacket, - const int32_t rtcpPacketLength, + const size_t rtcpPacketLength, const int8_t* fromIP, const uint16_t fromPort) OVERRIDE; @@ -47,21 +47,21 @@ private: }; void myTransportCB::IncomingRTPPacket(const int8_t* incomingRtpPacket, - const int32_t rtpPacketLength, + const size_t rtpPacketLength, const int8_t* fromIP, const uint16_t fromPort) { printf("Receiving RTP from IP %s, port %u\n", fromIP, fromPort); - _rtpMod->IncomingPacket((uint8_t *) incomingRtpPacket, static_cast(rtpPacketLength)); + _rtpMod->IncomingPacket((uint8_t *) incomingRtpPacket, rtpPacketLength); } void myTransportCB::IncomingRTCPPacket(const int8_t* incomingRtcpPacket, - const int32_t rtcpPacketLength, + const size_t rtcpPacketLength, const int8_t* fromIP, const uint16_t fromPort) { printf("Receiving RTCP from IP %s, port %u\n", fromIP, fromPort); - _rtpMod->IncomingPacket((uint8_t *) incomingRtcpPacket, static_cast(rtcpPacketLength)); + _rtpMod->IncomingPacket((uint8_t *) incomingRtcpPacket, rtcpPacketLength); } diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc index 6a66f26770..6b322f7c64 100644 --- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc +++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc @@ -131,7 +131,7 @@ int TestLoadGenerator::generatePayload () int TestLoadGenerator::sendPayload (const uint32_t timeStamp, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const webrtc::FrameType frameType /*= webrtc::kVideoFrameDelta*/) { @@ -139,7 +139,10 @@ int TestLoadGenerator::sendPayload (const uint32_t timeStamp, } -CBRGenerator::CBRGenerator (TestSenderReceiver *sender, int32_t payloadSizeBytes, int32_t bitrateKbps, int32_t rtpSampleRate) +CBRGenerator::CBRGenerator (TestSenderReceiver *sender, + size_t payloadSizeBytes, + int32_t bitrateKbps, + int32_t rtpSampleRate) : //_eventPtr(NULL), _payloadSizeBytes(payloadSizeBytes), @@ -300,10 +303,10 @@ bool CBRFixFRGenerator::GeneratorLoop () return true; } -int32_t CBRFixFRGenerator::nextPayloadSize() +size_t CBRFixFRGenerator::nextPayloadSize() { const double periodMs = 1000.0 / _frameRateFps; - return static_cast(_bitrateKbps * periodMs / 8 + 0.5); + return static_cast(_bitrateKbps * periodMs / 8 + 0.5); } int CBRFixFRGenerator::generatePayload ( uint32_t timestamp ) @@ -313,7 +316,7 @@ int CBRFixFRGenerator::generatePayload ( uint32_t timestamp ) double factor = ((double) rand() - RAND_MAX/2) / RAND_MAX; // [-0.5; 0.5] factor = 1 + 2 * _spreadFactor * factor; // [1 - _spreadFactor ; 1 + _spreadFactor] - int32_t thisPayloadBytes = static_cast(_payloadSizeBytes * factor); + size_t thisPayloadBytes = static_cast(_payloadSizeBytes * factor); // sanity if (thisPayloadBytes > _payloadAllocLen) { @@ -338,15 +341,17 @@ CBRFixFRGenerator(sender, bitrateKbps, rtpSampleRate, frameRateFps, spread) { } -int32_t PeriodicKeyFixFRGenerator::nextPayloadSize() +size_t PeriodicKeyFixFRGenerator::nextPayloadSize() { // calculate payload size for a delta frame - int32_t payloadSizeBytes = static_cast(1000 * _bitrateKbps / (8.0 * _frameRateFps * (1.0 + (_keyFactor - 1.0) / _keyPeriod)) + 0.5); + size_t payloadSizeBytes = static_cast(1000 * _bitrateKbps / + (8.0 * _frameRateFps * (1.0 + (_keyFactor - 1.0) / _keyPeriod)) + 0.5); if (_frameCount % _keyPeriod == 0) { // this is a key frame, scale the payload size - payloadSizeBytes = static_cast(_keyFactor * _payloadSizeBytes + 0.5); + payloadSizeBytes = + static_cast(_keyFactor * _payloadSizeBytes + 0.5); } _frameCount++; @@ -396,7 +401,7 @@ void CBRVarFRGenerator::ChangeFrameRate() printf("New frame rate: %d\n", _frameRateFps); } -int32_t CBRVarFRGenerator::nextPayloadSize() +size_t CBRVarFRGenerator::nextPayloadSize() { ChangeFrameRate(); return CBRFixFRGenerator::nextPayloadSize(); @@ -416,7 +421,7 @@ CBRFrameDropGenerator::~CBRFrameDropGenerator() { } -int32_t CBRFrameDropGenerator::nextPayloadSize() +size_t CBRFrameDropGenerator::nextPayloadSize() { _accBits -= 1000 * _bitrateKbps / _frameRateFps; if (_accBits < 0) @@ -432,8 +437,10 @@ int32_t CBRFrameDropGenerator::nextPayloadSize() { //printf("keep\n"); const double periodMs = 1000.0 / _frameRateFps; - int32_t frameSize = static_cast(_bitrateKbps * periodMs / 8 + 0.5); - frameSize = std::max(frameSize, static_cast(300 * periodMs / 8 + 0.5)); + size_t frameSize = + static_cast(_bitrateKbps * periodMs / 8 + 0.5); + frameSize = + std::max(frameSize, static_cast(300 * periodMs / 8 + 0.5)); _accBits += frameSize * 8; return frameSize; } diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h index 61ebec867d..fafdbf0c28 100644 --- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h +++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h @@ -39,7 +39,7 @@ protected: int generatePayload (); int sendPayload (const uint32_t timeStamp, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const webrtc::FrameType frameType = webrtc::kVideoFrameDelta); webrtc::CriticalSectionWrapper* _critSect; @@ -55,7 +55,10 @@ protected: class CBRGenerator : public TestLoadGenerator { public: - CBRGenerator (TestSenderReceiver *sender, int32_t payloadSizeBytes, int32_t bitrateKbps, int32_t rtpSampleRate = 90000); + CBRGenerator (TestSenderReceiver *sender, + size_t payloadSizeBytes, + int32_t bitrateKbps, + int32_t rtpSampleRate = 90000); virtual ~CBRGenerator (); virtual int32_t Start () {return (TestLoadGenerator::Start("CBRGenerator"));}; @@ -65,7 +68,7 @@ public: protected: virtual int generatePayload ( uint32_t timestamp ); - int32_t _payloadSizeBytes; + size_t _payloadSizeBytes; uint8_t *_payload; }; @@ -82,12 +85,12 @@ public: virtual bool GeneratorLoop (); protected: - virtual int32_t nextPayloadSize (); + virtual size_t nextPayloadSize (); virtual int generatePayload ( uint32_t timestamp ); - int32_t _payloadSizeBytes; + size_t _payloadSizeBytes; uint8_t *_payload; - int32_t _payloadAllocLen; + size_t _payloadAllocLen; int32_t _frameRateFps; double _spreadFactor; }; @@ -100,7 +103,7 @@ public: virtual ~PeriodicKeyFixFRGenerator () {} protected: - virtual int32_t nextPayloadSize (); + virtual size_t nextPayloadSize (); double _keyFactor; uint32_t _keyPeriod; @@ -120,7 +123,7 @@ public: protected: virtual void ChangeFrameRate(); - virtual int32_t nextPayloadSize (); + virtual size_t nextPayloadSize (); double _avgFrPeriodMs; double _frSpreadFactor; @@ -138,7 +141,7 @@ public: ~CBRFrameDropGenerator(); protected: - virtual int32_t nextPayloadSize(); + virtual size_t nextPayloadSize(); double _accBits; }; diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc index a536ebcc24..50c1981719 100644 --- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc +++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc @@ -256,9 +256,9 @@ bool TestSenderReceiver::ProcLoop(void) int32_t TestSenderReceiver::ReceiveBitrateKbps () { - uint32_t bytesSent; + size_t bytesSent; uint32_t packetsSent; - uint32_t bytesReceived; + size_t bytesReceived; uint32_t packetsReceived; if (_rtp->DataCountersRTP(&bytesSent, &packetsSent, &bytesReceived, &packetsReceived) == 0) @@ -290,7 +290,7 @@ int32_t TestSenderReceiver::SetPacketTimeout(const uint32_t timeoutMS) int32_t TestSenderReceiver::OnReceivedPayloadData(const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const webrtc::WebRtcRTPHeader* rtpHeader) { //printf("OnReceivedPayloadData\n"); @@ -299,21 +299,21 @@ int32_t TestSenderReceiver::OnReceivedPayloadData(const uint8_t* payloadData, void TestSenderReceiver::IncomingRTPPacket(const int8_t* incomingRtpPacket, - const int32_t rtpPacketLength, - const int8_t* fromIP, - const uint16_t fromPort) + const size_t rtpPacketLength, + const int8_t* fromIP, + const uint16_t fromPort) { - _rtp->IncomingPacket((uint8_t *) incomingRtpPacket, static_cast(rtpPacketLength)); + _rtp->IncomingPacket((uint8_t *) incomingRtpPacket, rtpPacketLength); } void TestSenderReceiver::IncomingRTCPPacket(const int8_t* incomingRtcpPacket, - const int32_t rtcpPacketLength, - const int8_t* fromIP, - const uint16_t fromPort) + const size_t rtcpPacketLength, + const int8_t* fromIP, + const uint16_t fromPort) { - _rtp->IncomingPacket((uint8_t *) incomingRtcpPacket, static_cast(rtcpPacketLength)); + _rtp->IncomingPacket((uint8_t *) incomingRtcpPacket, rtcpPacketLength); } @@ -386,7 +386,7 @@ int32_t TestSenderReceiver::InitSender (const uint32_t startBitrateKbps, int32_t TestSenderReceiver::SendOutgoingData(const uint32_t timeStamp, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const webrtc::FrameType frameType /*= webrtc::kVideoFrameDelta*/) { return (_rtp->SendOutgoingData(frameType, _payloadType, timeStamp, payloadData, payloadSize)); diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h index 3968e65ae4..30a84c960a 100644 --- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h +++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h @@ -90,18 +90,18 @@ public: // Inherited from RtpData virtual int32_t OnReceivedPayloadData( const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const webrtc::WebRtcRTPHeader* rtpHeader) OVERRIDE; // Inherited from UdpTransportData virtual void IncomingRTPPacket(const int8_t* incomingRtpPacket, - const int32_t rtpPacketLength, + const size_t rtpPacketLength, const int8_t* fromIP, const uint16_t fromPort) OVERRIDE; virtual void IncomingRTCPPacket(const int8_t* incomingRtcpPacket, - const int32_t rtcpPacketLength, + const size_t rtcpPacketLength, const int8_t* fromIP, const uint16_t fromPort) OVERRIDE; @@ -118,7 +118,7 @@ public: int32_t SendOutgoingData(const uint32_t timeStamp, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const webrtc::FrameType frameType = webrtc::kVideoFrameDelta); int32_t SetLoadGenerator(TestLoadGenerator *generator); @@ -150,7 +150,7 @@ private: bool _isSender; bool _isReceiver; SendRecCB * _sendRecCB; - uint32_t _lastBytesReceived; + size_t _lastBytesReceived; int64_t _lastTime; }; diff --git a/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h b/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h index bd9d197b67..0085641e51 100644 --- a/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h +++ b/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h @@ -43,7 +43,7 @@ class LoopBackTransport : public webrtc::Transport { void DropEveryNthPacket(int n) { _packetLoss = n; } - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE { _count++; if (_packetLoss > 0) { if ((_count % _packetLoss) == 0) { @@ -52,9 +52,7 @@ class LoopBackTransport : public webrtc::Transport { } RTPHeader header; scoped_ptr parser(RtpHeaderParser::Create()); - if (!parser->Parse(static_cast(data), - static_cast(len), - &header)) { + if (!parser->Parse(static_cast(data), len, &header)) { return -1; } PayloadUnion payload_specific; @@ -70,11 +68,13 @@ class LoopBackTransport : public webrtc::Transport { } return len; } - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE { + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE { if (_rtpRtcpModule->IncomingRtcpPacket((const uint8_t*)data, len) < 0) { return -1; } - return len; + return static_cast(len); } private: int _count; @@ -90,7 +90,7 @@ class TestRtpReceiver : public NullRtpData { virtual int32_t OnReceivedPayloadData( const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const webrtc::WebRtcRTPHeader* rtpHeader) OVERRIDE { EXPECT_LE(payloadSize, sizeof(_payloadData)); memcpy(_payloadData, payloadData, payloadSize); @@ -103,7 +103,7 @@ class TestRtpReceiver : public NullRtpData { return _payloadData; } - uint16_t payload_size() const { + size_t payload_size() const { return _payloadSize; } @@ -113,7 +113,7 @@ class TestRtpReceiver : public NullRtpData { private: uint8_t _payloadData[1500]; - uint16_t _payloadSize; + size_t _payloadSize; webrtc::WebRtcRTPHeader _rtpHeader; }; diff --git a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc index 0832f63a9b..49ee83a7db 100644 --- a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc +++ b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc @@ -27,11 +27,11 @@ class VerifyingAudioReceiver : public NullRtpData { public: virtual int32_t OnReceivedPayloadData( const uint8_t* payloadData, - const uint16_t payloadSize, + const size_t payloadSize, const webrtc::WebRtcRTPHeader* rtpHeader) OVERRIDE { if (rtpHeader->header.payloadType == 98 || rtpHeader->header.payloadType == 99) { - EXPECT_EQ(4, payloadSize); + EXPECT_EQ(4u, payloadSize); char str[5]; memcpy(str, payloadData, payloadSize); str[4] = 0; @@ -265,10 +265,10 @@ TEST_F(RtpRtcpAudioTest, RED) { RTPFragmentationHeader fragmentation; fragmentation.fragmentationVectorSize = 2; - fragmentation.fragmentationLength = new uint32_t[2]; + fragmentation.fragmentationLength = new size_t[2]; fragmentation.fragmentationLength[0] = 4; fragmentation.fragmentationLength[1] = 4; - fragmentation.fragmentationOffset = new uint32_t[2]; + fragmentation.fragmentationOffset = new size_t[2]; fragmentation.fragmentationOffset[0] = 0; fragmentation.fragmentationOffset[1] = 4; fragmentation.fragmentationTimeDiff = new uint16_t[2]; diff --git a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc index 4c4944d9f8..ddcfa9674c 100644 --- a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc +++ b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc @@ -73,43 +73,42 @@ class RtpRtcpVideoTest : public ::testing::Test { 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(0x80); // version 2 dataBuffer[1] = static_cast(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(&(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 @@ class RtpRtcpVideoTest : public ::testing::Test { 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, BasicVideo) { } 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 @@ TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) { 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 parser(RtpHeaderParser::Create()); @@ -175,11 +174,11 @@ TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) { 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; diff --git a/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc b/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc index bdb53afebc..f1353b8d8d 100644 --- a/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc +++ b/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc @@ -232,7 +232,7 @@ TEST(FecTest, FecTest) { for (uint32_t i = 0; i < numMediaPackets; ++i) { mediaPacket = new ForwardErrorCorrection::Packet; mediaPacketList.push_back(mediaPacket); - mediaPacket->length = static_cast( + mediaPacket->length = static_cast( (static_cast(rand()) / RAND_MAX) * (IP_PACKET_SIZE - 12 - 28 - ForwardErrorCorrection::PacketOverhead())); @@ -264,7 +264,7 @@ TEST(FecTest, FecTest) { timeStamp); RtpUtility::AssignUWord32ToBuffer(&mediaPacket->data[8], ssrc); // Generate random values for payload - for (int32_t j = 12; j < mediaPacket->length; ++j) { + for (size_t j = 12; j < mediaPacket->length; ++j) { mediaPacket->data[j] = static_cast(rand() % 256); } seqNum++; diff --git a/webrtc/modules/utility/interface/rtp_dump.h b/webrtc/modules/utility/interface/rtp_dump.h index 6c2dc7c61d..df45ae209d 100644 --- a/webrtc/modules/utility/interface/rtp_dump.h +++ b/webrtc/modules/utility/interface/rtp_dump.h @@ -43,7 +43,7 @@ public: // Note: packet should contain the RTP/RTCP part of the packet. I.e. the // first bytes of packet should be the RTP/RTCP header. virtual int32_t DumpPacket(const uint8_t* packet, - uint16_t packetLength) = 0; + size_t packetLength) = 0; protected: virtual ~RtpDump(); diff --git a/webrtc/modules/utility/source/coder.cc b/webrtc/modules/utility/source/coder.cc index 11a462abac..5a3974820e 100644 --- a/webrtc/modules/utility/source/coder.cc +++ b/webrtc/modules/utility/source/coder.cc @@ -54,7 +54,7 @@ int32_t AudioCoder::SetDecodeCodec(const CodecInst& codecInst, int32_t AudioCoder::Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz, const int8_t* incomingPayload, - int32_t payloadLength) + size_t payloadLength) { if (payloadLength > 0) { @@ -79,7 +79,7 @@ int32_t AudioCoder::PlayoutData(AudioFrame& decodedAudio, int32_t AudioCoder::Encode(const AudioFrame& audio, int8_t* encodedData, - uint32_t& encodedLengthInBytes) + size_t& encodedLengthInBytes) { // Fake a timestamp in case audio doesn't contain a correct timestamp. // Make a local copy of the audio frame since audio is const @@ -109,7 +109,7 @@ int32_t AudioCoder::SendData( uint8_t /* payloadType */, uint32_t /* timeStamp */, const uint8_t* payloadData, - uint16_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader* /* fragmentation*/) { memcpy(_encodedData,payloadData,sizeof(uint8_t) * payloadSize); diff --git a/webrtc/modules/utility/source/coder.h b/webrtc/modules/utility/source/coder.h index e04372d9a5..036369098e 100644 --- a/webrtc/modules/utility/source/coder.h +++ b/webrtc/modules/utility/source/coder.h @@ -34,12 +34,12 @@ public: ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient); int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz, - const int8_t* incomingPayload, int32_t payloadLength); + const int8_t* incomingPayload, size_t payloadLength); int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz); int32_t Encode(const AudioFrame& audio, int8_t* encodedData, - uint32_t& encodedLengthInBytes); + size_t& encodedLengthInBytes); protected: virtual int32_t SendData( @@ -47,7 +47,7 @@ protected: uint8_t payloadType, uint32_t timeStamp, const uint8_t* payloadData, - uint16_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader* fragmentation) OVERRIDE; private: @@ -57,7 +57,7 @@ private: uint32_t _encodeTimestamp; int8_t* _encodedData; - uint32_t _encodedLengthInBytes; + size_t _encodedLengthInBytes; uint32_t _decodeTimestamp; }; diff --git a/webrtc/modules/utility/source/file_player_impl.cc b/webrtc/modules/utility/source/file_player_impl.cc index 8049245fb0..29f70426de 100644 --- a/webrtc/modules/utility/source/file_player_impl.cc +++ b/webrtc/modules/utility/source/file_player_impl.cc @@ -124,7 +124,7 @@ int32_t FilePlayerImpl::Get10msAudioFromFile( unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq; // L16 is un-encoded data. Just pull 10 ms. - uint32_t lengthInBytes = + size_t lengthInBytes = sizeof(unresampledAudioFrame.data_); if (_fileModule.PlayoutAudioData( (int8_t*)unresampledAudioFrame.data_, @@ -147,11 +147,11 @@ int32_t FilePlayerImpl::Get10msAudioFromFile( // expects a full frame. If the frame size is larger than 10 ms, // PlayoutAudioData(..) data should be called proportionally less often. int16_t encodedBuffer[MAX_AUDIO_BUFFER_IN_SAMPLES]; - uint32_t encodedLengthInBytes = 0; + size_t encodedLengthInBytes = 0; if(++_numberOf10MsInDecoder >= _numberOf10MsPerFrame) { _numberOf10MsInDecoder = 0; - uint32_t bytesFromFile = sizeof(encodedBuffer); + size_t bytesFromFile = sizeof(encodedBuffer); if (_fileModule.PlayoutAudioData((int8_t*)encodedBuffer, bytesFromFile) == -1) { @@ -581,7 +581,7 @@ int32_t VideoFilePlayerImpl::TimeUntilNextVideoFrame() if(_fileFormat == kFileFormatAviFile) { // Get next video frame - uint32_t encodedBufferLengthInBytes = _encodedData.bufferSize; + size_t encodedBufferLengthInBytes = _encodedData.bufferSize; if(_fileModule.PlayoutAVIVideoData( reinterpret_cast< int8_t*>(_encodedData.payloadData), encodedBufferLengthInBytes) != 0) @@ -656,7 +656,7 @@ int32_t VideoFilePlayerImpl::SetUpVideoDecoder() // Size of unencoded data (I420) should be the largest possible frame size // in a file. - const uint32_t KReadBufferSize = 3 * video_codec_info_.width * + const size_t KReadBufferSize = 3 * video_codec_info_.width * video_codec_info_.height / 2; _encodedData.VerifyAndAllocate(KReadBufferSize); _encodedData.encodedHeight = video_codec_info_.height; diff --git a/webrtc/modules/utility/source/file_recorder_impl.cc b/webrtc/modules/utility/source/file_recorder_impl.cc index 264b867a25..14c5288bb0 100644 --- a/webrtc/modules/utility/source/file_recorder_impl.cc +++ b/webrtc/modules/utility/source/file_recorder_impl.cc @@ -227,7 +227,7 @@ int32_t FileRecorderImpl::RecordAudioToFile( // NOTE: stereo recording is only supported for WAV files. // TODO (hellner): WAV expect PCM in little endian byte order. Not // "encoding" with PCM coder should be a problem for big endian systems. - uint32_t encodedLenInBytes = 0; + size_t encodedLenInBytes = 0; if (_fileFormat == kFileFormatPreencodedFile || STR_CASE_CMP(codec_info_.plname, "L16") != 0) { @@ -272,9 +272,8 @@ int32_t FileRecorderImpl::RecordAudioToFile( uint16_t msOfData = ptrAudioFrame->samples_per_channel_ / uint16_t(ptrAudioFrame->sample_rate_hz_ / 1000); - if (WriteEncodedAudioData(_audioBuffer, - (uint16_t)encodedLenInBytes, - msOfData, playoutTS) == -1) + if (WriteEncodedAudioData(_audioBuffer, encodedLenInBytes, msOfData, + playoutTS) == -1) { return -1; } @@ -309,7 +308,7 @@ int32_t FileRecorderImpl::codec_info(CodecInst& codecInst) const int32_t FileRecorderImpl::WriteEncodedAudioData( const int8_t* audioBuffer, - uint16_t bufferLength, + size_t bufferLength, uint16_t /*millisecondsOfData*/, const TickTime* /*playoutTS*/) { @@ -398,7 +397,7 @@ int32_t AviRecorder::StopRecording() return FileRecorderImpl::StopRecording(); } -int32_t AviRecorder::CalcI420FrameSize( ) const +size_t AviRecorder::CalcI420FrameSize( ) const { return 3 * _videoCodecInst.width * _videoCodecInst.height / 2; } @@ -641,8 +640,8 @@ int32_t AviRecorder::EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame) if( STR_CASE_CMP(_videoCodecInst.plName, "I420") == 0) { - int length = CalcBufferSize(kI420, videoFrame.width(), - videoFrame.height()); + size_t length = + CalcBufferSize(kI420, videoFrame.width(), videoFrame.height()); _videoEncodedData.VerifyAndAllocate(length); // I420 is raw data. No encoding needed (each sample is represented by @@ -681,7 +680,7 @@ int32_t AviRecorder::EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame) // happens in AviRecorder::Process(). int32_t AviRecorder::WriteEncodedAudioData( const int8_t* audioBuffer, - uint16_t bufferLength, + size_t bufferLength, uint16_t millisecondsOfData, const TickTime* playoutTS) { diff --git a/webrtc/modules/utility/source/file_recorder_impl.h b/webrtc/modules/utility/source/file_recorder_impl.h index 53fd26bc25..9e17fd60ec 100644 --- a/webrtc/modules/utility/source/file_recorder_impl.h +++ b/webrtc/modules/utility/source/file_recorder_impl.h @@ -86,7 +86,7 @@ public: protected: virtual int32_t WriteEncodedAudioData( const int8_t* audioBuffer, - uint16_t bufferLength, + size_t bufferLength, uint16_t millisecondsOfData, const TickTime* playoutTS); @@ -111,7 +111,7 @@ class AudioFrameFileInfo { public: AudioFrameFileInfo(const int8_t* audioData, - const uint16_t audioSize, + const size_t audioSize, const uint16_t audioMS, const TickTime& playoutTS) : _audioData(), _audioSize(audioSize), _audioMS(audioMS), @@ -127,7 +127,7 @@ class AudioFrameFileInfo }; // TODO (hellner): either turn into a struct or provide get/set functions. int8_t _audioData[MAX_AUDIO_BUFFER_IN_BYTES]; - uint16_t _audioSize; + size_t _audioSize; uint16_t _audioMS; TickTime _playoutTS; }; @@ -151,7 +151,7 @@ public: protected: virtual int32_t WriteEncodedAudioData( const int8_t* audioBuffer, - uint16_t bufferLength, + size_t bufferLength, uint16_t millisecondsOfData, const TickTime* playoutTS); private: @@ -165,7 +165,7 @@ private: int32_t EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame); int32_t ProcessAudio(); - int32_t CalcI420FrameSize() const; + size_t CalcI420FrameSize() const; int32_t SetUpVideoEncoder(); VideoCodec _videoCodecInst; @@ -178,7 +178,7 @@ private: FrameScaler* _frameScaler; VideoCoder* _videoEncoder; - int32_t _videoMaxPayloadSize; + size_t _videoMaxPayloadSize; EncodedVideoData _videoEncodedData; ThreadWrapper* _thread; diff --git a/webrtc/modules/utility/source/rtp_dump_impl.cc b/webrtc/modules/utility/source/rtp_dump_impl.cc index 547df332f9..cab4065c92 100644 --- a/webrtc/modules/utility/source/rtp_dump_impl.cc +++ b/webrtc/modules/utility/source/rtp_dump_impl.cc @@ -12,6 +12,7 @@ #include #include +#include #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/logging.h" @@ -145,7 +146,7 @@ bool RtpDumpImpl::IsActive() const return _file.Open(); } -int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, uint16_t packetLength) +int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, size_t packetLength) { CriticalSectionScoped lock(_critSect); if (!IsActive()) @@ -158,7 +159,9 @@ int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, uint16_t packetLength) return -1; } - if (packetLength < 1) + rtpDumpPktHdr_t hdr; + size_t total_size = packetLength + sizeof hdr; + if (packetLength < 1 || total_size > std::numeric_limits::max()) { return -1; } @@ -167,11 +170,8 @@ int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, uint16_t packetLength) // considered RTP (without further verification). bool isRTCP = RTCP(packet); - rtpDumpPktHdr_t hdr; - uint32_t offset; - // Offset is relative to when recording was started. - offset = GetTimeInMS(); + uint32_t offset = GetTimeInMS(); if (offset < _startTime) { // Compensate for wraparound. @@ -181,7 +181,7 @@ int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, uint16_t packetLength) } hdr.offset = RtpDumpHtonl(offset); - hdr.length = RtpDumpHtons((uint16_t)(packetLength + sizeof(hdr))); + hdr.length = RtpDumpHtons((uint16_t)(total_size)); if (isRTCP) { hdr.plen = 0; diff --git a/webrtc/modules/utility/source/rtp_dump_impl.h b/webrtc/modules/utility/source/rtp_dump_impl.h index 0b721322e1..5be9cbe14d 100644 --- a/webrtc/modules/utility/source/rtp_dump_impl.h +++ b/webrtc/modules/utility/source/rtp_dump_impl.h @@ -26,7 +26,7 @@ public: virtual int32_t Stop() OVERRIDE; virtual bool IsActive() const OVERRIDE; virtual int32_t DumpPacket(const uint8_t* packet, - uint16_t packetLength) OVERRIDE; + size_t packetLength) OVERRIDE; private: // Return the system time in ms. inline uint32_t GetTimeInMS() const; diff --git a/webrtc/modules/utility/source/video_coder.cc b/webrtc/modules/utility/source/video_coder.cc index 5096acecd2..e0d969d6e5 100644 --- a/webrtc/modules/utility/source/video_coder.cc +++ b/webrtc/modules/utility/source/video_coder.cc @@ -113,7 +113,7 @@ int32_t VideoCoder::SendData( const uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& fragmentationHeader, const RTPVideoHeader* /*rtpVideoHdr*/) { diff --git a/webrtc/modules/utility/source/video_coder.h b/webrtc/modules/utility/source/video_coder.h index 03aa511147..a1d1a17d6e 100644 --- a/webrtc/modules/utility/source/video_coder.h +++ b/webrtc/modules/utility/source/video_coder.h @@ -53,7 +53,7 @@ private: uint32_t /*timeStamp*/, int64_t capture_time_ms, const uint8_t* payloadData, - uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& /* fragmentationHeader*/, const RTPVideoHeader* rtpTypeHdr) OVERRIDE; diff --git a/webrtc/modules/video_capture/android/video_capture_android.cc b/webrtc/modules/video_capture/android/video_capture_android.cc index 14dda7f9c6..fa4dcdaa60 100644 --- a/webrtc/modules/video_capture/android/video_capture_android.cc +++ b/webrtc/modules/video_capture/android/video_capture_android.cc @@ -106,7 +106,7 @@ VideoCaptureModule* VideoCaptureImpl::Create( } int32_t VideoCaptureAndroid::OnIncomingFrame(uint8_t* videoFrame, - int32_t videoFrameLength, + size_t videoFrameLength, int32_t degrees, int64_t captureTime) { if (!_captureStarted) diff --git a/webrtc/modules/video_capture/android/video_capture_android.h b/webrtc/modules/video_capture/android/video_capture_android.h index f45b726f18..74de7a9ba0 100644 --- a/webrtc/modules/video_capture/android/video_capture_android.h +++ b/webrtc/modules/video_capture/android/video_capture_android.h @@ -31,7 +31,7 @@ class VideoCaptureAndroid : public VideoCaptureImpl { virtual int32_t SetCaptureRotation(VideoCaptureRotation rotation); int32_t OnIncomingFrame(uint8_t* videoFrame, - int32_t videoFrameLength, + size_t videoFrameLength, int32_t degrees, int64_t captureTime = 0); diff --git a/webrtc/modules/video_capture/include/video_capture_defines.h b/webrtc/modules/video_capture/include/video_capture_defines.h index 330bfc75da..ea7939d5a7 100644 --- a/webrtc/modules/video_capture/include/video_capture_defines.h +++ b/webrtc/modules/video_capture/include/video_capture_defines.h @@ -92,7 +92,7 @@ class VideoCaptureExternal public: // |capture_time| must be specified in the NTP time format in milliseconds. virtual int32_t IncomingFrame(uint8_t* videoFrame, - int32_t videoFrameLength, + size_t videoFrameLength, const VideoCaptureCapability& frameInfo, int64_t captureTime = 0) = 0; virtual int32_t IncomingI420VideoFrame(I420VideoFrame* video_frame, diff --git a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm index b5c53b19f8..f6302f14d7 100644 --- a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm +++ b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm @@ -368,13 +368,14 @@ using namespace webrtc::videocapturemodule; uint8_t* baseAddress = (uint8_t*)CVPixelBufferGetBaseAddressOfPlane(videoFrame, kYPlaneIndex); - int yPlaneBytesPerRow = + size_t yPlaneBytesPerRow = CVPixelBufferGetBytesPerRowOfPlane(videoFrame, kYPlaneIndex); - int yPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kYPlaneIndex); - int uvPlaneBytesPerRow = + size_t yPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kYPlaneIndex); + size_t uvPlaneBytesPerRow = CVPixelBufferGetBytesPerRowOfPlane(videoFrame, kUVPlaneIndex); - int uvPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kUVPlaneIndex); - int frameSize = + size_t uvPlaneHeight = + CVPixelBufferGetHeightOfPlane(videoFrame, kUVPlaneIndex); + size_t frameSize = yPlaneBytesPerRow * yPlaneHeight + uvPlaneBytesPerRow * uvPlaneHeight; VideoCaptureCapability tempCaptureCapability; diff --git a/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm b/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm index 4120335fa6..7cd7407e45 100644 --- a/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm +++ b/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm @@ -237,8 +237,8 @@ using namespace videocapturemodule; if (CVPixelBufferLockBaseAddress(videoFrame, kFlags) == kCVReturnSuccess) { void *baseAddress = CVPixelBufferGetBaseAddress(videoFrame); size_t bytesPerRow = CVPixelBufferGetBytesPerRow(videoFrame); - int frameHeight = CVPixelBufferGetHeight(videoFrame); - int frameSize = bytesPerRow * frameHeight; + size_t frameHeight = CVPixelBufferGetHeight(videoFrame); + size_t frameSize = bytesPerRow * frameHeight; VideoCaptureCapability tempCaptureCapability; tempCaptureCapability.width = _frameWidth; diff --git a/webrtc/modules/video_capture/test/video_capture_unittest.cc b/webrtc/modules/video_capture/test/video_capture_unittest.cc index 59d58e7647..8635c9c44d 100644 --- a/webrtc/modules/video_capture/test/video_capture_unittest.cc +++ b/webrtc/modules/video_capture/test/video_capture_unittest.cc @@ -477,9 +477,9 @@ class VideoCaptureExternalTest : public testing::Test { // Test input of external video frames. TEST_F(VideoCaptureExternalTest, TestExternalCapture) { - unsigned int length = webrtc::CalcBufferSize(webrtc::kI420, - test_frame_.width(), - test_frame_.height()); + size_t length = webrtc::CalcBufferSize(webrtc::kI420, + test_frame_.width(), + test_frame_.height()); webrtc::scoped_ptr test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(test_frame_, length, test_buffer.get()); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), @@ -563,9 +563,9 @@ TEST_F(VideoCaptureExternalTest, DISABLED_ON_WIN(FrameRate)) { TickTime startTime = TickTime::Now(); while ((TickTime::Now() - startTime).Milliseconds() < testTime * 1000) { - unsigned int length = webrtc::CalcBufferSize(webrtc::kI420, - test_frame_.width(), - test_frame_.height()); + size_t length = webrtc::CalcBufferSize(webrtc::kI420, + test_frame_.width(), + test_frame_.height()); webrtc::scoped_ptr test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(test_frame_, length, test_buffer.get()); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), @@ -579,9 +579,9 @@ TEST_F(VideoCaptureExternalTest, DISABLED_ON_WIN(FrameRate)) { startTime = TickTime::Now(); while ((TickTime::Now() - startTime).Milliseconds() < testTime * 1000) { - unsigned int length = webrtc::CalcBufferSize(webrtc::kI420, - test_frame_.width(), - test_frame_.height()); + size_t length = webrtc::CalcBufferSize(webrtc::kI420, + test_frame_.width(), + test_frame_.height()); webrtc::scoped_ptr test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(test_frame_, length, test_buffer.get()); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), @@ -597,9 +597,9 @@ TEST_F(VideoCaptureExternalTest, DISABLED_ON_WIN(FrameRate)) { TEST_F(VideoCaptureExternalTest, Rotation) { EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kCameraRotate0)); - unsigned int length = webrtc::CalcBufferSize(webrtc::kI420, - test_frame_.width(), - test_frame_.height()); + size_t length = webrtc::CalcBufferSize(webrtc::kI420, + test_frame_.width(), + test_frame_.height()); webrtc::scoped_ptr test_buffer(new uint8_t[length]); webrtc::ExtractBuffer(test_frame_, length, test_buffer.get()); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc index 6f179e2da6..dc56ad37ef 100644 --- a/webrtc/modules/video_capture/video_capture_impl.cc +++ b/webrtc/modules/video_capture/video_capture_impl.cc @@ -256,7 +256,7 @@ int32_t VideoCaptureImpl::DeliverCapturedFrame(I420VideoFrame& captureFrame, int32_t VideoCaptureImpl::IncomingFrame( uint8_t* videoFrame, - int32_t videoFrameLength, + size_t videoFrameLength, const VideoCaptureCapability& frameInfo, int64_t captureTime/*=0*/) { diff --git a/webrtc/modules/video_capture/video_capture_impl.h b/webrtc/modules/video_capture/video_capture_impl.h index f3a4c64cbd..4e403370bc 100644 --- a/webrtc/modules/video_capture/video_capture_impl.h +++ b/webrtc/modules/video_capture/video_capture_impl.h @@ -84,7 +84,7 @@ public: // Implement VideoCaptureExternal // |capture_time| must be specified in the NTP time format in milliseconds. virtual int32_t IncomingFrame(uint8_t* videoFrame, - int32_t videoFrameLength, + size_t videoFrameLength, const VideoCaptureCapability& frameInfo, int64_t captureTime = 0); diff --git a/webrtc/modules/video_capture/windows/sink_filter_ds.cc b/webrtc/modules/video_capture/windows/sink_filter_ds.cc index 2edbe59c4a..f79fe1f5e6 100644 --- a/webrtc/modules/video_capture/windows/sink_filter_ds.cc +++ b/webrtc/modules/video_capture/windows/sink_filter_ds.cc @@ -353,7 +353,8 @@ CaptureInputPin::Receive ( IN IMediaSample * pIMediaSample ) if (SUCCEEDED (hr)) { - const int32_t length = pIMediaSample->GetActualDataLength(); + const LONG length = pIMediaSample->GetActualDataLength(); + ASSERT(length >= 0); unsigned char* pBuffer = NULL; if(S_OK != pIMediaSample->GetPointer(&pBuffer)) @@ -364,7 +365,7 @@ CaptureInputPin::Receive ( IN IMediaSample * pIMediaSample ) // NOTE: filter unlocked within Send call reinterpret_cast (m_pFilter)->ProcessCapturedFrame( - pBuffer,length,_resultingCapability); + pBuffer, static_cast(length), _resultingCapability); } else { @@ -485,9 +486,10 @@ void CaptureSinkFilter::SetFilterGraph(IGraphBuilder* graph) UnlockFilter(); } -void CaptureSinkFilter::ProcessCapturedFrame(unsigned char* pBuffer, - int32_t length, - const VideoCaptureCapability& frameInfo) +void CaptureSinkFilter::ProcessCapturedFrame( + unsigned char* pBuffer, + size_t length, + const VideoCaptureCapability& frameInfo) { // we have the receiver lock if (m_State == State_Running) diff --git a/webrtc/modules/video_capture/windows/sink_filter_ds.h b/webrtc/modules/video_capture/windows/sink_filter_ds.h index d1f0ed3eb8..064cd9d7d3 100644 --- a/webrtc/modules/video_capture/windows/sink_filter_ds.h +++ b/webrtc/modules/video_capture/windows/sink_filter_ds.h @@ -63,7 +63,7 @@ public: // -------------------------------------------------------------------- // class methods - void ProcessCapturedFrame(unsigned char* pBuffer, int32_t length, + void ProcessCapturedFrame(unsigned char* pBuffer, size_t length, const VideoCaptureCapability& frameInfo); // explicit receiver lock aquisition and release void LockReceive() { m_crtRecv.Lock();} diff --git a/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h b/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h index 1e99e699bd..2d41fd069c 100644 --- a/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h +++ b/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h @@ -18,8 +18,6 @@ namespace webrtc { -enum { kI420HeaderSize = 4 }; - class I420Encoder : public VideoEncoder { public: I420Encoder(); @@ -38,7 +36,7 @@ class I420Encoder : public VideoEncoder { // <0 - Error virtual int InitEncode(const VideoCodec* codecSettings, int /*numberOfCores*/, - uint32_t /*maxPayloadSize*/) OVERRIDE; + size_t /*maxPayloadSize*/) OVERRIDE; // "Encode" an I420 image (as a part of a video stream). The encoded image // will be returned to the user via the encode complete callback. diff --git a/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc b/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc index 69cc9e2ba5..bb61f5e032 100644 --- a/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc +++ b/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc @@ -15,6 +15,10 @@ #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" +namespace { +const size_t kI420HeaderSize = 4; +} + namespace webrtc { I420Encoder::I420Encoder() : _inited(false), _encodedImage(), @@ -39,7 +43,7 @@ int I420Encoder::Release() { int I420Encoder::InitEncode(const VideoCodec* codecSettings, int /*numberOfCores*/, - uint32_t /*maxPayloadSize */) { + size_t /*maxPayloadSize */) { if (codecSettings == NULL) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } @@ -53,10 +57,9 @@ int I420Encoder::InitEncode(const VideoCodec* codecSettings, _encodedImage._buffer = NULL; _encodedImage._size = 0; } - const uint32_t newSize = CalcBufferSize(kI420, - codecSettings->width, - codecSettings->height) - + kI420HeaderSize; + const size_t newSize = + CalcBufferSize(kI420, codecSettings->width, codecSettings->height) + + kI420HeaderSize; uint8_t* newBuffer = new uint8_t[newSize]; if (newBuffer == NULL) { return WEBRTC_VIDEO_CODEC_MEMORY; @@ -95,9 +98,10 @@ int I420Encoder::Encode(const I420VideoFrame& inputImage, return WEBRTC_VIDEO_CODEC_ERR_SIZE; } - int req_length = CalcBufferSize(kI420, inputImage.width(), - inputImage.height()) + kI420HeaderSize; - if (_encodedImage._size > static_cast(req_length)) { + size_t req_length = + CalcBufferSize(kI420, inputImage.width(), inputImage.height()) + + kI420HeaderSize; + if (_encodedImage._size > req_length) { // Reallocate buffer. delete [] _encodedImage._buffer; @@ -194,8 +198,7 @@ int I420Decoder::Decode(const EncodedImage& inputImage, bool /*missingFrames*/, _height = height; // Verify that the available length is sufficient: - uint32_t req_length = CalcBufferSize(kI420, _width, _height) - + kI420HeaderSize; + size_t req_length = CalcBufferSize(kI420, _width, _height) + kI420HeaderSize; if (req_length > inputImage._length) { return WEBRTC_VIDEO_CODEC_ERROR; diff --git a/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h b/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h index 69e99ae4ba..18bf5b8ca7 100644 --- a/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h +++ b/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h @@ -31,7 +31,7 @@ class MockVideoEncoder : public VideoEncoder { MOCK_CONST_METHOD2(Version, int32_t(int8_t *version, int32_t length)); MOCK_METHOD3(InitEncode, int32_t(const VideoCodec* codecSettings, int32_t numberOfCores, - uint32_t maxPayloadSize)); + size_t maxPayloadSize)); MOCK_METHOD3(Encode, int32_t(const I420VideoFrame& inputImage, const CodecSpecificInfo* codecSpecificInfo, const std::vector* frame_types)); diff --git a/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc b/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc index f4ca92a964..6e7139eca7 100644 --- a/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc +++ b/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc @@ -13,6 +13,8 @@ #include #include +#include "webrtc/base/format_macros.h" + namespace webrtc { namespace test { @@ -72,7 +74,7 @@ int PacketManipulatorImpl::ManipulatePackets( // Must set completeFrame to false to inform the decoder about this: encoded_image->_completeFrame = false; if (verbose_) { - printf("Dropped %d packets for frame %d (frame length: %d)\n", + printf("Dropped %d packets for frame %d (frame length: %" PRIuS ")\n", nbr_packets_dropped, encoded_image->_timeStamp, encoded_image->_length); } diff --git a/webrtc/modules/video_coding/codecs/test/packet_manipulator.h b/webrtc/modules/video_coding/codecs/test/packet_manipulator.h index 0fafa22d6d..69bc35b1fe 100644 --- a/webrtc/modules/video_coding/codecs/test/packet_manipulator.h +++ b/webrtc/modules/video_coding/codecs/test/packet_manipulator.h @@ -42,11 +42,11 @@ struct NetworkingConfig { } // Packet size in bytes. Default: 1500 bytes. - int packet_size_in_bytes; + size_t packet_size_in_bytes; // Encoder specific setting of maximum size in bytes of each payload. // Default: 1440 bytes. - int max_payload_size_in_bytes; + size_t max_payload_size_in_bytes; // Packet loss mode. Two different packet loss models are supported: // uniform or burst. This setting has no effect unless diff --git a/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc b/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc index 576d00570d..ace7bc0507 100644 --- a/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc +++ b/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc @@ -60,11 +60,11 @@ class PacketManipulatorTest: public PacketRelatedTest { void VerifyPacketLoss(int expected_nbr_packets_dropped, int actual_nbr_packets_dropped, - int expected_packet_data_length, + size_t expected_packet_data_length, uint8_t* expected_packet_data, EncodedImage& actual_image) { EXPECT_EQ(expected_nbr_packets_dropped, actual_nbr_packets_dropped); - EXPECT_EQ(expected_packet_data_length, static_cast(image_._length)); + EXPECT_EQ(expected_packet_data_length, image_._length); EXPECT_EQ(0, memcmp(expected_packet_data, actual_image._buffer, expected_packet_data_length)); } @@ -82,7 +82,7 @@ TEST_F(PacketManipulatorTest, DropNone) { } TEST_F(PacketManipulatorTest, UniformDropNoneSmallFrame) { - int data_length = 400; // smaller than the packet size + size_t data_length = 400; // smaller than the packet size image_._length = data_length; PacketManipulatorImpl manipulator(&packet_reader_, no_drop_config_, false); int nbr_packets_dropped = manipulator.ManipulatePackets(&image_); @@ -120,7 +120,7 @@ TEST_F(PacketManipulatorTest, UniformDropSinglePacket) { TEST_F(PacketManipulatorTest, BurstDropNinePackets) { // Create a longer packet data structure (10 packets) const int kNbrPackets = 10; - const int kDataLength = kPacketSizeInBytes * kNbrPackets; + const size_t kDataLength = kPacketSizeInBytes * kNbrPackets; uint8_t data[kDataLength]; uint8_t* data_pointer = data; // Fill with 0s, 1s and so on to be able to easily verify which were dropped: diff --git a/webrtc/modules/video_coding/codecs/test/stats.cc b/webrtc/modules/video_coding/codecs/test/stats.cc index f6605f902f..91a2f3c5f4 100644 --- a/webrtc/modules/video_coding/codecs/test/stats.cc +++ b/webrtc/modules/video_coding/codecs/test/stats.cc @@ -15,6 +15,8 @@ #include // min_element, max_element +#include "webrtc/base/format_macros.h" + namespace webrtc { namespace test { @@ -70,11 +72,11 @@ void Stats::PrintSummary() { // Calculate min, max, average and total encoding time int total_encoding_time_in_us = 0; int total_decoding_time_in_us = 0; - int total_encoded_frames_lengths = 0; - int total_encoded_key_frames_lengths = 0; - int total_encoded_nonkey_frames_lengths = 0; - int nbr_keyframes = 0; - int nbr_nonkeyframes = 0; + size_t total_encoded_frames_lengths = 0; + size_t total_encoded_key_frames_lengths = 0; + size_t total_encoded_nonkey_frames_lengths = 0; + size_t nbr_keyframes = 0; + size_t nbr_nonkeyframes = 0; for (FrameStatisticsIterator it = stats_.begin(); it != stats_.end(); ++it) { @@ -141,23 +143,24 @@ void Stats::PrintSummary() { printf("Frame sizes:\n"); frame = std::min_element(stats_.begin(), stats_.end(), LessForEncodedSize); - printf(" Min : %7d bytes (frame %d)\n", + printf(" Min : %7" PRIuS " bytes (frame %d)\n", frame->encoded_frame_length_in_bytes, frame->frame_number); frame = std::max_element(stats_.begin(), stats_.end(), LessForEncodedSize); - printf(" Max : %7d bytes (frame %d)\n", + printf(" Max : %7" PRIuS " bytes (frame %d)\n", frame->encoded_frame_length_in_bytes, frame->frame_number); - printf(" Average : %7d bytes\n", - static_cast(total_encoded_frames_lengths / stats_.size())); + printf(" Average : %7" PRIuS " bytes\n", + total_encoded_frames_lengths / stats_.size()); if (nbr_keyframes > 0) { - printf(" Average key frame size : %7d bytes (%d keyframes)\n", - total_encoded_key_frames_lengths / nbr_keyframes, - nbr_keyframes); + printf(" Average key frame size : %7" PRIuS " bytes (%" PRIuS + " keyframes)\n", + total_encoded_key_frames_lengths / nbr_keyframes, nbr_keyframes); } if (nbr_nonkeyframes > 0) { - printf(" Average non-key frame size: %7d bytes (%d frames)\n", + printf(" Average non-key frame size: %7" PRIuS " bytes (%" PRIuS + " frames)\n", total_encoded_nonkey_frames_lengths / nbr_nonkeyframes, nbr_nonkeyframes); } diff --git a/webrtc/modules/video_coding/codecs/test/stats.h b/webrtc/modules/video_coding/codecs/test/stats.h index 299877335f..8dc8f159fe 100644 --- a/webrtc/modules/video_coding/codecs/test/stats.h +++ b/webrtc/modules/video_coding/codecs/test/stats.h @@ -31,14 +31,14 @@ struct FrameStatistic { int frame_number; // How many packets were discarded of the encoded frame data (if any). int packets_dropped; - int total_packets; + size_t total_packets; // Current bit rate. Calculated out of the size divided with the time // interval per frame. int bit_rate_in_kbps; // Copied from EncodedImage - int encoded_frame_length_in_bytes; + size_t encoded_frame_length_in_bytes; webrtc::VideoFrameType frame_type; }; diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc index 93738caf12..412ec1024c 100644 --- a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc +++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc @@ -30,7 +30,7 @@ TestConfig::TestConfig() output_dir("out"), networking_config(), exclude_frame_types(kExcludeOnlyFirstKeyFrame), - frame_length_in_bytes(-1), + frame_length_in_bytes(0), use_single_core(false), keyframe_interval(0), codec_settings(NULL), @@ -157,7 +157,7 @@ void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) { num_spatial_resizes_ = 0; } -int VideoProcessorImpl::EncodedFrameSize() { +size_t VideoProcessorImpl::EncodedFrameSize() { return encoded_frame_size_; } @@ -330,11 +330,12 @@ void VideoProcessorImpl::FrameDecoded(const I420VideoFrame& image) { frame_number, ret_val); } // TODO(mikhal): Extracting the buffer for now - need to update test. - int length = CalcBufferSize(kI420, up_image.width(), up_image.height()); + size_t length = CalcBufferSize(kI420, up_image.width(), up_image.height()); scoped_ptr image_buffer(new uint8_t[length]); - length = ExtractBuffer(up_image, length, image_buffer.get()); + int extracted_length = ExtractBuffer(up_image, length, image_buffer.get()); + assert(extracted_length > 0); // Update our copy of the last successful frame: - memcpy(last_successful_frame_buffer_, image_buffer.get(), length); + memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); bool write_success = frame_writer_->WriteFrame(image_buffer.get()); assert(write_success); if (!write_success) { @@ -343,11 +344,11 @@ void VideoProcessorImpl::FrameDecoded(const I420VideoFrame& image) { } else { // No resize. // Update our copy of the last successful frame: // TODO(mikhal): Add as a member function, so won't be allocated per frame. - int length = CalcBufferSize(kI420, image.width(), image.height()); + size_t length = CalcBufferSize(kI420, image.width(), image.height()); scoped_ptr image_buffer(new uint8_t[length]); - length = ExtractBuffer(image, length, image_buffer.get()); - assert(length > 0); - memcpy(last_successful_frame_buffer_, image_buffer.get(), length); + int extracted_length = ExtractBuffer(image, length, image_buffer.get()); + assert(extracted_length > 0); + memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length); bool write_success = frame_writer_->WriteFrame(image_buffer.get()); assert(write_success); diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.h b/webrtc/modules/video_coding/codecs/test/videoprocessor.h index 20bcab5772..2cfde52880 100644 --- a/webrtc/modules/video_coding/codecs/test/videoprocessor.h +++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.h @@ -76,7 +76,7 @@ struct TestConfig { // The length of a single frame of the input video file. This value is // calculated out of the width and height according to the video format // specification. Must be set before processing. - int frame_length_in_bytes; + size_t frame_length_in_bytes; // Force the encoder and decoder to use a single core for processing. // Using a single core is necessary to get a deterministic behavior for the @@ -144,7 +144,7 @@ class VideoProcessor { // Return the size of the encoded frame in bytes. Dropped frames by the // encoder are regarded as zero size. - virtual int EncodedFrameSize() = 0; + virtual size_t EncodedFrameSize() = 0; // Return the number of dropped frames. virtual int NumberDroppedFrames() = 0; @@ -178,7 +178,7 @@ class VideoProcessorImpl : public VideoProcessor { // Updates the encoder with the target bit rate and the frame rate. virtual void SetRates(int bit_rate, int frame_rate) OVERRIDE; // Return the size of the encoded frame in bytes. - virtual int EncodedFrameSize() OVERRIDE; + virtual size_t EncodedFrameSize() OVERRIDE; // Return the number of dropped frames. virtual int NumberDroppedFrames() OVERRIDE; // Return the number of spatial resizes. @@ -206,7 +206,7 @@ class VideoProcessorImpl : public VideoProcessor { bool last_frame_missing_; // If Init() has executed successfully. bool initialized_; - int encoded_frame_size_; + size_t encoded_frame_size_; int prev_time_stamp_; int num_dropped_frames_; int num_spatial_resizes_; diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc index 420ef595ed..0c423a7d62 100644 --- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc +++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc @@ -266,8 +266,7 @@ class VideoProcessorIntegrationTest: public testing::Test { // For every encoded frame, update the rate control metrics. void UpdateRateControlMetrics(int frame_num, VideoFrameType frame_type) { - int encoded_frame_size = processor_->EncodedFrameSize(); - float encoded_size_kbits = encoded_frame_size * 8.0f / 1000.0f; + float encoded_size_kbits = processor_->EncodedFrameSize() * 8.0f / 1000.0f; // Update layer data. // Update rate mismatch relative to per-frame bandwidth for delta frames. if (frame_type == kDeltaFrame) { diff --git a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc index dcd74790c2..3ad6ed7d85 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc +++ b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc @@ -218,7 +218,7 @@ bool FrameQueue::Empty() return _frameBufferQueue.empty(); } -uint32_t VideoEncodeCompleteCallback::EncodedBytes() +size_t VideoEncodeCompleteCallback::EncodedBytes() { return _encodedBytes; } @@ -251,7 +251,7 @@ VideoEncodeCompleteCallback::Encoded(EncodedImage& encodedImage, return 0; } -uint32_t VideoDecodeCompleteCallback::DecodedBytes() +size_t VideoDecodeCompleteCallback::DecodedBytes() { return _decodedBytes; } diff --git a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h index 1e62534aca..63ac0bf118 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h +++ b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h @@ -153,12 +153,12 @@ public: Encoded(webrtc::EncodedImage& encodedImage, const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL, const webrtc::RTPFragmentationHeader* fragmentation = NULL); - uint32_t EncodedBytes(); + size_t EncodedBytes(); private: FILE* _encodedFile; FrameQueue* _frameQueue; NormalAsyncTest& _test; - uint32_t _encodedBytes; + size_t _encodedBytes; }; class VideoDecodeCompleteCallback : public webrtc::DecodedImageCallback @@ -176,11 +176,11 @@ public: ReceivedDecodedReferenceFrame(const uint64_t pictureId); virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId); - uint32_t DecodedBytes(); + size_t DecodedBytes(); private: FILE* _decodedFile; NormalAsyncTest& _test; - uint32_t _decodedBytes; + size_t _decodedBytes; }; #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAMEWORK_NORMAL_ASYNC_TEST_H_ diff --git a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc index 6bb7bbe677..c6315a7afb 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc +++ b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc @@ -92,8 +92,8 @@ PacketLossTest::Decoded(const I420VideoFrame& decodedImage) _frameQueue.pop_front(); // save image for future freeze-frame - unsigned int length = CalcBufferSize(kI420, decodedImage.width(), - decodedImage.height()); + size_t length = + CalcBufferSize(kI420, decodedImage.width(), decodedImage.height()); if (_lastFrameLength < length) { if (_lastFrame) delete [] _lastFrame; @@ -189,7 +189,7 @@ int PacketLossTest::DoPacketLoss() newEncBuf.VerifyAndAllocate(_lengthSourceFrame); _inBufIdx = 0; _outBufIdx = 0; - int size = 1; + size_t size = 1; int kept = 0; int thrown = 0; while ((size = NextPacket(1500, &packet)) > 0) @@ -204,7 +204,7 @@ int PacketLossTest::DoPacketLoss() // Use the ByteLoss function if you want to lose only // parts of a packet, and not the whole packet. - //int size2 = ByteLoss(size, packet, 15); + //size_t size2 = ByteLoss(size, packet, 15); thrown++; //if (size2 != size) //{ @@ -227,28 +227,27 @@ int PacketLossTest::DoPacketLoss() //printf("Encoded left: %d bytes\n", _encodedVideoBuffer.Length()); } -int PacketLossTest::NextPacket(int mtu, unsigned char **pkg) +size_t PacketLossTest::NextPacket(size_t mtu, unsigned char **pkg) { unsigned char *buf = _frameToDecode->_frame->Buffer(); *pkg = buf + _inBufIdx; - if (static_cast(_frameToDecode->_frame->Length()) - _inBufIdx <= mtu) - { - int size = _frameToDecode->_frame->Length() - _inBufIdx; - _inBufIdx = _frameToDecode->_frame->Length(); - return size; - } - _inBufIdx += mtu; - return mtu; + size_t old_idx = _inBufIdx; + _inBufIdx = std::min(_inBufIdx + mtu, _frameToDecode->_frame->Length()); + return _inBufIdx - old_idx; } -int PacketLossTest::ByteLoss(int size, unsigned char *pkg, int bytesToLose) +size_t PacketLossTest::ByteLoss(size_t size, + unsigned char *pkg, + size_t bytesToLose) { return size; } -void PacketLossTest::InsertPacket(VideoFrame *buf, unsigned char *pkg, int size) +void PacketLossTest::InsertPacket(VideoFrame *buf, + unsigned char *pkg, + size_t size) { - if (static_cast(buf->Size()) - _outBufIdx < size) + if ((_outBufIdx + size) > buf->Size()) { printf("InsertPacket error!\n"); return; diff --git a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h index e917054b4f..48a67a266f 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h +++ b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h @@ -34,12 +34,15 @@ protected: virtual void Teardown(); virtual void CodecSpecific_InitBitrate(); virtual int DoPacketLoss(); - virtual int NextPacket(int size, unsigned char **pkg); - virtual int ByteLoss(int size, unsigned char *pkg, int bytesToLose); - virtual void InsertPacket(webrtc::VideoFrame *buf, unsigned char *pkg, - int size); - int _inBufIdx; - int _outBufIdx; + virtual size_t NextPacket(size_t mtu, unsigned char **pkg); + virtual size_t ByteLoss(size_t size, + unsigned char *pkg, + size_t bytesToLose); + virtual void InsertPacket(webrtc::VideoFrame *buf, + unsigned char *pkg, + size_t size); + size_t _inBufIdx; + size_t _outBufIdx; // When NACK is being simulated _lossProbabilty is zero, // otherwise it is set equal to _lossRate. @@ -50,10 +53,10 @@ protected: int _totalKept; int _totalThrown; - int _sumChannelBytes; + size_t _sumChannelBytes; std::list _frameQueue; uint8_t* _lastFrame; - uint32_t _lastFrameLength; + size_t _lastFrameLength; }; diff --git a/webrtc/modules/video_coding/codecs/test_framework/test.h b/webrtc/modules/video_coding/codecs/test_framework/test.h index 7558abe6bb..db891ca00b 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/test.h +++ b/webrtc/modules/video_coding/codecs/test_framework/test.h @@ -48,8 +48,8 @@ protected: webrtc::VideoEncoder* _encoder; webrtc::VideoDecoder* _decoder; - uint32_t _bitRate; - unsigned int _lengthSourceFrame; + uint32_t _bitRate; + size_t _lengthSourceFrame; unsigned char* _sourceBuffer; webrtc::I420VideoFrame _inputVideoBuffer; // TODO(mikhal): For now using VideoFrame for encodedBuffer, should use a @@ -61,7 +61,7 @@ protected: std::string _inname; std::string _outname; std::string _encodedName; - int _sumEncBytes; + size_t _sumEncBytes; int _width; int _halfWidth; int _height; diff --git a/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc b/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc index ab8d4d2653..1af462c932 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc +++ b/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc @@ -146,7 +146,7 @@ UnitTestDecodeCompleteCallback::DecodeComplete() return false; } -uint32_t +size_t UnitTest::WaitForEncodedFrame() const { int64_t startTime = TickTime::MillisecondTimestamp(); @@ -160,7 +160,7 @@ UnitTest::WaitForEncodedFrame() const return 0; } -uint32_t +size_t UnitTest::WaitForDecodedFrame() const { int64_t startTime = TickTime::MillisecondTimestamp(); @@ -225,8 +225,8 @@ UnitTest::Setup() _inst.codecSpecific.VP8.denoisingOn = true; // Get input frame. - ASSERT_TRUE(fread(_refFrame, 1, _lengthSourceFrame, _sourceFile) - == _lengthSourceFrame); + ASSERT_EQ(_lengthSourceFrame, + fread(_refFrame, 1, _lengthSourceFrame, _sourceFile)); int size_y = _inst.width * _inst.height; int size_uv = ((_inst.width + 1) / 2) * ((_inst.height + 1) / 2); _inputVideoBuffer.CreateFrame(size_y, _refFrame, @@ -244,7 +244,7 @@ UnitTest::Setup() EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK); _encoder->Encode(_inputVideoBuffer, NULL, NULL); _refEncFrameLength = WaitForEncodedFrame(); - ASSERT_TRUE(_refEncFrameLength > 0); + ASSERT_GT(_refEncFrameLength, 0u); _refEncFrame = new unsigned char[_refEncFrameLength]; memcpy(_refEncFrame, _encodedVideoBuffer.Buffer(), _refEncFrameLength); @@ -255,7 +255,7 @@ UnitTest::Setup() EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK); ASSERT_FALSE(SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK); - unsigned int frameLength = 0; + size_t frameLength = 0; int i = 0; _inputVideoBuffer.CreateEmptyFrame(_inst.width, _inst.height, _inst.width, (_inst.width + 1) / 2, @@ -266,12 +266,12 @@ UnitTest::Setup() if (i > 0) { // Insert yet another frame. - ASSERT_TRUE(fread(_refFrame, 1, _lengthSourceFrame, - _sourceFile) == _lengthSourceFrame); + ASSERT_EQ(_lengthSourceFrame, + fread(_refFrame, 1, _lengthSourceFrame, _sourceFile)); EXPECT_EQ(0, ConvertToI420(kI420, _refFrame, 0, 0, _width, _height, 0, kRotateNone, &_inputVideoBuffer)); _encoder->Encode(_inputVideoBuffer, NULL, NULL); - ASSERT_TRUE(WaitForEncodedFrame() > 0); + ASSERT_GT(WaitForEncodedFrame(), 0u); } else { // The first frame is always a key frame. encodedImage._frameType = kKeyFrame; @@ -285,7 +285,7 @@ UnitTest::Setup() i++; } rewind(_sourceFile); - EXPECT_TRUE(frameLength == _lengthSourceFrame); + EXPECT_EQ(_lengthSourceFrame, frameLength); ExtractBuffer(_decodedVideoBuffer, _lengthSourceFrame, _refDecFrame); } @@ -324,9 +324,9 @@ UnitTest::DecodeWithoutAssert() EncodedImage encodedImage; VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage); int ret = _decoder->Decode(encodedImage, 0, NULL); - int frameLength = WaitForDecodedFrame(); + size_t frameLength = WaitForDecodedFrame(); _encodedVideoBuffer.SetLength(0); - return ret == WEBRTC_VIDEO_CODEC_OK ? frameLength : ret; + return ret == WEBRTC_VIDEO_CODEC_OK ? static_cast(frameLength) : ret; } int @@ -343,13 +343,11 @@ UnitTest::Decode() } int ret = _decoder->Decode(encodedImage, 0, NULL); - unsigned int frameLength = WaitForDecodedFrame(); - assert(ret == WEBRTC_VIDEO_CODEC_OK && (frameLength == 0 || frameLength - == _lengthSourceFrame)); - EXPECT_TRUE(ret == WEBRTC_VIDEO_CODEC_OK && (frameLength == 0 || frameLength - == _lengthSourceFrame)); + size_t frameLength = WaitForDecodedFrame(); + EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, ret); + EXPECT_TRUE(frameLength == 0 || frameLength == _lengthSourceFrame); _encodedVideoBuffer.SetLength(0); - return ret == WEBRTC_VIDEO_CODEC_OK ? frameLength : ret; + return ret == WEBRTC_VIDEO_CODEC_OK ? static_cast(frameLength) : ret; } // Test pure virtual VideoEncoder and VideoDecoder APIs. @@ -357,7 +355,7 @@ void UnitTest::Perform() { UnitTest::Setup(); - int frameLength; + size_t frameLength; I420VideoFrame inputImage; EncodedImage encodedImage; @@ -448,21 +446,21 @@ UnitTest::Perform() std::vector frame_types(1, frame_type); EXPECT_TRUE(_encoder->Encode(_inputVideoBuffer, NULL, &frame_types) == WEBRTC_VIDEO_CODEC_OK); - EXPECT_TRUE(WaitForEncodedFrame() > 0); + EXPECT_GT(WaitForEncodedFrame(), 0u); } // Init then encode. _encodedVideoBuffer.SetLength(0); EXPECT_TRUE(_encoder->Encode(_inputVideoBuffer, NULL, NULL) == WEBRTC_VIDEO_CODEC_OK); - EXPECT_TRUE(WaitForEncodedFrame() > 0); + EXPECT_GT(WaitForEncodedFrame(), 0u); EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK); _encoder->Encode(_inputVideoBuffer, NULL, NULL); frameLength = WaitForEncodedFrame(); - EXPECT_TRUE(frameLength > 0); + EXPECT_GT(frameLength, 0u); EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength, - _encodedVideoBuffer.Buffer(), frameLength) == true); + _encodedVideoBuffer.Buffer(), frameLength)); // Reset then encode. _encodedVideoBuffer.SetLength(0); @@ -472,9 +470,9 @@ UnitTest::Perform() EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK); _encoder->Encode(_inputVideoBuffer, NULL, NULL); frameLength = WaitForEncodedFrame(); - EXPECT_TRUE(frameLength > 0); + EXPECT_GT(frameLength, 0u); EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength, - _encodedVideoBuffer.Buffer(), frameLength) == true); + _encodedVideoBuffer.Buffer(), frameLength)); // Release then encode. _encodedVideoBuffer.SetLength(0); @@ -485,9 +483,9 @@ UnitTest::Perform() EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK); _encoder->Encode(_inputVideoBuffer, NULL, NULL); frameLength = WaitForEncodedFrame(); - EXPECT_TRUE(frameLength > 0); + EXPECT_GT(frameLength, 0u); EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength, - _encodedVideoBuffer.Buffer(), frameLength) == true); + _encodedVideoBuffer.Buffer(), frameLength)); //----- Decoder parameter tests ----- @@ -522,8 +520,8 @@ UnitTest::Perform() ASSERT_FALSE(SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK); for (int i = 0; i < 100; i++) { - ASSERT_TRUE(fread(tmpBuf, 1, _refEncFrameLength, _sourceFile) - == _refEncFrameLength); + ASSERT_EQ(_refEncFrameLength, + fread(tmpBuf, 1, _refEncFrameLength, _sourceFile)); _encodedVideoBuffer.CopyFrame(_refEncFrameLength, tmpBuf); VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage); int ret = _decoder->Decode(encodedImage, false, NULL); @@ -564,12 +562,12 @@ UnitTest::Perform() _decoder->Decode(encodedImage, false, NULL); frameLength = WaitForDecodedFrame(); } - unsigned int length = CalcBufferSize(kI420, width, height); + size_t length = CalcBufferSize(kI420, width, height); scoped_ptr decoded_buffer(new uint8_t[length]); ExtractBuffer(_decodedVideoBuffer, _lengthSourceFrame, decoded_buffer.get()); EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), frameLength, _refDecFrame, - _lengthSourceFrame) == true); + _lengthSourceFrame)); // Reset then decode. EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK); @@ -583,7 +581,7 @@ UnitTest::Perform() ExtractBuffer(_decodedVideoBuffer, _lengthSourceFrame, decoded_buffer.get()); EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), frameLength, - _refDecFrame, _lengthSourceFrame) == true); + _refDecFrame, _lengthSourceFrame)); // Decode with other size, reset, then decode with original size again // to verify that decoder is reset to a "fresh" state upon Reset(). @@ -614,7 +612,7 @@ UnitTest::Perform() tempInst.width, tmpHalfWidth, tmpHalfWidth); _encoder->Encode(tempInput, NULL, NULL); frameLength = WaitForEncodedFrame(); - EXPECT_TRUE(frameLength > 0); + EXPECT_GT(frameLength, 0u); // Reset then decode. EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK); frameLength = 0; @@ -631,7 +629,7 @@ UnitTest::Perform() WEBRTC_VIDEO_CODEC_OK); _encoder->Encode(_inputVideoBuffer, NULL, NULL); frameLength = WaitForEncodedFrame(); - EXPECT_TRUE(frameLength > 0); + EXPECT_GT(frameLength, 0u); // Reset then decode original frame again. EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK); @@ -644,11 +642,11 @@ UnitTest::Perform() } // check that decoded frame matches with reference - unsigned int length = CalcBufferSize(kI420, width, height); + size_t length = CalcBufferSize(kI420, width, height); scoped_ptr decoded_buffer(new uint8_t[length]); ExtractBuffer(_decodedVideoBuffer, length, decoded_buffer.get()); EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), length, - _refDecFrame, _lengthSourceFrame) == true); + _refDecFrame, _lengthSourceFrame)); } // Release then decode. @@ -664,7 +662,7 @@ UnitTest::Perform() } ExtractBuffer(_decodedVideoBuffer, length, decoded_buffer.get()); EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), frameLength, - _refDecFrame, _lengthSourceFrame) == true); + _refDecFrame, _lengthSourceFrame)); _encodedVideoBuffer.SetLength(0); delete [] tmpBuf; @@ -697,8 +695,7 @@ UnitTest::Perform() ASSERT_TRUE(_encoder->Encode(_inputVideoBuffer, NULL, NULL) == WEBRTC_VIDEO_CODEC_OK); frameLength = WaitForEncodedFrame(); - //ASSERT_TRUE(frameLength); - EXPECT_TRUE(frameLength > 0); + EXPECT_GT(frameLength, 0u); encTimeStamp = _encodedVideoBuffer.TimeStamp(); EXPECT_TRUE(_inputVideoBuffer.timestamp() == static_cast(encTimeStamp)); @@ -707,8 +704,7 @@ UnitTest::Perform() is_key_frame_ = true; } - frameLength = Decode(); - if (frameLength == 0) + if (Decode() == 0) { frameDelay++; } @@ -735,7 +731,7 @@ UnitTest::RateControlTests() { int frames = 0; VideoFrame inputImage; - uint32_t frameLength; + size_t frameLength; // Do not specify maxBitRate (as in ViE). _inst.maxBitrate = 0; @@ -754,7 +750,7 @@ UnitTest::RateControlTests() for (int i = 0; i < nBitrates; i++) { _bitRate = bitRate[i]; - int totalBytes = 0; + size_t totalBytes = 0; _inst.startBitrate = _bitRate; _encoder->InitEncode(&_inst, 4, 1440); _decoder->Reset(); @@ -789,27 +785,26 @@ UnitTest::RateControlTests() ASSERT_EQ(_encoder->Encode(_inputVideoBuffer, NULL, NULL), WEBRTC_VIDEO_CODEC_OK); frameLength = WaitForEncodedFrame(); - ASSERT_GE(frameLength, 0u); totalBytes += frameLength; frames++; _encodedVideoBuffer.SetLength(0); } - uint32_t actualBitrate = - (totalBytes / frames * _inst.maxFramerate * 8)/1000; - printf("Target bitrate: %d kbps, actual bitrate: %d kbps\n", _bitRate, - actualBitrate); + uint32_t actualBitrate = static_cast( + (totalBytes / frames * _inst.maxFramerate * 8) / 1000); + printf("Target bitrate: %u kbps, actual bitrate: %u kbps\n", _bitRate, + actualBitrate); // Test for close match over reasonable range. - EXPECT_TRUE(abs(int32_t(actualBitrate - _bitRate)) < - 0.12 * _bitRate); + EXPECT_LT(abs(static_cast(actualBitrate - _bitRate)), + 0.12 * _bitRate); ASSERT_TRUE(feof(_sourceFile) != 0); rewind(_sourceFile); } } bool -UnitTest::CheckIfBitExact(const void* ptrA, unsigned int aLengthBytes, - const void* ptrB, unsigned int bLengthBytes) +UnitTest::CheckIfBitExact(const void* ptrA, size_t aLengthBytes, + const void* ptrB, size_t bLengthBytes) { if (aLengthBytes != bLengthBytes) { diff --git a/webrtc/modules/video_coding/codecs/test_framework/unit_test.h b/webrtc/modules/video_coding/codecs/test_framework/unit_test.h index 4e2fea0e77..7e55a907f1 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/unit_test.h +++ b/webrtc/modules/video_coding/codecs/test_framework/unit_test.h @@ -48,11 +48,11 @@ protected: virtual int DecodeWithoutAssert(); virtual int SetCodecSpecificParameters() {return 0;}; - virtual bool CheckIfBitExact(const void *ptrA, unsigned int aLengthBytes, - const void *ptrB, unsigned int bLengthBytes); + virtual bool CheckIfBitExact(const void *ptrA, size_t aLengthBytes, + const void *ptrB, size_t bLengthBytes); - uint32_t WaitForEncodedFrame() const; - uint32_t WaitForDecodedFrame() const; + size_t WaitForEncodedFrame() const; + size_t WaitForDecodedFrame() const; int _tests; int _errors; @@ -61,7 +61,7 @@ protected: unsigned char* _refFrame; unsigned char* _refEncFrame; unsigned char* _refDecFrame; - unsigned int _refEncFrameLength; + size_t _refEncFrameLength; FILE* _sourceFile; bool is_key_frame_; diff --git a/webrtc/modules/video_coding/codecs/test_framework/video_source.cc b/webrtc/modules/video_coding/codecs/test_framework/video_source.cc index 23fbaa84a2..7092e45a92 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/video_source.cc +++ b/webrtc/modules/video_coding/codecs/test_framework/video_source.cc @@ -116,7 +116,7 @@ VideoSource::GetSize(uint16_t width, uint16_t height) return kUndefined; } -unsigned int +size_t VideoSource::GetFrameLength() const { return webrtc::CalcBufferSize(_type, _width, _height); diff --git a/webrtc/modules/video_coding/codecs/test_framework/video_source.h b/webrtc/modules/video_coding/codecs/test_framework/video_source.h index b3c4e79173..44f56aec66 100644 --- a/webrtc/modules/video_coding/codecs/test_framework/video_source.h +++ b/webrtc/modules/video_coding/codecs/test_framework/video_source.h @@ -71,7 +71,7 @@ public: VideoSize GetSize() const; static VideoSize GetSize(uint16_t width, uint16_t height); - unsigned int GetFrameLength() const; + size_t GetFrameLength() const; // Returns a human-readable size string. static const char* GetSizeString(VideoSize size); diff --git a/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc b/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc index 7a124469f2..ced92bce24 100644 --- a/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc +++ b/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc @@ -20,6 +20,7 @@ #endif #include "gflags/gflags.h" +#include "webrtc/base/format_macros.h" #include "webrtc/common_types.h" #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" #include "webrtc/modules/video_coding/codecs/test/stats.h" @@ -204,7 +205,8 @@ int HandleCommandLineFlags(webrtc::test::TestConfig* config) { FLAGS_packet_size); return 7; } - config->networking_config.packet_size_in_bytes = FLAGS_packet_size; + config->networking_config.packet_size_in_bytes = + static_cast(FLAGS_packet_size); if (FLAGS_max_payload_size <= 0) { fprintf(stderr, "Max payload size must be >0 bytes, was: %d\n", @@ -212,7 +214,7 @@ int HandleCommandLineFlags(webrtc::test::TestConfig* config) { return 8; } config->networking_config.max_payload_size_in_bytes = - FLAGS_max_payload_size; + static_cast(FLAGS_max_payload_size); // Check the width and height if (FLAGS_width <= 0 || FLAGS_height <= 0) { @@ -290,10 +292,10 @@ void PrintConfigurationSummary(const webrtc::test::TestConfig& config) { Log(" Input filename : %s\n", config.input_filename.c_str()); Log(" Output directory : %s\n", config.output_dir.c_str()); Log(" Output filename : %s\n", config.output_filename.c_str()); - Log(" Frame length : %d bytes\n", config.frame_length_in_bytes); - Log(" Packet size : %d bytes\n", + Log(" Frame length : %" PRIuS " bytes\n", config.frame_length_in_bytes); + Log(" Packet size : %" PRIuS " bytes\n", config.networking_config.packet_size_in_bytes); - Log(" Max payload size : %d bytes\n", + Log(" Max payload size : %" PRIuS " bytes\n", config.networking_config.max_payload_size_in_bytes); Log(" Packet loss:\n"); Log(" Mode : %s\n", @@ -320,8 +322,8 @@ void PrintCsvOutput(const webrtc::test::Stats& stats, const webrtc::test::FrameStatistic& f = stats.stats_[i]; const webrtc::test::FrameResult& ssim = ssim_result.frames[i]; const webrtc::test::FrameResult& psnr = psnr_result.frames[i]; - printf("%4d, %d, %d, %2d, %2d, %6d, %6d, %5d, %7d, %d, %2d, %2d, " - "%5.3f, %5.2f\n", + printf("%4d, %d, %d, %2d, %2d, %6d, %6d, %5d, %7" PRIuS ", %d, %2d, %2" + PRIuS ", %5.3f, %5.2f\n", f.frame_number, f.encoding_successful, f.decoding_successful, @@ -352,13 +354,13 @@ void PrintPythonOutput(const webrtc::test::TestConfig& config, "{'name': 'input_filename', 'value': '%s'},\n" "{'name': 'output_filename', 'value': '%s'},\n" "{'name': 'output_dir', 'value': '%s'},\n" - "{'name': 'packet_size_in_bytes', 'value': '%d'},\n" - "{'name': 'max_payload_size_in_bytes', 'value': '%d'},\n" + "{'name': 'packet_size_in_bytes', 'value': '%" PRIuS "'},\n" + "{'name': 'max_payload_size_in_bytes', 'value': '%" PRIuS "'},\n" "{'name': 'packet_loss_mode', 'value': '%s'},\n" "{'name': 'packet_loss_probability', 'value': '%f'},\n" "{'name': 'packet_loss_burst_length', 'value': '%d'},\n" "{'name': 'exclude_frame_types', 'value': '%s'},\n" - "{'name': 'frame_length_in_bytes', 'value': '%d'},\n" + "{'name': 'frame_length_in_bytes', 'value': '%" PRIuS "'},\n" "{'name': 'use_single_core', 'value': '%s'},\n" "{'name': 'keyframe_interval;', 'value': '%d'},\n" "{'name': 'video_codec_type', 'value': '%s'},\n" @@ -411,9 +413,9 @@ void PrintPythonOutput(const webrtc::test::TestConfig& config, "'encoding_successful': %s, 'decoding_successful': %s, " "'encode_time': %d, 'decode_time': %d, " "'encode_return_code': %d, 'decode_return_code': %d, " - "'bit_rate': %d, 'encoded_frame_length': %d, 'frame_type': %s, " - "'packets_dropped': %d, 'total_packets': %d, " - "'ssim': %f, 'psnr': %f},\n", + "'bit_rate': %d, 'encoded_frame_length': %" PRIuS ", " + "'frame_type': %s, 'packets_dropped': %d, " + "'total_packets': %" PRIuS ", 'ssim': %f, 'psnr': %f},\n", f.frame_number, f.encoding_successful ? "True " : "False", f.decoding_successful ? "True " : "False", diff --git a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc index 5e0bfc826a..6666bab8d5 100644 --- a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc +++ b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc @@ -148,7 +148,7 @@ class TestVp8Impl : public ::testing::Test { EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); } - int WaitForEncodedFrame() const { + size_t WaitForEncodedFrame() const { int64_t startTime = TickTime::MillisecondTimestamp(); while (TickTime::MillisecondTimestamp() - startTime < kMaxWaitEncTimeMs) { if (encode_complete_callback_->EncodeComplete()) { @@ -158,7 +158,7 @@ class TestVp8Impl : public ::testing::Test { return 0; } - int WaitForDecodedFrame() const { + size_t WaitForDecodedFrame() const { int64_t startTime = TickTime::MillisecondTimestamp(); while (TickTime::MillisecondTimestamp() - startTime < kMaxWaitDecTimeMs) { if (decode_complete_callback_->DecodeComplete()) { @@ -188,7 +188,7 @@ class TestVp8Impl : public ::testing::Test { scoped_ptr decoder_; VideoFrame encoded_video_frame_; I420VideoFrame decoded_video_frame_; - unsigned int length_source_frame_; + size_t length_source_frame_; VideoCodec codec_inst_; }; @@ -239,14 +239,14 @@ TEST_F(TestVp8Impl, EncoderParameterTest) { TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(AlignedStrideEncodeDecode)) { SetUpEncodeDecode(); encoder_->Encode(input_frame_, NULL, NULL); - EXPECT_GT(WaitForEncodedFrame(), 0); + EXPECT_GT(WaitForEncodedFrame(), 0u); EncodedImage encodedImage; VideoFrameToEncodedImage(encoded_video_frame_, encodedImage); // First frame should be a key frame. encodedImage._frameType = kKeyFrame; encodedImage.ntp_time_ms_ = kTestNtpTimeMs; EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encodedImage, false, NULL)); - EXPECT_GT(WaitForDecodedFrame(), 0); + EXPECT_GT(WaitForDecodedFrame(), 0u); // Compute PSNR on all planes (faster than SSIM). EXPECT_GT(I420PSNR(&input_frame_, &decoded_video_frame_), 36); EXPECT_EQ(kTestTimestamp, decoded_video_frame_.timestamp()); @@ -256,7 +256,7 @@ TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(AlignedStrideEncodeDecode)) { TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(DecodeWithACompleteKeyFrame)) { SetUpEncodeDecode(); encoder_->Encode(input_frame_, NULL, NULL); - EXPECT_GT(WaitForEncodedFrame(), 0); + EXPECT_GT(WaitForEncodedFrame(), 0u); EncodedImage encodedImage; VideoFrameToEncodedImage(encoded_video_frame_, encodedImage); // Setting complete to false -> should return an error. diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc index 2a2a9d043f..5345c805e0 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc @@ -116,7 +116,7 @@ int VP8EncoderImpl::SetRates(uint32_t new_bitrate_kbit, int VP8EncoderImpl::InitEncode(const VideoCodec* inst, int number_of_cores, - uint32_t /*max_payload_size*/) { + size_t /*max_payload_size*/) { if (inst == NULL) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } @@ -791,7 +791,7 @@ int VP8DecoderImpl::DecodePartitions( for (int i = 0; i < fragmentation->fragmentationVectorSize; ++i) { const uint8_t* partition = input_image._buffer + fragmentation->fragmentationOffset[i]; - const uint32_t partition_length = + const size_t partition_length = fragmentation->fragmentationLength[i]; if (vpx_codec_decode(decoder_, partition, diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h index fec53d53e8..06f2a26ce7 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h @@ -39,7 +39,7 @@ class VP8EncoderImpl : public VP8Encoder { virtual int InitEncode(const VideoCodec* codec_settings, int number_of_cores, - uint32_t max_payload_size); + size_t max_payload_size); virtual int Encode(const I420VideoFrame& input_image, const CodecSpecificInfo* codec_specific_info, diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc index ffa0bcc681..992f0898be 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc @@ -30,11 +30,11 @@ class Vp8SequenceCoderEncodeCallback : public webrtc::EncodedImageCallback { const webrtc::RTPFragmentationHeader*); // Returns the encoded image. webrtc::EncodedImage encoded_image() { return encoded_image_; } - int encoded_bytes() { return encoded_bytes_; } + size_t encoded_bytes() { return encoded_bytes_; } private: webrtc::EncodedImage encoded_image_; FILE* encoded_file_; - int encoded_bytes_; + size_t encoded_bytes_; }; Vp8SequenceCoderEncodeCallback::~Vp8SequenceCoderEncodeCallback() { @@ -141,7 +141,7 @@ int SequenceCoder(webrtc::test::CommandLineParser& parser) { } EXPECT_EQ(0, decoder->InitDecode(&inst, 1)); webrtc::I420VideoFrame input_frame; - unsigned int length = webrtc::CalcBufferSize(webrtc::kI420, width, height); + size_t length = webrtc::CalcBufferSize(webrtc::kI420, width, height); webrtc::scoped_ptr frame_buffer(new uint8_t[length]); int half_width = (width + 1) / 2; @@ -175,9 +175,8 @@ int SequenceCoder(webrtc::test::CommandLineParser& parser) { int64_t totalExecutionTime = endtime - starttime; printf("Total execution time: %.2lf ms\n", static_cast(totalExecutionTime)); - int sum_enc_bytes = encoder_callback.encoded_bytes(); - double actual_bit_rate = 8.0 * sum_enc_bytes / - (frame_cnt / inst.maxFramerate); + double actual_bit_rate = + 8.0 * encoder_callback.encoded_bytes() / (frame_cnt / inst.maxFramerate); printf("Actual bitrate: %f kbps\n", actual_bit_rate / 1000); webrtc::test::QualityMetricsResult psnr_result, ssim_result; EXPECT_EQ(0, webrtc::test::I420MetricsFromFiles( diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc index 734e73d27f..fa5b05b461 100644 --- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc @@ -103,7 +103,7 @@ int VP9EncoderImpl::SetRates(uint32_t new_bitrate_kbit, int VP9EncoderImpl::InitEncode(const VideoCodec* inst, int number_of_cores, - uint32_t /*max_payload_size*/) { + size_t /*max_payload_size*/) { if (inst == NULL) { return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } @@ -428,7 +428,7 @@ int VP9DecoderImpl::Decode(const EncodedImage& input_image, } if (vpx_codec_decode(decoder_, buffer, - input_image._length, + static_cast(input_image._length), 0, VPX_DL_REALTIME)) { return WEBRTC_VIDEO_CODEC_ERROR; diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h index 94788db5ee..355aadfa38 100644 --- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h +++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h @@ -34,7 +34,7 @@ class VP9EncoderImpl : public VP9Encoder { virtual int InitEncode(const VideoCodec* codec_settings, int number_of_cores, - uint32_t max_payload_size) OVERRIDE; + size_t max_payload_size) OVERRIDE; virtual int Encode(const I420VideoFrame& input_image, const CodecSpecificInfo* codec_specific_info, diff --git a/webrtc/modules/video_coding/main/interface/video_coding.h b/webrtc/modules/video_coding/main/interface/video_coding.h index ef9209a444..d46ac1567b 100644 --- a/webrtc/modules/video_coding/main/interface/video_coding.h +++ b/webrtc/modules/video_coding/main/interface/video_coding.h @@ -467,8 +467,8 @@ public: // Return value : VCM_OK, on success. // < 0, on error. virtual int32_t IncomingPacket(const uint8_t* incomingPayload, - uint32_t payloadLength, - const WebRtcRTPHeader& rtpInfo) = 0; + size_t payloadLength, + const WebRtcRTPHeader& rtpInfo) = 0; // Minimum playout delay (Used for lip-sync). This is the minimum delay required // to sync with audio. Not included in VideoCodingModule::Delay() diff --git a/webrtc/modules/video_coding/main/interface/video_coding_defines.h b/webrtc/modules/video_coding/main/interface/video_coding_defines.h index efdc41b487..72658a3152 100644 --- a/webrtc/modules/video_coding/main/interface/video_coding_defines.h +++ b/webrtc/modules/video_coding/main/interface/video_coding_defines.h @@ -75,7 +75,7 @@ class VCMPacketizationCallback { uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& fragmentationHeader, const RTPVideoHeader* rtpVideoHdr) = 0; protected: diff --git a/webrtc/modules/video_coding/main/source/codec_database.cc b/webrtc/modules/video_coding/main/source/codec_database.cc index 2fc92461ca..3bd65d6eb7 100644 --- a/webrtc/modules/video_coding/main/source/codec_database.cc +++ b/webrtc/modules/video_coding/main/source/codec_database.cc @@ -25,6 +25,10 @@ #include "webrtc/modules/video_coding/main/source/internal_defines.h" #include "webrtc/system_wrappers/interface/logging.h" +namespace { +const size_t kDefaultPayloadSize = 1440; +} + namespace webrtc { VideoCodecVP8 VideoEncoder::GetDefaultVp8Settings() { @@ -227,12 +231,12 @@ void VCMCodecDataBase::ResetSender() { bool VCMCodecDataBase::SetSendCodec( const VideoCodec* send_codec, int number_of_cores, - int max_payload_size, + size_t max_payload_size, VCMEncodedFrameCallback* encoded_frame_callback) { if (!send_codec) { return false; } - if (max_payload_size <= 0) { + if (max_payload_size == 0) { max_payload_size = kDefaultPayloadSize; } if (number_of_cores <= 0) { diff --git a/webrtc/modules/video_coding/main/source/codec_database.h b/webrtc/modules/video_coding/main/source/codec_database.h index f27218f61c..a31decb63f 100644 --- a/webrtc/modules/video_coding/main/source/codec_database.h +++ b/webrtc/modules/video_coding/main/source/codec_database.h @@ -22,10 +22,6 @@ namespace webrtc { -enum VCMCodecDBProperties { - kDefaultPayloadSize = 1440 -}; - struct VCMDecoderMapItem { public: VCMDecoderMapItem(VideoCodec* settings, @@ -70,7 +66,7 @@ class VCMCodecDataBase { // Returns true if the codec was successfully registered, false otherwise. bool SetSendCodec(const VideoCodec* send_codec, int number_of_cores, - int max_payload_size, + size_t max_payload_size, VCMEncodedFrameCallback* encoded_frame_callback); // Gets the current send codec. Relevant for internal codecs only. @@ -175,7 +171,7 @@ class VCMCodecDataBase { uint8_t payload_type) const; int number_of_cores_; - int max_payload_size_; + size_t max_payload_size_; bool periodic_key_frames_; bool pending_encoder_reset_; bool current_enc_is_external_; diff --git a/webrtc/modules/video_coding/main/source/encoded_frame.h b/webrtc/modules/video_coding/main/source/encoded_frame.h index dd0f843d26..4be4e6b50a 100644 --- a/webrtc/modules/video_coding/main/source/encoded_frame.h +++ b/webrtc/modules/video_coding/main/source/encoded_frame.h @@ -56,7 +56,7 @@ public: /** * Get frame length */ - uint32_t Length() const {return _length;} + size_t Length() const {return _length;} /** * Get frame timestamp (90kHz) */ diff --git a/webrtc/modules/video_coding/main/source/frame_buffer.cc b/webrtc/modules/video_coding/main/source/frame_buffer.cc index fce68fb32d..6dd35546a5 100644 --- a/webrtc/modules/video_coding/main/source/frame_buffer.cc +++ b/webrtc/modules/video_coding/main/source/frame_buffer.cc @@ -268,11 +268,11 @@ VCMFrameBuffer::PrepareForDecode(bool continuous) { _sessionInfo.BuildVP8FragmentationHeader(_buffer, _length, &_fragmentation); } else { - int bytes_removed = _sessionInfo.MakeDecodable(); + size_t bytes_removed = _sessionInfo.MakeDecodable(); _length -= bytes_removed; } #else - int bytes_removed = _sessionInfo.MakeDecodable(); + size_t bytes_removed = _sessionInfo.MakeDecodable(); _length -= bytes_removed; #endif // Transfer frame information to EncodedFrame and create any codec diff --git a/webrtc/modules/video_coding/main/source/generic_encoder.cc b/webrtc/modules/video_coding/main/source/generic_encoder.cc index 655f7acb84..d6a7bbb960 100644 --- a/webrtc/modules/video_coding/main/source/generic_encoder.cc +++ b/webrtc/modules/video_coding/main/source/generic_encoder.cc @@ -82,7 +82,7 @@ int32_t VCMGenericEncoder::Release() int32_t VCMGenericEncoder::InitEncode(const VideoCodec* settings, int32_t numberOfCores, - uint32_t maxPayloadSize) + size_t maxPayloadSize) { _bitRate = settings->startBitrate * 1000; _frameRate = settings->maxFramerate; @@ -218,7 +218,7 @@ VCMEncodedFrameCallback::Encoded( FrameType frameType = VCMEncodedFrame::ConvertFrameType(encodedImage._frameType); - uint32_t encodedBytes = 0; + size_t encodedBytes = 0; if (_sendCallback != NULL) { encodedBytes = encodedImage._length; diff --git a/webrtc/modules/video_coding/main/source/generic_encoder.h b/webrtc/modules/video_coding/main/source/generic_encoder.h index 9277260af3..8eb14804b5 100644 --- a/webrtc/modules/video_coding/main/source/generic_encoder.h +++ b/webrtc/modules/video_coding/main/source/generic_encoder.h @@ -84,7 +84,7 @@ public: */ int32_t InitEncode(const VideoCodec* settings, int32_t numberOfCores, - uint32_t maxPayloadSize); + size_t maxPayloadSize); /** * Encode raw image * inputFrame : Frame containing raw image diff --git a/webrtc/modules/video_coding/main/source/media_optimization.cc b/webrtc/modules/video_coding/main/source/media_optimization.cc index 578948076d..630f013036 100644 --- a/webrtc/modules/video_coding/main/source/media_optimization.cc +++ b/webrtc/modules/video_coding/main/source/media_optimization.cc @@ -62,14 +62,14 @@ void UpdateProtectionCallback( } // namespace struct MediaOptimization::EncodedFrameSample { - EncodedFrameSample(int size_bytes, + EncodedFrameSample(size_t size_bytes, uint32_t timestamp, int64_t time_complete_ms) : size_bytes(size_bytes), timestamp(timestamp), time_complete_ms(time_complete_ms) {} - uint32_t size_bytes; + size_t size_bytes; uint32_t timestamp; int64_t time_complete_ms; }; @@ -369,7 +369,7 @@ VCMFrameCount MediaOptimization::SentFrameCount() { return count; } -int32_t MediaOptimization::UpdateWithEncodedData(int encoded_length, +int32_t MediaOptimization::UpdateWithEncodedData(size_t encoded_length, uint32_t timestamp, FrameType encoded_frame_type) { CriticalSectionScoped lock(crit_sect_.get()); @@ -532,7 +532,7 @@ void MediaOptimization::UpdateSentBitrate(int64_t now_ms) { avg_sent_bit_rate_bps_ = 0; return; } - int framesize_sum = 0; + size_t framesize_sum = 0; for (FrameSampleList::iterator it = encoded_frame_samples_.begin(); it != encoded_frame_samples_.end(); ++it) { diff --git a/webrtc/modules/video_coding/main/source/media_optimization.h b/webrtc/modules/video_coding/main/source/media_optimization.h index df3fbb64ea..af35f01000 100644 --- a/webrtc/modules/video_coding/main/source/media_optimization.h +++ b/webrtc/modules/video_coding/main/source/media_optimization.h @@ -77,7 +77,7 @@ class MediaOptimization { void UpdateContentData(const VideoContentMetrics* content_metrics); // Informs Media Optimization of encoding output: Length and frame type. - int32_t UpdateWithEncodedData(int encoded_length, + int32_t UpdateWithEncodedData(size_t encoded_length, uint32_t timestamp, FrameType encoded_frame_type); diff --git a/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc b/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc index bacfdc604c..df79fb7524 100644 --- a/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc +++ b/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc @@ -30,12 +30,11 @@ class TestMediaOptimization : public ::testing::Test { next_timestamp_(0) {} // This method mimics what happens in VideoSender::AddVideoFrame. - void AddFrameAndAdvanceTime(int bitrate_bps, bool expect_frame_drop) { - ASSERT_GE(bitrate_bps, 0); + void AddFrameAndAdvanceTime(uint32_t bitrate_bps, bool expect_frame_drop) { bool frame_dropped = media_opt_.DropFrame(); EXPECT_EQ(expect_frame_drop, frame_dropped); if (!frame_dropped) { - int bytes_per_frame = bitrate_bps * frame_time_ms_ / (8 * 1000); + size_t bytes_per_frame = bitrate_bps * frame_time_ms_ / (8 * 1000); ASSERT_EQ(VCM_OK, media_opt_.UpdateWithEncodedData( bytes_per_frame, next_timestamp_, kVideoFrameDelta)); } @@ -54,14 +53,14 @@ TEST_F(TestMediaOptimization, VerifyMuting) { // Enable video suspension with these limits. // Suspend the video when the rate is below 50 kbps and resume when it gets // above 50 + 10 kbps again. - const int kThresholdBps = 50000; - const int kWindowBps = 10000; + const uint32_t kThresholdBps = 50000; + const uint32_t kWindowBps = 10000; media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps); // The video should not be suspended from the start. EXPECT_FALSE(media_opt_.IsVideoSuspended()); - int target_bitrate_kbps = 100; + uint32_t target_bitrate_kbps = 100; media_opt_.SetTargetRates(target_bitrate_kbps * 1000, 0, // Lossrate. 100, diff --git a/webrtc/modules/video_coding/main/source/packet.cc b/webrtc/modules/video_coding/main/source/packet.cc index 63dcd636dd..dd3743f701 100644 --- a/webrtc/modules/video_coding/main/source/packet.cc +++ b/webrtc/modules/video_coding/main/source/packet.cc @@ -35,7 +35,7 @@ VCMPacket::VCMPacket() } VCMPacket::VCMPacket(const uint8_t* ptr, - const uint32_t size, + const size_t size, const WebRtcRTPHeader& rtpHeader) : payloadType(rtpHeader.header.payloadType), timestamp(rtpHeader.header.timestamp), @@ -57,7 +57,11 @@ VCMPacket::VCMPacket(const uint8_t* ptr, CopyCodecSpecifics(rtpHeader.type.Video); } -VCMPacket::VCMPacket(const uint8_t* ptr, uint32_t size, uint16_t seq, uint32_t ts, bool mBit) : +VCMPacket::VCMPacket(const uint8_t* ptr, + size_t size, + uint16_t seq, + uint32_t ts, + bool mBit) : payloadType(0), timestamp(ts), ntp_time_ms_(0), diff --git a/webrtc/modules/video_coding/main/source/packet.h b/webrtc/modules/video_coding/main/source/packet.h index 242d3a4314..d98b6f65c2 100644 --- a/webrtc/modules/video_coding/main/source/packet.h +++ b/webrtc/modules/video_coding/main/source/packet.h @@ -21,10 +21,10 @@ class VCMPacket { public: VCMPacket(); VCMPacket(const uint8_t* ptr, - const uint32_t size, + const size_t size, const WebRtcRTPHeader& rtpHeader); VCMPacket(const uint8_t* ptr, - uint32_t size, + size_t size, uint16_t seqNum, uint32_t timestamp, bool markerBit); @@ -37,7 +37,7 @@ public: int64_t ntp_time_ms_; uint16_t seqNum; const uint8_t* dataPtr; - uint32_t sizeBytes; + size_t sizeBytes; bool markerBit; FrameType frameType; diff --git a/webrtc/modules/video_coding/main/source/qm_select.cc b/webrtc/modules/video_coding/main/source/qm_select.cc index 85c5f366d0..0df61b5527 100644 --- a/webrtc/modules/video_coding/main/source/qm_select.cc +++ b/webrtc/modules/video_coding/main/source/qm_select.cc @@ -239,11 +239,11 @@ void VCMQmResolution::UpdateCodecParameters(float frame_rate, uint16_t width, } // Update rate data after every encoded frame. -void VCMQmResolution::UpdateEncodedSize(int encoded_size, +void VCMQmResolution::UpdateEncodedSize(size_t encoded_size, FrameType encoded_frame_type) { frame_cnt_++; // Convert to Kbps. - float encoded_size_kbits = static_cast((encoded_size * 8.0) / 1000.0); + float encoded_size_kbits = 8.0f * static_cast(encoded_size) / 1000.0f; // Update the buffer level: // Note this is not the actual encoder buffer level. diff --git a/webrtc/modules/video_coding/main/source/qm_select.h b/webrtc/modules/video_coding/main/source/qm_select.h index ce57236709..a87d50252e 100644 --- a/webrtc/modules/video_coding/main/source/qm_select.h +++ b/webrtc/modules/video_coding/main/source/qm_select.h @@ -216,7 +216,7 @@ class VCMQmResolution : public VCMQmMethod { // Update with actual bit rate (size of the latest encoded frame) // and frame type, after every encoded frame. - void UpdateEncodedSize(int encoded_size, + void UpdateEncodedSize(size_t encoded_size, FrameType encoded_frame_type); // Update with new target bitrate, actual encoder sent rate, frame_rate, diff --git a/webrtc/modules/video_coding/main/source/qm_select_unittest.cc b/webrtc/modules/video_coding/main/source/qm_select_unittest.cc index 5a7daed143..0120f20f90 100644 --- a/webrtc/modules/video_coding/main/source/qm_select_unittest.cc +++ b/webrtc/modules/video_coding/main/source/qm_select_unittest.cc @@ -46,7 +46,7 @@ class QmSelectTest : public ::testing::Test { int native_height, int num_layers); - void UpdateQmEncodedFrame(int* encoded_size, int num_updates); + void UpdateQmEncodedFrame(size_t* encoded_size, size_t num_updates); void UpdateQmRateData(int* target_rate, int* encoder_sent_rate, @@ -315,8 +315,8 @@ TEST_F(QmSelectTest, DownActionBufferUnderflow) { // Update with encoded size over a number of frames. // per-frame bandwidth = 15 = 450/30: simulate (decoder) buffer underflow: - int encoded_size[] = {200, 100, 50, 30, 60, 40, 20, 30, 20, 40}; - UpdateQmEncodedFrame(encoded_size, 10); + size_t encoded_size[] = {200, 100, 50, 30, 60, 40, 20, 30, 20, 40}; + UpdateQmEncodedFrame(encoded_size, GTEST_ARRAY_SIZE_(encoded_size)); // Update rates for a sequence of intervals. int target_rate[] = {300, 300, 300}; @@ -359,8 +359,8 @@ TEST_F(QmSelectTest, NoActionBufferStable) { // Update with encoded size over a number of frames. // per-frame bandwidth = 15 = 450/30: simulate stable (decoder) buffer levels. - int32_t encoded_size[] = {40, 10, 10, 16, 18, 20, 17, 20, 16, 15}; - UpdateQmEncodedFrame(encoded_size, 10); + size_t encoded_size[] = {40, 10, 10, 16, 18, 20, 17, 20, 16, 15}; + UpdateQmEncodedFrame(encoded_size, GTEST_ARRAY_SIZE_(encoded_size)); // Update rates for a sequence of intervals. int target_rate[] = {350, 350, 350}; @@ -1262,11 +1262,12 @@ void QmSelectTest::UpdateQmContentData(float motion_metric, qm_resolution_->UpdateContent(content_metrics_); } -void QmSelectTest::UpdateQmEncodedFrame(int* encoded_size, int num_updates) { +void QmSelectTest::UpdateQmEncodedFrame(size_t* encoded_size, + size_t num_updates) { FrameType frame_type = kVideoFrameDelta; - for (int i = 0; i < num_updates; ++i) { + for (size_t i = 0; i < num_updates; ++i) { // Convert to bytes. - int32_t encoded_size_update = 1000 * encoded_size[i] / 8; + size_t encoded_size_update = 1000 * encoded_size[i] / 8; qm_resolution_->UpdateEncodedSize(encoded_size_update, frame_type); } } diff --git a/webrtc/modules/video_coding/main/source/session_info.cc b/webrtc/modules/video_coding/main/source/session_info.cc index d7d576d3f4..b165d7c919 100644 --- a/webrtc/modules/video_coding/main/source/session_info.cc +++ b/webrtc/modules/video_coding/main/source/session_info.cc @@ -110,8 +110,8 @@ void VCMSessionInfo::Reset() { last_packet_seq_num_ = -1; } -int VCMSessionInfo::SessionLength() const { - int length = 0; +size_t VCMSessionInfo::SessionLength() const { + size_t length = 0; for (PacketIteratorConst it = packets_.begin(); it != packets_.end(); ++it) length += (*it).sizeBytes; return length; @@ -121,13 +121,13 @@ int VCMSessionInfo::NumPackets() const { return packets_.size(); } -int VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer, - PacketIterator packet_it) { +size_t VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer, + PacketIterator packet_it) { VCMPacket& packet = *packet_it; PacketIterator it; // Calculate the offset into the frame buffer for this packet. - int offset = 0; + size_t offset = 0; for (it = packets_.begin(); it != packet_it; ++it) offset += (*it).sizeBytes; @@ -145,7 +145,7 @@ int VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer, size_t required_length = 0; const uint8_t* nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes; while (nalu_ptr < packet_buffer + packet.sizeBytes) { - uint32_t length = BufferToUWord16(nalu_ptr); + size_t length = BufferToUWord16(nalu_ptr); required_length += length + (packet.insertStartCode ? kH264StartCodeLengthBytes : 0); nalu_ptr += kLengthFieldLength + length; @@ -154,7 +154,7 @@ int VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer, nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes; uint8_t* frame_buffer_ptr = frame_buffer + offset; while (nalu_ptr < packet_buffer + packet.sizeBytes) { - uint32_t length = BufferToUWord16(nalu_ptr); + size_t length = BufferToUWord16(nalu_ptr); nalu_ptr += kLengthFieldLength; frame_buffer_ptr += Insert(nalu_ptr, length, @@ -276,9 +276,9 @@ VCMSessionInfo::PacketIterator VCMSessionInfo::FindNaluEnd( return --packet_it; } -int VCMSessionInfo::DeletePacketData(PacketIterator start, - PacketIterator end) { - int bytes_to_delete = 0; // The number of bytes to delete. +size_t VCMSessionInfo::DeletePacketData(PacketIterator start, + PacketIterator end) { + size_t bytes_to_delete = 0; // The number of bytes to delete. PacketIterator packet_after_end = end; ++packet_after_end; @@ -290,20 +290,20 @@ int VCMSessionInfo::DeletePacketData(PacketIterator start, (*it).dataPtr = NULL; } if (bytes_to_delete > 0) - ShiftSubsequentPackets(end, -bytes_to_delete); + ShiftSubsequentPackets(end, -static_cast(bytes_to_delete)); return bytes_to_delete; } -int VCMSessionInfo::BuildVP8FragmentationHeader( +size_t VCMSessionInfo::BuildVP8FragmentationHeader( uint8_t* frame_buffer, - int frame_buffer_length, + size_t frame_buffer_length, RTPFragmentationHeader* fragmentation) { - int new_length = 0; + size_t new_length = 0; // Allocate space for max number of partitions fragmentation->VerifyAndAllocateFragmentationHeader(kMaxVP8Partitions); fragmentation->fragmentationVectorSize = 0; memset(fragmentation->fragmentationLength, 0, - kMaxVP8Partitions * sizeof(uint32_t)); + kMaxVP8Partitions * sizeof(size_t)); if (packets_.empty()) return new_length; PacketIterator it = FindNextPartitionBeginning(packets_.begin()); @@ -314,11 +314,11 @@ int VCMSessionInfo::BuildVP8FragmentationHeader( fragmentation->fragmentationOffset[partition_id] = (*it).dataPtr - frame_buffer; assert(fragmentation->fragmentationOffset[partition_id] < - static_cast(frame_buffer_length)); + frame_buffer_length); fragmentation->fragmentationLength[partition_id] = (*partition_end).dataPtr + (*partition_end).sizeBytes - (*it).dataPtr; assert(fragmentation->fragmentationLength[partition_id] <= - static_cast(frame_buffer_length)); + frame_buffer_length); new_length += fragmentation->fragmentationLength[partition_id]; ++partition_end; it = FindNextPartitionBeginning(partition_end); @@ -385,8 +385,8 @@ bool VCMSessionInfo::InSequence(const PacketIterator& packet_it, (*packet_it).seqNum)); } -int VCMSessionInfo::MakeDecodable() { - int return_length = 0; +size_t VCMSessionInfo::MakeDecodable() { + size_t return_length = 0; if (packets_.empty()) { return 0; } @@ -511,13 +511,13 @@ int VCMSessionInfo::InsertPacket(const VCMPacket& packet, // The insert operation invalidates the iterator |rit|. PacketIterator packet_list_it = packets_.insert(rit.base(), packet); - int returnLength = InsertBuffer(frame_buffer, packet_list_it); + size_t returnLength = InsertBuffer(frame_buffer, packet_list_it); UpdateCompleteSession(); if (decode_error_mode == kWithErrors) decodable_ = true; else if (decode_error_mode == kSelectiveErrors) UpdateDecodableSession(frame_data); - return returnLength; + return static_cast(returnLength); } void VCMSessionInfo::InformOfEmptyPacket(uint16_t seq_num) { diff --git a/webrtc/modules/video_coding/main/source/session_info.h b/webrtc/modules/video_coding/main/source/session_info.h index 25216c7a1f..cd55130ec7 100644 --- a/webrtc/modules/video_coding/main/source/session_info.h +++ b/webrtc/modules/video_coding/main/source/session_info.h @@ -56,15 +56,15 @@ class VCMSessionInfo { // Builds fragmentation headers for VP8, each fragment being a decodable // VP8 partition. Returns the total number of bytes which are decodable. Is // used instead of MakeDecodable for VP8. - int BuildVP8FragmentationHeader(uint8_t* frame_buffer, - int frame_buffer_length, - RTPFragmentationHeader* fragmentation); + size_t BuildVP8FragmentationHeader(uint8_t* frame_buffer, + size_t frame_buffer_length, + RTPFragmentationHeader* fragmentation); // Makes the frame decodable. I.e., only contain decodable NALUs. All // non-decodable NALUs will be deleted and packets will be moved to in // memory to remove any empty space. // Returns the number of bytes deleted from the session. - int MakeDecodable(); + size_t MakeDecodable(); // Sets decodable_ to false. // Used by the dual decoder. After the mode is changed to kNoErrors from @@ -72,7 +72,7 @@ class VCMSessionInfo { // decodable and are not complete are marked as non-decodable. void SetNotDecodableIfIncomplete(); - int SessionLength() const; + size_t SessionLength() const; int NumPackets() const; bool HaveFirstPacket() const; bool HaveLastPacket() const; @@ -114,8 +114,8 @@ class VCMSessionInfo { PacketIterator FindPartitionEnd(PacketIterator it) const; static bool InSequence(const PacketIterator& it, const PacketIterator& prev_it); - int InsertBuffer(uint8_t* frame_buffer, - PacketIterator packetIterator); + size_t InsertBuffer(uint8_t* frame_buffer, + PacketIterator packetIterator); size_t Insert(const uint8_t* buffer, size_t length, bool insert_start_code, @@ -124,8 +124,8 @@ class VCMSessionInfo { PacketIterator FindNaluEnd(PacketIterator packet_iter) const; // Deletes the data of all packets between |start| and |end|, inclusively. // Note that this function doesn't delete the actual packets. - int DeletePacketData(PacketIterator start, - PacketIterator end); + size_t DeletePacketData(PacketIterator start, + PacketIterator end); void UpdateCompleteSession(); // When enabled, determine if session is decodable, i.e. incomplete but diff --git a/webrtc/modules/video_coding/main/source/session_info_unittest.cc b/webrtc/modules/video_coding/main/source/session_info_unittest.cc index 2fab94de36..fae55f4252 100644 --- a/webrtc/modules/video_coding/main/source/session_info_unittest.cc +++ b/webrtc/modules/video_coding/main/source/session_info_unittest.cc @@ -34,20 +34,20 @@ class TestSessionInfo : public ::testing::Test { } void FillPacket(uint8_t start_value) { - for (int i = 0; i < packet_buffer_size(); ++i) + for (size_t i = 0; i < packet_buffer_size(); ++i) packet_buffer_[i] = start_value + i; } void VerifyPacket(uint8_t* start_ptr, uint8_t start_value) { - for (int j = 0; j < packet_buffer_size(); ++j) { + for (size_t j = 0; j < packet_buffer_size(); ++j) { ASSERT_EQ(start_value + j, start_ptr[j]); } } - int packet_buffer_size() const { + size_t packet_buffer_size() const { return sizeof(packet_buffer_) / sizeof(packet_buffer_[0]); } - int frame_buffer_size() const { + size_t frame_buffer_size() const { return sizeof(frame_buffer_) / sizeof(frame_buffer_[0]); } @@ -77,10 +77,10 @@ class TestVP8Partitions : public TestSessionInfo { bool VerifyPartition(int partition_id, int packets_expected, int start_value) { - EXPECT_EQ(static_cast(packets_expected * packet_buffer_size()), + EXPECT_EQ(packets_expected * packet_buffer_size(), fragmentation_.fragmentationLength[partition_id]); for (int i = 0; i < packets_expected; ++i) { - int packet_index = fragmentation_.fragmentationOffset[partition_id] + + size_t packet_index = fragmentation_.fragmentationOffset[partition_id] + i * packet_buffer_size(); if (packet_index + packet_buffer_size() > frame_buffer_size()) return false; @@ -154,10 +154,8 @@ TEST_F(TestSessionInfo, TestSimpleAPIs) { packet_.frameType = kVideoFrameKey; FillPacket(0); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); EXPECT_FALSE(session_.HaveLastPacket()); EXPECT_EQ(kVideoFrameKey, session_.FrameType()); @@ -165,10 +163,8 @@ TEST_F(TestSessionInfo, TestSimpleAPIs) { packet_.markerBit = true; packet_.seqNum += 1; EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); EXPECT_TRUE(session_.HaveLastPacket()); EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); EXPECT_EQ(0xFFFE, session_.LowSequenceNumber()); @@ -193,31 +189,26 @@ TEST_F(TestSessionInfo, NormalOperation) { packet_.isFirstPacket = true; packet_.markerBit = false; FillPacket(0); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.isFirstPacket = false; for (int i = 1; i < 9; ++i) { packet_.seqNum += 1; FillPacket(i); - ASSERT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + ASSERT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, + frame_data))); } packet_.seqNum += 1; packet_.markerBit = true; FillPacket(9); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); EXPECT_EQ(10 * packet_buffer_size(), session_.SessionLength()); for (int i = 0; i < 10; ++i) { @@ -231,11 +222,10 @@ TEST_F(TestSessionInfo, ErrorsEqualDecodableState) { packet_.isFirstPacket = false; packet_.markerBit = false; FillPacket(3); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kWithErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kWithErrors, + frame_data))); EXPECT_TRUE(session_.decodable()); } @@ -246,21 +236,19 @@ TEST_F(TestSessionInfo, SelectiveDecodableState) { FillPacket(1); frame_data.rolling_average_packets_per_frame = 11; frame_data.rtt_ms = 150; - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kSelectiveErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kSelectiveErrors, + frame_data))); EXPECT_FALSE(session_.decodable()); packet_.seqNum -= 1; FillPacket(0); packet_.isFirstPacket = true; - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kSelectiveErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kSelectiveErrors, + frame_data))); EXPECT_TRUE(session_.decodable()); packet_.isFirstPacket = false; @@ -268,21 +256,19 @@ TEST_F(TestSessionInfo, SelectiveDecodableState) { for (int i = 2; i < 8; ++i) { packet_.seqNum += 1; FillPacket(i); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kSelectiveErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kSelectiveErrors, + frame_data))); EXPECT_TRUE(session_.decodable()); } packet_.seqNum += 1; FillPacket(8); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kSelectiveErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kSelectiveErrors, + frame_data))); EXPECT_TRUE(session_.decodable()); } @@ -291,11 +277,9 @@ TEST_F(TestSessionInfo, OutOfBoundsPackets1PacketFrame) { packet_.isFirstPacket = true; packet_.markerBit = true; FillPacket(1); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0x0004; packet_.isFirstPacket = true; @@ -320,11 +304,9 @@ TEST_F(TestSessionInfo, SetMarkerBitOnce) { packet_.isFirstPacket = false; packet_.markerBit = true; FillPacket(1); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); ++packet_.seqNum; packet_.isFirstPacket = true; packet_.markerBit = true; @@ -342,10 +324,8 @@ TEST_F(TestSessionInfo, OutOfBoundsPacketsBase) { packet_.markerBit = false; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); // Insert an older packet with a first packet set. packet_.seqNum = 0x0004; packet_.isFirstPacket = true; @@ -360,10 +340,8 @@ TEST_F(TestSessionInfo, OutOfBoundsPacketsBase) { packet_.markerBit = true; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0x0008; packet_.isFirstPacket = false; packet_.markerBit = true; @@ -380,29 +358,23 @@ TEST_F(TestSessionInfo, OutOfBoundsPacketsWrap) { packet_.markerBit = false; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0x0004; packet_.isFirstPacket = false; packet_.markerBit = true; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0x0002; packet_.isFirstPacket = false; packet_.markerBit = false; FillPacket(1); ASSERT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0xFFF0; packet_.isFirstPacket = false; packet_.markerBit = false; @@ -431,20 +403,16 @@ TEST_F(TestSessionInfo, OutOfBoundsOutOfOrder) { packet_.markerBit = false; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); // Insert an older packet with a first packet set. packet_.seqNum = 0x0005; packet_.isFirstPacket = true; packet_.markerBit = false; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0x0004; packet_.isFirstPacket = false; packet_.markerBit = false; @@ -458,19 +426,15 @@ TEST_F(TestSessionInfo, OutOfBoundsOutOfOrder) { packet_.markerBit = false; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0x0008; packet_.isFirstPacket = false; packet_.markerBit = true; FillPacket(1); EXPECT_EQ(packet_buffer_size(), - session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data)); + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum = 0x0009; packet_.isFirstPacket = false; @@ -493,11 +457,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss) { FillPacket(0); VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -507,11 +469,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss) { packet_header_.header.sequenceNumber += 2; FillPacket(2); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -521,18 +481,15 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss) { packet_header_.header.sequenceNumber += 1; FillPacket(3); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; // One packet should be removed (end of partition 0). - EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, - frame_buffer_size(), - &fragmentation_), - 2 * packet_buffer_size()); + EXPECT_EQ(2 * packet_buffer_size(), + session_.BuildVP8FragmentationHeader( + frame_buffer_, frame_buffer_size(), &fragmentation_)); SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(0, 1, 0)); SCOPED_TRACE("Calling VerifyPartition"); @@ -550,11 +507,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) { FillPacket(1); VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -564,11 +519,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) { packet_header_.header.sequenceNumber += 1; FillPacket(2); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -578,11 +531,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) { packet_header_.header.sequenceNumber += 1; FillPacket(3); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -592,18 +543,15 @@ TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) { packet_header_.header.sequenceNumber += 2; FillPacket(5); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; // One packet should be removed (end of partition 2), 3 left. - EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, - frame_buffer_size(), - &fragmentation_), - 3 * packet_buffer_size()); + EXPECT_EQ(3 * packet_buffer_size(), + session_.BuildVP8FragmentationHeader( + frame_buffer_, frame_buffer_size(), &fragmentation_)); SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(0, 2, 1)); SCOPED_TRACE("Calling VerifyPartition"); @@ -621,11 +569,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) { FillPacket(0); VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -635,11 +581,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) { packet_header_.header.sequenceNumber += 1; FillPacket(1); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -649,11 +593,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) { packet_header_.header.sequenceNumber += 1; FillPacket(2); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -663,18 +605,15 @@ TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) { packet_header_.header.sequenceNumber += 1; FillPacket(3); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; // No packet should be removed. - EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, - frame_buffer_size(), - &fragmentation_), - 4 * packet_buffer_size()); + EXPECT_EQ(4 * packet_buffer_size(), + session_.BuildVP8FragmentationHeader( + frame_buffer_, frame_buffer_size(), &fragmentation_)); SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(0, 2, 0)); SCOPED_TRACE("Calling VerifyPartition"); @@ -692,11 +631,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) { FillPacket(0); VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -706,11 +643,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) { packet_header_.header.sequenceNumber += 1; FillPacket(1); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -720,11 +655,9 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) { packet_header_.header.sequenceNumber += 1; FillPacket(2); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -734,18 +667,15 @@ TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) { packet_header_.header.sequenceNumber += 2; FillPacket(3); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; // One packet should be removed from the last partition - EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, - frame_buffer_size(), - &fragmentation_), - 3 * packet_buffer_size()); + EXPECT_EQ(3 * packet_buffer_size(), + session_.BuildVP8FragmentationHeader( + frame_buffer_, frame_buffer_size(), &fragmentation_)); SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(0, 2, 0)); SCOPED_TRACE("Calling VerifyPartition"); @@ -764,11 +694,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) { FillPacket(1); VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -778,11 +706,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) { packet_header_.header.sequenceNumber += 1; FillPacket(2); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -792,11 +718,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) { packet_header_.header.sequenceNumber += 3; FillPacket(5); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -806,18 +730,15 @@ TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) { packet_header_.header.sequenceNumber += 1; FillPacket(6); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; // No packet should be removed. - EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, - frame_buffer_size(), - &fragmentation_), - 4 * packet_buffer_size()); + EXPECT_EQ(4 * packet_buffer_size(), + session_.BuildVP8FragmentationHeader( + frame_buffer_, frame_buffer_size(), &fragmentation_)); SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(0, 2, 1)); SCOPED_TRACE("Calling VerifyPartition"); @@ -835,11 +756,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) { FillPacket(1); VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -850,11 +769,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) { FillPacket(2); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -864,11 +781,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) { packet_header_.header.sequenceNumber += 2; FillPacket(4); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -878,11 +793,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) { packet_header_.header.sequenceNumber += 1; FillPacket(5); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -892,11 +805,9 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) { packet_header_.header.sequenceNumber += 1; FillPacket(6); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -906,18 +817,15 @@ TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) { packet_header_.header.sequenceNumber += 1; FillPacket(7); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; // 2 partitions left. 2 packets removed from second partition - EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, - frame_buffer_size(), - &fragmentation_), - 4 * packet_buffer_size()); + EXPECT_EQ(4 * packet_buffer_size(), + session_.BuildVP8FragmentationHeader( + frame_buffer_, frame_buffer_size(), &fragmentation_)); SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(0, 2, 1)); SCOPED_TRACE("Calling VerifyPartition"); @@ -935,11 +843,9 @@ TEST_F(TestVP8Partitions, AggregationOverTwoPackets) { FillPacket(0); VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -949,11 +855,9 @@ TEST_F(TestVP8Partitions, AggregationOverTwoPackets) { packet_header_.header.sequenceNumber += 1; FillPacket(1); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; packet_header_.type.Video.isFirstPacket = false; @@ -963,18 +867,15 @@ TEST_F(TestVP8Partitions, AggregationOverTwoPackets) { packet_header_.header.sequenceNumber += 1; FillPacket(2); packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_); - EXPECT_EQ(session_.InsertPacket(*packet, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(*packet, frame_buffer_, + kNoErrors, frame_data))); delete packet; // No packets removed. - EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, - frame_buffer_size(), - &fragmentation_), - 3 * packet_buffer_size()); + EXPECT_EQ(3 * packet_buffer_size(), + session_.BuildVP8FragmentationHeader( + frame_buffer_, frame_buffer_size(), &fragmentation_)); SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(0, 2, 0)); // This partition is aggregated in partition 0 @@ -996,8 +897,8 @@ TEST_F(TestNalUnits, OnlyReceivedEmptyPacket) { kNoErrors, frame_data)); - EXPECT_EQ(0, session_.MakeDecodable()); - EXPECT_EQ(0, session_.SessionLength()); + EXPECT_EQ(0U, session_.MakeDecodable()); + EXPECT_EQ(0U, session_.SessionLength()); } TEST_F(TestNalUnits, OneIsolatedNaluLoss) { @@ -1006,24 +907,20 @@ TEST_F(TestNalUnits, OneIsolatedNaluLoss) { packet_.seqNum = 0; packet_.markerBit = false; FillPacket(0); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.isFirstPacket = false; packet_.completeNALU = kNaluComplete; packet_.seqNum += 2; packet_.markerBit = true; FillPacket(2); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); - EXPECT_EQ(0, session_.MakeDecodable()); + EXPECT_EQ(0U, session_.MakeDecodable()); EXPECT_EQ(2 * packet_buffer_size(), session_.SessionLength()); SCOPED_TRACE("Calling VerifyNalu"); EXPECT_TRUE(VerifyNalu(0, 1, 0)); @@ -1037,22 +934,18 @@ TEST_F(TestNalUnits, LossInMiddleOfNalu) { packet_.seqNum = 0; packet_.markerBit = false; FillPacket(0); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.isFirstPacket = false; packet_.completeNALU = kNaluEnd; packet_.seqNum += 2; packet_.markerBit = true; FillPacket(2); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); @@ -1066,22 +959,18 @@ TEST_F(TestNalUnits, StartAndEndOfLastNalUnitLost) { packet_.seqNum = 0; packet_.markerBit = false; FillPacket(0); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.isFirstPacket = false; packet_.completeNALU = kNaluIncomplete; packet_.seqNum += 2; packet_.markerBit = false; FillPacket(1); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); @@ -1096,35 +985,29 @@ TEST_F(TestNalUnits, ReorderWrapNoLoss) { packet_.seqNum += 1; packet_.markerBit = false; FillPacket(1); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.isFirstPacket = true; packet_.completeNALU = kNaluComplete; packet_.seqNum -= 1; packet_.markerBit = false; FillPacket(0); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.isFirstPacket = false; packet_.completeNALU = kNaluEnd; packet_.seqNum += 2; packet_.markerBit = true; FillPacket(2); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); - EXPECT_EQ(0, session_.MakeDecodable()); + EXPECT_EQ(0U, session_.MakeDecodable()); EXPECT_EQ(3 * packet_buffer_size(), session_.SessionLength()); SCOPED_TRACE("Calling VerifyNalu"); EXPECT_TRUE(VerifyNalu(0, 1, 0)); @@ -1136,25 +1019,21 @@ TEST_F(TestNalUnits, WrapLosses) { packet_.completeNALU = kNaluIncomplete; packet_.markerBit = false; FillPacket(1); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.isFirstPacket = false; packet_.completeNALU = kNaluEnd; packet_.seqNum += 2; packet_.markerBit = true; FillPacket(2); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); - EXPECT_EQ(0, session_.SessionLength()); + EXPECT_EQ(0U, session_.SessionLength()); } TEST_F(TestNalUnits, ReorderWrapLosses) { @@ -1165,25 +1044,21 @@ TEST_F(TestNalUnits, ReorderWrapLosses) { packet_.seqNum += 2; packet_.markerBit = true; FillPacket(2); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); packet_.seqNum -= 2; packet_.isFirstPacket = false; packet_.completeNALU = kNaluIncomplete; packet_.markerBit = false; FillPacket(1); - EXPECT_EQ(session_.InsertPacket(packet_, - frame_buffer_, - kNoErrors, - frame_data), - packet_buffer_size()); + EXPECT_EQ(packet_buffer_size(), + static_cast(session_.InsertPacket(packet_, frame_buffer_, + kNoErrors, frame_data))); EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); - EXPECT_EQ(0, session_.SessionLength()); + EXPECT_EQ(0U, session_.SessionLength()); } } // namespace webrtc diff --git a/webrtc/modules/video_coding/main/source/video_coding_impl.cc b/webrtc/modules/video_coding/main/source/video_coding_impl.cc index d566731bdb..2dfa99a747 100644 --- a/webrtc/modules/video_coding/main/source/video_coding_impl.cc +++ b/webrtc/modules/video_coding/main/source/video_coding_impl.cc @@ -301,7 +301,7 @@ class VideoCodingModuleImpl : public VideoCodingModule { } virtual int32_t IncomingPacket(const uint8_t* incomingPayload, - uint32_t payloadLength, + size_t payloadLength, const WebRtcRTPHeader& rtpInfo) OVERRIDE { return receiver_->IncomingPacket(incomingPayload, payloadLength, rtpInfo); } diff --git a/webrtc/modules/video_coding/main/source/video_coding_impl.h b/webrtc/modules/video_coding/main/source/video_coding_impl.h index ac7a1f4b0d..90186c730a 100644 --- a/webrtc/modules/video_coding/main/source/video_coding_impl.h +++ b/webrtc/modules/video_coding/main/source/video_coding_impl.h @@ -160,7 +160,7 @@ class VideoReceiver { VideoCodecType ReceiveCodec() const; int32_t IncomingPacket(const uint8_t* incomingPayload, - uint32_t payloadLength, + size_t payloadLength, const WebRtcRTPHeader& rtpInfo); int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs); int32_t SetRenderDelay(uint32_t timeMS); diff --git a/webrtc/modules/video_coding/main/source/video_receiver.cc b/webrtc/modules/video_coding/main/source/video_receiver.cc index a8de28bb72..f58d64f65f 100644 --- a/webrtc/modules/video_coding/main/source/video_receiver.cc +++ b/webrtc/modules/video_coding/main/source/video_receiver.cc @@ -631,7 +631,7 @@ VideoCodecType VideoReceiver::ReceiveCodec() const { // Incoming packet from network parsed and ready for decode, non blocking. int32_t VideoReceiver::IncomingPacket(const uint8_t* incomingPayload, - uint32_t payloadLength, + size_t payloadLength, const WebRtcRTPHeader& rtpInfo) { if (rtpInfo.frameType == kVideoFrameKey) { TRACE_EVENT1("webrtc", diff --git a/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc b/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc index 502dfa9dd2..ec5ba931c8 100644 --- a/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc +++ b/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc @@ -49,7 +49,6 @@ class TestVideoReceiver : public ::testing::Test { } void InsertAndVerifyPaddingFrame(const uint8_t* payload, - int length, WebRtcRTPHeader* header) { ASSERT_TRUE(header != NULL); for (int j = 0; j < 5; ++j) { @@ -63,7 +62,7 @@ class TestVideoReceiver : public ::testing::Test { } void InsertAndVerifyDecodableFrame(const uint8_t* payload, - int length, + size_t length, WebRtcRTPHeader* header) { ASSERT_TRUE(header != NULL); EXPECT_EQ(0, receiver_->IncomingPacket(payload, length, *header)); @@ -87,7 +86,7 @@ TEST_F(TestVideoReceiver, PaddingOnlyFrames) { EXPECT_EQ(0, receiver_->SetVideoProtection(kProtectionNack, true)); EXPECT_EQ( 0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_)); - const unsigned int kPaddingSize = 220; + const size_t kPaddingSize = 220; const uint8_t payload[kPaddingSize] = {0}; WebRtcRTPHeader header; memset(&header, 0, sizeof(header)); @@ -100,7 +99,7 @@ TEST_F(TestVideoReceiver, PaddingOnlyFrames) { header.type.Video.codec = kRtpVideoVp8; for (int i = 0; i < 10; ++i) { EXPECT_CALL(packet_request_callback_, ResendPackets(_, _)).Times(0); - InsertAndVerifyPaddingFrame(payload, 0, &header); + InsertAndVerifyPaddingFrame(payload, &header); clock_.AdvanceTimeMilliseconds(33); header.header.timestamp += 3000; } @@ -110,8 +109,8 @@ TEST_F(TestVideoReceiver, PaddingOnlyFramesWithLosses) { EXPECT_EQ(0, receiver_->SetVideoProtection(kProtectionNack, true)); EXPECT_EQ( 0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_)); - const unsigned int kFrameSize = 1200; - const unsigned int kPaddingSize = 220; + const size_t kFrameSize = 1200; + const size_t kPaddingSize = 220; const uint8_t payload[kFrameSize] = {0}; WebRtcRTPHeader header; memset(&header, 0, sizeof(header)); @@ -150,7 +149,7 @@ TEST_F(TestVideoReceiver, PaddingOnlyFramesWithLosses) { } else { EXPECT_CALL(packet_request_callback_, ResendPackets(_, _)).Times(0); } - InsertAndVerifyPaddingFrame(payload, 0, &header); + InsertAndVerifyPaddingFrame(payload, &header); } clock_.AdvanceTimeMilliseconds(33); header.header.timestamp += 3000; @@ -161,8 +160,8 @@ TEST_F(TestVideoReceiver, PaddingOnlyAndVideo) { EXPECT_EQ(0, receiver_->SetVideoProtection(kProtectionNack, true)); EXPECT_EQ( 0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_)); - const unsigned int kFrameSize = 1200; - const unsigned int kPaddingSize = 220; + const size_t kFrameSize = 1200; + const size_t kPaddingSize = 220; const uint8_t payload[kFrameSize] = {0}; WebRtcRTPHeader header; memset(&header, 0, sizeof(header)); @@ -195,7 +194,7 @@ TEST_F(TestVideoReceiver, PaddingOnlyAndVideo) { header.type.Video.isFirstPacket = false; header.header.markerBit = false; for (int j = 0; j < 2; ++j) { - // InsertAndVerifyPaddingFrame(payload, 0, &header); + // InsertAndVerifyPaddingFrame(payload, &header); clock_.AdvanceTimeMilliseconds(33); header.header.timestamp += 3000; } diff --git a/webrtc/modules/video_coding/main/source/video_sender_unittest.cc b/webrtc/modules/video_coding/main/source/video_sender_unittest.cc index 6bc8b80d8f..f689809b6c 100644 --- a/webrtc/modules/video_coding/main/source/video_sender_unittest.cc +++ b/webrtc/modules/video_coding/main/source/video_sender_unittest.cc @@ -91,7 +91,7 @@ class PacketizationCallback : public VCMPacketizationCallback { uint32_t timestamp, int64_t capture_time_ms, const uint8_t* payload_data, - uint32_t payload_size, + size_t payload_size, const RTPFragmentationHeader& fragmentation_header, const RTPVideoHeader* rtp_video_header) OVERRIDE { assert(rtp_video_header); @@ -127,10 +127,10 @@ class PacketizationCallback : public VCMPacketizationCallback { struct FrameData { FrameData() {} - FrameData(uint32_t payload_size, const RTPVideoHeader& rtp_video_header) + FrameData(size_t payload_size, const RTPVideoHeader& rtp_video_header) : payload_size(payload_size), rtp_video_header(rtp_video_header) {} - uint32_t payload_size; + size_t payload_size; RTPVideoHeader rtp_video_header; }; @@ -152,8 +152,8 @@ class PacketizationCallback : public VCMPacketizationCallback { return frames; } - int SumPayloadBytesWithinTemporalLayer(int temporal_layer) { - int payload_size = 0; + size_t SumPayloadBytesWithinTemporalLayer(int temporal_layer) { + size_t payload_size = 0; for (size_t i = 0; i < frame_data_.size(); ++i) { EXPECT_EQ(kRtpVideoVp8, frame_data_[i].rtp_video_header.codec); const uint8_t temporal_idx = diff --git a/webrtc/modules/video_coding/main/test/generic_codec_test.cc b/webrtc/modules/video_coding/main/test/generic_codec_test.cc index 7179c8023c..2848212c93 100644 --- a/webrtc/modules/video_coding/main/test/generic_codec_test.cc +++ b/webrtc/modules/video_coding/main/test/generic_codec_test.cc @@ -279,8 +279,9 @@ GenericCodecTest::Perform(CmdArgs& args) const float nBitrates = sizeof(bitRate)/sizeof(*bitRate); float _bitRate = 0; int _frameCnt = 0; - float totalBytesOneSec = 0;//, totalBytesTenSec; - float totalBytes, actualBitrate; + size_t totalBytesOneSec = 0;//, totalBytesTenSec; + size_t totalBytes; + float actualBitrate; VCMFrameCount frameCount; // testing frame type counters // start test NumberOfCodecs = _vcm->NumberOfCodecs(); @@ -478,7 +479,7 @@ GenericCodecTest::Print() } } -float +size_t GenericCodecTest::WaitForEncodedFrame() const { int64_t startTime = _clock->TimeInMilliseconds(); @@ -499,17 +500,17 @@ GenericCodecTest::IncrementDebugClock(float frameRate) } int -RTPSendCallback_SizeTest::SendPacket(int channel, const void *data, int len) +RTPSendCallback_SizeTest::SendPacket(int channel, const void *data, size_t len) { _nPackets++; _payloadSizeSum += len; // Make sure no payloads (len - header size) are larger than maxPayloadSize - TEST(len > 0 && static_cast(len - 12) <= _maxPayloadSize); + TEST(len > 0 && len - 12 <= _maxPayloadSize); return 0; } void -RTPSendCallback_SizeTest::SetMaxPayloadSize(uint32_t maxPayloadSize) +RTPSendCallback_SizeTest::SetMaxPayloadSize(size_t maxPayloadSize) { _maxPayloadSize = maxPayloadSize; } @@ -533,12 +534,12 @@ RTPSendCallback_SizeTest::AveragePayloadSize() const int32_t VCMEncComplete_KeyReqTest::SendData( - const FrameType frameType, - const uint8_t payloadType, - const uint32_t timeStamp, + FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& /*fragmentationHeader*/, const webrtc::RTPVideoHeader* /*videoHdr*/) { diff --git a/webrtc/modules/video_coding/main/test/generic_codec_test.h b/webrtc/modules/video_coding/main/test/generic_codec_test.h index 841662aadc..9a450de785 100644 --- a/webrtc/modules/video_coding/main/test/generic_codec_test.h +++ b/webrtc/modules/video_coding/main/test/generic_codec_test.h @@ -41,7 +41,7 @@ public: ~GenericCodecTest(); static int RunTest(CmdArgs& args); int32_t Perform(CmdArgs& args); - float WaitForEncodedFrame() const; + size_t WaitForEncodedFrame() const; private: void Setup(CmdArgs& args); @@ -75,14 +75,18 @@ class RTPSendCallback_SizeTest : public webrtc::Transport public: // constructor input: (receive side) rtp module to send encoded data to RTPSendCallback_SizeTest() : _maxPayloadSize(0), _payloadSizeSum(0), _nPackets(0) {} - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE; - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE {return 0;} - void SetMaxPayloadSize(uint32_t maxPayloadSize); + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE; + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE { + return 0; + } + void SetMaxPayloadSize(size_t maxPayloadSize); void Reset(); float AveragePayloadSize() const; private: - uint32_t _maxPayloadSize; - uint32_t _payloadSizeSum; + size_t _maxPayloadSize; + size_t _payloadSizeSum; uint32_t _nPackets; }; @@ -91,12 +95,12 @@ class VCMEncComplete_KeyReqTest : public webrtc::VCMPacketizationCallback public: VCMEncComplete_KeyReqTest(webrtc::VideoCodingModule &vcm) : _vcm(vcm), _seqNo(0), _timeStamp(0) {} virtual int32_t SendData( - const webrtc::FrameType frameType, - const uint8_t payloadType, + webrtc::FrameType frameType, + uint8_t payloadType, uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + size_t payloadSize, const webrtc::RTPFragmentationHeader& fragmentationHeader, const webrtc::RTPVideoHeader* videoHdr) OVERRIDE; private: diff --git a/webrtc/modules/video_coding/main/test/media_opt_test.cc b/webrtc/modules/video_coding/main/test/media_opt_test.cc index a8b8f19cdb..f3b1cf05a0 100644 --- a/webrtc/modules/video_coding/main/test/media_opt_test.cc +++ b/webrtc/modules/video_coding/main/test/media_opt_test.cc @@ -308,7 +308,7 @@ MediaOptTest::Perform() _vcm->RegisterReceiveCallback(&receiveCallback); _frameCnt = 0; - _sumEncBytes = 0.0; + _sumEncBytes = 0; _numFramesDropped = 0; int half_width = (_width + 1) / 2; int half_height = (_height + 1) / 2; @@ -338,7 +338,7 @@ MediaOptTest::Perform() printf ("Decode error in frame # %d",_frameCnt); } - float encBytes = encodeCompleteCallback->EncodedBytes(); + size_t encBytes = encodeCompleteCallback->EncodedBytes(); if (encBytes == 0) { _numFramesDropped += 1; diff --git a/webrtc/modules/video_coding/main/test/media_opt_test.h b/webrtc/modules/video_coding/main/test/media_opt_test.h index 5a95276abc..57398ebd13 100644 --- a/webrtc/modules/video_coding/main/test/media_opt_test.h +++ b/webrtc/modules/video_coding/main/test/media_opt_test.h @@ -80,7 +80,7 @@ private: double _lossRate; uint32_t _renderDelayMs; int32_t _frameCnt; - float _sumEncBytes; + size_t _sumEncBytes; int32_t _numFramesDropped; std::string _codecName; webrtc::VideoCodecType _sendCodecType; diff --git a/webrtc/modules/video_coding/main/test/mt_test_common.cc b/webrtc/modules/video_coding/main/test/mt_test_common.cc index 779ef7a78a..dec649f475 100644 --- a/webrtc/modules/video_coding/main/test/mt_test_common.cc +++ b/webrtc/modules/video_coding/main/test/mt_test_common.cc @@ -30,7 +30,7 @@ TransportCallback::~TransportCallback() } int -TransportCallback::SendPacket(int channel, const void *data, int len) +TransportCallback::SendPacket(int channel, const void *data, size_t len) { _sendCount++; _totalSentLength += len; diff --git a/webrtc/modules/video_coding/main/test/mt_test_common.h b/webrtc/modules/video_coding/main/test/mt_test_common.h index be6d9ea64f..78d73e21af 100644 --- a/webrtc/modules/video_coding/main/test/mt_test_common.h +++ b/webrtc/modules/video_coding/main/test/mt_test_common.h @@ -52,7 +52,7 @@ class TransportCallback:public RTPSendCompleteCallback // Add packets to list // Incorporate network conditions - delay and packet loss // Actual transmission will occur on a separate thread - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE; + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE; // Send to the receiver packets which are ready to be submitted int TransportPackets(); }; diff --git a/webrtc/modules/video_coding/main/test/normal_test.cc b/webrtc/modules/video_coding/main/test/normal_test.cc index 815c3acc8d..4ab97a1a64 100644 --- a/webrtc/modules/video_coding/main/test/normal_test.cc +++ b/webrtc/modules/video_coding/main/test/normal_test.cc @@ -71,12 +71,12 @@ void VCMNTEncodeCompleteCallback::RegisterTransportCallback( int32_t VCMNTEncodeCompleteCallback::SendData( - const FrameType frameType, - const uint8_t payloadType, - const uint32_t timeStamp, + FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& /*fragmentationHeader*/, const webrtc::RTPVideoHeader* videoHdr) @@ -131,7 +131,7 @@ VCMNTEncodeCompleteCallback::RegisterReceiverVCM(VideoCodingModule *vcm) _VCMReceiver = vcm; return; } - int32_t + size_t VCMNTEncodeCompleteCallback::EncodedBytes() { return _encodedBytes; @@ -144,13 +144,13 @@ VCMNTEncodeCompleteCallback::SkipCnt() } // Decoded Frame Callback Implementation -VCMNTDecodeCompleCallback::~VCMNTDecodeCompleCallback() +VCMNTDecodeCompleteCallback::~VCMNTDecodeCompleteCallback() { if (_decodedFile) fclose(_decodedFile); } int32_t -VCMNTDecodeCompleCallback::FrameToRender(webrtc::I420VideoFrame& videoFrame) +VCMNTDecodeCompleteCallback::FrameToRender(webrtc::I420VideoFrame& videoFrame) { if (videoFrame.width() != _currentWidth || videoFrame.height() != _currentHeight) @@ -167,13 +167,13 @@ VCMNTDecodeCompleCallback::FrameToRender(webrtc::I420VideoFrame& videoFrame) if (PrintI420VideoFrame(videoFrame, _decodedFile) < 0) { return -1; } - _decodedBytes+= webrtc::CalcBufferSize(webrtc::kI420, - videoFrame.width(), videoFrame.height()); + _decodedBytes += webrtc::CalcBufferSize(webrtc::kI420, videoFrame.width(), + videoFrame.height()); return VCM_OK; } - int32_t -VCMNTDecodeCompleCallback::DecodedBytes() + size_t +VCMNTDecodeCompleteCallback::DecodedBytes() { return _decodedBytes; } @@ -260,7 +260,7 @@ NormalTest::Perform(const CmdArgs& args) // register a decoder (same codec for decoder and encoder ) TEST(_vcm->RegisterReceiveCodec(&_sendCodec, 1) == VCM_OK); /* Callback Settings */ - VCMNTDecodeCompleCallback _decodeCallback(_outname); + VCMNTDecodeCompleteCallback _decodeCallback(_outname); _vcm->RegisterReceiveCallback(&_decodeCallback); VCMNTEncodeCompleteCallback _encodeCompleteCallback(_encodedFile, *this); _vcm->RegisterTransportCallback(&_encodeCompleteCallback); diff --git a/webrtc/modules/video_coding/main/test/normal_test.h b/webrtc/modules/video_coding/main/test/normal_test.h index 63e66b323d..4d33f3cf29 100644 --- a/webrtc/modules/video_coding/main/test/normal_test.h +++ b/webrtc/modules/video_coding/main/test/normal_test.h @@ -33,12 +33,12 @@ class VCMNTEncodeCompleteCallback : public webrtc::VCMPacketizationCallback // process encoded data received from the encoder, // pass stream to the VCMReceiver module virtual int32_t SendData( - const webrtc::FrameType frameType, - const uint8_t payloadType, - const uint32_t timeStamp, + webrtc::FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + size_t payloadSize, const webrtc::RTPFragmentationHeader& fragmentationHeader, const webrtc::RTPVideoHeader* videoHdr) OVERRIDE; @@ -46,15 +46,15 @@ class VCMNTEncodeCompleteCallback : public webrtc::VCMPacketizationCallback // Currently - encode and decode with the same vcm module. void RegisterReceiverVCM(webrtc::VideoCodingModule *vcm); // Return sum of encoded data (all frames in the sequence) - int32_t EncodedBytes(); + size_t EncodedBytes(); // return number of encoder-skipped frames - uint32_t SkipCnt();; + uint32_t SkipCnt(); // conversion function for payload type (needed for the callback function) // RTPVideoVideoCodecTypes ConvertPayloadType(uint8_t payloadType); private: FILE* _encodedFile; - uint32_t _encodedBytes; + size_t _encodedBytes; uint32_t _skipCnt; webrtc::VideoCodingModule* _VCMReceiver; webrtc::FrameType _frameType; @@ -62,29 +62,29 @@ class VCMNTEncodeCompleteCallback : public webrtc::VCMPacketizationCallback NormalTest& _test; }; // end of VCMEncodeCompleteCallback -class VCMNTDecodeCompleCallback: public webrtc::VCMReceiveCallback +class VCMNTDecodeCompleteCallback: public webrtc::VCMReceiveCallback { public: - VCMNTDecodeCompleCallback(std::string outname): // or should it get a name? - _decodedFile(NULL), - _outname(outname), - _decodedBytes(0), - _currentWidth(0), - _currentHeight(0) {} - virtual ~VCMNTDecodeCompleCallback(); + VCMNTDecodeCompleteCallback(std::string outname) // or should it get a name? + : _decodedFile(NULL), + _outname(outname), + _decodedBytes(0), + _currentWidth(0), + _currentHeight(0) {} + virtual ~VCMNTDecodeCompleteCallback(); void SetUserReceiveCallback(webrtc::VCMReceiveCallback* receiveCallback); // will write decoded frame into file virtual int32_t FrameToRender(webrtc::I420VideoFrame& videoFrame) OVERRIDE; - int32_t DecodedBytes(); + size_t DecodedBytes(); private: FILE* _decodedFile; std::string _outname; - int _decodedBytes; + size_t _decodedBytes; int _currentWidth; int _currentHeight; -}; // end of VCMDecodeCompleCallback class +}; // end of VCMNTDecodeCompleteCallback class class NormalTest { @@ -119,7 +119,7 @@ protected: std::string _inname; std::string _outname; std::string _encodedName; - int32_t _sumEncBytes; + size_t _sumEncBytes; FILE* _sourceFile; FILE* _decodedFile; FILE* _encodedFile; diff --git a/webrtc/modules/video_coding/main/test/quality_modes_test.cc b/webrtc/modules/video_coding/main/test/quality_modes_test.cc index d488fa92bf..2993e53aea 100644 --- a/webrtc/modules/video_coding/main/test/quality_modes_test.cc +++ b/webrtc/modules/video_coding/main/test/quality_modes_test.cc @@ -212,7 +212,7 @@ QualityModesTest::Perform(const CmdArgs& args) // register a decoder (same codec for decoder and encoder ) TEST(_vcm->RegisterReceiveCodec(&codec, 2) == VCM_OK); /* Callback Settings */ - VCMQMDecodeCompleCallback _decodeCallback( + VCMQMDecodeCompleteCallback _decodeCallback( _decodedFile, _nativeFrameRate, feature_table_name_); _vcm->RegisterReceiveCallback(&_decodeCallback); VCMNTEncodeCompleteCallback _encodeCompleteCallback(_encodedFile, *this); @@ -449,7 +449,7 @@ QMTestVideoSettingsCallback::SetVideoQMSettings(const uint32_t frameRate, } // Decoded Frame Callback Implementation -VCMQMDecodeCompleCallback::VCMQMDecodeCompleCallback( +VCMQMDecodeCompleteCallback::VCMQMDecodeCompleteCallback( FILE* decodedFile, int frame_rate, std::string feature_table_name): _decodedFile(decodedFile), _decodedBytes(0), @@ -468,7 +468,7 @@ feature_table_name_(feature_table_name) // } -VCMQMDecodeCompleCallback::~VCMQMDecodeCompleCallback() +VCMQMDecodeCompleteCallback::~VCMQMDecodeCompleteCallback() { // if (_interpolator != NULL) // { @@ -483,7 +483,7 @@ VCMQMDecodeCompleCallback::~VCMQMDecodeCompleCallback() } int32_t -VCMQMDecodeCompleCallback::FrameToRender(I420VideoFrame& videoFrame) +VCMQMDecodeCompleteCallback::FrameToRender(I420VideoFrame& videoFrame) { ++frames_cnt_since_drop_; @@ -537,19 +537,19 @@ VCMQMDecodeCompleCallback::FrameToRender(I420VideoFrame& videoFrame) return VCM_OK; } -int32_t VCMQMDecodeCompleCallback::DecodedBytes() +size_t VCMQMDecodeCompleteCallback::DecodedBytes() { return _decodedBytes; } -void VCMQMDecodeCompleCallback::SetOriginalFrameDimensions(int32_t width, - int32_t height) +void VCMQMDecodeCompleteCallback::SetOriginalFrameDimensions(int32_t width, + int32_t height) { _origWidth = width; _origHeight = height; } -int32_t VCMQMDecodeCompleCallback::buildInterpolator() +int32_t VCMQMDecodeCompleteCallback::buildInterpolator() { uint32_t decFrameLength = _origWidth*_origHeight*3 >> 1; if (_decBuffer != NULL) @@ -569,7 +569,7 @@ int32_t VCMQMDecodeCompleCallback::buildInterpolator() // frame (or several consecutive frames from the end) must have been dropped. If // this is the case, the last frame is repeated so that there are as many // frames rendered as there are number of frames encoded. -void VCMQMDecodeCompleCallback::WriteEnd(int input_frame_count) +void VCMQMDecodeCompleteCallback::WriteEnd(int input_frame_count) { int num_missing_frames = input_frame_count - _frameCnt; diff --git a/webrtc/modules/video_coding/main/test/quality_modes_test.h b/webrtc/modules/video_coding/main/test/quality_modes_test.h index 38da78d942..26c8229347 100644 --- a/webrtc/modules/video_coding/main/test/quality_modes_test.h +++ b/webrtc/modules/video_coding/main/test/quality_modes_test.h @@ -51,18 +51,18 @@ private: }; // end of QualityModesTest class -class VCMQMDecodeCompleCallback: public webrtc::VCMReceiveCallback +class VCMQMDecodeCompleteCallback: public webrtc::VCMReceiveCallback { public: - VCMQMDecodeCompleCallback( + VCMQMDecodeCompleteCallback( FILE* decodedFile, int frame_rate, std::string feature_table_name); - virtual ~VCMQMDecodeCompleCallback(); + virtual ~VCMQMDecodeCompleteCallback(); void SetUserReceiveCallback(webrtc::VCMReceiveCallback* receiveCallback); // will write decoded frame into file int32_t FrameToRender(webrtc::I420VideoFrame& videoFrame); - int32_t DecodedBytes(); + size_t DecodedBytes(); void SetOriginalFrameDimensions(int32_t width, int32_t height); int32_t buildInterpolator(); // Check if last frame is dropped, if so, repeat the last rendered frame. @@ -70,7 +70,7 @@ public: private: FILE* _decodedFile; - uint32_t _decodedBytes; + size_t _decodedBytes; // QualityModesTest& _test; int _origWidth; int _origHeight; @@ -86,7 +86,7 @@ private: -}; // end of VCMQMDecodeCompleCallback class +}; // end of VCMQMDecodeCompleteCallback class class QMTestVideoSettingsCallback : public webrtc::VCMQMSettingsCallback { diff --git a/webrtc/modules/video_coding/main/test/receiver_tests.h b/webrtc/modules/video_coding/main/test/receiver_tests.h index 91b7f8e54b..de1eb638c6 100644 --- a/webrtc/modules/video_coding/main/test/receiver_tests.h +++ b/webrtc/modules/video_coding/main/test/receiver_tests.h @@ -29,7 +29,7 @@ class RtpDataCallback : public webrtc::NullRtpData { virtual int32_t OnReceivedPayloadData( const uint8_t* payload_data, - const uint16_t payload_size, + const size_t payload_size, const webrtc::WebRtcRTPHeader* rtp_header) OVERRIDE { return vcm_->IncomingPacket(payload_data, payload_size, *rtp_header); } diff --git a/webrtc/modules/video_coding/main/test/rtp_player.cc b/webrtc/modules/video_coding/main/test/rtp_player.cc index 1aea7e03f1..81295abc09 100644 --- a/webrtc/modules/video_coding/main/test/rtp_player.cc +++ b/webrtc/modules/video_coding/main/test/rtp_player.cc @@ -41,7 +41,7 @@ enum { class RawRtpPacket { public: - RawRtpPacket(const uint8_t* data, uint32_t length, uint32_t ssrc, + RawRtpPacket(const uint8_t* data, size_t length, uint32_t ssrc, uint16_t seq_num) : data_(new uint8_t[length]), length_(length), @@ -53,7 +53,7 @@ class RawRtpPacket { } const uint8_t* data() const { return data_.get(); } - uint32_t length() const { return length_; } + size_t length() const { return length_; } int64_t resend_time_ms() const { return resend_time_ms_; } void set_resend_time_ms(int64_t timeMs) { resend_time_ms_ = timeMs; } uint32_t ssrc() const { return ssrc_; } @@ -61,7 +61,7 @@ class RawRtpPacket { private: scoped_ptr data_; - uint32_t length_; + size_t length_; int64_t resend_time_ms_; uint32_t ssrc_; uint16_t seq_num_; @@ -251,7 +251,7 @@ class SsrcHandlers { return 0; } - void IncomingPacket(const uint8_t* data, uint32_t length) { + void IncomingPacket(const uint8_t* data, size_t length) { for (HandlerMapIt it = handlers_.begin(); it != handlers_.end(); ++it) { if (!it->second->rtp_header_parser_->IsRtcp(data, length)) { RTPHeader header; @@ -375,14 +375,10 @@ class RtpPlayerImpl : public RtpPlayerInterface { if (reordering_ && reorder_buffer_.get() == NULL) { reorder_buffer_.reset( - new RawRtpPacket(next_packet_.data, - static_cast(next_packet_.length), - 0, - 0)); + new RawRtpPacket(next_packet_.data, next_packet_.length, 0, 0)); return 0; } - int ret = SendPacket(next_packet_.data, - static_cast(next_packet_.length)); + int ret = SendPacket(next_packet_.data, next_packet_.length); if (reorder_buffer_.get()) { SendPacket(reorder_buffer_->data(), reorder_buffer_->length()); reorder_buffer_.reset(NULL); @@ -421,7 +417,7 @@ class RtpPlayerImpl : public RtpPlayerInterface { } private: - int SendPacket(const uint8_t* data, uint32_t length) { + int SendPacket(const uint8_t* data, size_t length) { assert(data); assert(length > 0); diff --git a/webrtc/modules/video_coding/main/test/test_callbacks.cc b/webrtc/modules/video_coding/main/test/test_callbacks.cc index d68f9949ab..35aaae14c9 100644 --- a/webrtc/modules/video_coding/main/test/test_callbacks.cc +++ b/webrtc/modules/video_coding/main/test/test_callbacks.cc @@ -57,7 +57,7 @@ VCMEncodeCompleteCallback::SendData( const uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + const size_t payloadSize, const RTPFragmentationHeader& fragmentationHeader, const RTPVideoHeader* videoHdr) { @@ -106,7 +106,7 @@ VCMEncodeCompleteCallback::SendData( return ret; } -float +size_t VCMEncodeCompleteCallback::EncodedBytes() { return _encodedBytes; @@ -147,12 +147,12 @@ VCMEncodeCompleteCallback::ResetByteCount() int32_t VCMRTPEncodeCompleteCallback::SendData( - const FrameType frameType, - const uint8_t payloadType, - const uint32_t timeStamp, + FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& fragmentationHeader, const RTPVideoHeader* videoHdr) { @@ -169,11 +169,11 @@ VCMRTPEncodeCompleteCallback::SendData( videoHdr); } -float +size_t VCMRTPEncodeCompleteCallback::EncodedBytes() { // only good for one call - after which will reset value; - float tmp = _encodedBytes; + size_t tmp = _encodedBytes; _encodedBytes = 0; return tmp; } @@ -197,12 +197,12 @@ VCMDecodeCompleteCallback::FrameToRender(I420VideoFrame& videoFrame) if (PrintI420VideoFrame(videoFrame, _decodedFile) < 0) { return -1; } - _decodedBytes+= CalcBufferSize(kI420, videoFrame.width(), - videoFrame.height()); + _decodedBytes += CalcBufferSize(kI420, videoFrame.width(), + videoFrame.height()); return VCM_OK; } -int32_t +size_t VCMDecodeCompleteCallback::DecodedBytes() { return _decodedBytes; @@ -248,7 +248,7 @@ RTPSendCompleteCallback::~RTPSendCompleteCallback() } int -RTPSendCompleteCallback::SendPacket(int channel, const void *data, int len) +RTPSendCompleteCallback::SendPacket(int channel, const void *data, size_t len) { _sendCount++; _totalSentLength += len; @@ -319,11 +319,13 @@ RTPSendCompleteCallback::SendPacket(int channel, const void *data, int len) delete packet; packet = NULL; } - return len; // OK + return static_cast(len); // OK } int -RTPSendCompleteCallback::SendRTCPPacket(int channel, const void *data, int len) +RTPSendCompleteCallback::SendRTCPPacket(int channel, + const void *data, + size_t len) { // Incorporate network conditions return SendPacket(channel, data, len); diff --git a/webrtc/modules/video_coding/main/test/test_callbacks.h b/webrtc/modules/video_coding/main/test/test_callbacks.h index 608d185e3f..fb08e9cecf 100644 --- a/webrtc/modules/video_coding/main/test/test_callbacks.h +++ b/webrtc/modules/video_coding/main/test/test_callbacks.h @@ -44,12 +44,12 @@ public: void RegisterTransportCallback(VCMPacketizationCallback* transport); // Process encoded data received from the encoder, pass stream to the // VCMReceiver module - virtual int32_t SendData(const FrameType frameType, - const uint8_t payloadType, - const uint32_t timeStamp, + virtual int32_t SendData(FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& fragmentationHeader, const RTPVideoHeader* videoHdr) OVERRIDE; // Register exisitng VCM. Currently - encode and decode under same module. @@ -57,7 +57,7 @@ public: // Return size of last encoded frame data (all frames in the sequence) // Good for only one call - after which will reset value // (to allow detection of frame drop) - float EncodedBytes(); + size_t EncodedBytes(); // Return encode complete (true/false) bool EncodeComplete(); // Inform callback of codec used @@ -77,7 +77,7 @@ public: private: FILE* _encodedFile; - float _encodedBytes; + size_t _encodedBytes; VideoCodingModule* _VCMReceiver; FrameType _frameType; uint16_t _seqNo; @@ -101,17 +101,17 @@ public: virtual ~VCMRTPEncodeCompleteCallback() {} // Process encoded data received from the encoder, pass stream to the // RTP module - virtual int32_t SendData(const FrameType frameType, - const uint8_t payloadType, - const uint32_t timeStamp, + virtual int32_t SendData(FrameType frameType, + uint8_t payloadType, + uint32_t timeStamp, int64_t capture_time_ms, const uint8_t* payloadData, - const uint32_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader& fragmentationHeader, const RTPVideoHeader* videoHdr) OVERRIDE; // Return size of last encoded frame. Value good for one call // (resets to zero after call to inform test of frame drop) - float EncodedBytes(); + size_t EncodedBytes(); // Return encode complete (true/false) bool EncodeComplete(); // Inform callback of codec used @@ -126,7 +126,7 @@ public: } private: - float _encodedBytes; + size_t _encodedBytes; FrameType _frameType; bool _encodeComplete; RtpRtcp* _RTPModule; @@ -145,10 +145,10 @@ public: virtual ~VCMDecodeCompleteCallback() {} // Write decoded frame into file virtual int32_t FrameToRender(webrtc::I420VideoFrame& videoFrame) OVERRIDE; - int32_t DecodedBytes(); + size_t DecodedBytes(); private: - FILE* _decodedFile; - uint32_t _decodedBytes; + FILE* _decodedFile; + size_t _decodedBytes; }; // end of VCMDecodeCompleCallback class // Transport callback @@ -165,9 +165,11 @@ public: void SetRtpModule(RtpRtcp* rtp_module) { _rtp = rtp_module; } // Send Packet to receive side RTP module - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE; + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE; // Send RTCP Packet to receive side RTP module - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE; + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE; // Set percentage of channel loss in the network void SetLossPct(double lossPct); // Set average size of burst loss @@ -181,7 +183,7 @@ public: // Return send count int SendCount() {return _sendCount; } // Return accumulated length in bytes of transmitted packets - uint32_t TotalSentLength() {return _totalSentLength;} + size_t TotalSentLength() {return _totalSentLength;} protected: // Randomly decide whether to drop packets, based on the channel model bool PacketLoss(); @@ -198,7 +200,7 @@ protected: uint32_t _networkDelayMs; double _jitterVar; bool _prevLossState; - uint32_t _totalSentLength; + size_t _totalSentLength; std::list _rtpPackets; RtpDump* _rtpDump; }; diff --git a/webrtc/modules/video_coding/main/test/test_util.h b/webrtc/modules/video_coding/main/test/test_util.h index 9f8b5a9551..b1c156d6db 100644 --- a/webrtc/modules/video_coding/main/test/test_util.h +++ b/webrtc/modules/video_coding/main/test/test_util.h @@ -51,7 +51,7 @@ double NormalDist(double mean, double stdDev); struct RtpPacket { uint8_t data[1650]; // max packet size - int32_t length; + size_t length; int64_t receiveTime; }; diff --git a/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.cc b/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.cc index aa636a0816..e0dd5098f7 100644 --- a/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.cc +++ b/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.cc @@ -53,13 +53,13 @@ class VcmPayloadSinkFactory::VcmPayloadSink // PayloadSinkInterface virtual int32_t OnReceivedPayloadData( const uint8_t* payload_data, - const uint16_t payload_size, + const size_t payload_size, const WebRtcRTPHeader* rtp_header) OVERRIDE { return vcm_->IncomingPacket(payload_data, payload_size, *rtp_header); } virtual bool OnRecoveredPacket(const uint8_t* packet, - int packet_length) OVERRIDE { + size_t packet_length) OVERRIDE { // We currently don't handle FEC. return true; } diff --git a/webrtc/modules/video_coding/main/test/video_source.cc b/webrtc/modules/video_coding/main/test/video_source.cc index 65ee6a393c..0c02e29f8e 100644 --- a/webrtc/modules/video_coding/main/test/video_source.cc +++ b/webrtc/modules/video_coding/main/test/video_source.cc @@ -55,7 +55,7 @@ _frameRate(frameRate) assert(frameRate > 0); } -int32_t +size_t VideoSource::GetFrameLength() const { return webrtc::CalcBufferSize(_type, _width, _height); diff --git a/webrtc/modules/video_coding/main/test/video_source.h b/webrtc/modules/video_coding/main/test/video_source.h index 98cc3fe025..05deb4a39b 100644 --- a/webrtc/modules/video_coding/main/test/video_source.h +++ b/webrtc/modules/video_coding/main/test/video_source.h @@ -69,7 +69,7 @@ public: // Returns the filename with the path (including the leading slash) removed. std::string GetName() const; - int32_t GetFrameLength() const; + size_t GetFrameLength() const; private: std::string _fileName; diff --git a/webrtc/modules/video_coding/utility/frame_dropper.cc b/webrtc/modules/video_coding/utility/frame_dropper.cc index 54c8cb8a39..a684af7a39 100644 --- a/webrtc/modules/video_coding/utility/frame_dropper.cc +++ b/webrtc/modules/video_coding/utility/frame_dropper.cc @@ -75,7 +75,7 @@ FrameDropper::Enable(bool enable) } void -FrameDropper::Fill(uint32_t frameSizeBytes, bool deltaFrame) +FrameDropper::Fill(size_t frameSizeBytes, bool deltaFrame) { if (!_enabled) { diff --git a/webrtc/modules/video_coding/utility/include/frame_dropper.h b/webrtc/modules/video_coding/utility/include/frame_dropper.h index 8eebd7842e..2b78a7264f 100644 --- a/webrtc/modules/video_coding/utility/include/frame_dropper.h +++ b/webrtc/modules/video_coding/utility/include/frame_dropper.h @@ -11,6 +11,8 @@ #ifndef WEBRTC_MODULES_VIDEO_CODING_UTILITY_INCLUDE_FRAME_DROPPER_H_ #define WEBRTC_MODULES_VIDEO_CODING_UTILITY_INCLUDE_FRAME_DROPPER_H_ +#include + #include "webrtc/base/exp_filter.h" #include "webrtc/typedefs.h" @@ -49,7 +51,7 @@ public: // returned from the encoder. // - deltaFrame : True if the encoder returned // a key frame. - virtual void Fill(uint32_t frameSizeBytes, bool deltaFrame); + virtual void Fill(size_t frameSizeBytes, bool deltaFrame); virtual void Leak(uint32_t inputFrameRate); diff --git a/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.h b/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.h index 6daf9c2fd9..37e2c02b94 100644 --- a/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.h +++ b/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.h @@ -39,7 +39,7 @@ class VideoProcessingModuleTest : public ::testing::Test { const int height_; const int size_y_; const int size_uv_; - const unsigned int frame_length_; + const size_t frame_length_; }; } // namespace webrtc diff --git a/webrtc/modules/video_render/mac/video_render_agl.cc b/webrtc/modules/video_render/mac/video_render_agl.cc index 4a66064678..edaae973b4 100644 --- a/webrtc/modules/video_render/mac/video_render_agl.cc +++ b/webrtc/modules/video_render/mac/video_render_agl.cc @@ -49,7 +49,7 @@ VideoChannelAGL::VideoChannelAGL(AGLContext& aglContext, int iId, VideoRenderAGL _oldStretchedWidth( 0), _buffer( 0), _bufferSize( 0), - _incommingBufferSize(0), + _incomingBufferSize(0), _bufferIsUpdated( false), _sizeInitialized( false), _numberOfStreams( 0), @@ -138,7 +138,7 @@ int VideoChannelAGL::FrameSizeChange(int width, int height, int numberOfStreams) _bufferSize = 0; } - _incommingBufferSize = CalcBufferSize(kI420, _width, _height); + _incomingBufferSize = CalcBufferSize(kI420, _width, _height); _bufferSize = CalcBufferSize(kARGB, _width, _height);//_width * _height * bytesPerPixel; _buffer = new unsigned char [_bufferSize]; memset(_buffer, 0, _bufferSize * sizeof(unsigned char)); @@ -228,8 +228,8 @@ int VideoChannelAGL::DeliverFrame(const I420VideoFrame& videoFrame) { return 0; } - int length = CalcBufferSize(kI420, videoFrame.width(), videoFrame.height()); - if (length != _incommingBufferSize) { + if (CalcBufferSize(kI420, videoFrame.width(), videoFrame.height()) != + _incomingBufferSize) { _owner->UnlockAGLCntx(); return -1; } diff --git a/webrtc/modules/video_render/mac/video_render_agl.h b/webrtc/modules/video_render/mac/video_render_agl.h index 9226e0aeac..5336705a8d 100644 --- a/webrtc/modules/video_render/mac/video_render_agl.h +++ b/webrtc/modules/video_render/mac/video_render_agl.h @@ -72,8 +72,8 @@ class VideoChannelAGL : public VideoRenderCallback { int _oldStretchedHeight; int _oldStretchedWidth; unsigned char* _buffer; - int _bufferSize; - int _incommingBufferSize; + size_t _bufferSize; + size_t _incomingBufferSize; bool _bufferIsUpdated; bool _sizeInitialized; int _numberOfStreams; diff --git a/webrtc/modules/video_render/mac/video_render_nsopengl.h b/webrtc/modules/video_render/mac/video_render_nsopengl.h index 806c0d6ccd..c157eced1a 100644 --- a/webrtc/modules/video_render/mac/video_render_nsopengl.h +++ b/webrtc/modules/video_render/mac/video_render_nsopengl.h @@ -46,7 +46,8 @@ public: // A new frame is delivered virtual int DeliverFrame(const I420VideoFrame& videoFrame); - // Called when the incomming frame size and/or number of streams in mix changes + // Called when the incoming frame size and/or number of streams in mix + // changes. virtual int FrameSizeChange(int width, int height, int numberOfStreams); virtual int UpdateSize(int width, int height); @@ -89,8 +90,8 @@ private: int _oldStretchedHeight; int _oldStretchedWidth; unsigned char* _buffer; - int _bufferSize; - int _incommingBufferSize; + size_t _bufferSize; + size_t _incomingBufferSize; bool _bufferIsUpdated; int _numberOfStreams; GLenum _pixelFormat; diff --git a/webrtc/modules/video_render/mac/video_render_nsopengl.mm b/webrtc/modules/video_render/mac/video_render_nsopengl.mm index 933ee3b480..39ed95aa19 100644 --- a/webrtc/modules/video_render/mac/video_render_nsopengl.mm +++ b/webrtc/modules/video_render/mac/video_render_nsopengl.mm @@ -36,7 +36,7 @@ _oldStretchedHeight( 0), _oldStretchedWidth( 0), _buffer( 0), _bufferSize( 0), -_incommingBufferSize( 0), +_incomingBufferSize( 0), _bufferIsUpdated( false), _numberOfStreams( 0), _pixelFormat( GL_RGBA), @@ -150,7 +150,7 @@ int VideoChannelNSOpenGL::FrameSizeChange(int width, int height, int numberOfStr _bufferSize = 0; } - _incommingBufferSize = CalcBufferSize(kI420, _width, _height); + _incomingBufferSize = CalcBufferSize(kI420, _width, _height); _bufferSize = CalcBufferSize(kARGB, _width, _height); _buffer = new unsigned char [_bufferSize]; memset(_buffer, 0, _bufferSize * sizeof(unsigned char)); @@ -215,8 +215,8 @@ int VideoChannelNSOpenGL::DeliverFrame(const I420VideoFrame& videoFrame) { return 0; } - int length = CalcBufferSize(kI420, videoFrame.width(), videoFrame.height()); - if (length != _incommingBufferSize) { + if (CalcBufferSize(kI420, videoFrame.width(), videoFrame.height()) != + _incomingBufferSize) { _owner->UnlockAGLCntx(); return -1; } diff --git a/webrtc/system_wrappers/interface/file_wrapper.h b/webrtc/system_wrappers/interface/file_wrapper.h index 68dc00501b..a61863433d 100644 --- a/webrtc/system_wrappers/interface/file_wrapper.h +++ b/webrtc/system_wrappers/interface/file_wrapper.h @@ -69,12 +69,12 @@ class FileWrapper : public InStream, public OutStream { // Inherited from Instream. // Reads |length| bytes from file to |buf|. Returns the number of bytes read // or -1 on error. - virtual int Read(void* buf, int length) = 0; + virtual int Read(void* buf, size_t length) = 0; // Inherited from OutStream. // Writes |length| bytes from |buf| to file. The actual writing may happen // some time later. Call Flush() to force a write. - virtual bool Write(const void* buf, int length) = 0; + virtual bool Write(const void* buf, size_t length) = 0; // Inherited from both Instream and OutStream. // Rewinds the file to the start. Only available when OpenFile() has been diff --git a/webrtc/system_wrappers/source/file_impl.cc b/webrtc/system_wrappers/source/file_impl.cc index 8b21b96eb4..eb199a8482 100644 --- a/webrtc/system_wrappers/source/file_impl.cc +++ b/webrtc/system_wrappers/source/file_impl.cc @@ -187,19 +187,16 @@ int FileWrapperImpl::OpenFromFileHandle(FILE* handle, return 0; } -int FileWrapperImpl::Read(void* buf, int length) { +int FileWrapperImpl::Read(void* buf, size_t length) { WriteLockScoped write(*rw_lock_); - if (length < 0) - return -1; - if (id_ == NULL) return -1; - int bytes_read = static_cast(fread(buf, 1, length, id_)); + size_t bytes_read = fread(buf, 1, length, id_); if (bytes_read != length && !looping_) { CloseFileImpl(); } - return bytes_read; + return static_cast(bytes_read); } int FileWrapperImpl::WriteText(const char* format, ...) { @@ -226,14 +223,11 @@ int FileWrapperImpl::WriteText(const char* format, ...) { } } -bool FileWrapperImpl::Write(const void* buf, int length) { +bool FileWrapperImpl::Write(const void* buf, size_t length) { WriteLockScoped write(*rw_lock_); if (buf == NULL) return false; - if (length < 0) - return false; - if (read_only_) return false; diff --git a/webrtc/system_wrappers/source/file_impl.h b/webrtc/system_wrappers/source/file_impl.h index 1abf010194..bed692b2ba 100644 --- a/webrtc/system_wrappers/source/file_impl.h +++ b/webrtc/system_wrappers/source/file_impl.h @@ -44,8 +44,8 @@ class FileWrapperImpl : public FileWrapper { virtual int SetMaxFileSize(size_t bytes) OVERRIDE; virtual int Flush() OVERRIDE; - virtual int Read(void* buf, int length) OVERRIDE; - virtual bool Write(const void* buf, int length) OVERRIDE; + virtual int Read(void* buf, size_t length) OVERRIDE; + virtual bool Write(const void* buf, size_t length) OVERRIDE; virtual int WriteText(const char* format, ...) OVERRIDE; virtual int Rewind() OVERRIDE; diff --git a/webrtc/test/channel_transport/channel_transport.cc b/webrtc/test/channel_transport/channel_transport.cc index 4b0a5ae19e..725a090641 100644 --- a/webrtc/test/channel_transport/channel_transport.cc +++ b/webrtc/test/channel_transport/channel_transport.cc @@ -50,7 +50,7 @@ VoiceChannelTransport::~VoiceChannelTransport() { void VoiceChannelTransport::IncomingRTPPacket( const int8_t* incoming_rtp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) { voe_network_->ReceivedRTPPacket( @@ -59,7 +59,7 @@ void VoiceChannelTransport::IncomingRTPPacket( void VoiceChannelTransport::IncomingRTCPPacket( const int8_t* incoming_rtcp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) { voe_network_->ReceivedRTCPPacket(channel_, incoming_rtcp_packet, @@ -103,7 +103,7 @@ VideoChannelTransport::~VideoChannelTransport() { void VideoChannelTransport::IncomingRTPPacket( const int8_t* incoming_rtp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) { vie_network_->ReceivedRTPPacket( @@ -112,7 +112,7 @@ void VideoChannelTransport::IncomingRTPPacket( void VideoChannelTransport::IncomingRTCPPacket( const int8_t* incoming_rtcp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) { vie_network_->ReceivedRTCPPacket(channel_, incoming_rtcp_packet, diff --git a/webrtc/test/channel_transport/include/channel_transport.h b/webrtc/test/channel_transport/include/channel_transport.h index efe476231d..df22012d37 100644 --- a/webrtc/test/channel_transport/include/channel_transport.h +++ b/webrtc/test/channel_transport/include/channel_transport.h @@ -29,12 +29,12 @@ class VoiceChannelTransport : public UdpTransportData { // Start implementation of UdpTransportData. virtual void IncomingRTPPacket(const int8_t* incoming_rtp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) OVERRIDE; virtual void IncomingRTCPPacket(const int8_t* incoming_rtcp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) OVERRIDE; // End implementation of UdpTransportData. @@ -60,12 +60,12 @@ class VideoChannelTransport : public UdpTransportData { // Start implementation of UdpTransportData. virtual void IncomingRTPPacket(const int8_t* incoming_rtp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) OVERRIDE; virtual void IncomingRTCPPacket(const int8_t* incoming_rtcp_packet, - const int32_t packet_length, + const size_t packet_length, const char* /*from_ip*/, const uint16_t /*from_port*/) OVERRIDE; // End implementation of UdpTransportData. diff --git a/webrtc/test/channel_transport/udp_socket2_manager_win.h b/webrtc/test/channel_transport/udp_socket2_manager_win.h index 956cc03031..d3b8aed2d3 100644 --- a/webrtc/test/channel_transport/udp_socket2_manager_win.h +++ b/webrtc/test/channel_transport/udp_socket2_manager_win.h @@ -39,7 +39,7 @@ struct PerIoContext { WSAOVERLAPPED overlapped; char buffer[MAX_IO_BUFF_SIZE]; WSABUF wsabuf; - int nTotalBytes; + size_t nTotalBytes; int nSentBytes; int bytes; IO_OPERATION ioOperation; diff --git a/webrtc/test/channel_transport/udp_socket2_win.cc b/webrtc/test/channel_transport/udp_socket2_win.cc index 98afcb2d53..1d5234c165 100644 --- a/webrtc/test/channel_transport/udp_socket2_win.cc +++ b/webrtc/test/channel_transport/udp_socket2_win.cc @@ -14,6 +14,7 @@ #include #include +#include "webrtc/base/format_macros.h" #include "webrtc/system_wrappers/interface/sleep.h" #include "webrtc/test/channel_transport/traffic_control_win.h" #include "webrtc/test/channel_transport/udp_socket2_manager_win.h" @@ -349,19 +350,11 @@ bool UdpSocket2Windows::Bind(const SocketAddress& name) return returnValue; } -int32_t UdpSocket2Windows::SendTo(const int8_t* buf, int32_t len, +int32_t UdpSocket2Windows::SendTo(const int8_t* buf, size_t len, const SocketAddress& to) { int32_t retVal = 0; int32_t error = 0; - if(len < 0) - { - WEBRTC_TRACE(kTraceError, kTraceTransport, _id, - "UdpSocket2Windows(%d)::SendTo(), len= %d < 0", - (int32_t)this, len); - return -1; - } - PerIoContext* pIoContext = _mgr->PopIoContext(); if(pIoContext == 0) { @@ -371,14 +364,15 @@ int32_t UdpSocket2Windows::SendTo(const int8_t* buf, int32_t len, return -1; } // sizeof(pIoContext->buffer) is smaller than the highest number that - // can be represented by a int32_t. - if(len >= (int32_t) sizeof(pIoContext->buffer)) + // can be represented by a size_t. + if(len >= sizeof(pIoContext->buffer)) { WEBRTC_TRACE( kTraceError, kTraceTransport, _id, - "UdpSocket2Windows(%d)::SendTo(), len= %d > buffer_size = %d", + "UdpSocket2Windows(%d)::SendTo(), len= %" PRIuS + " > buffer_size = %d", (int32_t) this, len,sizeof(pIoContext->buffer)); len = sizeof(pIoContext->buffer); @@ -386,7 +380,7 @@ int32_t UdpSocket2Windows::SendTo(const int8_t* buf, int32_t len, memcpy(pIoContext->buffer,buf,len); pIoContext->wsabuf.buf = pIoContext->buffer; - pIoContext->wsabuf.len = len; + pIoContext->wsabuf.len = static_cast(len); pIoContext->fromLen=sizeof(SocketAddress); pIoContext->ioOperation = OP_WRITE; pIoContext->nTotalBytes = len; @@ -424,7 +418,7 @@ int32_t UdpSocket2Windows::SendTo(const int8_t* buf, int32_t len, } if(retVal == 0 || (retVal == SOCKET_ERROR && error == ERROR_IO_PENDING)) { - return len; + return static_cast(len); } error = _mgr->PushIoContext(pIoContext); if(error) diff --git a/webrtc/test/channel_transport/udp_socket2_win.h b/webrtc/test/channel_transport/udp_socket2_win.h index 629c9c36d7..7dec1eda99 100644 --- a/webrtc/test/channel_transport/udp_socket2_win.h +++ b/webrtc/test/channel_transport/udp_socket2_win.h @@ -56,7 +56,7 @@ public: virtual inline bool StartReceiving() OVERRIDE {return StartReceiving(8);} virtual bool StopReceiving() OVERRIDE; - virtual int32_t SendTo(const int8_t* buf, int32_t len, + virtual int32_t SendTo(const int8_t* buf, size_t len, const SocketAddress& to) OVERRIDE; virtual void CloseBlocking() OVERRIDE; diff --git a/webrtc/test/channel_transport/udp_socket_posix.cc b/webrtc/test/channel_transport/udp_socket_posix.cc index 355da536f9..43f75b4b1d 100644 --- a/webrtc/test/channel_transport/udp_socket_posix.cc +++ b/webrtc/test/channel_transport/udp_socket_posix.cc @@ -154,7 +154,7 @@ bool UdpSocketPosix::Bind(const SocketAddress& name) return false; } -int32_t UdpSocketPosix::SendTo(const int8_t* buf, int32_t len, +int32_t UdpSocketPosix::SendTo(const int8_t* buf, size_t len, const SocketAddress& to) { int size = sizeof(sockaddr); diff --git a/webrtc/test/channel_transport/udp_socket_posix.h b/webrtc/test/channel_transport/udp_socket_posix.h index 8458ca0d74..c503636c3b 100644 --- a/webrtc/test/channel_transport/udp_socket_posix.h +++ b/webrtc/test/channel_transport/udp_socket_posix.h @@ -45,7 +45,7 @@ public: virtual int32_t SetTOS(const int32_t serviceType) OVERRIDE; - virtual int32_t SendTo(const int8_t* buf, int32_t len, + virtual int32_t SendTo(const int8_t* buf, size_t len, const SocketAddress& to) OVERRIDE; // Deletes socket in addition to closing it. diff --git a/webrtc/test/channel_transport/udp_socket_wrapper.h b/webrtc/test/channel_transport/udp_socket_wrapper.h index 4be472227d..d14fcfddc5 100644 --- a/webrtc/test/channel_transport/udp_socket_wrapper.h +++ b/webrtc/test/channel_transport/udp_socket_wrapper.h @@ -38,7 +38,7 @@ typedef int SOCKET; typedef void* CallbackObj; typedef void(*IncomingSocketCallback)(CallbackObj obj, const int8_t* buf, - int32_t len, const SocketAddress* from); + size_t len, const SocketAddress* from); class UdpSocketWrapper { @@ -79,7 +79,7 @@ public: virtual int32_t SetPCP(const int32_t /*pcp*/); // Send buf of length len to the address specified by to. - virtual int32_t SendTo(const int8_t* buf, int32_t len, + virtual int32_t SendTo(const int8_t* buf, size_t len, const SocketAddress& to) = 0; virtual void SetEventToNull(); diff --git a/webrtc/test/channel_transport/udp_transport.h b/webrtc/test/channel_transport/udp_transport.h index d45326f958..a923835685 100644 --- a/webrtc/test/channel_transport/udp_transport.h +++ b/webrtc/test/channel_transport/udp_transport.h @@ -97,12 +97,12 @@ class UdpTransportData { virtual ~UdpTransportData() {}; virtual void IncomingRTPPacket(const int8_t* incomingRtpPacket, - const int32_t rtpPacketLength, + const size_t rtpPacketLength, const char* fromIP, const uint16_t fromPort) = 0; virtual void IncomingRTCPPacket(const int8_t* incomingRtcpPacket, - const int32_t rtcpPacketLength, + const size_t rtcpPacketLength, const char* fromIP, const uint16_t fromPort) = 0; }; @@ -283,33 +283,33 @@ class UdpTransport : public Transport { // address as set with InitializeSendSockets(..) is used if ip is NULL. // If isRTCP is true the port used will be the RTCP port. virtual int32_t SendRaw(const int8_t* data, - uint32_t length, + size_t length, int32_t isRTCP, uint16_t portnr = 0, const char* ip = NULL) = 0; // Send RTP data with size length to the address specified by to. virtual int32_t SendRTPPacketTo(const int8_t* data, - uint32_t length, + size_t length, const SocketAddress& to) = 0; // Send RTCP data with size length to the address specified by to. virtual int32_t SendRTCPPacketTo(const int8_t* data, - uint32_t length, + size_t length, const SocketAddress& to) = 0; // Send RTP data with size length to ip:rtpPort where ip is the ip set by // the InitializeSendSockets(..) call. virtual int32_t SendRTPPacketTo(const int8_t* data, - uint32_t length, + size_t length, uint16_t rtpPort) = 0; // Send RTCP data with size length to ip:rtcpPort where ip is the ip set by // the InitializeSendSockets(..) call. virtual int32_t SendRTCPPacketTo(const int8_t* data, - uint32_t length, + size_t length, uint16_t rtcpPort) = 0; // Set the IP address to which packets are sent to ipaddr. diff --git a/webrtc/test/channel_transport/udp_transport_impl.cc b/webrtc/test/channel_transport/udp_transport_impl.cc index c0e897e1bd..c367b2f0e6 100644 --- a/webrtc/test/channel_transport/udp_transport_impl.cc +++ b/webrtc/test/channel_transport/udp_transport_impl.cc @@ -1765,7 +1765,7 @@ void UdpTransportImpl::BuildSockaddrIn(uint16_t portnr, } int32_t UdpTransportImpl::SendRaw(const int8_t *data, - uint32_t length, + size_t length, int32_t isRTCP, uint16_t portnr, const char* ip) @@ -1841,7 +1841,7 @@ int32_t UdpTransportImpl::SendRaw(const int8_t *data, } int32_t UdpTransportImpl::SendRTPPacketTo(const int8_t* data, - uint32_t length, + size_t length, const SocketAddress& to) { CriticalSectionScoped cs(_crit); @@ -1857,7 +1857,7 @@ int32_t UdpTransportImpl::SendRTPPacketTo(const int8_t* data, } int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data, - uint32_t length, + size_t length, const SocketAddress& to) { @@ -1875,7 +1875,7 @@ int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data, } int32_t UdpTransportImpl::SendRTPPacketTo(const int8_t* data, - uint32_t length, + size_t length, const uint16_t rtpPort) { CriticalSectionScoped cs(_crit); @@ -1903,7 +1903,7 @@ int32_t UdpTransportImpl::SendRTPPacketTo(const int8_t* data, } int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data, - uint32_t length, + size_t length, const uint16_t rtcpPort) { CriticalSectionScoped cs(_crit); @@ -1931,7 +1931,9 @@ int32_t UdpTransportImpl::SendRTCPPacketTo(const int8_t* data, return -1; } -int UdpTransportImpl::SendPacket(int /*channel*/, const void* data, int length) +int UdpTransportImpl::SendPacket(int /*channel*/, + const void* data, + size_t length) { WEBRTC_TRACE(kTraceStream, kTraceTransport, _id, "%s", __FUNCTION__); @@ -1999,7 +2001,7 @@ int UdpTransportImpl::SendPacket(int /*channel*/, const void* data, int length) } int UdpTransportImpl::SendRTCPPacket(int /*channel*/, const void* data, - int length) + size_t length) { CriticalSectionScoped cs(_crit); @@ -2094,7 +2096,7 @@ int32_t UdpTransportImpl::SetSendPorts(uint16_t rtpPort, uint16_t rtcpPort) void UdpTransportImpl::IncomingRTPCallback(CallbackObj obj, const int8_t* rtpPacket, - int32_t rtpPacketLength, + size_t rtpPacketLength, const SocketAddress* from) { if (rtpPacket && rtpPacketLength > 0) @@ -2106,7 +2108,7 @@ void UdpTransportImpl::IncomingRTPCallback(CallbackObj obj, void UdpTransportImpl::IncomingRTCPCallback(CallbackObj obj, const int8_t* rtcpPacket, - int32_t rtcpPacketLength, + size_t rtcpPacketLength, const SocketAddress* from) { if (rtcpPacket && rtcpPacketLength > 0) @@ -2118,7 +2120,7 @@ void UdpTransportImpl::IncomingRTCPCallback(CallbackObj obj, } void UdpTransportImpl::IncomingRTPFunction(const int8_t* rtpPacket, - int32_t rtpPacketLength, + size_t rtpPacketLength, const SocketAddress* fromSocket) { char ipAddress[kIpAddressVersion6Length]; @@ -2181,7 +2183,7 @@ void UdpTransportImpl::IncomingRTPFunction(const int8_t* rtpPacket, } void UdpTransportImpl::IncomingRTCPFunction(const int8_t* rtcpPacket, - int32_t rtcpPacketLength, + size_t rtcpPacketLength, const SocketAddress* fromSocket) { char ipAddress[kIpAddressVersion6Length]; diff --git a/webrtc/test/channel_transport/udp_transport_impl.h b/webrtc/test/channel_transport/udp_transport_impl.h index 2b804c35bf..65ad095093 100644 --- a/webrtc/test/channel_transport/udp_transport_impl.h +++ b/webrtc/test/channel_transport/udp_transport_impl.h @@ -105,26 +105,28 @@ public: virtual bool SourcePortsInitialized() const OVERRIDE; virtual bool ReceiveSocketsInitialized() const OVERRIDE; virtual int32_t SendRaw(const int8_t* data, - uint32_t length, int32_t isRTCP, + size_t length, int32_t isRTCP, uint16_t portnr = 0, const char* ip = NULL) OVERRIDE; virtual int32_t SendRTPPacketTo(const int8_t *data, - uint32_t length, + size_t length, const SocketAddress& to) OVERRIDE; virtual int32_t SendRTCPPacketTo(const int8_t *data, - uint32_t length, + size_t length, const SocketAddress& to) OVERRIDE; virtual int32_t SendRTPPacketTo(const int8_t *data, - uint32_t length, + size_t length, uint16_t rtpPort) OVERRIDE; virtual int32_t SendRTCPPacketTo(const int8_t *data, - uint32_t length, + size_t length, uint16_t rtcpPort) OVERRIDE; // Transport functions - virtual int SendPacket(int channel, const void* data, int length) OVERRIDE; + virtual int SendPacket(int channel, + const void* data, + size_t length) OVERRIDE; virtual int SendRTCPPacket(int channel, const void* data, - int length) OVERRIDE; + size_t length) OVERRIDE; // UdpTransport functions continue. virtual int32_t SetSendIP(const char* ipaddr) OVERRIDE; @@ -144,11 +146,11 @@ protected: // UdpSocketWrapper. static void IncomingRTPCallback(CallbackObj obj, const int8_t* rtpPacket, - int32_t rtpPacketLength, + size_t rtpPacketLength, const SocketAddress* from); static void IncomingRTCPCallback(CallbackObj obj, const int8_t* rtcpPacket, - int32_t rtcpPacketLength, + size_t rtcpPacketLength, const SocketAddress* from); void CloseSendSockets(); @@ -169,10 +171,10 @@ protected: ErrorCode BindRTCPSendSocket(); void IncomingRTPFunction(const int8_t* rtpPacket, - int32_t rtpPacketLength, + size_t rtpPacketLength, const SocketAddress* from); void IncomingRTCPFunction(const int8_t* rtcpPacket, - int32_t rtcpPacketLength, + size_t rtcpPacketLength, const SocketAddress* from); bool FilterIPAddress(const SocketAddress* fromAddress); diff --git a/webrtc/test/channel_transport/udp_transport_unittest.cc b/webrtc/test/channel_transport/udp_transport_unittest.cc index 5ccc9ef2b8..862ebf9cb6 100644 --- a/webrtc/test/channel_transport/udp_transport_unittest.cc +++ b/webrtc/test/channel_transport/udp_transport_unittest.cc @@ -36,7 +36,7 @@ class MockUdpSocketWrapper : public UdpSocketWrapper { const int8_t*, int32_t)); MOCK_METHOD1(SetTOS, int32_t(int32_t)); - MOCK_METHOD3(SendTo, int32_t(const int8_t*, int32_t, const SocketAddress&)); + MOCK_METHOD3(SendTo, int32_t(const int8_t*, size_t, const SocketAddress&)); MOCK_METHOD8(SetQos, bool(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, diff --git a/webrtc/test/configurable_frame_size_encoder.cc b/webrtc/test/configurable_frame_size_encoder.cc index d3ed784ca9..f25f443dda 100644 --- a/webrtc/test/configurable_frame_size_encoder.cc +++ b/webrtc/test/configurable_frame_size_encoder.cc @@ -21,7 +21,7 @@ namespace webrtc { namespace test { ConfigurableFrameSizeEncoder::ConfigurableFrameSizeEncoder( - uint32_t max_frame_size) + size_t max_frame_size) : callback_(NULL), max_frame_size_(max_frame_size), current_frame_size_(max_frame_size), @@ -34,7 +34,7 @@ ConfigurableFrameSizeEncoder::~ConfigurableFrameSizeEncoder() {} int32_t ConfigurableFrameSizeEncoder::InitEncode( const VideoCodec* codec_settings, int32_t number_of_cores, - uint32_t max_payload_size) { + size_t max_payload_size) { return WEBRTC_VIDEO_CODEC_OK; } @@ -87,7 +87,7 @@ int32_t ConfigurableFrameSizeEncoder::CodecConfigParameters(uint8_t* buffer, return WEBRTC_VIDEO_CODEC_OK; } -int32_t ConfigurableFrameSizeEncoder::SetFrameSize(uint32_t size) { +int32_t ConfigurableFrameSizeEncoder::SetFrameSize(size_t size) { assert(size <= max_frame_size_); current_frame_size_ = size; return WEBRTC_VIDEO_CODEC_OK; diff --git a/webrtc/test/configurable_frame_size_encoder.h b/webrtc/test/configurable_frame_size_encoder.h index 4120bc6c83..43c4b29620 100644 --- a/webrtc/test/configurable_frame_size_encoder.h +++ b/webrtc/test/configurable_frame_size_encoder.h @@ -21,12 +21,12 @@ namespace test { class ConfigurableFrameSizeEncoder : public VideoEncoder { public: - explicit ConfigurableFrameSizeEncoder(uint32_t max_frame_size); + explicit ConfigurableFrameSizeEncoder(size_t max_frame_size); virtual ~ConfigurableFrameSizeEncoder(); virtual int32_t InitEncode(const VideoCodec* codec_settings, int32_t number_of_cores, - uint32_t max_payload_size) OVERRIDE; + size_t max_payload_size) OVERRIDE; virtual int32_t Encode(const I420VideoFrame& input_image, const CodecSpecificInfo* codec_specific_info, @@ -46,12 +46,12 @@ class ConfigurableFrameSizeEncoder : public VideoEncoder { virtual int32_t CodecConfigParameters(uint8_t* buffer, int32_t size) OVERRIDE; - int32_t SetFrameSize(uint32_t size); + int32_t SetFrameSize(size_t size); private: EncodedImageCallback* callback_; - const uint32_t max_frame_size_; - uint32_t current_frame_size_; + const size_t max_frame_size_; + size_t current_frame_size_; scoped_ptr buffer_; }; diff --git a/webrtc/test/fake_encoder.cc b/webrtc/test/fake_encoder.cc index 41d0ea3c58..d0b6402004 100644 --- a/webrtc/test/fake_encoder.cc +++ b/webrtc/test/fake_encoder.cc @@ -39,7 +39,7 @@ void FakeEncoder::SetMaxBitrate(int max_kbps) { int32_t FakeEncoder::InitEncode(const VideoCodec* config, int32_t number_of_cores, - uint32_t max_payload_size) { + size_t max_payload_size) { config_ = *config; target_bitrate_kbps_ = config_.startBitrate; return 0; @@ -50,7 +50,7 @@ int32_t FakeEncoder::Encode( const CodecSpecificInfo* codec_specific_info, const std::vector* frame_types) { assert(config_.maxFramerate > 0); - int time_since_last_encode_ms = 1000 / config_.maxFramerate; + int64_t time_since_last_encode_ms = 1000 / config_.maxFramerate; int64_t time_now_ms = clock_->TimeInMilliseconds(); const bool first_encode = last_encode_time_ms_ == 0; if (!first_encode) { @@ -59,36 +59,38 @@ int32_t FakeEncoder::Encode( time_since_last_encode_ms = time_now_ms - last_encode_time_ms_; } - int bits_available = target_bitrate_kbps_ * time_since_last_encode_ms; - int min_bits = - config_.simulcastStream[0].minBitrate * time_since_last_encode_ms; + size_t bits_available = + static_cast(target_bitrate_kbps_ * time_since_last_encode_ms); + size_t min_bits = static_cast( + config_.simulcastStream[0].minBitrate * time_since_last_encode_ms); if (bits_available < min_bits) bits_available = min_bits; - int max_bits = max_target_bitrate_kbps_ * time_since_last_encode_ms; + size_t max_bits = + static_cast(max_target_bitrate_kbps_ * time_since_last_encode_ms); if (max_bits > 0 && max_bits < bits_available) bits_available = max_bits; last_encode_time_ms_ = time_now_ms; assert(config_.numberOfSimulcastStreams > 0); - for (int i = 0; i < config_.numberOfSimulcastStreams; ++i) { + for (unsigned char i = 0; i < config_.numberOfSimulcastStreams; ++i) { CodecSpecificInfo specifics; memset(&specifics, 0, sizeof(specifics)); specifics.codecType = kVideoCodecGeneric; specifics.codecSpecific.generic.simulcast_idx = i; - int min_stream_bits = - config_.simulcastStream[i].minBitrate * time_since_last_encode_ms; - int max_stream_bits = - config_.simulcastStream[i].maxBitrate * time_since_last_encode_ms; - int stream_bits = (bits_available > max_stream_bits) ? max_stream_bits : + size_t min_stream_bits = static_cast( + config_.simulcastStream[i].minBitrate * time_since_last_encode_ms); + size_t max_stream_bits = static_cast( + config_.simulcastStream[i].maxBitrate * time_since_last_encode_ms); + size_t stream_bits = (bits_available > max_stream_bits) ? max_stream_bits : bits_available; - int stream_bytes = (stream_bits + 7) / 8; + size_t stream_bytes = (stream_bits + 7) / 8; if (first_encode) { // The first frame is a key frame and should be larger. // TODO(holmer): The FakeEncoder should store the bits_available between // encodes so that it can compensate for oversized frames. stream_bytes *= 10; } - if (static_cast(stream_bytes) > sizeof(encoded_buffer_)) + if (stream_bytes > sizeof(encoded_buffer_)) stream_bytes = sizeof(encoded_buffer_); EncodedImage encoded( @@ -104,7 +106,7 @@ int32_t FakeEncoder::Encode( assert(callback_ != NULL); if (callback_->Encoded(encoded, &specifics, NULL) != 0) return -1; - bits_available -= encoded._length * 8; + bits_available -= std::min(encoded._length * 8, bits_available); } return 0; } @@ -155,9 +157,9 @@ int32_t FakeH264Encoder::Encoded(EncodedImage& encoded_image, fragmentation.fragmentationOffset[2] = kSpsSize + kPpsSize; fragmentation.fragmentationLength[2] = encoded_image._length - (kSpsSize + kPpsSize); - const uint8_t kSpsNalHeader = 0x37; - const uint8_t kPpsNalHeader = 0x38; - const uint8_t kIdrNalHeader = 0x15; + const size_t kSpsNalHeader = 0x37; + const size_t kPpsNalHeader = 0x38; + const size_t kIdrNalHeader = 0x15; encoded_image._buffer[fragmentation.fragmentationOffset[0]] = kSpsNalHeader; encoded_image._buffer[fragmentation.fragmentationOffset[1]] = kPpsNalHeader; encoded_image._buffer[fragmentation.fragmentationOffset[2]] = kIdrNalHeader; @@ -166,7 +168,7 @@ int32_t FakeH264Encoder::Encoded(EncodedImage& encoded_image, fragmentation.VerifyAndAllocateFragmentationHeader(kNumSlices); fragmentation.fragmentationOffset[0] = 0; fragmentation.fragmentationLength[0] = encoded_image._length; - const uint8_t kNalHeader = 0x11; + const size_t kNalHeader = 0x11; encoded_image._buffer[fragmentation.fragmentationOffset[0]] = kNalHeader; } uint8_t value = 0; diff --git a/webrtc/test/fake_encoder.h b/webrtc/test/fake_encoder.h index 01b83f012d..b77cb3ed43 100644 --- a/webrtc/test/fake_encoder.h +++ b/webrtc/test/fake_encoder.h @@ -30,7 +30,7 @@ class FakeEncoder : public VideoEncoder { virtual int32_t InitEncode(const VideoCodec* config, int32_t number_of_cores, - uint32_t max_payload_size) OVERRIDE; + size_t max_payload_size) OVERRIDE; virtual int32_t Encode( const I420VideoFrame& input_image, const CodecSpecificInfo* codec_specific_info, diff --git a/webrtc/test/mock_transport.h b/webrtc/test/mock_transport.h index 388ee92e9d..5b1cb8dfb6 100644 --- a/webrtc/test/mock_transport.h +++ b/webrtc/test/mock_transport.h @@ -19,9 +19,9 @@ namespace webrtc { class MockTransport : public webrtc::Transport { public: MOCK_METHOD3(SendPacket, - int(int channel, const void* data, int len)); + int(int channel, const void* data, size_t len)); MOCK_METHOD3(SendRTCPPacket, - int(int channel, const void* data, int len)); + int(int channel, const void* data, size_t len)); }; } // namespace webrtc #endif // WEBRTC_TEST_MOCK_TRANSPORT_H_ diff --git a/webrtc/test/rtcp_packet_parser.cc b/webrtc/test/rtcp_packet_parser.cc index 558bee379e..391be85852 100644 --- a/webrtc/test/rtcp_packet_parser.cc +++ b/webrtc/test/rtcp_packet_parser.cc @@ -17,7 +17,7 @@ RtcpPacketParser::RtcpPacketParser() {} RtcpPacketParser::~RtcpPacketParser() {} -void RtcpPacketParser::Parse(const void *data, int len) { +void RtcpPacketParser::Parse(const void *data, size_t len) { const uint8_t* packet = static_cast(data); RTCPUtility::RTCPParserV2 parser(packet, len, true); for (RTCPUtility::RTCPPacketTypes type = parser.Begin(); diff --git a/webrtc/test/rtcp_packet_parser.h b/webrtc/test/rtcp_packet_parser.h index f7d36ba804..cc890b4f2f 100644 --- a/webrtc/test/rtcp_packet_parser.h +++ b/webrtc/test/rtcp_packet_parser.h @@ -631,7 +631,7 @@ class RtcpPacketParser { RtcpPacketParser(); ~RtcpPacketParser(); - void Parse(const void *packet, int packet_len); + void Parse(const void *packet, size_t packet_len); SenderReport* sender_report() { return &sender_report_; } ReceiverReport* receiver_report() { return &receiver_report_; } diff --git a/webrtc/test/testsupport/packet_reader.cc b/webrtc/test/testsupport/packet_reader.cc index 54552bd0f5..e27ec22f16 100644 --- a/webrtc/test/testsupport/packet_reader.cc +++ b/webrtc/test/testsupport/packet_reader.cc @@ -12,6 +12,7 @@ #include #include +#include namespace webrtc { namespace test { @@ -22,10 +23,9 @@ PacketReader::PacketReader() PacketReader::~PacketReader() {} void PacketReader::InitializeReading(uint8_t* data, - int data_length_in_bytes, - int packet_size_in_bytes) { + size_t data_length_in_bytes, + size_t packet_size_in_bytes) { assert(data); - assert(data_length_in_bytes >= 0); assert(packet_size_in_bytes > 0); data_ = data; data_length_ = data_length_in_bytes; @@ -40,16 +40,9 @@ int PacketReader::NextPacket(uint8_t** packet_pointer) { return -1; } *packet_pointer = data_ + currentIndex_; - // Check if we're about to read the last packet: - if (data_length_ - currentIndex_ <= packet_size_) { - int size = data_length_ - currentIndex_; - currentIndex_ = data_length_; - assert(size >= 0); - return size; - } - currentIndex_ += packet_size_; - assert(packet_size_ >= 0); - return packet_size_; + size_t old_index = currentIndex_; + currentIndex_ = std::min(currentIndex_ + packet_size_, data_length_); + return static_cast(currentIndex_ - old_index); } } // namespace test diff --git a/webrtc/test/testsupport/packet_reader.h b/webrtc/test/testsupport/packet_reader.h index e84ecd96b5..b58db4d093 100644 --- a/webrtc/test/testsupport/packet_reader.h +++ b/webrtc/test/testsupport/packet_reader.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_TEST_TESTSUPPORT_PACKET_READER_H_ #define WEBRTC_TEST_TESTSUPPORT_PACKET_READER_H_ +#include #include "webrtc/typedefs.h" namespace webrtc { @@ -24,12 +25,12 @@ class PacketReader { // Inizializes a new reading operation. Must be done before invoking the // NextPacket method. - // * data_length_in_bytes is the length of the data byte array. Must be >= 0. + // * data_length_in_bytes is the length of the data byte array. // 0 length will result in no packets are read. // * packet_size_in_bytes is the number of bytes to read in each NextPacket // method call. Must be > 0 - virtual void InitializeReading(uint8_t* data, int data_length_in_bytes, - int packet_size_in_bytes); + virtual void InitializeReading(uint8_t* data, size_t data_length_in_bytes, + size_t packet_size_in_bytes); // Moves the supplied pointer to the beginning of the next packet. // Returns: @@ -41,9 +42,9 @@ class PacketReader { private: uint8_t* data_; - int data_length_; - int packet_size_; - int currentIndex_; + size_t data_length_; + size_t packet_size_; + size_t currentIndex_; bool initialized_; }; diff --git a/webrtc/test/testsupport/packet_reader_unittest.cc b/webrtc/test/testsupport/packet_reader_unittest.cc index 83cde6957d..2679be473f 100644 --- a/webrtc/test/testsupport/packet_reader_unittest.cc +++ b/webrtc/test/testsupport/packet_reader_unittest.cc @@ -26,11 +26,11 @@ class PacketReaderTest: public PacketRelatedTest { void TearDown() { delete reader_; } - void VerifyPacketData(int expected_length, + void VerifyPacketData(size_t expected_length, int actual_length, uint8_t* original_data_pointer, uint8_t* new_data_pointer) { - EXPECT_EQ(expected_length, actual_length); + EXPECT_EQ(static_cast(expected_length), actual_length); EXPECT_EQ(*original_data_pointer, *new_data_pointer); EXPECT_EQ(0, memcmp(original_data_pointer, new_data_pointer, actual_length)); @@ -82,7 +82,7 @@ TEST_F(PacketReaderTest, NormalOnePacketData) { // Reading another one shall result in 0 bytes: length_to_read = reader_->NextPacket(&data_pointer); EXPECT_EQ(0, length_to_read); - EXPECT_EQ(kPacketSizeInBytes, data_pointer - data); + EXPECT_EQ(kPacketSizeInBytes, static_cast(data_pointer - data)); } // Test with data length that will result in 3 packets @@ -105,7 +105,8 @@ TEST_F(PacketReaderTest, NormalLargeData) { // Reading another one shall result in 0 bytes: length_to_read = reader_->NextPacket(&packet_data_pointer_); EXPECT_EQ(0, length_to_read); - EXPECT_EQ(kPacketDataLength, packet_data_pointer_ - packet_data_); + EXPECT_EQ(kPacketDataLength, + static_cast(packet_data_pointer_ - packet_data_)); } // Test with empty data. diff --git a/webrtc/test/testsupport/unittest_utils.h b/webrtc/test/testsupport/unittest_utils.h index bb244a441a..ba6db9883b 100644 --- a/webrtc/test/testsupport/unittest_utils.h +++ b/webrtc/test/testsupport/unittest_utils.h @@ -14,8 +14,8 @@ namespace webrtc { namespace test { -const int kPacketSizeInBytes = 1500; -const int kPacketDataLength = kPacketSizeInBytes * 2 + 1; +const size_t kPacketSizeInBytes = 1500; +const size_t kPacketDataLength = kPacketSizeInBytes * 2 + 1; const int kPacketDataNumberOfPackets = 3; // A base test fixture for packet related tests. Contains diff --git a/webrtc/tools/frame_editing/frame_editing_lib.cc b/webrtc/tools/frame_editing/frame_editing_lib.cc index 93a548fe56..78c88cb272 100644 --- a/webrtc/tools/frame_editing/frame_editing_lib.cc +++ b/webrtc/tools/frame_editing/frame_editing_lib.cc @@ -36,7 +36,7 @@ int EditFrames(const string& in_path, int width, int height, } // Frame size of I420. - int frame_length = CalcBufferSize(kI420, width, height); + size_t frame_length = CalcBufferSize(kI420, width, height); webrtc::scoped_ptr temp_buffer(new uint8_t[frame_length]); @@ -50,7 +50,7 @@ int EditFrames(const string& in_path, int width, int height, int num_frames_read = 0; int num_frames_read_between = 0; - int num_bytes_read; + size_t num_bytes_read; while ((num_bytes_read = fread(temp_buffer.get(), 1, frame_length, in_fid)) == frame_length) { diff --git a/webrtc/tools/frame_editing/frame_editing_unittest.cc b/webrtc/tools/frame_editing/frame_editing_unittest.cc index 69468e18ce..62ab740f5e 100644 --- a/webrtc/tools/frame_editing/frame_editing_unittest.cc +++ b/webrtc/tools/frame_editing/frame_editing_unittest.cc @@ -24,7 +24,7 @@ namespace test { const int kWidth = 352; const int kHeight = 288; -const int kFrameSize = CalcBufferSize(kI420, kWidth, kHeight); +const size_t kFrameSize = CalcBufferSize(kI420, kWidth, kHeight); class FrameEditingTest : public ::testing::Test { protected: @@ -79,7 +79,7 @@ class FrameEditingTest : public ::testing::Test { std::string test_video_; FILE* original_fid_; FILE* edited_fid_; - int num_bytes_read_; + size_t num_bytes_read_; scoped_ptr original_buffer_; scoped_ptr edited_buffer_; int num_frames_read_; diff --git a/webrtc/video/call_perf_tests.cc b/webrtc/video/call_perf_tests.cc index a93c072459..a6e619eefd 100644 --- a/webrtc/video/call_perf_tests.cc +++ b/webrtc/video/call_perf_tests.cc @@ -199,12 +199,11 @@ void CallPerfTest::TestAudioVideoSync(bool fec) { virtual DeliveryStatus DeliverPacket(const uint8_t* packet, size_t length) OVERRIDE { int ret; - if (parser_->IsRtcp(packet, static_cast(length))) { - ret = voe_network_->ReceivedRTCPPacket( - channel_, packet, static_cast(length)); + if (parser_->IsRtcp(packet, length)) { + ret = voe_network_->ReceivedRTCPPacket(channel_, packet, length); } else { - ret = voe_network_->ReceivedRTPPacket( - channel_, packet, static_cast(length), PacketTime()); + ret = voe_network_->ReceivedRTPPacket(channel_, packet, length, + PacketTime()); } return ret == 0 ? DELIVERY_OK : DELIVERY_PACKET_ERROR; } @@ -612,7 +611,7 @@ TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) { virtual int32_t InitEncode(const VideoCodec* config, int32_t number_of_cores, - uint32_t max_payload_size) OVERRIDE { + size_t max_payload_size) OVERRIDE { if (encoder_inits_ == 0) { EXPECT_EQ(kInitialBitrateKbps, config->startBitrate) << "Encoder not initialized at expected bitrate."; diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc index cce5659cf2..86b8009c49 100644 --- a/webrtc/video/end_to_end_tests.cc +++ b/webrtc/video/end_to_end_tests.cc @@ -1723,11 +1723,9 @@ TEST_F(EndToEndTest, DISABLED_RedundantPayloadsTransmittedOnAllSsrcs) { if (!registered_rtx_ssrc_[header.ssrc]) return SEND_PACKET; - EXPECT_LE(static_cast(header.headerLength + header.paddingLength), - length); + EXPECT_LE(header.headerLength + header.paddingLength, length); const bool packet_is_redundant_payload = - static_cast(header.headerLength + header.paddingLength) < - length; + header.headerLength + header.paddingLength < length; if (!packet_is_redundant_payload) return SEND_PACKET; @@ -1809,8 +1807,7 @@ void EndToEndTest::TestRtpStatePreservation(bool use_rtx) { const uint16_t sequence_number = header.sequenceNumber; const uint32_t timestamp = header.timestamp; const bool only_padding = - static_cast(header.headerLength + header.paddingLength) == - length; + header.headerLength + header.paddingLength == length; EXPECT_TRUE(configured_ssrcs_[ssrc]) << "Received SSRC that wasn't configured: " << ssrc; diff --git a/webrtc/video/rampup_tests.cc b/webrtc/video/rampup_tests.cc index 3238704016..644cb70196 100644 --- a/webrtc/video/rampup_tests.cc +++ b/webrtc/video/rampup_tests.cc @@ -9,6 +9,7 @@ */ #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/common.h" #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" @@ -115,11 +116,13 @@ void StreamObserver::OnReceiveBitrateChanged( bool StreamObserver::SendRtp(const uint8_t* packet, size_t length) { CriticalSectionScoped lock(crit_.get()); RTPHeader header; - EXPECT_TRUE(rtp_parser_->Parse(packet, static_cast(length), &header)); + bool parse_succeeded = rtp_parser_->Parse(packet, length, &header); + RTC_UNUSED(parse_succeeded); + assert(parse_succeeded); receive_stats_->IncomingPacket(header, length, false); payload_registry_->SetIncomingPayloadType(header); remote_bitrate_estimator_->IncomingPacket( - clock_->TimeInMilliseconds(), static_cast(length - 12), header); + clock_->TimeInMilliseconds(), length - 12, header); if (remote_bitrate_estimator_->TimeUntilNextProcess() <= 0) { remote_bitrate_estimator_->Process(); } @@ -134,7 +137,7 @@ bool StreamObserver::SendRtp(const uint8_t* packet, size_t length) { ++rtx_media_packets_sent_; uint8_t restored_packet[kMaxPacketSize]; uint8_t* restored_packet_ptr = restored_packet; - int restored_length = static_cast(length); + size_t restored_length = length; payload_registry_->RestoreOriginalPacket(&restored_packet_ptr, packet, &restored_length, @@ -265,10 +268,12 @@ PacketReceiver::DeliveryStatus LowRateStreamObserver::DeliverPacket( const uint8_t* packet, size_t length) { CriticalSectionScoped lock(crit_.get()); RTPHeader header; - EXPECT_TRUE(rtp_parser_->Parse(packet, static_cast(length), &header)); + bool parse_succeeded = rtp_parser_->Parse(packet, length, &header); + RTC_UNUSED(parse_succeeded); + assert(parse_succeeded); receive_stats_->IncomingPacket(header, length, false); remote_bitrate_estimator_->IncomingPacket( - clock_->TimeInMilliseconds(), static_cast(length - 12), header); + clock_->TimeInMilliseconds(), length - 12, header); if (remote_bitrate_estimator_->TimeUntilNextProcess() <= 0) { remote_bitrate_estimator_->Process(); } diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc index d7750f8aaf..06abb9ed86 100644 --- a/webrtc/video/send_statistics_proxy_unittest.cc +++ b/webrtc/video/send_statistics_proxy_unittest.cc @@ -197,13 +197,14 @@ TEST_F(SendStatisticsProxyTest, DataCounters) { const uint32_t ssrc = *it; StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; // Add statistics with some arbitrary, but unique, numbers. - uint32_t offset = ssrc * sizeof(StreamDataCounters); + size_t offset = ssrc * sizeof(StreamDataCounters); + uint32_t offset_uint32 = static_cast(offset); counters.bytes = offset; counters.header_bytes = offset + 1; - counters.fec_packets = offset + 2; + counters.fec_packets = offset_uint32 + 2; counters.padding_bytes = offset + 3; - counters.retransmitted_packets = offset + 4; - counters.packets = offset + 5; + counters.retransmitted_packets = offset_uint32 + 4; + counters.packets = offset_uint32 + 5; callback->DataCountersUpdated(counters, ssrc); } for (std::vector::const_iterator it = config_.rtp.rtx.ssrcs.begin(); @@ -212,13 +213,14 @@ TEST_F(SendStatisticsProxyTest, DataCounters) { const uint32_t ssrc = *it; StreamDataCounters& counters = expected_.substreams[ssrc].rtp_stats; // Add statistics with some arbitrary, but unique, numbers. - uint32_t offset = ssrc * sizeof(StreamDataCounters); + size_t offset = ssrc * sizeof(StreamDataCounters); + uint32_t offset_uint32 = static_cast(offset); counters.bytes = offset; counters.header_bytes = offset + 1; - counters.fec_packets = offset + 2; + counters.fec_packets = offset_uint32 + 2; counters.padding_bytes = offset + 3; - counters.retransmitted_packets = offset + 4; - counters.packets = offset + 5; + counters.retransmitted_packets = offset_uint32 + 4; + counters.packets = offset_uint32 + 5; callback->DataCountersUpdated(counters, ssrc); } diff --git a/webrtc/video/transport_adapter.cc b/webrtc/video/transport_adapter.cc index 6f27d9972a..7b5a6962c4 100644 --- a/webrtc/video/transport_adapter.cc +++ b/webrtc/video/transport_adapter.cc @@ -18,24 +18,24 @@ TransportAdapter::TransportAdapter(newapi::Transport* transport) int TransportAdapter::SendPacket(int /*channel*/, const void* packet, - int length) { + size_t length) { if (enabled_.Value() == 0) return false; bool success = transport_->SendRtp(static_cast(packet), - static_cast(length)); - return success ? length : -1; + length); + return success ? static_cast(length) : -1; } int TransportAdapter::SendRTCPPacket(int /*channel*/, const void* packet, - int length) { + size_t length) { if (enabled_.Value() == 0) return false; bool success = transport_->SendRtcp(static_cast(packet), - static_cast(length)); - return success ? length : -1; + length); + return success ? static_cast(length) : -1; } void TransportAdapter::Enable() { diff --git a/webrtc/video/transport_adapter.h b/webrtc/video/transport_adapter.h index a9a72e1672..89b0ca0760 100644 --- a/webrtc/video/transport_adapter.h +++ b/webrtc/video/transport_adapter.h @@ -23,10 +23,10 @@ class TransportAdapter : public webrtc::Transport { virtual int SendPacket(int /*channel*/, const void* packet, - int length) OVERRIDE; + size_t length) OVERRIDE; virtual int SendRTCPPacket(int /*channel*/, const void* packet, - int length) OVERRIDE; + size_t length) OVERRIDE; void Enable(); void Disable(); diff --git a/webrtc/video/video_receive_stream.cc b/webrtc/video/video_receive_stream.cc index 5b085bb856..3fc24a34d6 100644 --- a/webrtc/video/video_receive_stream.cc +++ b/webrtc/video/video_receive_stream.cc @@ -257,13 +257,12 @@ VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { } bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { - return network_->ReceivedRTCPPacket( - channel_, packet, static_cast(length)) == 0; + return network_->ReceivedRTCPPacket(channel_, packet, length) == 0; } bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, size_t length) { - return network_->ReceivedRTPPacket( - channel_, packet, static_cast(length), PacketTime()) == 0; + return network_->ReceivedRTPPacket(channel_, packet, length, PacketTime()) == + 0; } void VideoReceiveStream::FrameCallback(I420VideoFrame* video_frame) { diff --git a/webrtc/video/video_send_stream.cc b/webrtc/video/video_send_stream.cc index 489cd14081..f9727fa348 100644 --- a/webrtc/video/video_send_stream.cc +++ b/webrtc/video/video_send_stream.cc @@ -422,8 +422,7 @@ bool VideoSendStream::ReconfigureVideoEncoder( } bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { - return network_->ReceivedRTCPPacket( - channel_, packet, static_cast(length)) == 0; + return network_->ReceivedRTCPPacket(channel_, packet, length) == 0; } VideoSendStream::Stats VideoSendStream::GetStats() const { diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc index bbfd3822aa..9646f2bc92 100644 --- a/webrtc/video/video_send_stream_tests.cc +++ b/webrtc/video/video_send_stream_tests.cc @@ -247,7 +247,7 @@ class FakeReceiveStatistics : public NullReceiveStatistics { *statistics = stats_; return true; } - virtual void GetDataCounters(uint32_t* bytes_received, + virtual void GetDataCounters(size_t* bytes_received, uint32_t* packets_received) const OVERRIDE { *bytes_received = 0; *packets_received = 0; @@ -469,18 +469,18 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format, // Use a fake encoder to output a frame of every size in the range [90, 290], // for each size making sure that the exact number of payload bytes received // is correct and that packets are fragmented to respect max packet size. - static const uint32_t kMaxPacketSize = 128; - static const uint32_t start = 90; - static const uint32_t stop = 290; + static const size_t kMaxPacketSize = 128; + static const size_t start = 90; + static const size_t stop = 290; // Observer that verifies that the expected number of packets and bytes // arrive for each frame size, from start_size to stop_size. class FrameFragmentationTest : public test::SendTest, public EncodedFrameObserver { public: - FrameFragmentationTest(uint32_t max_packet_size, - uint32_t start_size, - uint32_t stop_size, + FrameFragmentationTest(size_t max_packet_size, + size_t start_size, + size_t stop_size, bool test_generic_packetization, bool use_fec) : SendTest(kLongTimeoutMs), @@ -495,16 +495,16 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format, accumulated_payload_(0), fec_packet_received_(false), current_size_rtp_(start_size), - current_size_frame_(start_size) { + current_size_frame_(static_cast(start_size)) { // Fragmentation required, this test doesn't make sense without it. - encoder_.SetFrameSize(start); + encoder_.SetFrameSize(start_size); assert(stop_size > max_packet_size); transport_adapter_.Enable(); } private: virtual Action OnSendRtp(const uint8_t* packet, size_t size) OVERRIDE { - uint32_t length = static_cast(size); + size_t length = size; RTPHeader header; EXPECT_TRUE(parser_->Parse(packet, length, &header)); @@ -526,7 +526,7 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format, TriggerLossReport(header); if (test_generic_packetization_) { - uint32_t overhead = header.headerLength + header.paddingLength + + size_t overhead = header.headerLength + header.paddingLength + (1 /* Generic header */); if (use_fec_) overhead += 1; // RED for FEC header. @@ -599,7 +599,7 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format, current_size_frame_.Value() < static_cast(stop_size_)) { ++current_size_frame_; } - encoder_.SetFrameSize(current_size_frame_.Value()); + encoder_.SetFrameSize(static_cast(current_size_frame_.Value())); } virtual void ModifyConfigs( @@ -633,17 +633,17 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format, internal::TransportAdapter transport_adapter_; test::ConfigurableFrameSizeEncoder encoder_; - const uint32_t max_packet_size_; - const uint32_t stop_size_; + const size_t max_packet_size_; + const size_t stop_size_; const bool test_generic_packetization_; const bool use_fec_; uint32_t packet_count_; - uint32_t accumulated_size_; - uint32_t accumulated_payload_; + size_t accumulated_size_; + size_t accumulated_payload_; bool fec_packet_received_; - uint32_t current_size_rtp_; + size_t current_size_rtp_; Atomic32 current_size_frame_; }; @@ -1260,7 +1260,7 @@ TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) { private: virtual int32_t InitEncode(const VideoCodec* codecSettings, int32_t numberOfCores, - uint32_t maxPayloadSize) OVERRIDE { + size_t maxPayloadSize) OVERRIDE { CriticalSectionScoped lock(crit_.get()); EXPECT_FALSE(initialized_); initialized_ = true; @@ -1382,7 +1382,7 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesCommonEncoderConfigValues) { virtual int32_t InitEncode(const VideoCodec* config, int32_t number_of_cores, - uint32_t max_payload_size) OVERRIDE { + size_t max_payload_size) OVERRIDE { if (num_initializations_ == 0) { // Verify default values. EXPECT_EQ(kRealtimeVideo, config->mode); @@ -1449,7 +1449,7 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) { virtual int32_t InitEncode(const VideoCodec* config, int32_t number_of_cores, - uint32_t max_payload_size) OVERRIDE { + size_t max_payload_size) OVERRIDE { EXPECT_EQ(kVideoCodecVP8, config->codecType); // Check that the number of temporal layers has propagated properly to @@ -1555,7 +1555,7 @@ TEST_F(VideoSendStreamTest, TranslatesTwoLayerScreencastToTargetBitrate) { private: virtual int32_t InitEncode(const VideoCodec* config, int32_t number_of_cores, - uint32_t max_payload_size) { + size_t max_payload_size) OVERRIDE { EXPECT_EQ(static_cast(kScreencastTargetBitrateKbps), config->targetBitrate); observation_complete_->Set(); diff --git a/webrtc/video_encoder.h b/webrtc/video_encoder.h index 2bf52f3c32..649051cdb4 100644 --- a/webrtc/video_encoder.h +++ b/webrtc/video_encoder.h @@ -68,7 +68,7 @@ class VideoEncoder { // WEBRTC_VIDEO_CODEC_ERROR virtual int32_t InitEncode(const VideoCodec* codec_settings, int32_t number_of_cores, - uint32_t max_payload_size) = 0; + size_t max_payload_size) = 0; // Register an encode complete callback object. // diff --git a/webrtc/video_engine/include/vie_capture.h b/webrtc/video_engine/include/vie_capture.h index cee3626510..a602a5b74e 100644 --- a/webrtc/video_engine/include/vie_capture.h +++ b/webrtc/video_engine/include/vie_capture.h @@ -106,7 +106,7 @@ class WEBRTC_DLLEXPORT ViEExternalCapture { // VideoEngine. // |capture_time| must be specified in the NTP time format in milliseconds. virtual int IncomingFrame(unsigned char* video_frame, - unsigned int video_frame_length, + size_t video_frame_length, unsigned short width, unsigned short height, RawVideoType video_type, diff --git a/webrtc/video_engine/include/vie_image_process.h b/webrtc/video_engine/include/vie_image_process.h index 8bb895fb58..adf0c199c9 100644 --- a/webrtc/video_engine/include/vie_image_process.h +++ b/webrtc/video_engine/include/vie_image_process.h @@ -32,7 +32,7 @@ class WEBRTC_DLLEXPORT ViEEffectFilter { public: // This method is called with an I420 video frame allowing the user to // modify the video frame. - virtual int Transform(int size, + virtual int Transform(size_t size, unsigned char* frame_buffer, int64_t ntp_time_ms, unsigned int timestamp, diff --git a/webrtc/video_engine/include/vie_network.h b/webrtc/video_engine/include/vie_network.h index bb368182cf..a1f75ba724 100644 --- a/webrtc/video_engine/include/vie_network.h +++ b/webrtc/video_engine/include/vie_network.h @@ -65,14 +65,14 @@ class WEBRTC_DLLEXPORT ViENetwork { // the RTP header and payload. virtual int ReceivedRTPPacket(const int video_channel, const void* data, - const int length, + const size_t length, const PacketTime& packet_time) = 0; // When using external transport for a channel, received RTCP packets should // be passed to VideoEngine using this function. virtual int ReceivedRTCPPacket(const int video_channel, const void* data, - const int length) = 0; + const size_t length) = 0; // This function sets the Maximum Transition Unit (MTU) for a channel. The // RTP packet will be packetized based on this MTU to optimize performance @@ -82,7 +82,7 @@ class WEBRTC_DLLEXPORT ViENetwork { // Forward (audio) packet to bandwidth estimator for the given video channel, // for aggregated audio+video BWE. virtual int ReceivedBWEPacket(const int video_channel, - int64_t arrival_time_ms, int payload_size, const RTPHeader& header) { + int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header) { return 0; } diff --git a/webrtc/video_engine/include/vie_render.h b/webrtc/video_engine/include/vie_render.h index 2c9b0f55b3..5cceb723d8 100644 --- a/webrtc/video_engine/include/vie_render.h +++ b/webrtc/video_engine/include/vie_render.h @@ -36,7 +36,7 @@ class ExternalRenderer { // This method is called when a new frame should be rendered. virtual int DeliverFrame(unsigned char* buffer, - int buffer_size, + size_t buffer_size, // RTP timestamp in 90kHz. uint32_t timestamp, // NTP time of the capture time in local timebase diff --git a/webrtc/video_engine/include/vie_rtp_rtcp.h b/webrtc/video_engine/include/vie_rtp_rtcp.h index fdf96bbc4c..f704f741c5 100644 --- a/webrtc/video_engine/include/vie_rtp_rtcp.h +++ b/webrtc/video_engine/include/vie_rtp_rtcp.h @@ -351,9 +351,9 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP { // TODO(sprang): Temporary hacks to prevent libjingle build from failing, // remove when libjingle has been lifted to support webrtc issue 2589 virtual int GetRTPStatistics(const int video_channel, - unsigned int& bytes_sent, + size_t& bytes_sent, unsigned int& packets_sent, - unsigned int& bytes_received, + size_t& bytes_received, unsigned int& packets_received) const { StreamDataCounters sent; StreamDataCounters received; diff --git a/webrtc/video_engine/test/auto_test/automated/vie_network_test.cc b/webrtc/video_engine/test/auto_test/automated/vie_network_test.cc index 206d055524..9c77674a62 100644 --- a/webrtc/video_engine/test/auto_test/automated/vie_network_test.cc +++ b/webrtc/video_engine/test/auto_test/automated/vie_network_test.cc @@ -27,11 +27,13 @@ class RtcpCollectorTransport : public webrtc::Transport { virtual int SendPacket(int /*channel*/, const void* /*data*/, - int /*len*/) OVERRIDE { + size_t /*len*/) OVERRIDE { EXPECT_TRUE(false); return 0; } - virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE { + virtual int SendRTCPPacket(int channel, + const void* data, + size_t len) OVERRIDE { const uint8_t* buf = static_cast(data); webrtc::RtpUtility::RtpHeaderParser parser(buf, len); if (parser.RTCP()) { @@ -39,7 +41,7 @@ class RtcpCollectorTransport : public webrtc::Transport { p.channel = channel; p.length = len; if (parser.ParseRtcp(&p.header)) { - if (p.header.payloadType == 201) { + if (p.header.payloadType == 201 && len >= 20) { buf += 20; len -= 20; } else { @@ -68,20 +70,20 @@ class RtcpCollectorTransport : public webrtc::Transport { struct Packet { Packet() : channel(-1), length(0), header(), remb_bitrate(0), remb_ssrc() {} int channel; - int length; + size_t length; webrtc::RTPHeader header; double remb_bitrate; std::vector remb_ssrc; }; - bool TryParseREMB(const uint8_t* buf, int length, Packet* p) { + bool TryParseREMB(const uint8_t* buf, size_t length, Packet* p) { if (length < 8) { return false; } if (buf[0] != 'R' || buf[1] != 'E' || buf[2] != 'M' || buf[3] != 'B') { return false; } - uint8_t ssrcs = buf[4]; + size_t ssrcs = buf[4]; uint8_t exp = buf[5] >> 2; uint32_t mantissa = ((buf[5] & 0x03) << 16) + (buf[6] << 8) + buf[7]; double bitrate = mantissa * static_cast(1 << exp); @@ -91,7 +93,7 @@ class RtcpCollectorTransport : public webrtc::Transport { return false; } buf += 8; - for (uint8_t i = 0; i < ssrcs; ++i) { + for (size_t i = 0; i < ssrcs; ++i) { uint32_t ssrc = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]; p->remb_ssrc.push_back(ssrc); buf += 4; diff --git a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.cc b/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.cc index e623ced297..f50a40f13e 100644 --- a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.cc +++ b/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.cc @@ -40,7 +40,7 @@ class LocalRendererEffectFilter : public webrtc::ExternalRendererEffectFilter { FrameDropDetector* frame_drop_detector) : ExternalRendererEffectFilter(renderer), frame_drop_detector_(frame_drop_detector) {} - int Transform(int size, + int Transform(size_t size, unsigned char* frame_buffer, int64_t ntp_time_ms, unsigned int timestamp, @@ -100,7 +100,7 @@ class DecodedTimestampEffectFilter : public webrtc::ViEEffectFilter { explicit DecodedTimestampEffectFilter(FrameDropDetector* frame_drop_detector) : frame_drop_detector_(frame_drop_detector) {} virtual ~DecodedTimestampEffectFilter() {} - virtual int Transform(int size, + virtual int Transform(size_t size, unsigned char* frame_buffer, int64_t ntp_time_ms, unsigned int timestamp, @@ -593,7 +593,7 @@ int FrameDropDetector::GetNumberOfFramesDroppedAt(State state) { } int FrameDropMonitoringRemoteFileRenderer::DeliverFrame( - unsigned char *buffer, int buffer_size, uint32_t time_stamp, + unsigned char *buffer, size_t buffer_size, uint32_t time_stamp, int64_t ntp_time_ms, int64_t render_time, void* /*handle*/) { // |render_time| provides the ideal render time for this frame. If that time // has already passed we will render it immediately. diff --git a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h b/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h index 1dd2f58d48..bcafe9021f 100644 --- a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h +++ b/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h @@ -224,7 +224,8 @@ class FrameDropMonitoringRemoteFileRenderer : public ViEToFileRenderer { // Implementation of ExternalRenderer: int FrameSizeChange(unsigned int width, unsigned int height, unsigned int number_of_streams) OVERRIDE; - int DeliverFrame(unsigned char* buffer, int buffer_size, + int DeliverFrame(unsigned char* buffer, + size_t buffer_size, uint32_t time_stamp, int64_t ntp_time_ms, int64_t render_time, diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc index 4fd601264a..3f3c3a614b 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc @@ -83,7 +83,7 @@ class CaptureEffectFilter : public webrtc::ViEEffectFilter { } // Implements video_engineEffectFilter. - virtual int Transform(int size, + virtual int Transform(size_t size, unsigned char* frame_buffer, int64_t ntp_time_ms, unsigned int timestamp, @@ -445,7 +445,7 @@ void ViEAutoTest::ViECaptureExternalCaptureTest() { /// ************************************************************** // Engine ready. Begin testing class /// ************************************************************** - const unsigned int video_frame_length = (176 * 144 * 3) / 2; + const size_t video_frame_length = (176 * 144 * 3) / 2; unsigned char* video_frame = new unsigned char[video_frame_length]; memset(video_frame, 128, 176 * 144); diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_codec.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_codec.cc index 93738c2a17..8bd579f432 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_codec.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_codec.cc @@ -122,7 +122,7 @@ class RenderFilter : public webrtc::ViEEffectFilter { virtual ~RenderFilter() { } - virtual int Transform(int size, + virtual int Transform(size_t size, unsigned char* frame_buffer, int64_t ntp_time_ms, unsigned int timestamp, diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_image_process.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_image_process.cc index c6f0a05981..51ed85bf43 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_image_process.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_image_process.cc @@ -28,7 +28,7 @@ public: ~MyEffectFilter() {} - virtual int Transform(int size, + virtual int Transform(size_t size, unsigned char* frame_buffer, int64_t ntp_time_ms, unsigned int timestamp, diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_render.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_render.cc index 1e9155f99f..889e907cbb 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_render.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_render.cc @@ -12,6 +12,7 @@ // vie_autotest_render.cc // +#include "webrtc/base/format_macros.h" #include "webrtc/engine_configurations.h" #include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" #include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" @@ -57,14 +58,14 @@ public: } virtual int DeliverFrame(unsigned char* buffer, - int bufferSize, + size_t bufferSize, uint32_t time_stamp, int64_t ntp_time_ms, int64_t render_time, void* /*handle*/) { if (bufferSize != CalcBufferSize(webrtc::kI420, _width, _height)) { - ViETest::Log("Incorrect render buffer received, of length = %d\n", - bufferSize); + ViETest::Log("Incorrect render buffer received, of length = %" PRIuS + "\n", bufferSize); return 0; } return 0; diff --git a/webrtc/video_engine/test/libvietest/helpers/vie_file_capture_device.cc b/webrtc/video_engine/test/libvietest/helpers/vie_file_capture_device.cc index b86ff0926a..7c6f5d0ccd 100644 --- a/webrtc/video_engine/test/libvietest/helpers/vie_file_capture_device.cc +++ b/webrtc/video_engine/test/libvietest/helpers/vie_file_capture_device.cc @@ -80,7 +80,7 @@ void ViEFileCaptureDevice::ReadFileFor(uint64_t time_slice_ms, while (elapsed_ms < time_slice_ms) { FramePacemaker pacemaker(max_fps); - int read = fread(frame_buffer, 1, frame_length_, input_file_); + size_t read = fread(frame_buffer, 1, frame_length_, input_file_); if (feof(input_file_)) { rewind(input_file_); diff --git a/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc b/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc index 16c73f4e6f..33e88391b4 100644 --- a/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc +++ b/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc @@ -20,7 +20,7 @@ namespace test { struct Frame { public: Frame(unsigned char* buffer, - int buffer_size, + size_t buffer_size, uint32_t timestamp, int64_t render_time) : buffer(new unsigned char[buffer_size]), @@ -31,7 +31,7 @@ struct Frame { } webrtc::scoped_ptr buffer; - int buffer_size; + size_t buffer_size; uint32_t timestamp; int64_t render_time; @@ -121,7 +121,7 @@ void ViEToFileRenderer::ForgetOutputFile() { } int ViEToFileRenderer::DeliverFrame(unsigned char *buffer, - int buffer_size, + size_t buffer_size, uint32_t time_stamp, int64_t ntp_time_ms, int64_t render_time, @@ -174,8 +174,8 @@ bool ViEToFileRenderer::ProcessRenderQueue() { // the renderer. frame_queue_cs_->Leave(); assert(output_file_); - int written = fwrite(frame->buffer.get(), sizeof(unsigned char), - frame->buffer_size, output_file_); + size_t written = fwrite(frame->buffer.get(), sizeof(unsigned char), + frame->buffer_size, output_file_); frame_queue_cs_->Enter(); // Return the frame. free_frame_queue_.push_front(frame); diff --git a/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h b/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h index 2037ba910d..484afd59fd 100644 --- a/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h +++ b/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h @@ -26,7 +26,7 @@ public: virtual int32_t InitEncode(const webrtc::VideoCodec* codecSettings, int32_t numberOfCores, - uint32_t maxPayloadSize) OVERRIDE; + size_t maxPayloadSize) OVERRIDE; virtual int32_t Encode( const webrtc::I420VideoFrame& inputImage, diff --git a/webrtc/video_engine/test/libvietest/include/tb_external_transport.h b/webrtc/video_engine/test/libvietest/include/tb_external_transport.h index b4518a3fb0..b713aee9f0 100644 --- a/webrtc/video_engine/test/libvietest/include/tb_external_transport.h +++ b/webrtc/video_engine/test/libvietest/include/tb_external_transport.h @@ -85,8 +85,10 @@ public: TbExternalTransport::SsrcChannelMap* receive_channels); ~TbExternalTransport(void); - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE; - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE; + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE; + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE; // Should only be called before/after traffic is being processed. // Only one observer can be set (multiple calls will overwrite each other). @@ -139,7 +141,7 @@ private: typedef struct { int8_t packetBuffer[KMaxPacketSize]; - int32_t length; + size_t length; int32_t channel; int64_t receiveTime; } VideoPacket; diff --git a/webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h b/webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h index 039a1fd0fb..057f6c8011 100644 --- a/webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h +++ b/webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h @@ -24,7 +24,7 @@ class ExternalRendererEffectFilter : public webrtc::ViEEffectFilter { explicit ExternalRendererEffectFilter(webrtc::ExternalRenderer* renderer) : width_(0), height_(0), renderer_(renderer) {} virtual ~ExternalRendererEffectFilter() {} - virtual int Transform(int size, + virtual int Transform(size_t size, unsigned char* frame_buffer, int64_t ntp_time_ms, unsigned int timestamp, diff --git a/webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h b/webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h index e23dad2ad4..dccf262487 100644 --- a/webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h +++ b/webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h @@ -58,7 +58,7 @@ class ViEToFileRenderer: public webrtc::ExternalRenderer { unsigned int number_of_streams) OVERRIDE; int DeliverFrame(unsigned char* buffer, - int buffer_size, + size_t buffer_size, uint32_t time_stamp, int64_t ntp_time_ms, int64_t render_time, diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc b/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc index f807fd58a1..747e06e7e6 100644 --- a/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc +++ b/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc @@ -53,7 +53,7 @@ int32_t TbI420Encoder::SetChannelParameters(uint32_t packetLoss, int rtt) { int32_t TbI420Encoder::InitEncode(const webrtc::VideoCodec* inst, int32_t /*numberOfCores*/, - uint32_t /*maxPayloadSize */) + size_t /*maxPayloadSize */) { _functionCalls.InitEncode++; if (inst == NULL) @@ -105,9 +105,9 @@ int32_t TbI420Encoder::Encode( _encodedImage._timeStamp = inputImage.timestamp(); _encodedImage._encodedHeight = inputImage.height(); _encodedImage._encodedWidth = inputImage.width(); - unsigned int reqSize = webrtc::CalcBufferSize(webrtc::kI420, - _encodedImage._encodedWidth, - _encodedImage._encodedHeight); + size_t reqSize = webrtc::CalcBufferSize(webrtc::kI420, + _encodedImage._encodedWidth, + _encodedImage._encodedHeight); if (reqSize > _encodedImage._size) { @@ -232,8 +232,8 @@ int32_t TbI420Decoder::Decode( } // Only send complete frames. - if (static_cast(inputImage._length) != - webrtc::CalcBufferSize(webrtc::kI420,_width,_height)) { + if (webrtc::CalcBufferSize(webrtc::kI420,_width,_height) != + inputImage._length) { return WEBRTC_VIDEO_CODEC_ERROR; } diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc b/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc index 7ccedc2f10..4698b1ce0b 100644 --- a/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc +++ b/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc @@ -107,7 +107,7 @@ TbExternalTransport::~TbExternalTransport() delete &_statCrit; } -int TbExternalTransport::SendPacket(int channel, const void *data, int len) +int TbExternalTransport::SendPacket(int channel, const void *data, size_t len) { // Parse timestamp from RTP header according to RFC 3550, section 5.1. uint8_t* ptr = (uint8_t*)data; @@ -137,7 +137,7 @@ int TbExternalTransport::SendPacket(int channel, const void *data, int len) ssrc += ptr[11]; if (ssrc != _SSRC) { - return len; // return len to avoid error in trace file + return static_cast(len); // avoid error in trace file } } if (_temporalLayers) { @@ -182,7 +182,7 @@ int TbExternalTransport::SendPacket(int channel, const void *data, int len) } if (_currentRelayLayer < TID) { - return len; // return len to avoid error in trace file + return static_cast(len); // avoid error in trace file } if (ptr[14] & 0x80) // 2 byte PID { @@ -227,7 +227,7 @@ int TbExternalTransport::SendPacket(int channel, const void *data, int len) _statCrit.Enter(); _dropCount++; _statCrit.Leave(); - return len; + return static_cast(len); } VideoPacket* newPacket = new VideoPacket(); @@ -266,7 +266,7 @@ int TbExternalTransport::SendPacket(int channel, const void *data, int len) _rtpPackets.push_back(newPacket); _event.Set(); _crit.Leave(); - return len; + return static_cast(len); } void TbExternalTransport::RegisterSendFrameCallback( @@ -285,7 +285,9 @@ void TbExternalTransport::SetTemporalToggle(unsigned char layers) _temporalLayers = layers; } -int TbExternalTransport::SendRTCPPacket(int channel, const void *data, int len) +int TbExternalTransport::SendRTCPPacket(int channel, + const void *data, + size_t len) { _statCrit.Enter(); _rtcpCount++; @@ -304,7 +306,7 @@ int TbExternalTransport::SendRTCPPacket(int channel, const void *data, int len) _rtcpPackets.push_back(newPacket); _event.Set(); _crit.Leave(); - return len; + return static_cast(len); } void TbExternalTransport::SetNetworkParameters( diff --git a/webrtc/video_engine/vie_capturer.cc b/webrtc/video_engine/vie_capturer.cc index 31cbadcd0d..5440b09216 100644 --- a/webrtc/video_engine/vie_capturer.cc +++ b/webrtc/video_engine/vie_capturer.cc @@ -279,7 +279,7 @@ int32_t ViECapturer::SetRotateCapturedFrames( } int ViECapturer::IncomingFrame(unsigned char* video_frame, - unsigned int video_frame_length, + size_t video_frame_length, uint16_t width, uint16_t height, RawVideoType video_type, @@ -522,9 +522,8 @@ void ViECapturer::DeliverI420Frame(I420VideoFrame* video_frame) { } } if (effect_filter_) { - unsigned int length = CalcBufferSize(kI420, - video_frame->width(), - video_frame->height()); + size_t length = + CalcBufferSize(kI420, video_frame->width(), video_frame->height()); scoped_ptr video_buffer(new uint8_t[length]); ExtractBuffer(*video_frame, length, video_buffer.get()); effect_filter_->Transform(length, diff --git a/webrtc/video_engine/vie_capturer.h b/webrtc/video_engine/vie_capturer.h index fdee5d8878..0ed5d95937 100644 --- a/webrtc/video_engine/vie_capturer.h +++ b/webrtc/video_engine/vie_capturer.h @@ -69,7 +69,7 @@ class ViECapturer // Implements ExternalCapture. virtual int IncomingFrame(unsigned char* video_frame, - unsigned int video_frame_length, + size_t video_frame_length, uint16_t width, uint16_t height, RawVideoType video_type, diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc index 270da2a252..60ab009620 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -1128,9 +1128,9 @@ void ViEChannel::RegisterReceiveChannelRtcpStatisticsCallback( callback); } -int32_t ViEChannel::GetRtpStatistics(uint32_t* bytes_sent, +int32_t ViEChannel::GetRtpStatistics(size_t* bytes_sent, uint32_t* packets_sent, - uint32_t* bytes_received, + size_t* bytes_received, uint32_t* packets_received) const { StreamStatistician* statistician = vie_receiver_.GetReceiveStatistics()-> GetStatistician(vie_receiver_.GetRemoteSsrc()); @@ -1145,7 +1145,7 @@ int32_t ViEChannel::GetRtpStatistics(uint32_t* bytes_sent, for (std::list::const_iterator it = simulcast_rtp_rtcp_.begin(); it != simulcast_rtp_rtcp_.end(); it++) { - uint32_t bytes_sent_temp = 0; + size_t bytes_sent_temp = 0; uint32_t packets_sent_temp = 0; RtpRtcp* rtp_rtcp = *it; rtp_rtcp->DataCountersRTP(&bytes_sent_temp, &packets_sent_temp); @@ -1154,7 +1154,7 @@ int32_t ViEChannel::GetRtpStatistics(uint32_t* bytes_sent, } for (std::list::const_iterator it = removed_rtp_rtcp_.begin(); it != removed_rtp_rtcp_.end(); ++it) { - uint32_t bytes_sent_temp = 0; + size_t bytes_sent_temp = 0; uint32_t packets_sent_temp = 0; RtpRtcp* rtp_rtcp = *it; rtp_rtcp->DataCountersRTP(&bytes_sent_temp, &packets_sent_temp); @@ -1395,7 +1395,7 @@ int32_t ViEChannel::DeregisterSendTransport() { } int32_t ViEChannel::ReceivedRTPPacket( - const void* rtp_packet, const int32_t rtp_packet_length, + const void* rtp_packet, const size_t rtp_packet_length, const PacketTime& packet_time) { { CriticalSectionScoped cs(callback_cs_.get()); @@ -1408,7 +1408,7 @@ int32_t ViEChannel::ReceivedRTPPacket( } int32_t ViEChannel::ReceivedRTCPPacket( - const void* rtcp_packet, const int32_t rtcp_packet_length) { + const void* rtcp_packet, const size_t rtcp_packet_length) { { CriticalSectionScoped cs(callback_cs_.get()); if (!external_transport_) { @@ -1475,9 +1475,8 @@ int32_t ViEChannel::FrameToRender( if (pre_render_callback_ != NULL) pre_render_callback_->FrameCallback(&video_frame); if (effect_filter_) { - unsigned int length = CalcBufferSize(kI420, - video_frame.width(), - video_frame.height()); + size_t length = + CalcBufferSize(kI420, video_frame.width(), video_frame.height()); scoped_ptr video_buffer(new uint8_t[length]); ExtractBuffer(video_frame, length, video_buffer.get()); effect_filter_->Transform(length, @@ -1763,7 +1762,8 @@ void ViEChannel::RegisterSendFrameCountObserver( } void ViEChannel::ReceivedBWEPacket(int64_t arrival_time_ms, - int payload_size, const RTPHeader& header) { + size_t payload_size, + const RTPHeader& header) { vie_receiver_.ReceivedBWEPacket(arrival_time_ms, payload_size, header); } } // namespace webrtc diff --git a/webrtc/video_engine/vie_channel.h b/webrtc/video_engine/vie_channel.h index 97b158784b..3f2621aab8 100644 --- a/webrtc/video_engine/vie_channel.h +++ b/webrtc/video_engine/vie_channel.h @@ -189,9 +189,9 @@ class ViEChannel RtcpStatisticsCallback* callback); // Gets sent/received packets statistics. - int32_t GetRtpStatistics(uint32_t* bytes_sent, + int32_t GetRtpStatistics(size_t* bytes_sent, uint32_t* packets_sent, - uint32_t* bytes_received, + size_t* bytes_received, uint32_t* packets_received) const; // Called on update of RTP statistics. @@ -272,12 +272,12 @@ class ViEChannel // Incoming packet from external transport. int32_t ReceivedRTPPacket(const void* rtp_packet, - const int32_t rtp_packet_length, + const size_t rtp_packet_length, const PacketTime& packet_time); // Incoming packet from external transport. int32_t ReceivedRTCPPacket(const void* rtcp_packet, - const int32_t rtcp_packet_length); + const size_t rtcp_packet_length); // Sets the maximum transfer unit size for the network link, i.e. including // IP, UDP and RTP headers. @@ -346,7 +346,7 @@ class ViEChannel void RegisterSendFrameCountObserver(FrameCountObserver* observer); - void ReceivedBWEPacket(int64_t arrival_time_ms, int payload_size, + void ReceivedBWEPacket(int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header); protected: diff --git a/webrtc/video_engine/vie_channel_group.cc b/webrtc/video_engine/vie_channel_group.cc index 9c2d59f014..a4bba8067c 100644 --- a/webrtc/video_engine/vie_channel_group.cc +++ b/webrtc/video_engine/vie_channel_group.cc @@ -53,7 +53,7 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator { virtual ~WrappingBitrateEstimator() {} virtual void IncomingPacket(int64_t arrival_time_ms, - int payload_size, + size_t payload_size, const RTPHeader& header) OVERRIDE { CriticalSectionScoped cs(crit_sect_.get()); PickEstimatorFromHeader(header); diff --git a/webrtc/video_engine/vie_encoder.cc b/webrtc/video_engine/vie_encoder.cc index 3cb0ae7043..a5ac55a23b 100644 --- a/webrtc/video_engine/vie_encoder.cc +++ b/webrtc/video_engine/vie_encoder.cc @@ -117,7 +117,7 @@ class ViEPacedSenderCallback : public PacedSender::Callback { return owner_->TimeToSendPacket(ssrc, sequence_number, capture_time_ms, retransmission); } - virtual int TimeToSendPadding(int bytes) { + virtual size_t TimeToSendPadding(size_t bytes) { return owner_->TimeToSendPadding(bytes); } private: @@ -443,7 +443,7 @@ bool ViEEncoder::TimeToSendPacket(uint32_t ssrc, capture_time_ms, retransmission); } -int ViEEncoder::TimeToSendPadding(int bytes) { +size_t ViEEncoder::TimeToSendPadding(size_t bytes) { bool send_padding; { CriticalSectionScoped cs(data_cs_.get()); @@ -546,7 +546,7 @@ void ViEEncoder::DeliverFrame(int id, { CriticalSectionScoped cs(callback_cs_.get()); if (effect_filter_) { - unsigned int length = + size_t length = CalcBufferSize(kI420, video_frame->width(), video_frame->height()); scoped_ptr video_buffer(new uint8_t[length]); ExtractBuffer(*video_frame, length, video_buffer.get()); @@ -731,7 +731,7 @@ int32_t ViEEncoder::SendData( const uint32_t time_stamp, int64_t capture_time_ms, const uint8_t* payload_data, - const uint32_t payload_size, + const size_t payload_size, const webrtc::RTPFragmentationHeader& fragmentation_header, const RTPVideoHeader* rtp_video_hdr) { // New encoded data, hand over to the rtp module. diff --git a/webrtc/video_engine/vie_encoder.h b/webrtc/video_engine/vie_encoder.h index 1e358def18..effb78f3f0 100644 --- a/webrtc/video_engine/vie_encoder.h +++ b/webrtc/video_engine/vie_encoder.h @@ -127,7 +127,7 @@ class ViEEncoder uint32_t time_stamp, int64_t capture_time_ms, const uint8_t* payload_data, - uint32_t payload_size, + size_t payload_size, const RTPFragmentationHeader& fragmentation_header, const RTPVideoHeader* rtp_video_hdr) OVERRIDE; @@ -189,7 +189,7 @@ class ViEEncoder // Called by PacedSender. bool TimeToSendPacket(uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms, bool retransmission); - int TimeToSendPadding(int bytes); + size_t TimeToSendPadding(size_t bytes); private: bool EncoderPaused() const EXCLUSIVE_LOCKS_REQUIRED(data_cs_); void TraceFrameDropStart() EXCLUSIVE_LOCKS_REQUIRED(data_cs_); diff --git a/webrtc/video_engine/vie_network_impl.cc b/webrtc/video_engine/vie_network_impl.cc index 4a9d866585..aafcd2dce1 100644 --- a/webrtc/video_engine/vie_network_impl.cc +++ b/webrtc/video_engine/vie_network_impl.cc @@ -111,7 +111,7 @@ int ViENetworkImpl::DeregisterSendTransport(const int video_channel) { } int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data, - const int length, + const size_t length, const PacketTime& packet_time) { ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); ViEChannel* vie_channel = cs.Channel(video_channel); @@ -123,7 +123,7 @@ int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data, } int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel, - const void* data, const int length) { + const void* data, const size_t length) { ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); ViEChannel* vie_channel = cs.Channel(video_channel); if (!vie_channel) { @@ -149,7 +149,9 @@ int ViENetworkImpl::SetMTU(int video_channel, unsigned int mtu) { } int ViENetworkImpl::ReceivedBWEPacket(const int video_channel, - int64_t arrival_time_ms, int payload_size, const RTPHeader& header) { + int64_t arrival_time_ms, + size_t payload_size, + const RTPHeader& header) { ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); ViEChannel* vie_channel = cs.Channel(video_channel); if (!vie_channel) { diff --git a/webrtc/video_engine/vie_network_impl.h b/webrtc/video_engine/vie_network_impl.h index e9ca75469d..cf2c72efe2 100644 --- a/webrtc/video_engine/vie_network_impl.h +++ b/webrtc/video_engine/vie_network_impl.h @@ -32,16 +32,16 @@ class ViENetworkImpl virtual int DeregisterSendTransport(const int video_channel) OVERRIDE; virtual int ReceivedRTPPacket(const int video_channel, const void* data, - const int length, + const size_t length, const PacketTime& packet_time) OVERRIDE; virtual int ReceivedRTCPPacket(const int video_channel, const void* data, - const int length) OVERRIDE; + const size_t length) OVERRIDE; virtual int SetMTU(int video_channel, unsigned int mtu) OVERRIDE; virtual int ReceivedBWEPacket(const int video_channel, int64_t arrival_time_ms, - int payload_size, + size_t payload_size, const RTPHeader& header) OVERRIDE; virtual bool SetBandwidthEstimationConfig( diff --git a/webrtc/video_engine/vie_receiver.cc b/webrtc/video_engine/vie_receiver.cc index 0501ec31af..8f359bf7da 100644 --- a/webrtc/video_engine/vie_receiver.cc +++ b/webrtc/video_engine/vie_receiver.cc @@ -165,21 +165,21 @@ bool ViEReceiver::SetReceiveAbsoluteSendTimeStatus(bool enable, int id) { } int ViEReceiver::ReceivedRTPPacket(const void* rtp_packet, - int rtp_packet_length, + size_t rtp_packet_length, const PacketTime& packet_time) { return InsertRTPPacket(static_cast(rtp_packet), rtp_packet_length, packet_time); } int ViEReceiver::ReceivedRTCPPacket(const void* rtcp_packet, - int rtcp_packet_length) { + size_t rtcp_packet_length) { return InsertRTCPPacket(static_cast(rtcp_packet), rtcp_packet_length); } -int32_t ViEReceiver::OnReceivedPayloadData( - const uint8_t* payload_data, const uint16_t payload_size, - const WebRtcRTPHeader* rtp_header) { +int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data, + const size_t payload_size, + const WebRtcRTPHeader* rtp_header) { WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; rtp_header_with_ntp.ntp_time_ms = ntp_estimator_->Estimate(rtp_header->header.timestamp); @@ -193,7 +193,7 @@ int32_t ViEReceiver::OnReceivedPayloadData( } bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, - int rtp_packet_length) { + size_t rtp_packet_length) { RTPHeader header; if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { return false; @@ -204,7 +204,7 @@ bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, } void ViEReceiver::ReceivedBWEPacket( - int64_t arrival_time_ms, int payload_size, const RTPHeader& header) { + int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header) { // Only forward if the incoming packet *and* the channel are both configured // to receive absolute sender time. RTP time stamps may have different rates // for audio and video and shouldn't be mixed. @@ -215,7 +215,7 @@ void ViEReceiver::ReceivedBWEPacket( } int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet, - int rtp_packet_length, + size_t rtp_packet_length, const PacketTime& packet_time) { { CriticalSectionScoped cs(receive_cs_.get()); @@ -223,8 +223,7 @@ int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet, return -1; } if (rtp_dump_) { - rtp_dump_->DumpPacket(rtp_packet, - static_cast(rtp_packet_length)); + rtp_dump_->DumpPacket(rtp_packet, rtp_packet_length); } } @@ -233,7 +232,7 @@ int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet, &header)) { return -1; } - int payload_length = rtp_packet_length - header.headerLength; + size_t payload_length = rtp_packet_length - header.headerLength; int64_t arrival_time_ms; int64_t now_ms = clock_->TimeInMilliseconds(); if (packet_time.timestamp != -1) @@ -277,15 +276,15 @@ int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet, } bool ViEReceiver::ReceivePacket(const uint8_t* packet, - int packet_length, + size_t packet_length, const RTPHeader& header, bool in_order) { if (rtp_payload_registry_->IsEncapsulated(header)) { return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); } const uint8_t* payload = packet + header.headerLength; - int payload_length = packet_length - header.headerLength; - assert(payload_length >= 0); + assert(packet_length >= header.headerLength); + size_t payload_length = packet_length - header.headerLength; PayloadUnion payload_specific; if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, &payload_specific)) { @@ -296,7 +295,7 @@ bool ViEReceiver::ReceivePacket(const uint8_t* packet, } bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet, - int packet_length, + size_t packet_length, const RTPHeader& header) { if (rtp_payload_registry_->IsRed(header)) { int8_t ulpfec_pt = rtp_payload_registry_->ulpfec_payload_type(); @@ -316,7 +315,7 @@ bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet, // Remove the RTX header and parse the original RTP header. if (packet_length < header.headerLength) return false; - if (packet_length > static_cast(sizeof(restored_packet_))) + if (packet_length > sizeof(restored_packet_)) return false; CriticalSectionScoped cs(receive_cs_.get()); if (restored_packet_in_use_) { @@ -339,7 +338,7 @@ bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet, } int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet, - int rtcp_packet_length) { + size_t rtcp_packet_length) { { CriticalSectionScoped cs(receive_cs_.get()); if (!receiving_) { @@ -347,8 +346,7 @@ int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet, } if (rtp_dump_) { - rtp_dump_->DumpPacket( - rtcp_packet, static_cast(rtcp_packet_length)); + rtp_dump_->DumpPacket(rtcp_packet, rtcp_packet_length); } std::list::iterator it = rtp_rtcp_simulcast_.begin(); diff --git a/webrtc/video_engine/vie_receiver.h b/webrtc/video_engine/vie_receiver.h index e9d28f33a8..a7b238bf0d 100644 --- a/webrtc/video_engine/vie_receiver.h +++ b/webrtc/video_engine/vie_receiver.h @@ -69,38 +69,38 @@ class ViEReceiver : public RtpData { int StopRTPDump(); // Receives packets from external transport. - int ReceivedRTPPacket(const void* rtp_packet, int rtp_packet_length, + int ReceivedRTPPacket(const void* rtp_packet, size_t rtp_packet_length, const PacketTime& packet_time); - int ReceivedRTCPPacket(const void* rtcp_packet, int rtcp_packet_length); + int ReceivedRTCPPacket(const void* rtcp_packet, size_t rtcp_packet_length); // Implements RtpData. virtual int32_t OnReceivedPayloadData( const uint8_t* payload_data, - const uint16_t payload_size, + const size_t payload_size, const WebRtcRTPHeader* rtp_header) OVERRIDE; virtual bool OnRecoveredPacket(const uint8_t* packet, - int packet_length) OVERRIDE; + size_t packet_length) OVERRIDE; void GetReceiveBandwidthEstimatorStats( ReceiveBandwidthEstimatorStats* output) const; ReceiveStatistics* GetReceiveStatistics() const; - void ReceivedBWEPacket(int64_t arrival_time_ms, int payload_size, + void ReceivedBWEPacket(int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header); private: - int InsertRTPPacket(const uint8_t* rtp_packet, int rtp_packet_length, + int InsertRTPPacket(const uint8_t* rtp_packet, size_t rtp_packet_length, const PacketTime& packet_time); bool ReceivePacket(const uint8_t* packet, - int packet_length, + size_t packet_length, const RTPHeader& header, bool in_order); // Parses and handles for instance RTX and RED headers. // This function assumes that it's being called from only one thread. bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet, - int packet_length, + size_t packet_length, const RTPHeader& header); - int InsertRTCPPacket(const uint8_t* rtcp_packet, int rtcp_packet_length); + int InsertRTCPPacket(const uint8_t* rtcp_packet, size_t rtcp_packet_length); bool IsPacketInOrder(const RTPHeader& header) const; bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; diff --git a/webrtc/video_engine/vie_renderer.cc b/webrtc/video_engine/vie_renderer.cc index b4ec73828d..2f1c136be9 100644 --- a/webrtc/video_engine/vie_renderer.cc +++ b/webrtc/video_engine/vie_renderer.cc @@ -195,9 +195,9 @@ int32_t ViEExternalRendererImpl::RenderFrame( // Convert to requested format. VideoType type = RawVideoTypeToCommonVideoVideoType(external_renderer_format_); - int buffer_size = CalcBufferSize(type, video_frame.width(), - video_frame.height()); - if (buffer_size <= 0) { + size_t buffer_size = CalcBufferSize(type, video_frame.width(), + video_frame.height()); + if (buffer_size == 0) { // Unsupported video format. assert(false); return -1; diff --git a/webrtc/video_engine/vie_sender.cc b/webrtc/video_engine/vie_sender.cc index 28bf390334..db7a5b116d 100644 --- a/webrtc/video_engine/vie_sender.cc +++ b/webrtc/video_engine/vie_sender.cc @@ -85,7 +85,7 @@ int ViESender::StopRTPDump() { return 0; } -int ViESender::SendPacket(int vie_id, const void* data, int len) { +int ViESender::SendPacket(int vie_id, const void* data, size_t len) { CriticalSectionScoped cs(critsect_.get()); if (!transport_) { // No transport @@ -94,14 +94,13 @@ int ViESender::SendPacket(int vie_id, const void* data, int len) { assert(ChannelId(vie_id) == channel_id_); if (rtp_dump_) { - rtp_dump_->DumpPacket(static_cast(data), - static_cast(len)); + rtp_dump_->DumpPacket(static_cast(data), len); } return transport_->SendPacket(channel_id_, data, len); } -int ViESender::SendRTCPPacket(int vie_id, const void* data, int len) { +int ViESender::SendRTCPPacket(int vie_id, const void* data, size_t len) { CriticalSectionScoped cs(critsect_.get()); if (!transport_) { return -1; @@ -109,8 +108,7 @@ int ViESender::SendRTCPPacket(int vie_id, const void* data, int len) { assert(ChannelId(vie_id) == channel_id_); if (rtp_dump_) { - rtp_dump_->DumpPacket(static_cast(data), - static_cast(len)); + rtp_dump_->DumpPacket(static_cast(data), len); } return transport_->SendRTCPPacket(channel_id_, data, len); diff --git a/webrtc/video_engine/vie_sender.h b/webrtc/video_engine/vie_sender.h index f910cb1af6..8423a54aac 100644 --- a/webrtc/video_engine/vie_sender.h +++ b/webrtc/video_engine/vie_sender.h @@ -40,8 +40,8 @@ class ViESender: public Transport { int StopRTPDump(); // Implements Transport. - virtual int SendPacket(int vie_id, const void* data, int len) OVERRIDE; - virtual int SendRTCPPacket(int vie_id, const void* data, int len) OVERRIDE; + virtual int SendPacket(int vie_id, const void* data, size_t len) OVERRIDE; + virtual int SendRTCPPacket(int vie_id, const void* data, size_t len) OVERRIDE; private: const int32_t channel_id_; diff --git a/webrtc/video_frame.h b/webrtc/video_frame.h index f76b9af373..2c753b9f25 100644 --- a/webrtc/video_frame.h +++ b/webrtc/video_frame.h @@ -189,7 +189,7 @@ class EncodedImage { _size(0), _completeFrame(false) {} - EncodedImage(uint8_t* buffer, uint32_t length, uint32_t size) + EncodedImage(uint8_t* buffer, size_t length, size_t size) : _encodedWidth(0), _encodedHeight(0), _timeStamp(0), @@ -209,8 +209,8 @@ class EncodedImage { int64_t capture_time_ms_; VideoFrameType _frameType; uint8_t* _buffer; - uint32_t _length; - uint32_t _size; + size_t _length; + size_t _size; bool _completeFrame; }; diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index d651d8f76d..91167c0cf1 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -10,6 +10,7 @@ #include "webrtc/voice_engine/channel.h" +#include "webrtc/base/format_macros.h" #include "webrtc/base/timeutils.h" #include "webrtc/common.h" #include "webrtc/modules/audio_device/include/audio_device.h" @@ -112,13 +113,14 @@ Channel::SendData(FrameType frameType, uint8_t payloadType, uint32_t timeStamp, const uint8_t* payloadData, - uint16_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader* fragmentation) { WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::SendData(frameType=%u, payloadType=%u, timeStamp=%u," - " payloadSize=%u, fragmentation=0x%x)", - frameType, payloadType, timeStamp, payloadSize, fragmentation); + " payloadSize=%" PRIuS ", fragmentation=0x%x)", + frameType, payloadType, timeStamp, + payloadSize, fragmentation); if (_includeAudioLevelIndication) { @@ -182,13 +184,14 @@ Channel::OnRxVadDetected(int vadDecision) } int -Channel::SendPacket(int channel, const void *data, int len) +Channel::SendPacket(int channel, const void *data, size_t len) { channel = VoEChannelId(channel); assert(channel == _channelId); WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), - "Channel::SendPacket(channel=%d, len=%d)", channel, len); + "Channel::SendPacket(channel=%d, len=%" PRIuS ")", channel, + len); CriticalSectionScoped cs(&_callbackCritSect); @@ -201,7 +204,7 @@ Channel::SendPacket(int channel, const void *data, int len) } uint8_t* bufferToSendPtr = (uint8_t*)data; - int32_t bufferLength = len; + size_t bufferLength = len; // Dump the RTP packet to a file (if RTP dump is enabled). if (_rtpDumpOut.DumpPacket((const uint8_t*)data, len) == -1) @@ -226,13 +229,14 @@ Channel::SendPacket(int channel, const void *data, int len) } int -Channel::SendRTCPPacket(int channel, const void *data, int len) +Channel::SendRTCPPacket(int channel, const void *data, size_t len) { channel = VoEChannelId(channel); assert(channel == _channelId); WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), - "Channel::SendRTCPPacket(channel=%d, len=%d)", channel, len); + "Channel::SendRTCPPacket(channel=%d, len=%" PRIuS ")", channel, + len); CriticalSectionScoped cs(&_callbackCritSect); if (_transportPtr == NULL) @@ -245,7 +249,7 @@ Channel::SendRTCPPacket(int channel, const void *data, int len) } uint8_t* bufferToSendPtr = (uint8_t*)data; - int32_t bufferLength = len; + size_t bufferLength = len; // Dump the RTCP packet to a file (if RTP dump is enabled). if (_rtpDumpOut.DumpPacket((const uint8_t*)data, len) == -1) @@ -367,11 +371,11 @@ Channel::OnInitializeDecoder( int32_t Channel::OnReceivedPayloadData(const uint8_t* payloadData, - uint16_t payloadSize, + size_t payloadSize, const WebRtcRTPHeader* rtpHeader) { WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), - "Channel::OnReceivedPayloadData(payloadSize=%d," + "Channel::OnReceivedPayloadData(payloadSize=%" PRIuS "," " payloadType=%u, audioChannel=%u)", payloadSize, rtpHeader->header.payloadType, @@ -419,7 +423,7 @@ Channel::OnReceivedPayloadData(const uint8_t* payloadData, } bool Channel::OnRecoveredPacket(const uint8_t* rtp_packet, - int rtp_packet_length) { + size_t rtp_packet_length) { RTPHeader header; if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { WEBRTC_TRACE(kTraceDebug, webrtc::kTraceVoice, _channelId, @@ -1601,7 +1605,7 @@ Channel::DeRegisterExternalTransport() return 0; } -int32_t Channel::ReceivedRTPPacket(const int8_t* data, int32_t length, +int32_t Channel::ReceivedRTPPacket(const int8_t* data, size_t length, const PacketTime& packet_time) { WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::ReceivedRTPPacket()"); @@ -1642,7 +1646,7 @@ int32_t Channel::ReceivedRTPPacket(const int8_t* data, int32_t length, } else { arrival_time_ms = TickTime::MillisecondTimestamp(); } - int payload_length = length - header.headerLength; + size_t payload_length = length - header.headerLength; vie_network_->ReceivedBWEPacket(video_channel_, arrival_time_ms, payload_length, header); } @@ -1652,15 +1656,15 @@ int32_t Channel::ReceivedRTPPacket(const int8_t* data, int32_t length, } bool Channel::ReceivePacket(const uint8_t* packet, - int packet_length, + size_t packet_length, const RTPHeader& header, bool in_order) { if (rtp_payload_registry_->IsEncapsulated(header)) { return HandleEncapsulation(packet, packet_length, header); } const uint8_t* payload = packet + header.headerLength; - int payload_length = packet_length - header.headerLength; - assert(payload_length >= 0); + assert(packet_length >= header.headerLength); + size_t payload_length = packet_length - header.headerLength; PayloadUnion payload_specific; if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, &payload_specific)) { @@ -1671,7 +1675,7 @@ bool Channel::ReceivePacket(const uint8_t* packet, } bool Channel::HandleEncapsulation(const uint8_t* packet, - int packet_length, + size_t packet_length, const RTPHeader& header) { if (!rtp_payload_registry_->IsRtx(header)) return false; @@ -1724,23 +1728,21 @@ bool Channel::IsPacketRetransmitted(const RTPHeader& header, statistician->IsRetransmitOfOldPacket(header, min_rtt); } -int32_t Channel::ReceivedRTCPPacket(const int8_t* data, int32_t length) { +int32_t Channel::ReceivedRTCPPacket(const int8_t* data, size_t length) { WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::ReceivedRTCPPacket()"); // Store playout timestamp for the received RTCP packet UpdatePlayoutTimestamp(true); // Dump the RTCP packet to a file (if RTP dump is enabled). - if (_rtpDumpIn.DumpPacket((const uint8_t*)data, - (uint16_t)length) == -1) { + if (_rtpDumpIn.DumpPacket((const uint8_t*)data, length) == -1) { WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::SendPacket() RTCP dump to input file failed"); } // Deliver RTCP packet to RTP/RTCP module for parsing - if (_rtpRtcpModule->IncomingRtcpPacket((const uint8_t*)data, - (uint16_t)length) == -1) { + if (_rtpRtcpModule->IncomingRtcpPacket((const uint8_t*)data, length) == -1) { _engineStatisticsPtr->SetLastError( VE_SOCKET_TRANSPORT_MODULE_ERROR, kTraceWarning, "Channel::IncomingRTPPacket() RTCP packet is invalid"); @@ -3233,9 +3235,9 @@ Channel::GetRTPStatistics(CallStatistics& stats) // --- Data counters - uint32_t bytesSent(0); + size_t bytesSent(0); uint32_t packetsSent(0); - uint32_t bytesReceived(0); + size_t bytesReceived(0); uint32_t packetsReceived(0); if (statistician) { @@ -3258,8 +3260,8 @@ Channel::GetRTPStatistics(CallStatistics& stats) WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), - "GetRTPStatistics() => bytesSent=%d, packetsSent=%d," - " bytesReceived=%d, packetsReceived=%d)", + "GetRTPStatistics() => bytesSent=%" PRIuS ", packetsSent=%d," + " bytesReceived=%" PRIuS ", packetsReceived=%d)", stats.bytesSent, stats.packetsSent, stats.bytesReceived, stats.packetsReceived); @@ -4051,7 +4053,7 @@ Channel::InsertInbandDtmfTone() } int32_t -Channel::SendPacketRaw(const void *data, int len, bool RTCP) +Channel::SendPacketRaw(const void *data, size_t len, bool RTCP) { CriticalSectionScoped cs(&_callbackCritSect); if (_transportPtr == NULL) diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index 94a34328c0..b729d71dc6 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -214,9 +214,9 @@ public: // VoENetwork int32_t RegisterExternalTransport(Transport& transport); int32_t DeRegisterExternalTransport(); - int32_t ReceivedRTPPacket(const int8_t* data, int32_t length, + int32_t ReceivedRTPPacket(const int8_t* data, size_t length, const PacketTime& packet_time); - int32_t ReceivedRTCPPacket(const int8_t* data, int32_t length); + int32_t ReceivedRTCPPacket(const int8_t* data, size_t length); // VoEFile int StartPlayingFileLocally(const char* fileName, bool loop, @@ -352,7 +352,7 @@ public: uint8_t payloadType, uint32_t timeStamp, const uint8_t* payloadData, - uint16_t payloadSize, + size_t payloadSize, const RTPFragmentationHeader* fragmentation) OVERRIDE; // From ACMVADCallback in the ACM @@ -363,10 +363,10 @@ public: // From RtpData in the RTP/RTCP module virtual int32_t OnReceivedPayloadData( const uint8_t* payloadData, - uint16_t payloadSize, + size_t payloadSize, const WebRtcRTPHeader* rtpHeader) OVERRIDE; virtual bool OnRecoveredPacket(const uint8_t* packet, - int packet_length) OVERRIDE; + size_t packet_length) OVERRIDE; // From RtpFeedback in the RTP/RTCP module virtual int32_t OnInitializeDecoder( @@ -389,10 +389,12 @@ public: uint8_t volume) OVERRIDE; // From Transport (called by the RTP/RTCP module) - virtual int SendPacket(int /*channel*/, const void *data, int len) OVERRIDE; + virtual int SendPacket(int /*channel*/, + const void *data, + size_t len) OVERRIDE; virtual int SendRTCPPacket(int /*channel*/, const void *data, - int len) OVERRIDE; + size_t len) OVERRIDE; // From MixerParticipant virtual int32_t GetAudioFrame(int32_t id, AudioFrame& audioFrame) OVERRIDE; @@ -458,10 +460,10 @@ public: const uint32_t rtt); private: - bool ReceivePacket(const uint8_t* packet, int packet_length, + bool ReceivePacket(const uint8_t* packet, size_t packet_length, const RTPHeader& header, bool in_order); bool HandleEncapsulation(const uint8_t* packet, - int packet_length, + size_t packet_length, const RTPHeader& header); bool IsPacketInOrder(const RTPHeader& header) const; bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; @@ -469,7 +471,7 @@ private: int InsertInbandDtmfTone(); int32_t MixOrReplaceAudioWithFile(int mixingFrequency); int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency); - int32_t SendPacketRaw(const void *data, int len, bool RTCP); + int32_t SendPacketRaw(const void *data, size_t len, bool RTCP); void UpdatePacketDelay(uint32_t timestamp, uint16_t sequenceNumber); void RegisterReceiveCodecsToRTPModule(); diff --git a/webrtc/voice_engine/include/voe_network.h b/webrtc/voice_engine/include/voe_network.h index 67429755a7..ff8b8e1f94 100644 --- a/webrtc/voice_engine/include/voe_network.h +++ b/webrtc/voice_engine/include/voe_network.h @@ -69,10 +69,10 @@ public: // including the RTP-header must also be given to the VoiceEngine. virtual int ReceivedRTPPacket(int channel, const void* data, - unsigned int length) = 0; + size_t length) = 0; virtual int ReceivedRTPPacket(int channel, const void* data, - unsigned int length, + size_t length, const PacketTime& packet_time) { return 0; } @@ -80,8 +80,9 @@ public: // The packets received from the network should be passed to this // function when external transport is enabled. Note that the data // including the RTCP-header must also be given to the VoiceEngine. - virtual int ReceivedRTCPPacket( - int channel, const void* data, unsigned int length) = 0; + virtual int ReceivedRTCPPacket(int channel, + const void* data, + size_t length) = 0; protected: VoENetwork() {} diff --git a/webrtc/voice_engine/include/voe_rtp_rtcp.h b/webrtc/voice_engine/include/voe_rtp_rtcp.h index c5ab861509..6230211a77 100644 --- a/webrtc/voice_engine/include/voe_rtp_rtcp.h +++ b/webrtc/voice_engine/include/voe_rtp_rtcp.h @@ -69,9 +69,9 @@ struct CallStatistics unsigned int extendedMax; unsigned int jitterSamples; int rttMs; - int bytesSent; + size_t bytesSent; int packetsSent; - int bytesReceived; + size_t bytesReceived; int packetsReceived; // The capture ntp time (in local timebase) of the first played out audio // frame. diff --git a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc b/webrtc/voice_engine/test/android/android_test/jni/android_test.cc index 2f04cc57ab..8de7c6ef58 100644 --- a/webrtc/voice_engine/test/android/android_test/jni/android_test.cc +++ b/webrtc/voice_engine/test/android/android_test/jni/android_test.cc @@ -139,19 +139,21 @@ class my_transportation : public Transport netw(network) { } - virtual int SendPacket(int channel,const void *data,int len) OVERRIDE; - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE; + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE; + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE; private: VoENetwork * netw; }; -int my_transportation::SendPacket(int channel,const void *data,int len) +int my_transportation::SendPacket(int channel, const void *data, size_t len) { netw->ReceivedRTPPacket(channel, data, len); return len; } -int my_transportation::SendRTCPPacket(int channel, const void *data, int len) +int my_transportation::SendRTCPPacket(int channel, const void *data, size_t len) { netw->ReceivedRTCPPacket(channel, data, len); return len; diff --git a/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc b/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc index 164e547ab1..bd2b94e8c7 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc +++ b/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.cc @@ -71,7 +71,9 @@ bool FakeExternalTransport::Process() { return true; } -int FakeExternalTransport::SendPacket(int channel, const void *data, int len) { +int FakeExternalTransport::SendPacket(int channel, + const void *data, + size_t len) { lock_->Enter(); if (len < 1612) { memcpy(packet_buffer_, (const unsigned char*) data, len); @@ -80,17 +82,17 @@ int FakeExternalTransport::SendPacket(int channel, const void *data, int len) { } lock_->Leave(); event_->Set(); // Triggers ReceivedRTPPacket() from worker thread. - return len; + return static_cast(len); } int FakeExternalTransport::SendRTCPPacket(int channel, const void *data, - int len) { + size_t len) { if (delay_is_enabled_) { webrtc::SleepMs(delay_time_in_ms_); } my_network_->ReceivedRTCPPacket(channel, data, len); - return len; + return static_cast(len); } void FakeExternalTransport::SetDelayStatus(bool enable, diff --git a/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.h b/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.h index 318afdaf68..029b19ed17 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.h +++ b/webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.h @@ -23,10 +23,10 @@ class FakeExternalTransport : public webrtc::Transport { public: explicit FakeExternalTransport(webrtc::VoENetwork* ptr); virtual ~FakeExternalTransport(); - - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE; - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE; - + virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE; + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE; void SetDelayStatus(bool enabled, unsigned int delayInMs = 100); webrtc::VoENetwork* my_network_; @@ -39,7 +39,7 @@ class FakeExternalTransport : public webrtc::Transport { webrtc::EventWrapper* event_; private: unsigned char packet_buffer_[1612]; - int length_; + size_t length_; int channel_; bool delay_is_enabled_; int delay_time_in_ms_; diff --git a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h index 3b3878a777..928ec26a61 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h +++ b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h @@ -35,14 +35,16 @@ class LoopBackTransport : public webrtc::Transport { ~LoopBackTransport() { thread_->Stop(); } - virtual int SendPacket(int channel, const void* data, int len) OVERRIDE { + virtual int SendPacket(int channel, const void* data, size_t len) OVERRIDE { StorePacket(Packet::Rtp, channel, data, len); - return len; + return static_cast(len); } - virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE { + virtual int SendRTCPPacket(int channel, + const void* data, + size_t len) OVERRIDE { StorePacket(Packet::Rtcp, channel, data, len); - return len; + return static_cast(len); } private: @@ -50,18 +52,20 @@ class LoopBackTransport : public webrtc::Transport { enum Type { Rtp, Rtcp, } type; Packet() : len(0) {} - Packet(Type type, int channel, const void* data, int len) + Packet(Type type, int channel, const void* data, size_t len) : type(type), channel(channel), len(len) { assert(len <= 1500); - memcpy(this->data, data, static_cast(len)); + memcpy(this->data, data, len); } int channel; uint8_t data[1500]; - int len; + size_t len; }; - void StorePacket(Packet::Type type, int channel, const void* data, int len) { + void StorePacket(Packet::Type type, int channel, + const void* data, + size_t len) { webrtc::CriticalSectionScoped lock(crit_.get()); packet_queue_.push_back(Packet(type, channel, data, len)); packet_event_->Set(); diff --git a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc index 2fc117b673..c0b3011cef 100644 --- a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc +++ b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc @@ -29,11 +29,9 @@ class ExtensionVerifyTransport : public webrtc::Transport { audio_level_id_(-1), absolute_sender_time_id_(-1) {} - virtual int SendPacket(int channel, const void* data, int len) OVERRIDE { + virtual int SendPacket(int channel, const void* data, size_t len) OVERRIDE { webrtc::RTPHeader header; - if (parser_->Parse(reinterpret_cast(data), - static_cast(len), - &header)) { + if (parser_->Parse(reinterpret_cast(data), len, &header)) { bool ok = true; if (audio_level_id_ >= 0 && !header.extension.hasAudioLevel) { @@ -51,11 +49,13 @@ class ExtensionVerifyTransport : public webrtc::Transport { } // received_packets_ count all packets we receive. ++received_packets_; - return len; + return static_cast(len); } - virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE { - return len; + virtual int SendRTCPPacket(int channel, + const void* data, + size_t len) OVERRIDE { + return static_cast(len); } void SetAudioLevelId(int id) { @@ -166,11 +166,11 @@ class MockViENetwork : public webrtc::ViENetwork { MOCK_METHOD2(SetNetworkTransmissionState, void(const int, const bool)); MOCK_METHOD2(RegisterSendTransport, int(const int, webrtc::Transport&)); MOCK_METHOD1(DeregisterSendTransport, int(const int)); - MOCK_METHOD4(ReceivedRTPPacket, int(const int, const void*, const int, + MOCK_METHOD4(ReceivedRTPPacket, int(const int, const void*, const size_t, const webrtc::PacketTime&)); - MOCK_METHOD3(ReceivedRTCPPacket, int(const int, const void*, const int)); + MOCK_METHOD3(ReceivedRTCPPacket, int(const int, const void*, const size_t)); MOCK_METHOD2(SetMTU, int(int, unsigned int)); - MOCK_METHOD4(ReceivedBWEPacket, int(const int, int64_t, int, + MOCK_METHOD4(ReceivedBWEPacket, int(const int, int64_t, size_t, const webrtc::RTPHeader&)); }; diff --git a/webrtc/voice_engine/test/win_test/WinTestDlg.cc b/webrtc/voice_engine/test/win_test/WinTestDlg.cc index 4929ae4af6..b63b1d2068 100644 --- a/webrtc/voice_engine/test/win_test/WinTestDlg.cc +++ b/webrtc/voice_engine/test/win_test/WinTestDlg.cc @@ -129,8 +129,12 @@ class MyTransport : public Transport { public: MyTransport(VoENetwork* veNetwork); - virtual int SendPacket(int channel, const void *data, int len) OVERRIDE; - virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE; + virtual int SendPacket(int channel, + const void *data, + size_t len) OVERRIDE; + virtual int SendRTCPPacket(int channel, + const void *data, + size_t len) OVERRIDE; private: VoENetwork* _veNetworkPtr; }; @@ -141,14 +145,14 @@ MyTransport::MyTransport(VoENetwork* veNetwork) : } int -MyTransport::SendPacket(int channel, const void *data, int len) +MyTransport::SendPacket(int channel, const void *data, size_t len) { _veNetworkPtr->ReceivedRTPPacket(channel, data, len); return len; } int -MyTransport::SendRTCPPacket(int channel, const void *data, int len) +MyTransport::SendRTCPPacket(int channel, const void *data, size_t len) { _veNetworkPtr->ReceivedRTCPPacket(channel, data, len); return len; diff --git a/webrtc/voice_engine/voe_network_impl.cc b/webrtc/voice_engine/voe_network_impl.cc index 70c548857b..89d1b04f48 100644 --- a/webrtc/voice_engine/voe_network_impl.cc +++ b/webrtc/voice_engine/voe_network_impl.cc @@ -10,6 +10,7 @@ #include "webrtc/voice_engine/voe_network_impl.h" +#include "webrtc/base/format_macros.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/trace.h" @@ -88,17 +89,18 @@ int VoENetworkImpl::DeRegisterExternalTransport(int channel) int VoENetworkImpl::ReceivedRTPPacket(int channel, const void* data, - unsigned int length) { + size_t length) { return ReceivedRTPPacket(channel, data, length, webrtc::PacketTime()); } int VoENetworkImpl::ReceivedRTPPacket(int channel, const void* data, - unsigned int length, + size_t length, const PacketTime& packet_time) { WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_shared->instance_id(), -1), - "ReceivedRTPPacket(channel=%d, length=%u)", channel, length); + "ReceivedRTPPacket(channel=%d, length=%" PRIuS ")", channel, + length); if (!_shared->statistics().Initialized()) { _shared->SetLastError(VE_NOT_INITED, kTraceError); @@ -137,10 +139,11 @@ int VoENetworkImpl::ReceivedRTPPacket(int channel, } int VoENetworkImpl::ReceivedRTCPPacket(int channel, const void* data, - unsigned int length) + size_t length) { WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_shared->instance_id(), -1), - "ReceivedRTCPPacket(channel=%d, length=%u)", channel, length); + "ReceivedRTCPPacket(channel=%d, length=%" PRIuS ")", channel, + length); if (!_shared->statistics().Initialized()) { _shared->SetLastError(VE_NOT_INITED, kTraceError); diff --git a/webrtc/voice_engine/voe_network_impl.h b/webrtc/voice_engine/voe_network_impl.h index 0cf07ad1fd..dc9eb3802e 100644 --- a/webrtc/voice_engine/voe_network_impl.h +++ b/webrtc/voice_engine/voe_network_impl.h @@ -29,15 +29,15 @@ public: virtual int ReceivedRTPPacket(int channel, const void* data, - unsigned int length) OVERRIDE; + size_t length) OVERRIDE; virtual int ReceivedRTPPacket(int channel, const void* data, - unsigned int length, + size_t length, const PacketTime& packet_time) OVERRIDE; virtual int ReceivedRTCPPacket(int channel, const void* data, - unsigned int length) OVERRIDE; + size_t length) OVERRIDE; protected: VoENetworkImpl(voe::SharedData* shared);