diff --git a/video/BUILD.gn b/video/BUILD.gn index e7f5a5b96b..634e40eda8 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -163,6 +163,7 @@ rtc_source_set("frame_dumping_decoder") { "../modules/video_coding:video_codec_interface", "../modules/video_coding:video_coding_utility", "../rtc_base:rtc_base_approved", + "../rtc_base/system:file_wrapper", "//third_party/abseil-cpp/absl/memory", ] } diff --git a/video/frame_dumping_decoder.cc b/video/frame_dumping_decoder.cc index 72fc0ff3b9..31d024cf99 100644 --- a/video/frame_dumping_decoder.cc +++ b/video/frame_dumping_decoder.cc @@ -12,9 +12,34 @@ #include +#include "absl/memory/memory.h" #include "modules/video_coding/include/video_codec_interface.h" +#include "modules/video_coding/utility/ivf_file_writer.h" namespace webrtc { +namespace { + +class FrameDumpingDecoder : public VideoDecoder { + public: + FrameDumpingDecoder(std::unique_ptr 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 decoder_; + VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric; + std::unique_ptr writer_; +}; FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr decoder, FileWrapper file) @@ -56,4 +81,13 @@ const char* FrameDumpingDecoder::ImplementationName() const { return decoder_->ImplementationName(); } +} // namespace + +std::unique_ptr CreateFrameDumpingDecoderWrapper( + std::unique_ptr decoder, + FileWrapper file) { + return absl::make_unique(std::move(decoder), + std::move(file)); +} + } // namespace webrtc diff --git a/video/frame_dumping_decoder.h b/video/frame_dumping_decoder.h index 8235a1e88c..3a97c8bc61 100644 --- a/video/frame_dumping_decoder.h +++ b/video/frame_dumping_decoder.h @@ -11,40 +11,17 @@ #ifndef VIDEO_FRAME_DUMPING_DECODER_H_ #define VIDEO_FRAME_DUMPING_DECODER_H_ -#include - #include -#include "api/video/encoded_image.h" -#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_decoder.h" -#include "modules/video_coding/include/video_codec_interface.h" -#include "modules/video_coding/utility/ivf_file_writer.h" +#include "rtc_base/system/file_wrapper.h" namespace webrtc { -// A decoder wrapper that writes the encoded frames to a file. -class FrameDumpingDecoder : public VideoDecoder { - public: - FrameDumpingDecoder(std::unique_ptr 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 decoder_; - VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric; - std::unique_ptr writer_; -}; +// Creates a decoder wrapper that writes the encoded frames to an IVF file. +std::unique_ptr CreateFrameDumpingDecoderWrapper( + std::unique_ptr decoder, + FileWrapper file); } // namespace webrtc diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index fedcffaf9d..663452a53a 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -286,7 +286,7 @@ std::unique_ptr VideoQualityTest::CreateVideoDecoder( str << receive_logs_++; std::string path = params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; - decoder = absl::make_unique( + decoder = CreateFrameDumpingDecoderWrapper( std::move(decoder), FileWrapper::OpenWriteOnly(path)); } return decoder; diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index df27405b45..3e26fa9c21 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -362,7 +362,7 @@ void VideoReceiveStream::Start() { ssb << decoded_output_file << "/webrtc_receive_stream_" << this->config_.rtp.remote_ssrc << "-" << rtc::TimeMicros() << ".ivf"; - video_decoder = absl::make_unique( + video_decoder = CreateFrameDumpingDecoderWrapper( std::move(video_decoder), FileWrapper::OpenWriteOnly(ssb.str())); }