diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc index 379008514b..12edc8a0f8 100644 --- a/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc +++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc @@ -16,8 +16,6 @@ #if defined(WEBRTC_ANDROID) #include "modules/video_coding/codecs/test/android_codec_factory_helper.h" -#elif defined(WEBRTC_IOS) -#include "modules/video_coding/codecs/test/objc_codec_factory_helper.h" #endif #include "api/video_codecs/sdp_video_format.h" @@ -298,35 +296,37 @@ void VideoProcessorIntegrationTest::VerifyVideoStatistic( } } -void VideoProcessorIntegrationTest::CreateEncoderAndDecoder() { - if (config_.hw_encoder) { -#if defined(WEBRTC_ANDROID) - encoder_factory_ = CreateAndroidEncoderFactory(); -#elif defined(WEBRTC_IOS) - EXPECT_EQ(kVideoCodecH264, config_.codec_settings.codecType) - << "iOS HW codecs only support H264."; - encoder_factory_ = CreateObjCEncoderFactory(); -#else - RTC_NOTREACHED() << "Only support HW encoder on Android and iOS."; -#endif - } else { - encoder_factory_ = rtc::MakeUnique(); - } - - std::unique_ptr decoder_factory; +std::unique_ptr +VideoProcessorIntegrationTest::CreateDecoderFactory() { if (config_.hw_decoder) { #if defined(WEBRTC_ANDROID) - decoder_factory = CreateAndroidDecoderFactory(); -#elif defined(WEBRTC_IOS) - EXPECT_EQ(kVideoCodecH264, config_.codec_settings.codecType) - << "iOS HW codecs only support H264."; - decoder_factory = CreateObjCDecoderFactory(); + return CreateAndroidDecoderFactory(); #else - RTC_NOTREACHED() << "Only support HW decoder on Android and iOS."; + RTC_NOTREACHED() << "Only support HW decoder on Android."; + return nullptr; #endif } else { - decoder_factory = rtc::MakeUnique(); + return rtc::MakeUnique(); } +} + +std::unique_ptr +VideoProcessorIntegrationTest::CreateEncoderFactory() { + if (config_.hw_encoder) { +#if defined(WEBRTC_ANDROID) + return CreateAndroidEncoderFactory(); +#else + RTC_NOTREACHED() << "Only support HW encoder on Android."; + return nullptr; +#endif + } else { + return rtc::MakeUnique(); + } +} + +void VideoProcessorIntegrationTest::CreateEncoderAndDecoder() { + encoder_factory_ = CreateEncoderFactory(); + std::unique_ptr decoder_factory = CreateDecoderFactory(); const SdpVideoFormat format = config_.ToSdpVideoFormat(); if (config_.simulcast_adapted_encoder) { diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest.h b/modules/video_coding/codecs/test/videoprocessor_integrationtest.h index cce9baf442..32a9160773 100644 --- a/modules/video_coding/codecs/test/videoprocessor_integrationtest.h +++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest.h @@ -17,6 +17,7 @@ #include #include +#include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" #include "common_types.h" // NOLINT(build/include) #include "common_video/h264/h264_common.h" @@ -98,6 +99,11 @@ class VideoProcessorIntegrationTest : public testing::Test { // Can be used by all H.264 tests. const H264KeyframeChecker h264_keyframe_checker_; + protected: + // Overwrite in subclasses for custom codec factories. + virtual std::unique_ptr CreateDecoderFactory(); + virtual std::unique_ptr CreateEncoderFactory(); + private: class CpuProcessTime; diff --git a/modules/video_coding/codecs/test/videoprocessor_integrationtest_videotoolbox.cc b/modules/video_coding/codecs/test/videoprocessor_integrationtest_videotoolbox.cc index 43647b6d82..54b38bec28 100644 --- a/modules/video_coding/codecs/test/videoprocessor_integrationtest_videotoolbox.cc +++ b/modules/video_coding/codecs/test/videoprocessor_integrationtest_videotoolbox.cc @@ -12,6 +12,7 @@ #include +#include "modules/video_coding/codecs/test/objc_codec_factory_helper.h" #include "test/field_trial.h" #include "test/testsupport/fileutils.h" @@ -33,12 +34,32 @@ class VideoProcessorIntegrationTestVideoToolbox config_.hw_decoder = true; config_.encoded_frame_checker = &h264_keyframe_checker_; } + + std::unique_ptr CreateDecoderFactory() override { + if (config_.hw_decoder) { + EXPECT_EQ(kVideoCodecH264, config_.codec_settings.codecType) + << "iOS HW codecs only support H264."; + return CreateObjCDecoderFactory(); + } + RTC_NOTREACHED() << "Only support HW decoder on iOS."; + return nullptr; + } + + std::unique_ptr CreateEncoderFactory() override { + if (config_.hw_encoder) { + EXPECT_EQ(kVideoCodecH264, config_.codec_settings.codecType) + << "iOS HW codecs only support H264."; + return CreateObjCEncoderFactory(); + } + RTC_NOTREACHED() << "Only support HW encoder on iOS."; + return nullptr; + } }; // TODO(webrtc:9099): Disabled until the issue is fixed. // HW codecs don't work on simulators. Only run these tests on device. // #if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR -// #define MAYBE_TEST_F TEST_F +// #define MAYBE_TEST_F TEST_F // #else #define MAYBE_TEST_F(s, name) TEST_F(s, DISABLED_##name) // #endif