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
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 2d41fd0..7fef060 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 @@
}
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 4758aa1..ad72071 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 @@
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 5e258c3..a922e35 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 @@
// 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 @@
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;
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 a47b8de..51acc4c 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 @@
// 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 @@
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 38a5bdd..d37308b 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::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 8b27bed..51127fb 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 @@
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;
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 8f2eb7a..870dcc7 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 @@
}
MOCK_METHOD2(SetChannelParameters,
- int32_t(uint32_t packetLoss, int rtt));
+ int32_t(uint32_t packetLoss, int64_t rtt));
virtual ~MockVideoEncoder() {
}
@@ -175,7 +175,7 @@
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, 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 21b07bc..d871eb8 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 @@
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 82b2f24..c9bdb98 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 @@
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 486acdf..5491bd0 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 @@
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 ee40749..6c9f1ab 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 @@
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 94e8f9d..f1ce2ec 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 @@
// 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 @@
//
// 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 096287f..6baf833 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 @@
}
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 a986ada..70569fa 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 @@
/**
* 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 2a590df..14f33ff 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<uint32_t, VCMFrameBuffer*> FrameListPair;
@@ -783,7 +783,7 @@
// low_rtt_nackThresholdMs_ == -1 means no FEC.
double rtt_mult = 1.0f;
if (low_rtt_nack_threshold_ms_ >= 0 &&
- static_cast<int>(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 @@
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 @@
// 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<unsigned int>(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 5ac2b7a..7857aaa 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 @@
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 @@
// |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 @@
// 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 b36775a..9024443 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 @@
}
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 ec7e35c..46ed67b 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 @@
//
// 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 b506a5b..79e1268 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 @@
_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 @@
}
// 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 @@
}
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 d421d9e..3b6fa8f 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 @@
// 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 @@
numLayers(1)
{}
- int rtt;
+ int64_t rtt;
float lossPr;
float bitRate;
float packetsPerFrame;
@@ -211,16 +208,14 @@
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 @@
private:
int ComputeMaxFramesFec(const VCMProtectionParameters* parameters);
- int _lowRttNackMs;
- int _highRttNackMs;
+ int64_t _lowRttNackMs;
+ int64_t _highRttNackMs;
int _maxFramesFec;
};
@@ -267,7 +262,7 @@
//
// 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 @@
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 85cce8f..1151d5b 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 @@
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 675d64e..aa21921 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 @@
// 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 acf62bf..b82bb1b 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 @@
{
// 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 9255aed..3007f63 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 @@
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 654c078..079e7f8 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 @@
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 @@
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 e1a4e2f..c84d992 100644
--- a/webrtc/modules/video_coding/main/source/receiver.cc
+++ b/webrtc/modules/video_coding/main/source/receiver.cc
@@ -59,7 +59,7 @@
return VCM_OK;
}
-void VCMReceiver::UpdateRtt(uint32_t rtt) {
+void VCMReceiver::UpdateRtt(int64_t rtt) {
jitter_buffer_.UpdateRtt(rtt);
}
@@ -191,8 +191,8 @@
}
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 068715f..f531ac8 100644
--- a/webrtc/modules/video_coding/main/source/receiver.h
+++ b/webrtc/modules/video_coding/main/source/receiver.h
@@ -44,7 +44,7 @@
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 @@
// 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 739cc82..5742e8f 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 @@
}
void
-VCMRttFilter::Update(uint32_t rttMs)
+VCMRttFilter::Update(int64_t rttMs)
{
if (!_gotNonZeroUpdate)
{
@@ -103,7 +103,7 @@
}
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 @@
}
bool
-VCMRttFilter::DriftDetection(uint32_t rttMs)
+VCMRttFilter::DriftDetection(int64_t rttMs)
{
if (_maxRtt - _avgRtt > _driftStdDevs * sqrt(_varRtt))
{
@@ -174,7 +174,7 @@
}
void
-VCMRttFilter::ShortRttFilter(uint32_t* buf, uint32_t length)
+VCMRttFilter::ShortRttFilter(int64_t* buf, uint32_t length)
{
if (length == 0)
{
@@ -193,10 +193,10 @@
_avgRtt = _avgRtt / static_cast<double>(length);
}
-uint32_t
+int64_t
VCMRttFilter::RttMs() const
{
- return static_cast<uint32_t>(_maxRtt + 0.5);
+ return static_cast<int64_t>(_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 8b816a0..9e14a1a 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 @@
// 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 @@
// 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 @@
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 c981829..361c0a1 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 @@
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 cd55130..21f6c43 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 @@
// 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 ac938e6..b7c72da 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 @@
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 @@
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 3454e9c..cf4a986 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 @@
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 @@
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 f623c7d..5d87553 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 @@
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 6fdc29d..b2dd23e 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 @@
// 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 57398eb..662faa8 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 @@
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 35cd1f3..d7beb46 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 @@
// 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 02ae7c2..5057f7d 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 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 @@
int loss_count_;
RtpPacketList packets_;
Clock* clock_;
- uint32_t rtt_ms_;
+ int64_t rtt_ms_;
DISALLOW_IMPLICIT_CONSTRUCTORS(LostPackets);
};
@@ -323,7 +323,7 @@
RtpPlayerImpl(PayloadSinkFactoryInterface* payload_sink_factory,
const PayloadTypes& payload_types, Clock* clock,
scoped_ptr<test::RtpFileReader>* 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 @@
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<test::RtpFileReader> 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 1703618..7459231 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 @@
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 4b40cb3..76d5478 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 @@
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 130bd42..0817423 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 @@
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 @@
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<NullEventFactory> 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 b285056..5f8ea35 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 @@
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 8abd8b8..f334db5 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 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;