mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Use Video{Encoder, Decoder}FactoryTemplate instead of Internal{Encoder, Decoder}Factory.
Bug: webrtc:13573 Change-Id: Id0e46a9b6053dedae3cbf0e5581768868900630b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269247 Commit-Queue: Philip Eliasson <philipel@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37596}
This commit is contained in:
parent
a5cc0accfb
commit
f012bfaf96
4 changed files with 59 additions and 12 deletions
|
@ -18,19 +18,27 @@
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
// TODO(bugs.webrtc.org/13573): When OpenH264 is no longer a conditional build
|
// TODO(bugs.webrtc.org/13573): When OpenH264 is no longer a conditional build
|
||||||
// target remove this #ifdef.
|
// target remove #ifdefs.
|
||||||
#if defined(WEBRTC_USE_H264)
|
|
||||||
struct OpenH264DecoderTemplateAdapter {
|
struct OpenH264DecoderTemplateAdapter {
|
||||||
static std::vector<SdpVideoFormat> SupportedFormats() {
|
static std::vector<SdpVideoFormat> SupportedFormats() {
|
||||||
|
#if defined(WEBRTC_USE_H264)
|
||||||
|
|
||||||
return SupportedH264DecoderCodecs();
|
return SupportedH264DecoderCodecs();
|
||||||
|
#else
|
||||||
|
return {};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<VideoDecoder> CreateDecoder(
|
static std::unique_ptr<VideoDecoder> CreateDecoder(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
|
#if defined(WEBRTC_USE_H264)
|
||||||
|
|
||||||
return H264Decoder::Create();
|
return H264Decoder::Create();
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif // defined(WEBRTC_USE_H264)
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_TEMPLATE_OPEN_H264_ADAPTER_H_
|
#endif // API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_TEMPLATE_OPEN_H264_ADAPTER_H_
|
||||||
|
|
|
@ -18,23 +18,33 @@
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
// TODO(bugs.webrtc.org/13573): When OpenH264 is no longer a conditional build
|
// TODO(bugs.webrtc.org/13573): When OpenH264 is no longer a conditional build
|
||||||
// target remove this #ifdef.
|
// target remove #ifdefs.
|
||||||
#if defined(WEBRTC_USE_H264)
|
|
||||||
struct OpenH264EncoderTemplateAdapter {
|
struct OpenH264EncoderTemplateAdapter {
|
||||||
static std::vector<SdpVideoFormat> SupportedFormats() {
|
static std::vector<SdpVideoFormat> SupportedFormats() {
|
||||||
|
#if defined(WEBRTC_USE_H264)
|
||||||
return SupportedH264Codecs(/*add_scalability_modes=*/true);
|
return SupportedH264Codecs(/*add_scalability_modes=*/true);
|
||||||
|
#else
|
||||||
|
return {};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<VideoEncoder> CreateEncoder(
|
static std::unique_ptr<VideoEncoder> CreateEncoder(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
|
#if defined(WEBRTC_USE_H264)
|
||||||
return H264Encoder::Create(cricket::VideoCodec(format));
|
return H264Encoder::Create(cricket::VideoCodec(format));
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsScalabilityModeSupported(ScalabilityMode scalability_mode) {
|
static bool IsScalabilityModeSupported(ScalabilityMode scalability_mode) {
|
||||||
|
#if defined(WEBRTC_USE_H264)
|
||||||
return H264Encoder::SupportsScalabilityMode(scalability_mode);
|
return H264Encoder::SupportsScalabilityMode(scalability_mode);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif // defined(WEBRTC_USE_H264)
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_OPEN_H264_ADAPTER_H_
|
#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_OPEN_H264_ADAPTER_H_
|
||||||
|
|
|
@ -929,10 +929,19 @@ if (rtc_include_tests) {
|
||||||
"../../api/transport:field_trial_based_config",
|
"../../api/transport:field_trial_based_config",
|
||||||
"../../api/video:video_bitrate_allocation",
|
"../../api/video:video_bitrate_allocation",
|
||||||
"../../api/video_codecs:video_codecs_api",
|
"../../api/video_codecs:video_codecs_api",
|
||||||
|
"../../api/video_codecs:video_decoder_factory_template",
|
||||||
|
"../../api/video_codecs:video_decoder_factory_template_dav1d_adapter",
|
||||||
|
"../../api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter",
|
||||||
|
"../../api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter",
|
||||||
|
"../../api/video_codecs:video_decoder_factory_template_open_h264_adapter",
|
||||||
|
"../../api/video_codecs:video_encoder_factory_template",
|
||||||
|
"../../api/video_codecs:video_encoder_factory_template_libaom_av1_adapter",
|
||||||
|
"../../api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter",
|
||||||
|
"../../api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
|
||||||
|
"../../api/video_codecs:video_encoder_factory_template_open_h264_adapter",
|
||||||
"../../call:video_stream_api",
|
"../../call:video_stream_api",
|
||||||
"../../common_video",
|
"../../common_video",
|
||||||
"../../media:rtc_audio_video",
|
"../../media:rtc_audio_video",
|
||||||
"../../media:rtc_internal_video_codecs",
|
|
||||||
"../../media:rtc_media_base",
|
"../../media:rtc_media_base",
|
||||||
"../../rtc_base:checks",
|
"../../rtc_base:checks",
|
||||||
"../../rtc_base:logging",
|
"../../rtc_base:logging",
|
||||||
|
|
|
@ -29,11 +29,20 @@
|
||||||
#include "api/video_codecs/sdp_video_format.h"
|
#include "api/video_codecs/sdp_video_format.h"
|
||||||
#include "api/video_codecs/video_codec.h"
|
#include "api/video_codecs/video_codec.h"
|
||||||
#include "api/video_codecs/video_decoder.h"
|
#include "api/video_codecs/video_decoder.h"
|
||||||
|
#include "api/video_codecs/video_decoder_factory_template.h"
|
||||||
|
#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
|
||||||
|
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
|
||||||
|
#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h"
|
||||||
|
#include "api/video_codecs/video_decoder_factory_template_open_h264_adapter.h"
|
||||||
#include "api/video_codecs/video_encoder_config.h"
|
#include "api/video_codecs/video_encoder_config.h"
|
||||||
|
#include "api/video_codecs/video_encoder_factory.h"
|
||||||
|
#include "api/video_codecs/video_encoder_factory_template.h"
|
||||||
|
#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"
|
||||||
|
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
|
||||||
|
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
|
||||||
|
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
|
||||||
#include "common_video/h264/h264_common.h"
|
#include "common_video/h264/h264_common.h"
|
||||||
#include "media/base/media_constants.h"
|
#include "media/base/media_constants.h"
|
||||||
#include "media/engine/internal_decoder_factory.h"
|
|
||||||
#include "media/engine/internal_encoder_factory.h"
|
|
||||||
#include "media/engine/simulcast.h"
|
#include "media/engine/simulcast.h"
|
||||||
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
|
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
|
||||||
#include "modules/video_coding/codecs/vp9/svc_config.h"
|
#include "modules/video_coding/codecs/vp9/svc_config.h"
|
||||||
|
@ -157,9 +166,12 @@ SdpVideoFormat CreateSdpVideoFormat(
|
||||||
{cricket::kH264FmtpProfileLevelId,
|
{cricket::kH264FmtpProfileLevelId,
|
||||||
*H264ProfileLevelIdToString(H264ProfileLevelId(
|
*H264ProfileLevelIdToString(H264ProfileLevelId(
|
||||||
config.h264_codec_settings.profile, H264Level::kLevel3_1))},
|
config.h264_codec_settings.profile, H264Level::kLevel3_1))},
|
||||||
{cricket::kH264FmtpPacketizationMode, packetization_mode}};
|
{cricket::kH264FmtpPacketizationMode, packetization_mode},
|
||||||
|
{cricket::kH264FmtpLevelAsymmetryAllowed, "1"}};
|
||||||
|
|
||||||
return SdpVideoFormat(config.codec_name, codec_params);
|
return SdpVideoFormat(config.codec_name, codec_params);
|
||||||
|
} else if (config.codec_settings.codecType == kVideoCodecVP9) {
|
||||||
|
return SdpVideoFormat(config.codec_name, {{"profile-id", "0"}});
|
||||||
}
|
}
|
||||||
|
|
||||||
return SdpVideoFormat(config.codec_name);
|
return SdpVideoFormat(config.codec_name);
|
||||||
|
@ -406,8 +418,16 @@ class VideoCodecTestFixtureImpl::CpuProcessTime final {
|
||||||
};
|
};
|
||||||
|
|
||||||
VideoCodecTestFixtureImpl::VideoCodecTestFixtureImpl(Config config)
|
VideoCodecTestFixtureImpl::VideoCodecTestFixtureImpl(Config config)
|
||||||
: encoder_factory_(std::make_unique<InternalEncoderFactory>()),
|
: encoder_factory_(std::make_unique<webrtc::VideoEncoderFactoryTemplate<
|
||||||
decoder_factory_(std::make_unique<InternalDecoderFactory>()),
|
webrtc::LibvpxVp8EncoderTemplateAdapter,
|
||||||
|
webrtc::LibvpxVp9EncoderTemplateAdapter,
|
||||||
|
webrtc::OpenH264EncoderTemplateAdapter,
|
||||||
|
webrtc::LibaomAv1EncoderTemplateAdapter>>()),
|
||||||
|
decoder_factory_(std::make_unique<webrtc::VideoDecoderFactoryTemplate<
|
||||||
|
webrtc::LibvpxVp8DecoderTemplateAdapter,
|
||||||
|
webrtc::LibvpxVp9DecoderTemplateAdapter,
|
||||||
|
webrtc::OpenH264DecoderTemplateAdapter,
|
||||||
|
webrtc::Dav1dDecoderTemplateAdapter>>()),
|
||||||
config_(config) {}
|
config_(config) {}
|
||||||
|
|
||||||
VideoCodecTestFixtureImpl::VideoCodecTestFixtureImpl(
|
VideoCodecTestFixtureImpl::VideoCodecTestFixtureImpl(
|
||||||
|
|
Loading…
Reference in a new issue