mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Reland "Use the factory instead of using the builtin code path in VideoCodecInitializer
"
Compared the original CL: https://webrtc-review.googlesource.com/c/src/+/94782 This new CL added backward compatible functions to WebRtcMediaEngineFactory so that internal projects will not be broken. Because of that, now we can revert all the changes to SDK and PeerConnection and do it in following CLs. This makes this CL cleaner. One temporary disadvantage of this is the media engine now need to take a dependency onto builtin video bitrate factory, but practically it just moved code around and should not result in a large binary size change. We can remove this dependency later if needed. Bug: webrtc:9513 Change-Id: I38708762ff365e4ca05974b99fac71edc739a756 Reviewed-on: https://webrtc-review.googlesource.com/c/109040 Commit-Queue: Jiawei Ou <ouj@fb.com> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25574}
This commit is contained in:
parent
0393c64af1
commit
c2ebe21ba9
42 changed files with 388 additions and 121 deletions
12
api/BUILD.gn
12
api/BUILD.gn
|
@ -545,6 +545,18 @@ if (rtc_include_tests) {
|
|||
]
|
||||
}
|
||||
|
||||
rtc_source_set("mock_video_bitrate_allocator_factory") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"test/mock_video_bitrate_allocator_factory.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../api/video:video_bitrate_allocator_factory",
|
||||
"../test:test_support",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_source_set("mock_video_codec_factory") {
|
||||
testonly = true
|
||||
sources = [
|
||||
|
|
37
api/test/mock_video_bitrate_allocator_factory.h
Normal file
37
api/test/mock_video_bitrate_allocator_factory.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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_TEST_MOCK_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
||||
#define API_TEST_MOCK_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "test/gmock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class MockVideoBitrateAllocatorFactory
|
||||
: public webrtc::VideoBitrateAllocatorFactory {
|
||||
public:
|
||||
virtual std::unique_ptr<VideoBitrateAllocator> CreateVideoBitrateAllocator(
|
||||
const VideoCodec& codec) {
|
||||
return std::unique_ptr<VideoBitrateAllocator>(
|
||||
CreateVideoBitrateAllocatorProxy(codec));
|
||||
}
|
||||
~MockVideoBitrateAllocatorFactory() { Die(); }
|
||||
MOCK_METHOD1(CreateVideoBitrateAllocatorProxy,
|
||||
VideoBitrateAllocator*(const VideoCodec&));
|
||||
MOCK_METHOD0(Die, void());
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_TEST_MOCK_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
|
@ -174,6 +174,7 @@ rtc_source_set("video_stream_encoder") {
|
|||
]
|
||||
|
||||
deps = [
|
||||
":video_bitrate_allocator_factory",
|
||||
":video_frame",
|
||||
|
||||
# For rtpparameters.h
|
||||
|
@ -204,3 +205,22 @@ rtc_source_set("video_stream_encoder_create") {
|
|||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_static_library("builtin_video_bitrate_allocator_factory") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"builtin_video_bitrate_allocator_factory.cc",
|
||||
"builtin_video_bitrate_allocator_factory.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":video_bitrate_allocation",
|
||||
":video_bitrate_allocator_factory",
|
||||
"../../media:rtc_media_base",
|
||||
"../../modules/video_coding:video_coding_utility",
|
||||
"../../modules/video_coding:webrtc_vp9_helpers",
|
||||
"../../rtc_base:ptr_util",
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "pc/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "media/base/codec.h"
|
|
@ -8,8 +8,8 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef PC_BUILTIN_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
||||
#define PC_BUILTIN_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
||||
#ifndef API_VIDEO_BUILTIN_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
||||
#define API_VIDEO_BUILTIN_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -22,4 +22,4 @@ CreateBuiltinVideoBitrateAllocatorFactory();
|
|||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // PC_BUILTIN_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
||||
#endif // API_VIDEO_BUILTIN_VIDEO_BITRATE_ALLOCATOR_FACTORY_H_
|
|
@ -11,6 +11,7 @@
|
|||
#ifndef API_VIDEO_VIDEO_STREAM_ENCODER_SETTINGS_H_
|
||||
#define API_VIDEO_VIDEO_STREAM_ENCODER_SETTINGS_H_
|
||||
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "api/video_codecs/video_encoder_factory.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
@ -24,6 +25,9 @@ struct VideoStreamEncoderSettings {
|
|||
|
||||
// Ownership stays with WebrtcVideoEngine (delegated from PeerConnection).
|
||||
VideoEncoderFactory* encoder_factory = nullptr;
|
||||
|
||||
// Ownership stays with WebrtcVideoEngine (delegated from PeerConnection).
|
||||
VideoBitrateAllocatorFactory* bitrate_allocator_factory = nullptr;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -390,6 +390,7 @@ if (rtc_include_tests) {
|
|||
"..:webrtc_common",
|
||||
"../api:simulated_network_api",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:video_bitrate_allocation",
|
||||
"../api/video_codecs:video_codecs_api",
|
||||
"../logging:rtc_event_log_api",
|
||||
|
|
|
@ -124,6 +124,8 @@ class BitrateEstimatorTest : public test::CallTest {
|
|||
video_send_config.rtp.ssrcs.push_back(kVideoSendSsrcs[0]);
|
||||
video_send_config.encoder_settings.encoder_factory =
|
||||
&fake_encoder_factory_;
|
||||
video_send_config.encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_.get();
|
||||
video_send_config.rtp.payload_name = "FAKE";
|
||||
video_send_config.rtp.payload_type = kFakeVideoSendPayloadType;
|
||||
SetVideoSendConfig(video_send_config);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "absl/memory/memory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video/video_bitrate_allocation.h"
|
||||
#include "api/video_codecs/video_encoder_config.h"
|
||||
#include "call/call.h"
|
||||
|
@ -729,7 +730,9 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
|||
last_set_bitrate_kbps_(0),
|
||||
send_stream_(nullptr),
|
||||
frame_generator_(nullptr),
|
||||
encoder_factory_(this) {}
|
||||
encoder_factory_(this),
|
||||
bitrate_allocator_factory_(
|
||||
CreateBuiltinVideoBitrateAllocatorFactory()) {}
|
||||
|
||||
int32_t InitEncode(const VideoCodec* config,
|
||||
int32_t number_of_cores,
|
||||
|
@ -776,6 +779,8 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
|||
std::vector<VideoReceiveStream::Config>* receive_configs,
|
||||
VideoEncoderConfig* encoder_config) override {
|
||||
send_config->encoder_settings.encoder_factory = &encoder_factory_;
|
||||
send_config->encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_.get();
|
||||
encoder_config->max_bitrate_bps = 2 * kReconfigureThresholdKbps * 1000;
|
||||
encoder_config->video_stream_factory =
|
||||
new rtc::RefCountedObject<VideoStreamFactory>();
|
||||
|
@ -811,6 +816,7 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
|||
VideoSendStream* send_stream_;
|
||||
test::FrameGeneratorCapturer* frame_generator_;
|
||||
test::VideoEncoderProxyFactory encoder_factory_;
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
||||
VideoEncoderConfig encoder_config_;
|
||||
} test;
|
||||
|
||||
|
|
|
@ -503,6 +503,7 @@ if (is_ios || (is_mac && target_cpu != "x86")) {
|
|||
"../api:libjingle_peerconnection_api",
|
||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../logging:rtc_event_log_impl_base",
|
||||
"../media:rtc_audio_video",
|
||||
"../modules/audio_processing:api",
|
||||
|
|
|
@ -49,6 +49,7 @@ if (is_android) {
|
|||
"//api:libjingle_peerconnection_api",
|
||||
"//api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"//api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"//api/video:builtin_video_bitrate_allocator_factory",
|
||||
"//logging:rtc_event_log_impl_base",
|
||||
"//media:rtc_audio_video",
|
||||
"//media:rtc_internal_video_codecs",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "api/peerconnectioninterface.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "examples/androidnativeapi/generated_jni/jni/CallClient_jni.h"
|
||||
#include "media/engine/internaldecoderfactory.h"
|
||||
#include "media/engine/internalencoderfactory.h"
|
||||
|
@ -159,6 +160,7 @@ void AndroidCallClient::CreatePeerConnectionFactory() {
|
|||
webrtc::CreateBuiltinAudioDecoderFactory(),
|
||||
absl::make_unique<webrtc::InternalEncoderFactory>(),
|
||||
absl::make_unique<webrtc::InternalDecoderFactory>(),
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory(),
|
||||
nullptr /* audio_mixer */, webrtc::AudioProcessingBuilder().Create());
|
||||
RTC_LOG(LS_INFO) << "Media engine created: " << media_engine.get();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "api/peerconnectioninterface.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "media/engine/webrtcmediaengine.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
#include "sdk/objc/native/api/video_capturer.h"
|
||||
|
@ -116,12 +117,16 @@ void ObjCCallClient::CreatePeerConnectionFactory() {
|
|||
std::unique_ptr<webrtc::VideoEncoderFactory> videoEncoderFactory =
|
||||
webrtc::ObjCToNativeVideoEncoderFactory([[RTCDefaultVideoEncoderFactory alloc] init]);
|
||||
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> videoBitrateAllocatorFactory =
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory();
|
||||
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine =
|
||||
cricket::WebRtcMediaEngineFactory::Create(nullptr /* adm */,
|
||||
webrtc::CreateBuiltinAudioEncoderFactory(),
|
||||
webrtc::CreateBuiltinAudioDecoderFactory(),
|
||||
std::move(videoEncoderFactory),
|
||||
std::move(videoDecoderFactory),
|
||||
std::move(videoBitrateAllocatorFactory),
|
||||
nullptr /* audio_mixer */,
|
||||
webrtc::AudioProcessingBuilder().Create());
|
||||
RTC_LOG(LS_INFO) << "Media engine created: " << media_engine.get();
|
||||
|
|
|
@ -278,6 +278,7 @@ rtc_static_library("rtc_audio_video") {
|
|||
defines = []
|
||||
libs = []
|
||||
deps = [
|
||||
"../api/video:video_bitrate_allocator_factory",
|
||||
"../modules/audio_processing:api",
|
||||
"../modules/audio_processing/aec_dump:aec_dump",
|
||||
"../modules/video_coding:video_codec_interface",
|
||||
|
@ -353,6 +354,7 @@ rtc_static_library("rtc_audio_video") {
|
|||
"../api:libjingle_peerconnection_api",
|
||||
"../api:transport_api",
|
||||
"../api/audio_codecs:audio_codecs_api",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:video_frame",
|
||||
"../api/video:video_frame_i420",
|
||||
"../api/video_codecs:rtc_software_fallback_wrappers",
|
||||
|
@ -629,10 +631,13 @@ if (rtc_include_tests) {
|
|||
":rtc_vp9_profile",
|
||||
"../api:create_simulcast_test_fixture_api",
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api:mock_video_bitrate_allocator",
|
||||
"../api:mock_video_bitrate_allocator_factory",
|
||||
"../api:mock_video_codec_factory",
|
||||
"../api:simulcast_test_fixture_api",
|
||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:video_bitrate_allocation",
|
||||
"../api/video:video_frame",
|
||||
"../api/video_codecs:builtin_video_decoder_factory",
|
||||
|
|
|
@ -123,6 +123,7 @@ FakeVideoSendStream::FakeVideoSendStream(
|
|||
source_(nullptr),
|
||||
num_swapped_frames_(0) {
|
||||
RTC_DCHECK(config.encoder_settings.encoder_factory != nullptr);
|
||||
RTC_DCHECK(config.encoder_settings.bitrate_allocator_factory != nullptr);
|
||||
ReconfigureVideoEncoder(std::move(encoder_config));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video_codecs/video_decoder_factory.h"
|
||||
#include "api/video_codecs/video_encoder_factory.h"
|
||||
#include "media/engine/webrtcvoiceengine.h"
|
||||
|
@ -38,15 +39,19 @@ MediaEngineInterface* CreateWebRtcMediaEngine(
|
|||
audio_decoder_factory,
|
||||
WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) {
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
typedef WebRtcVideoEngine VideoEngine;
|
||||
std::tuple<std::unique_ptr<WebRtcVideoEncoderFactory>,
|
||||
std::unique_ptr<WebRtcVideoDecoderFactory>>
|
||||
std::unique_ptr<WebRtcVideoDecoderFactory>,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>>
|
||||
video_args(
|
||||
(std::unique_ptr<WebRtcVideoEncoderFactory>(video_encoder_factory)),
|
||||
(std::unique_ptr<WebRtcVideoDecoderFactory>(video_decoder_factory)));
|
||||
(std::unique_ptr<WebRtcVideoDecoderFactory>(video_decoder_factory)),
|
||||
(std::move(video_bitrate_allocator_factory)));
|
||||
#else
|
||||
typedef NullWebRtcVideoEngine VideoEngine;
|
||||
std::tuple<> video_args;
|
||||
|
@ -67,10 +72,26 @@ MediaEngineInterface* WebRtcMediaEngineFactory::Create(
|
|||
audio_decoder_factory,
|
||||
WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
WebRtcVideoDecoderFactory* video_decoder_factory) {
|
||||
return CreateWebRtcMediaEngine(adm, audio_encoder_factory,
|
||||
audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, nullptr,
|
||||
webrtc::AudioProcessingBuilder().Create());
|
||||
return WebRtcMediaEngineFactory::Create(
|
||||
adm, audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory,
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory());
|
||||
}
|
||||
|
||||
MediaEngineInterface* WebRtcMediaEngineFactory::Create(
|
||||
webrtc::AudioDeviceModule* adm,
|
||||
const rtc::scoped_refptr<webrtc::AudioEncoderFactory>&
|
||||
audio_encoder_factory,
|
||||
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
||||
audio_decoder_factory,
|
||||
WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory) {
|
||||
return CreateWebRtcMediaEngine(
|
||||
adm, audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, std::move(video_bitrate_allocator_factory),
|
||||
nullptr, webrtc::AudioProcessingBuilder().Create());
|
||||
}
|
||||
|
||||
MediaEngineInterface* WebRtcMediaEngineFactory::Create(
|
||||
|
@ -83,9 +104,29 @@ MediaEngineInterface* WebRtcMediaEngineFactory::Create(
|
|||
WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) {
|
||||
return WebRtcMediaEngineFactory::Create(
|
||||
adm, audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory,
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory(), audio_mixer,
|
||||
audio_processing);
|
||||
}
|
||||
|
||||
MediaEngineInterface* WebRtcMediaEngineFactory::Create(
|
||||
webrtc::AudioDeviceModule* adm,
|
||||
const rtc::scoped_refptr<webrtc::AudioEncoderFactory>&
|
||||
audio_encoder_factory,
|
||||
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
||||
audio_decoder_factory,
|
||||
WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) {
|
||||
return CreateWebRtcMediaEngine(
|
||||
adm, audio_encoder_factory, audio_decoder_factory, video_encoder_factory,
|
||||
video_decoder_factory, audio_mixer, audio_processing);
|
||||
video_decoder_factory, std::move(video_bitrate_allocator_factory),
|
||||
audio_mixer, audio_processing);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -97,12 +138,31 @@ std::unique_ptr<MediaEngineInterface> WebRtcMediaEngineFactory::Create(
|
|||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) {
|
||||
return WebRtcMediaEngineFactory::Create(
|
||||
adm, audio_encoder_factory, audio_decoder_factory,
|
||||
std::move(video_encoder_factory), std::move(video_decoder_factory),
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory(), audio_mixer,
|
||||
audio_processing);
|
||||
}
|
||||
|
||||
std::unique_ptr<MediaEngineInterface> WebRtcMediaEngineFactory::Create(
|
||||
rtc::scoped_refptr<webrtc::AudioDeviceModule> adm,
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory,
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) {
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
typedef WebRtcVideoEngine VideoEngine;
|
||||
std::tuple<std::unique_ptr<webrtc::VideoEncoderFactory>,
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory>>
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory>,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>>
|
||||
video_args(std::move(video_encoder_factory),
|
||||
std::move(video_decoder_factory));
|
||||
std::move(video_decoder_factory),
|
||||
std::move(video_bitrate_allocator_factory));
|
||||
#else
|
||||
typedef NullWebRtcVideoEngine VideoEngine;
|
||||
std::tuple<> video_args;
|
||||
|
|
|
@ -25,6 +25,7 @@ class AudioMixer;
|
|||
class AudioProcessing;
|
||||
class VideoDecoderFactory;
|
||||
class VideoEncoderFactory;
|
||||
class VideoBitrateAllocatorFactory;
|
||||
} // namespace webrtc
|
||||
namespace cricket {
|
||||
class WebRtcVideoDecoderFactory;
|
||||
|
@ -50,6 +51,7 @@ class WebRtcMediaEngineFactory {
|
|||
audio_decoder_factory,
|
||||
WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
WebRtcVideoDecoderFactory* video_decoder_factory);
|
||||
|
||||
static MediaEngineInterface* Create(
|
||||
webrtc::AudioDeviceModule* adm,
|
||||
const rtc::scoped_refptr<webrtc::AudioEncoderFactory>&
|
||||
|
@ -60,6 +62,30 @@ class WebRtcMediaEngineFactory {
|
|||
WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> apm);
|
||||
|
||||
static MediaEngineInterface* Create(
|
||||
webrtc::AudioDeviceModule* adm,
|
||||
const rtc::scoped_refptr<webrtc::AudioEncoderFactory>&
|
||||
audio_encoder_factory,
|
||||
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
||||
audio_decoder_factory,
|
||||
WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory);
|
||||
|
||||
static MediaEngineInterface* Create(
|
||||
webrtc::AudioDeviceModule* adm,
|
||||
const rtc::scoped_refptr<webrtc::AudioEncoderFactory>&
|
||||
audio_encoder_factory,
|
||||
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
|
||||
audio_decoder_factory,
|
||||
WebRtcVideoEncoderFactory* video_encoder_factory,
|
||||
WebRtcVideoDecoderFactory* video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> apm);
|
||||
#endif
|
||||
|
||||
// Create a MediaEngineInterface with optional video codec factories. These
|
||||
|
@ -73,6 +99,17 @@ class WebRtcMediaEngineFactory {
|
|||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing);
|
||||
|
||||
static std::unique_ptr<MediaEngineInterface> Create(
|
||||
rtc::scoped_refptr<webrtc::AudioDeviceModule> adm,
|
||||
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory,
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory,
|
||||
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
|
||||
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing);
|
||||
};
|
||||
|
||||
// Verify that extension IDs are within 1-byte extension range and are not
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video_codecs/builtin_video_decoder_factory.h"
|
||||
#include "api/video_codecs/builtin_video_encoder_factory.h"
|
||||
#include "media/engine/webrtcmediaengine.h"
|
||||
|
@ -249,4 +250,15 @@ TEST(WebRtcMediaEngineFactoryTest, CreateWithBuiltinDecoders) {
|
|||
EXPECT_TRUE(engine);
|
||||
}
|
||||
|
||||
TEST(WebRtcMediaEngineFactoryTest, CreateWithVideoBitrateFactory) {
|
||||
std::unique_ptr<MediaEngineInterface> engine(WebRtcMediaEngineFactory::Create(
|
||||
nullptr /* adm */, webrtc::CreateBuiltinAudioEncoderFactory(),
|
||||
webrtc::CreateBuiltinAudioDecoderFactory(),
|
||||
webrtc::CreateBuiltinVideoEncoderFactory(),
|
||||
webrtc::CreateBuiltinVideoDecoderFactory(),
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory(),
|
||||
nullptr /* audio_mixer */, webrtc::AudioProcessingBuilder().Create()));
|
||||
EXPECT_TRUE(engine);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
|
|
@ -437,20 +437,26 @@ void DefaultUnsignalledSsrcHandler::SetDefaultSink(
|
|||
#if defined(USE_BUILTIN_SW_CODECS)
|
||||
WebRtcVideoEngine::WebRtcVideoEngine(
|
||||
std::unique_ptr<WebRtcVideoEncoderFactory> external_video_encoder_factory,
|
||||
std::unique_ptr<WebRtcVideoDecoderFactory> external_video_decoder_factory)
|
||||
std::unique_ptr<WebRtcVideoDecoderFactory> external_video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory)
|
||||
: decoder_factory_(ConvertVideoDecoderFactory(
|
||||
std::move(external_video_decoder_factory))),
|
||||
encoder_factory_(ConvertVideoEncoderFactory(
|
||||
std::move(external_video_encoder_factory))) {
|
||||
std::move(external_video_encoder_factory))),
|
||||
bitrate_allocator_factory_(std::move(video_bitrate_allocator_factory)) {
|
||||
RTC_LOG(LS_INFO) << "WebRtcVideoEngine::WebRtcVideoEngine()";
|
||||
}
|
||||
#endif
|
||||
|
||||
WebRtcVideoEngine::WebRtcVideoEngine(
|
||||
std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory,
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory)
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory)
|
||||
: decoder_factory_(std::move(video_decoder_factory)),
|
||||
encoder_factory_(std::move(video_encoder_factory)) {
|
||||
encoder_factory_(std::move(video_encoder_factory)),
|
||||
bitrate_allocator_factory_(std::move(video_bitrate_allocator_factory)) {
|
||||
RTC_LOG(LS_INFO) << "WebRtcVideoEngine::WebRtcVideoEngine()";
|
||||
}
|
||||
|
||||
|
@ -465,7 +471,8 @@ WebRtcVideoChannel* WebRtcVideoEngine::CreateChannel(
|
|||
const webrtc::CryptoOptions& crypto_options) {
|
||||
RTC_LOG(LS_INFO) << "CreateChannel. Options: " << options.ToString();
|
||||
return new WebRtcVideoChannel(call, config, options, crypto_options,
|
||||
encoder_factory_.get(), decoder_factory_.get());
|
||||
encoder_factory_.get(), decoder_factory_.get(),
|
||||
bitrate_allocator_factory_.get());
|
||||
}
|
||||
|
||||
std::vector<VideoCodec> WebRtcVideoEngine::codecs() const {
|
||||
|
@ -516,13 +523,15 @@ WebRtcVideoChannel::WebRtcVideoChannel(
|
|||
const VideoOptions& options,
|
||||
const webrtc::CryptoOptions& crypto_options,
|
||||
webrtc::VideoEncoderFactory* encoder_factory,
|
||||
webrtc::VideoDecoderFactory* decoder_factory)
|
||||
webrtc::VideoDecoderFactory* decoder_factory,
|
||||
webrtc::VideoBitrateAllocatorFactory* bitrate_allocator_factory)
|
||||
: VideoMediaChannel(config),
|
||||
call_(call),
|
||||
unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
|
||||
video_config_(config.video),
|
||||
encoder_factory_(encoder_factory),
|
||||
decoder_factory_(decoder_factory),
|
||||
bitrate_allocator_factory_(bitrate_allocator_factory),
|
||||
preferred_dscp_(rtc::DSCP_DEFAULT),
|
||||
default_send_options_(options),
|
||||
last_stats_log_ms_(-1),
|
||||
|
@ -1069,6 +1078,8 @@ bool WebRtcVideoChannel::AddSendStream(const StreamParams& sp) {
|
|||
config.encoder_settings.experiment_cpu_load_estimator =
|
||||
video_config_.experiment_cpu_load_estimator;
|
||||
config.encoder_settings.encoder_factory = encoder_factory_;
|
||||
config.encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_;
|
||||
config.crypto_options = crypto_options_;
|
||||
config.rtp.extmap_allow_mixed = ExtmapAllowMixed();
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/call/transport.h"
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video/video_sink_interface.h"
|
||||
#include "api/video/video_source_interface.h"
|
||||
|
@ -84,15 +85,18 @@ class WebRtcVideoEngine {
|
|||
// Internal SW video codecs will be added on top of the external codecs.
|
||||
WebRtcVideoEngine(
|
||||
std::unique_ptr<WebRtcVideoEncoderFactory> external_video_encoder_factory,
|
||||
std::unique_ptr<WebRtcVideoDecoderFactory>
|
||||
external_video_decoder_factory);
|
||||
std::unique_ptr<WebRtcVideoDecoderFactory> external_video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory);
|
||||
#endif
|
||||
|
||||
// These video codec factories represents all video codecs, i.e. both software
|
||||
// and external hardware codecs.
|
||||
WebRtcVideoEngine(
|
||||
std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory,
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory);
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory);
|
||||
|
||||
virtual ~WebRtcVideoEngine();
|
||||
|
||||
|
@ -108,16 +112,20 @@ class WebRtcVideoEngine {
|
|||
private:
|
||||
const std::unique_ptr<webrtc::VideoDecoderFactory> decoder_factory_;
|
||||
const std::unique_ptr<webrtc::VideoEncoderFactory> encoder_factory_;
|
||||
const std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
||||
bitrate_allocator_factory_;
|
||||
};
|
||||
|
||||
class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
|
||||
public:
|
||||
WebRtcVideoChannel(webrtc::Call* call,
|
||||
const MediaConfig& config,
|
||||
const VideoOptions& options,
|
||||
const webrtc::CryptoOptions& crypto_options,
|
||||
webrtc::VideoEncoderFactory* encoder_factory,
|
||||
webrtc::VideoDecoderFactory* decoder_factory);
|
||||
WebRtcVideoChannel(
|
||||
webrtc::Call* call,
|
||||
const MediaConfig& config,
|
||||
const VideoOptions& options,
|
||||
const webrtc::CryptoOptions& crypto_options,
|
||||
webrtc::VideoEncoderFactory* encoder_factory,
|
||||
webrtc::VideoDecoderFactory* decoder_factory,
|
||||
webrtc::VideoBitrateAllocatorFactory* bitrate_allocator_factory);
|
||||
~WebRtcVideoChannel() override;
|
||||
|
||||
// VideoMediaChannel implementation
|
||||
|
@ -491,6 +499,7 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
|
|||
|
||||
webrtc::VideoEncoderFactory* const encoder_factory_;
|
||||
webrtc::VideoDecoderFactory* const decoder_factory_;
|
||||
webrtc::VideoBitrateAllocatorFactory* const bitrate_allocator_factory_;
|
||||
std::vector<VideoCodecSettings> recv_codecs_;
|
||||
std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
|
||||
// See reason for keeping track of the FlexFEC payload type separately in
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/rtpparameters.h"
|
||||
#include "api/test/mock_video_bitrate_allocator.h"
|
||||
#include "api/test/mock_video_bitrate_allocator_factory.h"
|
||||
#include "api/test/mock_video_decoder_factory.h"
|
||||
#include "api/test/mock_video_encoder_factory.h"
|
||||
#include "api/units/time_delta.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video/video_bitrate_allocation.h"
|
||||
#include "api/video_codecs/builtin_video_decoder_factory.h"
|
||||
#include "api/video_codecs/builtin_video_encoder_factory.h"
|
||||
|
@ -214,7 +217,8 @@ class WebRtcVideoEngineTest : public ::testing::Test {
|
|||
engine_(std::unique_ptr<cricket::FakeWebRtcVideoEncoderFactory>(
|
||||
encoder_factory_),
|
||||
std::unique_ptr<cricket::FakeWebRtcVideoDecoderFactory>(
|
||||
decoder_factory_)) {
|
||||
decoder_factory_),
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory()) {
|
||||
// Ensure fake clock doesn't return 0, which will cause some initializations
|
||||
// fail inside RTP senders.
|
||||
fake_clock_.AdvanceTimeMicros(1);
|
||||
|
@ -1009,8 +1013,10 @@ TEST_F(WebRtcVideoEngineTest, GetSourcesWithNonExistingSsrc) {
|
|||
TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, NullFactories) {
|
||||
std::unique_ptr<webrtc::VideoEncoderFactory> encoder_factory;
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> decoder_factory;
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> rate_allocator_factory;
|
||||
WebRtcVideoEngine engine(std::move(encoder_factory),
|
||||
std::move(decoder_factory));
|
||||
std::move(decoder_factory),
|
||||
std::move(rate_allocator_factory));
|
||||
EXPECT_EQ(0u, engine.codecs().size());
|
||||
}
|
||||
|
||||
|
@ -1020,13 +1026,18 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, EmptyFactories) {
|
|||
new webrtc::MockVideoEncoderFactory();
|
||||
webrtc::MockVideoDecoderFactory* decoder_factory =
|
||||
new webrtc::MockVideoDecoderFactory();
|
||||
webrtc::MockVideoBitrateAllocatorFactory* rate_allocator_factory =
|
||||
new webrtc::MockVideoBitrateAllocatorFactory();
|
||||
WebRtcVideoEngine engine(
|
||||
(std::unique_ptr<webrtc::VideoEncoderFactory>(encoder_factory)),
|
||||
(std::unique_ptr<webrtc::VideoDecoderFactory>(decoder_factory)));
|
||||
(std::unique_ptr<webrtc::VideoDecoderFactory>(decoder_factory)),
|
||||
(std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>(
|
||||
rate_allocator_factory)));
|
||||
EXPECT_CALL(*encoder_factory, GetSupportedFormats());
|
||||
EXPECT_EQ(0u, engine.codecs().size());
|
||||
EXPECT_CALL(*encoder_factory, Die());
|
||||
EXPECT_CALL(*decoder_factory, Die());
|
||||
EXPECT_CALL(*rate_allocator_factory, Die());
|
||||
}
|
||||
|
||||
// Test full behavior in the video engine when video codec factories of the new
|
||||
|
@ -1039,9 +1050,17 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
|
|||
new webrtc::MockVideoEncoderFactory();
|
||||
webrtc::MockVideoDecoderFactory* decoder_factory =
|
||||
new webrtc::MockVideoDecoderFactory();
|
||||
webrtc::MockVideoBitrateAllocatorFactory* rate_allocator_factory =
|
||||
new webrtc::MockVideoBitrateAllocatorFactory();
|
||||
EXPECT_CALL(*rate_allocator_factory,
|
||||
CreateVideoBitrateAllocatorProxy(Field(
|
||||
&webrtc::VideoCodec::codecType, webrtc::kVideoCodecVP8)))
|
||||
.WillOnce(testing::Return(new webrtc::MockVideoBitrateAllocator()));
|
||||
WebRtcVideoEngine engine(
|
||||
(std::unique_ptr<webrtc::VideoEncoderFactory>(encoder_factory)),
|
||||
(std::unique_ptr<webrtc::VideoDecoderFactory>(decoder_factory)));
|
||||
(std::unique_ptr<webrtc::VideoDecoderFactory>(decoder_factory)),
|
||||
(std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>(
|
||||
rate_allocator_factory)));
|
||||
const webrtc::SdpVideoFormat vp8_format("VP8");
|
||||
const std::vector<webrtc::SdpVideoFormat> supported_formats = {vp8_format};
|
||||
EXPECT_CALL(*encoder_factory, GetSupportedFormats())
|
||||
|
@ -1137,6 +1156,7 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
|
|||
// Remove streams previously added to free the encoder and decoder instance.
|
||||
EXPECT_CALL(*encoder_factory, Die());
|
||||
EXPECT_CALL(*decoder_factory, Die());
|
||||
EXPECT_CALL(*rate_allocator_factory, Die());
|
||||
EXPECT_TRUE(send_channel->RemoveSendStream(send_ssrc));
|
||||
EXPECT_TRUE(recv_channel->RemoveRecvStream(recv_ssrc));
|
||||
}
|
||||
|
@ -1145,12 +1165,16 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
|
|||
TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, NullDecoder) {
|
||||
// |engine| take ownership of the factories.
|
||||
webrtc::MockVideoEncoderFactory* encoder_factory =
|
||||
new testing::StrictMock<webrtc::MockVideoEncoderFactory>();
|
||||
new webrtc::MockVideoEncoderFactory();
|
||||
webrtc::MockVideoDecoderFactory* decoder_factory =
|
||||
new testing::StrictMock<webrtc::MockVideoDecoderFactory>();
|
||||
new webrtc::MockVideoDecoderFactory();
|
||||
webrtc::MockVideoBitrateAllocatorFactory* rate_allocator_factory =
|
||||
new webrtc::MockVideoBitrateAllocatorFactory();
|
||||
WebRtcVideoEngine engine(
|
||||
(std::unique_ptr<webrtc::VideoEncoderFactory>(encoder_factory)),
|
||||
(std::unique_ptr<webrtc::VideoDecoderFactory>(decoder_factory)));
|
||||
(std::unique_ptr<webrtc::VideoDecoderFactory>(decoder_factory)),
|
||||
(std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>(
|
||||
rate_allocator_factory)));
|
||||
const webrtc::SdpVideoFormat vp8_format("VP8");
|
||||
const std::vector<webrtc::SdpVideoFormat> supported_formats = {vp8_format};
|
||||
EXPECT_CALL(*encoder_factory, GetSupportedFormats())
|
||||
|
@ -1243,7 +1267,8 @@ class WebRtcVideoChannelBaseTest : public testing::Test {
|
|||
protected:
|
||||
WebRtcVideoChannelBaseTest()
|
||||
: engine_(webrtc::CreateBuiltinVideoEncoderFactory(),
|
||||
webrtc::CreateBuiltinVideoDecoderFactory()) {}
|
||||
webrtc::CreateBuiltinVideoDecoderFactory(),
|
||||
webrtc::CreateBuiltinVideoBitrateAllocatorFactory()) {}
|
||||
|
||||
virtual void SetUp() {
|
||||
// One testcase calls SetUp in a loop, only create call_ once.
|
||||
|
@ -6754,10 +6779,14 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test {
|
|||
: fake_call_(),
|
||||
encoder_factory_(new cricket::FakeWebRtcVideoEncoderFactory),
|
||||
decoder_factory_(new cricket::FakeWebRtcVideoDecoderFactory),
|
||||
mock_rate_allocator_factory_(
|
||||
new webrtc::MockVideoBitrateAllocatorFactory),
|
||||
engine_(std::unique_ptr<cricket::FakeWebRtcVideoEncoderFactory>(
|
||||
encoder_factory_),
|
||||
std::unique_ptr<cricket::FakeWebRtcVideoDecoderFactory>(
|
||||
decoder_factory_)),
|
||||
decoder_factory_),
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>(
|
||||
mock_rate_allocator_factory_)),
|
||||
last_ssrc_(0) {}
|
||||
|
||||
void SetUp() override {
|
||||
|
@ -6914,6 +6943,7 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test {
|
|||
FakeCall fake_call_;
|
||||
cricket::FakeWebRtcVideoEncoderFactory* encoder_factory_;
|
||||
cricket::FakeWebRtcVideoDecoderFactory* decoder_factory_;
|
||||
webrtc::MockVideoBitrateAllocatorFactory* mock_rate_allocator_factory_;
|
||||
WebRtcVideoEngine engine_;
|
||||
std::unique_ptr<VideoMediaChannel> channel_;
|
||||
uint32_t last_ssrc_;
|
||||
|
|
|
@ -159,6 +159,7 @@ rtc_static_library("video_coding") {
|
|||
"..:module_api_public",
|
||||
"../..:webrtc_common",
|
||||
"../../api:fec_controller_api",
|
||||
"../../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../../api/video:encoded_frame",
|
||||
"../../api/video:video_bitrate_allocator",
|
||||
"../../api/video:video_frame",
|
||||
|
@ -644,6 +645,7 @@ if (rtc_include_tests) {
|
|||
":webrtc_vp9_helpers",
|
||||
"../..:webrtc_common",
|
||||
"../../api:videocodec_test_fixture_api",
|
||||
"../../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../../api/video:video_bitrate_allocator",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video:video_frame_i420",
|
||||
|
@ -895,7 +897,9 @@ if (rtc_include_tests) {
|
|||
"../../api:simulcast_test_fixture_api",
|
||||
"../../api:videocodec_test_fixture_api",
|
||||
"../../api/test/video:function_video_factory",
|
||||
"../../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../../api/video:video_bitrate_allocator",
|
||||
"../../api/video:video_bitrate_allocator_factory",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video:video_frame_i420",
|
||||
"../../api/video_codecs:create_vp8_temporal_layers",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video/i420_buffer.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "common_video/h264/h264_common.h"
|
||||
|
@ -173,8 +174,9 @@ VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
|
|||
stats_(stats),
|
||||
encoder_(encoder),
|
||||
decoders_(decoders),
|
||||
bitrate_allocator_(VideoCodecInitializer::CreateBitrateAllocator(
|
||||
config_.codec_settings)),
|
||||
bitrate_allocator_(
|
||||
CreateBuiltinVideoBitrateAllocatorFactory()
|
||||
->CreateVideoBitrateAllocator(config_.codec_settings)),
|
||||
framerate_fps_(0),
|
||||
encode_callback_(this),
|
||||
input_frame_reader_(input_frame_reader),
|
||||
|
|
|
@ -30,15 +30,9 @@ class VideoCodecInitializer {
|
|||
// type used. For instance, VP8 will create an allocator than can handle
|
||||
// simulcast and temporal layering.
|
||||
// GetBitrateAllocator is called implicitly from here, no need to call again.
|
||||
static bool SetupCodec(
|
||||
const VideoEncoderConfig& config,
|
||||
const std::vector<VideoStream>& streams,
|
||||
VideoCodec* codec,
|
||||
std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator = nullptr);
|
||||
|
||||
// Create a bitrate allocator for the specified codec.
|
||||
static std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
|
||||
const VideoCodec& codec);
|
||||
static bool SetupCodec(const VideoEncoderConfig& config,
|
||||
const std::vector<VideoStream>& streams,
|
||||
VideoCodec* codec);
|
||||
|
||||
private:
|
||||
static VideoCodec VideoEncoderConfigToVideoCodec(
|
||||
|
|
|
@ -24,15 +24,13 @@
|
|||
|
||||
namespace webrtc {
|
||||
|
||||
bool VideoCodecInitializer::SetupCodec(
|
||||
const VideoEncoderConfig& config,
|
||||
const std::vector<VideoStream>& streams,
|
||||
VideoCodec* codec,
|
||||
std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) {
|
||||
bool VideoCodecInitializer::SetupCodec(const VideoEncoderConfig& config,
|
||||
const std::vector<VideoStream>& streams,
|
||||
VideoCodec* codec) {
|
||||
if (config.codec_type == kVideoCodecMultiplex) {
|
||||
VideoEncoderConfig associated_config = config.Copy();
|
||||
associated_config.codec_type = kVideoCodecVP9;
|
||||
if (!SetupCodec(associated_config, streams, codec, bitrate_allocator)) {
|
||||
if (!SetupCodec(associated_config, streams, codec)) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to create stereo encoder configuration.";
|
||||
return false;
|
||||
}
|
||||
|
@ -41,33 +39,9 @@ bool VideoCodecInitializer::SetupCodec(
|
|||
}
|
||||
|
||||
*codec = VideoEncoderConfigToVideoCodec(config, streams);
|
||||
if (bitrate_allocator) {
|
||||
*bitrate_allocator = CreateBitrateAllocator(*codec);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoBitrateAllocator>
|
||||
VideoCodecInitializer::CreateBitrateAllocator(const VideoCodec& codec) {
|
||||
std::unique_ptr<VideoBitrateAllocator> rate_allocator;
|
||||
|
||||
switch (codec.codecType) {
|
||||
case kVideoCodecVP8:
|
||||
RTC_FALLTHROUGH();
|
||||
case kVideoCodecH264:
|
||||
rate_allocator.reset(new SimulcastRateAllocator(codec));
|
||||
break;
|
||||
case kVideoCodecVP9:
|
||||
rate_allocator.reset(new SvcRateAllocator(codec));
|
||||
break;
|
||||
default:
|
||||
rate_allocator.reset(new DefaultVideoBitrateAllocator(codec));
|
||||
}
|
||||
|
||||
return rate_allocator;
|
||||
}
|
||||
|
||||
// TODO(sprang): Split this up and separate the codec specific parts.
|
||||
VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
|
||||
const VideoEncoderConfig& config,
|
||||
|
|
|
@ -9,12 +9,13 @@
|
|||
*/
|
||||
|
||||
#include "modules/video_coding/include/video_codec_initializer.h"
|
||||
#include "api/video/video_bitrate_allocator.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video_codecs/create_vp8_temporal_layers.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "api/video_codecs/vp8_temporal_layers.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/refcountedobject.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
|
@ -75,12 +76,13 @@ class VideoCodecInitializerTest : public ::testing::Test {
|
|||
|
||||
bool InitializeCodec() {
|
||||
codec_out_ = VideoCodec();
|
||||
bitrate_allocator_out_.reset();
|
||||
temporal_layers_.clear();
|
||||
if (!VideoCodecInitializer::SetupCodec(config_, streams_, &codec_out_,
|
||||
&bitrate_allocator_out_)) {
|
||||
if (!VideoCodecInitializer::SetupCodec(config_, streams_, &codec_out_)) {
|
||||
return false;
|
||||
}
|
||||
bitrate_allocator_ = CreateBuiltinVideoBitrateAllocatorFactory()
|
||||
->CreateVideoBitrateAllocator(codec_out_);
|
||||
RTC_CHECK(bitrate_allocator_);
|
||||
if (codec_out_.codecType == VideoCodecType::kVideoCodecMultiplex)
|
||||
return true;
|
||||
|
||||
|
@ -126,7 +128,7 @@ class VideoCodecInitializerTest : public ::testing::Test {
|
|||
|
||||
// Output.
|
||||
VideoCodec codec_out_;
|
||||
std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_out_;
|
||||
std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_;
|
||||
std::vector<std::unique_ptr<Vp8TemporalLayers>> temporal_layers_;
|
||||
};
|
||||
|
||||
|
@ -135,9 +137,8 @@ TEST_F(VideoCodecInitializerTest, SingleStreamVp8Screenshare) {
|
|||
streams_.push_back(DefaultStream());
|
||||
EXPECT_TRUE(InitializeCodec());
|
||||
|
||||
VideoBitrateAllocation bitrate_allocation =
|
||||
bitrate_allocator_out_->GetAllocation(kDefaultTargetBitrateBps,
|
||||
kDefaultFrameRate);
|
||||
VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
|
||||
kDefaultTargetBitrateBps, kDefaultFrameRate);
|
||||
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
|
||||
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
|
||||
EXPECT_EQ(kDefaultTargetBitrateBps, bitrate_allocation.get_sum_bps());
|
||||
|
@ -150,9 +151,8 @@ TEST_F(VideoCodecInitializerTest, SingleStreamVp8ScreenshareInactive) {
|
|||
streams_.push_back(inactive_stream);
|
||||
EXPECT_TRUE(InitializeCodec());
|
||||
|
||||
VideoBitrateAllocation bitrate_allocation =
|
||||
bitrate_allocator_out_->GetAllocation(kDefaultTargetBitrateBps,
|
||||
kDefaultFrameRate);
|
||||
VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
|
||||
kDefaultTargetBitrateBps, kDefaultFrameRate);
|
||||
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
|
||||
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
|
||||
EXPECT_EQ(0U, bitrate_allocation.get_sum_bps());
|
||||
|
@ -165,9 +165,8 @@ TEST_F(VideoCodecInitializerTest, TemporalLayeredVp8Screenshare) {
|
|||
|
||||
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
|
||||
EXPECT_EQ(2u, codec_out_.VP8()->numberOfTemporalLayers);
|
||||
VideoBitrateAllocation bitrate_allocation =
|
||||
bitrate_allocator_out_->GetAllocation(kScreenshareCodecTargetBitrateBps,
|
||||
kScreenshareDefaultFramerate);
|
||||
VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
|
||||
kScreenshareCodecTargetBitrateBps, kScreenshareDefaultFramerate);
|
||||
EXPECT_EQ(kScreenshareCodecTargetBitrateBps,
|
||||
bitrate_allocation.get_sum_bps());
|
||||
EXPECT_EQ(kScreenshareTl0BitrateBps, bitrate_allocation.GetBitrate(0, 0));
|
||||
|
@ -185,9 +184,8 @@ TEST_F(VideoCodecInitializerTest, SimulcastVp8Screenshare) {
|
|||
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
|
||||
const uint32_t max_bitrate_bps =
|
||||
streams_[0].target_bitrate_bps + streams_[1].max_bitrate_bps;
|
||||
VideoBitrateAllocation bitrate_allocation =
|
||||
bitrate_allocator_out_->GetAllocation(max_bitrate_bps,
|
||||
kScreenshareDefaultFramerate);
|
||||
VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
|
||||
max_bitrate_bps, kScreenshareDefaultFramerate);
|
||||
EXPECT_EQ(max_bitrate_bps, bitrate_allocation.get_sum_bps());
|
||||
EXPECT_EQ(static_cast<uint32_t>(streams_[0].target_bitrate_bps),
|
||||
bitrate_allocation.GetSpatialLayerSum(0));
|
||||
|
@ -210,9 +208,8 @@ TEST_F(VideoCodecInitializerTest, SimulcastVp8ScreenshareInactive) {
|
|||
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
|
||||
const uint32_t target_bitrate =
|
||||
streams_[0].target_bitrate_bps + streams_[1].target_bitrate_bps;
|
||||
VideoBitrateAllocation bitrate_allocation =
|
||||
bitrate_allocator_out_->GetAllocation(target_bitrate,
|
||||
kScreenshareDefaultFramerate);
|
||||
VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
|
||||
target_bitrate, kScreenshareDefaultFramerate);
|
||||
EXPECT_EQ(static_cast<uint32_t>(streams_[0].max_bitrate_bps),
|
||||
bitrate_allocation.get_sum_bps());
|
||||
EXPECT_EQ(static_cast<uint32_t>(streams_[0].max_bitrate_bps),
|
||||
|
@ -235,7 +232,7 @@ TEST_F(VideoCodecInitializerTest, HighFpsSimulcastVp8Screenshare) {
|
|||
const uint32_t max_bitrate_bps =
|
||||
streams_[0].target_bitrate_bps + streams_[1].max_bitrate_bps;
|
||||
VideoBitrateAllocation bitrate_allocation =
|
||||
bitrate_allocator_out_->GetAllocation(max_bitrate_bps, kDefaultFrameRate);
|
||||
bitrate_allocator_->GetAllocation(max_bitrate_bps, kDefaultFrameRate);
|
||||
EXPECT_EQ(max_bitrate_bps, bitrate_allocation.get_sum_bps());
|
||||
EXPECT_EQ(static_cast<uint32_t>(streams_[0].target_bitrate_bps),
|
||||
bitrate_allocation.GetSpatialLayerSum(0));
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video/video_bitrate_allocator.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||
|
@ -81,6 +82,7 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
|||
KeyFrameRequestSender* keyframe_request_sender)
|
||||
: VideoCodingModule(),
|
||||
sender_(clock, &post_encode_callback_),
|
||||
rate_allocator_factory_(CreateBuiltinVideoBitrateAllocatorFactory()),
|
||||
timing_(new VCMTiming(clock)),
|
||||
receiver_(clock, timing_.get(), nack_sender, keyframe_request_sender) {}
|
||||
|
||||
|
@ -105,7 +107,8 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
|||
// asynchronously keep the instance alive until destruction or until a
|
||||
// new send codec is registered.
|
||||
VideoCodec codec = *sendCodec;
|
||||
rate_allocator_ = VideoCodecInitializer::CreateBitrateAllocator(codec);
|
||||
rate_allocator_ =
|
||||
rate_allocator_factory_->CreateVideoBitrateAllocator(codec);
|
||||
return sender_.RegisterSendCodec(&codec, numberOfCores, maxPayloadSize);
|
||||
}
|
||||
return sender_.RegisterSendCodec(sendCodec, numberOfCores, maxPayloadSize);
|
||||
|
@ -204,8 +207,9 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
|||
rtc::ThreadChecker construction_thread_;
|
||||
EncodedImageCallbackWrapper post_encode_callback_;
|
||||
vcm::VideoSender sender_;
|
||||
const std::unique_ptr<VideoBitrateAllocatorFactory> rate_allocator_factory_;
|
||||
std::unique_ptr<VideoBitrateAllocator> rate_allocator_;
|
||||
std::unique_ptr<VCMTiming> timing_;
|
||||
const std::unique_ptr<VCMTiming> timing_;
|
||||
vcm::VideoReceiver receiver_;
|
||||
};
|
||||
} // namespace
|
||||
|
|
17
pc/BUILD.gn
17
pc/BUILD.gn
|
@ -217,23 +217,6 @@ rtc_static_library("peerconnection") {
|
|||
]
|
||||
}
|
||||
|
||||
rtc_static_library("builtin_video_bitrate_allocator_factory") {
|
||||
sources = [
|
||||
"builtin_video_bitrate_allocator_factory.cc",
|
||||
"builtin_video_bitrate_allocator_factory.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../api/video:video_bitrate_allocator_factory",
|
||||
"../media:rtc_media_base",
|
||||
"../modules/video_coding:video_coding_utility",
|
||||
"../modules/video_coding:webrtc_vp9_helpers",
|
||||
"../rtc_base:ptr_util",
|
||||
"../rtc_base/system:fallthrough",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
}
|
||||
|
||||
# This target implements CreatePeerConnectionFactory methods that will create a
|
||||
# PeerConnection will full functionality (audio, video and data). Applications
|
||||
# that wish to reduce their binary size by ommitting functionality they don't
|
||||
|
|
|
@ -338,6 +338,7 @@ if (rtc_include_tests) {
|
|||
"../api:create_simulcast_test_fixture_api",
|
||||
"../api:simulcast_test_fixture_api",
|
||||
"../api/test/video:function_video_factory",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:video_frame_i420",
|
||||
"../modules/rtp_rtcp:rtp_rtcp",
|
||||
"../modules/video_capture",
|
||||
|
@ -673,6 +674,8 @@ rtc_source_set("test_common") {
|
|||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../api/test/video:function_video_factory",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:video_bitrate_allocator_factory",
|
||||
"../api/video:video_frame",
|
||||
"../api/video_codecs:video_codecs_api",
|
||||
"../audio",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "absl/memory/memory.h"
|
||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video_codecs/video_encoder_config.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
#include "call/rtp_transport_controller_send.h"
|
||||
|
@ -54,6 +55,7 @@ CallTest::CallTest()
|
|||
return fake_encoder;
|
||||
}),
|
||||
fake_decoder_factory_([]() { return absl::make_unique<FakeDecoder>(); }),
|
||||
bitrate_allocator_factory_(CreateBuiltinVideoBitrateAllocatorFactory()),
|
||||
num_video_streams_(1),
|
||||
num_audio_streams_(0),
|
||||
num_flexfec_streams_(0),
|
||||
|
@ -233,6 +235,8 @@ void CallTest::CreateVideoSendConfig(VideoSendStream::Config* video_config,
|
|||
RTC_DCHECK_LE(num_video_streams + num_used_ssrcs, kNumSsrcs);
|
||||
*video_config = VideoSendStream::Config(send_transport);
|
||||
video_config->encoder_settings.encoder_factory = &fake_encoder_factory_;
|
||||
video_config->encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_.get();
|
||||
video_config->rtp.payload_name = "FAKE";
|
||||
video_config->rtp.payload_type = kFakeVideoSendPayloadType;
|
||||
video_config->rtp.extensions.push_back(
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "api/test/video/function_video_decoder_factory.h"
|
||||
#include "api/test/video/function_video_encoder_factory.h"
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "call/call.h"
|
||||
#include "call/rtp_transport_controller_send.h"
|
||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
||||
|
@ -205,6 +206,7 @@ class CallTest : public ::testing::Test {
|
|||
test::FunctionVideoEncoderFactory fake_encoder_factory_;
|
||||
int fake_encoder_max_bitrate_ = -1;
|
||||
test::FunctionVideoDecoderFactory fake_decoder_factory_;
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
||||
// Number of simulcast substreams.
|
||||
size_t num_video_streams_;
|
||||
size_t num_audio_streams_;
|
||||
|
|
|
@ -46,6 +46,7 @@ if (rtc_include_tests) {
|
|||
"../../api/units:data_rate",
|
||||
"../../api/units:time_delta",
|
||||
"../../api/units:timestamp",
|
||||
"../../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video:video_frame_i420",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "api/test/video/function_video_encoder_factory.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "media/base/mediaconstants.h"
|
||||
#include "media/engine/internaldecoderfactory.h"
|
||||
#include "media/engine/internalencoderfactory.h"
|
||||
|
@ -213,9 +214,15 @@ SendVideoStream::SendVideoStream(CallClient* sender,
|
|||
}
|
||||
RTC_CHECK(encoder_factory_);
|
||||
|
||||
bitrate_allocator_factory_ = CreateBuiltinVideoBitrateAllocatorFactory();
|
||||
RTC_CHECK(bitrate_allocator_factory_);
|
||||
|
||||
VideoSendStream::Config send_config =
|
||||
CreateVideoSendStreamConfig(config, ssrcs_, send_transport);
|
||||
send_config.encoder_settings.encoder_factory = encoder_factory_.get();
|
||||
send_config.encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_.get();
|
||||
|
||||
VideoEncoderConfig encoder_config = CreateVideoEncoderConfig(config);
|
||||
|
||||
send_stream_ = sender_->call_->CreateVideoSendStream(
|
||||
|
|
|
@ -50,6 +50,7 @@ class SendVideoStream {
|
|||
CallClient* const sender_;
|
||||
const VideoStreamConfig config_;
|
||||
std::unique_ptr<VideoEncoderFactory> encoder_factory_;
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
||||
std::unique_ptr<TestVideoCapturer> video_capturer_;
|
||||
FrameGeneratorCapturer* frame_generator_ = nullptr;
|
||||
int next_local_network_id_ = 0;
|
||||
|
|
|
@ -174,6 +174,7 @@ rtc_source_set("video_stream_encoder_impl") {
|
|||
deps = [
|
||||
"../api/video:encoded_image",
|
||||
"../api/video:video_bitrate_allocator",
|
||||
"../api/video:video_bitrate_allocator_factory",
|
||||
"../api/video:video_frame",
|
||||
"../api/video:video_frame_i420",
|
||||
"../api/video:video_stream_encoder",
|
||||
|
@ -228,6 +229,8 @@ if (rtc_include_tests) {
|
|||
"../api:fec_controller_api",
|
||||
"../api:test_dependency_factory",
|
||||
"../api:video_quality_test_fixture_api",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:video_bitrate_allocator_factory",
|
||||
"../call:fake_network",
|
||||
"../call:simulated_network",
|
||||
"../logging:rtc_event_log_api",
|
||||
|
@ -452,6 +455,7 @@ if (rtc_include_tests) {
|
|||
"../api:fake_frame_encryptor",
|
||||
"../api:simulated_network_api",
|
||||
"../api/test/video:function_video_factory",
|
||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../api/video:encoded_image",
|
||||
"../api/video:video_frame",
|
||||
"../api/video:video_frame_i420",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
#include "call/simulated_network.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
|
@ -272,6 +273,8 @@ TEST_F(BandwidthEndToEndTest, ReportsSetEncoderRates) {
|
|||
task_queue_(task_queue),
|
||||
send_stream_(nullptr),
|
||||
encoder_factory_(this),
|
||||
bitrate_allocator_factory_(
|
||||
CreateBuiltinVideoBitrateAllocatorFactory()),
|
||||
bitrate_kbps_(0) {}
|
||||
|
||||
void OnVideoStreamsCreated(
|
||||
|
@ -285,6 +288,8 @@ TEST_F(BandwidthEndToEndTest, ReportsSetEncoderRates) {
|
|||
std::vector<VideoReceiveStream::Config>* receive_configs,
|
||||
VideoEncoderConfig* encoder_config) override {
|
||||
send_config->encoder_settings.encoder_factory = &encoder_factory_;
|
||||
send_config->encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_.get();
|
||||
RTC_DCHECK_EQ(1, encoder_config->number_of_streams);
|
||||
}
|
||||
|
||||
|
@ -343,6 +348,7 @@ TEST_F(BandwidthEndToEndTest, ReportsSetEncoderRates) {
|
|||
rtc::CriticalSection crit_;
|
||||
VideoSendStream* send_stream_;
|
||||
test::VideoEncoderProxyFactory encoder_factory_;
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
||||
uint32_t bitrate_kbps_ RTC_GUARDED_BY(crit_);
|
||||
} test(&task_queue_);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "api/test/video/function_video_encoder_factory.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
#include "call/simulated_network.h"
|
||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
||||
|
@ -54,6 +55,8 @@ void MultiStreamTester::RunTest() {
|
|||
test::FrameGeneratorCapturer* frame_generators[kNumStreams];
|
||||
test::FunctionVideoEncoderFactory encoder_factory(
|
||||
[]() { return VP8Encoder::Create(); });
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory =
|
||||
CreateBuiltinVideoBitrateAllocatorFactory();
|
||||
InternalDecoderFactory decoder_factory;
|
||||
|
||||
task_queue_->SendTask([&]() {
|
||||
|
@ -75,6 +78,8 @@ void MultiStreamTester::RunTest() {
|
|||
VideoSendStream::Config send_config(sender_transport.get());
|
||||
send_config.rtp.ssrcs.push_back(ssrc);
|
||||
send_config.encoder_settings.encoder_factory = &encoder_factory;
|
||||
send_config.encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory.get();
|
||||
send_config.rtp.payload_name = "VP8";
|
||||
send_config.rtp.payload_type = kVideoPayloadType;
|
||||
VideoEncoderConfig encoder_config;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
#include "call/simulated_network.h"
|
||||
#include "logging/rtc_event_log/output/rtc_event_log_output_file.h"
|
||||
|
@ -227,6 +228,8 @@ VideoQualityTest::VideoQualityTest(
|
|||
[this](const SdpVideoFormat& format) {
|
||||
return this->CreateVideoEncoder(format, analyzer_.get());
|
||||
}),
|
||||
video_bitrate_allocator_factory_(
|
||||
CreateBuiltinVideoBitrateAllocatorFactory()),
|
||||
receive_logs_(0),
|
||||
send_logs_(0),
|
||||
injection_components_(std::move(injection_components)),
|
||||
|
@ -558,6 +561,8 @@ void VideoQualityTest::SetupVideo(Transport* send_transport,
|
|||
video_send_configs_[video_idx].encoder_settings.encoder_factory =
|
||||
(video_idx == 0) ? &video_encoder_factory_with_analyzer_
|
||||
: &video_encoder_factory_;
|
||||
video_send_configs_[video_idx].encoder_settings.bitrate_allocator_factory =
|
||||
video_bitrate_allocator_factory_.get();
|
||||
|
||||
video_send_configs_[video_idx].rtp.payload_name =
|
||||
params_.video[video_idx].codec;
|
||||
|
@ -746,6 +751,8 @@ void VideoQualityTest::SetupThumbnails(Transport* send_transport,
|
|||
// TODO(nisse): Could use a simpler VP8-only encoder factory.
|
||||
thumbnail_send_config.encoder_settings.encoder_factory =
|
||||
&video_encoder_factory_;
|
||||
thumbnail_send_config.encoder_settings.bitrate_allocator_factory =
|
||||
video_bitrate_allocator_factory_.get();
|
||||
thumbnail_send_config.rtp.payload_name = params_.video[0].codec;
|
||||
thumbnail_send_config.rtp.payload_type = kPayloadTypeVP8;
|
||||
thumbnail_send_config.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "api/fec_controller.h"
|
||||
#include "api/test/video_quality_test_fixture.h"
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
#include "media/engine/internaldecoderfactory.h"
|
||||
#include "media/engine/internalencoderfactory.h"
|
||||
|
@ -105,6 +106,8 @@ class VideoQualityTest :
|
|||
InternalDecoderFactory internal_decoder_factory_;
|
||||
test::FunctionVideoEncoderFactory video_encoder_factory_;
|
||||
test::FunctionVideoEncoderFactory video_encoder_factory_with_analyzer_;
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory>
|
||||
video_bitrate_allocator_factory_;
|
||||
InternalEncoderFactory internal_encoder_factory_;
|
||||
std::vector<VideoSendStream::Config> thumbnail_send_configs_;
|
||||
std::vector<VideoEncoderConfig> thumbnail_encoder_configs_;
|
||||
|
|
|
@ -80,6 +80,7 @@ VideoSendStream::VideoSendStream(
|
|||
config_(std::move(config)),
|
||||
content_type_(encoder_config.content_type) {
|
||||
RTC_DCHECK(config_.encoder_settings.encoder_factory);
|
||||
RTC_DCHECK(config_.encoder_settings.bitrate_allocator_factory);
|
||||
|
||||
video_stream_encoder_ = CreateVideoStreamEncoder(num_cpu_cores, &stats_proxy_,
|
||||
config_.encoder_settings,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "api/video/i420_buffer.h"
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "modules/video_coding/include/video_codec_initializer.h"
|
||||
#include "modules/video_coding/include/video_coding.h"
|
||||
#include "rtc_base/arraysize.h"
|
||||
|
@ -534,11 +535,14 @@ void VideoStreamEncoder::ReconfigureEncoder() {
|
|||
crop_height_ = last_frame_info_->height - highest_stream_height;
|
||||
|
||||
VideoCodec codec;
|
||||
if (!VideoCodecInitializer::SetupCodec(encoder_config_, streams, &codec,
|
||||
&rate_allocator_)) {
|
||||
if (!VideoCodecInitializer::SetupCodec(encoder_config_, streams, &codec)) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to create encoder configuration.";
|
||||
}
|
||||
|
||||
rate_allocator_ =
|
||||
settings_.bitrate_allocator_factory->CreateVideoBitrateAllocator(codec);
|
||||
RTC_CHECK(rate_allocator_) << "Failed to create bitrate allocator.";
|
||||
|
||||
// Set min_bitrate_bps, max_bitrate_bps, and max padding bit rate for VP9.
|
||||
if (encoder_config_.codec_type == kVideoCodecVP9) {
|
||||
RTC_DCHECK_EQ(1U, streams.size());
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video/i420_buffer.h"
|
||||
#include "api/video_codecs/create_vp8_temporal_layers.h"
|
||||
#include "api/video_codecs/vp8_temporal_layers.h"
|
||||
|
@ -279,6 +280,7 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
|||
max_framerate_(kDefaultFramerate),
|
||||
fake_encoder_(),
|
||||
encoder_factory_(&fake_encoder_),
|
||||
bitrate_allocator_factory_(CreateBuiltinVideoBitrateAllocatorFactory()),
|
||||
stats_proxy_(new MockableSendStatisticsProxy(
|
||||
Clock::GetRealTimeClock(),
|
||||
video_send_config_,
|
||||
|
@ -289,6 +291,8 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
|||
metrics::Reset();
|
||||
video_send_config_ = VideoSendStream::Config(nullptr);
|
||||
video_send_config_.encoder_settings.encoder_factory = &encoder_factory_;
|
||||
video_send_config_.encoder_settings.bitrate_allocator_factory =
|
||||
bitrate_allocator_factory_.get();
|
||||
video_send_config_.rtp.payload_name = "FAKE";
|
||||
video_send_config_.rtp.payload_type = 125;
|
||||
|
||||
|
@ -696,6 +700,7 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
|||
int max_framerate_;
|
||||
TestEncoder fake_encoder_;
|
||||
test::VideoEncoderProxyFactory encoder_factory_;
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
||||
std::unique_ptr<MockableSendStatisticsProxy> stats_proxy_;
|
||||
TestSink sink_;
|
||||
AdaptingFrameForwarder video_source_;
|
||||
|
|
Loading…
Reference in a new issue