Follow-up fix for r3681.

TESTS=trybots and vie_auto_test
BUG=1514

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3689 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2013-03-19 10:04:57 +00:00
parent ecfd32880e
commit 3d0b0d6902
9 changed files with 30 additions and 16 deletions

View File

@ -75,7 +75,8 @@ VCMGenericEncoder::SetChannelParameters(WebRtc_Word32 packetLoss, int rtt)
WebRtc_Word32 WebRtc_Word32
VCMGenericEncoder::SetRates(WebRtc_UWord32 newBitRate, WebRtc_UWord32 frameRate) VCMGenericEncoder::SetRates(WebRtc_UWord32 newBitRate, WebRtc_UWord32 frameRate)
{ {
WebRtc_Word32 ret = _encoder.SetRates(newBitRate, frameRate); uint32_t target_bitrate_kbps = (newBitRate + 500) / 1000;
WebRtc_Word32 ret = _encoder.SetRates(target_bitrate_kbps, frameRate);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;

View File

@ -176,13 +176,16 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 target_bitrate,
_targetBitRate = target_bitrate - protection_overhead_bps; _targetBitRate = target_bitrate - protection_overhead_bps;
// Update encoding rates following protection settings // Update encoding rates following protection settings
_frameDropper->SetRates(target_bitrate_kbps, _incomingFrameRate); float target_video_bitrate_kbps =
static_cast<float>(_targetBitRate) / 1000.0f;
_frameDropper->SetRates(target_video_bitrate_kbps, _incomingFrameRate);
if (_enableQm) if (_enableQm)
{ {
// Update QM with rates // Update QM with rates
_qmResolution->UpdateRates(target_bitrate_kbps, sent_video_rate_kbps, _qmResolution->UpdateRates(target_video_bitrate_kbps,
_incomingFrameRate, _fractionLost); sent_video_rate_kbps, _incomingFrameRate,
_fractionLost);
// Check for QM selection // Check for QM selection
bool selectQM = CheckStatusForQMchange(); bool selectQM = CheckStatusForQMchange();
if (selectQM) if (selectQM)

View File

@ -676,7 +676,6 @@ VideoCodingModuleImpl::AddVideoFrame(const I420VideoFrame& videoFrame,
const CodecSpecificInfo* codecSpecificInfo) const CodecSpecificInfo* codecSpecificInfo)
{ {
CriticalSectionScoped cs(_sendCritSect); CriticalSectionScoped cs(_sendCritSect);
if (_encoder == NULL) if (_encoder == NULL)
{ {
return VCM_UNINITIALIZED; return VCM_UNINITIALIZED;

View File

@ -317,7 +317,8 @@ GenericCodecTest::Perform(CmdArgs& args)
_frameCnt = 0; _frameCnt = 0;
totalBytes = 0; totalBytes = 0;
_encodeCompleteCallback->Initialize(); _encodeCompleteCallback->Initialize();
sendStats.SetTargetFrameRate(static_cast<WebRtc_UWord32>(_frameRate)); sendStats.set_framerate(static_cast<WebRtc_UWord32>(_frameRate));
sendStats.set_bitrate(1000 * _bitRate);
_vcm->RegisterSendStatisticsCallback(&sendStats); _vcm->RegisterSendStatisticsCallback(&sendStats);
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) == while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) ==
_lengthSourceFrame) _lengthSourceFrame)
@ -436,7 +437,8 @@ GenericCodecTest::Perform(CmdArgs& args)
// up to here // up to here
_vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 20); _vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 20);
_encodeCompleteCallback->Initialize(); _encodeCompleteCallback->Initialize();
sendStats.SetTargetFrameRate(static_cast<WebRtc_UWord32>(_frameRate)); sendStats.set_framerate(static_cast<WebRtc_UWord32>(_frameRate));
sendStats.set_bitrate(1000 * _bitRate);
_vcm->RegisterSendStatisticsCallback(&sendStats); _vcm->RegisterSendStatisticsCallback(&sendStats);
rewind(_sourceFile); rewind(_sourceFile);
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) == while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) ==

View File

@ -281,7 +281,8 @@ NormalTest::Perform(const CmdArgs& args)
_vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 0); _vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 0);
SendStatsTest sendStats; SendStatsTest sendStats;
sendStats.SetTargetFrameRate(static_cast<WebRtc_UWord32>(_frameRate)); sendStats.set_framerate(static_cast<WebRtc_UWord32>(_frameRate));
sendStats.set_bitrate(1000 * _bitRate);
_vcm->RegisterSendStatisticsCallback(&sendStats); _vcm->RegisterSendStatisticsCallback(&sendStats);
while (feof(_sourceFile) == 0) { while (feof(_sourceFile) == 0) {

View File

@ -242,7 +242,8 @@ QualityModesTest::Perform(const CmdArgs& args)
_vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 0); _vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 0);
SendStatsTest sendStats; SendStatsTest sendStats;
sendStats.SetTargetFrameRate(static_cast<WebRtc_UWord32>(_frameRate)); sendStats.set_framerate(static_cast<WebRtc_UWord32>(_frameRate));
sendStats.set_bitrate(1000 * _bitRate);
_vcm->RegisterSendStatisticsCallback(&sendStats); _vcm->RegisterSendStatisticsCallback(&sendStats);
VideoContentMetrics* contentMetrics = NULL; VideoContentMetrics* contentMetrics = NULL;

View File

@ -408,8 +408,8 @@ WebRtc_Word32
SendStatsTest::SendStatistics(const WebRtc_UWord32 bitRate, SendStatsTest::SendStatistics(const WebRtc_UWord32 bitRate,
const WebRtc_UWord32 frameRate) const WebRtc_UWord32 frameRate)
{ {
TEST(frameRate <= _frameRate); TEST(frameRate <= _framerate);
TEST(bitRate > 0 && bitRate < 100000); TEST(bitRate > _bitrate / 2 && bitRate < 3 * _bitrate / 2);
printf("VCM 1 sec: Bit rate: %u\tFrame rate: %u\n", bitRate, frameRate); printf("VCM 1 sec: Bit rate: %u\tFrame rate: %u\n", bitRate, frameRate);
return 0; return 0;
} }

View File

@ -223,12 +223,14 @@ public:
class SendStatsTest: public webrtc::VCMSendStatisticsCallback class SendStatsTest: public webrtc::VCMSendStatisticsCallback
{ {
public: public:
SendStatsTest() : _frameRate(15) {} SendStatsTest() : _framerate(15), _bitrate(500) {}
WebRtc_Word32 SendStatistics(const WebRtc_UWord32 bitRate, WebRtc_Word32 SendStatistics(const WebRtc_UWord32 bitRate,
const WebRtc_UWord32 frameRate); const WebRtc_UWord32 frameRate);
void SetTargetFrameRate(WebRtc_UWord32 frameRate) {_frameRate = frameRate;} void set_framerate(WebRtc_UWord32 frameRate) {_framerate = frameRate;}
void set_bitrate(uint32_t bitrate) {_bitrate = bitrate;}
private: private:
WebRtc_UWord32 _frameRate; WebRtc_UWord32 _framerate;
uint32_t _bitrate;
}; };
// Protection callback - allows the VCM (media optimization) to inform the RTP // Protection callback - allows the VCM (media optimization) to inform the RTP

View File

@ -306,11 +306,13 @@ WebRtc_Word32 ViEEncoder::DeRegisterExternalEncoder(WebRtc_UWord8 pl_type) {
webrtc::VideoCodec current_send_codec; webrtc::VideoCodec current_send_codec;
if (vcm_.SendCodec(&current_send_codec) == VCM_OK) { if (vcm_.SendCodec(&current_send_codec) == VCM_OK) {
if (vcm_.Bitrate(&current_send_codec.startBitrate) != 0) { uint32_t current_bitrate_bps = 0;
if (vcm_.Bitrate(&current_bitrate_bps) != 0) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo,
ViEId(engine_id_, channel_id_), ViEId(engine_id_, channel_id_),
"Failed to get the current encoder target bitrate."); "Failed to get the current encoder target bitrate.");
} }
current_send_codec.startBitrate = (current_bitrate_bps + 500) / 1000;
} }
if (vcm_.RegisterExternalEncoder(NULL, pl_type) != VCM_OK) { if (vcm_.RegisterExternalEncoder(NULL, pl_type) != VCM_OK) {
@ -681,11 +683,14 @@ WebRtc_Word32 ViEEncoder::UpdateProtectionMethod() {
webrtc::VideoCodec codec; webrtc::VideoCodec codec;
if (vcm_.SendCodec(&codec) == 0) { if (vcm_.SendCodec(&codec) == 0) {
WebRtc_UWord16 max_pay_load = default_rtp_rtcp_->MaxDataPayloadLength(); WebRtc_UWord16 max_pay_load = default_rtp_rtcp_->MaxDataPayloadLength();
if (vcm_.Bitrate(&codec.startBitrate) != 0) { uint32_t current_bitrate_bps = 0;
if (vcm_.Bitrate(&current_bitrate_bps) != 0) {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo,
ViEId(engine_id_, channel_id_), ViEId(engine_id_, channel_id_),
"Failed to get the current encoder target bitrate."); "Failed to get the current encoder target bitrate.");
} }
// Convert to start bitrate in kbps.
codec.startBitrate = (current_bitrate_bps + 500) / 1000;
if (vcm_.RegisterSendCodec(&codec, number_of_cores_, max_pay_load) != 0) { if (vcm_.RegisterSendCodec(&codec, number_of_cores_, max_pay_load) != 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
ViEId(engine_id_, channel_id_), ViEId(engine_id_, channel_id_),