Use int64_t for milliseconds more often, primarily for TimeUntilNextProcess.
This fixes a variety of MSVC warnings about value truncations when implicitly
storing the 64-bit values we get back from e.g. TimeTicks in 32-bit objects, and
removes the need for a number of explicit casts.
This also moves a number of constants so they're declared right where they're used, which is easier to read and maintain, and makes some of them of integral type rather than using the "enum hack".
BUG=chromium:81439
TEST=none
R=tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/33649004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7905 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/app/webrtc/test/fakeaudiocapturemodule.cc b/talk/app/webrtc/test/fakeaudiocapturemodule.cc
index 2ad3f0f..1642789 100644
--- a/talk/app/webrtc/test/fakeaudiocapturemodule.cc
+++ b/talk/app/webrtc/test/fakeaudiocapturemodule.cc
@@ -94,7 +94,7 @@
return frames_received_;
}
-int32_t FakeAudioCaptureModule::TimeUntilNextProcess() {
+int64_t FakeAudioCaptureModule::TimeUntilNextProcess() {
const uint32 current_time = rtc::Time();
if (current_time < last_process_time_ms_) {
// TODO: wraparound could be handled more gracefully.
diff --git a/talk/app/webrtc/test/fakeaudiocapturemodule.h b/talk/app/webrtc/test/fakeaudiocapturemodule.h
index 72de840..2d0eda3 100644
--- a/talk/app/webrtc/test/fakeaudiocapturemodule.h
+++ b/talk/app/webrtc/test/fakeaudiocapturemodule.h
@@ -76,7 +76,7 @@
// Only functions called by PeerConnection are implemented, the rest do
// nothing and return success. If a function is not expected to be called by
// PeerConnection an assertion is triggered if it is in fact called.
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE;
diff --git a/talk/media/webrtc/fakewebrtcvideocapturemodule.h b/talk/media/webrtc/fakewebrtcvideocapturemodule.h
index 82b5cdd..7ec7e43 100644
--- a/talk/media/webrtc/fakewebrtcvideocapturemodule.h
+++ b/talk/media/webrtc/fakewebrtcvideocapturemodule.h
@@ -44,7 +44,7 @@
running_(false),
delay_(0) {
}
- virtual int32_t TimeUntilNextProcess() OVERRIDE {
+ virtual int64_t TimeUntilNextProcess() OVERRIDE {
return 0;
}
virtual int32_t Process() OVERRIDE {
diff --git a/talk/media/webrtc/webrtcpassthroughrender.h b/talk/media/webrtc/webrtcpassthroughrender.h
index 8d8c488..5d2c702 100644
--- a/talk/media/webrtc/webrtcpassthroughrender.h
+++ b/talk/media/webrtc/webrtcpassthroughrender.h
@@ -45,7 +45,7 @@
return 0;
}
- virtual int32_t TimeUntilNextProcess() OVERRIDE { return 0; }
+ virtual int64_t TimeUntilNextProcess() OVERRIDE { return 0; }
virtual int32_t Process() OVERRIDE { return 0; }
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 458e5c8..cbea050 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
@@ -262,7 +262,7 @@
// Returns the number of milliseconds until the module want a
// worker thread to call Process.
-int32_t AudioCodingModuleImpl::TimeUntilNextProcess() {
+int64_t AudioCodingModuleImpl::TimeUntilNextProcess() {
CriticalSectionScoped lock(acm_crit_sect_);
if (!HaveValidEncoder("TimeUntilNextProcess")) {
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 949ce33..2d0f767 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
@@ -40,7 +40,7 @@
// Returns the number of milliseconds until the module want a worker thread
// to call Process.
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
// Process any pending tasks such as timeouts.
virtual int32_t Process() OVERRIDE;
diff --git a/webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h b/webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h
index 6290c22..efcd59b 100644
--- a/webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h
+++ b/webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h
@@ -41,7 +41,7 @@
// Module functions
virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE = 0;
- virtual int32_t TimeUntilNextProcess() OVERRIDE = 0;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE = 0;
virtual int32_t Process() OVERRIDE = 0;
// Register/unregister a callback class for receiving the mixed audio.
diff --git a/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc b/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc
index 6ef6166..c65cee4 100644
--- a/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc
+++ b/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.cc
@@ -197,8 +197,8 @@
}
// Process should be called every kProcessPeriodicityInMs ms
-int32_t AudioConferenceMixerImpl::TimeUntilNextProcess() {
- int32_t timeUntilNextProcess = 0;
+int64_t AudioConferenceMixerImpl::TimeUntilNextProcess() {
+ int64_t timeUntilNextProcess = 0;
CriticalSectionScoped cs(_crit.get());
if(_timeScheduler.TimeToNextUpdate(timeUntilNextProcess) != 0) {
WEBRTC_TRACE(kTraceError, kTraceAudioMixerServer, _id,
diff --git a/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h b/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
index 2756314..9591e42 100644
--- a/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
+++ b/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
@@ -65,7 +65,7 @@
// Module functions
virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
// AudioConferenceMixer functions
diff --git a/webrtc/modules/audio_conference_mixer/source/time_scheduler.cc b/webrtc/modules/audio_conference_mixer/source/time_scheduler.cc
index 738f826..4d75bc5 100644
--- a/webrtc/modules/audio_conference_mixer/source/time_scheduler.cc
+++ b/webrtc/modules/audio_conference_mixer/source/time_scheduler.cc
@@ -12,7 +12,7 @@
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
namespace webrtc {
-TimeScheduler::TimeScheduler(const uint32_t periodicityInMs)
+TimeScheduler::TimeScheduler(const int64_t periodicityInMs)
: _crit(CriticalSectionWrapper::CreateCriticalSection()),
_isStarted(false),
_lastPeriodMark(),
@@ -50,8 +50,7 @@
int64_t amassedMs = amassedTicks.Milliseconds();
// Calculate the number of periods the time that has passed correspond to.
- int32_t periodsToClaim = static_cast<int32_t>(amassedMs /
- static_cast<int32_t>(_periodicityInMs));
+ int64_t periodsToClaim = amassedMs / _periodicityInMs;
// One period will be worked off by this call. Make sure that the number of
// pending periods don't end up being negative (e.g. if this function is
@@ -65,7 +64,7 @@
// Note that if this fuunction is called to often _lastPeriodMark can
// refer to a time in the future which in turn will yield TimeToNextUpdate
// that is greater than the periodicity
- for(int32_t i = 0; i < periodsToClaim; i++)
+ for(int64_t i = 0; i < periodsToClaim; i++)
{
_lastPeriodMark += _periodicityInTicks;
}
@@ -77,7 +76,7 @@
}
int32_t TimeScheduler::TimeToNextUpdate(
- int32_t& updateTimeInMS) const
+ int64_t& updateTimeInMS) const
{
CriticalSectionScoped cs(_crit);
// Missed periods means that the next UpdateScheduler() should happen
@@ -92,8 +91,8 @@
// UpdateScheduler()
TickTime tickNow = TickTime::Now();
TickInterval ticksSinceLastUpdate = tickNow - _lastPeriodMark;
- const int32_t millisecondsSinceLastUpdate =
- static_cast<int32_t>(ticksSinceLastUpdate.Milliseconds());
+ const int64_t millisecondsSinceLastUpdate =
+ ticksSinceLastUpdate.Milliseconds();
updateTimeInMS = _periodicityInMs - millisecondsSinceLastUpdate;
updateTimeInMS = (updateTimeInMS < 0) ? 0 : updateTimeInMS;
diff --git a/webrtc/modules/audio_conference_mixer/source/time_scheduler.h b/webrtc/modules/audio_conference_mixer/source/time_scheduler.h
index 5a77006..5152b2d 100644
--- a/webrtc/modules/audio_conference_mixer/source/time_scheduler.h
+++ b/webrtc/modules/audio_conference_mixer/source/time_scheduler.h
@@ -22,7 +22,7 @@
class TimeScheduler
{
public:
- TimeScheduler(const uint32_t periodicityInMs);
+ TimeScheduler(const int64_t periodicityInMs);
~TimeScheduler();
// Signal that a periodic event has been triggered.
@@ -30,7 +30,7 @@
// Set updateTimeInMs to the amount of time until UpdateScheduler() should
// be called. This time will never be negative.
- int32_t TimeToNextUpdate(int32_t& updateTimeInMS) const;
+ int32_t TimeToNextUpdate(int64_t& updateTimeInMS) const;
private:
CriticalSectionWrapper* _crit;
@@ -38,8 +38,8 @@
bool _isStarted;
TickTime _lastPeriodMark;
- uint32_t _periodicityInMs;
- int64_t _periodicityInTicks;
+ int64_t _periodicityInMs;
+ int64_t _periodicityInTicks;
uint32_t _missedPeriods;
};
} // namespace webrtc
diff --git a/webrtc/modules/audio_device/audio_device_impl.cc b/webrtc/modules/audio_device/audio_device_impl.cc
index a440381..a2b0971 100644
--- a/webrtc/modules/audio_device/audio_device_impl.cc
+++ b/webrtc/modules/audio_device/audio_device_impl.cc
@@ -480,7 +480,7 @@
// to call Process().
// ----------------------------------------------------------------------------
-int32_t AudioDeviceModuleImpl::TimeUntilNextProcess()
+int64_t AudioDeviceModuleImpl::TimeUntilNextProcess()
{
uint32_t now = AudioDeviceUtility::GetTimeInMS();
int32_t deltaProcess = kAdmMaxIdleTimeProcess - (now - _lastProcessTime);
diff --git a/webrtc/modules/audio_device/audio_device_impl.h b/webrtc/modules/audio_device/audio_device_impl.h
index dfc9b5d..ab9ddbb 100644
--- a/webrtc/modules/audio_device/audio_device_impl.h
+++ b/webrtc/modules/audio_device/audio_device_impl.h
@@ -44,7 +44,7 @@
public: // RefCountedModule
virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
public:
diff --git a/webrtc/modules/audio_device/include/fake_audio_device.h b/webrtc/modules/audio_device/include/fake_audio_device.h
index a627aec..8b7e87c 100644
--- a/webrtc/modules/audio_device/include/fake_audio_device.h
+++ b/webrtc/modules/audio_device/include/fake_audio_device.h
@@ -36,7 +36,7 @@
virtual int32_t SetStereoRecording(bool enable) { return 0; }
virtual int32_t SetAGC(bool enable) { return 0; }
virtual int32_t StopRecording() { return 0; }
- virtual int32_t TimeUntilNextProcess() { return 0; }
+ virtual int64_t TimeUntilNextProcess() { return 0; }
virtual int32_t Process() { return 0; }
virtual int32_t Terminate() { return 0; }
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
index f1a9b47..5e1fd46 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
@@ -223,12 +223,13 @@
MaybeTriggerOnNetworkChanged();
}
-int32_t BitrateControllerImpl::TimeUntilNextProcess() {
- enum { kBitrateControllerUpdateIntervalMs = 25 };
+int64_t BitrateControllerImpl::TimeUntilNextProcess() {
+ const int64_t kBitrateControllerUpdateIntervalMs = 25;
CriticalSectionScoped cs(critsect_);
- int time_since_update_ms =
+ int64_t time_since_update_ms =
clock_->TimeInMilliseconds() - last_bitrate_update_ms_;
- return std::max(0, kBitrateControllerUpdateIntervalMs - time_since_update_ms);
+ return std::max<int64_t>(
+ kBitrateControllerUpdateIntervalMs - time_since_update_ms, 0);
}
int32_t BitrateControllerImpl::Process() {
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
index 61b2e08..3d16202 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
@@ -46,7 +46,7 @@
virtual void EnforceMinBitrate(bool enforce_min_bitrate) OVERRIDE;
virtual void SetReservedBitrate(uint32_t reserved_bitrate_bps) OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
private:
diff --git a/webrtc/modules/interface/module.h b/webrtc/modules/interface/module.h
index c177fd1..ccaee8b 100644
--- a/webrtc/modules/interface/module.h
+++ b/webrtc/modules/interface/module.h
@@ -25,7 +25,7 @@
// Returns the number of milliseconds until the module want a worker
// thread to call Process.
- virtual int32_t TimeUntilNextProcess() = 0;
+ virtual int64_t TimeUntilNextProcess() = 0;
// Process any pending tasks such as timeouts.
virtual int32_t Process() = 0;
diff --git a/webrtc/modules/media_file/source/media_file_impl.cc b/webrtc/modules/media_file/source/media_file_impl.cc
index 06df171..b669ab6 100644
--- a/webrtc/modules/media_file/source/media_file_impl.cc
+++ b/webrtc/modules/media_file/source/media_file_impl.cc
@@ -91,7 +91,7 @@
return 0;
}
-int32_t MediaFileImpl::TimeUntilNextProcess()
+int64_t MediaFileImpl::TimeUntilNextProcess()
{
WEBRTC_TRACE(
kTraceWarning,
diff --git a/webrtc/modules/media_file/source/media_file_impl.h b/webrtc/modules/media_file/source/media_file_impl.h
index fc5799d..17391a5 100644
--- a/webrtc/modules/media_file/source/media_file_impl.h
+++ b/webrtc/modules/media_file/source/media_file_impl.h
@@ -28,7 +28,7 @@
virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE;
virtual int32_t Process() OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
// MediaFile functions
virtual int32_t PlayoutAudioData(int8_t* audioBuffer,
diff --git a/webrtc/modules/pacing/include/mock/mock_paced_sender.h b/webrtc/modules/pacing/include/mock/mock_paced_sender.h
index bff6a5d..632ec9b 100644
--- a/webrtc/modules/pacing/include/mock/mock_paced_sender.h
+++ b/webrtc/modules/pacing/include/mock/mock_paced_sender.h
@@ -29,7 +29,7 @@
int64_t capture_time_ms,
size_t bytes,
bool retransmission));
- MOCK_CONST_METHOD0(QueueInMs, int());
+ MOCK_CONST_METHOD0(QueueInMs, int64_t());
MOCK_CONST_METHOD0(QueueInPackets, int());
};
diff --git a/webrtc/modules/pacing/include/paced_sender.h b/webrtc/modules/pacing/include/paced_sender.h
index f0e98e8..ab3ce7f 100644
--- a/webrtc/modules/pacing/include/paced_sender.h
+++ b/webrtc/modules/pacing/include/paced_sender.h
@@ -106,7 +106,7 @@
bool retransmission);
// Returns the time since the oldest queued packet was enqueued.
- virtual int QueueInMs() const;
+ virtual int64_t QueueInMs() const;
virtual size_t QueueSizePackets() const;
@@ -116,7 +116,7 @@
// Returns the number of milliseconds until the module want a worker thread
// to call Process.
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
// Process any pending packets in the queue(s).
virtual int32_t Process() OVERRIDE;
@@ -126,7 +126,7 @@
private:
// Updates the number of bytes that can be sent for the next time interval.
- void UpdateBytesPerInterval(uint32_t delta_time_in_ms)
+ void UpdateBytesPerInterval(int64_t delta_time_in_ms)
EXCLUSIVE_LOCKS_REQUIRED(critsect_);
bool SendPacket(const paced_sender::Packet& packet)
diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc
index 890955e..ff9c4d9 100644
--- a/webrtc/modules/pacing/paced_sender.cc
+++ b/webrtc/modules/pacing/paced_sender.cc
@@ -26,11 +26,11 @@
namespace {
// Time limit in milliseconds between packet bursts.
-const int kMinPacketLimitMs = 5;
+const int64_t kMinPacketLimitMs = 5;
// Upper cap on process interval, in case process has not been called in a long
// time.
-const int kMaxIntervalTimeMs = 30;
+const int64_t kMaxIntervalTimeMs = 30;
} // namespace
@@ -178,8 +178,8 @@
target_rate_kbps_ = target_rate_kbps;
}
- void IncreaseBudget(int delta_time_ms) {
- int bytes = target_rate_kbps_ * delta_time_ms / 8;
+ void IncreaseBudget(int64_t delta_time_ms) {
+ int64_t bytes = target_rate_kbps_ * delta_time_ms / 8;
if (bytes_remaining_ < 0) {
// We overused last interval, compensate this interval.
bytes_remaining_ = bytes_remaining_ + bytes;
@@ -293,7 +293,7 @@
return packets_->SizeInPackets();
}
-int PacedSender::QueueInMs() const {
+int64_t PacedSender::QueueInMs() const {
CriticalSectionScoped cs(critsect_.get());
int64_t oldest_packet = packets_->OldestEnqueueTime();
@@ -303,31 +303,27 @@
return clock_->TimeInMilliseconds() - oldest_packet;
}
-int32_t PacedSender::TimeUntilNextProcess() {
+int64_t PacedSender::TimeUntilNextProcess() {
CriticalSectionScoped cs(critsect_.get());
- int64_t elapsed_time_us = clock_->TimeInMicroseconds() - time_last_update_us_;
- int elapsed_time_ms = static_cast<int>((elapsed_time_us + 500) / 1000);
if (prober_->IsProbing()) {
- int next_probe = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds());
- return next_probe;
+ return prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds());
}
- if (elapsed_time_ms >= kMinPacketLimitMs) {
- return 0;
- }
- return kMinPacketLimitMs - elapsed_time_ms;
+ int64_t elapsed_time_us = clock_->TimeInMicroseconds() - time_last_update_us_;
+ int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000;
+ return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0);
}
int32_t PacedSender::Process() {
int64_t now_us = clock_->TimeInMicroseconds();
CriticalSectionScoped cs(critsect_.get());
- int elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000;
+ int64_t elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000;
time_last_update_us_ = now_us;
if (!enabled_) {
return 0;
}
if (!paused_) {
if (elapsed_time_ms > 0) {
- uint32_t delta_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms);
+ int64_t delta_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms);
UpdateBytesPerInterval(delta_time_ms);
}
@@ -387,7 +383,7 @@
padding_budget_->UseBudget(bytes_sent);
}
-void PacedSender::UpdateBytesPerInterval(uint32_t delta_time_ms) {
+void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) {
media_budget_->IncreaseBudget(delta_time_ms);
padding_budget_->IncreaseBudget(delta_time_ms);
}
diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
index 1ea088a..f6a4864 100644
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
@@ -20,7 +20,6 @@
static const uint32_t kDefaultRttMs = 200;
static const int64_t kLogIntervalMs = 1000;
-static const int kMinFeedbackIntervalMs = 200;
static const double kWithinIncomingBitrateHysteresis = 1.05;
AimdRateControl::AimdRateControl(uint32_t min_bitrate_bps)
@@ -54,17 +53,15 @@
return bitrate_is_initialized_;
}
-int AimdRateControl::GetFeedbackInterval() const {
+int64_t AimdRateControl::GetFeedbackInterval() const {
// Estimate how often we can send RTCP if we allocate up to 5% of bandwidth
// to feedback.
- static const int kRtcpSize = 80.0;
- int interval = kRtcpSize * 8.0 * 1000.0 / (0.05 * current_bitrate_bps_) + 0.5;
- if (interval > kMaxFeedbackIntervalMs)
- interval = kMaxFeedbackIntervalMs;
- else if (interval < kMinFeedbackIntervalMs) {
- interval = kMinFeedbackIntervalMs;
- }
- return interval;
+ static const int kRtcpSize = 80;
+ int64_t interval = static_cast<int64_t>(
+ kRtcpSize * 8.0 * 1000.0 / (0.05 * current_bitrate_bps_) + 0.5);
+ const int64_t kMinFeedbackIntervalMs = 200;
+ return std::min(std::max(interval, kMinFeedbackIntervalMs),
+ kMaxFeedbackIntervalMs);
}
bool AimdRateControl::TimeToReduceFurther(int64_t time_now,
diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h
index f2f6e08..a862071 100644
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h
@@ -30,7 +30,7 @@
virtual bool ValidEstimate() const OVERRIDE;
virtual RateControlType GetControlType() const OVERRIDE;
virtual uint32_t GetMinBitrate() const OVERRIDE;
- virtual int GetFeedbackInterval() const OVERRIDE;
+ virtual int64_t GetFeedbackInterval() const OVERRIDE;
// Returns true if the bitrate estimate hasn't been changed for more than
// an RTT, or if the incoming_bitrate is more than 5% above the current
// estimate. Should be used to decide if we should reduce the rate further
diff --git a/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h b/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h
index ede3c5d..92a0eb8 100644
--- a/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h
+++ b/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h
@@ -89,8 +89,8 @@
virtual bool GetStats(ReceiveBandwidthEstimatorStats* output) const = 0;
protected:
- static const int kProcessIntervalMs = 1000;
- static const int kStreamTimeOutMs = 2000;
+ static const int64_t kProcessIntervalMs = 1000;
+ static const int64_t kStreamTimeOutMs = 2000;
};
struct RemoteBitrateEstimatorFactory {
diff --git a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc
index 8c9e8f4..941409c 100644
--- a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc
+++ b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.cc
@@ -55,7 +55,7 @@
return initialized_bit_rate_;
}
-int MimdRateControl::GetFeedbackInterval() const {
+int64_t MimdRateControl::GetFeedbackInterval() const {
return kMaxFeedbackIntervalMs;
}
diff --git a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h
index fe9ddbb..94c9b6b 100644
--- a/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h
+++ b/webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h
@@ -28,7 +28,7 @@
virtual RateControlType GetControlType() const OVERRIDE;
virtual uint32_t GetMinBitrate() const OVERRIDE;
virtual bool ValidEstimate() const OVERRIDE;
- virtual int GetFeedbackInterval() const OVERRIDE;
+ virtual int64_t GetFeedbackInterval() const OVERRIDE;
virtual bool TimeToReduceFurther(
int64_t time_now, uint32_t incoming_bitrate_bps) const OVERRIDE;
virtual uint32_t LatestEstimate() const OVERRIDE;
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 9a723fc..5398834 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
@@ -83,7 +83,7 @@
// shouldn't be detached from the ProcessThread except if it's about to be
// deleted.
virtual int32_t Process() OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual void OnRttUpdate(uint32_t rtt) OVERRIDE;
virtual void RemoveStream(unsigned int ssrc) OVERRIDE;
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
@@ -168,7 +168,7 @@
int64_t last_process_time_;
std::vector<int> recent_propagation_delta_ms_ GUARDED_BY(crit_sect_.get());
std::vector<int64_t> recent_update_time_ms_ GUARDED_BY(crit_sect_.get());
- int process_interval_ms_ GUARDED_BY(crit_sect_.get());
+ int64_t process_interval_ms_ GUARDED_BY(crit_sect_.get());
int total_propagation_delta_ms_ GUARDED_BY(crit_sect_.get());
std::list<Probe> probes_;
@@ -376,7 +376,7 @@
return 0;
}
-int32_t RemoteBitrateEstimatorAbsSendTimeImpl::TimeUntilNextProcess() {
+int64_t RemoteBitrateEstimatorAbsSendTimeImpl::TimeUntilNextProcess() {
if (last_process_time_ < 0) {
return 0;
}
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
index 13efcf1..863129a 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
@@ -97,8 +97,8 @@
TEST_F(RemoteBitrateEstimatorAbsSendTimeTest, TestProcessAfterTimeout) {
// This time constant must be equal to the ones defined for the
// RemoteBitrateEstimator.
- const int kStreamTimeOutMs = 2000;
- const int kProcessIntervalMs = 1000;
+ const int64_t kStreamTimeOutMs = 2000;
+ const int64_t kProcessIntervalMs = 1000;
IncomingPacket(0, 1000, clock_.TimeInMilliseconds(), 0, 0);
clock_.AdvanceTimeMilliseconds(kStreamTimeOutMs + 1);
// Trigger timeout.
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 14fab73..47e6b02 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
@@ -40,7 +40,7 @@
size_t payload_size,
const RTPHeader& header) OVERRIDE;
virtual int32_t Process() OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual void OnRttUpdate(uint32_t rtt) OVERRIDE;
virtual void RemoveStream(unsigned int ssrc) OVERRIDE;
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
@@ -79,7 +79,7 @@
RemoteBitrateObserver* observer_ GUARDED_BY(crit_sect_.get());
scoped_ptr<CriticalSectionWrapper> crit_sect_;
int64_t last_process_time_;
- int process_interval_ms_ GUARDED_BY(crit_sect_.get());
+ int64_t process_interval_ms_ GUARDED_BY(crit_sect_.get());
DISALLOW_IMPLICIT_CONSTRUCTORS(RemoteBitrateEstimatorImpl);
};
@@ -172,7 +172,7 @@
return 0;
}
-int32_t RemoteBitrateEstimatorImpl::TimeUntilNextProcess() {
+int64_t RemoteBitrateEstimatorImpl::TimeUntilNextProcess() {
if (last_process_time_ < 0) {
return 0;
}
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc
index ea4838d..763a575 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.cc
@@ -14,6 +14,10 @@
#include "webrtc/modules/remote_bitrate_estimator/mimd_rate_control.h"
namespace webrtc {
+
+// static
+const int64_t RemoteRateControl::kMaxFeedbackIntervalMs = 1000;
+
RemoteRateControl* RemoteRateControl::Create(RateControlType control_type,
uint32_t min_bitrate_bps) {
if (control_type == kAimdControl) {
@@ -22,4 +26,5 @@
return new MimdRateControl(min_bitrate_bps);
}
}
+
} // namespace webrtc
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h
index f9889db..41d9253 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h
+++ b/webrtc/modules/remote_bitrate_estimator/remote_rate_control.h
@@ -28,7 +28,7 @@
virtual bool ValidEstimate() const = 0;
virtual RateControlType GetControlType() const = 0;
virtual uint32_t GetMinBitrate() const = 0;
- virtual int GetFeedbackInterval() const = 0;
+ virtual int64_t GetFeedbackInterval() const = 0;
// Returns true if the bitrate estimate hasn't been changed for more than
// an RTT, or if the incoming_bitrate is more than 5% above the current
@@ -44,7 +44,7 @@
virtual void SetEstimate(int bitrate_bps, int64_t time_now_ms) = 0;
protected:
- static const int kMaxFeedbackIntervalMs = 1000;
+ static const int64_t kMaxFeedbackIntervalMs;
};
} // namespace webrtc
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc
index d4919e7..a1312ba 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc
@@ -76,11 +76,11 @@
}
}
- int64_t step_ms = std::max(estimator_->TimeUntilNextProcess(), 0);
+ int64_t step_ms = std::max<int64_t>(estimator_->TimeUntilNextProcess(), 0);
while ((clock_.TimeInMilliseconds() + step_ms) < packet_time_ms) {
clock_.AdvanceTimeMilliseconds(step_ms);
estimator_->Process();
- step_ms = std::max(estimator_->TimeUntilNextProcess(), 0);
+ step_ms = std::max<int64_t>(estimator_->TimeUntilNextProcess(), 0);
}
estimator_->IncomingPacket(packet_time_ms, packet.payload_size(),
packet.header());
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
index 42b5d34..8983f2d 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
@@ -700,7 +700,7 @@
int64_t end_time_ms = clock_.TimeInMilliseconds() + time_ms;
Packets::iterator it = generated_packets.begin();
while (clock_.TimeInMilliseconds() <= end_time_ms) {
- int time_until_process_ms = pacer_.TimeUntilNextProcess();
+ int64_t time_until_process_ms = pacer_.TimeUntilNextProcess();
if (time_until_process_ms < 0)
time_until_process_ms = 0;
int time_until_packet_ms = time_ms;
diff --git a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
index dde9bdd..a83efd9 100644
--- a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
+++ b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
@@ -10,6 +10,7 @@
#include <stdio.h>
+#include "webrtc/base/format_macros.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
@@ -98,18 +99,17 @@
packet.time_ms = packet.time_ms - first_rtp_time_ms;
next_rtp_time_ms = packet.time_ms;
}
- int time_until_process_ms = rbe->TimeUntilNextProcess();
+ int64_t time_until_process_ms = rbe->TimeUntilNextProcess();
if (time_until_process_ms <= 0) {
rbe->Process();
}
- int time_until_next_event =
+ int64_t time_until_next_event =
std::min(rbe->TimeUntilNextProcess(),
- static_cast<int>(next_rtp_time_ms -
- clock.TimeInMilliseconds()));
- clock.AdvanceTimeMilliseconds(std::max(time_until_next_event, 0));
+ next_rtp_time_ms - clock.TimeInMilliseconds());
+ clock.AdvanceTimeMilliseconds(std::max<int64_t>(time_until_next_event, 0));
}
- printf("Parsed %d packets\nTime passed: %u ms\n", packet_counter,
- static_cast<uint32_t>(clock.TimeInMilliseconds()));
+ printf("Parsed %d packets\nTime passed: %" PRId64 " ms\n", packet_counter,
+ clock.TimeInMilliseconds());
printf("Estimator used: %s\n", estimator_used.c_str());
printf("Packets with absolute send time: %d\n",
abs_send_time_count);
diff --git a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h
index cf6b975..b3aa733 100644
--- a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h
+++ b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h
@@ -90,7 +90,7 @@
virtual void FecPacketReceived(uint32_t ssrc) OVERRIDE;
virtual StatisticianMap GetActiveStatisticians() const OVERRIDE;
virtual StreamStatistician* GetStatistician(uint32_t ssrc) const OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
virtual void SetMaxReorderingThreshold(int max_reordering_threshold) OVERRIDE;
virtual void RegisterRtcpStatisticsCallback(RtcpStatisticsCallback* callback)
diff --git a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
index 0edcf45..25175b3 100644
--- a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
+++ b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
@@ -261,7 +261,7 @@
MOCK_CONST_METHOD3(Version,
int32_t(char* version, uint32_t& remaining_buffer_in_bytes, uint32_t& position));
MOCK_METHOD0(TimeUntilNextProcess,
- int32_t());
+ int64_t());
MOCK_METHOD0(Process,
int32_t());
MOCK_METHOD1(RegisterSendFrameCountObserver,
diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
index fd4b82e..321ea13 100644
--- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
@@ -20,7 +20,7 @@
namespace webrtc {
const int64_t kStatisticsTimeoutMs = 8000;
-const int kStatisticsProcessIntervalMs = 1000;
+const int64_t kStatisticsProcessIntervalMs = 1000;
StreamStatistician::~StreamStatistician() {}
@@ -491,11 +491,12 @@
return 0;
}
-int32_t ReceiveStatisticsImpl::TimeUntilNextProcess() {
+int64_t ReceiveStatisticsImpl::TimeUntilNextProcess() {
CriticalSectionScoped cs(receive_statistics_lock_.get());
- int time_since_last_update = clock_->TimeInMilliseconds() -
+ int64_t time_since_last_update = clock_->TimeInMilliseconds() -
last_rate_update_ms_;
- return std::max(kStatisticsProcessIntervalMs - time_since_last_update, 0);
+ return std::max<int64_t>(
+ kStatisticsProcessIntervalMs - time_since_last_update, 0);
}
void ReceiveStatisticsImpl::RegisterRtcpStatisticsCallback(
@@ -548,7 +549,7 @@
void NullReceiveStatistics::SetMaxReorderingThreshold(
int max_reordering_threshold) {}
-int32_t NullReceiveStatistics::TimeUntilNextProcess() { return 0; }
+int64_t NullReceiveStatistics::TimeUntilNextProcess() { return 0; }
int32_t NullReceiveStatistics::Process() { return 0; }
diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h
index 87eea01..0228925 100644
--- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h
+++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h
@@ -117,7 +117,7 @@
// Implement Module.
virtual int32_t Process() OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual void RegisterRtcpStatisticsCallback(RtcpStatisticsCallback* callback)
OVERRIDE;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h
index 7d124b1..7cfebd9 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h
@@ -13,11 +13,6 @@
// Configuration file for RTP utilities (RTPSender, RTPReceiver ...)
namespace webrtc {
-enum { kRtpRtcpMaxIdleTimeProcess = 5,
- kRtpRtcpBitrateProcessTimeMs = 10,
- kRtpRtcpPacketTimeoutProcessTimeMs = 100,
- kRtpRtcpRttProcessTimeMs = 1000 };
-
enum { NACK_BYTECOUNT_SIZE = 60}; // size of our NACK history
// A sanity for the NACK list parsing at the send-side.
enum { kSendSideNackListSizeSanity = 20000 };
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index f1f1dd6..5f12773 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -154,9 +154,10 @@
// Returns the number of milliseconds until the module want a worker thread
// to call Process.
-int32_t ModuleRtpRtcpImpl::TimeUntilNextProcess() {
- const int64_t now = clock_->TimeInMilliseconds();
- return kRtpRtcpMaxIdleTimeProcess - (now - last_process_time_);
+int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() {
+ const int64_t now = clock_->TimeInMilliseconds();
+ const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5;
+ return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_);
}
// Process any pending tasks such as timeouts (non time critical events).
@@ -164,12 +165,14 @@
const int64_t now = clock_->TimeInMilliseconds();
last_process_time_ = now;
+ const int64_t kRtpRtcpBitrateProcessTimeMs = 10;
if (now >= last_bitrate_process_time_ + kRtpRtcpBitrateProcessTimeMs) {
rtp_sender_.ProcessBitrate();
last_bitrate_process_time_ = now;
}
if (!IsDefaultModule()) {
+ const int64_t kRtpRtcpRttProcessTimeMs = 1000;
bool process_rtt = now >= last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs;
if (rtcp_sender_.Sending()) {
// Process RTT if we have received a receiver report and we haven't
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 0b6de8e..cb00d6d 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -31,7 +31,7 @@
// Returns the number of milliseconds until the module want a worker thread to
// call Process.
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
// Process any pending tasks such as timeouts.
virtual int32_t Process() OVERRIDE;
diff --git a/webrtc/modules/utility/source/process_thread_impl.cc b/webrtc/modules/utility/source/process_thread_impl.cc
index bf7db3b..90f107c 100644
--- a/webrtc/modules/utility/source/process_thread_impl.cc
+++ b/webrtc/modules/utility/source/process_thread_impl.cc
@@ -130,12 +130,12 @@
{
// Wait for the module that should be called next, but don't block thread
// longer than 100 ms.
- int32_t minTimeToNext = 100;
+ int64_t minTimeToNext = 100;
{
CriticalSectionScoped lock(_critSectModules);
for (ModuleList::iterator iter = _modules.begin();
iter != _modules.end(); ++iter) {
- int32_t timeToNext = (*iter)->TimeUntilNextProcess();
+ int64_t timeToNext = (*iter)->TimeUntilNextProcess();
if(minTimeToNext > timeToNext)
{
minTimeToNext = timeToNext;
@@ -145,7 +145,8 @@
if(minTimeToNext > 0)
{
- if(kEventError == _timeEvent.Wait(minTimeToNext))
+ if(kEventError ==
+ _timeEvent.Wait(static_cast<unsigned long>(minTimeToNext)))
{
return true;
}
@@ -159,7 +160,7 @@
CriticalSectionScoped lock(_critSectModules);
for (ModuleList::iterator iter = _modules.begin();
iter != _modules.end(); ++iter) {
- int32_t timeToNext = (*iter)->TimeUntilNextProcess();
+ int64_t timeToNext = (*iter)->TimeUntilNextProcess();
if(timeToNext < 1)
{
(*iter)->Process();
diff --git a/webrtc/modules/video_capture/include/mock/mock_video_capture.h b/webrtc/modules/video_capture/include/mock/mock_video_capture.h
index 8ad74a2..7938b01 100644
--- a/webrtc/modules/video_capture/include/mock/mock_video_capture.h
+++ b/webrtc/modules/video_capture/include/mock/mock_video_capture.h
@@ -18,7 +18,7 @@
class MockVideoCaptureModule : public VideoCaptureModule {
public:
// from Module
- MOCK_METHOD0(TimeUntilNextProcess, int32_t());
+ MOCK_METHOD0(TimeUntilNextProcess, int64_t());
MOCK_METHOD0(Process, int32_t());
// from RefCountedModule
diff --git a/webrtc/modules/video_capture/video_capture_config.h b/webrtc/modules/video_capture/video_capture_config.h
index ab4010c..829a6be 100644
--- a/webrtc/modules/video_capture/video_capture_config.h
+++ b/webrtc/modules/video_capture/video_capture_config.h
@@ -24,7 +24,6 @@
enum {kDefaultCaptureDelay = 120};
enum {kMaxCaptureDelay = 270}; // Max capture delay allowed in the precompiled capture delay values.
-enum {kProcessInterval = 300};
enum {kFrameRateCallbackInterval = 1000};
enum {kFrameRateCountHistorySize = 90};
enum {kFrameRateHistoryWindowMs = 2000};
diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc
index dc56ad3..16b2b45 100644
--- a/webrtc/modules/video_capture/video_capture_impl.cc
+++ b/webrtc/modules/video_capture/video_capture_impl.cc
@@ -89,14 +89,12 @@
}
// returns the number of milliseconds until the module want a worker thread to call Process
-int32_t VideoCaptureImpl::TimeUntilNextProcess()
+int64_t VideoCaptureImpl::TimeUntilNextProcess()
{
CriticalSectionScoped cs(&_callBackCs);
-
- int32_t timeToNormalProcess = kProcessInterval
- - (int32_t)((TickTime::Now() - _lastProcessTime).Milliseconds());
-
- return timeToNormalProcess;
+ const int64_t kProcessIntervalMs = 300;
+ return kProcessIntervalMs -
+ (TickTime::Now() - _lastProcessTime).Milliseconds();
}
// Process any pending tasks such as timeouts
diff --git a/webrtc/modules/video_capture/video_capture_impl.h b/webrtc/modules/video_capture/video_capture_impl.h
index 4e40337..6f0291e 100644
--- a/webrtc/modules/video_capture/video_capture_impl.h
+++ b/webrtc/modules/video_capture/video_capture_impl.h
@@ -78,7 +78,7 @@
virtual const char* CurrentDeviceName() const;
// Module handling
- virtual int32_t TimeUntilNextProcess();
+ virtual int64_t TimeUntilNextProcess();
virtual int32_t Process();
// Implement VideoCaptureExternal
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 80258be..751cff6 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_impl.cc
+++ b/webrtc/modules/video_coding/main/source/video_coding_impl.cc
@@ -21,20 +21,16 @@
namespace webrtc {
namespace vcm {
-uint32_t
+int64_t
VCMProcessTimer::Period() const {
return _periodMs;
}
-uint32_t
+int64_t
VCMProcessTimer::TimeUntilProcess() const {
- const int64_t time_since_process = _clock->TimeInMilliseconds() -
- static_cast<int64_t>(_latestMs);
- const int64_t time_until_process = static_cast<int64_t>(_periodMs) -
- time_since_process;
- if (time_until_process < 0)
- return 0;
- return time_until_process;
+ const int64_t time_since_process = _clock->TimeInMilliseconds() - _latestMs;
+ const int64_t time_until_process = _periodMs - time_since_process;
+ return std::max<int64_t>(time_until_process, 0);
}
void
@@ -90,9 +86,9 @@
own_event_factory_.reset();
}
- virtual int32_t TimeUntilNextProcess() OVERRIDE {
- int32_t sender_time = sender_->TimeUntilNextProcess();
- int32_t receiver_time = receiver_->TimeUntilNextProcess();
+ virtual int64_t TimeUntilNextProcess() OVERRIDE {
+ int64_t sender_time = sender_->TimeUntilNextProcess();
+ int64_t receiver_time = receiver_->TimeUntilNextProcess();
assert(sender_time >= 0);
assert(receiver_time >= 0);
return VCM_MIN(sender_time, receiver_time);
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 179d2c3..71424a6 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_impl.h
+++ b/webrtc/modules/video_coding/main/source/video_coding_impl.h
@@ -37,17 +37,17 @@
class VCMProcessTimer {
public:
- VCMProcessTimer(uint32_t periodMs, Clock* clock)
+ VCMProcessTimer(int64_t periodMs, Clock* clock)
: _clock(clock),
_periodMs(periodMs),
_latestMs(_clock->TimeInMilliseconds()) {}
- uint32_t Period() const;
- uint32_t TimeUntilProcess() const;
+ int64_t Period() const;
+ int64_t TimeUntilProcess() const;
void Processed();
private:
Clock* _clock;
- uint32_t _periodMs;
+ int64_t _periodMs;
int64_t _latestMs;
};
@@ -105,7 +105,7 @@
void SuspendBelowMinBitrate();
bool VideoSuspended() const;
- int32_t TimeUntilNextProcess();
+ int64_t TimeUntilNextProcess();
int32_t Process();
private:
@@ -179,7 +179,7 @@
int32_t SetReceiveChannelParameters(uint32_t rtt);
int32_t SetVideoProtection(VCMVideoProtection videoProtection, bool enable);
- int32_t TimeUntilNextProcess();
+ int64_t TimeUntilNextProcess();
int32_t Process();
void RegisterPreDecodeImageCallback(EncodedImageCallback* observer);
diff --git a/webrtc/modules/video_coding/main/source/video_receiver.cc b/webrtc/modules/video_coding/main/source/video_receiver.cc
index 2f43399..1589315 100644
--- a/webrtc/modules/video_coding/main/source/video_receiver.cc
+++ b/webrtc/modules/video_coding/main/source/video_receiver.cc
@@ -154,8 +154,8 @@
return returnValue;
}
-int32_t VideoReceiver::TimeUntilNextProcess() {
- uint32_t timeUntilNextProcess = _receiveStatsTimer.TimeUntilProcess();
+int64_t VideoReceiver::TimeUntilNextProcess() {
+ int64_t timeUntilNextProcess = _receiveStatsTimer.TimeUntilProcess();
if (_receiver.NackMode() != kNoNack) {
// We need a Process call more often if we are relying on
// retransmissions
diff --git a/webrtc/modules/video_coding/main/source/video_sender.cc b/webrtc/modules/video_coding/main/source/video_sender.cc
index e82df38..6fdc29d 100644
--- a/webrtc/modules/video_coding/main/source/video_sender.cc
+++ b/webrtc/modules/video_coding/main/source/video_sender.cc
@@ -110,7 +110,7 @@
return VCM_OK;
}
-int32_t VideoSender::TimeUntilNextProcess() {
+int64_t VideoSender::TimeUntilNextProcess() {
return _sendStatsTimer.TimeUntilProcess();
}
diff --git a/webrtc/modules/video_processing/main/interface/video_processing.h b/webrtc/modules/video_processing/main/interface/video_processing.h
index df8a361..a4425af 100644
--- a/webrtc/modules/video_processing/main/interface/video_processing.h
+++ b/webrtc/modules/video_processing/main/interface/video_processing.h
@@ -89,7 +89,7 @@
/**
Not supported.
*/
- virtual int32_t TimeUntilNextProcess() OVERRIDE { return -1; }
+ virtual int64_t TimeUntilNextProcess() OVERRIDE { return -1; }
/**
Not supported.
diff --git a/webrtc/modules/video_render/include/video_render.h b/webrtc/modules/video_render/include/video_render.h
index 53a4041..7723950 100644
--- a/webrtc/modules/video_render/include/video_render.h
+++ b/webrtc/modules/video_render/include/video_render.h
@@ -59,7 +59,7 @@
*/
virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE = 0;
- virtual int32_t TimeUntilNextProcess() OVERRIDE = 0;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE = 0;
virtual int32_t Process() OVERRIDE = 0;
/**************************************************************************
diff --git a/webrtc/modules/video_render/video_render_impl.cc b/webrtc/modules/video_render/video_render_impl.cc
index db0dd5a..bcf9d81 100644
--- a/webrtc/modules/video_render/video_render_impl.cc
+++ b/webrtc/modules/video_render/video_render_impl.cc
@@ -129,7 +129,7 @@
return 0;
}
-int32_t ModuleVideoRenderImpl::TimeUntilNextProcess()
+int64_t ModuleVideoRenderImpl::TimeUntilNextProcess()
{
// Not used
return 50;
diff --git a/webrtc/modules/video_render/video_render_impl.h b/webrtc/modules/video_render/video_render_impl.h
index b8f8d67..cf02652 100644
--- a/webrtc/modules/video_render/video_render_impl.h
+++ b/webrtc/modules/video_render/video_render_impl.h
@@ -39,7 +39,7 @@
*/
virtual int32_t ChangeUniqueId(const int32_t id);
- virtual int32_t TimeUntilNextProcess();
+ virtual int64_t TimeUntilNextProcess();
virtual int32_t Process();
/*
diff --git a/webrtc/modules/video_render/video_render_internal_impl.cc b/webrtc/modules/video_render/video_render_internal_impl.cc
index 106a375..963cd11 100644
--- a/webrtc/modules/video_render/video_render_internal_impl.cc
+++ b/webrtc/modules/video_render/video_render_internal_impl.cc
@@ -309,7 +309,7 @@
return 0;
}
-int32_t ModuleVideoRenderImpl::TimeUntilNextProcess()
+int64_t ModuleVideoRenderImpl::TimeUntilNextProcess()
{
// Not used
return 50;
diff --git a/webrtc/test/direct_transport.cc b/webrtc/test/direct_transport.cc
index fd59815..57990b4 100644
--- a/webrtc/test/direct_transport.cc
+++ b/webrtc/test/direct_transport.cc
@@ -78,9 +78,9 @@
bool DirectTransport::SendPackets() {
fake_network_.Process();
- int wait_time_ms = fake_network_.TimeUntilNextProcess();
+ int64_t wait_time_ms = fake_network_.TimeUntilNextProcess();
if (wait_time_ms > 0) {
- switch (packet_event_->Wait(wait_time_ms)) {
+ switch (packet_event_->Wait(static_cast<unsigned long>(wait_time_ms))) {
case kEventSignaled:
packet_event_->Reset();
break;
diff --git a/webrtc/test/fake_network_pipe.cc b/webrtc/test/fake_network_pipe.cc
index c88205b..93a4f6e 100644
--- a/webrtc/test/fake_network_pipe.cc
+++ b/webrtc/test/fake_network_pipe.cc
@@ -22,7 +22,6 @@
namespace webrtc {
const double kPi = 3.14159265;
-const int kDefaultProcessIntervalMs = 30;
static int GaussianRandom(int mean_delay_ms, int standard_deviation_ms) {
// Creating a Normal distribution variable from two independent uniform
@@ -208,12 +207,13 @@
}
}
-int FakeNetworkPipe::TimeUntilNextProcess() const {
+int64_t FakeNetworkPipe::TimeUntilNextProcess() const {
CriticalSectionScoped crit(lock_.get());
+ const int64_t kDefaultProcessIntervalMs = 30;
if (capacity_link_.size() == 0 || delay_link_.size() == 0)
return kDefaultProcessIntervalMs;
- return std::max(static_cast<int>(next_process_time_ -
- TickTime::MillisecondTimestamp()), 0);
+ return std::max<int64_t>(
+ next_process_time_ - TickTime::MillisecondTimestamp(), 0);
}
} // namespace webrtc
diff --git a/webrtc/test/fake_network_pipe.h b/webrtc/test/fake_network_pipe.h
index a9ca760..02813da 100644
--- a/webrtc/test/fake_network_pipe.h
+++ b/webrtc/test/fake_network_pipe.h
@@ -66,7 +66,7 @@
// Processes the network queues and trigger PacketReceiver::IncomingPacket for
// packets ready to be delivered.
void Process();
- int TimeUntilNextProcess() const;
+ int64_t TimeUntilNextProcess() const;
// Get statistics.
float PercentageLoss();
diff --git a/webrtc/video_engine/call_stats.cc b/webrtc/video_engine/call_stats.cc
index ccc97fa..2d324ff 100644
--- a/webrtc/video_engine/call_stats.cc
+++ b/webrtc/video_engine/call_stats.cc
@@ -18,14 +18,14 @@
namespace webrtc {
namespace {
-// A rtt report is considered valid for this long.
-const int kRttTimeoutMs = 1500;
// Time interval for updating the observers.
-const int kUpdateIntervalMs = 1000;
+const int64_t kUpdateIntervalMs = 1000;
// Weight factor to apply to the average rtt.
const float kWeightFactor = 0.3f;
void RemoveOldReports(int64_t now, std::list<CallStats::RttTime>* reports) {
+ // A rtt report is considered valid for this long.
+ const int64_t kRttTimeoutMs = 1500;
while (!reports->empty() &&
(now - reports->front().time) > kRttTimeoutMs) {
reports->pop_front();
@@ -101,7 +101,7 @@
assert(observers_.empty());
}
-int32_t CallStats::TimeUntilNextProcess() {
+int64_t CallStats::TimeUntilNextProcess() {
return last_process_time_ + kUpdateIntervalMs -
TickTime::MillisecondTimestamp();
}
diff --git a/webrtc/video_engine/call_stats.h b/webrtc/video_engine/call_stats.h
index f516ebf..ce7a15a 100644
--- a/webrtc/video_engine/call_stats.h
+++ b/webrtc/video_engine/call_stats.h
@@ -32,7 +32,7 @@
~CallStats();
// Implements Module, to use the process thread.
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
// Returns a RtcpRttStats to register at a statistics provider. The object
diff --git a/webrtc/video_engine/overuse_frame_detector.cc b/webrtc/video_engine/overuse_frame_detector.cc
index 32b0d25..aed0328 100644
--- a/webrtc/video_engine/overuse_frame_detector.cc
+++ b/webrtc/video_engine/overuse_frame_detector.cc
@@ -384,7 +384,7 @@
metrics->capture_queue_delay_ms_per_s = capture_queue_delay_->Value();
}
-int32_t OveruseFrameDetector::TimeUntilNextProcess() {
+int64_t OveruseFrameDetector::TimeUntilNextProcess() {
CriticalSectionScoped cs(crit_.get());
return next_process_time_ - clock_->TimeInMilliseconds();
}
diff --git a/webrtc/video_engine/overuse_frame_detector.h b/webrtc/video_engine/overuse_frame_detector.h
index f92971e..d96adb1 100644
--- a/webrtc/video_engine/overuse_frame_detector.h
+++ b/webrtc/video_engine/overuse_frame_detector.h
@@ -99,7 +99,7 @@
int FramesInQueue() const;
// Implements Module.
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
private:
diff --git a/webrtc/video_engine/vie_channel_group.cc b/webrtc/video_engine/vie_channel_group.cc
index a4bba80..1a4e50f 100644
--- a/webrtc/video_engine/vie_channel_group.cc
+++ b/webrtc/video_engine/vie_channel_group.cc
@@ -65,7 +65,7 @@
return rbe_->Process();
}
- virtual int32_t TimeUntilNextProcess() OVERRIDE {
+ virtual int64_t TimeUntilNextProcess() OVERRIDE {
CriticalSectionScoped cs(crit_sect_.get());
return rbe_->TimeUntilNextProcess();
}
diff --git a/webrtc/video_engine/vie_sync_module.cc b/webrtc/video_engine/vie_sync_module.cc
index a5ca652..f644b68 100644
--- a/webrtc/video_engine/vie_sync_module.cc
+++ b/webrtc/video_engine/vie_sync_module.cc
@@ -22,8 +22,6 @@
namespace webrtc {
-enum { kSyncInterval = 1000};
-
int UpdateMeasurements(StreamSynchronization::Measurements* stream,
const RtpRtcp& rtp_rtcp, const RtpReceiver& receiver) {
if (!receiver.Timestamp(&stream->latest_timestamp))
@@ -93,9 +91,9 @@
return voe_channel_id_;
}
-int32_t ViESyncModule::TimeUntilNextProcess() {
- return static_cast<int32_t>(kSyncInterval -
- (TickTime::Now() - last_sync_time_).Milliseconds());
+int64_t ViESyncModule::TimeUntilNextProcess() {
+ const int64_t kSyncIntervalMs = 1000;
+ return kSyncIntervalMs - (TickTime::Now() - last_sync_time_).Milliseconds();
}
int32_t ViESyncModule::Process() {
diff --git a/webrtc/video_engine/vie_sync_module.h b/webrtc/video_engine/vie_sync_module.h
index e6ca5fd..b125f29 100644
--- a/webrtc/video_engine/vie_sync_module.h
+++ b/webrtc/video_engine/vie_sync_module.h
@@ -45,7 +45,7 @@
int SetTargetBufferingDelay(int target_delay_ms);
// Implements Module.
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
private:
diff --git a/webrtc/voice_engine/monitor_module.cc b/webrtc/voice_engine/monitor_module.cc
index 88de5c8..b1b4732 100644
--- a/webrtc/voice_engine/monitor_module.cc
+++ b/webrtc/voice_engine/monitor_module.cc
@@ -58,13 +58,12 @@
return 0;
}
-int32_t
+int64_t
MonitorModule::TimeUntilNextProcess()
{
- uint32_t now = TickTime::MillisecondTimestamp();
- int32_t timeToNext =
- kAverageProcessUpdateTimeMs - (now - _lastProcessTime);
- return (timeToNext);
+ int64_t now = TickTime::MillisecondTimestamp();
+ const int64_t kAverageProcessUpdateTimeMs = 1000;
+ return kAverageProcessUpdateTimeMs - (now - _lastProcessTime);
}
int32_t
diff --git a/webrtc/voice_engine/monitor_module.h b/webrtc/voice_engine/monitor_module.h
index 693b2e0..9714e92 100644
--- a/webrtc/voice_engine/monitor_module.h
+++ b/webrtc/voice_engine/monitor_module.h
@@ -42,14 +42,13 @@
public: // module
virtual int32_t ChangeUniqueId(int32_t id) OVERRIDE;
- virtual int32_t TimeUntilNextProcess() OVERRIDE;
+ virtual int64_t TimeUntilNextProcess() OVERRIDE;
virtual int32_t Process() OVERRIDE;
private:
- enum { kAverageProcessUpdateTimeMs = 1000 };
MonitorObserver* _observerPtr;
CriticalSectionWrapper& _callbackCritSect;
- int32_t _lastProcessTime;
+ int64_t _lastProcessTime;
};
} // namespace voe