Revert "Replace usage of old SetRates/SetRateAllocation methods"

This reverts commit 7ac0d5f348f0b956089c4ed65c46e65bac125508.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Replace usage of old SetRates/SetRateAllocation methods
> 
> This rather large CL replaces all relevant usage of the old
> VideoEncoder::SetRates()/SetRateAllocation() methods in WebRTC.
> API is unchanged to allow downstream projects to update without
> breakage.
> 
> Bug: webrtc:10481
> Change-Id: Iab8f292ce6be6c3f5056a239d26361962b14bb38
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131949
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Per Kjellander <perkj@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#27554}

TBR=brandtr@webrtc.org,sakal@webrtc.org,nisse@webrtc.org,sprang@webrtc.org,perkj@webrtc.org

Change-Id: I576760b584e3f258013b0279c0c173c895bbb37e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10481
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132561
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27559}
This commit is contained in:
Minyue Li
2019-04-11 10:50:19 +00:00
committed by Commit Bot
parent 7061e51b48
commit 7ddef1af88
41 changed files with 389 additions and 430 deletions

View File

@ -300,8 +300,10 @@ void VideoProcessor::SetRates(size_t bitrate_kbps, size_t framerate_fps) {
framerate_fps_ = static_cast<uint32_t>(framerate_fps);
bitrate_allocation_ = bitrate_allocator_->GetAllocation(
static_cast<uint32_t>(bitrate_kbps * 1000), framerate_fps_);
encoder_->SetRates(VideoEncoder::RateControlParameters(
bitrate_allocation_, static_cast<double>(framerate_fps_)));
const int set_rates_result =
encoder_->SetRateAllocation(bitrate_allocation_, framerate_fps_);
RTC_DCHECK_GE(set_rates_result, 0)
<< "Failed to update encoder with new rate " << bitrate_kbps << ".";
}
int32_t VideoProcessor::VideoProcessorDecodeCompleteCallback::Decoded(

View File

@ -25,10 +25,7 @@
#include "test/testsupport/mock/mock_frame_reader.h"
using ::testing::_;
using ::testing::AllOf;
using ::testing::Field;
using ::testing::Property;
using ::testing::ResultOf;
using ::testing::Return;
namespace webrtc {
@ -99,11 +96,9 @@ TEST_F(VideoProcessorTest, InitRelease) {
TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) {
const int kBitrateKbps = 456;
const int kFramerateFps = 31;
EXPECT_CALL(
encoder_mock_,
SetRates(Field(&VideoEncoder::RateControlParameters::framerate_fps,
static_cast<double>(kFramerateFps))))
.Times(1);
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kFramerateFps))
.Times(1)
.WillOnce(Return(0));
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); });
EXPECT_CALL(frame_reader_mock_, ReadFrame())
@ -127,11 +122,9 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
const int kBitrateKbps = 456;
const int kStartFramerateFps = 27;
const int kStartTimestamp = 90000 / kStartFramerateFps;
EXPECT_CALL(
encoder_mock_,
SetRates(Field(&VideoEncoder::RateControlParameters::framerate_fps,
static_cast<double>(kStartFramerateFps))))
.Times(1);
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kStartFramerateFps))
.Times(1)
.WillOnce(Return(0));
q_.SendTask(
[=] { video_processor_->SetRates(kBitrateKbps, kStartFramerateFps); });
@ -143,11 +136,9 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
q_.SendTask([this] { video_processor_->ProcessFrame(); });
const int kNewFramerateFps = 13;
EXPECT_CALL(
encoder_mock_,
SetRates(Field(&VideoEncoder::RateControlParameters::framerate_fps,
static_cast<double>(kNewFramerateFps))))
.Times(1);
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kNewFramerateFps))
.Times(1)
.WillOnce(Return(0));
q_.SendTask(
[=] { video_processor_->SetRates(kBitrateKbps, kNewFramerateFps); });
@ -162,32 +153,21 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
}
TEST_F(VideoProcessorTest, SetRates) {
const uint32_t kBitrateKbps = 123;
const int kBitrateKbps = 123;
const int kFramerateFps = 17;
EXPECT_CALL(
encoder_mock_,
SetRates(AllOf(ResultOf(
[](const VideoEncoder::RateControlParameters& params) {
return params.bitrate.get_sum_kbps();
},
kBitrateKbps),
Field(&VideoEncoder::RateControlParameters::framerate_fps,
static_cast<double>(kFramerateFps)))))
EXPECT_CALL(encoder_mock_,
SetRateAllocation(
Property(&VideoBitrateAllocation::get_sum_kbps, kBitrateKbps),
kFramerateFps))
.Times(1);
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); });
const uint32_t kNewBitrateKbps = 456;
const int kNewBitrateKbps = 456;
const int kNewFramerateFps = 34;
EXPECT_CALL(
encoder_mock_,
SetRates(AllOf(ResultOf(
[](const VideoEncoder::RateControlParameters& params) {
return params.bitrate.get_sum_kbps();
},
kNewBitrateKbps),
Field(&VideoEncoder::RateControlParameters::framerate_fps,
static_cast<double>(kNewFramerateFps)))))
EXPECT_CALL(encoder_mock_,
SetRateAllocation(Property(&VideoBitrateAllocation::get_sum_kbps,
kNewBitrateKbps),
kNewFramerateFps))
.Times(1);
q_.SendTask(
[=] { video_processor_->SetRates(kNewBitrateKbps, kNewFramerateFps); });