Move setting of encoder bitrate allocation callback type to VideoSendStream
It turned out that the negotiated rtp header extensions are not fully known in WebRtcVideoChannel::AddSendStream. The cl also remove the unnecessary factory for creating VideoStreamEncoder. Bug: webrtc:12000 Change-Id: If994c8deb69f3ce4212896d3ad757dac94c6e09f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/198840 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32916}
This commit is contained in:
parent
c96601e20c
commit
b03b6c8a94
@ -299,24 +299,6 @@ rtc_source_set("video_frame_metadata") {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("video_stream_encoder_create") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"video_stream_encoder_create.cc",
|
||||
"video_stream_encoder_create.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":video_frame",
|
||||
":video_stream_encoder",
|
||||
"../../api:scoped_refptr",
|
||||
"../../video:video_stream_encoder_impl",
|
||||
"../../video/adaptation:video_adaptation",
|
||||
"../task_queue",
|
||||
"../video_codecs:video_codecs_api",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("builtin_video_bitrate_allocator_factory") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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 "api/video/video_stream_encoder_create.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "video/adaptation/overuse_frame_detector.h"
|
||||
#include "video/video_stream_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
std::unique_ptr<VideoStreamEncoderInterface> CreateVideoStreamEncoder(
|
||||
Clock* clock,
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
uint32_t number_of_cores,
|
||||
VideoStreamEncoderObserver* encoder_stats_observer,
|
||||
const VideoStreamEncoderSettings& settings) {
|
||||
return std::make_unique<VideoStreamEncoder>(
|
||||
clock, number_of_cores, encoder_stats_observer, settings,
|
||||
std::make_unique<OveruseFrameDetector>(encoder_stats_observer),
|
||||
task_queue_factory);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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 API_VIDEO_VIDEO_STREAM_ENCODER_CREATE_H_
|
||||
#define API_VIDEO_VIDEO_STREAM_ENCODER_CREATE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video/video_sink_interface.h"
|
||||
#include "api/video/video_stream_encoder_interface.h"
|
||||
#include "api/video/video_stream_encoder_observer.h"
|
||||
#include "api/video/video_stream_encoder_settings.h"
|
||||
|
||||
namespace webrtc {
|
||||
// TODO(srte): Find a way to avoid this forward declaration.
|
||||
class Clock;
|
||||
|
||||
std::unique_ptr<VideoStreamEncoderInterface> CreateVideoStreamEncoder(
|
||||
Clock* clock,
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
uint32_t number_of_cores,
|
||||
VideoStreamEncoderObserver* encoder_stats_observer,
|
||||
const VideoStreamEncoderSettings& settings);
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_VIDEO_VIDEO_STREAM_ENCODER_CREATE_H_
|
||||
@ -39,12 +39,6 @@ class EncoderSwitchRequestCallback {
|
||||
};
|
||||
|
||||
struct VideoStreamEncoderSettings {
|
||||
enum class BitrateAllocationCallbackType {
|
||||
kVideoBitrateAllocation,
|
||||
kVideoBitrateAllocationWhenScreenSharing,
|
||||
kVideoLayersAllocation
|
||||
};
|
||||
|
||||
explicit VideoStreamEncoderSettings(
|
||||
const VideoEncoder::Capabilities& capabilities)
|
||||
: capabilities(capabilities) {}
|
||||
@ -65,11 +59,6 @@ struct VideoStreamEncoderSettings {
|
||||
// Negotiated capabilities which the VideoEncoder may expect the other
|
||||
// side to use.
|
||||
VideoEncoder::Capabilities capabilities;
|
||||
|
||||
// TODO(bugs.webrtc.org/12000): Reporting of VideoBitrateAllocation is beeing
|
||||
// deprecated. Instead VideoLayersAllocation should be reported.
|
||||
BitrateAllocationCallbackType allocation_cb_type =
|
||||
BitrateAllocationCallbackType::kVideoBitrateAllocationWhenScreenSharing;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -1349,21 +1349,6 @@ bool WebRtcVideoChannel::AddSendStream(const StreamParams& sp) {
|
||||
video_config_.periodic_alr_bandwidth_probing;
|
||||
config.encoder_settings.experiment_cpu_load_estimator =
|
||||
video_config_.experiment_cpu_load_estimator;
|
||||
using TargetBitrateType =
|
||||
webrtc::VideoStreamEncoderSettings::BitrateAllocationCallbackType;
|
||||
if (send_rtp_extensions_ &&
|
||||
webrtc::RtpExtension::FindHeaderExtensionByUri(
|
||||
*send_rtp_extensions_,
|
||||
webrtc::RtpExtension::kVideoLayersAllocationUri)) {
|
||||
config.encoder_settings.allocation_cb_type =
|
||||
TargetBitrateType::kVideoLayersAllocation;
|
||||
} else if (IsEnabled(call_->trials(), "WebRTC-Target-Bitrate-Rtcp")) {
|
||||
config.encoder_settings.allocation_cb_type =
|
||||
TargetBitrateType::kVideoBitrateAllocation;
|
||||
} else {
|
||||
config.encoder_settings.allocation_cb_type =
|
||||
TargetBitrateType::kVideoBitrateAllocationWhenScreenSharing;
|
||||
}
|
||||
config.encoder_settings.encoder_factory = encoder_factory_;
|
||||
config.encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_;
|
||||
|
||||
@ -68,6 +68,7 @@ rtc_library("video") {
|
||||
|
||||
deps = [
|
||||
":frame_dumping_decoder",
|
||||
":video_stream_encoder_impl",
|
||||
"../api:array_view",
|
||||
"../api:fec_controller_api",
|
||||
"../api:frame_transformer_interface",
|
||||
@ -88,7 +89,6 @@ rtc_library("video") {
|
||||
"../api/video:video_frame",
|
||||
"../api/video:video_rtp_headers",
|
||||
"../api/video:video_stream_encoder",
|
||||
"../api/video:video_stream_encoder_create",
|
||||
"../api/video_codecs:video_codecs_api",
|
||||
"../call:bitrate_allocator",
|
||||
"../call:call_interfaces",
|
||||
@ -138,6 +138,7 @@ rtc_library("video") {
|
||||
"../system_wrappers",
|
||||
"../system_wrappers:field_trial",
|
||||
"../system_wrappers:metrics",
|
||||
"./adaptation:video_adaptation",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
|
||||
@ -62,13 +62,11 @@ class RtcpXrObserver : public test::EndToEndTest {
|
||||
RtcpXrObserver(bool enable_rrtr,
|
||||
bool expect_target_bitrate,
|
||||
bool enable_zero_target_bitrate,
|
||||
bool enable_target_bitrate,
|
||||
VideoEncoderConfig::ContentType content_type)
|
||||
: EndToEndTest(test::CallTest::kDefaultTimeoutMs),
|
||||
enable_rrtr_(enable_rrtr),
|
||||
expect_target_bitrate_(expect_target_bitrate),
|
||||
enable_zero_target_bitrate_(enable_zero_target_bitrate),
|
||||
enable_target_bitrate_(enable_target_bitrate),
|
||||
content_type_(content_type),
|
||||
sent_rtcp_sr_(0),
|
||||
sent_rtcp_rr_(0),
|
||||
@ -177,12 +175,6 @@ class RtcpXrObserver : public test::EndToEndTest {
|
||||
VideoSendStream::Config* send_config,
|
||||
std::vector<VideoReceiveStream::Config>* receive_configs,
|
||||
VideoEncoderConfig* encoder_config) override {
|
||||
if (enable_target_bitrate_) {
|
||||
send_config->encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation;
|
||||
}
|
||||
|
||||
if (enable_zero_target_bitrate_) {
|
||||
// Configure VP8 to be able to use simulcast.
|
||||
send_config->rtp.payload_name = "VP8";
|
||||
@ -210,7 +202,6 @@ class RtcpXrObserver : public test::EndToEndTest {
|
||||
const bool enable_rrtr_;
|
||||
const bool expect_target_bitrate_;
|
||||
const bool enable_zero_target_bitrate_;
|
||||
const bool enable_target_bitrate_;
|
||||
const VideoEncoderConfig::ContentType content_type_;
|
||||
int sent_rtcp_sr_;
|
||||
int sent_rtcp_rr_ RTC_GUARDED_BY(&mutex_);
|
||||
@ -226,7 +217,6 @@ TEST_F(ExtendedReportsEndToEndTest,
|
||||
TestExtendedReportsWithRrtrWithoutTargetBitrate) {
|
||||
RtcpXrObserver test(/*enable_rrtr=*/true, /*expect_target_bitrate=*/false,
|
||||
/*enable_zero_target_bitrate=*/false,
|
||||
/*enable_target_bitrate=*/false,
|
||||
VideoEncoderConfig::ContentType::kRealtimeVideo);
|
||||
RunBaseTest(&test);
|
||||
}
|
||||
@ -235,7 +225,6 @@ TEST_F(ExtendedReportsEndToEndTest,
|
||||
TestExtendedReportsWithoutRrtrWithoutTargetBitrate) {
|
||||
RtcpXrObserver test(/*enable_rrtr=*/false, /*expect_target_bitrate=*/false,
|
||||
/*enable_zero_target_bitrate=*/false,
|
||||
/*enable_target_bitrate=*/false,
|
||||
VideoEncoderConfig::ContentType::kRealtimeVideo);
|
||||
RunBaseTest(&test);
|
||||
}
|
||||
@ -244,7 +233,6 @@ TEST_F(ExtendedReportsEndToEndTest,
|
||||
TestExtendedReportsWithRrtrWithTargetBitrate) {
|
||||
RtcpXrObserver test(/*enable_rrtr=*/true, /*expect_target_bitrate=*/true,
|
||||
/*enable_zero_target_bitrate=*/false,
|
||||
/*enable_target_bitrate=*/false,
|
||||
VideoEncoderConfig::ContentType::kScreen);
|
||||
RunBaseTest(&test);
|
||||
}
|
||||
@ -253,16 +241,15 @@ TEST_F(ExtendedReportsEndToEndTest,
|
||||
TestExtendedReportsWithoutRrtrWithTargetBitrate) {
|
||||
RtcpXrObserver test(/*enable_rrtr=*/false, /*expect_target_bitrate=*/true,
|
||||
/*enable_zero_target_bitrate=*/false,
|
||||
/*enable_target_bitrate=*/false,
|
||||
VideoEncoderConfig::ContentType::kScreen);
|
||||
RunBaseTest(&test);
|
||||
}
|
||||
|
||||
TEST_F(ExtendedReportsEndToEndTest,
|
||||
TestExtendedReportsWithoutRrtrWithTargetBitrateExplicitlySet) {
|
||||
test::ScopedFieldTrials field_trials("WebRTC-Target-Bitrate-Rtcp/Enabled/");
|
||||
RtcpXrObserver test(/*enable_rrtr=*/false, /*expect_target_bitrate=*/true,
|
||||
/*enable_zero_target_bitrate=*/false,
|
||||
/*enable_target_bitrate=*/true,
|
||||
VideoEncoderConfig::ContentType::kRealtimeVideo);
|
||||
RunBaseTest(&test);
|
||||
}
|
||||
@ -271,7 +258,6 @@ TEST_F(ExtendedReportsEndToEndTest,
|
||||
TestExtendedReportsCanSignalZeroTargetBitrate) {
|
||||
RtcpXrObserver test(/*enable_rrtr=*/false, /*expect_target_bitrate=*/true,
|
||||
/*enable_zero_target_bitrate=*/true,
|
||||
/*enable_target_bitrate=*/false,
|
||||
VideoEncoderConfig::ContentType::kScreen);
|
||||
RunBaseTest(&test);
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include "api/array_view.h"
|
||||
#include "api/video/video_stream_encoder_create.h"
|
||||
#include "api/video/video_stream_encoder_settings.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_header_extension_size.h"
|
||||
@ -23,7 +22,9 @@
|
||||
#include "rtc_base/task_utils/to_queued_task.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "video/adaptation/overuse_frame_detector.h"
|
||||
#include "video/video_send_stream_impl.h"
|
||||
#include "video/video_stream_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -60,6 +61,22 @@ size_t CalculateMaxHeaderSize(const RtpConfig& config) {
|
||||
return header_size;
|
||||
}
|
||||
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType
|
||||
GetBitrateAllocationCallbackType(const VideoSendStream::Config& config) {
|
||||
if (webrtc::RtpExtension::FindHeaderExtensionByUri(
|
||||
config.rtp.extensions,
|
||||
webrtc::RtpExtension::kVideoLayersAllocationUri)) {
|
||||
return VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
}
|
||||
if (field_trial::IsEnabled("WebRTC-Target-Bitrate-Rtcp")) {
|
||||
return VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation;
|
||||
}
|
||||
return VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocationWhenScreenSharing;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace internal {
|
||||
@ -86,9 +103,11 @@ VideoSendStream::VideoSendStream(
|
||||
RTC_DCHECK(config_.encoder_settings.encoder_factory);
|
||||
RTC_DCHECK(config_.encoder_settings.bitrate_allocator_factory);
|
||||
|
||||
video_stream_encoder_ =
|
||||
CreateVideoStreamEncoder(clock, task_queue_factory, num_cpu_cores,
|
||||
&stats_proxy_, config_.encoder_settings);
|
||||
video_stream_encoder_ = std::make_unique<VideoStreamEncoder>(
|
||||
clock, num_cpu_cores, &stats_proxy_, config_.encoder_settings,
|
||||
std::make_unique<OveruseFrameDetector>(&stats_proxy_), task_queue_factory,
|
||||
GetBitrateAllocationCallbackType(config_));
|
||||
|
||||
// TODO(srte): Initialization should not be done posted on a task queue.
|
||||
// Note that the posted task must not outlive this scope since the closure
|
||||
// references local variables.
|
||||
|
||||
@ -429,12 +429,14 @@ VideoStreamEncoder::VideoStreamEncoder(
|
||||
VideoStreamEncoderObserver* encoder_stats_observer,
|
||||
const VideoStreamEncoderSettings& settings,
|
||||
std::unique_ptr<OveruseFrameDetector> overuse_detector,
|
||||
TaskQueueFactory* task_queue_factory)
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
BitrateAllocationCallbackType allocation_cb_type)
|
||||
: main_queue_(TaskQueueBase::Current()),
|
||||
number_of_cores_(number_of_cores),
|
||||
quality_scaling_experiment_enabled_(QualityScalingExperiment::Enabled()),
|
||||
sink_(nullptr),
|
||||
settings_(settings),
|
||||
allocation_cb_type_(allocation_cb_type),
|
||||
rate_control_settings_(RateControlSettings::ParseFromFieldTrials()),
|
||||
encoder_selector_(settings.encoder_factory->GetEncoderSelector()),
|
||||
encoder_stats_observer_(encoder_stats_observer),
|
||||
@ -1276,21 +1278,18 @@ void VideoStreamEncoder::SetEncoderRates(
|
||||
static_cast<uint32_t>(rate_settings.rate_control.framerate_fps + 0.5));
|
||||
stream_resource_manager_.SetEncoderRates(rate_settings.rate_control);
|
||||
if (layer_allocation_changed &&
|
||||
settings_.allocation_cb_type ==
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation) {
|
||||
allocation_cb_type_ ==
|
||||
BitrateAllocationCallbackType::kVideoLayersAllocation) {
|
||||
sink_->OnVideoLayersAllocationUpdated(CreateVideoLayersAllocation(
|
||||
send_codec_, rate_settings.rate_control, encoder_->GetEncoderInfo()));
|
||||
}
|
||||
}
|
||||
if ((settings_.allocation_cb_type ==
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation) ||
|
||||
if ((allocation_cb_type_ ==
|
||||
BitrateAllocationCallbackType::kVideoBitrateAllocation) ||
|
||||
(encoder_config_.content_type ==
|
||||
VideoEncoderConfig::ContentType::kScreen &&
|
||||
settings_.allocation_cb_type ==
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocationWhenScreenSharing)) {
|
||||
allocation_cb_type_ == BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocationWhenScreenSharing)) {
|
||||
sink_->OnBitrateAllocationUpdated(
|
||||
// Update allocation according to info from encoder. An encoder may
|
||||
// choose to not use all layers due to for example HW.
|
||||
|
||||
@ -61,12 +61,20 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
|
||||
private EncodedImageCallback,
|
||||
public VideoSourceRestrictionsListener {
|
||||
public:
|
||||
// TODO(bugs.webrtc.org/12000): Reporting of VideoBitrateAllocation is being
|
||||
// deprecated. Instead VideoLayersAllocation should be reported.
|
||||
enum class BitrateAllocationCallbackType {
|
||||
kVideoBitrateAllocation,
|
||||
kVideoBitrateAllocationWhenScreenSharing,
|
||||
kVideoLayersAllocation
|
||||
};
|
||||
VideoStreamEncoder(Clock* clock,
|
||||
uint32_t number_of_cores,
|
||||
VideoStreamEncoderObserver* encoder_stats_observer,
|
||||
const VideoStreamEncoderSettings& settings,
|
||||
std::unique_ptr<OveruseFrameDetector> overuse_detector,
|
||||
TaskQueueFactory* task_queue_factory);
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
BitrateAllocationCallbackType allocation_cb_type);
|
||||
~VideoStreamEncoder() override;
|
||||
|
||||
void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override;
|
||||
@ -225,6 +233,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
|
||||
|
||||
EncoderSink* sink_;
|
||||
const VideoStreamEncoderSettings settings_;
|
||||
const BitrateAllocationCallbackType allocation_cb_type_;
|
||||
const RateControlSettings rate_control_settings_;
|
||||
|
||||
std::unique_ptr<VideoEncoderFactory::EncoderSelectorInterface> const
|
||||
|
||||
@ -318,7 +318,9 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
|
||||
VideoStreamEncoderUnderTest(TimeController* time_controller,
|
||||
TaskQueueFactory* task_queue_factory,
|
||||
SendStatisticsProxy* stats_proxy,
|
||||
const VideoStreamEncoderSettings& settings)
|
||||
const VideoStreamEncoderSettings& settings,
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType
|
||||
allocation_callback_type)
|
||||
: VideoStreamEncoder(time_controller->GetClock(),
|
||||
1 /* number_of_cores */,
|
||||
stats_proxy,
|
||||
@ -326,7 +328,8 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
|
||||
std::unique_ptr<OveruseFrameDetector>(
|
||||
overuse_detector_proxy_ =
|
||||
new CpuOveruseDetectorProxy(stats_proxy)),
|
||||
task_queue_factory),
|
||||
task_queue_factory,
|
||||
allocation_callback_type),
|
||||
time_controller_(time_controller),
|
||||
fake_cpu_resource_(FakeResource::Create("FakeResource[CPU]")),
|
||||
fake_quality_resource_(FakeResource::Create("FakeResource[QP]")),
|
||||
@ -628,12 +631,17 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
}
|
||||
|
||||
void ConfigureEncoder(VideoEncoderConfig video_encoder_config) {
|
||||
void ConfigureEncoder(
|
||||
VideoEncoderConfig video_encoder_config,
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType
|
||||
allocation_callback_type =
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocationWhenScreenSharing) {
|
||||
if (video_stream_encoder_)
|
||||
video_stream_encoder_->Stop();
|
||||
video_stream_encoder_.reset(new VideoStreamEncoderUnderTest(
|
||||
&time_controller_, GetTaskQueueFactory(), stats_proxy_.get(),
|
||||
video_send_config_.encoder_settings));
|
||||
video_send_config_.encoder_settings, allocation_callback_type));
|
||||
video_stream_encoder_->SetSink(&sink_, false /* rotation_applied */);
|
||||
video_stream_encoder_->SetSource(
|
||||
&video_source_, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
|
||||
@ -643,18 +651,16 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
||||
video_stream_encoder_->WaitUntilTaskQueueIsIdle();
|
||||
}
|
||||
|
||||
void ResetEncoder(
|
||||
const std::string& payload_name,
|
||||
size_t num_streams,
|
||||
size_t num_temporal_layers,
|
||||
unsigned char num_spatial_layers,
|
||||
bool screenshare,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType
|
||||
allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocationWhenScreenSharing) {
|
||||
void ResetEncoder(const std::string& payload_name,
|
||||
size_t num_streams,
|
||||
size_t num_temporal_layers,
|
||||
unsigned char num_spatial_layers,
|
||||
bool screenshare,
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType
|
||||
allocation_callback_type =
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocationWhenScreenSharing) {
|
||||
video_send_config_.rtp.payload_name = payload_name;
|
||||
video_send_config_.encoder_settings.allocation_cb_type = allocation_cb_type;
|
||||
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(PayloadStringToCodecType(payload_name),
|
||||
@ -676,7 +682,7 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
||||
new rtc::RefCountedObject<
|
||||
VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
|
||||
}
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config), allocation_callback_type);
|
||||
}
|
||||
|
||||
VideoFrame CreateFrame(int64_t ntp_time_ms,
|
||||
@ -3988,7 +3994,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
|
||||
TEST_F(VideoStreamEncoderTest, ReportsVideoBitrateAllocation) {
|
||||
ResetEncoder("FAKE", 1, 1, 1, /*screenshare*/ false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation);
|
||||
|
||||
const int kDefaultFps = 30;
|
||||
@ -4034,7 +4040,7 @@ TEST_F(VideoStreamEncoderTest, ReportsVideoBitrateAllocation) {
|
||||
|
||||
TEST_F(VideoStreamEncoderTest, ReportsVideoLayersAllocationForVP8Simulcast) {
|
||||
ResetEncoder("VP8", /*num_streams*/ 2, 1, 1, /*screenshare*/ false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
const int kDefaultFps = 30;
|
||||
@ -4089,9 +4095,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 2, true);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP8,
|
||||
/* num_streams*/ 3, &video_encoder_config);
|
||||
@ -4108,7 +4111,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_encoder_config.simulcast_layers[0].active = true;
|
||||
video_encoder_config.simulcast_layers[1].active = false;
|
||||
video_encoder_config.simulcast_layers[2].active = true;
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4135,9 +4140,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 2, true);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP8,
|
||||
/* num_streams*/ 3, &video_encoder_config);
|
||||
@ -4154,7 +4156,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_encoder_config.simulcast_layers[0].active = true;
|
||||
video_encoder_config.simulcast_layers[1].active = false;
|
||||
video_encoder_config.simulcast_layers[2].active = false;
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4180,9 +4184,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
ReportsVideoLayersAllocationForV9SvcWithTemporalLayerSupport) {
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, true);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP9,
|
||||
/* num_streams*/ 1, &video_encoder_config);
|
||||
@ -4197,7 +4198,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_encoder_config.encoder_specific_settings =
|
||||
new rtc::RefCountedObject<VideoEncoderConfig::Vp9EncoderSpecificSettings>(
|
||||
vp9_settings);
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4236,9 +4239,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
ReportsVideoLayersAllocationForV9SvcWithoutTemporalLayerSupport) {
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, false);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, false);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP9,
|
||||
/* num_streams*/ 1, &video_encoder_config);
|
||||
@ -4253,7 +4253,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_encoder_config.encoder_specific_settings =
|
||||
new rtc::RefCountedObject<VideoEncoderConfig::Vp9EncoderSpecificSettings>(
|
||||
vp9_settings);
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4285,9 +4287,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
ReportsVideoLayersAllocationForVP9KSvcWithTemporalLayerSupport) {
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, true);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP9,
|
||||
/* num_streams*/ 1, &video_encoder_config);
|
||||
@ -4302,7 +4301,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_encoder_config.encoder_specific_settings =
|
||||
new rtc::RefCountedObject<VideoEncoderConfig::Vp9EncoderSpecificSettings>(
|
||||
vp9_settings);
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4334,9 +4335,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 2, true);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP9,
|
||||
/* num_streams*/ 1, &video_encoder_config);
|
||||
@ -4356,7 +4354,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_encoder_config.simulcast_layers[0].active = false;
|
||||
video_encoder_config.simulcast_layers[1].active = true;
|
||||
video_encoder_config.simulcast_layers[2].active = true;
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4394,9 +4394,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 2, true);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP9,
|
||||
/* num_streams*/ 1, &video_encoder_config);
|
||||
@ -4414,7 +4411,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
// Simulcast layers are used for enabling/disabling streams.
|
||||
video_encoder_config.simulcast_layers.resize(3);
|
||||
video_encoder_config.simulcast_layers[2].active = false;
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4447,9 +4446,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx=*/0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 1, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(/*spatial_idx*/ 2, true);
|
||||
video_send_config_.encoder_settings.allocation_cb_type =
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation;
|
||||
VideoEncoderConfig video_encoder_config;
|
||||
test::FillEncoderConfiguration(VideoCodecType::kVideoCodecVP9,
|
||||
/* num_streams*/ 1, &video_encoder_config);
|
||||
@ -4469,7 +4465,9 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_encoder_config.simulcast_layers[0].active = false;
|
||||
video_encoder_config.simulcast_layers[1].active = false;
|
||||
video_encoder_config.simulcast_layers[2].active = true;
|
||||
ConfigureEncoder(std::move(video_encoder_config));
|
||||
ConfigureEncoder(std::move(video_encoder_config),
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4496,7 +4494,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
|
||||
TEST_F(VideoStreamEncoderTest, ReportsVideoLayersAllocationForH264) {
|
||||
ResetEncoder("H264", 1, 1, 1, false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
@ -4525,7 +4523,7 @@ TEST_F(VideoStreamEncoderTest, ReportsVideoLayersAllocationForH264) {
|
||||
TEST_F(VideoStreamEncoderTest,
|
||||
ReportsUpdatedVideoLayersAllocationWhenBweChanges) {
|
||||
ResetEncoder("VP8", /*num_streams*/ 2, 1, 1, /*screenshare*/ false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
@ -4566,7 +4564,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
TEST_F(VideoStreamEncoderTest,
|
||||
ReportsUpdatedVideoLayersAllocationWhenResolutionChanges) {
|
||||
ResetEncoder("VP8", /*num_streams*/ 2, 1, 1, /*screenshare*/ false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoLayersAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
@ -4605,7 +4603,7 @@ TEST_F(VideoStreamEncoderTest, TemporalLayersNotDisabledIfSupported) {
|
||||
// 2 TLs configured, temporal layers supported by encoder.
|
||||
const int kNumTemporalLayers = 2;
|
||||
ResetEncoder("VP8", 1, kNumTemporalLayers, 1, /*screenshare*/ false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation);
|
||||
fake_encoder_.SetTemporalLayersSupported(0, true);
|
||||
|
||||
@ -4629,7 +4627,7 @@ TEST_F(VideoStreamEncoderTest, TemporalLayersNotDisabledIfSupported) {
|
||||
TEST_F(VideoStreamEncoderTest, TemporalLayersDisabledIfNotSupported) {
|
||||
// 2 TLs configured, temporal layers not supported by encoder.
|
||||
ResetEncoder("VP8", 1, /*num_temporal_layers*/ 2, 1, /*screenshare*/ false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation);
|
||||
fake_encoder_.SetTemporalLayersSupported(0, false);
|
||||
|
||||
@ -4651,7 +4649,7 @@ TEST_F(VideoStreamEncoderTest, VerifyBitrateAllocationForTwoStreams) {
|
||||
|
||||
// 2 TLs configured, temporal layers only supported for first stream.
|
||||
ResetEncoder("VP8", 2, /*num_temporal_layers*/ 2, 1, /*screenshare*/ false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation);
|
||||
fake_encoder_.SetTemporalLayersSupported(0, true);
|
||||
fake_encoder_.SetTemporalLayersSupported(1, false);
|
||||
@ -6154,7 +6152,7 @@ TEST_F(VideoStreamEncoderTest, DoesNotUpdateBitrateAllocationWhenSuspended) {
|
||||
const int kFrameHeight = 720;
|
||||
const int kTargetBitrateBps = 1000000;
|
||||
ResetEncoder("FAKE", 1, 1, 1, false,
|
||||
VideoStreamEncoderSettings::BitrateAllocationCallbackType::
|
||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||
kVideoBitrateAllocation);
|
||||
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user