Simplify the VideoFrameDumpingDecoder API.

This CL changes the VideoFrameDumpingDecoder API to only expose a
factory function creating the wrapper instead of the full class.

Bug: webrtc:10902
Change-Id: I1e7e3a60accea1a7c48207d4262ed4bacacab4a2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150040
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28924}
This commit is contained in:
Markus Handell 2019-08-20 20:21:37 +02:00 committed by Commit Bot
parent 54d5d2c75b
commit 1c2f6372f6
5 changed files with 42 additions and 30 deletions

View File

@ -163,6 +163,7 @@ rtc_source_set("frame_dumping_decoder") {
"../modules/video_coding:video_codec_interface", "../modules/video_coding:video_codec_interface",
"../modules/video_coding:video_coding_utility", "../modules/video_coding:video_coding_utility",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base/system:file_wrapper",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
] ]
} }

View File

@ -12,9 +12,34 @@
#include <utility> #include <utility>
#include "absl/memory/memory.h"
#include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
namespace webrtc { namespace webrtc {
namespace {
class FrameDumpingDecoder : public VideoDecoder {
public:
FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder, FileWrapper file);
~FrameDumpingDecoder() override;
int32_t InitDecode(const VideoCodec* codec_settings,
int32_t number_of_cores) override;
int32_t Decode(const EncodedImage& input_image,
bool missing_frames,
int64_t render_time_ms) override;
int32_t RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) override;
int32_t Release() override;
bool PrefersLateDecoding() const override;
const char* ImplementationName() const override;
private:
std::unique_ptr<VideoDecoder> decoder_;
VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric;
std::unique_ptr<IvfFileWriter> writer_;
};
FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder, FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder,
FileWrapper file) FileWrapper file)
@ -56,4 +81,13 @@ const char* FrameDumpingDecoder::ImplementationName() const {
return decoder_->ImplementationName(); return decoder_->ImplementationName();
} }
} // namespace
std::unique_ptr<VideoDecoder> CreateFrameDumpingDecoderWrapper(
std::unique_ptr<VideoDecoder> decoder,
FileWrapper file) {
return absl::make_unique<FrameDumpingDecoder>(std::move(decoder),
std::move(file));
}
} // namespace webrtc } // namespace webrtc

View File

@ -11,40 +11,17 @@
#ifndef VIDEO_FRAME_DUMPING_DECODER_H_ #ifndef VIDEO_FRAME_DUMPING_DECODER_H_
#define VIDEO_FRAME_DUMPING_DECODER_H_ #define VIDEO_FRAME_DUMPING_DECODER_H_
#include <stdint.h>
#include <memory> #include <memory>
#include "api/video/encoded_image.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_decoder.h" #include "api/video_codecs/video_decoder.h"
#include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/system/file_wrapper.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
namespace webrtc { namespace webrtc {
// A decoder wrapper that writes the encoded frames to a file. // Creates a decoder wrapper that writes the encoded frames to an IVF file.
class FrameDumpingDecoder : public VideoDecoder { std::unique_ptr<VideoDecoder> CreateFrameDumpingDecoderWrapper(
public: std::unique_ptr<VideoDecoder> decoder,
FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder, FileWrapper file); FileWrapper file);
~FrameDumpingDecoder() override;
int32_t InitDecode(const VideoCodec* codec_settings,
int32_t number_of_cores) override;
int32_t Decode(const EncodedImage& input_image,
bool missing_frames,
int64_t render_time_ms) override;
int32_t RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) override;
int32_t Release() override;
bool PrefersLateDecoding() const override;
const char* ImplementationName() const override;
private:
std::unique_ptr<VideoDecoder> decoder_;
VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric;
std::unique_ptr<IvfFileWriter> writer_;
};
} // namespace webrtc } // namespace webrtc

View File

@ -286,7 +286,7 @@ std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder(
str << receive_logs_++; str << receive_logs_++;
std::string path = std::string path =
params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
decoder = absl::make_unique<FrameDumpingDecoder>( decoder = CreateFrameDumpingDecoderWrapper(
std::move(decoder), FileWrapper::OpenWriteOnly(path)); std::move(decoder), FileWrapper::OpenWriteOnly(path));
} }
return decoder; return decoder;

View File

@ -362,7 +362,7 @@ void VideoReceiveStream::Start() {
ssb << decoded_output_file << "/webrtc_receive_stream_" ssb << decoded_output_file << "/webrtc_receive_stream_"
<< this->config_.rtp.remote_ssrc << "-" << rtc::TimeMicros() << this->config_.rtp.remote_ssrc << "-" << rtc::TimeMicros()
<< ".ivf"; << ".ivf";
video_decoder = absl::make_unique<FrameDumpingDecoder>( video_decoder = CreateFrameDumpingDecoderWrapper(
std::move(video_decoder), FileWrapper::OpenWriteOnly(ssb.str())); std::move(video_decoder), FileWrapper::OpenWriteOnly(ssb.str()));
} }