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

@ -88,7 +88,8 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder {
int32_t Release() override;
int32_t Encode(const VideoFrame& frame,
const std::vector<VideoFrameType>* frame_types) override;
void SetRates(const RateControlParameters& parameters) override;
int32_t SetRateAllocation(const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) override;
EncoderInfo GetEncoderInfo() const override;
private:
@ -121,8 +122,10 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder {
int32_t number_of_cores_;
size_t max_payload_size_;
// The last rate control settings, if set.
absl::optional<RateControlParameters> rate_control_parameters_;
// The last bitrate/framerate set, and a flag for noting they are set.
bool rates_set_;
VideoBitrateAllocation bitrate_allocation_;
uint32_t framerate_;
// The last channel parameters set, and a flag for noting they are set.
bool channel_parameters_set_;
@ -144,6 +147,8 @@ VideoEncoderSoftwareFallbackWrapper::VideoEncoderSoftwareFallbackWrapper(
std::unique_ptr<webrtc::VideoEncoder> hw_encoder)
: number_of_cores_(0),
max_payload_size_(0),
rates_set_(false),
framerate_(0),
channel_parameters_set_(false),
packet_loss_(0),
rtt_(0),
@ -176,8 +181,8 @@ bool VideoEncoderSoftwareFallbackWrapper::InitFallbackEncoder() {
// Replay callback, rates, and channel parameters.
if (callback_)
fallback_encoder_->RegisterEncodeCompleteCallback(callback_);
if (rate_control_parameters_)
fallback_encoder_->SetRates(*rate_control_parameters_);
if (rates_set_)
fallback_encoder_->SetRateAllocation(bitrate_allocation_, framerate_);
// Since we're switching to the fallback encoder, Release the real encoder. It
// may be re-initialized via InitEncode later, and it will continue to get
@ -196,7 +201,7 @@ int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode(
number_of_cores_ = number_of_cores;
max_payload_size_ = max_payload_size;
// Clear stored rate/channel parameters.
rate_control_parameters_ = absl::nullopt;
rates_set_ = false;
ValidateSettingsForForcedFallback();
// Try to reinit forced software codec if it is in use.
@ -259,12 +264,16 @@ int32_t VideoEncoderSoftwareFallbackWrapper::Encode(
return ret;
}
void VideoEncoderSoftwareFallbackWrapper::SetRates(
const RateControlParameters& parameters) {
rate_control_parameters_ = parameters;
encoder_->SetRates(parameters);
int32_t VideoEncoderSoftwareFallbackWrapper::SetRateAllocation(
const VideoBitrateAllocation& bitrate_allocation,
uint32_t framerate) {
rates_set_ = true;
bitrate_allocation_ = bitrate_allocation;
framerate_ = framerate;
int32_t ret = encoder_->SetRateAllocation(bitrate_allocation_, framerate);
if (use_fallback_encoder_)
fallback_encoder_->SetRates(parameters);
return fallback_encoder_->SetRateAllocation(bitrate_allocation_, framerate);
return ret;
}
VideoEncoder::EncoderInfo VideoEncoderSoftwareFallbackWrapper::GetEncoderInfo()