mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Propagate Environment through SimulcastEncoderAdapter when provided
Bug: webrtc:15860 Change-Id: Iabd7752ada2f8f774de1e2adc02a4157004bf43c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342720 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Florent Castelli <orphis@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41893}
This commit is contained in:
parent
b8abf5199a
commit
2725317b1f
15 changed files with 170 additions and 89 deletions
|
@ -139,10 +139,7 @@ rtc_library("builtin_video_decoder_factory") {
|
|||
|
||||
rtc_library("builtin_video_encoder_factory") {
|
||||
visibility = [ "*" ]
|
||||
allow_poison = [
|
||||
"audio_codecs", # TODO(bugs.webrtc.org/8396): Remove.
|
||||
"software_video_codecs",
|
||||
]
|
||||
allow_poison = [ "software_video_codecs" ]
|
||||
sources = [
|
||||
"builtin_video_encoder_factory.cc",
|
||||
"builtin_video_encoder_factory.h",
|
||||
|
@ -150,13 +147,11 @@ rtc_library("builtin_video_encoder_factory") {
|
|||
|
||||
deps = [
|
||||
":video_codecs_api",
|
||||
"../../api:scoped_refptr",
|
||||
"../../media:codec",
|
||||
"../../media:media_constants",
|
||||
"../../media:rtc_internal_video_codecs",
|
||||
"../../media:rtc_simulcast_encoder_adapter",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base/system:rtc_export",
|
||||
"../environment",
|
||||
"../transport:field_trial_based_config",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
|
|
|
@ -14,15 +14,14 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "media/base/codec.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "api/video_codecs/video_encoder_factory.h"
|
||||
#include "media/engine/internal_encoder_factory.h"
|
||||
#include "media/engine/simulcast_encoder_adapter.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -43,12 +42,29 @@ class BuiltinVideoEncoderFactory : public VideoEncoderFactory {
|
|||
if (format.IsCodecInList(
|
||||
internal_encoder_factory_->GetSupportedFormats())) {
|
||||
encoder = std::make_unique<SimulcastEncoderAdapter>(
|
||||
internal_encoder_factory_.get(), format);
|
||||
/*primary_factory=*/internal_encoder_factory_.get(),
|
||||
/*fallback_factory=*/nullptr, format, FieldTrialBasedConfig());
|
||||
}
|
||||
|
||||
return encoder;
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoEncoder> Create(const Environment& env,
|
||||
const SdpVideoFormat& format) override {
|
||||
// Try creating an InternalEncoderFactory-backed SimulcastEncoderAdapter.
|
||||
// The adapter has a passthrough mode for the case that simulcast is not
|
||||
// used, so all responsibility can be delegated to it.
|
||||
if (format.IsCodecInList(
|
||||
internal_encoder_factory_->GetSupportedFormats())) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
env,
|
||||
/*primary_factory=*/internal_encoder_factory_.get(),
|
||||
/*fallback_factory=*/nullptr, format);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<SdpVideoFormat> GetSupportedFormats() const override {
|
||||
return internal_encoder_factory_->GetSupportedFormats();
|
||||
}
|
||||
|
|
|
@ -1186,9 +1186,10 @@ void CallPerfTest::TestEncodeFramerate(VideoEncoderFactory* encoder_factory,
|
|||
TEST_F(CallPerfTest, TestEncodeFramerateVp8Simulcast) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestEncodeFramerate(&encoder_factory, "VP8",
|
||||
|
@ -1198,9 +1199,10 @@ TEST_F(CallPerfTest, TestEncodeFramerateVp8Simulcast) {
|
|||
TEST_F(CallPerfTest, TestEncodeFramerateVp8SimulcastLowerInputFps) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestEncodeFramerate(&encoder_factory, "VP8",
|
||||
|
|
|
@ -464,6 +464,7 @@ rtc_library("rtc_simulcast_encoder_adapter") {
|
|||
"../api:field_trials_view",
|
||||
"../api:scoped_refptr",
|
||||
"../api:sequence_checker",
|
||||
"../api/environment",
|
||||
"../api/transport:field_trial_based_config",
|
||||
"../api/video:video_codec_constants",
|
||||
"../api/video:video_frame",
|
||||
|
@ -485,6 +486,7 @@ rtc_library("rtc_simulcast_encoder_adapter") {
|
|||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/base:nullability",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
@ -807,6 +809,7 @@ if (rtc_include_tests) {
|
|||
"../api:fec_controller_api",
|
||||
"../api:rtp_parameters",
|
||||
"../api:scoped_refptr",
|
||||
"../api/environment",
|
||||
"../api/task_queue",
|
||||
"../api/task_queue:pending_task_safety_flag",
|
||||
"../api/transport:field_trial_based_config",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "media/base/codec.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "media/engine/simulcast_encoder_adapter.h"
|
||||
|
@ -24,6 +25,8 @@ namespace cricket {
|
|||
|
||||
namespace {
|
||||
|
||||
using ::webrtc::Environment;
|
||||
|
||||
static constexpr webrtc::TimeDelta kEventTimeout =
|
||||
webrtc::TimeDelta::Seconds(10);
|
||||
|
||||
|
@ -232,8 +235,8 @@ FakeWebRtcVideoEncoderFactory::QueryCodecSupport(
|
|||
return {.is_supported = false};
|
||||
}
|
||||
|
||||
std::unique_ptr<webrtc::VideoEncoder>
|
||||
FakeWebRtcVideoEncoderFactory::CreateVideoEncoder(
|
||||
std::unique_ptr<webrtc::VideoEncoder> FakeWebRtcVideoEncoderFactory::Create(
|
||||
const Environment& env,
|
||||
const webrtc::SdpVideoFormat& format) {
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
std::unique_ptr<webrtc::VideoEncoder> encoder;
|
||||
|
@ -244,7 +247,8 @@ FakeWebRtcVideoEncoderFactory::CreateVideoEncoder(
|
|||
// encoders. Enter vp8_factory_mode so that we now create these encoders
|
||||
// instead of more adapters.
|
||||
vp8_factory_mode_ = true;
|
||||
encoder = std::make_unique<webrtc::SimulcastEncoderAdapter>(this, format);
|
||||
encoder = std::make_unique<webrtc::SimulcastEncoderAdapter>(
|
||||
env, /*primary_factory=*/this, /*fallback_factory=*/nullptr, format);
|
||||
} else {
|
||||
num_created_encoders_++;
|
||||
created_video_encoder_event_.Set();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/fec_controller_override.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "api/video/video_bitrate_allocation.h"
|
||||
|
@ -118,7 +119,8 @@ class FakeWebRtcVideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
|||
webrtc::VideoEncoderFactory::CodecSupport QueryCodecSupport(
|
||||
const webrtc::SdpVideoFormat& format,
|
||||
absl::optional<std::string> scalability_mode) const override;
|
||||
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
|
||||
std::unique_ptr<webrtc::VideoEncoder> Create(
|
||||
const webrtc::Environment& env,
|
||||
const webrtc::SdpVideoFormat& format) override;
|
||||
|
||||
bool WaitForCreatedVideoEncoders(int num_encoders);
|
||||
|
|
|
@ -246,10 +246,22 @@ void SimulcastEncoderAdapter::StreamContext::OnDroppedFrame(
|
|||
parent_->OnDroppedFrame(stream_idx_);
|
||||
}
|
||||
|
||||
SimulcastEncoderAdapter::SimulcastEncoderAdapter(
|
||||
const Environment& env,
|
||||
absl::Nonnull<VideoEncoderFactory*> primary_factory,
|
||||
absl::Nullable<VideoEncoderFactory*> fallback_factory,
|
||||
const SdpVideoFormat& format)
|
||||
: SimulcastEncoderAdapter(&env,
|
||||
primary_factory,
|
||||
fallback_factory,
|
||||
format,
|
||||
env.field_trials()) {}
|
||||
|
||||
SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory,
|
||||
const SdpVideoFormat& format)
|
||||
: SimulcastEncoderAdapter(factory,
|
||||
nullptr,
|
||||
: SimulcastEncoderAdapter(/*env=*/nullptr,
|
||||
/*primary_factory=*/factory,
|
||||
/*fallback_factory=*/nullptr,
|
||||
format,
|
||||
FieldTrialBasedConfig()) {}
|
||||
|
||||
|
@ -258,7 +270,20 @@ SimulcastEncoderAdapter::SimulcastEncoderAdapter(
|
|||
VideoEncoderFactory* fallback_factory,
|
||||
const SdpVideoFormat& format,
|
||||
const FieldTrialsView& field_trials)
|
||||
: inited_(0),
|
||||
: SimulcastEncoderAdapter(/*env=*/nullptr,
|
||||
primary_factory,
|
||||
fallback_factory,
|
||||
format,
|
||||
field_trials) {}
|
||||
|
||||
SimulcastEncoderAdapter::SimulcastEncoderAdapter(
|
||||
absl::Nullable<const Environment*> env,
|
||||
absl::Nonnull<VideoEncoderFactory*> primary_factory,
|
||||
absl::Nullable<VideoEncoderFactory*> fallback_factory,
|
||||
const SdpVideoFormat& format,
|
||||
const FieldTrialsView& field_trials)
|
||||
: env_(env != nullptr ? absl::make_optional(*env) : absl::nullopt),
|
||||
inited_(0),
|
||||
primary_encoder_factory_(primary_factory),
|
||||
fallback_encoder_factory_(fallback_factory),
|
||||
video_format_(format),
|
||||
|
@ -744,12 +769,16 @@ SimulcastEncoderAdapter::FetchOrCreateEncoderContext(
|
|||
cached_encoder_contexts_.erase(encoder_context_iter);
|
||||
} else {
|
||||
std::unique_ptr<VideoEncoder> primary_encoder =
|
||||
primary_encoder_factory_->CreateVideoEncoder(video_format_);
|
||||
env_.has_value()
|
||||
? primary_encoder_factory_->Create(*env_, video_format_)
|
||||
: primary_encoder_factory_->CreateVideoEncoder(video_format_);
|
||||
|
||||
std::unique_ptr<VideoEncoder> fallback_encoder;
|
||||
if (fallback_encoder_factory_ != nullptr) {
|
||||
fallback_encoder =
|
||||
fallback_encoder_factory_->CreateVideoEncoder(video_format_);
|
||||
env_.has_value()
|
||||
? fallback_encoder_factory_->Create(*env_, video_format_)
|
||||
: fallback_encoder_factory_->CreateVideoEncoder(video_format_);
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoEncoder> encoder;
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/nullability.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/fec_controller_override.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/sequence_checker.h"
|
||||
|
@ -41,12 +43,19 @@ namespace webrtc {
|
|||
// interfaces should be called from the encoder task queue.
|
||||
class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder {
|
||||
public:
|
||||
// TODO(bugs.webrtc.org/11000): Remove when downstream usage is gone.
|
||||
SimulcastEncoderAdapter(VideoEncoderFactory* primarty_factory,
|
||||
const SdpVideoFormat& format);
|
||||
// `primary_factory` produces the first-choice encoders to use.
|
||||
// `fallback_factory`, if non-null, is used to create fallback encoder that
|
||||
// will be used if InitEncode() fails for the primary encoder.
|
||||
SimulcastEncoderAdapter(const Environment& env,
|
||||
absl::Nonnull<VideoEncoderFactory*> primary_factory,
|
||||
absl::Nullable<VideoEncoderFactory*> fallback_factory,
|
||||
const SdpVideoFormat& format);
|
||||
|
||||
[[deprecated("bugs.webrtc.org/15860")]] SimulcastEncoderAdapter(
|
||||
VideoEncoderFactory* primarty_factory,
|
||||
const SdpVideoFormat& format);
|
||||
|
||||
// TODO: bugs.webrtc.org/15860 - Deprecate or delete when not used by chromium
|
||||
SimulcastEncoderAdapter(VideoEncoderFactory* primary_factory,
|
||||
VideoEncoderFactory* fallback_factory,
|
||||
const SdpVideoFormat& format,
|
||||
|
@ -144,6 +153,12 @@ class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder {
|
|||
bool is_paused_;
|
||||
};
|
||||
|
||||
SimulcastEncoderAdapter(absl::Nullable<const Environment*> env,
|
||||
absl::Nonnull<VideoEncoderFactory*> primary_factory,
|
||||
absl::Nullable<VideoEncoderFactory*> fallback_factory,
|
||||
const SdpVideoFormat& format,
|
||||
const FieldTrialsView& field_trials);
|
||||
|
||||
bool Initialized() const;
|
||||
|
||||
void DestroyStoredEncoders();
|
||||
|
@ -169,6 +184,9 @@ class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder {
|
|||
|
||||
void OverrideFromFieldTrial(VideoEncoder::EncoderInfo* info) const;
|
||||
|
||||
// TODO: bugs.webrtc.org/15860 - Make env_ non optional when deprecated
|
||||
// constructors are deleted.
|
||||
const absl::optional<Environment> env_;
|
||||
std::atomic<int> inited_;
|
||||
VideoEncoderFactory* const primary_encoder_factory_;
|
||||
VideoEncoderFactory* const fallback_encoder_factory_;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/test/create_simulcast_test_fixture.h"
|
||||
#include "api/test/simulcast_test_fixture.h"
|
||||
|
@ -56,9 +57,10 @@ std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture(
|
|||
VideoEncoderFactory* internal_encoder_factory) {
|
||||
std::unique_ptr<VideoEncoderFactory> encoder_factory =
|
||||
std::make_unique<FunctionVideoEncoderFactory>(
|
||||
[internal_encoder_factory]() {
|
||||
[internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
std::unique_ptr<VideoDecoderFactory> decoder_factory =
|
||||
std::make_unique<FunctionVideoDecoderFactory>(
|
||||
|
@ -403,33 +405,30 @@ void MockVideoEncoderFactory::set_init_encode_return_value(int32_t value) {
|
|||
class TestSimulcastEncoderAdapterFakeHelper {
|
||||
public:
|
||||
explicit TestSimulcastEncoderAdapterFakeHelper(
|
||||
const Environment& env,
|
||||
bool use_fallback_factory,
|
||||
const SdpVideoFormat& video_format,
|
||||
const FieldTrialsView& field_trials)
|
||||
: primary_factory_(new MockVideoEncoderFactory()),
|
||||
fallback_factory_(use_fallback_factory ? new MockVideoEncoderFactory()
|
||||
: nullptr),
|
||||
video_format_(video_format),
|
||||
field_trials_(field_trials) {}
|
||||
const SdpVideoFormat& video_format)
|
||||
: env_(env),
|
||||
fallback_factory_(use_fallback_factory
|
||||
? std::make_unique<MockVideoEncoderFactory>()
|
||||
: nullptr),
|
||||
video_format_(video_format) {}
|
||||
|
||||
// Can only be called once as the SimulcastEncoderAdapter will take the
|
||||
// ownership of `factory_`.
|
||||
VideoEncoder* CreateMockEncoderAdapter() {
|
||||
return new SimulcastEncoderAdapter(primary_factory_.get(),
|
||||
fallback_factory_.get(), video_format_,
|
||||
field_trials_);
|
||||
std::unique_ptr<VideoEncoder> CreateMockEncoderAdapter() {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
env_, &primary_factory_, fallback_factory_.get(), video_format_);
|
||||
}
|
||||
|
||||
MockVideoEncoderFactory* factory() { return primary_factory_.get(); }
|
||||
MockVideoEncoderFactory* factory() { return &primary_factory_; }
|
||||
MockVideoEncoderFactory* fallback_factory() {
|
||||
return fallback_factory_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<MockVideoEncoderFactory> primary_factory_;
|
||||
const Environment env_;
|
||||
MockVideoEncoderFactory primary_factory_;
|
||||
std::unique_ptr<MockVideoEncoderFactory> fallback_factory_;
|
||||
SdpVideoFormat video_format_;
|
||||
const FieldTrialsView& field_trials_;
|
||||
};
|
||||
|
||||
static const int kTestTemporalLayerProfile[3] = {3, 2, 1};
|
||||
|
@ -446,10 +445,10 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
|
|||
}
|
||||
|
||||
void SetUp() override {
|
||||
helper_.reset(new TestSimulcastEncoderAdapterFakeHelper(
|
||||
use_fallback_factory_, SdpVideoFormat("VP8", sdp_video_parameters_),
|
||||
field_trials_));
|
||||
adapter_.reset(helper_->CreateMockEncoderAdapter());
|
||||
helper_ = std::make_unique<TestSimulcastEncoderAdapterFakeHelper>(
|
||||
CreateEnvironment(&field_trials_), use_fallback_factory_,
|
||||
SdpVideoFormat("VP8", sdp_video_parameters_));
|
||||
adapter_ = helper_->CreateMockEncoderAdapter();
|
||||
last_encoded_image_width_ = absl::nullopt;
|
||||
last_encoded_image_height_ = absl::nullopt;
|
||||
last_encoded_image_simulcast_index_ = absl::nullopt;
|
||||
|
|
|
@ -363,13 +363,12 @@ TEST(VideoCodecTestLibvpx, MAYBE_SimulcastVP8) {
|
|||
config.encoded_frame_checker = frame_checker.get();
|
||||
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
std::unique_ptr<VideoEncoderFactory> adapted_encoder_factory =
|
||||
std::make_unique<FunctionVideoEncoderFactory>([&]() {
|
||||
auto adapted_encoder_factory = std::make_unique<FunctionVideoEncoderFactory>(
|
||||
[&](const Environment& env, const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
std::unique_ptr<InternalDecoderFactory> internal_decoder_factory(
|
||||
new InternalDecoderFactory());
|
||||
auto internal_decoder_factory = std::make_unique<InternalDecoderFactory>();
|
||||
|
||||
auto fixture =
|
||||
CreateVideoCodecTestFixture(config, std::move(internal_decoder_factory),
|
||||
|
|
|
@ -2754,6 +2754,7 @@ if (rtc_include_tests && !build_with_chromium) {
|
|||
"../api:sequence_checker",
|
||||
"../api/audio:audio_mixer_api",
|
||||
"../api/audio_codecs:audio_codecs_api",
|
||||
"../api/environment",
|
||||
"../api/environment:environment_factory",
|
||||
"../api/task_queue",
|
||||
"../api/task_queue:default_task_queue_factory",
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "absl/types/optional.h"
|
||||
#include "api/audio/audio_mixer.h"
|
||||
#include "api/create_peerconnection_factory.h"
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/media_types.h"
|
||||
#include "api/sequence_checker.h"
|
||||
#include "api/video_codecs/video_decoder_factory.h"
|
||||
|
@ -50,18 +51,20 @@
|
|||
#include "rtc_base/time_utils.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
using webrtc::FakeVideoTrackRenderer;
|
||||
using webrtc::IceCandidateInterface;
|
||||
using webrtc::MediaStreamInterface;
|
||||
using webrtc::MediaStreamTrackInterface;
|
||||
using webrtc::MockSetSessionDescriptionObserver;
|
||||
using webrtc::PeerConnectionInterface;
|
||||
using webrtc::RtpReceiverInterface;
|
||||
using webrtc::SdpType;
|
||||
using webrtc::SessionDescriptionInterface;
|
||||
using webrtc::VideoTrackInterface;
|
||||
|
||||
namespace {
|
||||
|
||||
using ::webrtc::Environment;
|
||||
using ::webrtc::FakeVideoTrackRenderer;
|
||||
using ::webrtc::IceCandidateInterface;
|
||||
using ::webrtc::MediaStreamInterface;
|
||||
using ::webrtc::MediaStreamTrackInterface;
|
||||
using ::webrtc::MockSetSessionDescriptionObserver;
|
||||
using ::webrtc::PeerConnectionInterface;
|
||||
using ::webrtc::RtpReceiverInterface;
|
||||
using ::webrtc::SdpType;
|
||||
using ::webrtc::SessionDescriptionInterface;
|
||||
using ::webrtc::VideoTrackInterface;
|
||||
|
||||
const char kStreamIdBase[] = "stream_id";
|
||||
const char kVideoTrackLabelBase[] = "video_track";
|
||||
const char kAudioTrackLabelBase[] = "audio_track";
|
||||
|
@ -75,13 +78,14 @@ class FuzzyMatchedVideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
|||
return factory_.GetSupportedFormats();
|
||||
}
|
||||
|
||||
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
|
||||
std::unique_ptr<webrtc::VideoEncoder> Create(
|
||||
const Environment& env,
|
||||
const webrtc::SdpVideoFormat& format) override {
|
||||
if (absl::optional<webrtc::SdpVideoFormat> original_format =
|
||||
webrtc::FuzzyMatchSdpVideoFormat(factory_.GetSupportedFormats(),
|
||||
format)) {
|
||||
return std::make_unique<webrtc::SimulcastEncoderAdapter>(
|
||||
&factory_, *original_format);
|
||||
env, &factory_, nullptr, *original_format);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
|
@ -388,9 +388,10 @@ TEST_P(PictureIdTest, ContinuousAfterStreamCountChangeVp8) {
|
|||
TEST_P(PictureIdTest, ContinuousAfterReconfigureSimulcastEncoderAdapter) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
SetupEncoder(&encoder_factory, "VP8");
|
||||
TestPictureIdContinuousAfterReconfigure({1, 3, 3, 1, 1});
|
||||
|
@ -401,9 +402,10 @@ TEST_P(PictureIdTest,
|
|||
DISABLED_IncreasingAfterRecreateStreamSimulcastEncoderAdapter) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
SetupEncoder(&encoder_factory, "VP8");
|
||||
TestPictureIdIncreaseAfterRecreateStreams({1, 3, 3, 1, 1});
|
||||
|
@ -412,9 +414,10 @@ TEST_P(PictureIdTest,
|
|||
TEST_P(PictureIdTest, ContinuousAfterStreamCountChangeSimulcastEncoderAdapter) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
// Make sure that the picture id is not reset if the stream count goes
|
||||
// down and then up.
|
||||
|
|
|
@ -317,8 +317,8 @@ std::unique_ptr<VideoEncoder> VideoQualityTest::CreateVideoEncoder(
|
|||
VideoAnalyzer* analyzer) {
|
||||
std::unique_ptr<VideoEncoder> encoder;
|
||||
if (format.name == "VP8") {
|
||||
encoder = std::make_unique<SimulcastEncoderAdapter>(encoder_factory_.get(),
|
||||
format);
|
||||
encoder = std::make_unique<SimulcastEncoderAdapter>(
|
||||
env, encoder_factory_.get(), nullptr, format);
|
||||
} else if (format.name == "FakeCodec") {
|
||||
encoder = webrtc::FakeVideoEncoderFactory::CreateVideoEncoder();
|
||||
} else {
|
||||
|
|
|
@ -4212,9 +4212,10 @@ void VideoSendStreamTest::TestTemporalLayers(
|
|||
TEST_F(VideoSendStreamTest, TestTemporalLayersVp8) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestTemporalLayers(&encoder_factory, "VP8",
|
||||
|
@ -4225,9 +4226,10 @@ TEST_F(VideoSendStreamTest, TestTemporalLayersVp8) {
|
|||
TEST_F(VideoSendStreamTest, TestTemporalLayersVp8Simulcast) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestTemporalLayers(&encoder_factory, "VP8",
|
||||
|
@ -4238,9 +4240,10 @@ TEST_F(VideoSendStreamTest, TestTemporalLayersVp8Simulcast) {
|
|||
TEST_F(VideoSendStreamTest, TestTemporalLayersVp8SimulcastWithDifferentNumTls) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestTemporalLayers(&encoder_factory, "VP8",
|
||||
|
@ -4260,9 +4263,10 @@ TEST_F(VideoSendStreamTest, TestTemporalLayersVp8SimulcastWithoutSimAdapter) {
|
|||
TEST_F(VideoSendStreamTest, TestScalabilityModeVp8L1T2) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestTemporalLayers(&encoder_factory, "VP8",
|
||||
|
@ -4272,9 +4276,10 @@ TEST_F(VideoSendStreamTest, TestScalabilityModeVp8L1T2) {
|
|||
TEST_F(VideoSendStreamTest, TestScalabilityModeVp8Simulcast) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestTemporalLayers(&encoder_factory, "VP8",
|
||||
|
@ -4285,9 +4290,10 @@ TEST_F(VideoSendStreamTest, TestScalabilityModeVp8Simulcast) {
|
|||
TEST_F(VideoSendStreamTest, TestScalabilityModeVp8SimulcastWithDifferentMode) {
|
||||
InternalEncoderFactory internal_encoder_factory;
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[&internal_encoder_factory]() {
|
||||
[&internal_encoder_factory](const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
return std::make_unique<SimulcastEncoderAdapter>(
|
||||
&internal_encoder_factory, SdpVideoFormat::VP8());
|
||||
env, &internal_encoder_factory, nullptr, SdpVideoFormat::VP8());
|
||||
});
|
||||
|
||||
TestTemporalLayers(&encoder_factory, "VP8",
|
||||
|
|
Loading…
Reference in a new issue