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
This commit is contained in:
pkasting@chromium.org
2014-12-15 22:09:40 +00:00
parent 96a626262a
commit 0b1534c52e
68 changed files with 160 additions and 173 deletions

View File

@ -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 @@ class VideoCodingModuleImpl : public VideoCodingModule {
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);

View File

@ -37,17 +37,17 @@ class DebugRecorder;
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 @@ class VideoSender {
void SuspendBelowMinBitrate();
bool VideoSuspended() const;
int32_t TimeUntilNextProcess();
int64_t TimeUntilNextProcess();
int32_t Process();
private:
@ -179,7 +179,7 @@ class VideoReceiver {
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);

View File

@ -154,8 +154,8 @@ int32_t VideoReceiver::Process() {
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

View File

@ -110,7 +110,7 @@ int32_t VideoSender::InitializeSender() {
return VCM_OK;
}
int32_t VideoSender::TimeUntilNextProcess() {
int64_t VideoSender::TimeUntilNextProcess() {
return _sendStatsTimer.TimeUntilProcess();
}