mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-16 15:20:42 +01:00
Propagate Environment into VideoStreamEncoder
VideoStreamEncoder creates VideoEncoders. To pass an Environment to VideoEncoder, it should be available in the VideoStreamEncoder. Bug: webrtc:15860 Change-Id: Id89ac024ce61fdd9673bb66f03f94f243fc0c7f7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/341840 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41861}
This commit is contained in:
parent
9f11b96e6b
commit
c9bb2c6c4e
8 changed files with 107 additions and 111 deletions
10
call/call.cc
10
call/call.cc
|
@ -888,13 +888,11 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
|
||||||
std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
|
std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
|
||||||
|
|
||||||
VideoSendStreamImpl* send_stream = new VideoSendStreamImpl(
|
VideoSendStreamImpl* send_stream = new VideoSendStreamImpl(
|
||||||
&env_.clock(), num_cpu_cores_, &env_.task_queue_factory(),
|
env_, num_cpu_cores_, call_stats_->AsRtcpRttStats(),
|
||||||
call_stats_->AsRtcpRttStats(), transport_send_.get(),
|
transport_send_.get(), config_.encode_metronome, bitrate_allocator_.get(),
|
||||||
config_.encode_metronome, bitrate_allocator_.get(),
|
video_send_delay_stats_.get(), std::move(config),
|
||||||
video_send_delay_stats_.get(), &env_.event_log(), std::move(config),
|
|
||||||
std::move(encoder_config), suspended_video_send_ssrcs_,
|
std::move(encoder_config), suspended_video_send_ssrcs_,
|
||||||
suspended_video_payload_states_, std::move(fec_controller),
|
suspended_video_payload_states_, std::move(fec_controller));
|
||||||
env_.field_trials());
|
|
||||||
|
|
||||||
for (uint32_t ssrc : ssrcs) {
|
for (uint32_t ssrc : ssrcs) {
|
||||||
RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
|
RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
|
||||||
|
|
|
@ -413,6 +413,7 @@ rtc_library("video_stream_encoder_impl") {
|
||||||
"../api:rtp_sender_interface",
|
"../api:rtp_sender_interface",
|
||||||
"../api:sequence_checker",
|
"../api:sequence_checker",
|
||||||
"../api/adaptation:resource_adaptation_api",
|
"../api/adaptation:resource_adaptation_api",
|
||||||
|
"../api/environment",
|
||||||
"../api/task_queue:pending_task_safety_flag",
|
"../api/task_queue:pending_task_safety_flag",
|
||||||
"../api/task_queue:task_queue",
|
"../api/task_queue:task_queue",
|
||||||
"../api/units:data_rate",
|
"../api/units:data_rate",
|
||||||
|
@ -464,7 +465,6 @@ rtc_library("video_stream_encoder_impl") {
|
||||||
"../rtc_base/system:no_unique_address",
|
"../rtc_base/system:no_unique_address",
|
||||||
"../rtc_base/task_utils:repeating_task",
|
"../rtc_base/task_utils:repeating_task",
|
||||||
"../system_wrappers",
|
"../system_wrappers",
|
||||||
"../system_wrappers:field_trial",
|
|
||||||
"../system_wrappers:metrics",
|
"../system_wrappers:metrics",
|
||||||
"adaptation:video_adaptation",
|
"adaptation:video_adaptation",
|
||||||
"config:encoder_config",
|
"config:encoder_config",
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "api/adaptation/resource.h"
|
#include "api/adaptation/resource.h"
|
||||||
#include "api/call/bitrate_allocation.h"
|
#include "api/call/bitrate_allocation.h"
|
||||||
#include "api/crypto/crypto_options.h"
|
#include "api/crypto/crypto_options.h"
|
||||||
|
#include "api/environment/environment.h"
|
||||||
#include "api/fec_controller.h"
|
#include "api/fec_controller.h"
|
||||||
#include "api/field_trials_view.h"
|
#include "api/field_trials_view.h"
|
||||||
#include "api/metronome/metronome.h"
|
#include "api/metronome/metronome.h"
|
||||||
|
@ -340,27 +341,25 @@ RtpSenderObservers CreateObservers(RtcpRttStats* call_stats,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<VideoStreamEncoderInterface> CreateVideoStreamEncoder(
|
std::unique_ptr<VideoStreamEncoderInterface> CreateVideoStreamEncoder(
|
||||||
Clock* clock,
|
const Environment& env,
|
||||||
int num_cpu_cores,
|
int num_cpu_cores,
|
||||||
TaskQueueFactory* task_queue_factory,
|
|
||||||
SendStatisticsProxy* stats_proxy,
|
SendStatisticsProxy* stats_proxy,
|
||||||
const VideoStreamEncoderSettings& encoder_settings,
|
const VideoStreamEncoderSettings& encoder_settings,
|
||||||
VideoStreamEncoder::BitrateAllocationCallbackType
|
VideoStreamEncoder::BitrateAllocationCallbackType
|
||||||
bitrate_allocation_callback_type,
|
bitrate_allocation_callback_type,
|
||||||
const FieldTrialsView& field_trials,
|
|
||||||
Metronome* metronome,
|
Metronome* metronome,
|
||||||
webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector) {
|
webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector) {
|
||||||
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> encoder_queue =
|
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> encoder_queue =
|
||||||
task_queue_factory->CreateTaskQueue("EncoderQueue",
|
env.task_queue_factory().CreateTaskQueue(
|
||||||
TaskQueueFactory::Priority::NORMAL);
|
"EncoderQueue", TaskQueueFactory::Priority::NORMAL);
|
||||||
TaskQueueBase* encoder_queue_ptr = encoder_queue.get();
|
TaskQueueBase* encoder_queue_ptr = encoder_queue.get();
|
||||||
return std::make_unique<VideoStreamEncoder>(
|
return std::make_unique<VideoStreamEncoder>(
|
||||||
clock, num_cpu_cores, stats_proxy, encoder_settings,
|
env, num_cpu_cores, stats_proxy, encoder_settings,
|
||||||
std::make_unique<OveruseFrameDetector>(stats_proxy),
|
std::make_unique<OveruseFrameDetector>(stats_proxy),
|
||||||
FrameCadenceAdapterInterface::Create(
|
FrameCadenceAdapterInterface::Create(
|
||||||
clock, encoder_queue_ptr, metronome,
|
&env.clock(), encoder_queue_ptr, metronome,
|
||||||
/*worker_queue=*/TaskQueueBase::Current(), field_trials),
|
/*worker_queue=*/TaskQueueBase::Current(), env.field_trials()),
|
||||||
std::move(encoder_queue), bitrate_allocation_callback_type, field_trials,
|
std::move(encoder_queue), bitrate_allocation_callback_type,
|
||||||
encoder_selector);
|
encoder_selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,24 +384,25 @@ PacingConfig::PacingConfig(const PacingConfig&) = default;
|
||||||
PacingConfig::~PacingConfig() = default;
|
PacingConfig::~PacingConfig() = default;
|
||||||
|
|
||||||
VideoSendStreamImpl::VideoSendStreamImpl(
|
VideoSendStreamImpl::VideoSendStreamImpl(
|
||||||
Clock* clock,
|
const Environment& env,
|
||||||
int num_cpu_cores,
|
int num_cpu_cores,
|
||||||
TaskQueueFactory* task_queue_factory,
|
|
||||||
RtcpRttStats* call_stats,
|
RtcpRttStats* call_stats,
|
||||||
RtpTransportControllerSendInterface* transport,
|
RtpTransportControllerSendInterface* transport,
|
||||||
Metronome* metronome,
|
Metronome* metronome,
|
||||||
BitrateAllocatorInterface* bitrate_allocator,
|
BitrateAllocatorInterface* bitrate_allocator,
|
||||||
SendDelayStats* send_delay_stats,
|
SendDelayStats* send_delay_stats,
|
||||||
RtcEventLog* event_log,
|
|
||||||
VideoSendStream::Config config,
|
VideoSendStream::Config config,
|
||||||
VideoEncoderConfig encoder_config,
|
VideoEncoderConfig encoder_config,
|
||||||
const std::map<uint32_t, RtpState>& suspended_ssrcs,
|
const std::map<uint32_t, RtpState>& suspended_ssrcs,
|
||||||
const std::map<uint32_t, RtpPayloadState>& suspended_payload_states,
|
const std::map<uint32_t, RtpPayloadState>& suspended_payload_states,
|
||||||
std::unique_ptr<FecController> fec_controller,
|
std::unique_ptr<FecController> fec_controller,
|
||||||
const FieldTrialsView& field_trials,
|
|
||||||
std::unique_ptr<VideoStreamEncoderInterface> video_stream_encoder_for_test)
|
std::unique_ptr<VideoStreamEncoderInterface> video_stream_encoder_for_test)
|
||||||
: transport_(transport),
|
: env_(env),
|
||||||
stats_proxy_(clock, config, encoder_config.content_type, field_trials),
|
transport_(transport),
|
||||||
|
stats_proxy_(&env_.clock(),
|
||||||
|
config,
|
||||||
|
encoder_config.content_type,
|
||||||
|
env_.field_trials()),
|
||||||
send_packet_observer_(&stats_proxy_, send_delay_stats),
|
send_packet_observer_(&stats_proxy_, send_delay_stats),
|
||||||
config_(std::move(config)),
|
config_(std::move(config)),
|
||||||
content_type_(encoder_config.content_type),
|
content_type_(encoder_config.content_type),
|
||||||
|
@ -410,17 +410,16 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
||||||
video_stream_encoder_for_test
|
video_stream_encoder_for_test
|
||||||
? std::move(video_stream_encoder_for_test)
|
? std::move(video_stream_encoder_for_test)
|
||||||
: CreateVideoStreamEncoder(
|
: CreateVideoStreamEncoder(
|
||||||
clock,
|
env_,
|
||||||
num_cpu_cores,
|
num_cpu_cores,
|
||||||
task_queue_factory,
|
|
||||||
&stats_proxy_,
|
&stats_proxy_,
|
||||||
config_.encoder_settings,
|
config_.encoder_settings,
|
||||||
GetBitrateAllocationCallbackType(config_, field_trials),
|
GetBitrateAllocationCallbackType(config_,
|
||||||
field_trials,
|
env_.field_trials()),
|
||||||
metronome,
|
metronome,
|
||||||
config_.encoder_selector)),
|
config_.encoder_selector)),
|
||||||
encoder_feedback_(
|
encoder_feedback_(
|
||||||
clock,
|
&env_.clock(),
|
||||||
SupportsPerLayerPictureLossIndication(
|
SupportsPerLayerPictureLossIndication(
|
||||||
encoder_config.video_format.parameters),
|
encoder_config.video_format.parameters),
|
||||||
config_.rtp.ssrcs,
|
config_.rtp.ssrcs,
|
||||||
|
@ -438,18 +437,16 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
||||||
&encoder_feedback_,
|
&encoder_feedback_,
|
||||||
&stats_proxy_,
|
&stats_proxy_,
|
||||||
&send_packet_observer_),
|
&send_packet_observer_),
|
||||||
event_log,
|
&env_.event_log(),
|
||||||
std::move(fec_controller),
|
std::move(fec_controller),
|
||||||
CreateFrameEncryptionConfig(&config_),
|
CreateFrameEncryptionConfig(&config_),
|
||||||
config_.frame_transformer)),
|
config_.frame_transformer)),
|
||||||
clock_(clock),
|
|
||||||
has_alr_probing_(
|
has_alr_probing_(
|
||||||
config_.periodic_alr_bandwidth_probing ||
|
config_.periodic_alr_bandwidth_probing ||
|
||||||
GetAlrSettings(field_trials, encoder_config.content_type)),
|
GetAlrSettings(env_.field_trials(), encoder_config.content_type)),
|
||||||
pacing_config_(PacingConfig(field_trials)),
|
pacing_config_(PacingConfig(env_.field_trials())),
|
||||||
worker_queue_(TaskQueueBase::Current()),
|
worker_queue_(TaskQueueBase::Current()),
|
||||||
timed_out_(false),
|
timed_out_(false),
|
||||||
|
|
||||||
bitrate_allocator_(bitrate_allocator),
|
bitrate_allocator_(bitrate_allocator),
|
||||||
has_active_encodings_(HasActiveEncodings(encoder_config)),
|
has_active_encodings_(HasActiveEncodings(encoder_config)),
|
||||||
disable_padding_(true),
|
disable_padding_(true),
|
||||||
|
@ -460,11 +457,13 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
||||||
encoder_target_rate_bps_(0),
|
encoder_target_rate_bps_(0),
|
||||||
encoder_bitrate_priority_(encoder_config.bitrate_priority),
|
encoder_bitrate_priority_(encoder_config.bitrate_priority),
|
||||||
encoder_av1_priority_bitrate_override_bps_(
|
encoder_av1_priority_bitrate_override_bps_(
|
||||||
GetEncoderPriorityBitrate(config_.rtp.payload_name, field_trials)),
|
GetEncoderPriorityBitrate(config_.rtp.payload_name,
|
||||||
configured_pacing_factor_(GetConfiguredPacingFactor(config_,
|
env_.field_trials())),
|
||||||
content_type_,
|
configured_pacing_factor_(
|
||||||
pacing_config_,
|
GetConfiguredPacingFactor(config_,
|
||||||
field_trials)) {
|
content_type_,
|
||||||
|
pacing_config_,
|
||||||
|
env_.field_trials())) {
|
||||||
RTC_DCHECK_GE(config_.rtp.payload_type, 0);
|
RTC_DCHECK_GE(config_.rtp.payload_type, 0);
|
||||||
RTC_DCHECK_LE(config_.rtp.payload_type, 127);
|
RTC_DCHECK_LE(config_.rtp.payload_type, 127);
|
||||||
RTC_DCHECK(!config_.rtp.ssrcs.empty());
|
RTC_DCHECK(!config_.rtp.ssrcs.empty());
|
||||||
|
@ -472,7 +471,8 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
||||||
RTC_DCHECK_NE(encoder_max_bitrate_bps_, 0);
|
RTC_DCHECK_NE(encoder_max_bitrate_bps_, 0);
|
||||||
RTC_LOG(LS_INFO) << "VideoSendStreamImpl: " << config_.ToString();
|
RTC_LOG(LS_INFO) << "VideoSendStreamImpl: " << config_.ToString();
|
||||||
|
|
||||||
RTC_CHECK(AlrExperimentSettings::MaxOneFieldTrialEnabled(field_trials));
|
RTC_CHECK(
|
||||||
|
AlrExperimentSettings::MaxOneFieldTrialEnabled(env_.field_trials()));
|
||||||
|
|
||||||
absl::optional<bool> enable_alr_bw_probing;
|
absl::optional<bool> enable_alr_bw_probing;
|
||||||
|
|
||||||
|
@ -480,14 +480,14 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
||||||
// pacing settings.
|
// pacing settings.
|
||||||
if (configured_pacing_factor_) {
|
if (configured_pacing_factor_) {
|
||||||
absl::optional<AlrExperimentSettings> alr_settings =
|
absl::optional<AlrExperimentSettings> alr_settings =
|
||||||
GetAlrSettings(field_trials, content_type_);
|
GetAlrSettings(env_.field_trials(), content_type_);
|
||||||
int queue_time_limit_ms;
|
int queue_time_limit_ms;
|
||||||
if (alr_settings) {
|
if (alr_settings) {
|
||||||
enable_alr_bw_probing = true;
|
enable_alr_bw_probing = true;
|
||||||
queue_time_limit_ms = alr_settings->max_paced_queue_time;
|
queue_time_limit_ms = alr_settings->max_paced_queue_time;
|
||||||
} else {
|
} else {
|
||||||
RateControlSettings rate_control_settings =
|
RateControlSettings rate_control_settings =
|
||||||
RateControlSettings::ParseFromKeyValueConfig(&field_trials);
|
RateControlSettings::ParseFromKeyValueConfig(&env_.field_trials());
|
||||||
enable_alr_bw_probing = rate_control_settings.UseAlrProbing();
|
enable_alr_bw_probing = rate_control_settings.UseAlrProbing();
|
||||||
queue_time_limit_ms = pacing_config_.max_pacing_delay.Get().ms();
|
queue_time_limit_ms = pacing_config_.max_pacing_delay.Get().ms();
|
||||||
}
|
}
|
||||||
|
@ -720,7 +720,7 @@ void VideoSendStreamImpl::OnBitrateAllocationUpdated(
|
||||||
if (encoder_target_rate_bps_ == 0) {
|
if (encoder_target_rate_bps_ == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
int64_t now_ms = env_.clock().TimeInMilliseconds();
|
||||||
if (video_bitrate_allocation_context_) {
|
if (video_bitrate_allocation_context_) {
|
||||||
// If new allocation is within kMaxVbaSizeDifferencePercent larger
|
// If new allocation is within kMaxVbaSizeDifferencePercent larger
|
||||||
// than the previously sent allocation and the same streams are still
|
// than the previously sent allocation and the same streams are still
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
|
#include "api/environment/environment.h"
|
||||||
#include "api/field_trials_view.h"
|
#include "api/field_trials_view.h"
|
||||||
#include "api/metronome/metronome.h"
|
#include "api/metronome/metronome.h"
|
||||||
#include "api/task_queue/pending_task_safety_flag.h"
|
#include "api/task_queue/pending_task_safety_flag.h"
|
||||||
|
@ -73,21 +74,18 @@ class VideoSendStreamImpl : public webrtc::VideoSendStream,
|
||||||
using RtpStateMap = std::map<uint32_t, RtpState>;
|
using RtpStateMap = std::map<uint32_t, RtpState>;
|
||||||
using RtpPayloadStateMap = std::map<uint32_t, RtpPayloadState>;
|
using RtpPayloadStateMap = std::map<uint32_t, RtpPayloadState>;
|
||||||
|
|
||||||
VideoSendStreamImpl(Clock* clock,
|
VideoSendStreamImpl(const Environment& env,
|
||||||
int num_cpu_cores,
|
int num_cpu_cores,
|
||||||
TaskQueueFactory* task_queue_factory,
|
|
||||||
RtcpRttStats* call_stats,
|
RtcpRttStats* call_stats,
|
||||||
RtpTransportControllerSendInterface* transport,
|
RtpTransportControllerSendInterface* transport,
|
||||||
Metronome* metronome,
|
Metronome* metronome,
|
||||||
BitrateAllocatorInterface* bitrate_allocator,
|
BitrateAllocatorInterface* bitrate_allocator,
|
||||||
SendDelayStats* send_delay_stats,
|
SendDelayStats* send_delay_stats,
|
||||||
RtcEventLog* event_log,
|
|
||||||
VideoSendStream::Config config,
|
VideoSendStream::Config config,
|
||||||
VideoEncoderConfig encoder_config,
|
VideoEncoderConfig encoder_config,
|
||||||
const RtpStateMap& suspended_ssrcs,
|
const RtpStateMap& suspended_ssrcs,
|
||||||
const RtpPayloadStateMap& suspended_payload_states,
|
const RtpPayloadStateMap& suspended_payload_states,
|
||||||
std::unique_ptr<FecController> fec_controller,
|
std::unique_ptr<FecController> fec_controller,
|
||||||
const FieldTrialsView& field_trials,
|
|
||||||
std::unique_ptr<VideoStreamEncoderInterface>
|
std::unique_ptr<VideoStreamEncoderInterface>
|
||||||
video_stream_encoder_for_test = nullptr);
|
video_stream_encoder_for_test = nullptr);
|
||||||
~VideoSendStreamImpl() override;
|
~VideoSendStreamImpl() override;
|
||||||
|
@ -187,6 +185,7 @@ class VideoSendStreamImpl : public webrtc::VideoSendStream,
|
||||||
MediaStreamAllocationConfig GetAllocationConfig() const
|
MediaStreamAllocationConfig GetAllocationConfig() const
|
||||||
RTC_RUN_ON(thread_checker_);
|
RTC_RUN_ON(thread_checker_);
|
||||||
|
|
||||||
|
const Environment env_;
|
||||||
RTC_NO_UNIQUE_ADDRESS SequenceChecker thread_checker_;
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker thread_checker_;
|
||||||
|
|
||||||
RtpTransportControllerSendInterface* const transport_;
|
RtpTransportControllerSendInterface* const transport_;
|
||||||
|
@ -200,7 +199,6 @@ class VideoSendStreamImpl : public webrtc::VideoSendStream,
|
||||||
RtpVideoSenderInterface* const rtp_video_sender_;
|
RtpVideoSenderInterface* const rtp_video_sender_;
|
||||||
bool running_ RTC_GUARDED_BY(thread_checker_) = false;
|
bool running_ RTC_GUARDED_BY(thread_checker_) = false;
|
||||||
|
|
||||||
Clock* const clock_;
|
|
||||||
const bool has_alr_probing_;
|
const bool has_alr_probing_;
|
||||||
const PacingConfig pacing_config_;
|
const PacingConfig pacing_config_;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "api/call/bitrate_allocation.h"
|
#include "api/call/bitrate_allocation.h"
|
||||||
|
#include "api/environment/environment.h"
|
||||||
|
#include "api/environment/environment_factory.h"
|
||||||
#include "api/rtc_event_log/rtc_event_log.h"
|
#include "api/rtc_event_log/rtc_event_log.h"
|
||||||
#include "api/rtp_parameters.h"
|
#include "api/rtp_parameters.h"
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
|
@ -193,14 +195,14 @@ class VideoSendStreamImplTest : public ::testing::Test {
|
||||||
video_stream_encoder_ = video_stream_encoder.get();
|
video_stream_encoder_ = video_stream_encoder.get();
|
||||||
|
|
||||||
auto ret = std::make_unique<VideoSendStreamImpl>(
|
auto ret = std::make_unique<VideoSendStreamImpl>(
|
||||||
time_controller_.GetClock(),
|
CreateEnvironment(&field_trials_, time_controller_.GetClock(),
|
||||||
/*num_cpu_cores=*/1, time_controller_.GetTaskQueueFactory(),
|
time_controller_.GetTaskQueueFactory()),
|
||||||
|
/*num_cpu_cores=*/1,
|
||||||
/*call_stats=*/nullptr, &transport_controller_,
|
/*call_stats=*/nullptr, &transport_controller_,
|
||||||
/*metronome=*/nullptr, &bitrate_allocator_, &send_delay_stats_,
|
/*metronome=*/nullptr, &bitrate_allocator_, &send_delay_stats_,
|
||||||
/*event_log=*/nullptr, config_.Copy(), std::move(encoder_config),
|
config_.Copy(), std::move(encoder_config), suspended_ssrcs,
|
||||||
suspended_ssrcs, suspended_payload_states,
|
suspended_payload_states,
|
||||||
/*fec_controller=*/nullptr, field_trials_,
|
/*fec_controller=*/nullptr, std::move(video_stream_encoder));
|
||||||
std::move(video_stream_encoder));
|
|
||||||
|
|
||||||
// The call to GetStartBitrate() executes asynchronously on the tq.
|
// The call to GetStartBitrate() executes asynchronously on the tq.
|
||||||
// Ensure all tasks get to run.
|
// Ensure all tasks get to run.
|
||||||
|
|
|
@ -645,7 +645,7 @@ class VideoStreamEncoder::DegradationPreferenceManager
|
||||||
};
|
};
|
||||||
|
|
||||||
VideoStreamEncoder::VideoStreamEncoder(
|
VideoStreamEncoder::VideoStreamEncoder(
|
||||||
Clock* clock,
|
const Environment& env,
|
||||||
uint32_t number_of_cores,
|
uint32_t number_of_cores,
|
||||||
VideoStreamEncoderObserver* encoder_stats_observer,
|
VideoStreamEncoderObserver* encoder_stats_observer,
|
||||||
const VideoStreamEncoderSettings& settings,
|
const VideoStreamEncoderSettings& settings,
|
||||||
|
@ -654,15 +654,14 @@ VideoStreamEncoder::VideoStreamEncoder(
|
||||||
std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter>
|
std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter>
|
||||||
encoder_queue,
|
encoder_queue,
|
||||||
BitrateAllocationCallbackType allocation_cb_type,
|
BitrateAllocationCallbackType allocation_cb_type,
|
||||||
const FieldTrialsView& field_trials,
|
|
||||||
webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector)
|
webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector)
|
||||||
: field_trials_(field_trials),
|
: env_(env),
|
||||||
worker_queue_(TaskQueueBase::Current()),
|
worker_queue_(TaskQueueBase::Current()),
|
||||||
number_of_cores_(number_of_cores),
|
number_of_cores_(number_of_cores),
|
||||||
settings_(settings),
|
settings_(settings),
|
||||||
allocation_cb_type_(allocation_cb_type),
|
allocation_cb_type_(allocation_cb_type),
|
||||||
rate_control_settings_(
|
rate_control_settings_(
|
||||||
RateControlSettings::ParseFromKeyValueConfig(&field_trials)),
|
RateControlSettings::ParseFromKeyValueConfig(&env_.field_trials())),
|
||||||
encoder_selector_from_constructor_(encoder_selector),
|
encoder_selector_from_constructor_(encoder_selector),
|
||||||
encoder_selector_from_factory_(
|
encoder_selector_from_factory_(
|
||||||
encoder_selector_from_constructor_
|
encoder_selector_from_constructor_
|
||||||
|
@ -673,10 +672,9 @@ VideoStreamEncoder::VideoStreamEncoder(
|
||||||
: encoder_selector_from_factory_.get()),
|
: encoder_selector_from_factory_.get()),
|
||||||
encoder_stats_observer_(encoder_stats_observer),
|
encoder_stats_observer_(encoder_stats_observer),
|
||||||
frame_cadence_adapter_(std::move(frame_cadence_adapter)),
|
frame_cadence_adapter_(std::move(frame_cadence_adapter)),
|
||||||
clock_(clock),
|
delta_ntp_internal_ms_(env_.clock().CurrentNtpInMilliseconds() -
|
||||||
delta_ntp_internal_ms_(clock_->CurrentNtpInMilliseconds() -
|
env_.clock().TimeInMilliseconds()),
|
||||||
clock_->TimeInMilliseconds()),
|
last_frame_log_ms_(env_.clock().TimeInMilliseconds()),
|
||||||
last_frame_log_ms_(clock_->TimeInMilliseconds()),
|
|
||||||
next_frame_types_(1, VideoFrameType::kVideoFrameDelta),
|
next_frame_types_(1, VideoFrameType::kVideoFrameDelta),
|
||||||
automatic_animation_detection_experiment_(
|
automatic_animation_detection_experiment_(
|
||||||
ParseAutomatincAnimationDetectionFieldTrial()),
|
ParseAutomatincAnimationDetectionFieldTrial()),
|
||||||
|
@ -684,28 +682,29 @@ VideoStreamEncoder::VideoStreamEncoder(
|
||||||
video_stream_adapter_(
|
video_stream_adapter_(
|
||||||
std::make_unique<VideoStreamAdapter>(&input_state_provider_,
|
std::make_unique<VideoStreamAdapter>(&input_state_provider_,
|
||||||
encoder_stats_observer,
|
encoder_stats_observer,
|
||||||
field_trials)),
|
env_.field_trials())),
|
||||||
degradation_preference_manager_(
|
degradation_preference_manager_(
|
||||||
std::make_unique<DegradationPreferenceManager>(
|
std::make_unique<DegradationPreferenceManager>(
|
||||||
video_stream_adapter_.get())),
|
video_stream_adapter_.get())),
|
||||||
stream_resource_manager_(&input_state_provider_,
|
stream_resource_manager_(&input_state_provider_,
|
||||||
encoder_stats_observer,
|
encoder_stats_observer,
|
||||||
clock_,
|
&env_.clock(),
|
||||||
settings_.experiment_cpu_load_estimator,
|
settings_.experiment_cpu_load_estimator,
|
||||||
std::move(overuse_detector),
|
std::move(overuse_detector),
|
||||||
degradation_preference_manager_.get(),
|
degradation_preference_manager_.get(),
|
||||||
field_trials),
|
env_.field_trials()),
|
||||||
video_source_sink_controller_(/*sink=*/frame_cadence_adapter_.get(),
|
video_source_sink_controller_(/*sink=*/frame_cadence_adapter_.get(),
|
||||||
/*source=*/nullptr),
|
/*source=*/nullptr),
|
||||||
default_limits_allowed_(
|
default_limits_allowed_(!env_.field_trials().IsEnabled(
|
||||||
!field_trials.IsEnabled("WebRTC-DefaultBitrateLimitsKillSwitch")),
|
"WebRTC-DefaultBitrateLimitsKillSwitch")),
|
||||||
qp_parsing_allowed_(
|
qp_parsing_allowed_(
|
||||||
!field_trials.IsEnabled("WebRTC-QpParsingKillSwitch")),
|
!env_.field_trials().IsEnabled("WebRTC-QpParsingKillSwitch")),
|
||||||
switch_encoder_on_init_failures_(!field_trials.IsDisabled(
|
switch_encoder_on_init_failures_(!env_.field_trials().IsDisabled(
|
||||||
kSwitchEncoderOnInitializationFailuresFieldTrial)),
|
kSwitchEncoderOnInitializationFailuresFieldTrial)),
|
||||||
vp9_low_tier_core_threshold_(
|
vp9_low_tier_core_threshold_(
|
||||||
ParseVp9LowTierCoreCountThreshold(field_trials)),
|
ParseVp9LowTierCoreCountThreshold(env_.field_trials())),
|
||||||
experimental_encoder_thread_limit_(ParseEncoderThreadLimit(field_trials)),
|
experimental_encoder_thread_limit_(
|
||||||
|
ParseEncoderThreadLimit(env_.field_trials())),
|
||||||
encoder_queue_(std::move(encoder_queue)) {
|
encoder_queue_(std::move(encoder_queue)) {
|
||||||
TRACE_EVENT0("webrtc", "VideoStreamEncoder::VideoStreamEncoder");
|
TRACE_EVENT0("webrtc", "VideoStreamEncoder::VideoStreamEncoder");
|
||||||
RTC_DCHECK_RUN_ON(worker_queue_);
|
RTC_DCHECK_RUN_ON(worker_queue_);
|
||||||
|
@ -950,7 +949,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
|
||||||
encoder_ = MaybeCreateFrameDumpingEncoderWrapper(
|
encoder_ = MaybeCreateFrameDumpingEncoderWrapper(
|
||||||
settings_.encoder_factory->CreateVideoEncoder(
|
settings_.encoder_factory->CreateVideoEncoder(
|
||||||
encoder_config_.video_format),
|
encoder_config_.video_format),
|
||||||
field_trials_);
|
env_.field_trials());
|
||||||
if (!encoder_) {
|
if (!encoder_) {
|
||||||
RTC_LOG(LS_ERROR) << "CreateVideoEncoder failed, failing encoder format: "
|
RTC_LOG(LS_ERROR) << "CreateVideoEncoder failed, failing encoder format: "
|
||||||
<< encoder_config_.video_format.ToString();
|
<< encoder_config_.video_format.ToString();
|
||||||
|
@ -986,7 +985,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
|
||||||
webrtc::VideoEncoderConfig::ContentType::kScreen,
|
webrtc::VideoEncoderConfig::ContentType::kScreen,
|
||||||
encoder_config_.legacy_conference_mode, encoder_->GetEncoderInfo(),
|
encoder_config_.legacy_conference_mode, encoder_->GetEncoderInfo(),
|
||||||
MergeRestrictions({latest_restrictions_, animate_restrictions_}),
|
MergeRestrictions({latest_restrictions_, animate_restrictions_}),
|
||||||
&field_trials_);
|
&env_.field_trials());
|
||||||
|
|
||||||
streams = factory->CreateEncoderStreams(
|
streams = factory->CreateEncoderStreams(
|
||||||
last_frame_info_->width, last_frame_info_->height, encoder_config_);
|
last_frame_info_->width, last_frame_info_->height, encoder_config_);
|
||||||
|
@ -1362,13 +1361,13 @@ void VideoStreamEncoder::ReconfigureEncoder() {
|
||||||
// * We have screensharing with layers.
|
// * We have screensharing with layers.
|
||||||
// * "WebRTC-FrameDropper" field trial is "Disabled".
|
// * "WebRTC-FrameDropper" field trial is "Disabled".
|
||||||
force_disable_frame_dropper_ =
|
force_disable_frame_dropper_ =
|
||||||
field_trials_.IsDisabled(kFrameDropperFieldTrial) ||
|
env_.field_trials().IsDisabled(kFrameDropperFieldTrial) ||
|
||||||
(num_layers > 1 && codec.mode == VideoCodecMode::kScreensharing);
|
(num_layers > 1 && codec.mode == VideoCodecMode::kScreensharing);
|
||||||
|
|
||||||
const VideoEncoder::EncoderInfo info = encoder_->GetEncoderInfo();
|
const VideoEncoder::EncoderInfo info = encoder_->GetEncoderInfo();
|
||||||
if (rate_control_settings_.UseEncoderBitrateAdjuster()) {
|
if (rate_control_settings_.UseEncoderBitrateAdjuster()) {
|
||||||
bitrate_adjuster_ =
|
bitrate_adjuster_ =
|
||||||
std::make_unique<EncoderBitrateAdjuster>(codec, field_trials_);
|
std::make_unique<EncoderBitrateAdjuster>(codec, env_.field_trials());
|
||||||
bitrate_adjuster_->OnEncoderInfo(info);
|
bitrate_adjuster_->OnEncoderInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1787,7 +1786,7 @@ void VideoStreamEncoder::MaybeEncodeVideoFrame(const VideoFrame& video_frame,
|
||||||
uint32_t framerate_fps = GetInputFramerateFps();
|
uint32_t framerate_fps = GetInputFramerateFps();
|
||||||
frame_cadence_adapter_->UpdateFrameRate();
|
frame_cadence_adapter_->UpdateFrameRate();
|
||||||
|
|
||||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
int64_t now_ms = env_.clock().TimeInMilliseconds();
|
||||||
if (pending_encoder_reconfiguration_) {
|
if (pending_encoder_reconfiguration_) {
|
||||||
ReconfigureEncoder();
|
ReconfigureEncoder();
|
||||||
last_parameters_update_ms_.emplace(now_ms);
|
last_parameters_update_ms_.emplace(now_ms);
|
||||||
|
@ -1936,7 +1935,7 @@ void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
encoder_info_ = info;
|
encoder_info_ = info;
|
||||||
last_encode_info_ms_ = clock_->TimeInMilliseconds();
|
last_encode_info_ms_ = env_.clock().TimeInMilliseconds();
|
||||||
|
|
||||||
VideoFrame out_frame(video_frame);
|
VideoFrame out_frame(video_frame);
|
||||||
// Crop or scale the frame if needed. Dimension may be reduced to fit encoder
|
// Crop or scale the frame if needed. Dimension may be reduced to fit encoder
|
||||||
|
@ -2198,7 +2197,7 @@ EncodedImageCallback::Result VideoStreamEncoder::OnEncodedImage(
|
||||||
temporal_index = 0;
|
temporal_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RunPostEncode(image_copy, clock_->CurrentTime().us(), temporal_index,
|
RunPostEncode(image_copy, env_.clock().CurrentTime().us(), temporal_index,
|
||||||
frame_size);
|
frame_size);
|
||||||
|
|
||||||
if (result.error == Result::OK) {
|
if (result.error == Result::OK) {
|
||||||
|
@ -2319,7 +2318,7 @@ void VideoStreamEncoder::OnBitrateUpdated(DataRate target_bitrate,
|
||||||
!DropDueToSize(pending_frame_->size())) {
|
!DropDueToSize(pending_frame_->size())) {
|
||||||
// A pending stored frame can be processed.
|
// A pending stored frame can be processed.
|
||||||
int64_t pending_time_us =
|
int64_t pending_time_us =
|
||||||
clock_->CurrentTime().us() - pending_frame_post_time_us_;
|
env_.clock().CurrentTime().us() - pending_frame_post_time_us_;
|
||||||
if (pending_time_us < kPendingFrameTimeoutMs * 1000)
|
if (pending_time_us < kPendingFrameTimeoutMs * 1000)
|
||||||
EncodeVideoFrame(*pending_frame_, pending_frame_post_time_us_);
|
EncodeVideoFrame(*pending_frame_, pending_frame_post_time_us_);
|
||||||
pending_frame_.reset();
|
pending_frame_.reset();
|
||||||
|
@ -2450,8 +2449,8 @@ VideoStreamEncoder::AutomaticAnimationDetectionExperiment
|
||||||
VideoStreamEncoder::ParseAutomatincAnimationDetectionFieldTrial() const {
|
VideoStreamEncoder::ParseAutomatincAnimationDetectionFieldTrial() const {
|
||||||
AutomaticAnimationDetectionExperiment result;
|
AutomaticAnimationDetectionExperiment result;
|
||||||
|
|
||||||
result.Parser()->Parse(
|
result.Parser()->Parse(env_.field_trials().Lookup(
|
||||||
field_trials_.Lookup("WebRTC-AutomaticAnimationDetectionScreenshare"));
|
"WebRTC-AutomaticAnimationDetectionScreenshare"));
|
||||||
|
|
||||||
if (!result.enabled) {
|
if (!result.enabled) {
|
||||||
RTC_LOG(LS_INFO) << "Automatic animation detection experiment is disabled.";
|
RTC_LOG(LS_INFO) << "Automatic animation detection experiment is disabled.";
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "absl/container/inlined_vector.h"
|
#include "absl/container/inlined_vector.h"
|
||||||
#include "api/adaptation/resource.h"
|
#include "api/adaptation/resource.h"
|
||||||
#include "api/field_trials_view.h"
|
#include "api/environment/environment.h"
|
||||||
#include "api/rtp_sender_interface.h"
|
#include "api/rtp_sender_interface.h"
|
||||||
#include "api/sequence_checker.h"
|
#include "api/sequence_checker.h"
|
||||||
#include "api/task_queue/pending_task_safety_flag.h"
|
#include "api/task_queue/pending_task_safety_flag.h"
|
||||||
|
@ -43,7 +43,6 @@
|
||||||
#include "rtc_base/race_checker.h"
|
#include "rtc_base/race_checker.h"
|
||||||
#include "rtc_base/rate_statistics.h"
|
#include "rtc_base/rate_statistics.h"
|
||||||
#include "rtc_base/thread_annotations.h"
|
#include "rtc_base/thread_annotations.h"
|
||||||
#include "system_wrappers/include/clock.h"
|
|
||||||
#include "video/adaptation/video_stream_encoder_resource_manager.h"
|
#include "video/adaptation/video_stream_encoder_resource_manager.h"
|
||||||
#include "video/encoder_bitrate_adjuster.h"
|
#include "video/encoder_bitrate_adjuster.h"
|
||||||
#include "video/frame_cadence_adapter.h"
|
#include "video/frame_cadence_adapter.h"
|
||||||
|
@ -74,7 +73,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
|
||||||
kVideoLayersAllocation
|
kVideoLayersAllocation
|
||||||
};
|
};
|
||||||
VideoStreamEncoder(
|
VideoStreamEncoder(
|
||||||
Clock* clock,
|
const Environment& env,
|
||||||
uint32_t number_of_cores,
|
uint32_t number_of_cores,
|
||||||
VideoStreamEncoderObserver* encoder_stats_observer,
|
VideoStreamEncoderObserver* encoder_stats_observer,
|
||||||
const VideoStreamEncoderSettings& settings,
|
const VideoStreamEncoderSettings& settings,
|
||||||
|
@ -83,7 +82,6 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
|
||||||
std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter>
|
std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter>
|
||||||
encoder_queue,
|
encoder_queue,
|
||||||
BitrateAllocationCallbackType allocation_cb_type,
|
BitrateAllocationCallbackType allocation_cb_type,
|
||||||
const FieldTrialsView& field_trials,
|
|
||||||
webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector =
|
webrtc::VideoEncoderFactory::EncoderSelectorInterface* encoder_selector =
|
||||||
nullptr);
|
nullptr);
|
||||||
~VideoStreamEncoder() override;
|
~VideoStreamEncoder() override;
|
||||||
|
@ -270,7 +268,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
|
||||||
VideoStreamEncoderObserver::DropReason reason)
|
VideoStreamEncoderObserver::DropReason reason)
|
||||||
RTC_RUN_ON(encoder_queue_);
|
RTC_RUN_ON(encoder_queue_);
|
||||||
|
|
||||||
const FieldTrialsView& field_trials_;
|
const Environment env_;
|
||||||
TaskQueueBase* const worker_queue_;
|
TaskQueueBase* const worker_queue_;
|
||||||
|
|
||||||
const int number_of_cores_;
|
const int number_of_cores_;
|
||||||
|
@ -331,7 +329,6 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
|
||||||
RTC_GUARDED_BY(encoder_queue_) = false;
|
RTC_GUARDED_BY(encoder_queue_) = false;
|
||||||
|
|
||||||
bool encoder_failed_ RTC_GUARDED_BY(encoder_queue_) = false;
|
bool encoder_failed_ RTC_GUARDED_BY(encoder_queue_) = false;
|
||||||
Clock* const clock_;
|
|
||||||
|
|
||||||
// Used to make sure incoming time stamp is increasing for every frame.
|
// Used to make sure incoming time stamp is increasing for every frame.
|
||||||
int64_t last_captured_timestamp_ RTC_GUARDED_BY(encoder_queue_) = 0;
|
int64_t last_captured_timestamp_ RTC_GUARDED_BY(encoder_queue_) = 0;
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
|
#include "api/environment/environment.h"
|
||||||
|
#include "api/environment/environment_factory.h"
|
||||||
#include "api/field_trials_view.h"
|
#include "api/field_trials_view.h"
|
||||||
#include "api/rtp_parameters.h"
|
#include "api/rtp_parameters.h"
|
||||||
#include "api/task_queue/default_task_queue_factory.h"
|
#include "api/task_queue/default_task_queue_factory.h"
|
||||||
|
@ -381,17 +383,17 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
|
||||||
allocation_callback_type,
|
allocation_callback_type,
|
||||||
const FieldTrialsView& field_trials,
|
const FieldTrialsView& field_trials,
|
||||||
int num_cores)
|
int num_cores)
|
||||||
: VideoStreamEncoder(time_controller->GetClock(),
|
: VideoStreamEncoder(
|
||||||
num_cores,
|
CreateEnvironment(&field_trials, time_controller->GetClock()),
|
||||||
stats_proxy,
|
num_cores,
|
||||||
settings,
|
stats_proxy,
|
||||||
std::unique_ptr<OveruseFrameDetector>(
|
settings,
|
||||||
overuse_detector_proxy_ =
|
std::unique_ptr<OveruseFrameDetector>(
|
||||||
new CpuOveruseDetectorProxy(stats_proxy)),
|
overuse_detector_proxy_ =
|
||||||
std::move(cadence_adapter),
|
new CpuOveruseDetectorProxy(stats_proxy)),
|
||||||
std::move(encoder_queue),
|
std::move(cadence_adapter),
|
||||||
allocation_callback_type,
|
std::move(encoder_queue),
|
||||||
field_trials),
|
allocation_callback_type),
|
||||||
time_controller_(time_controller),
|
time_controller_(time_controller),
|
||||||
fake_cpu_resource_(FakeResource::Create("FakeResource[CPU]")),
|
fake_cpu_resource_(FakeResource::Create("FakeResource[CPU]")),
|
||||||
fake_quality_resource_(FakeResource::Create("FakeResource[QP]")),
|
fake_quality_resource_(FakeResource::Create("FakeResource[QP]")),
|
||||||
|
@ -693,15 +695,15 @@ class SimpleVideoStreamEncoderFactory {
|
||||||
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> encoder_queue,
|
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> encoder_queue,
|
||||||
const FieldTrialsView* field_trials = nullptr) {
|
const FieldTrialsView* field_trials = nullptr) {
|
||||||
auto result = std::make_unique<AdaptedVideoStreamEncoder>(
|
auto result = std::make_unique<AdaptedVideoStreamEncoder>(
|
||||||
time_controller_.GetClock(),
|
CreateEnvironment(&field_trials_, field_trials,
|
||||||
|
time_controller_.GetClock()),
|
||||||
/*number_of_cores=*/1,
|
/*number_of_cores=*/1,
|
||||||
/*stats_proxy=*/stats_proxy_.get(), encoder_settings_,
|
/*stats_proxy=*/stats_proxy_.get(), encoder_settings_,
|
||||||
std::make_unique<CpuOveruseDetectorProxy>(
|
std::make_unique<CpuOveruseDetectorProxy>(
|
||||||
/*stats_proxy=*/nullptr),
|
/*stats_proxy=*/nullptr),
|
||||||
std::move(zero_hertz_adapter), std::move(encoder_queue),
|
std::move(zero_hertz_adapter), std::move(encoder_queue),
|
||||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||||
kVideoBitrateAllocation,
|
kVideoBitrateAllocation);
|
||||||
field_trials ? *field_trials : field_trials_);
|
|
||||||
result->SetSink(&sink_, /*rotation_applied=*/false);
|
result->SetSink(&sink_, /*rotation_applied=*/false);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -9230,11 +9232,12 @@ TEST(VideoStreamEncoderSimpleTest, CreateDestroy) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lots of boiler plate.
|
// Lots of boiler plate.
|
||||||
test::ScopedKeyValueConfig field_trials;
|
|
||||||
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
|
GlobalSimulatedTimeController time_controller(Timestamp::Zero());
|
||||||
auto stats_proxy = std::make_unique<MockableSendStatisticsProxy>(
|
Environment env = CreateEnvironment(time_controller.GetClock());
|
||||||
time_controller.GetClock(), VideoSendStream::Config(nullptr),
|
MockableSendStatisticsProxy stats_proxy(
|
||||||
webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials);
|
&env.clock(), VideoSendStream::Config(nullptr),
|
||||||
|
webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
|
||||||
|
env.field_trials());
|
||||||
SimpleVideoStreamEncoderFactory::MockFakeEncoder mock_fake_encoder(
|
SimpleVideoStreamEncoderFactory::MockFakeEncoder mock_fake_encoder(
|
||||||
time_controller.GetClock());
|
time_controller.GetClock());
|
||||||
test::VideoEncoderProxyFactory encoder_factory(&mock_fake_encoder);
|
test::VideoEncoderProxyFactory encoder_factory(&mock_fake_encoder);
|
||||||
|
@ -9252,20 +9255,19 @@ TEST(VideoStreamEncoderSimpleTest, CreateDestroy) {
|
||||||
encoder_queue(new SuperLazyTaskQueue());
|
encoder_queue(new SuperLazyTaskQueue());
|
||||||
|
|
||||||
// Construct a VideoStreamEncoder instance and let it go out of scope without
|
// Construct a VideoStreamEncoder instance and let it go out of scope without
|
||||||
// doing anything else (including calling Stop()). This should be fine since
|
// doing anything else. This should be fine since the posted init task will
|
||||||
// the posted init task will simply be deleted.
|
// simply be deleted.
|
||||||
auto encoder = std::make_unique<VideoStreamEncoder>(
|
VideoStreamEncoder encoder(
|
||||||
time_controller.GetClock(), 1, stats_proxy.get(), encoder_settings,
|
env, 1, &stats_proxy, encoder_settings,
|
||||||
std::make_unique<CpuOveruseDetectorProxy>(stats_proxy.get()),
|
std::make_unique<CpuOveruseDetectorProxy>(&stats_proxy),
|
||||||
std::move(adapter), std::move(encoder_queue),
|
std::move(adapter), std::move(encoder_queue),
|
||||||
VideoStreamEncoder::BitrateAllocationCallbackType::
|
VideoStreamEncoder::BitrateAllocationCallbackType::
|
||||||
kVideoBitrateAllocation,
|
kVideoBitrateAllocation);
|
||||||
field_trials);
|
|
||||||
|
|
||||||
// Stop the encoder explicitly. This additional step tests if we could
|
// Stop the encoder explicitly. This additional step tests if we could
|
||||||
// hang when calling stop and the TQ has been stopped and/or isn't accepting
|
// hang when calling stop and the TQ has been stopped and/or isn't accepting
|
||||||
// any more tasks.
|
// any more tasks.
|
||||||
encoder->Stop();
|
encoder.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VideoStreamEncoderFrameCadenceTest, ActivatesFrameCadenceOnContentType) {
|
TEST(VideoStreamEncoderFrameCadenceTest, ActivatesFrameCadenceOnContentType) {
|
||||||
|
|
Loading…
Reference in a new issue