mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Make video scalability mode configurable from peerconnection level.
This CL does not aim at cleaning up simulcast/SVC configuration, just to make it possible to set the scalability mode for AV1. Implementing a codec agnostic SVC/simulcast API is a (big) project on its own. Change-Id: Ia88df31eb1111713e5f8832e95c8db44f92887ca BUG: webrtc:11607 Change-Id: Ia88df31eb1111713e5f8832e95c8db44f92887ca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192541 Reviewed-by: Florent Castelli <orphis@webrtc.org> Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32631}
This commit is contained in:
parent
a9961b3839
commit
87e99095a7
5 changed files with 27 additions and 3 deletions
|
@ -465,6 +465,9 @@ struct RTC_EXPORT RtpEncodingParameters {
|
|||
// For video, scale the resolution down by this factor.
|
||||
absl::optional<double> scale_resolution_down_by;
|
||||
|
||||
// https://w3c.github.io/webrtc-svc/#rtcrtpencodingparameters
|
||||
absl::optional<std::string> scalability_mode;
|
||||
|
||||
// For an RtpSender, set to true to cause this encoding to be encoded and
|
||||
// sent, and false for it not to be encoded and sent. This allows control
|
||||
// across multiple encodings of a sender for turning simulcast layers on and
|
||||
|
|
|
@ -64,6 +64,8 @@ struct VideoStream {
|
|||
// between multiple streams.
|
||||
absl::optional<double> bitrate_priority;
|
||||
|
||||
absl::optional<std::string> scalability_mode;
|
||||
|
||||
// If this stream is enabled by the user, or not.
|
||||
bool active;
|
||||
};
|
||||
|
|
|
@ -2261,9 +2261,11 @@ webrtc::RTCError WebRtcVideoChannel::WebRtcVideoSendStream::SetRtpParameters(
|
|||
// TODO(bugs.webrtc.org/8807): The bitrate priority really doesn't require an
|
||||
// entire encoder reconfiguration, it just needs to update the bitrate
|
||||
// allocator.
|
||||
bool reconfigure_encoder =
|
||||
new_param || (new_parameters.encodings[0].bitrate_priority !=
|
||||
rtp_parameters_.encodings[0].bitrate_priority);
|
||||
bool reconfigure_encoder = new_param ||
|
||||
(new_parameters.encodings[0].bitrate_priority !=
|
||||
rtp_parameters_.encodings[0].bitrate_priority) ||
|
||||
new_parameters.encodings[0].scalability_mode !=
|
||||
rtp_parameters_.encodings[0].scalability_mode;
|
||||
|
||||
// TODO(bugs.webrtc.org/8807): The active field as well should not require
|
||||
// a full encoder reconfiguration, but it needs to update both the bitrate
|
||||
|
@ -2422,6 +2424,8 @@ WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig(
|
|||
for (size_t i = 0; i < encoder_config.simulcast_layers.size(); ++i) {
|
||||
encoder_config.simulcast_layers[i].active =
|
||||
rtp_parameters_.encodings[i].active;
|
||||
encoder_config.simulcast_layers[i].scalability_mode =
|
||||
rtp_parameters_.encodings[i].scalability_mode;
|
||||
if (rtp_parameters_.encodings[i].min_bitrate_bps) {
|
||||
encoder_config.simulcast_layers[i].min_bitrate_bps =
|
||||
*rtp_parameters_.encodings[i].min_bitrate_bps;
|
||||
|
|
|
@ -94,6 +94,7 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
|
|||
|
||||
int max_framerate = 0;
|
||||
|
||||
absl::optional<std::string> scalability_mode = streams[0].scalability_mode;
|
||||
for (size_t i = 0; i < streams.size(); ++i) {
|
||||
SpatialLayer* sim_stream = &video_codec.simulcastStream[i];
|
||||
RTC_DCHECK_GT(streams[i].width, 0);
|
||||
|
@ -126,6 +127,15 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
|
|||
video_codec.qpMax = std::max(video_codec.qpMax,
|
||||
static_cast<unsigned int>(streams[i].max_qp));
|
||||
max_framerate = std::max(max_framerate, streams[i].max_framerate);
|
||||
|
||||
if (streams[0].scalability_mode != streams[i].scalability_mode) {
|
||||
RTC_LOG(LS_WARNING) << "Inconsistent scalability modes configured.";
|
||||
scalability_mode.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (scalability_mode.has_value()) {
|
||||
video_codec.SetScalabilityMode(*scalability_mode);
|
||||
}
|
||||
|
||||
if (video_codec.maxBitrate == 0) {
|
||||
|
|
|
@ -149,6 +149,11 @@ bool RequiresEncoderReset(const VideoCodec& prev_send_codec,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (new_send_codec.ScalabilityMode() != prev_send_codec.ScalabilityMode()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue