Reland "Replace usage of old SetRates/SetRateAllocation methods"

This is a reland of 7ac0d5f348f0b956089c4ed65c46e65bac125508

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,perkj@webrtc.org

Bug: webrtc:10481
Change-Id: I2978d5c527a18e885b7845c4e53a2424e8ad5b4b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132551
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27593}
This commit is contained in:
Erik Språng
2019-04-12 13:59:09 +02:00
committed by Commit Bot
parent 70f80e5962
commit 16cb8f5d74
41 changed files with 430 additions and 389 deletions

View File

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