Skip to content

Commit

Permalink
Add ability for inject custom codec factories in VP integration test.
Browse files Browse the repository at this point in the history
This makes it easier to add new test cases without modifying the actual test class.

Bug: None
Change-Id: I48e4f14e26cd6610678ffb07ce9fd56e6bc1ac4e
Reviewed-on: https://webrtc-review.googlesource.com/69600
Commit-Queue: Kári Helgason <[email protected]>
Reviewed-by: Rasmus Brandt <[email protected]>
Cr-Commit-Position: refs/heads/master@{#22840}
  • Loading branch information
kthelgason authored and Commit Bot committed Apr 12, 2018
1 parent 98a91ad commit c3f8c75
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 21 deletions.
40 changes: 20 additions & 20 deletions modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -298,35 +296,37 @@ void VideoProcessorIntegrationTest::VerifyVideoStatistic(
}
}

void VideoProcessorIntegrationTest::CreateEncoderAndDecoder() {
if (config_.hw_encoder) {
std::unique_ptr<VideoDecoderFactory>
VideoProcessorIntegrationTest::CreateDecoderFactory() {
if (config_.hw_decoder) {
#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();
return CreateAndroidDecoderFactory();
#else
RTC_NOTREACHED() << "Only support HW encoder on Android and iOS.";
RTC_NOTREACHED() << "Only support HW decoder on Android.";
return nullptr;
#endif
} else {
encoder_factory_ = rtc::MakeUnique<InternalEncoderFactory>();
return rtc::MakeUnique<InternalDecoderFactory>();
}
}

std::unique_ptr<VideoDecoderFactory> decoder_factory;
if (config_.hw_decoder) {
std::unique_ptr<VideoEncoderFactory>
VideoProcessorIntegrationTest::CreateEncoderFactory() {
if (config_.hw_encoder) {
#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 CreateAndroidEncoderFactory();
#else
RTC_NOTREACHED() << "Only support HW decoder on Android and iOS.";
RTC_NOTREACHED() << "Only support HW encoder on Android.";
return nullptr;
#endif
} else {
decoder_factory = rtc::MakeUnique<InternalDecoderFactory>();
return rtc::MakeUnique<InternalEncoderFactory>();
}
}

void VideoProcessorIntegrationTest::CreateEncoderAndDecoder() {
encoder_factory_ = CreateEncoderFactory();
std::unique_ptr<VideoDecoderFactory> decoder_factory = CreateDecoderFactory();

const SdpVideoFormat format = config_.ToSdpVideoFormat();
if (config_.simulcast_adapted_encoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <string>
#include <vector>

#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"
Expand Down Expand Up @@ -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<VideoDecoderFactory> CreateDecoderFactory();
virtual std::unique_ptr<VideoEncoderFactory> CreateEncoderFactory();

private:
class CpuProcessTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <vector>

#include "modules/video_coding/codecs/test/objc_codec_factory_helper.h"
#include "test/field_trial.h"
#include "test/testsupport/fileutils.h"

Expand All @@ -33,12 +34,32 @@ class VideoProcessorIntegrationTestVideoToolbox
config_.hw_decoder = true;
config_.encoded_frame_checker = &h264_keyframe_checker_;
}

std::unique_ptr<VideoDecoderFactory> 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<VideoEncoderFactory> 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
Expand Down

0 comments on commit c3f8c75

Please sign in to comment.