From 16825b1a828bb4ff40f7682040e43a239b7b8ca3 Mon Sep 17 00:00:00 2001 From: "pkasting@chromium.org" Date: Mon, 12 Jan 2015 21:51:21 +0000 Subject: [PATCH] Use int64_t more consistently for times, in particular for RTT values. Existing code was inconsistent about whether to use uint16_t, int, unsigned int, or uint32_t, and sometimes silently truncated one to another, or truncated int64_t. Because most core time-handling functions use int64_t, being consistent about using int64_t unless otherwise necessary minimizes the number of explicit or implicit casts. BUG=chromium:81439 TEST=none R=henrik.lundin@webrtc.org, holmer@google.com, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31349004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8045 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../app/webrtc/java/jni/peerconnection_jni.cc | 4 +- talk/media/base/mediachannel.h | 4 +- talk/media/webrtc/fakewebrtcvideoengine.h | 10 ++--- talk/media/webrtc/webrtcvideoengine.cc | 4 +- webrtc/call.h | 4 +- .../media_demo/jni/video_engine_jni.cc | 4 +- .../audio_coding/main/acm2/acm_receiver.cc | 5 ++- .../audio_coding/main/acm2/acm_receiver.h | 2 +- .../main/acm2/audio_coding_module_impl.cc | 2 +- .../main/acm2/audio_coding_module_impl.h | 2 +- webrtc/modules/audio_coding/main/acm2/nack.cc | 4 +- webrtc/modules/audio_coding/main/acm2/nack.h | 8 ++-- .../audio_coding/main/acm2/nack_unittest.cc | 2 +- .../main/interface/audio_coding_module.h | 3 +- .../bitrate_controller_impl.cc | 16 ++++---- .../bitrate_controller_impl.h | 10 ++--- .../bitrate_controller_unittest.cc | 36 ++++++++--------- .../include/bitrate_controller.h | 2 +- .../send_side_bandwidth_estimation.cc | 14 +++---- .../send_side_bandwidth_estimation.h | 8 ++-- ...send_side_bandwidth_estimation_unittest.cc | 4 +- .../modules/desktop_capture/desktop_frame.h | 6 +-- .../modules/interface/module_common_types.h | 2 +- .../aimd_rate_control.cc | 11 ++--- .../aimd_rate_control.h | 6 +-- .../mimd_rate_control.cc | 17 ++++---- .../mimd_rate_control.h | 6 +-- .../remote_bitrate_estimator_abs_send_time.cc | 4 +- .../remote_bitrate_estimator_single_stream.cc | 4 +- .../remote_rate_control.h | 2 +- .../rtp_rtcp/interface/receive_statistics.h | 2 +- .../interface/remote_ntp_time_estimator.h | 2 +- webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h | 8 ++-- .../rtp_rtcp/interface/rtp_rtcp_defines.h | 6 +-- webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h | 6 ++- .../source/receive_statistics_impl.cc | 9 ++--- .../rtp_rtcp/source/receive_statistics_impl.h | 2 +- .../source/remote_ntp_time_estimator.cc | 2 +- .../remote_ntp_time_estimator_unittest.cc | 6 +-- .../modules/rtp_rtcp/source/rtcp_receiver.cc | 40 +++++++++---------- .../modules/rtp_rtcp/source/rtcp_receiver.h | 12 +++--- .../rtp_rtcp/source/rtcp_receiver_help.h | 12 +++--- .../rtp_rtcp/source/rtcp_receiver_unittest.cc | 2 +- webrtc/modules/rtp_rtcp/source/rtcp_sender.cc | 5 +-- webrtc/modules/rtp_rtcp/source/rtcp_sender.h | 6 +-- .../rtp_rtcp/source/rtp_packet_history.cc | 2 +- .../rtp_rtcp/source/rtp_packet_history.h | 2 +- .../modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 28 ++++++------- .../modules/rtp_rtcp/source/rtp_rtcp_impl.h | 18 ++++----- .../rtp_rtcp/source/rtp_rtcp_impl_unittest.cc | 28 ++++++------- webrtc/modules/rtp_rtcp/source/rtp_sender.cc | 4 +- webrtc/modules/rtp_rtcp/source/rtp_sender.h | 4 +- .../rtp_rtcp/test/testAPI/test_api_rtcp.cc | 8 ++-- .../video_capture/include/video_capture.h | 2 +- .../codecs/i420/main/interface/i420.h | 2 +- .../mock/mock_video_codec_interface.h | 2 +- .../codecs/vp8/reference_picture_selection.cc | 9 +++-- .../codecs/vp8/reference_picture_selection.h | 8 ++-- .../codecs/vp8/simulcast_encoder_adapter.cc | 2 +- .../codecs/vp8/simulcast_encoder_adapter.h | 2 +- .../vp8/simulcast_encoder_adapter_unittest.cc | 6 +-- .../video_coding/codecs/vp8/vp8_impl.cc | 2 +- .../video_coding/codecs/vp8/vp8_impl.h | 2 +- .../video_coding/codecs/vp9/vp9_impl.cc | 2 +- .../video_coding/codecs/vp9/vp9_impl.h | 2 +- .../main/interface/video_coding.h | 6 +-- .../main/source/generic_encoder.cc | 2 +- .../main/source/generic_encoder.h | 2 +- .../video_coding/main/source/jitter_buffer.cc | 12 +++--- .../video_coding/main/source/jitter_buffer.h | 12 +++--- .../main/source/jitter_estimator.cc | 2 +- .../main/source/jitter_estimator.h | 2 +- .../main/source/media_opt_util.cc | 8 ++-- .../video_coding/main/source/media_opt_util.h | 21 ++++------ .../main/source/media_optimization.cc | 2 +- .../main/source/media_optimization.h | 2 +- .../main/source/nack_fec_tables.h | 5 +-- .../video_coding/main/source/qm_select.cc | 2 +- .../video_coding/main/source/qm_select.h | 4 +- .../video_coding/main/source/receiver.cc | 6 +-- .../video_coding/main/source/receiver.h | 6 +-- .../video_coding/main/source/rtt_filter.cc | 12 +++--- .../video_coding/main/source/rtt_filter.h | 16 ++++---- .../video_coding/main/source/session_info.cc | 15 +++---- .../video_coding/main/source/session_info.h | 2 +- .../main/source/video_coding_impl.cc | 4 +- .../main/source/video_coding_impl.h | 4 +- .../main/source/video_receiver.cc | 2 +- .../video_coding/main/source/video_sender.cc | 2 +- .../video_coding/main/test/media_opt_test.h | 2 +- .../video_coding/main/test/mt_rx_tx_test.cc | 2 +- .../video_coding/main/test/rtp_player.cc | 8 ++-- .../video_coding/main/test/rtp_player.h | 2 +- .../main/test/vcm_payload_sink_factory.cc | 2 +- .../main/test/vcm_payload_sink_factory.h | 4 +- .../video_coding/main/test/video_rtp_play.cc | 2 +- .../main/test/video_rtp_play_mt.cc | 2 +- .../test/configurable_frame_size_encoder.cc | 2 +- webrtc/test/configurable_frame_size_encoder.h | 3 +- webrtc/test/fake_encoder.cc | 2 +- webrtc/test/fake_encoder.h | 3 +- webrtc/video/video_send_stream.cc | 8 ++-- webrtc/video/video_send_stream.h | 4 +- webrtc/video/video_send_stream_tests.cc | 4 +- webrtc/video_encoder.h | 2 +- webrtc/video_engine/call_stats.cc | 18 ++++----- webrtc/video_engine/call_stats.h | 12 +++--- webrtc/video_engine/call_stats_unittest.cc | 24 +++++------ webrtc/video_engine/include/vie_rtp_rtcp.h | 26 ++++++------ .../source/vie_autotest_custom_call.cc | 2 +- .../auto_test/source/vie_autotest_rtp_rtcp.cc | 4 +- .../test/libvietest/include/tb_I420_codec.h | 3 +- .../test/libvietest/testbed/tb_I420_codec.cc | 2 +- webrtc/video_engine/vie_channel.cc | 16 ++++---- webrtc/video_engine/vie_channel.h | 6 +-- webrtc/video_engine/vie_channel_group.cc | 2 +- webrtc/video_engine/vie_encoder.cc | 6 +-- webrtc/video_engine/vie_encoder.h | 4 +- webrtc/video_engine/vie_receiver.cc | 4 +- webrtc/video_engine/vie_rtp_rtcp_impl.cc | 6 +-- webrtc/video_engine/vie_rtp_rtcp_impl.h | 6 +-- webrtc/voice_engine/channel.cc | 28 ++++++------- webrtc/voice_engine/channel.h | 4 +- webrtc/voice_engine/include/voe_rtp_rtcp.h | 2 +- 124 files changed, 422 insertions(+), 417 deletions(-) diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc index 57efaadba3..28bd7b8d6f 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -1271,7 +1271,7 @@ class MediaCodecVideoEncoder : public webrtc::VideoEncoder, webrtc::EncodedImageCallback* callback) OVERRIDE; virtual int32_t Release() OVERRIDE; virtual int32_t SetChannelParameters(uint32_t /* packet_loss */, - int /* rtt */) OVERRIDE; + int64_t /* rtt */) OVERRIDE; virtual int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) OVERRIDE; // rtc::MessageHandler implementation. @@ -1472,7 +1472,7 @@ int32_t MediaCodecVideoEncoder::Release() { } int32_t MediaCodecVideoEncoder::SetChannelParameters(uint32_t /* packet_loss */, - int /* rtt */) { + int64_t /* rtt */) { return WEBRTC_VIDEO_CODEC_OK; } diff --git a/talk/media/base/mediachannel.h b/talk/media/base/mediachannel.h index e3454c41a1..ce8aaac4c7 100644 --- a/talk/media/base/mediachannel.h +++ b/talk/media/base/mediachannel.h @@ -681,7 +681,7 @@ struct MediaSenderInfo { int packets_sent; int packets_lost; float fraction_lost; - int rtt_ms; + int64_t rtt_ms; std::string codec_name; std::vector local_stats; std::vector remote_stats; @@ -948,7 +948,7 @@ struct BandwidthEstimationInfo { int actual_enc_bitrate; int retransmit_bitrate; int transmit_bitrate; - int bucket_delay; + int64_t bucket_delay; // The following stats are only valid when // StatsOptions::include_received_propagation_stats is true. int total_received_propagation_delta_ms; diff --git a/talk/media/webrtc/fakewebrtcvideoengine.h b/talk/media/webrtc/fakewebrtcvideoengine.h index aaa2f3bc0b..b4e6b3b396 100644 --- a/talk/media/webrtc/fakewebrtcvideoengine.h +++ b/talk/media/webrtc/fakewebrtcvideoengine.h @@ -175,7 +175,7 @@ class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder { } virtual int32 SetChannelParameters(uint32 packetLoss, - int rtt) { + int64_t rtt) { return WEBRTC_VIDEO_CODEC_OK; } @@ -1134,15 +1134,15 @@ class FakeWebRtcVideoEngine WEBRTC_STUB_CONST(GetRtcpPacketTypeCounters, (int, webrtc::RtcpPacketTypeCounter*, webrtc::RtcpPacketTypeCounter*)); WEBRTC_STUB_CONST(GetReceivedRTCPStatistics, (const int, unsigned short&, - unsigned int&, unsigned int&, unsigned int&, int&)); + unsigned int&, unsigned int&, unsigned int&, int64_t&)); WEBRTC_STUB_CONST(GetSentRTCPStatistics, (const int, unsigned short&, - unsigned int&, unsigned int&, unsigned int&, int&)); + unsigned int&, unsigned int&, unsigned int&, int64_t&)); WEBRTC_STUB_CONST(GetRTPStatistics, (const int, size_t&, unsigned int&, size_t&, unsigned int&)); WEBRTC_STUB_CONST(GetReceiveChannelRtcpStatistics, (const int, - webrtc::RtcpStatistics&, int&)); + webrtc::RtcpStatistics&, int64_t&)); WEBRTC_STUB_CONST(GetSendChannelRtcpStatistics, (const int, - webrtc::RtcpStatistics&, int&)); + webrtc::RtcpStatistics&, int64_t&)); WEBRTC_STUB_CONST(GetRtpStatistics, (const int, webrtc::StreamDataCounters&, webrtc::StreamDataCounters&)); WEBRTC_FUNC_CONST(GetBandwidthUsage, (const int channel, diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc index 689aef35d3..70264171ab 100644 --- a/talk/media/webrtc/webrtcvideoengine.cc +++ b/talk/media/webrtc/webrtcvideoengine.cc @@ -2678,7 +2678,7 @@ bool WebRtcVideoMediaChannel::GetStats(const StatsOptions& options, // It's not a fatal error if we can't, since RTCP may not have arrived // yet. webrtc::RtcpStatistics outgoing_stream_rtcp_stats; - int outgoing_stream_rtt_ms; + int64_t outgoing_stream_rtt_ms; if (engine_->vie()->rtp()->GetSendChannelRtcpStatistics( channel_id, @@ -2782,7 +2782,7 @@ bool WebRtcVideoMediaChannel::GetStats(const StatsOptions& options, // Get our locally created statistics of the received RTP stream. webrtc::RtcpStatistics incoming_stream_rtcp_stats; - int incoming_stream_rtt_ms; + int64_t incoming_stream_rtt_ms; if (engine_->vie()->rtp()->GetReceiveChannelRtcpStatistics( channel->channel_id(), incoming_stream_rtcp_stats, diff --git a/webrtc/call.h b/webrtc/call.h index 56efacb0d2..99f8b27a52 100644 --- a/webrtc/call.h +++ b/webrtc/call.h @@ -105,8 +105,8 @@ class Call { int send_bandwidth_bps; int recv_bandwidth_bps; - int pacer_delay_ms; - int rtt_ms; + int64_t pacer_delay_ms; + int64_t rtt_ms; }; static Call* Create(const Call::Config& config); diff --git a/webrtc/examples/android/media_demo/jni/video_engine_jni.cc b/webrtc/examples/android/media_demo/jni/video_engine_jni.cc index c7af1c54ff..d9e6312546 100644 --- a/webrtc/examples/android/media_demo/jni/video_engine_jni.cc +++ b/webrtc/examples/android/media_demo/jni/video_engine_jni.cc @@ -594,7 +594,7 @@ JOWW(jobject, VideoEngine_getReceivedRtcpStatistics)(JNIEnv* jni, jobject j_vie, unsigned int cumulative_lost; // NOLINT unsigned int extended_max; // NOLINT unsigned int jitter; // NOLINT - int rtt_ms; + int64_t rtt_ms; VideoEngineData* vie_data = GetVideoEngineData(jni, j_vie); if (vie_data->rtp->GetReceivedRTCPStatistics(channel, fraction_lost, cumulative_lost, extended_max, @@ -608,7 +608,7 @@ JOWW(jobject, VideoEngine_getReceivedRtcpStatistics)(JNIEnv* jni, jobject j_vie, jobject j_rtcp_statistics = jni->NewObject(j_rtcp_statistics_class, j_rtcp_statistics_ctor, fraction_lost, cumulative_lost, extended_max, jitter, - rtt_ms); + static_cast(rtt_ms)); CHECK_EXCEPTION(jni, "error during NewObject"); return j_rtcp_statistics; } diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc index f0531ed11c..07c27846d6 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc @@ -15,6 +15,7 @@ #include // sort #include +#include "webrtc/base/format_macros.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" @@ -727,12 +728,12 @@ void AcmReceiver::DisableNack() { } std::vector AcmReceiver::GetNackList( - int round_trip_time_ms) const { + int64_t round_trip_time_ms) const { CriticalSectionScoped lock(crit_sect_.get()); if (round_trip_time_ms < 0) { WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, id_, "GetNackList: round trip time cannot be negative." - " round_trip_time_ms=%d", round_trip_time_ms); + " round_trip_time_ms=%" PRId64, round_trip_time_ms); } if (nack_enabled_ && round_trip_time_ms >= 0) { assert(nack_.get()); diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h index 057cb5ae9c..f6ce463e13 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h @@ -305,7 +305,7 @@ class AcmReceiver { // -round_trip_time_ms : estimate of the round-trip-time (in milliseconds). // Return value : list of packets to be retransmitted. // - std::vector GetNackList(int round_trip_time_ms) const; + std::vector GetNackList(int64_t round_trip_time_ms) const; // // Get statistics of calls to GetAudio(). 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 cbea050fbb..4aa372fe24 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 @@ -2017,7 +2017,7 @@ void AudioCodingModuleImpl::DisableNack() { } std::vector AudioCodingModuleImpl::GetNackList( - int round_trip_time_ms) const { + int64_t round_trip_time_ms) const { return receiver_.GetNackList(round_trip_time_ms); } 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 2d0f767d93..a06d87778b 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 @@ -246,7 +246,7 @@ class AudioCodingModuleImpl : public AudioCodingModule { virtual void DisableNack() OVERRIDE; virtual std::vector GetNackList( - int round_trip_time_ms) const OVERRIDE; + int64_t round_trip_time_ms) const OVERRIDE; virtual void GetDecodingCallStatistics( AudioDecodingCallStats* stats) const OVERRIDE; diff --git a/webrtc/modules/audio_coding/main/acm2/nack.cc b/webrtc/modules/audio_coding/main/acm2/nack.cc index 7265fe63c5..4324cd2e79 100644 --- a/webrtc/modules/audio_coding/main/acm2/nack.cc +++ b/webrtc/modules/audio_coding/main/acm2/nack.cc @@ -207,13 +207,13 @@ void Nack::LimitNackListSize() { nack_list_.erase(nack_list_.begin(), nack_list_.upper_bound(limit)); } -int Nack::TimeToPlay(uint32_t timestamp) const { +int64_t Nack::TimeToPlay(uint32_t timestamp) const { uint32_t timestamp_increase = timestamp - timestamp_last_decoded_rtp_; return timestamp_increase / sample_rate_khz_; } // We don't erase elements with time-to-play shorter than round-trip-time. -std::vector Nack::GetNackList(int round_trip_time_ms) const { +std::vector Nack::GetNackList(int64_t round_trip_time_ms) const { std::vector sequence_numbers; for (NackList::const_iterator it = nack_list_.begin(); it != nack_list_.end(); ++it) { diff --git a/webrtc/modules/audio_coding/main/acm2/nack.h b/webrtc/modules/audio_coding/main/acm2/nack.h index 3809327199..d74bb1f0bc 100644 --- a/webrtc/modules/audio_coding/main/acm2/nack.h +++ b/webrtc/modules/audio_coding/main/acm2/nack.h @@ -87,7 +87,7 @@ class Nack { // Get a list of "missing" packets which have expected time-to-play larger // than the given round-trip-time (in milliseconds). // Note: Late packets are not included. - std::vector GetNackList(int round_trip_time_ms) const; + std::vector GetNackList(int64_t round_trip_time_ms) const; // Reset to default values. The NACK list is cleared. // |nack_threshold_packets_| & |max_nack_list_size_| preserve their values. @@ -98,7 +98,7 @@ class Nack { FRIEND_TEST_ALL_PREFIXES(NackTest, EstimateTimestampAndTimeToPlay); struct NackElement { - NackElement(int initial_time_to_play_ms, + NackElement(int64_t initial_time_to_play_ms, uint32_t initial_timestamp, bool missing) : time_to_play_ms(initial_time_to_play_ms), @@ -107,7 +107,7 @@ class Nack { // Estimated time (ms) left for this packet to be decoded. This estimate is // updated every time jitter buffer decodes a packet. - int time_to_play_ms; + int64_t time_to_play_ms; // A guess about the timestamp of the missing packet, it is used for // estimation of |time_to_play_ms|. The estimate might be slightly wrong if @@ -171,7 +171,7 @@ class Nack { uint32_t EstimateTimestamp(uint16_t sequence_number); // Compute time-to-play given a timestamp. - int TimeToPlay(uint32_t timestamp) const; + int64_t TimeToPlay(uint32_t timestamp) const; // If packet N is arrived, any packet prior to N - |nack_threshold_packets_| // which is not arrived is considered missing, and should be in NACK list. diff --git a/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc b/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc index 7863c75b96..c175908c19 100644 --- a/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc +++ b/webrtc/modules/audio_coding/main/acm2/nack_unittest.cc @@ -29,7 +29,7 @@ const int kNackThreshold = 3; const int kSampleRateHz = 16000; const int kPacketSizeMs = 30; const uint32_t kTimestampIncrement = 480; // 30 ms. -const int kShortRoundTripTimeMs = 1; +const int64_t kShortRoundTripTimeMs = 1; bool IsNackListCorrect(const std::vector& nack_list, const uint16_t* lost_sequence_numbers, 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 83e6dce58c..88261940c5 100644 --- a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h +++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h @@ -991,7 +991,8 @@ class AudioCodingModule: public Module { // Negative |round_trip_time_ms| results is an error message and empty list // is returned. // - virtual std::vector GetNackList(int round_trip_time_ms) const = 0; + virtual std::vector GetNackList( + int64_t round_trip_time_ms) const = 0; virtual void GetDecodingCallStatistics( AudioDecodingCallStats* call_stats) const = 0; diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc index 605190d879..acfeb59683 100644 --- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc +++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc @@ -33,7 +33,7 @@ class BitrateControllerImpl::RtcpBandwidthObserverImpl // Received RTCP receiver block. virtual void OnReceivedRtcpReceiverReport( const ReportBlockList& report_blocks, - uint16_t rtt, + int64_t rtt, int64_t now_ms) OVERRIDE { if (report_blocks.empty()) return; @@ -153,7 +153,7 @@ void BitrateControllerImpl::SetBitrateObserver( } uint32_t current_estimate; uint8_t loss; - uint32_t rtt; + int64_t rtt; bandwidth_estimation_.CurrentEstimate(¤t_estimate, &loss, &rtt); bandwidth_estimation_.SetSendBitrate(std::max(sum_start_bitrate, current_estimate)); @@ -252,7 +252,7 @@ int32_t BitrateControllerImpl::Process() { void BitrateControllerImpl::OnReceivedRtcpReceiverReport( uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, int number_of_packets, int64_t now_ms) { CriticalSectionScoped cs(critsect_); @@ -264,7 +264,7 @@ void BitrateControllerImpl::OnReceivedRtcpReceiverReport( void BitrateControllerImpl::MaybeTriggerOnNetworkChanged() { uint32_t bitrate; uint8_t fraction_loss; - uint32_t rtt; + int64_t rtt; bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); bitrate -= std::min(bitrate, reserved_bitrate_bps_); @@ -286,7 +286,7 @@ void BitrateControllerImpl::MaybeTriggerOnNetworkChanged() { void BitrateControllerImpl::OnNetworkChanged(uint32_t bitrate, uint8_t fraction_loss, - uint32_t rtt) { + int64_t rtt) { // Sanity check. if (bitrate_observers_.empty()) return; @@ -304,7 +304,7 @@ void BitrateControllerImpl::OnNetworkChanged(uint32_t bitrate, void BitrateControllerImpl::NormalRateAllocation(uint32_t bitrate, uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, uint32_t sum_min_bitrates) { uint32_t number_of_observers = bitrate_observers_.size(); uint32_t bitrate_per_observer = (bitrate - sum_min_bitrates) / @@ -344,7 +344,7 @@ void BitrateControllerImpl::NormalRateAllocation(uint32_t bitrate, void BitrateControllerImpl::LowRateAllocation(uint32_t bitrate, uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, uint32_t sum_min_bitrates) { if (enforce_min_bitrate_) { // Min bitrate to all observers. @@ -375,7 +375,7 @@ bool BitrateControllerImpl::AvailableBandwidth(uint32_t* bandwidth) const { CriticalSectionScoped cs(critsect_); uint32_t bitrate; uint8_t fraction_loss; - uint32_t rtt; + int64_t rtt; bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); if (bitrate) { *bandwidth = bitrate - std::min(bitrate, reserved_bitrate_bps_); diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h index fb2622f921..f8d8022aa1 100644 --- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h +++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h @@ -89,7 +89,7 @@ class BitrateControllerImpl : public BitrateController { void OnReceivedEstimatedBitrate(uint32_t bitrate); void OnReceivedRtcpReceiverReport(uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, int number_of_packets, int64_t now_ms); @@ -97,18 +97,18 @@ class BitrateControllerImpl : public BitrateController { void OnNetworkChanged(uint32_t bitrate, uint8_t fraction_loss, // 0 - 255. - uint32_t rtt) + int64_t rtt) EXCLUSIVE_LOCKS_REQUIRED(*critsect_); void NormalRateAllocation(uint32_t bitrate, uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, uint32_t sum_min_bitrates) EXCLUSIVE_LOCKS_REQUIRED(*critsect_); void LowRateAllocation(uint32_t bitrate, uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, uint32_t sum_min_bitrates) EXCLUSIVE_LOCKS_REQUIRED(*critsect_); @@ -129,7 +129,7 @@ class BitrateControllerImpl : public BitrateController { uint32_t last_bitrate_bps_ GUARDED_BY(*critsect_); uint8_t last_fraction_loss_ GUARDED_BY(*critsect_); - uint32_t last_rtt_ms_ GUARDED_BY(*critsect_); + int64_t last_rtt_ms_ GUARDED_BY(*critsect_); bool last_enforce_min_bitrate_ GUARDED_BY(*critsect_); bool bitrate_observers_modified_ GUARDED_BY(*critsect_); uint32_t last_reserved_bitrate_bps_ GUARDED_BY(*critsect_); diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc index 6344ee8c05..f89da9f85c 100644 --- a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc +++ b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc @@ -45,14 +45,14 @@ class TestBitrateObserver: public BitrateObserver { virtual void OnNetworkChanged(uint32_t bitrate, uint8_t fraction_loss, - uint32_t rtt) { + int64_t rtt) { last_bitrate_ = bitrate; last_fraction_loss_ = fraction_loss; last_rtt_ = rtt; } uint32_t last_bitrate_; uint8_t last_fraction_loss_; - uint32_t last_rtt_; + int64_t last_rtt_; }; class BitrateControllerTest : public ::testing::Test { @@ -112,7 +112,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) { bandwidth_observer_->OnReceivedEstimatedBitrate(200000); EXPECT_EQ(200000u, bitrate_observer.last_bitrate_); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(0u, bitrate_observer.last_rtt_); + EXPECT_EQ(0, bitrate_observer.last_rtt_); bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); report_blocks.clear(); time_ms += 2000; @@ -125,7 +125,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) { bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); EXPECT_EQ(217000u, bitrate_observer.last_bitrate_); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); time_ms += 1000; report_blocks.clear(); @@ -133,7 +133,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) { bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); EXPECT_EQ(235360u, bitrate_observer.last_bitrate_); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); time_ms += 1000; report_blocks.clear(); @@ -170,7 +170,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) { bandwidth_observer_->OnReceivedEstimatedBitrate(250000); EXPECT_EQ(250000u, bitrate_observer.last_bitrate_); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); bandwidth_observer_->OnReceivedEstimatedBitrate(1000); EXPECT_EQ(100000u, bitrate_observer.last_bitrate_); // Min cap. @@ -198,7 +198,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { report_blocks, 100, 1); EXPECT_EQ(217000u, bitrate_observer.last_bitrate_); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(100u, bitrate_observer.last_rtt_); + EXPECT_EQ(100, bitrate_observer.last_rtt_); time_ms += 500; // Test bitrate increase 8% per second. @@ -210,7 +210,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { report_blocks, 100, time_ms); EXPECT_EQ(235360u, bitrate_observer.last_bitrate_); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(100u, bitrate_observer.last_rtt_); + EXPECT_EQ(100, bitrate_observer.last_rtt_); time_ms += 500; // Extra report should not change estimate. @@ -268,7 +268,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { second_bandwidth_observer->OnReceivedEstimatedBitrate(250000); EXPECT_EQ(250000u, bitrate_observer.last_bitrate_); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); // Min cap. bandwidth_observer_->OnReceivedEstimatedBitrate(1000); @@ -307,7 +307,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverMultipleReportBlocks) { time_ms); EXPECT_GT(bitrate_observer.last_bitrate_, last_bitrate); EXPECT_EQ(0, bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); last_bitrate = bitrate_observer.last_bitrate_; time_ms += 1000; sequence_number[0] += 20; @@ -323,7 +323,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverMultipleReportBlocks) { bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); EXPECT_LT(bitrate_observer.last_bitrate_, last_bitrate); EXPECT_EQ(WeightedLoss(20, 50, 1, 0), bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); last_bitrate = bitrate_observer.last_bitrate_; sequence_number[0] += 20; sequence_number[1] += 20; @@ -336,7 +336,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverMultipleReportBlocks) { bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); EXPECT_LT(bitrate_observer.last_bitrate_, last_bitrate); EXPECT_EQ(WeightedLoss(20, 0, 20, 75), bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); last_bitrate = bitrate_observer.last_bitrate_; sequence_number[0] += 20; sequence_number[1] += 1; @@ -349,7 +349,7 @@ TEST_F(BitrateControllerTest, OneBitrateObserverMultipleReportBlocks) { bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); EXPECT_EQ(bitrate_observer.last_bitrate_, last_bitrate); EXPECT_EQ(WeightedLoss(20, 1, 1, 255), bitrate_observer.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer.last_rtt_); + EXPECT_EQ(50, bitrate_observer.last_rtt_); last_bitrate = bitrate_observer.last_bitrate_; sequence_number[0] += 20; sequence_number[1] += 1; @@ -369,7 +369,7 @@ TEST_F(BitrateControllerTest, TwoBitrateObserversOneRtcpObserver) { bandwidth_observer_->OnReceivedEstimatedBitrate(200000); EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); EXPECT_EQ(0, bitrate_observer_1.last_fraction_loss_); - EXPECT_EQ(0u, bitrate_observer_1.last_rtt_); + EXPECT_EQ(0, bitrate_observer_1.last_rtt_); bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); report_blocks.clear(); time_ms += 2000; @@ -383,12 +383,12 @@ TEST_F(BitrateControllerTest, TwoBitrateObserversOneRtcpObserver) { bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); EXPECT_EQ(112500u, bitrate_observer_1.last_bitrate_); EXPECT_EQ(0, bitrate_observer_1.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer_1.last_rtt_); + EXPECT_EQ(50, bitrate_observer_1.last_rtt_); time_ms += 1000; EXPECT_EQ(212500u, bitrate_observer_2.last_bitrate_); EXPECT_EQ(0, bitrate_observer_2.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer_2.last_rtt_); + EXPECT_EQ(50, bitrate_observer_2.last_rtt_); report_blocks.clear(); report_blocks.push_back(CreateReportBlock(1, 2, 0, 41)); @@ -460,10 +460,10 @@ TEST_F(BitrateControllerTest, TwoBitrateObserversOneRtcpObserver) { bandwidth_observer_->OnReceivedEstimatedBitrate(350000); EXPECT_EQ(125000u, bitrate_observer_1.last_bitrate_); EXPECT_EQ(0, bitrate_observer_1.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer_1.last_rtt_); + EXPECT_EQ(50, bitrate_observer_1.last_rtt_); EXPECT_EQ(225000u, bitrate_observer_2.last_bitrate_); EXPECT_EQ(0, bitrate_observer_2.last_fraction_loss_); - EXPECT_EQ(50u, bitrate_observer_2.last_rtt_); + EXPECT_EQ(50, bitrate_observer_2.last_rtt_); bandwidth_observer_->OnReceivedEstimatedBitrate(1000); EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); // Min cap. diff --git a/webrtc/modules/bitrate_controller/include/bitrate_controller.h b/webrtc/modules/bitrate_controller/include/bitrate_controller.h index 2b84ada194..aea822ba32 100644 --- a/webrtc/modules/bitrate_controller/include/bitrate_controller.h +++ b/webrtc/modules/bitrate_controller/include/bitrate_controller.h @@ -31,7 +31,7 @@ class BitrateObserver { public: virtual void OnNetworkChanged(uint32_t target_bitrate, uint8_t fraction_loss, // 0 - 255. - uint32_t rtt) = 0; + int64_t rtt) = 0; virtual ~BitrateObserver() {} }; diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc index 9fb8c1bddc..a08e12300d 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc @@ -27,7 +27,7 @@ enum { kBweConverganceTimeMs = 20000 }; // Calculate the rate that TCP-Friendly Rate Control (TFRC) would apply. // The formula in RFC 3448, Section 3.1, is used. -uint32_t CalcTfrcBps(uint16_t rtt, uint8_t loss) { +uint32_t CalcTfrcBps(int64_t rtt, uint8_t loss) { if (rtt == 0 || loss == 0) { // Input variables out of range. return 0; @@ -89,7 +89,7 @@ void SendSideBandwidthEstimation::SetMinBitrate(uint32_t min_bitrate) { void SendSideBandwidthEstimation::CurrentEstimate(uint32_t* bitrate, uint8_t* loss, - uint32_t* rtt) const { + int64_t* rtt) const { *bitrate = bitrate_; *loss = last_fraction_loss_; *rtt = last_round_trip_time_ms_; @@ -101,7 +101,7 @@ void SendSideBandwidthEstimation::UpdateReceiverEstimate(uint32_t bandwidth) { } void SendSideBandwidthEstimation::UpdateReceiverBlock(uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, int number_of_packets, int64_t now_ms) { if (first_report_time_ms_ == -1) @@ -137,7 +137,7 @@ void SendSideBandwidthEstimation::UpdateReceiverBlock(uint8_t fraction_loss, } void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms, - int rtt, + int64_t rtt, int lost_packets) { if (IsInStartPhase(now_ms)) { initially_lost_packets_ += lost_packets; @@ -146,7 +146,8 @@ void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms, bitrate_at_2_seconds_kbps_ = (bitrate_ + 500) / 1000; RTC_HISTOGRAM_COUNTS( "WebRTC.BWE.InitiallyLostPackets", initially_lost_packets_, 0, 100, 50); - RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialRtt", rtt, 0, 2000, 50); + RTC_HISTOGRAM_COUNTS( + "WebRTC.BWE.InitialRtt", static_cast(rtt), 0, 2000, 50); RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialBandwidthEstimate", bitrate_at_2_seconds_kbps_, 0, @@ -203,8 +204,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + // rtt. if ((now_ms - time_last_decrease_ms_) >= - static_cast(kBweDecreaseIntervalMs + - last_round_trip_time_ms_)) { + (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { time_last_decrease_ms_ = now_ms; // Reduce rate: diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h index b8006e4e22..20ce5ee3af 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h @@ -24,7 +24,7 @@ class SendSideBandwidthEstimation { SendSideBandwidthEstimation(); virtual ~SendSideBandwidthEstimation(); - void CurrentEstimate(uint32_t* bitrate, uint8_t* loss, uint32_t* rtt) const; + void CurrentEstimate(uint32_t* bitrate, uint8_t* loss, int64_t* rtt) const; // Call periodically to update estimate. void UpdateEstimate(int64_t now_ms); @@ -34,7 +34,7 @@ class SendSideBandwidthEstimation { // Call when we receive a RTCP message with a ReceiveBlock. void UpdateReceiverBlock(uint8_t fraction_loss, - uint32_t rtt, + int64_t rtt, int number_of_packets, int64_t now_ms); @@ -50,7 +50,7 @@ class SendSideBandwidthEstimation { bool IsInStartPhase(int64_t now_ms) const; - void UpdateUmaStats(int64_t now_ms, int rtt, int lost_packets); + void UpdateUmaStats(int64_t now_ms, int64_t rtt, int lost_packets); // Returns the input bitrate capped to the thresholds defined by the max, // min and incoming bandwidth. @@ -73,7 +73,7 @@ class SendSideBandwidthEstimation { int64_t time_last_receiver_block_ms_; uint8_t last_fraction_loss_; - uint16_t last_round_trip_time_ms_; + int64_t last_round_trip_time_ms_; uint32_t bwe_incoming_; int64_t time_last_decrease_ms_; diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc index 4fe9ea970f..eed2d9ee8e 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc @@ -45,7 +45,7 @@ TEST(SendSideBweTest, InitialRembWithProbing) { bwe.UpdateEstimate(now_ms); uint32_t bitrate; uint8_t fraction_loss; - uint32_t rtt; + int64_t rtt; bwe.CurrentEstimate(&bitrate, &fraction_loss, &rtt); EXPECT_EQ(kRemb, bitrate); @@ -73,7 +73,7 @@ TEST(SendSideBweTest, InitialRembWithoutProbing) { bwe.UpdateEstimate(now_ms); uint32_t bitrate; uint8_t fraction_loss; - uint32_t rtt; + int64_t rtt; bwe.CurrentEstimate(&bitrate, &fraction_loss, &rtt); EXPECT_EQ(kStartBitrate, bitrate); } diff --git a/webrtc/modules/desktop_capture/desktop_frame.h b/webrtc/modules/desktop_capture/desktop_frame.h index 7bcc346f85..047ee63646 100644 --- a/webrtc/modules/desktop_capture/desktop_frame.h +++ b/webrtc/modules/desktop_capture/desktop_frame.h @@ -51,8 +51,8 @@ class DesktopFrame { void set_dpi(const DesktopVector& dpi) { dpi_ = dpi; } // Time taken to capture the frame in milliseconds. - int32_t capture_time_ms() const { return capture_time_ms_; } - void set_capture_time_ms(int32_t time_ms) { capture_time_ms_ = time_ms; } + int64_t capture_time_ms() const { return capture_time_ms_; } + void set_capture_time_ms(int64_t time_ms) { capture_time_ms_ = time_ms; } // Optional shape for the frame. Frames may be shaped e.g. if // capturing the contents of a shaped window. @@ -87,7 +87,7 @@ class DesktopFrame { DesktopRegion updated_region_; DesktopVector dpi_; - int32_t capture_time_ms_; + int64_t capture_time_ms_; scoped_ptr shape_; private: diff --git a/webrtc/modules/interface/module_common_types.h b/webrtc/modules/interface/module_common_types.h index fea76ce449..5cb2c56108 100644 --- a/webrtc/modules/interface/module_common_types.h +++ b/webrtc/modules/interface/module_common_types.h @@ -279,7 +279,7 @@ struct FecProtectionParams { // CallStats object using RegisterStatsObserver. class CallStatsObserver { public: - virtual void OnRttUpdate(uint32_t rtt_ms) = 0; + virtual void OnRttUpdate(int64_t rtt_ms) = 0; virtual ~CallStatsObserver() {} }; diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc index f6a4864b96..bed5d99cab 100644 --- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -18,7 +18,7 @@ namespace webrtc { -static const uint32_t kDefaultRttMs = 200; +static const int64_t kDefaultRttMs = 200; static const int64_t kLogIntervalMs = 1000; static const double kWithinIncomingBitrateHysteresis = 1.05; @@ -66,7 +66,8 @@ int64_t AimdRateControl::GetFeedbackInterval() const { bool AimdRateControl::TimeToReduceFurther(int64_t time_now, uint32_t incoming_bitrate_bps) const { - const int bitrate_reduction_interval = std::max(std::min(rtt_, 200u), 10u); + const int64_t bitrate_reduction_interval = + std::max(std::min(rtt_, 200), 10); if (time_now - time_last_bitrate_change_ >= bitrate_reduction_interval) { return true; } @@ -93,7 +94,7 @@ uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) { return current_bitrate_bps_; } -void AimdRateControl::SetRtt(uint32_t rtt) { +void AimdRateControl::SetRtt(int64_t rtt) { rtt_ = rtt; } @@ -168,7 +169,7 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, } if (rate_control_region_ == kRcNearMax) { // Approximate the over-use estimator delay to 100 ms. - const uint32_t response_time = rtt_ + 100; + const int64_t response_time = rtt_ + 100; uint32_t additive_increase_bps = AdditiveRateIncrease( now_ms, time_last_bitrate_change_, response_time); BWE_TEST_LOGGING_PLOT("add_increase#1", -1, @@ -253,7 +254,7 @@ uint32_t AimdRateControl::MultiplicativeRateIncrease( } uint32_t AimdRateControl::AdditiveRateIncrease( - int64_t now_ms, int64_t last_ms, uint32_t response_time_ms) const { + int64_t now_ms, int64_t last_ms, int64_t response_time_ms) const { assert(response_time_ms > 0); double beta = 0.0; if (last_ms > 0) { diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h index a8620717dd..b5aee769c7 100644 --- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h +++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h @@ -39,7 +39,7 @@ class AimdRateControl : public RemoteRateControl { int64_t time_now, uint32_t incoming_bitrate_bps) const OVERRIDE; virtual uint32_t LatestEstimate() const OVERRIDE; virtual uint32_t UpdateBandwidthEstimate(int64_t now_ms) OVERRIDE; - virtual void SetRtt(uint32_t rtt) OVERRIDE; + virtual void SetRtt(int64_t rtt) OVERRIDE; virtual RateControlRegion Update(const RateControlInput* input, int64_t now_ms) OVERRIDE; virtual void SetEstimate(int bitrate_bps, int64_t now_ms) OVERRIDE; @@ -58,7 +58,7 @@ class AimdRateControl : public RemoteRateControl { uint32_t MultiplicativeRateIncrease(int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const; uint32_t AdditiveRateIncrease(int64_t now_ms, int64_t last_ms, - uint32_t response_time_ms) const; + int64_t response_time_ms) const; void UpdateChangePeriod(int64_t now_ms); void UpdateMaxBitRateEstimate(float incoming_bit_rate_kbps); void ChangeState(const RateControlInput& input, int64_t now_ms); @@ -80,7 +80,7 @@ class AimdRateControl : public RemoteRateControl { int64_t time_first_incoming_estimate_; bool bitrate_is_initialized_; float beta_; - uint32_t rtt_; + int64_t rtt_; int64_t time_of_last_log_; DISALLOW_IMPLICIT_CONSTRUCTORS(AimdRateControl); diff --git a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc index 941409c74d..ab8f4db826 100644 --- a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc +++ b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc @@ -17,7 +17,7 @@ namespace webrtc { -const uint32_t kDefaultRttMs = 200; +const int64_t kDefaultRttMs = 200; const int64_t kLogIntervalMs = 1000; MimdRateControl::MimdRateControl(uint32_t min_bitrate_bps) @@ -61,7 +61,8 @@ int64_t MimdRateControl::GetFeedbackInterval() const { bool MimdRateControl::TimeToReduceFurther(int64_t time_now, uint32_t incoming_bitrate_bps) const { - const int bitrate_reduction_interval = std::max(std::min(rtt_, 200u), 10u); + const int64_t bitrate_reduction_interval = + std::max(std::min(rtt_, 200), 10); if (time_now - last_bit_rate_change_ >= bitrate_reduction_interval) { return true; } @@ -88,7 +89,7 @@ uint32_t MimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) { return current_bit_rate_; } -void MimdRateControl::SetRtt(uint32_t rtt) { +void MimdRateControl::SetRtt(int64_t rtt) { rtt_ = rtt; } @@ -156,8 +157,8 @@ uint32_t MimdRateControl::ChangeBitRate(uint32_t current_bit_rate, ChangeRegion(kRcAboveMax); } } - const uint32_t response_time = static_cast(avg_change_period_ + - 0.5f) + rtt_ + 300; + const int64_t response_time = + static_cast(avg_change_period_ + 0.5f) + rtt_ + 300; double alpha = RateIncreaseFactor(now_ms, last_bit_rate_change_, response_time, noise_var); @@ -215,9 +216,9 @@ uint32_t MimdRateControl::ChangeBitRate(uint32_t current_bit_rate, } double MimdRateControl::RateIncreaseFactor(int64_t now_ms, - int64_t last_ms, - uint32_t reaction_time_ms, - double noise_var) const { + int64_t last_ms, + int64_t reaction_time_ms, + double noise_var) const { // alpha = 1.02 + B ./ (1 + exp(b*(tr - (c1*s2 + c2)))) // Parameters const double B = 0.0407; diff --git a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h index 94c9b6be72..1b1862c6fe 100644 --- a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h +++ b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h @@ -33,7 +33,7 @@ class MimdRateControl : public RemoteRateControl { int64_t time_now, uint32_t incoming_bitrate_bps) const OVERRIDE; virtual uint32_t LatestEstimate() const OVERRIDE; virtual uint32_t UpdateBandwidthEstimate(int64_t now_ms) OVERRIDE; - virtual void SetRtt(uint32_t rtt) OVERRIDE; + virtual void SetRtt(int64_t rtt) OVERRIDE; virtual RateControlRegion Update(const RateControlInput* input, int64_t now_ms) OVERRIDE; virtual void SetEstimate(int bitrate_bps, int64_t now_ms) OVERRIDE; @@ -45,7 +45,7 @@ class MimdRateControl : public RemoteRateControl { int64_t now_ms); double RateIncreaseFactor(int64_t now_ms, int64_t last_ms, - uint32_t reaction_time_ms, + int64_t reaction_time_ms, double noise_var) const; void UpdateChangePeriod(int64_t now_ms); void UpdateMaxBitRateEstimate(float incoming_bit_rate_kbps); @@ -70,7 +70,7 @@ class MimdRateControl : public RemoteRateControl { float avg_change_period_; int64_t last_change_ms_; float beta_; - uint32_t rtt_; + int64_t rtt_; int64_t time_of_last_log_; DISALLOW_IMPLICIT_CONSTRUCTORS(MimdRateControl); diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc index 5398834e01..98f5893d3e 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc @@ -84,7 +84,7 @@ class RemoteBitrateEstimatorAbsSendTimeImpl : public RemoteBitrateEstimator { // deleted. virtual int32_t Process() OVERRIDE; virtual int64_t TimeUntilNextProcess() OVERRIDE; - virtual void OnRttUpdate(uint32_t rtt) OVERRIDE; + virtual void OnRttUpdate(int64_t rtt) OVERRIDE; virtual void RemoveStream(unsigned int ssrc) OVERRIDE; virtual bool LatestEstimate(std::vector* ssrcs, unsigned int* bitrate_bps) const OVERRIDE; @@ -419,7 +419,7 @@ void RemoteBitrateEstimatorAbsSendTimeImpl::UpdateEstimate(int64_t now_ms) { detector_.SetRateControlRegion(region); } -void RemoteBitrateEstimatorAbsSendTimeImpl::OnRttUpdate(uint32_t rtt) { +void RemoteBitrateEstimatorAbsSendTimeImpl::OnRttUpdate(int64_t rtt) { CriticalSectionScoped cs(crit_sect_.get()); remote_rate_->SetRtt(rtt); } 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 47e6b0252e..c3de19bf32 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 @@ -41,7 +41,7 @@ class RemoteBitrateEstimatorImpl : public RemoteBitrateEstimator { const RTPHeader& header) OVERRIDE; virtual int32_t Process() OVERRIDE; virtual int64_t TimeUntilNextProcess() OVERRIDE; - virtual void OnRttUpdate(uint32_t rtt) OVERRIDE; + virtual void OnRttUpdate(int64_t rtt) OVERRIDE; virtual void RemoveStream(unsigned int ssrc) OVERRIDE; virtual bool LatestEstimate(std::vector* ssrcs, unsigned int* bitrate_bps) const OVERRIDE; @@ -230,7 +230,7 @@ void RemoteBitrateEstimatorImpl::UpdateEstimate(int64_t now_ms) { } } -void RemoteBitrateEstimatorImpl::OnRttUpdate(uint32_t rtt) { +void RemoteBitrateEstimatorImpl::OnRttUpdate(int64_t rtt) { CriticalSectionScoped cs(crit_sect_.get()); remote_rate_->SetRtt(rtt); } diff --git a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h index 41d92537d8..4398c57fa6 100644 --- a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h +++ b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h @@ -38,7 +38,7 @@ class RemoteRateControl { uint32_t incoming_bitrate_bps) const = 0; virtual uint32_t LatestEstimate() const = 0; virtual uint32_t UpdateBandwidthEstimate(int64_t now_ms) = 0; - virtual void SetRtt(unsigned int rtt) = 0; + virtual void SetRtt(int64_t rtt) = 0; virtual RateControlRegion Update(const RateControlInput* input, int64_t now_ms) = 0; virtual void SetEstimate(int bitrate_bps, int64_t time_now_ms) = 0; diff --git a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h index b3aa733f7b..701d8dd3af 100644 --- a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h +++ b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h @@ -41,7 +41,7 @@ class StreamStatistician { // Returns true if the packet with RTP header |header| is likely to be a // retransmitted packet, false otherwise. virtual bool IsRetransmitOfOldPacket(const RTPHeader& header, - int min_rtt) const = 0; + int64_t min_rtt) const = 0; // Returns true if |sequence_number| is received in order, false otherwise. virtual bool IsPacketInOrder(uint16_t sequence_number) const = 0; diff --git a/webrtc/modules/rtp_rtcp/interface/remote_ntp_time_estimator.h b/webrtc/modules/rtp_rtcp/interface/remote_ntp_time_estimator.h index c237986a27..80f18032fe 100644 --- a/webrtc/modules/rtp_rtcp/interface/remote_ntp_time_estimator.h +++ b/webrtc/modules/rtp_rtcp/interface/remote_ntp_time_estimator.h @@ -31,7 +31,7 @@ class RemoteNtpTimeEstimator { // Updates the estimator with round trip time |rtt|, NTP seconds |ntp_secs|, // NTP fraction |ntp_frac| and RTP timestamp |rtcp_timestamp|. - bool UpdateRtcpTimestamp(uint16_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, + bool UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, uint32_t rtp_timestamp); // Estimates the NTP timestamp in local timebase from |rtp_timestamp|. diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h index 6b9a5542e1..52dfeabf78 100644 --- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h +++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h @@ -376,10 +376,10 @@ class RtpRtcp : public Module { * return -1 on failure else 0 */ virtual int32_t RTT(uint32_t remoteSSRC, - uint16_t* RTT, - uint16_t* avgRTT, - uint16_t* minRTT, - uint16_t* maxRTT) const = 0; + int64_t* RTT, + int64_t* avgRTT, + int64_t* minRTT, + int64_t* maxRTT) const = 0; /* * Force a send of a RTCP packet diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h index b1903a4032..76091a16c0 100644 --- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h +++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h @@ -287,7 +287,7 @@ class RtcpBandwidthObserver { virtual void OnReceivedRtcpReceiverReport( const ReportBlockList& report_blocks, - uint16_t rtt, + int64_t rtt, int64_t now_ms) = 0; virtual ~RtcpBandwidthObserver() {} @@ -295,9 +295,9 @@ class RtcpBandwidthObserver { class RtcpRttStats { public: - virtual void OnRttUpdate(uint32_t rtt) = 0; + virtual void OnRttUpdate(int64_t rtt) = 0; - virtual uint32_t LastProcessedRtt() const = 0; + virtual int64_t LastProcessedRtt() const = 0; virtual ~RtcpRttStats() {}; }; diff --git a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h index 31fade4791..3ea1626aa2 100644 --- a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h +++ b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h @@ -155,7 +155,11 @@ class MockRtpRtcp : public RtpRtcp { MOCK_METHOD1(RemoveMixedCNAME, int32_t(const uint32_t SSRC)); MOCK_CONST_METHOD5(RTT, - int32_t(const uint32_t remoteSSRC, uint16_t* RTT, uint16_t* avgRTT, uint16_t* minRTT, uint16_t* maxRTT)); + int32_t(const uint32_t remoteSSRC, + int64_t* RTT, + int64_t* avgRTT, + int64_t* minRTT, + int64_t* maxRTT)); MOCK_METHOD1(SendRTCP, int32_t(uint32_t rtcpPacketType)); MOCK_METHOD1(SendRTCPReferencePictureSelection, diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc index 76b2075e60..302c42cbc2 100644 --- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc +++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc @@ -345,7 +345,7 @@ void StreamStatisticianImpl::LastReceiveTimeNtp(uint32_t* secs, } bool StreamStatisticianImpl::IsRetransmitOfOldPacket( - const RTPHeader& header, int min_rtt) const { + const RTPHeader& header, int64_t min_rtt) const { CriticalSectionScoped cs(stream_lock_.get()); if (InOrderPacketInternal(header.sequenceNumber)) { return false; @@ -358,17 +358,16 @@ bool StreamStatisticianImpl::IsRetransmitOfOldPacket( // Diff in time stamp since last received in order. uint32_t timestamp_diff = header.timestamp - last_received_timestamp_; - int32_t rtp_time_stamp_diff_ms = static_cast(timestamp_diff) / - frequency_khz; + uint32_t rtp_time_stamp_diff_ms = timestamp_diff / frequency_khz; - int32_t max_delay_ms = 0; + int64_t max_delay_ms = 0; if (min_rtt == 0) { // Jitter standard deviation in samples. float jitter_std = sqrt(static_cast(jitter_q4_ >> 4)); // 2 times the standard deviation => 95% confidence. // And transform to milliseconds by dividing by the frequency in kHz. - max_delay_ms = static_cast((2 * jitter_std) / frequency_khz); + max_delay_ms = static_cast((2 * jitter_std) / frequency_khz); // Min max_delay_ms is 1. if (max_delay_ms == 0) { diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h index 22e42eadba..4b02f36388 100644 --- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h +++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h @@ -38,7 +38,7 @@ class StreamStatisticianImpl : public StreamStatistician { virtual uint32_t BitrateReceived() const OVERRIDE; virtual void ResetStatistics() OVERRIDE; virtual bool IsRetransmitOfOldPacket(const RTPHeader& header, - int min_rtt) const OVERRIDE; + int64_t min_rtt) const OVERRIDE; virtual bool IsPacketInOrder(uint16_t sequence_number) const OVERRIDE; void IncomingPacket(const RTPHeader& rtp_header, diff --git a/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc b/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc index 8e2651c623..0c968bdb61 100644 --- a/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc +++ b/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc @@ -28,7 +28,7 @@ RemoteNtpTimeEstimator::RemoteNtpTimeEstimator(Clock* clock) RemoteNtpTimeEstimator::~RemoteNtpTimeEstimator() {} -bool RemoteNtpTimeEstimator::UpdateRtcpTimestamp(uint16_t rtt, +bool RemoteNtpTimeEstimator::UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, uint32_t rtcp_timestamp) { diff --git a/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc b/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc index a320a85793..45817b01e6 100644 --- a/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc @@ -21,7 +21,7 @@ using ::testing::SetArgPointee; namespace webrtc { -static const int kTestRtt = 10; +static const int64_t kTestRtt = 10; static const int64_t kLocalClockInitialTimeMs = 123; static const int64_t kRemoteClockInitialTimeMs = 345; static const uint32_t kTimestampOffset = 567; @@ -54,14 +54,14 @@ class RemoteNtpTimeEstimatorTest : public ::testing::Test { ReceiveRtcpSr(kTestRtt, rtcp_timestamp, ntp_seconds, ntp_fractions); } - void UpdateRtcpTimestamp(uint16_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, + void UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, uint32_t rtp_timestamp, bool expected_result) { EXPECT_EQ(expected_result, estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp)); } - void ReceiveRtcpSr(uint16_t rtt, + void ReceiveRtcpSr(int64_t rtt, uint32_t rtcp_timestamp, uint32_t ntp_seconds, uint32_t ntp_fractions) { diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc index 3978332c22..a4e51f5169 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -163,10 +163,10 @@ void RTCPReceiver::SetSsrcs(uint32_t main_ssrc, } int32_t RTCPReceiver::RTT(uint32_t remoteSSRC, - uint16_t* RTT, - uint16_t* avgRTT, - uint16_t* minRTT, - uint16_t* maxRTT) const { + int64_t* RTT, + int64_t* avgRTT, + int64_t* minRTT, + int64_t* maxRTT) const { CriticalSectionScoped lock(_criticalSectionRTCPReceiver); RTCPReportBlockInformation* reportBlock = @@ -190,7 +190,7 @@ int32_t RTCPReceiver::RTT(uint32_t remoteSSRC, return 0; } -bool RTCPReceiver::GetAndResetXrRrRtt(uint16_t* rtt_ms) { +bool RTCPReceiver::GetAndResetXrRrRtt(int64_t* rtt_ms) { assert(rtt_ms); CriticalSectionScoped lock(_criticalSectionRTCPReceiver); if (xr_rr_rtt_ms_ == 0) { @@ -480,7 +480,7 @@ void RTCPReceiver::HandleReportBlock( // To avoid problem with acquiring _criticalSectionRTCPSender while holding // _criticalSectionRTCPReceiver. _criticalSectionRTCPReceiver->Leave(); - uint32_t sendTimeMS = + int64_t sendTimeMS = _rtpRtcp.SendTimeOfSendReport(rtcpPacket.ReportBlockItem.LastSR); _criticalSectionRTCPReceiver->Enter(); @@ -526,15 +526,15 @@ void RTCPReceiver::HandleReportBlock( _clock->CurrentNtp(lastReceivedRRNTPsecs, lastReceivedRRNTPfrac); // time when we received this in MS - uint32_t receiveTimeMS = Clock::NtpToMs(lastReceivedRRNTPsecs, - lastReceivedRRNTPfrac); + int64_t receiveTimeMS = Clock::NtpToMs(lastReceivedRRNTPsecs, + lastReceivedRRNTPfrac); // Estimate RTT uint32_t d = (delaySinceLastSendReport & 0x0000ffff) * 1000; d /= 65536; d += ((delaySinceLastSendReport & 0xffff0000) >> 16) * 1000; - int32_t RTT = 0; + int64_t RTT = 0; if (sendTimeMS > 0) { RTT = receiveTimeMS - d - sendTimeMS; @@ -543,27 +543,27 @@ void RTCPReceiver::HandleReportBlock( } if (RTT > reportBlock->maxRTT) { // store max RTT - reportBlock->maxRTT = (uint16_t) RTT; + reportBlock->maxRTT = RTT; } if (reportBlock->minRTT == 0) { // first RTT - reportBlock->minRTT = (uint16_t) RTT; + reportBlock->minRTT = RTT; } else if (RTT < reportBlock->minRTT) { // Store min RTT - reportBlock->minRTT = (uint16_t) RTT; + reportBlock->minRTT = RTT; } // store last RTT - reportBlock->RTT = (uint16_t) RTT; + reportBlock->RTT = RTT; // store average RTT if (reportBlock->numAverageCalcs != 0) { - float ac = static_cast (reportBlock->numAverageCalcs); - float newAverage = ((ac / (ac + 1)) * reportBlock->avgRTT) - + ((1 / (ac + 1)) * RTT); - reportBlock->avgRTT = static_cast (newAverage + 0.5f); + float ac = static_cast(reportBlock->numAverageCalcs); + float newAverage = + ((ac / (ac + 1)) * reportBlock->avgRTT) + ((1 / (ac + 1)) * RTT); + reportBlock->avgRTT = static_cast(newAverage + 0.5f); } else { // first RTT - reportBlock->avgRTT = (uint16_t) RTT; + reportBlock->avgRTT = RTT; } reportBlock->numAverageCalcs++; } @@ -962,9 +962,9 @@ void RTCPReceiver::HandleXrDlrrReportBlockItem( (((packet.XRDLRRReportBlockItem.DelayLastRR & 0x0000ffff) * 1000) >> 16) + (((packet.XRDLRRReportBlockItem.DelayLastRR & 0xffff0000) >> 16) * 1000); - int32_t rtt = _clock->CurrentNtpInMilliseconds() - delay_rr_ms - send_time_ms; + int64_t rtt = _clock->CurrentNtpInMilliseconds() - delay_rr_ms - send_time_ms; - xr_rr_rtt_ms_ = static_cast(std::max(rtt, 1)); + xr_rr_rtt_ms_ = std::max(rtt, 1); rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock; } diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h index 223da7692f..0301977419 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h @@ -71,14 +71,14 @@ public: // get rtt int32_t RTT(uint32_t remoteSSRC, - uint16_t* RTT, - uint16_t* avgRTT, - uint16_t* minRTT, - uint16_t* maxRTT) const; + int64_t* RTT, + int64_t* avgRTT, + int64_t* minRTT, + int64_t* maxRTT) const; int32_t SenderInfoReceived(RTCPSenderInfo* senderInfo) const; - bool GetAndResetXrRrRtt(uint16_t* rtt_ms); + bool GetAndResetXrRrRtt(int64_t* rtt_ms); // get statistics int32_t StatisticsReceived( @@ -257,7 +257,7 @@ protected: uint32_t _lastReceivedXRNTPsecs; uint32_t _lastReceivedXRNTPfrac; // Estimated rtt, zero when there is no valid estimate. - uint16_t xr_rr_rtt_ms_; + int64_t xr_rr_rtt_ms_; // Received report blocks. ReportBlockMap _receivedReportBlockMap diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h index 0ca43fa53e..73ac7a5c0e 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h @@ -34,11 +34,11 @@ public: uint32_t remoteMaxJitter; // RTT - uint16_t RTT; - uint16_t minRTT; - uint16_t maxRTT; - uint16_t avgRTT; - uint32_t numAverageCalcs; + int64_t RTT; + int64_t minRTT; + int64_t maxRTT; + int64_t avgRTT; + uint32_t numAverageCalcs; }; class RTCPPacketInformation @@ -68,7 +68,7 @@ public: uint16_t applicationLength; ReportBlockList report_blocks; - uint16_t rtt; + int64_t rtt; uint32_t interArrivalJitter; diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index a7d84778e0..cceb544980 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -744,7 +744,7 @@ TEST_F(RtcpReceiverTest, InjectXrPacketWithUnknownReportBlock) { } TEST_F(RtcpReceiverTest, TestXrRrRttInitiallyFalse) { - uint16_t rtt_ms; + int64_t rtt_ms; EXPECT_FALSE(rtcp_receiver_->GetAndResetXrRrRtt(&rtt_ms)); } diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc index c896d14ec6..95256ba8c2 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -438,8 +438,7 @@ From RFC 3550 return false; } -uint32_t -RTCPSender::LastSendReport( uint32_t& lastRTCPTime) +uint32_t RTCPSender::LastSendReport(int64_t& lastRTCPTime) { CriticalSectionScoped lock(_criticalSectionRTCPSender); @@ -447,7 +446,7 @@ RTCPSender::LastSendReport( uint32_t& lastRTCPTime) return _lastSendReport[0]; } -uint32_t RTCPSender::SendTimeOfSendReport(uint32_t sendReport) { +int64_t RTCPSender::SendTimeOfSendReport(uint32_t sendReport) { CriticalSectionScoped lock(_criticalSectionRTCPSender); // This is only saved when we are the sender diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h index 0cb08aa2e9..255d8adce3 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h @@ -103,13 +103,13 @@ public: int32_t RemoveMixedCNAME(uint32_t SSRC); - uint32_t SendTimeOfSendReport(uint32_t sendReport); + int64_t SendTimeOfSendReport(uint32_t sendReport); bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const; bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const; - uint32_t LastSendReport(uint32_t& lastRTCPTime); + uint32_t LastSendReport(int64_t& lastRTCPTime); int32_t SendRTCP( const FeedbackState& feedback_state, @@ -310,7 +310,7 @@ private: // Sent uint32_t _lastSendReport[RTCP_NUMBER_OF_SR] GUARDED_BY( _criticalSectionRTCPSender); // allow packet loss and RTT above 1 sec - uint32_t _lastRTCPTime[RTCP_NUMBER_OF_SR] GUARDED_BY( + int64_t _lastRTCPTime[RTCP_NUMBER_OF_SR] GUARDED_BY( _criticalSectionRTCPSender); // Sent XR receiver reference time report. diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc index 2546ac08df..455f3dcbfe 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -178,7 +178,7 @@ bool RTPPacketHistory::HasRTPPacket(uint16_t sequence_number) const { } bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number, - uint32_t min_elapsed_time_ms, + int64_t min_elapsed_time_ms, bool retransmit, uint8_t* packet, size_t* packet_length, diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h index eea3f123a4..9d58125401 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h @@ -53,7 +53,7 @@ class RTPPacketHistory { // stored_time_ms: returns the time when the packet was stored. // type: returns the storage type set in PutRTPPacket. bool GetPacketAndSetSendTime(uint16_t sequence_number, - uint32_t min_elapsed_time_ms, + int64_t min_elapsed_time_ms, bool retransmit, uint8_t* packet, size_t* packet_length, diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 4dd74cee41..817a6be832 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -181,10 +181,10 @@ int32_t ModuleRtpRtcpImpl::Process() { last_rtt_process_time_ && process_rtt) { std::vector receive_blocks; rtcp_receiver_.StatisticsReceived(&receive_blocks); - uint16_t max_rtt = 0; + int64_t max_rtt = 0; for (std::vector::iterator it = receive_blocks.begin(); it != receive_blocks.end(); ++it) { - uint16_t rtt = 0; + int64_t rtt = 0; rtcp_receiver_.RTT(it->remoteSSRC, &rtt, NULL, NULL, NULL); max_rtt = (rtt > max_rtt) ? rtt : max_rtt; } @@ -216,7 +216,7 @@ int32_t ModuleRtpRtcpImpl::Process() { } else { // Report rtt from receiver. if (process_rtt) { - uint16_t rtt_ms; + int64_t rtt_ms; if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) { rtt_stats_->OnRttUpdate(rtt_ms); } @@ -707,7 +707,7 @@ void ModuleRtpRtcpImpl::SetRTCPStatus(const RTCPMethod method) { // Only for internal test. uint32_t ModuleRtpRtcpImpl::LastSendReport( - uint32_t& last_rtcptime) { + int64_t& last_rtcptime) { return rtcp_sender_.LastSendReport(last_rtcptime); } @@ -747,14 +747,14 @@ int32_t ModuleRtpRtcpImpl::RemoteNTP( // Get RoundTripTime. int32_t ModuleRtpRtcpImpl::RTT(const uint32_t remote_ssrc, - uint16_t* rtt, - uint16_t* avg_rtt, - uint16_t* min_rtt, - uint16_t* max_rtt) const { + int64_t* rtt, + int64_t* avg_rtt, + int64_t* min_rtt, + int64_t* max_rtt) const { int32_t ret = rtcp_receiver_.RTT(remote_ssrc, rtt, avg_rtt, min_rtt, max_rtt); if (rtt && *rtt == 0) { // Try to get RTT from RtcpRttStats class. - *rtt = static_cast(rtt_ms()); + *rtt = rtt_ms(); } return ret; } @@ -944,7 +944,7 @@ int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list, bool ModuleRtpRtcpImpl::TimeToSendFullNackList(int64_t now) const { // Use RTT from RtcpRttStats class if provided. - uint16_t rtt = rtt_ms(); + int64_t rtt = rtt_ms(); if (rtt == 0) { rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); } @@ -1244,7 +1244,7 @@ int32_t ModuleRtpRtcpImpl::SendRTCPReferencePictureSelection( GetFeedbackState(), kRtcpRpsi, 0, 0, false, picture_id); } -uint32_t ModuleRtpRtcpImpl::SendTimeOfSendReport( +int64_t ModuleRtpRtcpImpl::SendTimeOfSendReport( const uint32_t send_report) { return rtcp_sender_.SendTimeOfSendReport(send_report); } @@ -1261,7 +1261,7 @@ void ModuleRtpRtcpImpl::OnReceivedNACK( return; } // Use RTT from RtcpRttStats class if provided. - uint16_t rtt = rtt_ms(); + int64_t rtt = rtt_ms(); if (rtt == 0) { rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); } @@ -1324,12 +1324,12 @@ void ModuleRtpRtcpImpl::SetRtcpReceiverSsrcs(uint32_t main_ssrc) { rtcp_receiver_.SetSsrcs(main_ssrc, ssrcs); } -void ModuleRtpRtcpImpl::set_rtt_ms(uint32_t rtt_ms) { +void ModuleRtpRtcpImpl::set_rtt_ms(int64_t rtt_ms) { CriticalSectionScoped cs(critical_section_rtt_.get()); rtt_ms_ = rtt_ms; } -uint32_t ModuleRtpRtcpImpl::rtt_ms() const { +int64_t ModuleRtpRtcpImpl::rtt_ms() const { CriticalSectionScoped cs(critical_section_rtt_.get()); return rtt_ms_; } diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h index ec067832f4..306f49aeef 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -158,10 +158,10 @@ class ModuleRtpRtcpImpl : public RtpRtcp { // Get RoundTripTime. virtual int32_t RTT(uint32_t remote_ssrc, - uint16_t* rtt, - uint16_t* avg_rtt, - uint16_t* min_rtt, - uint16_t* max_rtt) const OVERRIDE; + int64_t* rtt, + int64_t* avg_rtt, + int64_t* min_rtt, + int64_t* max_rtt) const OVERRIDE; // Force a send of an RTCP packet. // Normal SR and RR are triggered via the process function. @@ -326,7 +326,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp { uint32_t* fec_rate, uint32_t* nackRate) const OVERRIDE; - uint32_t SendTimeOfSendReport(uint32_t send_report); + int64_t SendTimeOfSendReport(uint32_t send_report); bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const; @@ -367,7 +367,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp { uint16_t RemoteSequenceNumber() const; // Only for internal testing. - uint32_t LastSendReport(uint32_t& last_rtcptime); + uint32_t LastSendReport(int64_t& last_rtcptime); RTPSender rtp_sender_; @@ -382,8 +382,8 @@ class ModuleRtpRtcpImpl : public RtpRtcp { int64_t RtcpReportInterval(); void SetRtcpReceiverSsrcs(uint32_t main_ssrc); - void set_rtt_ms(uint32_t rtt_ms); - uint32_t rtt_ms() const; + void set_rtt_ms(int64_t rtt_ms); + int64_t rtt_ms() const; bool TimeToSendFullNackList(int64_t now) const; @@ -419,7 +419,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp { // The processed RTT from RtcpRttStats. scoped_ptr critical_section_rtt_; - uint32_t rtt_ms_; + int64_t rtt_ms_; }; } // namespace webrtc 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 3f9e95fa08..7f209eaf52 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc @@ -31,7 +31,7 @@ namespace { const uint32_t kSenderSsrc = 0x12345; const uint32_t kReceiverSsrc = 0x23456; const uint32_t kSenderRtxSsrc = 0x32345; -const uint32_t kOneWayNetworkDelayMs = 100; +const int64_t kOneWayNetworkDelayMs = 100; const uint8_t kBaseLayerTid = 0; const uint8_t kHigherLayerTid = 1; const uint16_t kSequenceNumber = 100; @@ -41,13 +41,13 @@ class RtcpRttStatsTestImpl : public RtcpRttStats { RtcpRttStatsTestImpl() : rtt_ms_(0) {} virtual ~RtcpRttStatsTestImpl() {} - virtual void OnRttUpdate(uint32_t rtt_ms) OVERRIDE { + virtual void OnRttUpdate(int64_t rtt_ms) OVERRIDE { rtt_ms_ = rtt_ms; } - virtual uint32_t LastProcessedRtt() const OVERRIDE { + virtual int64_t LastProcessedRtt() const OVERRIDE { return rtt_ms_; } - uint32_t rtt_ms_; + int64_t rtt_ms_; }; class SendTransport : public Transport, @@ -63,7 +63,7 @@ class SendTransport : public Transport, void SetRtpRtcpModule(ModuleRtpRtcpImpl* receiver) { receiver_ = receiver; } - void SimulateNetworkDelay(uint32_t delay_ms, SimulatedClock* clock) { + void SimulateNetworkDelay(int64_t delay_ms, SimulatedClock* clock) { clock_ = clock; delay_ms_ = delay_ms; } @@ -92,7 +92,7 @@ class SendTransport : public Transport, } ModuleRtpRtcpImpl* receiver_; SimulatedClock* clock_; - uint32_t delay_ms_; + int64_t delay_ms_; int rtp_packets_sent_; RTPHeader last_rtp_header_; std::vector last_nack_list_; @@ -277,10 +277,10 @@ TEST_F(RtpRtcpImplTest, Rtt) { EXPECT_EQ(0, receiver_.impl_->SendRTCP(kRtcpReport)); // Verify RTT. - uint16_t rtt; - uint16_t avg_rtt; - uint16_t min_rtt; - uint16_t max_rtt; + int64_t rtt; + int64_t avg_rtt; + int64_t min_rtt; + int64_t max_rtt; EXPECT_EQ(0, sender_.impl_->RTT(kReceiverSsrc, &rtt, &avg_rtt, &min_rtt, &max_rtt)); EXPECT_EQ(2 * kOneWayNetworkDelayMs, rtt); @@ -293,8 +293,8 @@ TEST_F(RtpRtcpImplTest, Rtt) { sender_.impl_->RTT(kReceiverSsrc+1, &rtt, &avg_rtt, &min_rtt, &max_rtt)); // Verify RTT from rtt_stats config. - EXPECT_EQ(0U, sender_.rtt_stats_.LastProcessedRtt()); - EXPECT_EQ(0U, sender_.impl_->rtt_ms()); + EXPECT_EQ(0, sender_.rtt_stats_.LastProcessedRtt()); + EXPECT_EQ(0, sender_.impl_->rtt_ms()); sender_.impl_->Process(); EXPECT_EQ(2 * kOneWayNetworkDelayMs, sender_.rtt_stats_.LastProcessedRtt()); EXPECT_EQ(2 * kOneWayNetworkDelayMs, sender_.impl_->rtt_ms()); @@ -317,8 +317,8 @@ TEST_F(RtpRtcpImplTest, RttForReceiverOnly) { EXPECT_EQ(0, sender_.impl_->SendRTCP(kRtcpReport)); // Verify RTT. - EXPECT_EQ(0U, receiver_.rtt_stats_.LastProcessedRtt()); - EXPECT_EQ(0U, receiver_.impl_->rtt_ms()); + EXPECT_EQ(0, receiver_.rtt_stats_.LastProcessedRtt()); + EXPECT_EQ(0, receiver_.impl_->rtt_ms()); receiver_.impl_->Process(); EXPECT_EQ(2 * kOneWayNetworkDelayMs, receiver_.rtt_stats_.LastProcessedRtt()); EXPECT_EQ(2 * kOneWayNetworkDelayMs, receiver_.impl_->rtt_ms()); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc index a1810f24f1..6801cfd781 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc @@ -653,7 +653,7 @@ bool RTPSender::StorePackets() const { return packet_history_.StorePackets(); } -int32_t RTPSender::ReSendPacket(uint16_t packet_id, uint32_t min_resend_time) { +int32_t RTPSender::ReSendPacket(uint16_t packet_id, int64_t min_resend_time) { size_t length = IP_PACKET_SIZE; uint8_t data_buffer[IP_PACKET_SIZE]; int64_t capture_time_ms; @@ -720,7 +720,7 @@ int RTPSender::SetSelectiveRetransmissions(uint8_t settings) { } void RTPSender::OnReceivedNACK(const std::list& nack_sequence_numbers, - uint16_t avg_rtt) { + int64_t avg_rtt) { TRACE_EVENT2("webrtc_rtp", "RTPSender::OnReceivedNACK", "num_seqnum", nack_sequence_numbers.size(), "avg_rtt", avg_rtt); const int64_t now = clock_->TimeInMilliseconds(); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.h b/webrtc/modules/rtp_rtcp/source/rtp_sender.h index 2703fea760..d2ee2fa40a 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.h @@ -173,13 +173,13 @@ class RTPSender : public RTPSenderInterface { int SelectiveRetransmissions() const; int SetSelectiveRetransmissions(uint8_t settings); void OnReceivedNACK(const std::list& nack_sequence_numbers, - uint16_t avg_rtt); + int64_t avg_rtt); void SetStorePacketsStatus(bool enable, uint16_t number_to_store); bool StorePackets() const; - int32_t ReSendPacket(uint16_t packet_id, uint32_t min_resend_time = 0); + int32_t ReSendPacket(uint16_t packet_id, int64_t min_resend_time = 0); bool ProcessNACKBitRate(uint32_t now); diff --git a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc index bf06d7fb06..78c065e2f6 100644 --- a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc +++ b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc @@ -319,10 +319,10 @@ TEST_F(RtpRtcpRtcpTest, RTCP) { EXPECT_EQ(test_sequence_number, stats.extended_max_sequence_number); EXPECT_EQ(reportBlockReceived.jitter, stats.jitter); - uint16_t RTT; - uint16_t avgRTT; - uint16_t minRTT; - uint16_t maxRTT; + int64_t RTT; + int64_t avgRTT; + int64_t minRTT; + int64_t maxRTT; // Get RoundTripTime. EXPECT_EQ(0, module1->RTT(test_ssrc + 1, &RTT, &avgRTT, &minRTT, &maxRTT)); diff --git a/webrtc/modules/video_capture/include/video_capture.h b/webrtc/modules/video_capture/include/video_capture.h index 6e728d152e..50539ea06d 100644 --- a/webrtc/modules/video_capture/include/video_capture.h +++ b/webrtc/modules/video_capture/include/video_capture.h @@ -87,7 +87,7 @@ class VideoCaptureModule: public RefCountedModule { // - packetLoss : Fraction lost // (loss rate in percent = 100 * packetLoss / 255). // - rtt : Round-trip time in milliseconds. - virtual int32_t SetChannelParameters(uint32_t packetLoss, int rtt) = 0; + virtual int32_t SetChannelParameters(uint32_t packetLoss, int64_t rtt) = 0; // Encode the next frame as key frame. virtual int32_t EncodeFrameType(const FrameType type) = 0; 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 2d41fd069c..7fef06078d 100644 --- a/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h +++ b/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h @@ -73,7 +73,7 @@ class I420Encoder : public VideoEncoder { } virtual int SetChannelParameters(uint32_t /*packetLoss*/, - int /*rtt*/) OVERRIDE { + int64_t /*rtt*/) OVERRIDE { return WEBRTC_VIDEO_CODEC_OK; } 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 4758aa11ee..ad72071840 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 @@ -39,7 +39,7 @@ class MockVideoEncoder : public VideoEncoder { int32_t(EncodedImageCallback* callback)); MOCK_METHOD0(Release, int32_t()); MOCK_METHOD0(Reset, int32_t()); - MOCK_METHOD2(SetChannelParameters, int32_t(uint32_t packetLoss, int rtt)); + MOCK_METHOD2(SetChannelParameters, int32_t(uint32_t packetLoss, int64_t rtt)); MOCK_METHOD2(SetRates, int32_t(uint32_t newBitRate, uint32_t frameRate)); MOCK_METHOD1(SetPeriodicKeyFrames, int32_t(bool enable)); MOCK_METHOD2(CodecConfigParameters, diff --git a/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.cc b/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.cc index 5e258c37b9..a922e35712 100644 --- a/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.cc +++ b/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.cc @@ -78,7 +78,8 @@ int ReferencePictureSelection::EncodeFlags(int picture_id, bool send_refresh, // enough for an RPSI to arrive after the decoder decoded the reference frame. // Ideally that should happen after one round-trip time. // Add a margin defined by |kRttConfidence|. - uint32_t update_interval = kRttConfidence * rtt_; + int64_t update_interval = static_cast(kRttConfidence * rtt_); + const int64_t kMinUpdateInterval = 90 * 10; // Timestamp frequency if (update_interval < kMinUpdateInterval) update_interval = kMinUpdateInterval; // Don't send reference frame updates until we have an established reference. @@ -114,13 +115,13 @@ void ReferencePictureSelection::EncodedKeyFrame(int picture_id) { received_ack_ = false; } -void ReferencePictureSelection::SetRtt(int rtt) { +void ReferencePictureSelection::SetRtt(int64_t rtt) { // Convert from milliseconds to timestamp frequency. rtt_ = 90 * rtt; } -uint32_t ReferencePictureSelection::TimestampDiff(uint32_t new_ts, - uint32_t old_ts) { +int64_t ReferencePictureSelection::TimestampDiff(uint32_t new_ts, + uint32_t old_ts) { if (old_ts > new_ts) { // Assuming this is a wrap, doing a compensated subtraction. return (new_ts + (static_cast(1) << 32)) - old_ts; diff --git a/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.h b/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.h index a47b8de856..51acc4c182 100644 --- a/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.h +++ b/webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.h @@ -54,13 +54,11 @@ class ReferencePictureSelection { // Set the round-trip time between the sender and the receiver to |rtt| // milliseconds. - void SetRtt(int rtt); + void SetRtt(int64_t rtt); private: - static uint32_t TimestampDiff(uint32_t new_ts, uint32_t old_ts); + static int64_t TimestampDiff(uint32_t new_ts, uint32_t old_ts); - // The minimum time between reference frame updates. - enum { kMinUpdateInterval = 90 * 10 }; // Timestamp frequency const double kRttConfidence; bool update_golden_next_; @@ -70,7 +68,7 @@ class ReferencePictureSelection { uint32_t last_sent_ref_update_time_; int established_ref_picture_id_; uint32_t last_refresh_time_; - uint32_t rtt_; + int64_t rtt_; }; } // namespace webrtc diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc index 38a5bddf47..d37308b012 100644 --- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc +++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc @@ -297,7 +297,7 @@ int SimulcastEncoderAdapter::RegisterEncodeCompleteCallback( } int SimulcastEncoderAdapter::SetChannelParameters(uint32_t packet_loss, - int rtt) { + int64_t rtt) { for (size_t stream_idx = 0; stream_idx < streaminfos_.size(); ++stream_idx) { streaminfos_[stream_idx].encoder->SetChannelParameters(packet_loss, rtt); } diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h index 8b27bed750..51127fbef8 100644 --- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h +++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h @@ -47,7 +47,7 @@ class SimulcastEncoderAdapter : public VP8Encoder, const std::vector* frame_types) OVERRIDE; virtual int RegisterEncodeCompleteCallback( EncodedImageCallback* callback) OVERRIDE; - virtual int SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; + virtual int SetChannelParameters(uint32_t packet_loss, int64_t rtt) OVERRIDE; virtual int SetRates(uint32_t new_bitrate_kbit, uint32_t new_framerate) OVERRIDE; diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc index 8f2eb7a0b3..870dcc72d2 100644 --- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc +++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc @@ -132,7 +132,7 @@ class MockVideoEncoder : public VideoEncoder { } MOCK_METHOD2(SetChannelParameters, - int32_t(uint32_t packetLoss, int rtt)); + int32_t(uint32_t packetLoss, int64_t rtt)); virtual ~MockVideoEncoder() { } @@ -175,7 +175,7 @@ class TestSimulcastEncoderAdapterFakeHelper { return new SimulcastEncoderAdapter(scoped_factory.Pass()); } - void ExpectCallSetChannelParameters(uint32_t packetLoss, int rtt) { + void ExpectCallSetChannelParameters(uint32_t packetLoss, int64_t rtt) { EXPECT_TRUE(!factory_->encoders().empty()); for (size_t i = 0; i < factory_->encoders().size(); ++i) { EXPECT_CALL(*factory_->encoders()[i], @@ -295,7 +295,7 @@ TEST_F(TestSimulcastEncoderAdapterFake, InitEncode) { TEST_F(TestSimulcastEncoderAdapterFake, SetChannelParameters) { SetupCodec(); const uint32_t packetLoss = 5; - const int rtt = 30; + const int64_t rtt = 30; helper_->ExpectCallSetChannelParameters(packetLoss, rtt); adapter_->SetChannelParameters(packetLoss, rtt); } diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc index 21b07bc45a..d871eb82b6 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc @@ -1024,7 +1024,7 @@ int VP8EncoderImpl::GetEncodedPartitions( return WEBRTC_VIDEO_CODEC_OK; } -int VP8EncoderImpl::SetChannelParameters(uint32_t packetLoss, int rtt) { +int VP8EncoderImpl::SetChannelParameters(uint32_t packetLoss, int64_t rtt) { rps_.SetRtt(rtt); return WEBRTC_VIDEO_CODEC_OK; } diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h index 82b2f24c3b..c9bdb98975 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h @@ -51,7 +51,7 @@ class VP8EncoderImpl : public VP8Encoder { virtual int RegisterEncodeCompleteCallback(EncodedImageCallback* callback); - virtual int SetChannelParameters(uint32_t packet_loss, int rtt); + virtual int SetChannelParameters(uint32_t packet_loss, int64_t rtt); virtual int SetRates(uint32_t new_bitrate_kbit, uint32_t frame_rate); diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc index 486acdf61d..5491bd08ab 100644 --- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc @@ -334,7 +334,7 @@ int VP9EncoderImpl::GetEncodedPartitions(const I420VideoFrame& input_image) { return WEBRTC_VIDEO_CODEC_OK; } -int VP9EncoderImpl::SetChannelParameters(uint32_t packet_loss, int rtt) { +int VP9EncoderImpl::SetChannelParameters(uint32_t packet_loss, int64_t rtt) { return WEBRTC_VIDEO_CODEC_OK; } diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h index ee40749b70..6c9f1ab564 100644 --- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h +++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h @@ -38,7 +38,7 @@ class VP9EncoderImpl : public VP9Encoder { virtual int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) OVERRIDE; - virtual int SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; + virtual int SetChannelParameters(uint32_t packet_loss, int64_t rtt) OVERRIDE; virtual int SetRates(uint32_t new_bitrate_kbit, uint32_t frame_rate) OVERRIDE; diff --git a/webrtc/modules/video_coding/main/interface/video_coding.h b/webrtc/modules/video_coding/main/interface/video_coding.h index 94e8f9de01..f1ce2ec5a3 100644 --- a/webrtc/modules/video_coding/main/interface/video_coding.h +++ b/webrtc/modules/video_coding/main/interface/video_coding.h @@ -196,8 +196,8 @@ public: // Return value : VCM_OK, on success. // < 0, on error. virtual int32_t SetChannelParameters(uint32_t target_bitrate, - uint8_t lossRate, - uint32_t rtt) = 0; + uint8_t lossRate, + int64_t rtt) = 0; // Sets the parameters describing the receive channel. These parameters are inputs to the // Media Optimization inside the VCM. @@ -209,7 +209,7 @@ public: // // Return value : VCM_OK, on success. // < 0, on error. - virtual int32_t SetReceiveChannelParameters(uint32_t rtt) = 0; + virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0; // Register a transport callback which will be called to deliver the encoded data and // side information. diff --git a/webrtc/modules/video_coding/main/source/generic_encoder.cc b/webrtc/modules/video_coding/main/source/generic_encoder.cc index 096287f228..6baf83324f 100644 --- a/webrtc/modules/video_coding/main/source/generic_encoder.cc +++ b/webrtc/modules/video_coding/main/source/generic_encoder.cc @@ -106,7 +106,7 @@ VCMGenericEncoder::Encode(const I420VideoFrame& inputFrame, } int32_t -VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int rtt) +VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int64_t rtt) { return _encoder.SetChannelParameters(packetLoss, rtt); } diff --git a/webrtc/modules/video_coding/main/source/generic_encoder.h b/webrtc/modules/video_coding/main/source/generic_encoder.h index a986ada2ab..70569fa7dc 100644 --- a/webrtc/modules/video_coding/main/source/generic_encoder.h +++ b/webrtc/modules/video_coding/main/source/generic_encoder.h @@ -103,7 +103,7 @@ public: /** * Set a new packet loss rate and a new round-trip time in milliseconds. */ - int32_t SetChannelParameters(int32_t packetLoss, int rtt); + int32_t SetChannelParameters(int32_t packetLoss, int64_t rtt); int32_t CodecConfigParameters(uint8_t* buffer, int32_t size); /** * Register a transport callback which will be called to deliver the encoded diff --git a/webrtc/modules/video_coding/main/source/jitter_buffer.cc b/webrtc/modules/video_coding/main/source/jitter_buffer.cc index 2a590df69f..14f33ff332 100644 --- a/webrtc/modules/video_coding/main/source/jitter_buffer.cc +++ b/webrtc/modules/video_coding/main/source/jitter_buffer.cc @@ -31,7 +31,7 @@ namespace webrtc { // Use this rtt if no value has been reported. -static const uint32_t kDefaultRtt = 200; +static const int64_t kDefaultRtt = 200; typedef std::pair FrameListPair; @@ -783,7 +783,7 @@ uint32_t VCMJitterBuffer::EstimatedJitterMs() { // low_rtt_nackThresholdMs_ == -1 means no FEC. double rtt_mult = 1.0f; if (low_rtt_nack_threshold_ms_ >= 0 && - static_cast(rtt_ms_) >= low_rtt_nack_threshold_ms_) { + rtt_ms_ >= low_rtt_nack_threshold_ms_) { // For RTTs above low_rtt_nack_threshold_ms_ we don't apply extra delay // when waiting for retransmissions. rtt_mult = 0.0f; @@ -791,15 +791,15 @@ uint32_t VCMJitterBuffer::EstimatedJitterMs() { return jitter_estimate_.GetJitterEstimate(rtt_mult); } -void VCMJitterBuffer::UpdateRtt(uint32_t rtt_ms) { +void VCMJitterBuffer::UpdateRtt(int64_t rtt_ms) { CriticalSectionScoped cs(crit_sect_); rtt_ms_ = rtt_ms; jitter_estimate_.UpdateRtt(rtt_ms); } void VCMJitterBuffer::SetNackMode(VCMNackMode mode, - int low_rtt_nack_threshold_ms, - int high_rtt_nack_threshold_ms) { + int64_t low_rtt_nack_threshold_ms, + int64_t high_rtt_nack_threshold_ms) { CriticalSectionScoped cs(crit_sect_); nack_mode_ = mode; if (mode == kNoNack) { @@ -1214,7 +1214,7 @@ bool VCMJitterBuffer::WaitForRetransmissions() { // Evaluate if the RTT is higher than |high_rtt_nack_threshold_ms_|, and in // that case we don't wait for retransmissions. if (high_rtt_nack_threshold_ms_ >= 0 && - rtt_ms_ >= static_cast(high_rtt_nack_threshold_ms_)) { + rtt_ms_ >= high_rtt_nack_threshold_ms_) { return false; } return true; diff --git a/webrtc/modules/video_coding/main/source/jitter_buffer.h b/webrtc/modules/video_coding/main/source/jitter_buffer.h index 5ac2b7aabc..7857aaa383 100644 --- a/webrtc/modules/video_coding/main/source/jitter_buffer.h +++ b/webrtc/modules/video_coding/main/source/jitter_buffer.h @@ -153,7 +153,7 @@ class VCMJitterBuffer { uint32_t EstimatedJitterMs(); // Updates the round-trip time estimate. - void UpdateRtt(uint32_t rtt_ms); + void UpdateRtt(int64_t rtt_ms); // Set the NACK mode. |highRttNackThreshold| is an RTT threshold in ms above // which NACK will be disabled if the NACK mode is |kNackHybrid|, -1 meaning @@ -161,8 +161,8 @@ class VCMJitterBuffer { // |lowRttNackThreshold| is an RTT threshold in ms below which we expect to // rely on NACK only, and therefore are using larger buffers to have time to // wait for retransmissions. - void SetNackMode(VCMNackMode mode, int low_rtt_nack_threshold_ms, - int high_rtt_nack_threshold_ms); + void SetNackMode(VCMNackMode mode, int64_t low_rtt_nack_threshold_ms, + int64_t high_rtt_nack_threshold_ms); void SetNackSettings(size_t max_nack_list_size, int max_packet_age_to_nack, @@ -331,12 +331,12 @@ class VCMJitterBuffer { // Calculates network delays used for jitter calculations. VCMInterFrameDelay inter_frame_delay_; VCMJitterSample waiting_for_completion_; - uint32_t rtt_ms_; + int64_t rtt_ms_; // NACK and retransmissions. VCMNackMode nack_mode_; - int low_rtt_nack_threshold_ms_; - int high_rtt_nack_threshold_ms_; + int64_t low_rtt_nack_threshold_ms_; + int64_t high_rtt_nack_threshold_ms_; // Holds the internal NACK list (the missing sequence numbers). SequenceNumberSet missing_sequence_numbers_; uint16_t latest_received_sequence_number_; diff --git a/webrtc/modules/video_coding/main/source/jitter_estimator.cc b/webrtc/modules/video_coding/main/source/jitter_estimator.cc index b36775a4ab..9024443006 100644 --- a/webrtc/modules/video_coding/main/source/jitter_estimator.cc +++ b/webrtc/modules/video_coding/main/source/jitter_estimator.cc @@ -406,7 +406,7 @@ VCMJitterEstimator::PostProcessEstimate() } void -VCMJitterEstimator::UpdateRtt(uint32_t rttMs) +VCMJitterEstimator::UpdateRtt(int64_t rttMs) { _rttFilter.Update(rttMs); } diff --git a/webrtc/modules/video_coding/main/source/jitter_estimator.h b/webrtc/modules/video_coding/main/source/jitter_estimator.h index ec7e35cef8..46ed67ba1d 100644 --- a/webrtc/modules/video_coding/main/source/jitter_estimator.h +++ b/webrtc/modules/video_coding/main/source/jitter_estimator.h @@ -59,7 +59,7 @@ public: // // Input: // - rttMs : RTT in ms - void UpdateRtt(uint32_t rttMs); + void UpdateRtt(int64_t rttMs); void UpdateMaxFrameSize(uint32_t frameSizeBytes); diff --git a/webrtc/modules/video_coding/main/source/media_opt_util.cc b/webrtc/modules/video_coding/main/source/media_opt_util.cc index b506a5b5c2..79e1268c6d 100644 --- a/webrtc/modules/video_coding/main/source/media_opt_util.cc +++ b/webrtc/modules/video_coding/main/source/media_opt_util.cc @@ -53,8 +53,8 @@ VCMProtectionMethod::UpdateContentMetrics(const _qmRobustness->UpdateContent(contentMetrics); } -VCMNackFecMethod::VCMNackFecMethod(int lowRttNackThresholdMs, - int highRttNackThresholdMs) +VCMNackFecMethod::VCMNackFecMethod(int64_t lowRttNackThresholdMs, + int64_t highRttNackThresholdMs) : VCMFecMethod(), _lowRttNackMs(lowRttNackThresholdMs), _highRttNackMs(highRttNackThresholdMs), @@ -159,6 +159,8 @@ bool VCMNackFecMethod::BitRateTooLowForFec( } // TODO (marpan): add condition based on maximum frames used for FEC, // and expand condition based on frame size. + // Max round trip time threshold in ms. + const int64_t kMaxRttTurnOffFec = 200; if (estimate_bytes_per_frame < max_bytes_per_frame && parameters->numLayers < 3 && parameters->rtt < kMaxRttTurnOffFec) { @@ -737,7 +739,7 @@ VCMLossProtectionLogic::RequiredBitRate() const } void -VCMLossProtectionLogic::UpdateRtt(uint32_t rtt) +VCMLossProtectionLogic::UpdateRtt(int64_t rtt) { _rtt = rtt; } diff --git a/webrtc/modules/video_coding/main/source/media_opt_util.h b/webrtc/modules/video_coding/main/source/media_opt_util.h index d421d9e7ca..3b6fa8fcd6 100644 --- a/webrtc/modules/video_coding/main/source/media_opt_util.h +++ b/webrtc/modules/video_coding/main/source/media_opt_util.h @@ -41,10 +41,7 @@ enum FilterPacketLossMode { // Thresholds for hybrid NACK/FEC // common to media optimization and the jitter buffer. -enum HybridNackTH { - kHighRttNackMs = 100, - kLowRttNackMs = 20 -}; +const int64_t kLowRttNackMs = 20; struct VCMProtectionParameters { @@ -55,7 +52,7 @@ struct VCMProtectionParameters numLayers(1) {} - int rtt; + int64_t rtt; float lossPr; float bitRate; float packetsPerFrame; @@ -211,16 +208,14 @@ protected: enum { kMaxBytesPerFrameForFecLow = 400 }; // Max bytes/frame for frame size larger than VGA, ~200k at 25fps. enum { kMaxBytesPerFrameForFecHigh = 1000 }; - // Max round trip time threshold in ms. - enum { kMaxRttTurnOffFec = 200 }; }; class VCMNackFecMethod : public VCMFecMethod { public: - VCMNackFecMethod(int lowRttNackThresholdMs, - int highRttNackThresholdMs); + VCMNackFecMethod(int64_t lowRttNackThresholdMs, + int64_t highRttNackThresholdMs); virtual ~VCMNackFecMethod(); virtual bool UpdateParameters(const VCMProtectionParameters* parameters); // Get the effective packet loss for ER @@ -234,8 +229,8 @@ public: private: int ComputeMaxFramesFec(const VCMProtectionParameters* parameters); - int _lowRttNackMs; - int _highRttNackMs; + int64_t _lowRttNackMs; + int64_t _highRttNackMs; int _maxFramesFec; }; @@ -267,7 +262,7 @@ public: // // Input: // - rtt : Round-trip time in seconds. - void UpdateRtt(uint32_t rtt); + void UpdateRtt(int64_t rtt); // Update residual packet loss // @@ -369,7 +364,7 @@ private: uint8_t MaxFilteredLossPr(int64_t nowMs) const; VCMProtectionMethod* _selectedMethod; VCMProtectionParameters _currentParameters; - uint32_t _rtt; + int64_t _rtt; float _lossPr; float _bitRate; float _frameRate; diff --git a/webrtc/modules/video_coding/main/source/media_optimization.cc b/webrtc/modules/video_coding/main/source/media_optimization.cc index 85cce8fbc5..1151d5b1f2 100644 --- a/webrtc/modules/video_coding/main/source/media_optimization.cc +++ b/webrtc/modules/video_coding/main/source/media_optimization.cc @@ -200,7 +200,7 @@ void MediaOptimization::SetEncodingDataInternal(VideoCodecType send_codec_type, uint32_t MediaOptimization::SetTargetRates( uint32_t target_bitrate, uint8_t fraction_lost, - uint32_t round_trip_time_ms, + int64_t round_trip_time_ms, VCMProtectionCallback* protection_callback, VCMQMSettingsCallback* qmsettings_callback) { CriticalSectionScoped lock(crit_sect_.get()); diff --git a/webrtc/modules/video_coding/main/source/media_optimization.h b/webrtc/modules/video_coding/main/source/media_optimization.h index 675d64e6cd..aa21921e12 100644 --- a/webrtc/modules/video_coding/main/source/media_optimization.h +++ b/webrtc/modules/video_coding/main/source/media_optimization.h @@ -58,7 +58,7 @@ class MediaOptimization { // an internal critical section. uint32_t SetTargetRates(uint32_t target_bitrate, uint8_t fraction_lost, - uint32_t round_trip_time_ms, + int64_t round_trip_time_ms, VCMProtectionCallback* protection_callback, VCMQMSettingsCallback* qmsettings_callback); diff --git a/webrtc/modules/video_coding/main/source/nack_fec_tables.h b/webrtc/modules/video_coding/main/source/nack_fec_tables.h index acf62bf025..b82bb1b4ba 100644 --- a/webrtc/modules/video_coding/main/source/nack_fec_tables.h +++ b/webrtc/modules/video_coding/main/source/nack_fec_tables.h @@ -15,9 +15,8 @@ namespace webrtc { // Table for adjusting FEC rate for NACK/FEC protection method -// Table values are built as a sigmoid function, ranging from 0 to -// kHighRttNackMs (100), based on the HybridNackTH values defined in -// media_opt_util.h. +// Table values are built as a sigmoid function, ranging from 0 to 100, based on +// the HybridNackTH values defined in media_opt_util.h. const uint16_t VCMNackFecTable[100] = { 0, 0, diff --git a/webrtc/modules/video_coding/main/source/qm_select.cc b/webrtc/modules/video_coding/main/source/qm_select.cc index 9255aed611..3007f63445 100644 --- a/webrtc/modules/video_coding/main/source/qm_select.cc +++ b/webrtc/modules/video_coding/main/source/qm_select.cc @@ -925,7 +925,7 @@ void VCMQmRobustness::Reset() { float VCMQmRobustness::AdjustFecFactor(uint8_t code_rate_delta, float total_rate, float framerate, - uint32_t rtt_time, + int64_t rtt_time, uint8_t packet_loss) { // Default: no adjustment float adjust_fec = 1.0f; diff --git a/webrtc/modules/video_coding/main/source/qm_select.h b/webrtc/modules/video_coding/main/source/qm_select.h index 654c078949..079e7f8879 100644 --- a/webrtc/modules/video_coding/main/source/qm_select.h +++ b/webrtc/modules/video_coding/main/source/qm_select.h @@ -353,7 +353,7 @@ class VCMQmRobustness : public VCMQmMethod { float AdjustFecFactor(uint8_t code_rate_delta, float total_rate, float framerate, - uint32_t rtt_time, + int64_t rtt_time, uint8_t packet_loss); // Set the UEP protection on/off. @@ -365,7 +365,7 @@ class VCMQmRobustness : public VCMQmMethod { private: // Previous state of network parameters. float prev_total_rate_; - uint32_t prev_rtt_time_; + int64_t prev_rtt_time_; uint8_t prev_packet_loss_; uint8_t prev_code_rate_delta_; }; diff --git a/webrtc/modules/video_coding/main/source/receiver.cc b/webrtc/modules/video_coding/main/source/receiver.cc index e1a4e2ff1b..c84d99223d 100644 --- a/webrtc/modules/video_coding/main/source/receiver.cc +++ b/webrtc/modules/video_coding/main/source/receiver.cc @@ -59,7 +59,7 @@ int32_t VCMReceiver::Initialize() { return VCM_OK; } -void VCMReceiver::UpdateRtt(uint32_t rtt) { +void VCMReceiver::UpdateRtt(int64_t rtt) { jitter_buffer_.UpdateRtt(rtt); } @@ -191,8 +191,8 @@ uint32_t VCMReceiver::DiscardedPackets() const { } void VCMReceiver::SetNackMode(VCMNackMode nackMode, - int low_rtt_nack_threshold_ms, - int high_rtt_nack_threshold_ms) { + int64_t low_rtt_nack_threshold_ms, + int64_t high_rtt_nack_threshold_ms) { CriticalSectionScoped cs(crit_sect_); // Default to always having NACK enabled in hybrid mode. jitter_buffer_.SetNackMode(nackMode, low_rtt_nack_threshold_ms, diff --git a/webrtc/modules/video_coding/main/source/receiver.h b/webrtc/modules/video_coding/main/source/receiver.h index 068715f795..f531ac8ea4 100644 --- a/webrtc/modules/video_coding/main/source/receiver.h +++ b/webrtc/modules/video_coding/main/source/receiver.h @@ -44,7 +44,7 @@ class VCMReceiver { void Reset(); int32_t Initialize(); - void UpdateRtt(uint32_t rtt); + void UpdateRtt(int64_t rtt); int32_t InsertPacket(const VCMPacket& packet, uint16_t frame_width, uint16_t frame_height); @@ -57,8 +57,8 @@ class VCMReceiver { // NACK. void SetNackMode(VCMNackMode nackMode, - int low_rtt_nack_threshold_ms, - int high_rtt_nack_threshold_ms); + int64_t low_rtt_nack_threshold_ms, + int64_t high_rtt_nack_threshold_ms); void SetNackSettings(size_t max_nack_list_size, int max_packet_age_to_nack, int max_incomplete_time_ms); diff --git a/webrtc/modules/video_coding/main/source/rtt_filter.cc b/webrtc/modules/video_coding/main/source/rtt_filter.cc index 739cc824c3..5742e8fa89 100644 --- a/webrtc/modules/video_coding/main/source/rtt_filter.cc +++ b/webrtc/modules/video_coding/main/source/rtt_filter.cc @@ -58,7 +58,7 @@ VCMRttFilter::Reset() } void -VCMRttFilter::Update(uint32_t rttMs) +VCMRttFilter::Update(int64_t rttMs) { if (!_gotNonZeroUpdate) { @@ -103,7 +103,7 @@ VCMRttFilter::Update(uint32_t rttMs) } bool -VCMRttFilter::JumpDetection(uint32_t rttMs) +VCMRttFilter::JumpDetection(int64_t rttMs) { double diffFromAvg = _avgRtt - rttMs; if (fabs(diffFromAvg) > _jumpStdDevs * sqrt(_varRtt)) @@ -147,7 +147,7 @@ VCMRttFilter::JumpDetection(uint32_t rttMs) } bool -VCMRttFilter::DriftDetection(uint32_t rttMs) +VCMRttFilter::DriftDetection(int64_t rttMs) { if (_maxRtt - _avgRtt > _driftStdDevs * sqrt(_varRtt)) { @@ -174,7 +174,7 @@ VCMRttFilter::DriftDetection(uint32_t rttMs) } void -VCMRttFilter::ShortRttFilter(uint32_t* buf, uint32_t length) +VCMRttFilter::ShortRttFilter(int64_t* buf, uint32_t length) { if (length == 0) { @@ -193,10 +193,10 @@ VCMRttFilter::ShortRttFilter(uint32_t* buf, uint32_t length) _avgRtt = _avgRtt / static_cast(length); } -uint32_t +int64_t VCMRttFilter::RttMs() const { - return static_cast(_maxRtt + 0.5); + return static_cast(_maxRtt + 0.5); } } diff --git a/webrtc/modules/video_coding/main/source/rtt_filter.h b/webrtc/modules/video_coding/main/source/rtt_filter.h index 8b816a0b46..9e14a1ab39 100644 --- a/webrtc/modules/video_coding/main/source/rtt_filter.h +++ b/webrtc/modules/video_coding/main/source/rtt_filter.h @@ -26,9 +26,9 @@ public: // Resets the filter. void Reset(); // Updates the filter with a new sample. - void Update(uint32_t rttMs); + void Update(int64_t rttMs); // A getter function for the current RTT level in ms. - uint32_t RttMs() const; + int64_t RttMs() const; private: // The size of the drift and jump memory buffers @@ -39,19 +39,19 @@ private: // samples and average to the standard deviation. // Returns true if the long time statistics should be updated // and false otherwise - bool JumpDetection(uint32_t rttMs); + bool JumpDetection(int64_t rttMs); // Detects RTT drifts by comparing the difference between // max and average to the standard deviation. // Returns true if the long time statistics should be updated // and false otherwise - bool DriftDetection(uint32_t rttMs); + bool DriftDetection(int64_t rttMs); // Computes the short time average and maximum of the vector buf. - void ShortRttFilter(uint32_t* buf, uint32_t length); + void ShortRttFilter(int64_t* buf, uint32_t length); bool _gotNonZeroUpdate; double _avgRtt; double _varRtt; - uint32_t _maxRtt; + int64_t _maxRtt; uint32_t _filtFactCount; const uint32_t _filtFactMax; const double _jumpStdDevs; @@ -59,8 +59,8 @@ private: int32_t _jumpCount; int32_t _driftCount; const int32_t _detectThreshold; - uint32_t _jumpBuf[kMaxDriftJumpCount]; - uint32_t _driftBuf[kMaxDriftJumpCount]; + int64_t _jumpBuf[kMaxDriftJumpCount]; + int64_t _driftBuf[kMaxDriftJumpCount]; }; } // namespace webrtc diff --git a/webrtc/modules/video_coding/main/source/session_info.cc b/webrtc/modules/video_coding/main/source/session_info.cc index c981829c08..361c0a1a22 100644 --- a/webrtc/modules/video_coding/main/source/session_info.cc +++ b/webrtc/modules/video_coding/main/source/session_info.cc @@ -14,18 +14,13 @@ #include "webrtc/system_wrappers/interface/logging.h" namespace webrtc { -namespace { -// Used in determining whether a frame is decodable. -enum {kRttThreshold = 100}; // Not decodable if Rtt is lower than this. -// Do not decode frames if the number of packets is between these two -// thresholds. -static const float kLowPacketPercentageThreshold = 0.2f; -static const float kHighPacketPercentageThreshold = 0.8f; +namespace { uint16_t BufferToUWord16(const uint8_t* dataBuffer) { return (dataBuffer[0] << 8) | dataBuffer[1]; } + } // namespace VCMSessionInfo::VCMSessionInfo() @@ -233,6 +228,12 @@ void VCMSessionInfo::UpdateDecodableSession(const FrameData& frame_data) { return; // TODO(agalusza): Account for bursty loss. // TODO(agalusza): Refine these values to better approximate optimal ones. + // Do not decode frames if the RTT is lower than this. + const int64_t kRttThreshold = 100; + // Do not decode frames if the number of packets is between these two + // thresholds. + const float kLowPacketPercentageThreshold = 0.2f; + const float kHighPacketPercentageThreshold = 0.8f; if (frame_data.rtt_ms < kRttThreshold || frame_type_ == kVideoFrameKey || !HaveFirstPacket() diff --git a/webrtc/modules/video_coding/main/source/session_info.h b/webrtc/modules/video_coding/main/source/session_info.h index cd55130ec7..21f6c437e3 100644 --- a/webrtc/modules/video_coding/main/source/session_info.h +++ b/webrtc/modules/video_coding/main/source/session_info.h @@ -22,7 +22,7 @@ namespace webrtc { // Used to pass data from jitter buffer to session info. // This data is then used in determining whether a frame is decodable. struct FrameData { - int rtt_ms; + int64_t rtt_ms; float rolling_average_packets_per_frame; }; 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 ac938e686b..b7c72da52b 100644 --- a/webrtc/modules/video_coding/main/source/video_coding_impl.cc +++ b/webrtc/modules/video_coding/main/source/video_coding_impl.cc @@ -142,7 +142,7 @@ class VideoCodingModuleImpl : public VideoCodingModule { virtual int32_t SetChannelParameters(uint32_t target_bitrate, // bits/s. uint8_t lossRate, - uint32_t rtt) OVERRIDE { + int64_t rtt) OVERRIDE { return sender_->SetChannelParameters(target_bitrate, lossRate, rtt); } @@ -332,7 +332,7 @@ class VideoCodingModuleImpl : public VideoCodingModule { return receiver_->SetMinReceiverDelay(desired_delay_ms); } - virtual int32_t SetReceiveChannelParameters(uint32_t rtt) OVERRIDE { + virtual int32_t SetReceiveChannelParameters(int64_t rtt) OVERRIDE { return receiver_->SetReceiveChannelParameters(rtt); } 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 3454e9cf1c..cf4a986264 100644 --- a/webrtc/modules/video_coding/main/source/video_coding_impl.h +++ b/webrtc/modules/video_coding/main/source/video_coding_impl.h @@ -79,7 +79,7 @@ class VideoSender { int32_t SetChannelParameters(uint32_t target_bitrate, // bits/s. uint8_t lossRate, - uint32_t rtt); + int64_t rtt); int32_t RegisterTransportCallback(VCMPacketizationCallback* transport); int32_t RegisterSendStatisticsCallback(VCMSendStatisticsCallback* sendStats); @@ -175,7 +175,7 @@ class VideoReceiver { void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode); int SetMinReceiverDelay(int desired_delay_ms); - int32_t SetReceiveChannelParameters(uint32_t rtt); + int32_t SetReceiveChannelParameters(int64_t rtt); int32_t SetVideoProtection(VCMVideoProtection videoProtection, bool enable); int64_t TimeUntilNextProcess(); diff --git a/webrtc/modules/video_coding/main/source/video_receiver.cc b/webrtc/modules/video_coding/main/source/video_receiver.cc index f623c7deb9..5d87553eed 100644 --- a/webrtc/modules/video_coding/main/source/video_receiver.cc +++ b/webrtc/modules/video_coding/main/source/video_receiver.cc @@ -168,7 +168,7 @@ int64_t VideoReceiver::TimeUntilNextProcess() { return timeUntilNextProcess; } -int32_t VideoReceiver::SetReceiveChannelParameters(uint32_t rtt) { +int32_t VideoReceiver::SetReceiveChannelParameters(int64_t rtt) { CriticalSectionScoped receiveCs(_receiveCritSect); _receiver.UpdateRtt(rtt); return 0; diff --git a/webrtc/modules/video_coding/main/source/video_sender.cc b/webrtc/modules/video_coding/main/source/video_sender.cc index 6fdc29d812..b2dd23e9d8 100644 --- a/webrtc/modules/video_coding/main/source/video_sender.cc +++ b/webrtc/modules/video_coding/main/source/video_sender.cc @@ -244,7 +244,7 @@ int VideoSender::FrameRate(unsigned int* framerate) const { // Set channel parameters int32_t VideoSender::SetChannelParameters(uint32_t target_bitrate, uint8_t lossRate, - uint32_t rtt) { + int64_t rtt) { int32_t ret = 0; { CriticalSectionScoped sendCs(_sendCritSect); 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 57398ebd13..662faa84a9 100644 --- a/webrtc/modules/video_coding/main/test/media_opt_test.h +++ b/webrtc/modules/video_coding/main/test/media_opt_test.h @@ -75,7 +75,7 @@ private: bool _nackEnabled; bool _fecEnabled; bool _nackFecEnabled; - uint8_t _rttMS; + int64_t _rttMS; float _bitRate; double _lossRate; uint32_t _renderDelayMs; diff --git a/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc b/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc index 35cd1f3850..d7beb46c2b 100644 --- a/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc +++ b/webrtc/modules/video_coding/main/test/mt_rx_tx_test.cc @@ -119,7 +119,7 @@ int MTRxTxTest(CmdArgs& args) // Nack support is currently not implemented in this test. bool nackEnabled = false; bool fecEnabled = false; - uint8_t rttMS = 20; + int64_t rttMS = 20; float lossRate = 0.0*255; // no packet loss uint32_t renderDelayMs = 0; uint32_t minPlayoutDelayMs = 0; diff --git a/webrtc/modules/video_coding/main/test/rtp_player.cc b/webrtc/modules/video_coding/main/test/rtp_player.cc index 02ae7c2974..5057f7d2e6 100644 --- a/webrtc/modules/video_coding/main/test/rtp_player.cc +++ b/webrtc/modules/video_coding/main/test/rtp_player.cc @@ -71,7 +71,7 @@ class RawRtpPacket { class LostPackets { public: - LostPackets(Clock* clock, uint32_t rtt_ms) + LostPackets(Clock* clock, int64_t rtt_ms) : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), debug_file_(fopen("PacketLossDebug.txt", "w")), loss_count_(0), @@ -180,7 +180,7 @@ class LostPackets { int loss_count_; RtpPacketList packets_; Clock* clock_; - uint32_t rtt_ms_; + int64_t rtt_ms_; DISALLOW_IMPLICIT_CONSTRUCTORS(LostPackets); }; @@ -323,7 +323,7 @@ class RtpPlayerImpl : public RtpPlayerInterface { RtpPlayerImpl(PayloadSinkFactoryInterface* payload_sink_factory, const PayloadTypes& payload_types, Clock* clock, scoped_ptr* packet_source, - float loss_rate, uint32_t rtt_ms, bool reordering) + float loss_rate, int64_t rtt_ms, bool reordering) : ssrc_handlers_(payload_sink_factory, payload_types), clock_(clock), next_rtp_time_(0), @@ -468,7 +468,7 @@ class RtpPlayerImpl : public RtpPlayerInterface { RtpPlayerInterface* Create(const std::string& input_filename, PayloadSinkFactoryInterface* payload_sink_factory, Clock* clock, - const PayloadTypes& payload_types, float loss_rate, uint32_t rtt_ms, + const PayloadTypes& payload_types, float loss_rate, int64_t rtt_ms, bool reordering) { scoped_ptr packet_source(test::RtpFileReader::Create( test::RtpFileReader::kRtpDump, input_filename)); diff --git a/webrtc/modules/video_coding/main/test/rtp_player.h b/webrtc/modules/video_coding/main/test/rtp_player.h index 1703618a24..7459231416 100644 --- a/webrtc/modules/video_coding/main/test/rtp_player.h +++ b/webrtc/modules/video_coding/main/test/rtp_player.h @@ -88,7 +88,7 @@ class RtpPlayerInterface { RtpPlayerInterface* Create(const std::string& inputFilename, PayloadSinkFactoryInterface* payloadSinkFactory, Clock* clock, - const PayloadTypes& payload_types, float lossRate, uint32_t rttMs, + const PayloadTypes& payload_types, float lossRate, int64_t rttMs, bool reordering); } // namespace rtpplayer 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 4b40cb39cb..76d54789de 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 @@ -108,7 +108,7 @@ VcmPayloadSinkFactory::VcmPayloadSinkFactory( Clock* clock, bool protection_enabled, VCMVideoProtection protection_method, - uint32_t rtt_ms, + int64_t rtt_ms, uint32_t render_delay_ms, uint32_t min_playout_delay_ms) : base_out_filename_(base_out_filename), diff --git a/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.h b/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.h index 130bd428da..0817423091 100644 --- a/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.h +++ b/webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.h @@ -28,7 +28,7 @@ class VcmPayloadSinkFactory : public PayloadSinkFactoryInterface { VcmPayloadSinkFactory(const std::string& base_out_filename, Clock* clock, bool protection_enabled, VCMVideoProtection protection_method, - uint32_t rtt_ms, uint32_t render_delay_ms, + int64_t rtt_ms, uint32_t render_delay_ms, uint32_t min_playout_delay_ms); virtual ~VcmPayloadSinkFactory(); @@ -50,7 +50,7 @@ class VcmPayloadSinkFactory : public PayloadSinkFactoryInterface { Clock* clock_; bool protection_enabled_; VCMVideoProtection protection_method_; - uint32_t rtt_ms_; + int64_t rtt_ms_; uint32_t render_delay_ms_; uint32_t min_playout_delay_ms_; scoped_ptr null_event_factory_; diff --git a/webrtc/modules/video_coding/main/test/video_rtp_play.cc b/webrtc/modules/video_coding/main/test/video_rtp_play.cc index b2850563f7..5f8ea35e74 100644 --- a/webrtc/modules/video_coding/main/test/video_rtp_play.cc +++ b/webrtc/modules/video_coding/main/test/video_rtp_play.cc @@ -20,7 +20,7 @@ const webrtc::VCMVideoProtection kConfigProtectionMethod = webrtc::kProtectionNack; const float kConfigLossRate = 0.0f; const bool kConfigReordering = false; -const uint32_t kConfigRttMs = 0; +const int64_t kConfigRttMs = 0; const uint32_t kConfigRenderDelayMs = 0; const uint32_t kConfigMinPlayoutDelayMs = 0; const int64_t kConfigMaxRuntimeMs = -1; diff --git a/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc b/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc index 8abd8b873d..f334db5840 100644 --- a/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc +++ b/webrtc/modules/video_coding/main/test/video_rtp_play_mt.cc @@ -26,7 +26,7 @@ const bool kConfigProtectionEnabled = true; const webrtc::VCMVideoProtection kConfigProtectionMethod = webrtc::kProtectionNack; const float kConfigLossRate = 0.05f; -const uint32_t kConfigRttMs = 50; +const int64_t kConfigRttMs = 50; const bool kConfigReordering = false; const uint32_t kConfigRenderDelayMs = 0; const uint32_t kConfigMinPlayoutDelayMs = 0; diff --git a/webrtc/test/configurable_frame_size_encoder.cc b/webrtc/test/configurable_frame_size_encoder.cc index f25f443dda..7d13be6897 100644 --- a/webrtc/test/configurable_frame_size_encoder.cc +++ b/webrtc/test/configurable_frame_size_encoder.cc @@ -69,7 +69,7 @@ int32_t ConfigurableFrameSizeEncoder::Release() { } int32_t ConfigurableFrameSizeEncoder::SetChannelParameters(uint32_t packet_loss, - int rtt) { + int64_t rtt) { return WEBRTC_VIDEO_CODEC_OK; } diff --git a/webrtc/test/configurable_frame_size_encoder.h b/webrtc/test/configurable_frame_size_encoder.h index 43c4b29620..17a02aacd9 100644 --- a/webrtc/test/configurable_frame_size_encoder.h +++ b/webrtc/test/configurable_frame_size_encoder.h @@ -38,7 +38,8 @@ class ConfigurableFrameSizeEncoder : public VideoEncoder { virtual int32_t Release() OVERRIDE; - virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; + virtual int32_t SetChannelParameters(uint32_t packet_loss, + int64_t rtt) OVERRIDE; virtual int32_t SetRates(uint32_t new_bit_rate, uint32_t frame_rate) OVERRIDE; diff --git a/webrtc/test/fake_encoder.cc b/webrtc/test/fake_encoder.cc index 42b6e9fe1b..cb763a5087 100644 --- a/webrtc/test/fake_encoder.cc +++ b/webrtc/test/fake_encoder.cc @@ -119,7 +119,7 @@ int32_t FakeEncoder::RegisterEncodeCompleteCallback( int32_t FakeEncoder::Release() { return 0; } -int32_t FakeEncoder::SetChannelParameters(uint32_t packet_loss, int rtt) { +int32_t FakeEncoder::SetChannelParameters(uint32_t packet_loss, int64_t rtt) { return 0; } diff --git a/webrtc/test/fake_encoder.h b/webrtc/test/fake_encoder.h index 4d31e1cc51..2cb28cac87 100644 --- a/webrtc/test/fake_encoder.h +++ b/webrtc/test/fake_encoder.h @@ -38,7 +38,8 @@ class FakeEncoder : public VideoEncoder { virtual int32_t RegisterEncodeCompleteCallback( EncodedImageCallback* callback) OVERRIDE; virtual int32_t Release() OVERRIDE; - virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; + virtual int32_t SetChannelParameters(uint32_t packet_loss, + int64_t rtt) OVERRIDE; virtual int32_t SetRates(uint32_t new_target_bitrate, uint32_t framerate) OVERRIDE; diff --git a/webrtc/video/video_send_stream.cc b/webrtc/video/video_send_stream.cc index b8ef4d3496..e61f5a2ee5 100644 --- a/webrtc/video/video_send_stream.cc +++ b/webrtc/video/video_send_stream.cc @@ -517,17 +517,17 @@ void VideoSendStream::SignalNetworkState(Call::NetworkState state) { rtp_rtcp_->SetRTCPStatus(channel_, kRtcpNone); } -int VideoSendStream::GetPacerQueuingDelayMs() const { - int pacer_delay_ms = 0; +int64_t VideoSendStream::GetPacerQueuingDelayMs() const { + int64_t pacer_delay_ms = 0; if (rtp_rtcp_->GetPacerQueuingDelayMs(channel_, &pacer_delay_ms) != 0) { return 0; } return pacer_delay_ms; } -int VideoSendStream::GetRtt() const { +int64_t VideoSendStream::GetRtt() const { webrtc::RtcpStatistics rtcp_stats; - int rtt_ms; + int64_t rtt_ms; if (rtp_rtcp_->GetSendChannelRtcpStatistics(channel_, rtcp_stats, rtt_ms) == 0) { return rtt_ms; diff --git a/webrtc/video/video_send_stream.h b/webrtc/video/video_send_stream.h index 6f7f400455..cff2fb111d 100644 --- a/webrtc/video/video_send_stream.h +++ b/webrtc/video/video_send_stream.h @@ -75,9 +75,9 @@ class VideoSendStream : public webrtc::VideoSendStream, void SetBitrateConfig(const Call::Config::BitrateConfig& bitrate_config); void SignalNetworkState(Call::NetworkState state); - int GetPacerQueuingDelayMs() const; + int64_t GetPacerQueuingDelayMs() const; - int GetRtt() const; + int64_t GetRtt() const; private: void ConfigureSsrcs(); diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc index 915bf9e35f..9d8ffb8835 100644 --- a/webrtc/video/video_send_stream_tests.cc +++ b/webrtc/video/video_send_stream_tests.cc @@ -258,7 +258,7 @@ class FakeReceiveStatistics : public NullReceiveStatistics { virtual uint32_t BitrateReceived() const OVERRIDE { return 0; } virtual void ResetStatistics() OVERRIDE {} virtual bool IsRetransmitOfOldPacket(const RTPHeader& header, - int min_rtt) const OVERRIDE { + int64_t min_rtt) const OVERRIDE { return false; } @@ -1302,7 +1302,7 @@ TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) { } virtual int32_t SetChannelParameters(uint32_t packetLoss, - int rtt) OVERRIDE { + int64_t rtt) OVERRIDE { EXPECT_TRUE(IsReadyForEncode()); return 0; } diff --git a/webrtc/video_encoder.h b/webrtc/video_encoder.h index a66a51a7d9..2a5a09f8dc 100644 --- a/webrtc/video_encoder.h +++ b/webrtc/video_encoder.h @@ -109,7 +109,7 @@ class VideoEncoder { // - rtt : Round-trip time in milliseconds // Return value : WEBRTC_VIDEO_CODEC_OK if OK // <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR - virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) = 0; + virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0; // Inform the encoder about the new target bit rate. // diff --git a/webrtc/video_engine/call_stats.cc b/webrtc/video_engine/call_stats.cc index 2d324ffc0e..6e51eebe5a 100644 --- a/webrtc/video_engine/call_stats.cc +++ b/webrtc/video_engine/call_stats.cc @@ -32,8 +32,8 @@ void RemoveOldReports(int64_t now, std::list* reports) { } } -uint32_t GetMaxRttMs(std::list* reports) { - uint32_t max_rtt_ms = 0; +int64_t GetMaxRttMs(std::list* reports) { + int64_t max_rtt_ms = 0; for (std::list::const_iterator it = reports->begin(); it != reports->end(); ++it) { max_rtt_ms = std::max(it->rtt, max_rtt_ms); @@ -41,11 +41,11 @@ uint32_t GetMaxRttMs(std::list* reports) { return max_rtt_ms; } -uint32_t GetAvgRttMs(std::list* reports) { +int64_t GetAvgRttMs(std::list* reports) { if (reports->empty()) { return 0; } - uint32_t sum = 0; + int64_t sum = 0; for (std::list::const_iterator it = reports->begin(); it != reports->end(); ++it) { sum += it->rtt; @@ -53,7 +53,7 @@ uint32_t GetAvgRttMs(std::list* reports) { return sum / reports->size(); } -void UpdateAvgRttMs(std::list* reports, uint32_t* avg_rtt) { +void UpdateAvgRttMs(std::list* reports, int64_t* avg_rtt) { uint32_t cur_rtt_ms = GetAvgRttMs(reports); if (cur_rtt_ms == 0) { // Reset. @@ -74,12 +74,12 @@ class RtcpObserver : public RtcpRttStats { explicit RtcpObserver(CallStats* owner) : owner_(owner) {} virtual ~RtcpObserver() {} - virtual void OnRttUpdate(uint32_t rtt) { + virtual void OnRttUpdate(int64_t rtt) { owner_->OnRttUpdate(rtt); } // Returns the average RTT. - virtual uint32_t LastProcessedRtt() const { + virtual int64_t LastProcessedRtt() const { return owner_->avg_rtt_ms(); } @@ -129,7 +129,7 @@ int32_t CallStats::Process() { return 0; } -uint32_t CallStats::avg_rtt_ms() const { +int64_t CallStats::avg_rtt_ms() const { CriticalSectionScoped cs(crit_.get()); return avg_rtt_ms_; } @@ -159,7 +159,7 @@ void CallStats::DeregisterStatsObserver(CallStatsObserver* observer) { } } -void CallStats::OnRttUpdate(uint32_t rtt) { +void CallStats::OnRttUpdate(int64_t rtt) { CriticalSectionScoped cs(crit_.get()); reports_.push_back(RttTime(rtt, TickTime::MillisecondTimestamp())); } diff --git a/webrtc/video_engine/call_stats.h b/webrtc/video_engine/call_stats.h index ce7a15a1af..da5c2e6c0d 100644 --- a/webrtc/video_engine/call_stats.h +++ b/webrtc/video_engine/call_stats.h @@ -45,16 +45,16 @@ class CallStats : public Module { // Helper struct keeping track of the time a rtt value is reported. struct RttTime { - RttTime(uint32_t new_rtt, int64_t rtt_time) + RttTime(int64_t new_rtt, int64_t rtt_time) : rtt(new_rtt), time(rtt_time) {} - const uint32_t rtt; + const int64_t rtt; const int64_t time; }; protected: - void OnRttUpdate(uint32_t rtt); + void OnRttUpdate(int64_t rtt); - uint32_t avg_rtt_ms() const; + int64_t avg_rtt_ms() const; private: // Protecting all members. @@ -64,8 +64,8 @@ class CallStats : public Module { // The last time 'Process' resulted in statistic update. int64_t last_process_time_; // The last RTT in the statistics update (zero if there is no valid estimate). - uint32_t max_rtt_ms_; - uint32_t avg_rtt_ms_; + int64_t max_rtt_ms_; + int64_t avg_rtt_ms_; // All Rtt reports within valid time interval, oldest first. std::list reports_; diff --git a/webrtc/video_engine/call_stats_unittest.cc b/webrtc/video_engine/call_stats_unittest.cc index 1196ada3ab..9f8f398502 100644 --- a/webrtc/video_engine/call_stats_unittest.cc +++ b/webrtc/video_engine/call_stats_unittest.cc @@ -27,7 +27,7 @@ class MockStatsObserver : public CallStatsObserver { MockStatsObserver() {} virtual ~MockStatsObserver() {} - MOCK_METHOD1(OnRttUpdate, void(uint32_t)); + MOCK_METHOD1(OnRttUpdate, void(int64_t)); }; class CallStatsTest : public ::testing::Test { @@ -44,21 +44,21 @@ TEST_F(CallStatsTest, AddAndTriggerCallback) { RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats(); call_stats_->RegisterStatsObserver(&stats_observer); TickTime::AdvanceFakeClock(1000); - EXPECT_EQ(0U, rtcp_rtt_stats->LastProcessedRtt()); + EXPECT_EQ(0, rtcp_rtt_stats->LastProcessedRtt()); - const uint32_t kRtt = 25; + const int64_t kRtt = 25; rtcp_rtt_stats->OnRttUpdate(kRtt); EXPECT_CALL(stats_observer, OnRttUpdate(kRtt)) .Times(1); call_stats_->Process(); EXPECT_EQ(kRtt, rtcp_rtt_stats->LastProcessedRtt()); - const int kRttTimeOutMs = 1500 + 10; + const int64_t kRttTimeOutMs = 1500 + 10; TickTime::AdvanceFakeClock(kRttTimeOutMs); EXPECT_CALL(stats_observer, OnRttUpdate(_)) .Times(0); call_stats_->Process(); - EXPECT_EQ(0U, rtcp_rtt_stats->LastProcessedRtt()); + EXPECT_EQ(0, rtcp_rtt_stats->LastProcessedRtt()); call_stats_->DeregisterStatsObserver(&stats_observer); } @@ -108,7 +108,7 @@ TEST_F(CallStatsTest, MultipleObservers) { call_stats_->RegisterStatsObserver(&stats_observer_2); RtcpRttStats* rtcp_rtt_stats = call_stats_->rtcp_rtt_stats(); - const uint32_t kRtt = 100; + const int64_t kRtt = 100; rtcp_rtt_stats->OnRttUpdate(kRtt); // Verify both observers are updated. @@ -151,7 +151,7 @@ TEST_F(CallStatsTest, ChangeRtt) { TickTime::AdvanceFakeClock(1000); // Set a first value and verify the callback is triggered. - const uint32_t kFirstRtt = 100; + const int64_t kFirstRtt = 100; rtcp_rtt_stats->OnRttUpdate(kFirstRtt); EXPECT_CALL(stats_observer, OnRttUpdate(kFirstRtt)) .Times(1); @@ -159,7 +159,7 @@ TEST_F(CallStatsTest, ChangeRtt) { // Increase rtt and verify the new value is reported. TickTime::AdvanceFakeClock(1000); - const uint32_t kHighRtt = kFirstRtt + 20; + const int64_t kHighRtt = kFirstRtt + 20; rtcp_rtt_stats->OnRttUpdate(kHighRtt); EXPECT_CALL(stats_observer, OnRttUpdate(kHighRtt)) .Times(1); @@ -169,7 +169,7 @@ TEST_F(CallStatsTest, ChangeRtt) { // rtt invalid. Report a lower rtt and verify the old/high value still is sent // in the callback. TickTime::AdvanceFakeClock(1000); - const uint32_t kLowRtt = kFirstRtt - 20; + const int64_t kLowRtt = kFirstRtt - 20; rtcp_rtt_stats->OnRttUpdate(kLowRtt); EXPECT_CALL(stats_observer, OnRttUpdate(kHighRtt)) .Times(1); @@ -193,9 +193,9 @@ TEST_F(CallStatsTest, LastProcessedRtt) { // Set a first values and verify that LastProcessedRtt initially returns the // average rtt. - const uint32_t kRttLow = 10; - const uint32_t kRttHigh = 30; - const uint32_t kAvgRtt = 20; + const int64_t kRttLow = 10; + const int64_t kRttHigh = 30; + const int64_t kAvgRtt = 20; rtcp_rtt_stats->OnRttUpdate(kRttLow); rtcp_rtt_stats->OnRttUpdate(kRttHigh); EXPECT_CALL(stats_observer, OnRttUpdate(kRttHigh)) diff --git a/webrtc/video_engine/include/vie_rtp_rtcp.h b/webrtc/video_engine/include/vie_rtp_rtcp.h index 103a196f63..051eba02c7 100644 --- a/webrtc/video_engine/include/vie_rtp_rtcp.h +++ b/webrtc/video_engine/include/vie_rtp_rtcp.h @@ -275,7 +275,7 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP { // stream. virtual int GetReceiveChannelRtcpStatistics(const int video_channel, RtcpStatistics& basic_stats, - int& rtt_ms) const = 0; + int64_t& rtt_ms) const = 0; // This function returns statistics reported by the remote client in RTCP // report blocks. If several streams are reported, the statistics will be @@ -284,16 +284,16 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP { // and will always be set to 0. virtual int GetSendChannelRtcpStatistics(const int video_channel, RtcpStatistics& basic_stats, - int& rtt_ms) const = 0; + int64_t& rtt_ms) const = 0; // TODO(sprang): Temporary hacks to prevent libjingle build from failing, // remove when libjingle has been lifted to support webrtc issue 2589 virtual int GetReceivedRTCPStatistics(const int video_channel, - unsigned short& fraction_lost, - unsigned int& cumulative_lost, - unsigned int& extended_max, - unsigned int& jitter, - int& rtt_ms) const { + unsigned short& fraction_lost, + unsigned int& cumulative_lost, + unsigned int& extended_max, + unsigned int& jitter, + int64_t& rtt_ms) const { RtcpStatistics stats; int ret_code = GetReceiveChannelRtcpStatistics(video_channel, stats, @@ -305,11 +305,11 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP { return ret_code; } virtual int GetSentRTCPStatistics(const int video_channel, - unsigned short& fraction_lost, - unsigned int& cumulative_lost, - unsigned int& extended_max, - unsigned int& jitter, - int& rtt_ms) const { + unsigned short& fraction_lost, + unsigned int& cumulative_lost, + unsigned int& extended_max, + unsigned int& jitter, + int64_t& rtt_ms) const { RtcpStatistics stats; int ret_code = GetSendChannelRtcpStatistics(video_channel, stats, @@ -416,7 +416,7 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP { // This function gets the PacedSender queuing delay for the last sent frame. // TODO(jiayl): remove the default impl when libjingle is updated. virtual int GetPacerQueuingDelayMs( - const int video_channel, int* delay_ms) const { + const int video_channel, int64_t* delay_ms) const { return -1; } diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_custom_call.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_custom_call.cc index b22e3673b7..c4d458a63e 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_custom_call.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_custom_call.cc @@ -1510,7 +1510,7 @@ void PrintRTCCPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, int error = 0; int number_of_errors = 0; webrtc::RtcpStatistics rtcp_stats; - int rtt_ms = 0; + int64_t rtt_ms = 0; switch (stat_type) { case kReceivedStatistic: diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc index 923fe41b1b..711bc581df 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc @@ -120,7 +120,7 @@ void ViEAutoTest::ViERtpRtcpStandardTest() // Pacing // webrtc::RtcpStatistics received; - int recRttMs = 0; + int64_t recRttMs = 0; unsigned int sentTotalBitrate = 0; unsigned int sentVideoBitrate = 0; unsigned int sentFecBitrate = 0; @@ -240,7 +240,7 @@ void ViEAutoTest::ViERtpRtcpStandardTest() EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); webrtc::RtcpStatistics sent; - int sentRttMs = 0; + int64_t sentRttMs = 0; // Fraction lost is a transient value that can get reset after a new rtcp // report block. Make regular polls to make sure it is propagated. 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 484afd59fd..3c4757fdf4 100644 --- a/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h +++ b/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h @@ -38,7 +38,8 @@ public: virtual int32_t Release() OVERRIDE; - virtual int32_t SetChannelParameters(uint32_t packetLoss, int rtt) OVERRIDE; + virtual int32_t SetChannelParameters(uint32_t packetLoss, + int64_t rtt) OVERRIDE; virtual int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) OVERRIDE; 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 747e06e7e6..55055dd7c7 100644 --- a/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc +++ b/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc @@ -46,7 +46,7 @@ int32_t TbI420Encoder::Release() return WEBRTC_VIDEO_CODEC_OK; } -int32_t TbI420Encoder::SetChannelParameters(uint32_t packetLoss, int rtt) { +int32_t TbI420Encoder::SetChannelParameters(uint32_t packetLoss, int64_t rtt) { _functionCalls.SetChannelParameters++; return WEBRTC_VIDEO_CODEC_OK; } diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc index 79ebe7081f..7b9d2cc404 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -51,7 +51,7 @@ class ChannelStatsObserver : public CallStatsObserver { virtual ~ChannelStatsObserver() {} // Implements StatsObserver. - virtual void OnRttUpdate(uint32_t rtt) { + virtual void OnRttUpdate(int64_t rtt) { owner_->OnRttUpdate(rtt); } @@ -1006,7 +1006,7 @@ int32_t ViEChannel::GetSendRtcpStatistics(uint16_t* fraction_lost, uint32_t* cumulative_lost, uint32_t* extended_max, uint32_t* jitter_samples, - int32_t* rtt_ms) { + int64_t* rtt_ms) { // Aggregate the report blocks associated with streams sent on this channel. std::vector report_blocks; rtp_rtcp_->RemoteRTCPStat(&report_blocks); @@ -1046,8 +1046,8 @@ int32_t ViEChannel::GetSendRtcpStatistics(uint16_t* fraction_lost, *extended_max = report.extendedHighSeqNum; *jitter_samples = report.jitter; - uint16_t dummy; - uint16_t rtt = 0; + int64_t dummy; + int64_t rtt = 0; if (rtp_rtcp_->RTT(remote_ssrc, &rtt, &dummy, &dummy, &dummy) != 0) { return -1; } @@ -1073,7 +1073,7 @@ int32_t ViEChannel::GetReceivedRtcpStatistics(uint16_t* fraction_lost, uint32_t* cumulative_lost, uint32_t* extended_max, uint32_t* jitter_samples, - int32_t* rtt_ms) { + int64_t* rtt_ms) { uint32_t remote_ssrc = vie_receiver_.GetRemoteSsrc(); StreamStatistician* statistician = vie_receiver_.GetReceiveStatistics()->GetStatistician(remote_ssrc); @@ -1091,8 +1091,8 @@ int32_t ViEChannel::GetReceivedRtcpStatistics(uint16_t* fraction_lost, // GetReceivedRtcpStatistics to be called. report_block_stats_receiver_->Store(receive_stats, remote_ssrc, 0); - uint16_t dummy = 0; - uint16_t rtt = 0; + int64_t dummy = 0; + int64_t rtt = 0; rtp_rtcp_->RTT(remote_ssrc, &rtt, &dummy, &dummy, &dummy); *rtt_ms = rtt; return 0; @@ -1599,7 +1599,7 @@ bool ViEChannel::ChannelDecodeProcess() { return true; } -void ViEChannel::OnRttUpdate(uint32_t rtt) { +void ViEChannel::OnRttUpdate(int64_t rtt) { vcm_->SetReceiveChannelParameters(rtt); } diff --git a/webrtc/video_engine/vie_channel.h b/webrtc/video_engine/vie_channel.h index 7a46d1f75e..bc91b3af71 100644 --- a/webrtc/video_engine/vie_channel.h +++ b/webrtc/video_engine/vie_channel.h @@ -171,7 +171,7 @@ class ViEChannel uint32_t* cumulative_lost, uint32_t* extended_max, uint32_t* jitter_samples, - int32_t* rtt_ms); + int64_t* rtt_ms); // Called on receipt of RTCP report block from remote side. void RegisterSendChannelRtcpStatisticsCallback( @@ -182,7 +182,7 @@ class ViEChannel uint32_t* cumulative_lost, uint32_t* extended_max, uint32_t* jitter_samples, - int32_t* rtt_ms); + int64_t* rtt_ms); // Called on generation of RTCP stats void RegisterReceiveChannelRtcpStatisticsCallback( @@ -364,7 +364,7 @@ class ViEChannel static bool ChannelDecodeThreadFunction(void* obj); bool ChannelDecodeProcess(); - void OnRttUpdate(uint32_t rtt); + void OnRttUpdate(int64_t rtt); private: void ReserveRtpRtcpModules(size_t total_modules) diff --git a/webrtc/video_engine/vie_channel_group.cc b/webrtc/video_engine/vie_channel_group.cc index d4a3f20d11..16e25d3b8b 100644 --- a/webrtc/video_engine/vie_channel_group.cc +++ b/webrtc/video_engine/vie_channel_group.cc @@ -70,7 +70,7 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator { return rbe_->TimeUntilNextProcess(); } - virtual void OnRttUpdate(uint32_t rtt) OVERRIDE { + virtual void OnRttUpdate(int64_t rtt) OVERRIDE { CriticalSectionScoped cs(crit_sect_.get()); rbe_->OnRttUpdate(rtt); } diff --git a/webrtc/video_engine/vie_encoder.cc b/webrtc/video_engine/vie_encoder.cc index 3b2ab8dd16..ca02002873 100644 --- a/webrtc/video_engine/vie_encoder.cc +++ b/webrtc/video_engine/vie_encoder.cc @@ -98,7 +98,7 @@ class ViEBitrateObserver : public BitrateObserver { // Implements BitrateObserver. virtual void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_lost, - uint32_t rtt) { + int64_t rtt) { owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt); } private: @@ -646,7 +646,7 @@ int32_t ViEEncoder::SendCodecStatistics( return 0; } -int32_t ViEEncoder::PacerQueuingDelayMs() const { +int64_t ViEEncoder::PacerQueuingDelayMs() const { return paced_sender_->QueueInMs(); } @@ -869,7 +869,7 @@ void ViEEncoder::SetMinTransmitBitrate(int min_transmit_bitrate_kbps) { // Called from ViEBitrateObserver. void ViEEncoder::OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_lost, - uint32_t round_trip_time_ms) { + int64_t round_trip_time_ms) { LOG(LS_VERBOSE) << "OnNetworkChanged, bitrate" << bitrate_bps << " packet loss " << fraction_lost << " rtt " << round_trip_time_ms; diff --git a/webrtc/video_engine/vie_encoder.h b/webrtc/video_engine/vie_encoder.h index 9ef6426a7c..ba7de53844 100644 --- a/webrtc/video_engine/vie_encoder.h +++ b/webrtc/video_engine/vie_encoder.h @@ -110,7 +110,7 @@ class ViEEncoder int32_t SendCodecStatistics(uint32_t* num_key_frames, uint32_t* num_delta_frames); - int PacerQueuingDelayMs() const; + int64_t PacerQueuingDelayMs() const; int CodecTargetBitrate(uint32_t* bitrate) const; // Loss protection. @@ -181,7 +181,7 @@ class ViEEncoder // Called by BitrateObserver. void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_lost, - uint32_t round_trip_time_ms); + int64_t round_trip_time_ms); // Called by PacedSender. bool TimeToSendPacket(uint32_t ssrc, uint16_t sequence_number, diff --git a/webrtc/video_engine/vie_receiver.cc b/webrtc/video_engine/vie_receiver.cc index 6dec985565..6adcffdb66 100644 --- a/webrtc/video_engine/vie_receiver.cc +++ b/webrtc/video_engine/vie_receiver.cc @@ -365,7 +365,7 @@ int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet, return ret; } - uint16_t rtt = 0; + int64_t rtt = 0; rtp_rtcp_->RTT(rtp_receiver_->SSRC(), &rtt, NULL, NULL, NULL); if (rtt == 0) { // Waiting for valid rtt. @@ -454,7 +454,7 @@ bool ViEReceiver::IsPacketRetransmitted(const RTPHeader& header, if (!statistician) return false; // Check if this is a retransmission. - uint16_t min_rtt = 0; + int64_t min_rtt = 0; rtp_rtcp_->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); return !in_order && statistician->IsRetransmitOfOldPacket(header, min_rtt); diff --git a/webrtc/video_engine/vie_rtp_rtcp_impl.cc b/webrtc/video_engine/vie_rtp_rtcp_impl.cc index ae213079d3..f9d96e646a 100644 --- a/webrtc/video_engine/vie_rtp_rtcp_impl.cc +++ b/webrtc/video_engine/vie_rtp_rtcp_impl.cc @@ -669,7 +669,7 @@ int ViERTP_RTCPImpl::SetReservedTransmitBitrate( int ViERTP_RTCPImpl::GetReceiveChannelRtcpStatistics( const int video_channel, RtcpStatistics& basic_stats, - int& rtt_ms) const { + int64_t& rtt_ms) const { ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); ViEChannel* vie_channel = cs.Channel(video_channel); if (!vie_channel) { @@ -694,7 +694,7 @@ int ViERTP_RTCPImpl::GetReceiveChannelRtcpStatistics( int ViERTP_RTCPImpl::GetSendChannelRtcpStatistics(const int video_channel, RtcpStatistics& basic_stats, - int& rtt_ms) const { + int64_t& rtt_ms) const { ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); ViEChannel* vie_channel = cs.Channel(video_channel); if (!vie_channel) { @@ -802,7 +802,7 @@ int ViERTP_RTCPImpl::GetReceiveBandwidthEstimatorStats( } int ViERTP_RTCPImpl::GetPacerQueuingDelayMs( - const int video_channel, int* delay_ms) const { + const int video_channel, int64_t* delay_ms) const { ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); ViEEncoder* vie_encoder = cs.Encoder(video_channel); if (!vie_encoder) { diff --git a/webrtc/video_engine/vie_rtp_rtcp_impl.h b/webrtc/video_engine/vie_rtp_rtcp_impl.h index 8e9f09735c..6c20f1eb08 100644 --- a/webrtc/video_engine/vie_rtp_rtcp_impl.h +++ b/webrtc/video_engine/vie_rtp_rtcp_impl.h @@ -99,10 +99,10 @@ class ViERTP_RTCPImpl int video_channel, unsigned int reserved_transmit_bitrate_bps); virtual int GetReceiveChannelRtcpStatistics(const int video_channel, RtcpStatistics& basic_stats, - int& rtt_ms) const; + int64_t& rtt_ms) const; virtual int GetSendChannelRtcpStatistics(const int video_channel, RtcpStatistics& basic_stats, - int& rtt_ms) const; + int64_t& rtt_ms) const; virtual int GetRtpStatistics(const int video_channel, StreamDataCounters& sent, StreamDataCounters& received) const; @@ -124,7 +124,7 @@ class ViERTP_RTCPImpl virtual int GetReceiveBandwidthEstimatorStats( const int video_channel, ReceiveBandwidthEstimatorStats* output) const; virtual int GetPacerQueuingDelayMs(const int video_channel, - int* delay_ms) const; + int64_t* delay_ms) const; virtual int StartRTPDump(const int video_channel, const char file_nameUTF8[1024], RTPDirections direction); diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index 7900ac911c..5b24b9b9bf 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -101,7 +101,7 @@ class VoEBitrateObserver : public BitrateObserver { // Implements BitrateObserver. virtual void OnNetworkChanged(const uint32_t bitrate_bps, const uint8_t fraction_lost, - const uint32_t rtt) OVERRIDE { + const int64_t rtt) OVERRIDE { // |fraction_lost| has a scale of 0 - 255. owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt); } @@ -410,7 +410,7 @@ Channel::OnReceivedPayloadData(const uint8_t* payloadData, UpdatePacketDelay(rtpHeader->header.timestamp, rtpHeader->header.sequenceNumber); - uint16_t round_trip_time = 0; + int64_t round_trip_time = 0; _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time, NULL, NULL, NULL); @@ -1330,10 +1330,10 @@ Channel::SetSendCodec(const CodecInst& codec) void Channel::OnNetworkChanged(const uint32_t bitrate_bps, const uint8_t fraction_lost, // 0 - 255. - const uint32_t rtt) { + const int64_t rtt) { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), - "Channel::OnNetworkChanged(bitrate_bps=%d, fration_lost=%d, rtt=%d)", - bitrate_bps, fraction_lost, rtt); + "Channel::OnNetworkChanged(bitrate_bps=%d, fration_lost=%d, rtt=%" PRId64 + ")", bitrate_bps, fraction_lost, rtt); // |fraction_lost| from BitrateObserver is short time observation of packet // loss rate from past. We use network predictor to make a more reasonable // loss rate estimation. @@ -1717,7 +1717,7 @@ bool Channel::IsPacketRetransmitted(const RTPHeader& header, if (!statistician) return false; // Check if this is a retransmission. - uint16_t min_rtt = 0; + int64_t min_rtt = 0; _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); return !in_order && statistician->IsRetransmitOfOldPacket(header, min_rtt); @@ -1745,7 +1745,7 @@ int32_t Channel::ReceivedRTCPPacket(const int8_t* data, size_t length) { { CriticalSectionScoped lock(ts_stats_lock_.get()); - uint16_t rtt = GetRTT(); + int64_t rtt = GetRTT(); if (rtt == 0) { // Waiting for valid RTT. return 0; @@ -3218,7 +3218,7 @@ Channel::GetRTPStatistics(CallStatistics& stats) "GetRTPStatistics() failed to get RTT"); } else { WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, _channelId), - "GetRTPStatistics() => rttMs=%d", stats.rttMs); + "GetRTPStatistics() => rttMs=%" PRId64, stats.rttMs); } // --- Data counters @@ -4245,7 +4245,7 @@ int32_t Channel::GetPlayoutFrequency() { return playout_frequency; } -int Channel::GetRTT() const { +int64_t Channel::GetRTT() const { RTCPMethod method = _rtpRtcpModule->RTCP(); if (method == kRtcpOff) { return 0; @@ -4269,15 +4269,15 @@ int Channel::GetRTT() const { // the SSRC of the other end. remoteSSRC = report_blocks[0].remoteSSRC; } - uint16_t rtt = 0; - uint16_t avg_rtt = 0; - uint16_t max_rtt= 0; - uint16_t min_rtt = 0; + int64_t rtt = 0; + int64_t avg_rtt = 0; + int64_t max_rtt= 0; + int64_t min_rtt = 0; if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 0) { return 0; } - return static_cast(rtt); + return rtt; } } // namespace voe diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index 57ae563630..eedd35ac12 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -457,7 +457,7 @@ public: // From BitrateObserver (called by the RTP/RTCP module). void OnNetworkChanged(const uint32_t bitrate_bps, const uint8_t fraction_lost, // 0 - 255. - const uint32_t rtt); + const int64_t rtt); private: bool ReceivePacket(const uint8_t* packet, size_t packet_length, @@ -481,7 +481,7 @@ private: unsigned char id); int32_t GetPlayoutFrequency(); - int GetRTT() const; + int64_t GetRTT() const; CriticalSectionWrapper& _fileCritSect; CriticalSectionWrapper& _callbackCritSect; diff --git a/webrtc/voice_engine/include/voe_rtp_rtcp.h b/webrtc/voice_engine/include/voe_rtp_rtcp.h index 6230211a77..fedb1340f0 100644 --- a/webrtc/voice_engine/include/voe_rtp_rtcp.h +++ b/webrtc/voice_engine/include/voe_rtp_rtcp.h @@ -68,7 +68,7 @@ struct CallStatistics unsigned int cumulativeLost; unsigned int extendedMax; unsigned int jitterSamples; - int rttMs; + int64_t rttMs; size_t bytesSent; int packetsSent; size_t bytesReceived;