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:
parent
ecfd32880e
commit
3d0b0d6902
@ -75,7 +75,8 @@ VCMGenericEncoder::SetChannelParameters(WebRtc_Word32 packetLoss, int rtt)
|
||||
WebRtc_Word32
|
||||
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)
|
||||
{
|
||||
return ret;
|
||||
|
@ -176,13 +176,16 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 target_bitrate,
|
||||
_targetBitRate = target_bitrate - protection_overhead_bps;
|
||||
|
||||
// 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)
|
||||
{
|
||||
// Update QM with rates
|
||||
_qmResolution->UpdateRates(target_bitrate_kbps, sent_video_rate_kbps,
|
||||
_incomingFrameRate, _fractionLost);
|
||||
_qmResolution->UpdateRates(target_video_bitrate_kbps,
|
||||
sent_video_rate_kbps, _incomingFrameRate,
|
||||
_fractionLost);
|
||||
// Check for QM selection
|
||||
bool selectQM = CheckStatusForQMchange();
|
||||
if (selectQM)
|
||||
|
@ -676,7 +676,6 @@ VideoCodingModuleImpl::AddVideoFrame(const I420VideoFrame& videoFrame,
|
||||
const CodecSpecificInfo* codecSpecificInfo)
|
||||
{
|
||||
CriticalSectionScoped cs(_sendCritSect);
|
||||
|
||||
if (_encoder == NULL)
|
||||
{
|
||||
return VCM_UNINITIALIZED;
|
||||
|
@ -317,7 +317,8 @@ GenericCodecTest::Perform(CmdArgs& args)
|
||||
_frameCnt = 0;
|
||||
totalBytes = 0;
|
||||
_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);
|
||||
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) ==
|
||||
_lengthSourceFrame)
|
||||
@ -436,7 +437,8 @@ GenericCodecTest::Perform(CmdArgs& args)
|
||||
// up to here
|
||||
_vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 20);
|
||||
_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);
|
||||
rewind(_sourceFile);
|
||||
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) ==
|
||||
|
@ -281,7 +281,8 @@ NormalTest::Perform(const CmdArgs& args)
|
||||
_vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 0);
|
||||
|
||||
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);
|
||||
|
||||
while (feof(_sourceFile) == 0) {
|
||||
|
@ -242,7 +242,8 @@ QualityModesTest::Perform(const CmdArgs& args)
|
||||
_vcm->SetChannelParameters(static_cast<uint32_t>(1000 * _bitRate), 0, 0);
|
||||
|
||||
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);
|
||||
|
||||
VideoContentMetrics* contentMetrics = NULL;
|
||||
|
@ -408,8 +408,8 @@ WebRtc_Word32
|
||||
SendStatsTest::SendStatistics(const WebRtc_UWord32 bitRate,
|
||||
const WebRtc_UWord32 frameRate)
|
||||
{
|
||||
TEST(frameRate <= _frameRate);
|
||||
TEST(bitRate > 0 && bitRate < 100000);
|
||||
TEST(frameRate <= _framerate);
|
||||
TEST(bitRate > _bitrate / 2 && bitRate < 3 * _bitrate / 2);
|
||||
printf("VCM 1 sec: Bit rate: %u\tFrame rate: %u\n", bitRate, frameRate);
|
||||
return 0;
|
||||
}
|
||||
|
@ -223,12 +223,14 @@ public:
|
||||
class SendStatsTest: public webrtc::VCMSendStatisticsCallback
|
||||
{
|
||||
public:
|
||||
SendStatsTest() : _frameRate(15) {}
|
||||
SendStatsTest() : _framerate(15), _bitrate(500) {}
|
||||
WebRtc_Word32 SendStatistics(const WebRtc_UWord32 bitRate,
|
||||
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:
|
||||
WebRtc_UWord32 _frameRate;
|
||||
WebRtc_UWord32 _framerate;
|
||||
uint32_t _bitrate;
|
||||
};
|
||||
|
||||
// Protection callback - allows the VCM (media optimization) to inform the RTP
|
||||
|
@ -306,11 +306,13 @@ WebRtc_Word32 ViEEncoder::DeRegisterExternalEncoder(WebRtc_UWord8 pl_type) {
|
||||
|
||||
webrtc::VideoCodec current_send_codec;
|
||||
if (vcm_.SendCodec(¤t_send_codec) == VCM_OK) {
|
||||
if (vcm_.Bitrate(¤t_send_codec.startBitrate) != 0) {
|
||||
uint32_t current_bitrate_bps = 0;
|
||||
if (vcm_.Bitrate(¤t_bitrate_bps) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"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) {
|
||||
@ -681,11 +683,14 @@ WebRtc_Word32 ViEEncoder::UpdateProtectionMethod() {
|
||||
webrtc::VideoCodec codec;
|
||||
if (vcm_.SendCodec(&codec) == 0) {
|
||||
WebRtc_UWord16 max_pay_load = default_rtp_rtcp_->MaxDataPayloadLength();
|
||||
if (vcm_.Bitrate(&codec.startBitrate) != 0) {
|
||||
uint32_t current_bitrate_bps = 0;
|
||||
if (vcm_.Bitrate(¤t_bitrate_bps) != 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
"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) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
||||
ViEId(engine_id_, channel_id_),
|
||||
|
Loading…
x
Reference in New Issue
Block a user