• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef TEST_TESTSUPPORT_VIDEO_FRAME_WRITER_H_
12 #define TEST_TESTSUPPORT_VIDEO_FRAME_WRITER_H_
13 
14 #include <memory>
15 #include <string>
16 
17 #include "api/video/video_frame.h"
18 #include "rtc_base/buffer.h"
19 #include "test/testsupport/frame_writer.h"
20 
21 namespace webrtc {
22 namespace test {
23 
24 class VideoFrameWriter {
25  public:
26   virtual ~VideoFrameWriter() = default;
27 
28   virtual bool WriteFrame(const webrtc::VideoFrame& frame) = 0;
29 
30   virtual void Close() = 0;
31 };
32 
33 // Writes webrtc::VideoFrame to specified file with y4m frame writer
34 class Y4mVideoFrameWriterImpl : public VideoFrameWriter {
35  public:
36   Y4mVideoFrameWriterImpl(std::string output_file_name,
37                           int width,
38                           int height,
39                           int fps);
40   ~Y4mVideoFrameWriterImpl() override = default;
41 
42   bool WriteFrame(const webrtc::VideoFrame& frame) override;
43   void Close() override;
44 
45  private:
46   const int width_;
47   const int height_;
48 
49   std::unique_ptr<FrameWriter> frame_writer_;
50 };
51 
52 // Writes webrtc::VideoFrame to specified file with yuv frame writer
53 class YuvVideoFrameWriterImpl : public VideoFrameWriter {
54  public:
55   YuvVideoFrameWriterImpl(std::string output_file_name, int width, int height);
56   ~YuvVideoFrameWriterImpl() override = default;
57 
58   bool WriteFrame(const webrtc::VideoFrame& frame) override;
59   void Close() override;
60 
61  private:
62   const int width_;
63   const int height_;
64 
65   std::unique_ptr<FrameWriter> frame_writer_;
66 };
67 
68 }  // namespace test
69 }  // namespace webrtc
70 
71 #endif  // TEST_TESTSUPPORT_VIDEO_FRAME_WRITER_H_
72