Change VCM interface to take target bitrate in bits per second.
This also solves issue 1469. TESTS=trybots BUG=1469 Review URL: https://webrtc-codereview.appspot.com/1215004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3681 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -105,10 +105,11 @@ public:
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
const std::vector<FrameType>& frameTypes);
|
||||
/**
|
||||
* Set new target bit rate and frame rate
|
||||
* Return Value: new bit rate if OK, otherwise <0s
|
||||
* Set new target bitrate (bits/s) and framerate.
|
||||
* Return Value: new bit rate if OK, otherwise <0s.
|
||||
*/
|
||||
WebRtc_Word32 SetRates(WebRtc_UWord32 newBitRate, WebRtc_UWord32 frameRate);
|
||||
WebRtc_Word32 SetRates(WebRtc_UWord32 target_bitrate,
|
||||
WebRtc_UWord32 frameRate);
|
||||
/**
|
||||
* Set a new packet loss rate and a new round-trip time in milliseconds.
|
||||
*/
|
||||
|
||||
@ -93,12 +93,13 @@ VCMMediaOptimization::Reset()
|
||||
}
|
||||
|
||||
WebRtc_UWord32
|
||||
VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
||||
VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 target_bitrate,
|
||||
WebRtc_UWord8 &fractionLost,
|
||||
WebRtc_UWord32 roundTripTimeMs)
|
||||
{
|
||||
VCMProtectionMethod *selectedMethod = _lossProtLogic->SelectedMethod();
|
||||
_lossProtLogic->UpdateBitRate(static_cast<float>(bitRate));
|
||||
float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f;
|
||||
_lossProtLogic->UpdateBitRate(target_bitrate_kbps);
|
||||
_lossProtLogic->UpdateRtt(roundTripTimeMs);
|
||||
_lossProtLogic->UpdateResidualPacketLoss(static_cast<float>(fractionLost));
|
||||
|
||||
@ -129,10 +130,10 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
||||
_lossProtLogic->UpdateFilteredLossPr(packetLossEnc);
|
||||
|
||||
// Rate cost of the protection methods
|
||||
uint32_t protection_overhead_kbps = 0;
|
||||
uint32_t protection_overhead_bps = 0;
|
||||
|
||||
// Update protection settings, when applicable
|
||||
float sent_video_rate = 0.0f;
|
||||
float sent_video_rate_kbps = 0.0f;
|
||||
if (selectedMethod)
|
||||
{
|
||||
// Update protection method with content metrics
|
||||
@ -159,32 +160,32 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
|
||||
// Estimate the overhead costs of the next second as staying the same
|
||||
// wrt the source bitrate.
|
||||
if (sent_total_rate_bps > 0) {
|
||||
protection_overhead_kbps = static_cast<uint32_t>(bitRate *
|
||||
protection_overhead_bps = static_cast<uint32_t>(target_bitrate *
|
||||
static_cast<double>(sent_nack_rate_bps + sent_fec_rate_bps) /
|
||||
sent_total_rate_bps + 0.5);
|
||||
}
|
||||
// Cap the overhead estimate to 50%.
|
||||
if (protection_overhead_kbps > bitRate / 2)
|
||||
protection_overhead_kbps = bitRate / 2;
|
||||
if (protection_overhead_bps > target_bitrate / 2)
|
||||
protection_overhead_bps = target_bitrate / 2;
|
||||
|
||||
// Get the effective packet loss for encoder ER
|
||||
// when applicable, should be passed to encoder via fractionLost
|
||||
packetLossEnc = selectedMethod->RequiredPacketLossER();
|
||||
sent_video_rate = static_cast<float>(sent_video_rate_bps / 1000.0);
|
||||
sent_video_rate_kbps =
|
||||
static_cast<float>(sent_video_rate_bps) / 1000.0f;
|
||||
}
|
||||
|
||||
// Source coding rate: total rate - protection overhead
|
||||
_targetBitRate = bitRate - protection_overhead_kbps;
|
||||
_targetBitRate = target_bitrate - protection_overhead_bps;
|
||||
|
||||
// Update encoding rates following protection settings
|
||||
_frameDropper->SetRates(static_cast<float>(_targetBitRate),
|
||||
_incomingFrameRate);
|
||||
_frameDropper->SetRates(target_bitrate_kbps, _incomingFrameRate);
|
||||
|
||||
if (_enableQm)
|
||||
{
|
||||
// Update QM with rates
|
||||
_qmResolution->UpdateRates((float)_targetBitRate, sent_video_rate,
|
||||
_incomingFrameRate, _fractionLost);
|
||||
_qmResolution->UpdateRates(target_bitrate_kbps, sent_video_rate_kbps,
|
||||
_incomingFrameRate, _fractionLost);
|
||||
// Check for QM selection
|
||||
bool selectQM = checkStatusForQMchange();
|
||||
if (selectQM)
|
||||
@ -266,7 +267,7 @@ WebRtc_Word32
|
||||
VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType,
|
||||
WebRtc_Word32 maxBitRate,
|
||||
WebRtc_UWord32 frameRate,
|
||||
WebRtc_UWord32 bitRate,
|
||||
WebRtc_UWord32 target_bitrate,
|
||||
WebRtc_UWord16 width,
|
||||
WebRtc_UWord16 height,
|
||||
int numLayers)
|
||||
@ -281,20 +282,20 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType,
|
||||
|
||||
_maxBitRate = maxBitRate;
|
||||
_sendCodecType = sendCodecType;
|
||||
_targetBitRate = bitRate;
|
||||
_lossProtLogic->UpdateBitRate(static_cast<float>(bitRate));
|
||||
_targetBitRate = target_bitrate;
|
||||
float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f;
|
||||
_lossProtLogic->UpdateBitRate(target_bitrate_kbps);
|
||||
_lossProtLogic->UpdateFrameRate(static_cast<float>(frameRate));
|
||||
_lossProtLogic->UpdateFrameSize(width, height);
|
||||
_lossProtLogic->UpdateNumLayers(numLayers);
|
||||
_frameDropper->Reset();
|
||||
_frameDropper->SetRates(static_cast<float>(bitRate),
|
||||
static_cast<float>(frameRate));
|
||||
_frameDropper->SetRates(target_bitrate_kbps, static_cast<float>(frameRate));
|
||||
_userFrameRate = static_cast<float>(frameRate);
|
||||
_codecWidth = width;
|
||||
_codecHeight = height;
|
||||
_numLayers = (numLayers <= 1) ? 1 : numLayers; // Can also be zero.
|
||||
WebRtc_Word32 ret = VCM_OK;
|
||||
ret = _qmResolution->Initialize((float)_targetBitRate, _userFrameRate,
|
||||
ret = _qmResolution->Initialize(target_bitrate_kbps, _userFrameRate,
|
||||
_codecWidth, _codecHeight, _numLayers);
|
||||
return ret;
|
||||
}
|
||||
@ -361,7 +362,7 @@ float
|
||||
VCMMediaOptimization::SentBitRate()
|
||||
{
|
||||
UpdateBitRateEstimate(-1, _clock->TimeInMilliseconds());
|
||||
return _avgSentBitRateBps / 1000.0f;
|
||||
return _avgSentBitRateBps;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
|
||||
@ -47,14 +47,13 @@ public:
|
||||
WebRtc_Word32 Reset();
|
||||
/**
|
||||
* Set target Rates for the encoder given the channel parameters
|
||||
* Inputs: bitRate - target bitRate, in the conference case this is the rate
|
||||
* between the sending client and the server
|
||||
* Inputs: target bitrate - the encoder target bitrate in bits/s.
|
||||
* fractionLost - packet loss in % in the network
|
||||
* roundTripTimeMs - round trip time in miliseconds
|
||||
* roundTripTimeMs - round trip time in milliseconds
|
||||
* minBitRate - the bit rate of the end-point with lowest rate
|
||||
* maxBitRate - the bit rate of the end-point with highest rate
|
||||
*/
|
||||
WebRtc_UWord32 SetTargetRates(WebRtc_UWord32 bitRate,
|
||||
WebRtc_UWord32 SetTargetRates(WebRtc_UWord32 target_bitrate,
|
||||
WebRtc_UWord8 &fractionLost,
|
||||
WebRtc_UWord32 roundTripTimeMs);
|
||||
|
||||
|
||||
@ -349,9 +349,9 @@ VideoCodingModuleImpl::RegisterSendCodec(const VideoCodec* sendCodec,
|
||||
kVideoFrameDelta);
|
||||
|
||||
_mediaOpt.SetEncodingData(_sendCodecType,
|
||||
sendCodec->maxBitrate,
|
||||
sendCodec->maxFramerate,
|
||||
sendCodec->startBitrate,
|
||||
sendCodec->maxBitrate * 1000,
|
||||
sendCodec->maxFramerate * 1000,
|
||||
sendCodec->startBitrate * 1000,
|
||||
sendCodec->width,
|
||||
sendCodec->height,
|
||||
numLayers);
|
||||
@ -447,14 +447,14 @@ int VideoCodingModuleImpl::FrameRate(unsigned int* framerate) const
|
||||
|
||||
// Set channel parameters
|
||||
WebRtc_Word32
|
||||
VideoCodingModuleImpl::SetChannelParameters(WebRtc_UWord32 availableBandWidth,
|
||||
VideoCodingModuleImpl::SetChannelParameters(WebRtc_UWord32 target_bitrate,
|
||||
WebRtc_UWord8 lossRate,
|
||||
WebRtc_UWord32 rtt)
|
||||
{
|
||||
WebRtc_Word32 ret = 0;
|
||||
{
|
||||
CriticalSectionScoped sendCs(_sendCritSect);
|
||||
WebRtc_UWord32 targetRate = _mediaOpt.SetTargetRates(availableBandWidth,
|
||||
WebRtc_UWord32 targetRate = _mediaOpt.SetTargetRates(target_bitrate,
|
||||
lossRate,
|
||||
rtt);
|
||||
if (_encoder != NULL)
|
||||
|
||||
@ -109,7 +109,7 @@ public:
|
||||
|
||||
// Set channel parameters
|
||||
virtual WebRtc_Word32 SetChannelParameters(
|
||||
WebRtc_UWord32 availableBandWidth,
|
||||
WebRtc_UWord32 target_bitrate, // bits/s.
|
||||
WebRtc_UWord8 lossRate,
|
||||
WebRtc_UWord32 rtt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user