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}
This commit is contained in:
@ -300,10 +300,8 @@ 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_);
|
||||
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 << ".";
|
||||
encoder_->SetRates(VideoEncoder::RateControlParameters(
|
||||
bitrate_allocation_, static_cast<double>(framerate_fps_)));
|
||||
}
|
||||
|
||||
int32_t VideoProcessor::VideoProcessorDecodeCompleteCallback::Decoded(
|
||||
|
||||
@ -25,7 +25,10 @@
|
||||
#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 {
|
||||
@ -96,9 +99,11 @@ TEST_F(VideoProcessorTest, InitRelease) {
|
||||
TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) {
|
||||
const int kBitrateKbps = 456;
|
||||
const int kFramerateFps = 31;
|
||||
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kFramerateFps))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
EXPECT_CALL(
|
||||
encoder_mock_,
|
||||
SetRates(Field(&VideoEncoder::RateControlParameters::framerate_fps,
|
||||
static_cast<double>(kFramerateFps))))
|
||||
.Times(1);
|
||||
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); });
|
||||
|
||||
EXPECT_CALL(frame_reader_mock_, ReadFrame())
|
||||
@ -122,9 +127,11 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
|
||||
const int kBitrateKbps = 456;
|
||||
const int kStartFramerateFps = 27;
|
||||
const int kStartTimestamp = 90000 / kStartFramerateFps;
|
||||
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kStartFramerateFps))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
EXPECT_CALL(
|
||||
encoder_mock_,
|
||||
SetRates(Field(&VideoEncoder::RateControlParameters::framerate_fps,
|
||||
static_cast<double>(kStartFramerateFps))))
|
||||
.Times(1);
|
||||
q_.SendTask(
|
||||
[=] { video_processor_->SetRates(kBitrateKbps, kStartFramerateFps); });
|
||||
|
||||
@ -136,9 +143,11 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
|
||||
q_.SendTask([this] { video_processor_->ProcessFrame(); });
|
||||
|
||||
const int kNewFramerateFps = 13;
|
||||
EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kNewFramerateFps))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
EXPECT_CALL(
|
||||
encoder_mock_,
|
||||
SetRates(Field(&VideoEncoder::RateControlParameters::framerate_fps,
|
||||
static_cast<double>(kNewFramerateFps))))
|
||||
.Times(1);
|
||||
q_.SendTask(
|
||||
[=] { video_processor_->SetRates(kBitrateKbps, kNewFramerateFps); });
|
||||
|
||||
@ -153,21 +162,32 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) {
|
||||
}
|
||||
|
||||
TEST_F(VideoProcessorTest, SetRates) {
|
||||
const int kBitrateKbps = 123;
|
||||
const uint32_t kBitrateKbps = 123;
|
||||
const int kFramerateFps = 17;
|
||||
EXPECT_CALL(encoder_mock_,
|
||||
SetRateAllocation(
|
||||
Property(&VideoBitrateAllocation::get_sum_kbps, kBitrateKbps),
|
||||
kFramerateFps))
|
||||
|
||||
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)))))
|
||||
.Times(1);
|
||||
q_.SendTask([=] { video_processor_->SetRates(kBitrateKbps, kFramerateFps); });
|
||||
|
||||
const int kNewBitrateKbps = 456;
|
||||
const uint32_t kNewBitrateKbps = 456;
|
||||
const int kNewFramerateFps = 34;
|
||||
EXPECT_CALL(encoder_mock_,
|
||||
SetRateAllocation(Property(&VideoBitrateAllocation::get_sum_kbps,
|
||||
kNewBitrateKbps),
|
||||
kNewFramerateFps))
|
||||
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)))))
|
||||
.Times(1);
|
||||
q_.SendTask(
|
||||
[=] { video_processor_->SetRates(kNewBitrateKbps, kNewFramerateFps); });
|
||||
|
||||
Reference in New Issue
Block a user