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:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -196,8 +196,8 @@ public:
|
||||
// Return value : VCM_OK, on success.
|
||||
// < 0, on error.
|
||||
virtual int32_t SetChannelParameters(uint32_t target_bitrate,
|
||||
uint8_t lossRate,
|
||||
uint32_t rtt) = 0;
|
||||
uint8_t lossRate,
|
||||
int64_t rtt) = 0;
|
||||
|
||||
// Sets the parameters describing the receive channel. These parameters are inputs to the
|
||||
// Media Optimization inside the VCM.
|
||||
@ -209,7 +209,7 @@ public:
|
||||
//
|
||||
// Return value : VCM_OK, on success.
|
||||
// < 0, on error.
|
||||
virtual int32_t SetReceiveChannelParameters(uint32_t rtt) = 0;
|
||||
virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0;
|
||||
|
||||
// Register a transport callback which will be called to deliver the encoded data and
|
||||
// side information.
|
||||
|
||||
@ -106,7 +106,7 @@ VCMGenericEncoder::Encode(const I420VideoFrame& inputFrame,
|
||||
}
|
||||
|
||||
int32_t
|
||||
VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int rtt)
|
||||
VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int64_t rtt)
|
||||
{
|
||||
return _encoder.SetChannelParameters(packetLoss, rtt);
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
/**
|
||||
* Set a new packet loss rate and a new round-trip time in milliseconds.
|
||||
*/
|
||||
int32_t SetChannelParameters(int32_t packetLoss, int rtt);
|
||||
int32_t SetChannelParameters(int32_t packetLoss, int64_t rtt);
|
||||
int32_t CodecConfigParameters(uint8_t* buffer, int32_t size);
|
||||
/**
|
||||
* Register a transport callback which will be called to deliver the encoded
|
||||
|
||||
@ -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 @@ uint32_t VCMJitterBuffer::EstimatedJitterMs() {
|
||||
// low_rtt_nackThresholdMs_ == -1 means no FEC.
|
||||
double rtt_mult = 1.0f;
|
||||
if (low_rtt_nack_threshold_ms_ >= 0 &&
|
||||
static_cast<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 @@ uint32_t VCMJitterBuffer::EstimatedJitterMs() {
|
||||
return jitter_estimate_.GetJitterEstimate(rtt_mult);
|
||||
}
|
||||
|
||||
void VCMJitterBuffer::UpdateRtt(uint32_t rtt_ms) {
|
||||
void VCMJitterBuffer::UpdateRtt(int64_t rtt_ms) {
|
||||
CriticalSectionScoped cs(crit_sect_);
|
||||
rtt_ms_ = rtt_ms;
|
||||
jitter_estimate_.UpdateRtt(rtt_ms);
|
||||
}
|
||||
|
||||
void VCMJitterBuffer::SetNackMode(VCMNackMode mode,
|
||||
int low_rtt_nack_threshold_ms,
|
||||
int high_rtt_nack_threshold_ms) {
|
||||
int64_t low_rtt_nack_threshold_ms,
|
||||
int64_t high_rtt_nack_threshold_ms) {
|
||||
CriticalSectionScoped cs(crit_sect_);
|
||||
nack_mode_ = mode;
|
||||
if (mode == kNoNack) {
|
||||
@ -1214,7 +1214,7 @@ bool VCMJitterBuffer::WaitForRetransmissions() {
|
||||
// Evaluate if the RTT is higher than |high_rtt_nack_threshold_ms_|, and in
|
||||
// that case we don't wait for retransmissions.
|
||||
if (high_rtt_nack_threshold_ms_ >= 0 &&
|
||||
rtt_ms_ >= static_cast<unsigned int>(high_rtt_nack_threshold_ms_)) {
|
||||
rtt_ms_ >= high_rtt_nack_threshold_ms_) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -153,7 +153,7 @@ class VCMJitterBuffer {
|
||||
uint32_t EstimatedJitterMs();
|
||||
|
||||
// Updates the round-trip time estimate.
|
||||
void UpdateRtt(uint32_t rtt_ms);
|
||||
void UpdateRtt(int64_t rtt_ms);
|
||||
|
||||
// Set the NACK mode. |highRttNackThreshold| is an RTT threshold in ms above
|
||||
// which NACK will be disabled if the NACK mode is |kNackHybrid|, -1 meaning
|
||||
@ -161,8 +161,8 @@ class VCMJitterBuffer {
|
||||
// |lowRttNackThreshold| is an RTT threshold in ms below which we expect to
|
||||
// rely on NACK only, and therefore are using larger buffers to have time to
|
||||
// wait for retransmissions.
|
||||
void SetNackMode(VCMNackMode mode, int low_rtt_nack_threshold_ms,
|
||||
int high_rtt_nack_threshold_ms);
|
||||
void SetNackMode(VCMNackMode mode, int64_t low_rtt_nack_threshold_ms,
|
||||
int64_t high_rtt_nack_threshold_ms);
|
||||
|
||||
void SetNackSettings(size_t max_nack_list_size,
|
||||
int max_packet_age_to_nack,
|
||||
@ -331,12 +331,12 @@ class VCMJitterBuffer {
|
||||
// Calculates network delays used for jitter calculations.
|
||||
VCMInterFrameDelay inter_frame_delay_;
|
||||
VCMJitterSample waiting_for_completion_;
|
||||
uint32_t rtt_ms_;
|
||||
int64_t rtt_ms_;
|
||||
|
||||
// NACK and retransmissions.
|
||||
VCMNackMode nack_mode_;
|
||||
int low_rtt_nack_threshold_ms_;
|
||||
int high_rtt_nack_threshold_ms_;
|
||||
int64_t low_rtt_nack_threshold_ms_;
|
||||
int64_t high_rtt_nack_threshold_ms_;
|
||||
// Holds the internal NACK list (the missing sequence numbers).
|
||||
SequenceNumberSet missing_sequence_numbers_;
|
||||
uint16_t latest_received_sequence_number_;
|
||||
|
||||
@ -406,7 +406,7 @@ VCMJitterEstimator::PostProcessEstimate()
|
||||
}
|
||||
|
||||
void
|
||||
VCMJitterEstimator::UpdateRtt(uint32_t rttMs)
|
||||
VCMJitterEstimator::UpdateRtt(int64_t rttMs)
|
||||
{
|
||||
_rttFilter.Update(rttMs);
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
//
|
||||
// Input:
|
||||
// - rttMs : RTT in ms
|
||||
void UpdateRtt(uint32_t rttMs);
|
||||
void UpdateRtt(int64_t rttMs);
|
||||
|
||||
void UpdateMaxFrameSize(uint32_t frameSizeBytes);
|
||||
|
||||
|
||||
@ -53,8 +53,8 @@ VCMProtectionMethod::UpdateContentMetrics(const
|
||||
_qmRobustness->UpdateContent(contentMetrics);
|
||||
}
|
||||
|
||||
VCMNackFecMethod::VCMNackFecMethod(int lowRttNackThresholdMs,
|
||||
int highRttNackThresholdMs)
|
||||
VCMNackFecMethod::VCMNackFecMethod(int64_t lowRttNackThresholdMs,
|
||||
int64_t highRttNackThresholdMs)
|
||||
: VCMFecMethod(),
|
||||
_lowRttNackMs(lowRttNackThresholdMs),
|
||||
_highRttNackMs(highRttNackThresholdMs),
|
||||
@ -159,6 +159,8 @@ bool VCMNackFecMethod::BitRateTooLowForFec(
|
||||
}
|
||||
// TODO (marpan): add condition based on maximum frames used for FEC,
|
||||
// and expand condition based on frame size.
|
||||
// Max round trip time threshold in ms.
|
||||
const int64_t kMaxRttTurnOffFec = 200;
|
||||
if (estimate_bytes_per_frame < max_bytes_per_frame &&
|
||||
parameters->numLayers < 3 &&
|
||||
parameters->rtt < kMaxRttTurnOffFec) {
|
||||
@ -737,7 +739,7 @@ VCMLossProtectionLogic::RequiredBitRate() const
|
||||
}
|
||||
|
||||
void
|
||||
VCMLossProtectionLogic::UpdateRtt(uint32_t rtt)
|
||||
VCMLossProtectionLogic::UpdateRtt(int64_t rtt)
|
||||
{
|
||||
_rtt = rtt;
|
||||
}
|
||||
|
||||
@ -41,10 +41,7 @@ enum FilterPacketLossMode {
|
||||
|
||||
// Thresholds for hybrid NACK/FEC
|
||||
// common to media optimization and the jitter buffer.
|
||||
enum HybridNackTH {
|
||||
kHighRttNackMs = 100,
|
||||
kLowRttNackMs = 20
|
||||
};
|
||||
const int64_t kLowRttNackMs = 20;
|
||||
|
||||
struct VCMProtectionParameters
|
||||
{
|
||||
@ -55,7 +52,7 @@ struct VCMProtectionParameters
|
||||
numLayers(1)
|
||||
{}
|
||||
|
||||
int rtt;
|
||||
int64_t rtt;
|
||||
float lossPr;
|
||||
float bitRate;
|
||||
float packetsPerFrame;
|
||||
@ -211,16 +208,14 @@ protected:
|
||||
enum { kMaxBytesPerFrameForFecLow = 400 };
|
||||
// Max bytes/frame for frame size larger than VGA, ~200k at 25fps.
|
||||
enum { kMaxBytesPerFrameForFecHigh = 1000 };
|
||||
// Max round trip time threshold in ms.
|
||||
enum { kMaxRttTurnOffFec = 200 };
|
||||
};
|
||||
|
||||
|
||||
class VCMNackFecMethod : public VCMFecMethod
|
||||
{
|
||||
public:
|
||||
VCMNackFecMethod(int lowRttNackThresholdMs,
|
||||
int highRttNackThresholdMs);
|
||||
VCMNackFecMethod(int64_t lowRttNackThresholdMs,
|
||||
int64_t highRttNackThresholdMs);
|
||||
virtual ~VCMNackFecMethod();
|
||||
virtual bool UpdateParameters(const VCMProtectionParameters* parameters);
|
||||
// Get the effective packet loss for ER
|
||||
@ -234,8 +229,8 @@ public:
|
||||
private:
|
||||
int ComputeMaxFramesFec(const VCMProtectionParameters* parameters);
|
||||
|
||||
int _lowRttNackMs;
|
||||
int _highRttNackMs;
|
||||
int64_t _lowRttNackMs;
|
||||
int64_t _highRttNackMs;
|
||||
int _maxFramesFec;
|
||||
};
|
||||
|
||||
@ -267,7 +262,7 @@ public:
|
||||
//
|
||||
// Input:
|
||||
// - rtt : Round-trip time in seconds.
|
||||
void UpdateRtt(uint32_t rtt);
|
||||
void UpdateRtt(int64_t rtt);
|
||||
|
||||
// Update residual packet loss
|
||||
//
|
||||
@ -369,7 +364,7 @@ private:
|
||||
uint8_t MaxFilteredLossPr(int64_t nowMs) const;
|
||||
VCMProtectionMethod* _selectedMethod;
|
||||
VCMProtectionParameters _currentParameters;
|
||||
uint32_t _rtt;
|
||||
int64_t _rtt;
|
||||
float _lossPr;
|
||||
float _bitRate;
|
||||
float _frameRate;
|
||||
|
||||
@ -200,7 +200,7 @@ void MediaOptimization::SetEncodingDataInternal(VideoCodecType send_codec_type,
|
||||
uint32_t MediaOptimization::SetTargetRates(
|
||||
uint32_t target_bitrate,
|
||||
uint8_t fraction_lost,
|
||||
uint32_t round_trip_time_ms,
|
||||
int64_t round_trip_time_ms,
|
||||
VCMProtectionCallback* protection_callback,
|
||||
VCMQMSettingsCallback* qmsettings_callback) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
|
||||
@ -58,7 +58,7 @@ class MediaOptimization {
|
||||
// an internal critical section.
|
||||
uint32_t SetTargetRates(uint32_t target_bitrate,
|
||||
uint8_t fraction_lost,
|
||||
uint32_t round_trip_time_ms,
|
||||
int64_t round_trip_time_ms,
|
||||
VCMProtectionCallback* protection_callback,
|
||||
VCMQMSettingsCallback* qmsettings_callback);
|
||||
|
||||
|
||||
@ -15,9 +15,8 @@ namespace webrtc
|
||||
{
|
||||
|
||||
// Table for adjusting FEC rate for NACK/FEC protection method
|
||||
// Table values are built as a sigmoid function, ranging from 0 to
|
||||
// kHighRttNackMs (100), based on the HybridNackTH values defined in
|
||||
// media_opt_util.h.
|
||||
// Table values are built as a sigmoid function, ranging from 0 to 100, based on
|
||||
// the HybridNackTH values defined in media_opt_util.h.
|
||||
const uint16_t VCMNackFecTable[100] = {
|
||||
0,
|
||||
0,
|
||||
|
||||
@ -925,7 +925,7 @@ void VCMQmRobustness::Reset() {
|
||||
float VCMQmRobustness::AdjustFecFactor(uint8_t code_rate_delta,
|
||||
float total_rate,
|
||||
float framerate,
|
||||
uint32_t rtt_time,
|
||||
int64_t rtt_time,
|
||||
uint8_t packet_loss) {
|
||||
// Default: no adjustment
|
||||
float adjust_fec = 1.0f;
|
||||
|
||||
@ -353,7 +353,7 @@ class VCMQmRobustness : public VCMQmMethod {
|
||||
float AdjustFecFactor(uint8_t code_rate_delta,
|
||||
float total_rate,
|
||||
float framerate,
|
||||
uint32_t rtt_time,
|
||||
int64_t rtt_time,
|
||||
uint8_t packet_loss);
|
||||
|
||||
// Set the UEP protection on/off.
|
||||
@ -365,7 +365,7 @@ class VCMQmRobustness : public VCMQmMethod {
|
||||
private:
|
||||
// Previous state of network parameters.
|
||||
float prev_total_rate_;
|
||||
uint32_t prev_rtt_time_;
|
||||
int64_t prev_rtt_time_;
|
||||
uint8_t prev_packet_loss_;
|
||||
uint8_t prev_code_rate_delta_;
|
||||
};
|
||||
|
||||
@ -59,7 +59,7 @@ int32_t VCMReceiver::Initialize() {
|
||||
return VCM_OK;
|
||||
}
|
||||
|
||||
void VCMReceiver::UpdateRtt(uint32_t rtt) {
|
||||
void VCMReceiver::UpdateRtt(int64_t rtt) {
|
||||
jitter_buffer_.UpdateRtt(rtt);
|
||||
}
|
||||
|
||||
@ -191,8 +191,8 @@ uint32_t VCMReceiver::DiscardedPackets() const {
|
||||
}
|
||||
|
||||
void VCMReceiver::SetNackMode(VCMNackMode nackMode,
|
||||
int low_rtt_nack_threshold_ms,
|
||||
int high_rtt_nack_threshold_ms) {
|
||||
int64_t low_rtt_nack_threshold_ms,
|
||||
int64_t high_rtt_nack_threshold_ms) {
|
||||
CriticalSectionScoped cs(crit_sect_);
|
||||
// Default to always having NACK enabled in hybrid mode.
|
||||
jitter_buffer_.SetNackMode(nackMode, low_rtt_nack_threshold_ms,
|
||||
|
||||
@ -44,7 +44,7 @@ class VCMReceiver {
|
||||
|
||||
void Reset();
|
||||
int32_t Initialize();
|
||||
void UpdateRtt(uint32_t rtt);
|
||||
void UpdateRtt(int64_t rtt);
|
||||
int32_t InsertPacket(const VCMPacket& packet,
|
||||
uint16_t frame_width,
|
||||
uint16_t frame_height);
|
||||
@ -57,8 +57,8 @@ class VCMReceiver {
|
||||
|
||||
// NACK.
|
||||
void SetNackMode(VCMNackMode nackMode,
|
||||
int low_rtt_nack_threshold_ms,
|
||||
int high_rtt_nack_threshold_ms);
|
||||
int64_t low_rtt_nack_threshold_ms,
|
||||
int64_t high_rtt_nack_threshold_ms);
|
||||
void SetNackSettings(size_t max_nack_list_size,
|
||||
int max_packet_age_to_nack,
|
||||
int max_incomplete_time_ms);
|
||||
|
||||
@ -58,7 +58,7 @@ VCMRttFilter::Reset()
|
||||
}
|
||||
|
||||
void
|
||||
VCMRttFilter::Update(uint32_t rttMs)
|
||||
VCMRttFilter::Update(int64_t rttMs)
|
||||
{
|
||||
if (!_gotNonZeroUpdate)
|
||||
{
|
||||
@ -103,7 +103,7 @@ VCMRttFilter::Update(uint32_t rttMs)
|
||||
}
|
||||
|
||||
bool
|
||||
VCMRttFilter::JumpDetection(uint32_t rttMs)
|
||||
VCMRttFilter::JumpDetection(int64_t rttMs)
|
||||
{
|
||||
double diffFromAvg = _avgRtt - rttMs;
|
||||
if (fabs(diffFromAvg) > _jumpStdDevs * sqrt(_varRtt))
|
||||
@ -147,7 +147,7 @@ VCMRttFilter::JumpDetection(uint32_t rttMs)
|
||||
}
|
||||
|
||||
bool
|
||||
VCMRttFilter::DriftDetection(uint32_t rttMs)
|
||||
VCMRttFilter::DriftDetection(int64_t rttMs)
|
||||
{
|
||||
if (_maxRtt - _avgRtt > _driftStdDevs * sqrt(_varRtt))
|
||||
{
|
||||
@ -174,7 +174,7 @@ VCMRttFilter::DriftDetection(uint32_t rttMs)
|
||||
}
|
||||
|
||||
void
|
||||
VCMRttFilter::ShortRttFilter(uint32_t* buf, uint32_t length)
|
||||
VCMRttFilter::ShortRttFilter(int64_t* buf, uint32_t length)
|
||||
{
|
||||
if (length == 0)
|
||||
{
|
||||
@ -193,10 +193,10 @@ VCMRttFilter::ShortRttFilter(uint32_t* buf, uint32_t length)
|
||||
_avgRtt = _avgRtt / static_cast<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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,9 +26,9 @@ public:
|
||||
// Resets the filter.
|
||||
void Reset();
|
||||
// Updates the filter with a new sample.
|
||||
void Update(uint32_t rttMs);
|
||||
void Update(int64_t rttMs);
|
||||
// A getter function for the current RTT level in ms.
|
||||
uint32_t RttMs() const;
|
||||
int64_t RttMs() const;
|
||||
|
||||
private:
|
||||
// The size of the drift and jump memory buffers
|
||||
@ -39,19 +39,19 @@ private:
|
||||
// samples and average to the standard deviation.
|
||||
// Returns true if the long time statistics should be updated
|
||||
// and false otherwise
|
||||
bool JumpDetection(uint32_t rttMs);
|
||||
bool JumpDetection(int64_t rttMs);
|
||||
// Detects RTT drifts by comparing the difference between
|
||||
// max and average to the standard deviation.
|
||||
// Returns true if the long time statistics should be updated
|
||||
// and false otherwise
|
||||
bool DriftDetection(uint32_t rttMs);
|
||||
bool DriftDetection(int64_t rttMs);
|
||||
// Computes the short time average and maximum of the vector buf.
|
||||
void ShortRttFilter(uint32_t* buf, uint32_t length);
|
||||
void ShortRttFilter(int64_t* buf, uint32_t length);
|
||||
|
||||
bool _gotNonZeroUpdate;
|
||||
double _avgRtt;
|
||||
double _varRtt;
|
||||
uint32_t _maxRtt;
|
||||
int64_t _maxRtt;
|
||||
uint32_t _filtFactCount;
|
||||
const uint32_t _filtFactMax;
|
||||
const double _jumpStdDevs;
|
||||
@ -59,8 +59,8 @@ private:
|
||||
int32_t _jumpCount;
|
||||
int32_t _driftCount;
|
||||
const int32_t _detectThreshold;
|
||||
uint32_t _jumpBuf[kMaxDriftJumpCount];
|
||||
uint32_t _driftBuf[kMaxDriftJumpCount];
|
||||
int64_t _jumpBuf[kMaxDriftJumpCount];
|
||||
int64_t _driftBuf[kMaxDriftJumpCount];
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -14,18 +14,13 @@
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
// Used in determining whether a frame is decodable.
|
||||
enum {kRttThreshold = 100}; // Not decodable if Rtt is lower than this.
|
||||
|
||||
// Do not decode frames if the number of packets is between these two
|
||||
// thresholds.
|
||||
static const float kLowPacketPercentageThreshold = 0.2f;
|
||||
static const float kHighPacketPercentageThreshold = 0.8f;
|
||||
namespace {
|
||||
|
||||
uint16_t BufferToUWord16(const uint8_t* dataBuffer) {
|
||||
return (dataBuffer[0] << 8) | dataBuffer[1];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
VCMSessionInfo::VCMSessionInfo()
|
||||
@ -233,6 +228,12 @@ void VCMSessionInfo::UpdateDecodableSession(const FrameData& frame_data) {
|
||||
return;
|
||||
// TODO(agalusza): Account for bursty loss.
|
||||
// TODO(agalusza): Refine these values to better approximate optimal ones.
|
||||
// Do not decode frames if the RTT is lower than this.
|
||||
const int64_t kRttThreshold = 100;
|
||||
// Do not decode frames if the number of packets is between these two
|
||||
// thresholds.
|
||||
const float kLowPacketPercentageThreshold = 0.2f;
|
||||
const float kHighPacketPercentageThreshold = 0.8f;
|
||||
if (frame_data.rtt_ms < kRttThreshold
|
||||
|| frame_type_ == kVideoFrameKey
|
||||
|| !HaveFirstPacket()
|
||||
|
||||
@ -22,7 +22,7 @@ namespace webrtc {
|
||||
// Used to pass data from jitter buffer to session info.
|
||||
// This data is then used in determining whether a frame is decodable.
|
||||
struct FrameData {
|
||||
int rtt_ms;
|
||||
int64_t rtt_ms;
|
||||
float rolling_average_packets_per_frame;
|
||||
};
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
||||
|
||||
virtual int32_t SetChannelParameters(uint32_t target_bitrate, // bits/s.
|
||||
uint8_t lossRate,
|
||||
uint32_t rtt) OVERRIDE {
|
||||
int64_t rtt) OVERRIDE {
|
||||
return sender_->SetChannelParameters(target_bitrate, lossRate, rtt);
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
||||
return receiver_->SetMinReceiverDelay(desired_delay_ms);
|
||||
}
|
||||
|
||||
virtual int32_t SetReceiveChannelParameters(uint32_t rtt) OVERRIDE {
|
||||
virtual int32_t SetReceiveChannelParameters(int64_t rtt) OVERRIDE {
|
||||
return receiver_->SetReceiveChannelParameters(rtt);
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ class VideoSender {
|
||||
|
||||
int32_t SetChannelParameters(uint32_t target_bitrate, // bits/s.
|
||||
uint8_t lossRate,
|
||||
uint32_t rtt);
|
||||
int64_t rtt);
|
||||
|
||||
int32_t RegisterTransportCallback(VCMPacketizationCallback* transport);
|
||||
int32_t RegisterSendStatisticsCallback(VCMSendStatisticsCallback* sendStats);
|
||||
@ -175,7 +175,7 @@ class VideoReceiver {
|
||||
void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode);
|
||||
int SetMinReceiverDelay(int desired_delay_ms);
|
||||
|
||||
int32_t SetReceiveChannelParameters(uint32_t rtt);
|
||||
int32_t SetReceiveChannelParameters(int64_t rtt);
|
||||
int32_t SetVideoProtection(VCMVideoProtection videoProtection, bool enable);
|
||||
|
||||
int64_t TimeUntilNextProcess();
|
||||
|
||||
@ -168,7 +168,7 @@ int64_t VideoReceiver::TimeUntilNextProcess() {
|
||||
return timeUntilNextProcess;
|
||||
}
|
||||
|
||||
int32_t VideoReceiver::SetReceiveChannelParameters(uint32_t rtt) {
|
||||
int32_t VideoReceiver::SetReceiveChannelParameters(int64_t rtt) {
|
||||
CriticalSectionScoped receiveCs(_receiveCritSect);
|
||||
_receiver.UpdateRtt(rtt);
|
||||
return 0;
|
||||
|
||||
@ -244,7 +244,7 @@ int VideoSender::FrameRate(unsigned int* framerate) const {
|
||||
// Set channel parameters
|
||||
int32_t VideoSender::SetChannelParameters(uint32_t target_bitrate,
|
||||
uint8_t lossRate,
|
||||
uint32_t rtt) {
|
||||
int64_t rtt) {
|
||||
int32_t ret = 0;
|
||||
{
|
||||
CriticalSectionScoped sendCs(_sendCritSect);
|
||||
|
||||
@ -75,7 +75,7 @@ private:
|
||||
bool _nackEnabled;
|
||||
bool _fecEnabled;
|
||||
bool _nackFecEnabled;
|
||||
uint8_t _rttMS;
|
||||
int64_t _rttMS;
|
||||
float _bitRate;
|
||||
double _lossRate;
|
||||
uint32_t _renderDelayMs;
|
||||
|
||||
@ -119,7 +119,7 @@ int MTRxTxTest(CmdArgs& args)
|
||||
// Nack support is currently not implemented in this test.
|
||||
bool nackEnabled = false;
|
||||
bool fecEnabled = false;
|
||||
uint8_t rttMS = 20;
|
||||
int64_t rttMS = 20;
|
||||
float lossRate = 0.0*255; // no packet loss
|
||||
uint32_t renderDelayMs = 0;
|
||||
uint32_t minPlayoutDelayMs = 0;
|
||||
|
||||
@ -71,7 +71,7 @@ class RawRtpPacket {
|
||||
|
||||
class LostPackets {
|
||||
public:
|
||||
LostPackets(Clock* clock, uint32_t rtt_ms)
|
||||
LostPackets(Clock* clock, int64_t rtt_ms)
|
||||
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
debug_file_(fopen("PacketLossDebug.txt", "w")),
|
||||
loss_count_(0),
|
||||
@ -180,7 +180,7 @@ class LostPackets {
|
||||
int loss_count_;
|
||||
RtpPacketList packets_;
|
||||
Clock* clock_;
|
||||
uint32_t rtt_ms_;
|
||||
int64_t rtt_ms_;
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(LostPackets);
|
||||
};
|
||||
@ -323,7 +323,7 @@ class RtpPlayerImpl : public RtpPlayerInterface {
|
||||
RtpPlayerImpl(PayloadSinkFactoryInterface* payload_sink_factory,
|
||||
const PayloadTypes& payload_types, Clock* clock,
|
||||
scoped_ptr<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 @@ class RtpPlayerImpl : public RtpPlayerInterface {
|
||||
|
||||
RtpPlayerInterface* Create(const std::string& input_filename,
|
||||
PayloadSinkFactoryInterface* payload_sink_factory, Clock* clock,
|
||||
const PayloadTypes& payload_types, float loss_rate, uint32_t rtt_ms,
|
||||
const PayloadTypes& payload_types, float loss_rate, int64_t rtt_ms,
|
||||
bool reordering) {
|
||||
scoped_ptr<test::RtpFileReader> packet_source(test::RtpFileReader::Create(
|
||||
test::RtpFileReader::kRtpDump, input_filename));
|
||||
|
||||
@ -88,7 +88,7 @@ class RtpPlayerInterface {
|
||||
|
||||
RtpPlayerInterface* Create(const std::string& inputFilename,
|
||||
PayloadSinkFactoryInterface* payloadSinkFactory, Clock* clock,
|
||||
const PayloadTypes& payload_types, float lossRate, uint32_t rttMs,
|
||||
const PayloadTypes& payload_types, float lossRate, int64_t rttMs,
|
||||
bool reordering);
|
||||
|
||||
} // namespace rtpplayer
|
||||
|
||||
@ -108,7 +108,7 @@ VcmPayloadSinkFactory::VcmPayloadSinkFactory(
|
||||
Clock* clock,
|
||||
bool protection_enabled,
|
||||
VCMVideoProtection protection_method,
|
||||
uint32_t rtt_ms,
|
||||
int64_t rtt_ms,
|
||||
uint32_t render_delay_ms,
|
||||
uint32_t min_playout_delay_ms)
|
||||
: base_out_filename_(base_out_filename),
|
||||
|
||||
@ -28,7 +28,7 @@ class VcmPayloadSinkFactory : public PayloadSinkFactoryInterface {
|
||||
VcmPayloadSinkFactory(const std::string& base_out_filename,
|
||||
Clock* clock, bool protection_enabled,
|
||||
VCMVideoProtection protection_method,
|
||||
uint32_t rtt_ms, uint32_t render_delay_ms,
|
||||
int64_t rtt_ms, uint32_t render_delay_ms,
|
||||
uint32_t min_playout_delay_ms);
|
||||
virtual ~VcmPayloadSinkFactory();
|
||||
|
||||
@ -50,7 +50,7 @@ class VcmPayloadSinkFactory : public PayloadSinkFactoryInterface {
|
||||
Clock* clock_;
|
||||
bool protection_enabled_;
|
||||
VCMVideoProtection protection_method_;
|
||||
uint32_t rtt_ms_;
|
||||
int64_t rtt_ms_;
|
||||
uint32_t render_delay_ms_;
|
||||
uint32_t min_playout_delay_ms_;
|
||||
scoped_ptr<NullEventFactory> null_event_factory_;
|
||||
|
||||
@ -20,7 +20,7 @@ const webrtc::VCMVideoProtection kConfigProtectionMethod =
|
||||
webrtc::kProtectionNack;
|
||||
const float kConfigLossRate = 0.0f;
|
||||
const bool kConfigReordering = false;
|
||||
const uint32_t kConfigRttMs = 0;
|
||||
const int64_t kConfigRttMs = 0;
|
||||
const uint32_t kConfigRenderDelayMs = 0;
|
||||
const uint32_t kConfigMinPlayoutDelayMs = 0;
|
||||
const int64_t kConfigMaxRuntimeMs = -1;
|
||||
|
||||
@ -26,7 +26,7 @@ const bool kConfigProtectionEnabled = true;
|
||||
const webrtc::VCMVideoProtection kConfigProtectionMethod =
|
||||
webrtc::kProtectionNack;
|
||||
const float kConfigLossRate = 0.05f;
|
||||
const uint32_t kConfigRttMs = 50;
|
||||
const int64_t kConfigRttMs = 50;
|
||||
const bool kConfigReordering = false;
|
||||
const uint32_t kConfigRenderDelayMs = 0;
|
||||
const uint32_t kConfigMinPlayoutDelayMs = 0;
|
||||
|
||||
Reference in New Issue
Block a user