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}
diff --git a/video/BUILD.gn b/video/BUILD.gn
index e7f5a5b..634e40e 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -163,6 +163,7 @@
     "../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 72fc0ff..31d024c 100644
--- a/video/frame_dumping_decoder.cc
+++ b/video/frame_dumping_decoder.cc
@@ -12,9 +12,34 @@
 
 #include <utility>
 
+#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<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,
                                          FileWrapper file)
@@ -56,4 +81,13 @@
   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
diff --git a/video/frame_dumping_decoder.h b/video/frame_dumping_decoder.h
index 8235a1e..3a97c8b 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 <stdint.h>
-
 #include <memory>
 
-#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<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_;
-};
+// Creates a decoder wrapper that writes the encoded frames to an IVF file.
+std::unique_ptr<VideoDecoder> CreateFrameDumpingDecoderWrapper(
+    std::unique_ptr<VideoDecoder> decoder,
+    FileWrapper file);
 
 }  // namespace webrtc
 
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index fedcffa..663452a 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -286,7 +286,7 @@
     str << receive_logs_++;
     std::string path =
         params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
-    decoder = absl::make_unique<FrameDumpingDecoder>(
+    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 df27405..3e26fa9 100644
--- a/video/video_receive_stream.cc
+++ b/video/video_receive_stream.cc
@@ -362,7 +362,7 @@
       ssb << decoded_output_file << "/webrtc_receive_stream_"
           << this->config_.rtp.remote_ssrc << "-" << rtc::TimeMicros()
           << ".ivf";
-      video_decoder = absl::make_unique<FrameDumpingDecoder>(
+      video_decoder = CreateFrameDumpingDecoderWrapper(
           std::move(video_decoder), FileWrapper::OpenWriteOnly(ssb.str()));
     }