Chromium Code Reviews| Index: webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc |
| diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc |
| index 7fd5dc2de79567b1edd32e55ccdb2e7fee838d68..25abc91a8d33b8c8aa3e8d64217518159fda075a 100644 |
| --- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc |
| +++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc |
| @@ -22,6 +22,7 @@ |
| #include "webrtc/media/engine/internaldecoderfactory.h" |
| #include "webrtc/media/engine/internalencoderfactory.h" |
| +#include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h" |
| #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" |
| #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| #include "webrtc/modules/video_coding/include/video_coding.h" |
| @@ -89,8 +90,12 @@ void VideoProcessorIntegrationTest::SetCodecSettings(TestConfig* config, |
| int width, |
| int height) { |
| webrtc::test::CodecSettings(codec_type, &config->codec_settings); |
| + |
| + // TODO(brandtr): Move the setting of |width| and |height| to the tests, and |
| + // DCHECK that they are set before initializing the codec instead. |
| config->codec_settings.width = width; |
| config->codec_settings.height = height; |
| + |
| switch (config->codec_settings.codecType) { |
| case kVideoCodecVP8: |
| config->codec_settings.VP8()->resilience = |
| @@ -186,7 +191,7 @@ void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify( |
| // MediaCodec API, we roughly pace the frames here. The downside |
| // of this is that the encode run will be done in real-time. |
| // TODO(brandtr): Investigate if this is needed on iOS. |
| - if (config_.hw_codec) { |
| + if (config_.hw_encoder || config_.hw_decoder) { |
| SleepMs(rtc::kNumMillisecsPerSec / |
| rate_profile.input_frame_rate[rate_update_index]); |
| } |
| @@ -208,7 +213,7 @@ void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify( |
| // Give the VideoProcessor pipeline some time to process the last frame, |
| // and then release the codecs. |
| - if (config_.hw_codec) { |
| + if (config_.hw_encoder || config_.hw_decoder) { |
| SleepMs(1 * rtc::kNumMillisecsPerSec); |
| } |
| ReleaseAndCloseObjects(&task_queue); |
| @@ -270,41 +275,55 @@ void VideoProcessorIntegrationTest::ProcessFramesAndMaybeVerify( |
| } |
| void VideoProcessorIntegrationTest::CreateEncoderAndDecoder() { |
| - if (config_.hw_codec) { |
| + std::unique_ptr<cricket::WebRtcVideoEncoderFactory> encoder_factory; |
| + if (config_.hw_encoder) { |
| +#if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) |
| +#if defined(WEBRTC_ANDROID) |
| + encoder_factory.reset(new jni::MediaCodecVideoEncoderFactory()); |
| +#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 |
| +#endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED |
| + } else { |
| + encoder_factory.reset(new cricket::InternalEncoderFactory()); |
| + } |
| + |
| + if (config_.hw_decoder) { |
| #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) |
| #if defined(WEBRTC_ANDROID) |
| - encoder_factory_.reset(new jni::MediaCodecVideoEncoderFactory()); |
| decoder_factory_.reset(new jni::MediaCodecVideoDecoderFactory()); |
| #elif defined(WEBRTC_IOS) |
| EXPECT_EQ(kVideoCodecH264, config_.codec_settings.codecType) |
| << "iOS HW codecs only support H264."; |
| - encoder_factory_ = CreateObjCEncoderFactory(); |
| decoder_factory_ = CreateObjCDecoderFactory(); |
| #else |
| - RTC_NOTREACHED() << "Only support HW codecs on Android and iOS."; |
| + RTC_NOTREACHED() << "Only support HW decoder on Android and iOS."; |
| #endif |
| #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED |
| } else { |
| - // SW codecs. |
| - encoder_factory_.reset(new cricket::InternalEncoderFactory()); |
| decoder_factory_.reset(new cricket::InternalDecoderFactory()); |
| } |
| + cricket::VideoCodec codec; |
|
srte
2017/09/05 11:11:07
Since this seems to only be used for the encoder c
brandtr
2017/09/06 11:17:27
Done.
|
| switch (config_.codec_settings.codecType) { |
| case kVideoCodecVP8: |
| - encoder_ = encoder_factory_->CreateVideoEncoder( |
| - cricket::VideoCodec(cricket::kVp8CodecName)); |
| + codec = cricket::VideoCodec(cricket::kVp8CodecName); |
| + encoder_.reset(encoder_factory->CreateVideoEncoder(codec)); |
| decoder_ = decoder_factory_->CreateVideoDecoder(kVideoCodecVP8); |
| break; |
| case kVideoCodecVP9: |
| - encoder_ = encoder_factory_->CreateVideoEncoder( |
| - cricket::VideoCodec(cricket::kVp9CodecName)); |
| + codec = cricket::VideoCodec(cricket::kVp9CodecName); |
| + encoder_.reset(encoder_factory->CreateVideoEncoder(codec)); |
| decoder_ = decoder_factory_->CreateVideoDecoder(kVideoCodecVP9); |
| break; |
| case kVideoCodecH264: |
| // TODO(brandtr): Generalize so that we support multiple profiles here. |
| - encoder_ = encoder_factory_->CreateVideoEncoder( |
| - cricket::VideoCodec(cricket::kH264CodecName)); |
| + codec = cricket::VideoCodec(cricket::kH264CodecName); |
| + encoder_.reset(encoder_factory->CreateVideoEncoder(codec)); |
| decoder_ = decoder_factory_->CreateVideoDecoder(kVideoCodecH264); |
| break; |
| default: |
| @@ -312,12 +331,17 @@ void VideoProcessorIntegrationTest::CreateEncoderAndDecoder() { |
| break; |
| } |
| + if (config_.sw_fallback_encoder) { |
| + encoder_ = rtc::MakeUnique<VideoEncoderSoftwareFallbackWrapper>( |
| + codec, std::move(encoder_)); |
| + } |
| + |
| EXPECT_TRUE(encoder_) << "Encoder not successfully created."; |
| EXPECT_TRUE(decoder_) << "Decoder not successfully created."; |
| } |
| void VideoProcessorIntegrationTest::DestroyEncoderAndDecoder() { |
| - encoder_factory_->DestroyVideoEncoder(encoder_); |
| + encoder_.reset(); |
| decoder_factory_->DestroyVideoDecoder(decoder_); |
| } |
| @@ -341,7 +365,7 @@ void VideoProcessorIntegrationTest::SetUpAndInitObjects( |
| if (visualization_params) { |
| const std::string codec_name = |
| CodecTypeToPayloadString(config_.codec_settings.codecType); |
| - const std::string implementation_type = config_.hw_codec ? "hw" : "sw"; |
| + const std::string implementation_type = config_.hw_encoder ? "hw" : "sw"; |
| // clang-format off |
| const std::string output_filename_base = |
| OutputPath() + config_.filename + "-" + |
| @@ -372,7 +396,7 @@ void VideoProcessorIntegrationTest::SetUpAndInitObjects( |
| rtc::Event sync_event(false, false); |
| task_queue->PostTask([this, &sync_event]() { |
| processor_ = rtc::MakeUnique<VideoProcessor>( |
| - encoder_, decoder_, analysis_frame_reader_.get(), |
| + encoder_.get(), decoder_, analysis_frame_reader_.get(), |
|
srte
2017/09/05 11:11:07
Somewhat dangerous call to .get() here, just make
brandtr
2017/09/06 11:17:27
Yes, the lifetime of the objects passed in here ne
|
| analysis_frame_writer_.get(), packet_manipulator_.get(), config_, |
| &stats_, encoded_frame_writer_.get(), decoded_frame_writer_.get()); |
| processor_->Init(); |