webrtc_m130/video/config/video_encoder_config.cc
Henrik Boström e8c97c0d09 Reland "Rename requested_resolution to scale_resolution_down_to."
This is a reland of commit 82617ac51e7825db53451818f4d1ad52b69761fd

The reason for the revert was a downstream use of
`rtc::VideoSinkWants::requested_resolution`, so in this reland we don't
rename this field, it's fine just to rename the one in
RtpEncodingParameters for now.

Original change's description:
> Rename `requested_resolution` to `scale_resolution_down_to`.
>
> This is a pure refactor/rename CL without any changes in behavior.
>
> This field is called scaleResolutionDownTo in the spec and JavaScript.
> Let's make C++ match to avoid confusion.
>
> In order not to break downstream during the transition a variable with
> the old name being a pure reference to the renamed attribute is added.
> This means we have to add custom constructors, but we can change this
> back to "= default" when the transition is completed, which should only
> be a couple of CLs away.
>
> Bug: webrtc:375048799
> Change-Id: If755102ccd79d46020ce5b33acd3dfcc29799e47
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/366560
> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
> Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#43300}

NOTRY=True

Bug: webrtc:375048799
Change-Id: Ic4ee156c1d50aa36070a8d84059870791dcbbe5e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/366660
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43304}
2024-10-25 08:39:49 +00:00

159 lines
4.8 KiB
C++

/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "video/config/video_encoder_config.h"
#include <string>
#include "rtc_base/checks.h"
#include "rtc_base/strings/string_builder.h"
namespace webrtc {
VideoStream::VideoStream()
: width(0),
height(0),
max_framerate(-1),
min_bitrate_bps(-1),
target_bitrate_bps(-1),
max_bitrate_bps(-1),
scale_resolution_down_by(-1.),
max_qp(-1),
num_temporal_layers(std::nullopt),
active(true) {}
VideoStream::VideoStream(const VideoStream& other) = default;
VideoStream::~VideoStream() = default;
std::string VideoStream::ToString() const {
char buf[1024];
rtc::SimpleStringBuilder ss(buf);
ss << "{width: " << width;
ss << ", height: " << height;
ss << ", max_framerate: " << max_framerate;
ss << ", min_bitrate_bps:" << min_bitrate_bps;
ss << ", target_bitrate_bps:" << target_bitrate_bps;
ss << ", max_bitrate_bps:" << max_bitrate_bps;
ss << ", max_qp: " << max_qp;
ss << ", num_temporal_layers: " << num_temporal_layers.value_or(1);
ss << ", bitrate_priority: " << bitrate_priority.value_or(0);
ss << ", active: " << active;
ss << ", scale_down_by: " << scale_resolution_down_by;
return ss.str();
}
VideoEncoderConfig::VideoEncoderConfig()
: codec_type(kVideoCodecGeneric),
video_format("Unset"),
content_type(ContentType::kRealtimeVideo),
frame_drop_enabled(false),
encoder_specific_settings(nullptr),
min_transmit_bitrate_bps(0),
max_bitrate_bps(0),
bitrate_priority(1.0),
number_of_streams(0),
legacy_conference_mode(false),
is_quality_scaling_allowed(false),
max_qp(-1) {}
VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default;
VideoEncoderConfig::~VideoEncoderConfig() = default;
std::string VideoEncoderConfig::ToString() const {
char buf[1024];
rtc::SimpleStringBuilder ss(buf);
ss << "{codec_type: " << CodecTypeToPayloadString(codec_type);
ss << ", content_type: ";
switch (content_type) {
case ContentType::kRealtimeVideo:
ss << "kRealtimeVideo";
break;
case ContentType::kScreen:
ss << "kScreenshare";
break;
}
ss << ", frame_drop_enabled: " << frame_drop_enabled;
ss << ", encoder_specific_settings: ";
ss << (encoder_specific_settings != nullptr ? "(ptr)" : "NULL");
ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps;
ss << '}';
return ss.str();
}
bool VideoEncoderConfig::HasScaleResolutionDownTo() const {
for (const VideoStream& simulcast_layer : simulcast_layers) {
if (simulcast_layer.scale_resolution_down_to.has_value()) {
return true;
}
}
return false;
}
VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default;
void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
VideoCodec* codec) const {
if (codec->codecType == kVideoCodecVP8) {
FillVideoCodecVp8(codec->VP8());
} else if (codec->codecType == kVideoCodecVP9) {
FillVideoCodecVp9(codec->VP9());
} else if (codec->codecType == kVideoCodecAV1) {
FillVideoCodecAv1(codec->AV1());
} else {
RTC_DCHECK_NOTREACHED()
<< "Encoder specifics set/used for unknown codec type.";
}
}
void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
VideoCodecVP8* vp8_settings) const {
RTC_DCHECK_NOTREACHED();
}
void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9(
VideoCodecVP9* vp9_settings) const {
RTC_DCHECK_NOTREACHED();
}
void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecAv1(
VideoCodecAV1* av1_settings) const {
RTC_DCHECK_NOTREACHED();
}
VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings(
const VideoCodecVP8& specifics)
: specifics_(specifics) {}
void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8(
VideoCodecVP8* vp8_settings) const {
*vp8_settings = specifics_;
}
VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings(
const VideoCodecVP9& specifics)
: specifics_(specifics) {}
void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9(
VideoCodecVP9* vp9_settings) const {
*vp9_settings = specifics_;
}
VideoEncoderConfig::Av1EncoderSpecificSettings::Av1EncoderSpecificSettings(
const VideoCodecAV1& specifics)
: specifics_(specifics) {}
void VideoEncoderConfig::Av1EncoderSpecificSettings::FillVideoCodecAv1(
VideoCodecAV1* av1_settings) const {
*av1_settings = specifics_;
}
} // namespace webrtc