Update all child modules of with received bandwidth estimate.

BUG=224

Review URL: http://webrtc-codereview.appspot.com/347007

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1391 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2012-01-11 14:18:33 +00:00
parent cd8cea50a6
commit 04c18cb37a

View File

@ -2650,61 +2650,80 @@ void ModuleRtpRtcpImpl::OnReceivedIntraFrameRequest(const RtpRtcp* caller) {
void ModuleRtpRtcpImpl::OnReceivedEstimatedMaxBitrate( void ModuleRtpRtcpImpl::OnReceivedEstimatedMaxBitrate(
const WebRtc_UWord32 maxBitrate) { const WebRtc_UWord32 maxBitrate) {
// We received a REMB // We received a REMB.
if (_defaultModule) {
// Let the default module handle this.
CriticalSectionScoped lock(_criticalSectionModulePtrs);
if (_defaultModule) { if (_defaultModule) {
CriticalSectionScoped lock(_criticalSectionModulePtrs); // if we use a default module pass this info to the default module
if (_defaultModule) { _defaultModule->OnReceivedEstimatedMaxBitrate(maxBitrate);
// if we use a default module pass this info to the default module return;
_defaultModule->OnReceivedEstimatedMaxBitrate(maxBitrate);
return;
}
} }
WebRtc_UWord32 newBitrate = 0; }
WebRtc_UWord8 fractionLost = 0; WebRtc_UWord32 newBitrate = 0;
WebRtc_UWord16 roundTripTime = 0; WebRtc_UWord8 fractionLost = 0;
WebRtc_UWord16 bwEstimateKbit = WebRtc_UWord16(maxBitrate / 1000); WebRtc_UWord16 roundTripTime = 0;
if (_bandwidthManagement.UpdateBandwidthEstimate(bwEstimateKbit, WebRtc_UWord16 bwEstimateKbit = WebRtc_UWord16(maxBitrate / 1000);
&newBitrate, if (_bandwidthManagement.UpdateBandwidthEstimate(bwEstimateKbit,
&fractionLost, &newBitrate,
&roundTripTime) == 0) { &fractionLost,
// TODO(mflodman) When encoding two streams, we need to split the bitrate &roundTripTime) == 0) {
// between REMB sending channels. // TODO(mflodman) When encoding two streams, we need to split the
// might trigger a OnNetworkChanged in video callback // bitrate between REMB sending channels.
_rtpReceiver.UpdateBandwidthManagement(newBitrate, _rtpReceiver.UpdateBandwidthManagement(newBitrate,
fractionLost, fractionLost,
roundTripTime); roundTripTime);
if (newBitrate <= 0) {
return;
}
const bool defaultInstance = !_childModules.empty();
if (!defaultInstance) {
return;
}
CriticalSectionScoped lock(_criticalSectionModulePtrsFeedback);
std::list<ModuleRtpRtcpImpl*>::iterator it = _childModules.begin();
WebRtc_UWord8 idx = 0;
while (it != _childModules.end()) {
// sanity
if (idx >= (_sendVideoCodec.numberOfSimulcastStreams - 1)) {
return;
}
ModuleRtpRtcpImpl* module = *it;
// update all child modules
if (newBitrate >= _sendVideoCodec.simulcastStream[idx].maxBitrate) {
module->_bandwidthManagement.SetSendBitrate(
_sendVideoCodec.simulcastStream[idx].maxBitrate, 0, 0);
module->_rtpSender.SetTargetSendBitrate(
_sendVideoCodec.simulcastStream[idx].maxBitrate);
newBitrate -= _sendVideoCodec.simulcastStream[idx].maxBitrate; // We've received a new bandwidth estimate lower than the current send
} else { // bitrate. For simulcast we need to update the sending bitrate for all
module->_bandwidthManagement.SetSendBitrate(newBitrate, 0, 0); // streams.
module->_rtpSender.SetTargetSendBitrate(newBitrate); if (_simulcast) {
newBitrate -= newBitrate; CriticalSectionScoped lock(_criticalSectionModulePtrsFeedback);
} WebRtc_UWord8 idx = 0;
idx++; for (std::list<ModuleRtpRtcpImpl*>::iterator it = _childModules.begin();
it != _childModules.end(); ++it) {
// sanity
if (idx >= (_sendVideoCodec.numberOfSimulcastStreams - 1)) {
return;
} }
ModuleRtpRtcpImpl* module = *it;
if (newBitrate >= _sendVideoCodec.simulcastStream[idx].maxBitrate) {
module->_bandwidthManagement.SetSendBitrate(
_sendVideoCodec.simulcastStream[idx].maxBitrate, 0, 0);
module->_rtpSender.SetTargetSendBitrate(
_sendVideoCodec.simulcastStream[idx].maxBitrate);
newBitrate -= _sendVideoCodec.simulcastStream[idx].maxBitrate;
} else {
module->_bandwidthManagement.SetSendBitrate(newBitrate, 0, 0);
module->_rtpSender.SetTargetSendBitrate(newBitrate);
newBitrate -= newBitrate;
}
idx++;
}
} }
}
// For non-simulcast, update all child modules with the new bandwidth estimate
// regardless of the new estimate.
if (!_simulcast) {
// Update all child modules with the new max bitrate before exiting.
CriticalSectionScoped lock(_criticalSectionModulePtrsFeedback);
for (std::list<ModuleRtpRtcpImpl*>::iterator it = _childModules.begin();
it != _childModules.end(); ++it) {
// Update all child modules with the maximum bitrate estimate.
ModuleRtpRtcpImpl* module = *it;
WebRtc_UWord32 ignoreBitrate = 0;
WebRtc_UWord8 ignoreFractionLost = 0;
WebRtc_UWord16 ignoreRoundTripTime = 0;
module->_bandwidthManagement.UpdateBandwidthEstimate(
bwEstimateKbit,
&ignoreBitrate,
&ignoreFractionLost,
&ignoreRoundTripTime);
// We don't need to take care of a possible lowered bitrate, that is
// handled earlier in this function for the default module.
}
}
} }
// received a request for a new SLI // received a request for a new SLI