Wire up pading.

Review URL: https://webrtc-codereview.appspot.com/509002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2094 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pwestin@webrtc.org
2012-04-23 14:52:15 +00:00
parent 11654c2344
commit ddab60be56
2 changed files with 33 additions and 10 deletions

View File

@ -516,12 +516,34 @@ RTPSender::SendOutgoingData(const FrameType frameType,
return _audio->SendAudio(frameType, payloadType, captureTimeStamp, payloadData, payloadSize,fragmentation); return _audio->SendAudio(frameType, payloadType, captureTimeStamp, payloadData, payloadSize,fragmentation);
} else } else
{ {
// assert audio frameTypes // Assert on audio frameTypes.
assert(frameType == kVideoFrameKey || assert(frameType != kAudioFrameSpeech &&
frameType == kVideoFrameDelta || frameType != kAudioFrameCN);
frameType == kVideoFrameGolden ||
frameType == kVideoFrameAltRef);
// If the encoder generate an empty frame send pading.
if (frameType == kFrameEmpty) {
// Current bitrate since last estimate(1 second) averaged with the
// estimate since then, to get the most up to date bitrate.
uint32_t current_bitrate = BitrateNow();
int bitrate_diff = _targetSendBitrate * 1000 - current_bitrate;
if (bitrate_diff > 0) {
int bytes = 0;
if (current_bitrate == 0) {
// Start up phase. Send one 33.3 ms batch to start with.
bytes = (bitrate_diff / 8) / 30;
} else {
bytes = (bitrate_diff / 8);
// Cap at 200 ms of target send data.
int bytes_cap = _targetSendBitrate * 25; // 1000 / 8 / 5
if (bytes_cap > bytes) {
bytes = bytes_cap;
}
}
// Send pading data.
return SendPadData(payloadType, captureTimeStamp, bytes);
}
return 0;
}
return _video->SendVideo(videoType, return _video->SendVideo(videoType,
frameType, frameType,
payloadType, payloadType,
@ -818,9 +840,8 @@ void RTPSender::UpdateNACKBitRate(const WebRtc_UWord32 bytes,
} }
} }
// Function triggered by timer.
void RTPSender::ProcessSendToNetwork() { void RTPSender::ProcessSendToNetwork() {
// triggered by timer
WebRtc_UWord32 delta_time_ms; WebRtc_UWord32 delta_time_ms;
{ {
CriticalSectionScoped cs(_sendCritsect); CriticalSectionScoped cs(_sendCritsect);
@ -828,12 +849,10 @@ void RTPSender::ProcessSendToNetwork() {
if (!_transmissionSmoothing) { if (!_transmissionSmoothing) {
return; return;
} }
WebRtc_UWord32 now = _clock.GetTimeInMS(); WebRtc_UWord32 now = _clock.GetTimeInMS();
delta_time_ms = now - _timeLastSendToNetworkUpdate; delta_time_ms = now - _timeLastSendToNetworkUpdate;
_timeLastSendToNetworkUpdate = now; _timeLastSendToNetworkUpdate = now;
} }
_sendBucket.UpdateBytesPerInterval(delta_time_ms, _targetSendBitrate); _sendBucket.UpdateBytesPerInterval(delta_time_ms, _targetSendBitrate);
while (!_sendBucket.Empty()) { while (!_sendBucket.Empty()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
* *
* Use of this source code is governed by a BSD-style license * Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source * that can be found in the LICENSE file in the root of the source
@ -216,6 +216,10 @@ webrtc::FrameType VCMEncodedFrame::ConvertFrameType(VideoFrameType frameType)
{ {
return kVideoFrameAltRef; return kVideoFrameAltRef;
} }
case kSkipFrame:
{
return kFrameEmpty;
}
default: default:
{ {
return kVideoFrameDelta; return kVideoFrameDelta;