Using FunctionVideoEncoderFactory in VideoQualityTest.

This reduces code duplication. FunctionVideoEncoderFactory is modified
to allow providing a function that takes an argument for the format.

Bug: webrtc:9510
Change-Id: I67fee84af4968a51326b52db35f3eb0c65848735
Reviewed-on: https://webrtc-review.googlesource.com/88222
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23965}
This commit is contained in:
Sebastian Jansson
2018-07-11 15:00:41 +02:00
committed by Commit Bot
parent 8e6602fade
commit e6d7c3e32a
3 changed files with 25 additions and 44 deletions

View File

@ -29,10 +29,11 @@ class FunctionVideoEncoderFactory final : public VideoEncoderFactory {
public:
explicit FunctionVideoEncoderFactory(
std::function<std::unique_ptr<VideoEncoder>()> create)
: create_(std::move(create)) {
codec_info_.is_hardware_accelerated = false;
codec_info_.has_internal_source = false;
}
: create_([create](const SdpVideoFormat&) { return create(); }) {}
explicit FunctionVideoEncoderFactory(
std::function<std::unique_ptr<VideoEncoder>(const SdpVideoFormat&)>
create)
: create_(std::move(create)) {}
// Unused by tests.
std::vector<SdpVideoFormat> GetSupportedFormats() const override {
@ -42,17 +43,20 @@ class FunctionVideoEncoderFactory final : public VideoEncoderFactory {
CodecInfo QueryVideoEncoder(
const SdpVideoFormat& /* format */) const override {
return codec_info_;
CodecInfo codec_info;
codec_info.is_hardware_accelerated = false;
codec_info.has_internal_source = false;
return codec_info;
}
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
const SdpVideoFormat& /* format */) override {
return create_();
const SdpVideoFormat& format) override {
return create_(format);
}
private:
const std::function<std::unique_ptr<VideoEncoder>()> create_;
CodecInfo codec_info_;
const std::function<std::unique_ptr<VideoEncoder>(const SdpVideoFormat&)>
create_;
};
} // namespace test