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
This commit is contained in:
pkasting@chromium.org
2015-01-12 21:51:21 +00:00
parent a7add19cf4
commit 16825b1a82
124 changed files with 422 additions and 417 deletions

View File

@ -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;
}

View File

@ -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,

View File

@ -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<int64_t>(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<int64_t>(1) << 32)) - old_ts;

View File

@ -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

View File

@ -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);
}

View File

@ -47,7 +47,7 @@ class SimulcastEncoderAdapter : public VP8Encoder,
const std::vector<VideoFrameType>* 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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;