mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 22:00:47 +01:00
Add a SimulcastStream::GetScalabilityMode2 method that returns an optional.
A call to GetScalabilityMode was added for logging purpose and causes an expectation failure for tests using 4 temporal layers. Plan is to remove the old GetScalabilityMode and keep only the one that returns an optional. Change-Id: I0e37a496bb621d9754d6572ef5838b58193aa183 Bug: b/327381318 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/341520 Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@google.com> Cr-Commit-Position: refs/heads/main@{#41838}
This commit is contained in:
parent
b9ce3b79fc
commit
3afa1b2ce8
5 changed files with 47 additions and 18 deletions
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "api/video_codecs/simulcast_stream.h"
|
#include "api/video_codecs/simulcast_stream.h"
|
||||||
|
|
||||||
|
#include "absl/types/optional.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
@ -34,4 +35,17 @@ ScalabilityMode SimulcastStream::GetScalabilityMode() const {
|
||||||
return scalability_modes[numberOfTemporalLayers - 1];
|
return scalability_modes[numberOfTemporalLayers - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(b/327381318): Rename to GetScalabilityMode.
|
||||||
|
absl::optional<ScalabilityMode> SimulcastStream::GetScalabilityMode2() const {
|
||||||
|
static const ScalabilityMode scalability_modes[3] = {
|
||||||
|
ScalabilityMode::kL1T1,
|
||||||
|
ScalabilityMode::kL1T2,
|
||||||
|
ScalabilityMode::kL1T3,
|
||||||
|
};
|
||||||
|
if (numberOfTemporalLayers < 1 || numberOfTemporalLayers > 3) {
|
||||||
|
return absl::nullopt;
|
||||||
|
}
|
||||||
|
return scalability_modes[numberOfTemporalLayers - 1];
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#ifndef API_VIDEO_CODECS_SIMULCAST_STREAM_H_
|
#ifndef API_VIDEO_CODECS_SIMULCAST_STREAM_H_
|
||||||
#define API_VIDEO_CODECS_SIMULCAST_STREAM_H_
|
#define API_VIDEO_CODECS_SIMULCAST_STREAM_H_
|
||||||
|
|
||||||
|
#include "absl/types/optional.h"
|
||||||
#include "api/video_codecs/scalability_mode.h"
|
#include "api/video_codecs/scalability_mode.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
@ -22,6 +23,8 @@ struct SimulcastStream {
|
||||||
// setting to ScalabilityMode.
|
// setting to ScalabilityMode.
|
||||||
unsigned char GetNumberOfTemporalLayers() const;
|
unsigned char GetNumberOfTemporalLayers() const;
|
||||||
ScalabilityMode GetScalabilityMode() const;
|
ScalabilityMode GetScalabilityMode() const;
|
||||||
|
// TODO(b/327381318): Rename to GetScalabilityMode.
|
||||||
|
absl::optional<ScalabilityMode> GetScalabilityMode2() const;
|
||||||
void SetNumberOfTemporalLayers(unsigned char n);
|
void SetNumberOfTemporalLayers(unsigned char n);
|
||||||
|
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
|
|
@ -92,9 +92,13 @@ std::string VideoCodec::ToString() const {
|
||||||
ss << ", Simulcast: {";
|
ss << ", Simulcast: {";
|
||||||
for (size_t i = 0; i < numberOfSimulcastStreams; ++i) {
|
for (size_t i = 0; i < numberOfSimulcastStreams; ++i) {
|
||||||
const SimulcastStream stream = simulcastStream[i];
|
const SimulcastStream stream = simulcastStream[i];
|
||||||
ss << "[" << stream.width << "x" << stream.height << " "
|
absl::optional<ScalabilityMode> scalability_mode =
|
||||||
<< ScalabilityModeToString(stream.GetScalabilityMode())
|
stream.GetScalabilityMode2();
|
||||||
<< (stream.active ? ", active" : ", inactive") << "]";
|
if (scalability_mode.has_value()) {
|
||||||
|
ss << "[" << stream.width << "x" << stream.height << " "
|
||||||
|
<< ScalabilityModeToString(*scalability_mode)
|
||||||
|
<< (stream.active ? ", active" : ", inactive") << "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ss << "}";
|
ss << "}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "absl/algorithm/container.h"
|
#include "absl/algorithm/container.h"
|
||||||
|
#include "absl/types/optional.h"
|
||||||
#include "api/field_trials_view.h"
|
#include "api/field_trials_view.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "api/transport/field_trial_based_config.h"
|
#include "api/transport/field_trial_based_config.h"
|
||||||
|
@ -808,7 +809,8 @@ webrtc::VideoCodec SimulcastEncoderAdapter::MakeStreamCodec(
|
||||||
// By default, `scalability_mode` comes from SimulcastStream when
|
// By default, `scalability_mode` comes from SimulcastStream when
|
||||||
// SimulcastEncoderAdapter is used. This allows multiple encodings of L1Tx,
|
// SimulcastEncoderAdapter is used. This allows multiple encodings of L1Tx,
|
||||||
// but SimulcastStream currently does not support multiple spatial layers.
|
// but SimulcastStream currently does not support multiple spatial layers.
|
||||||
ScalabilityMode scalability_mode = stream_params.GetScalabilityMode();
|
absl::optional<ScalabilityMode> scalability_mode =
|
||||||
|
stream_params.GetScalabilityMode2();
|
||||||
// To support the full set of scalability modes in the event that this is the
|
// To support the full set of scalability modes in the event that this is the
|
||||||
// only active encoding, prefer VideoCodec::GetScalabilityMode() if all other
|
// only active encoding, prefer VideoCodec::GetScalabilityMode() if all other
|
||||||
// encodings are inactive.
|
// encodings are inactive.
|
||||||
|
@ -821,10 +823,12 @@ webrtc::VideoCodec SimulcastEncoderAdapter::MakeStreamCodec(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (only_active_stream) {
|
if (only_active_stream) {
|
||||||
scalability_mode = codec.GetScalabilityMode().value();
|
scalability_mode = codec.GetScalabilityMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codec_params.SetScalabilityMode(scalability_mode);
|
if (scalability_mode.has_value()) {
|
||||||
|
codec_params.SetScalabilityMode(*scalability_mode);
|
||||||
|
}
|
||||||
// Settings that are based on stream/resolution.
|
// Settings that are based on stream/resolution.
|
||||||
if (is_lowest_quality_stream) {
|
if (is_lowest_quality_stream) {
|
||||||
// Settings for lowest spatial resolutions.
|
// Settings for lowest spatial resolutions.
|
||||||
|
|
|
@ -1158,18 +1158,22 @@ void VideoStreamEncoder::ReconfigureEncoder() {
|
||||||
rtc::SimpleStringBuilder log_stream(log_stream_buf);
|
rtc::SimpleStringBuilder log_stream(log_stream_buf);
|
||||||
log_stream << "ReconfigureEncoder: simulcast streams: ";
|
log_stream << "ReconfigureEncoder: simulcast streams: ";
|
||||||
for (size_t i = 0; i < codec.numberOfSimulcastStreams; ++i) {
|
for (size_t i = 0; i < codec.numberOfSimulcastStreams; ++i) {
|
||||||
log_stream << "{" << i << ": " << codec.simulcastStream[i].width << "x"
|
absl::optional<ScalabilityMode> scalability_mode =
|
||||||
<< codec.simulcastStream[i].height << " "
|
codec.simulcastStream[i].GetScalabilityMode2();
|
||||||
<< ScalabilityModeToString(
|
if (scalability_mode) {
|
||||||
codec.simulcastStream[i].GetScalabilityMode())
|
log_stream << "{" << i << ": " << codec.simulcastStream[i].width << "x"
|
||||||
<< ", min_kbps: " << codec.simulcastStream[i].minBitrate
|
<< codec.simulcastStream[i].height << " "
|
||||||
<< ", target_kbps: " << codec.simulcastStream[i].targetBitrate
|
<< ScalabilityModeToString(*scalability_mode)
|
||||||
<< ", max_kbps: " << codec.simulcastStream[i].maxBitrate
|
<< ", min_kbps: " << codec.simulcastStream[i].minBitrate
|
||||||
<< ", max_fps: " << codec.simulcastStream[i].maxFramerate
|
<< ", target_kbps: " << codec.simulcastStream[i].targetBitrate
|
||||||
<< ", max_qp: " << codec.simulcastStream[i].qpMax << ", num_tl: "
|
<< ", max_kbps: " << codec.simulcastStream[i].maxBitrate
|
||||||
<< codec.simulcastStream[i].numberOfTemporalLayers
|
<< ", max_fps: " << codec.simulcastStream[i].maxFramerate
|
||||||
<< ", active: "
|
<< ", max_qp: " << codec.simulcastStream[i].qpMax
|
||||||
<< (codec.simulcastStream[i].active ? "true" : "false") << "}";
|
<< ", num_tl: "
|
||||||
|
<< codec.simulcastStream[i].numberOfTemporalLayers
|
||||||
|
<< ", active: "
|
||||||
|
<< (codec.simulcastStream[i].active ? "true" : "false") << "}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (encoder_config_.codec_type == kVideoCodecVP9 ||
|
if (encoder_config_.codec_type == kVideoCodecVP9 ||
|
||||||
encoder_config_.codec_type == kVideoCodecAV1) {
|
encoder_config_.codec_type == kVideoCodecAV1) {
|
||||||
|
|
Loading…
Reference in a new issue