This is a reland of commit 09f03be54804e81f626c26e8fde8c86cc952545f Use max_num_layers instead of encoder_config.number_of_streams when calculation stream resolutions in EncoderStreamFactory::GetStreamResolutions(). Original change's description: > Pass true stream resolutions to GetSimulcastConfig() > > Before this change GetSimulcastConfig() received only maximum resolution as an input parameter and derived resolutions for low quality simulcast streams assuming 1/2 scaling factor [1]. These days applications can configure resolution scaling factors via RtpEncodingParameters. If the configured resolution scaling factors were different from 1/2 then we got wrong bitrate limits from GetSimulcastConfig(). Now resolutions are calculated using scaling factor from RtpEncodingParameters (or default 1/2) for all streams in EncoderStreamFactory::CreateEncoderStreams() and then passed to GetSimulcastConfig(). > > Moved tests from simulcast_unittest.cc to encoder_stream_factory_unittest.cc. Mapping of old to new tests: > * GetConfigWithLimitedMaxLayersForResolution -> ReducesStreamCountWhenResolutionIsLow > * GetConfigWithLowResolutionScreenshare -> ReducesLegacyScreencastStreamCountWhenResolutionIsLow > * GetConfigWithNotLimitedMaxLayersForResolution -> KeepsStreamCountUnchangedWhenLegacyLimitIsDisabled > * GetConfigWithNormalizedResolution -> AdjustsResolutionWhenUnaligned > * GetConfigWithNormalizedResolutionDivisibleBy4 -> MakesResolutionDivisibleBy4 > * GetConfigWithNormalizedResolutionDivisibleBy8 -> not needed (MakesResolutionDivisibleBy4 should be enough). > * GetConfigForLegacyLayerLimit -> KeepsStreamCountUnchangedWhenResolutionIsHigh and ReducesStreamCountWhenResolutionIsLow > * GetConfigForLegacyLayerLimitWithRequiredHD -> KeepsStreamCountUnchangedWhenLegacyLimitIsDisabled > > [1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/video/config/simulcast.cc;l=297-298;drc=1b78a7eb3f418460da03672b1d1af1d9488bb544 > > Bug: webrtc:351644568, b/352504711 > Change-Id: I0028904ab0bb1e27b9c1b7cd3fb9a8ccf447fa35 > No-Try: true > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/357280 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#42651} Bug: webrtc:351644568, b/352504711 Change-Id: Ib3fd859257b61c2a5d695b8b8f45c95495117c0e No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/357520 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42654}
56 lines
1.9 KiB
C++
56 lines
1.9 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.
|
|
*/
|
|
|
|
#ifndef VIDEO_CONFIG_SIMULCAST_H_
|
|
#define VIDEO_CONFIG_SIMULCAST_H_
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "api/array_view.h"
|
|
#include "api/field_trials_view.h"
|
|
#include "api/units/data_rate.h"
|
|
#include "api/video/resolution.h"
|
|
#include "video/config/video_encoder_config.h"
|
|
|
|
namespace cricket {
|
|
|
|
// Gets the total maximum bitrate for the `streams`.
|
|
webrtc::DataRate GetTotalMaxBitrate(
|
|
const std::vector<webrtc::VideoStream>& streams);
|
|
|
|
// Adds any bitrate of `max_bitrate` that is above the total maximum bitrate for
|
|
// the `layers` to the highest quality layer.
|
|
void BoostMaxSimulcastLayer(webrtc::DataRate max_bitrate,
|
|
std::vector<webrtc::VideoStream>* layers);
|
|
|
|
// Returns number of simulcast streams. The value depends on the resolution and
|
|
// is restricted to the range from `min_num_layers` to `max_num_layers`,
|
|
// inclusive.
|
|
size_t LimitSimulcastLayerCount(size_t min_num_layers,
|
|
size_t max_num_layers,
|
|
int width,
|
|
int height,
|
|
const webrtc::FieldTrialsView& trials,
|
|
webrtc::VideoCodecType codec);
|
|
|
|
// Gets simulcast settings.
|
|
std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
|
rtc::ArrayView<const webrtc::Resolution> resolutions,
|
|
bool is_screenshare_with_conference_mode,
|
|
bool temporal_layers_supported,
|
|
const webrtc::FieldTrialsView& trials,
|
|
webrtc::VideoCodecType codec);
|
|
|
|
} // namespace cricket
|
|
|
|
#endif // VIDEO_CONFIG_SIMULCAST_H_
|