• 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/test/video/video_frame_writer.h"
18 #include "api/video/video_frame.h"
19 #include "rtc_base/buffer.h"
20 #include "test/testsupport/frame_writer.h"
21 
22 namespace webrtc {
23 namespace test {
24 
25 // Writes webrtc::VideoFrame to specified file with y4m frame writer
26 class Y4mVideoFrameWriterImpl : public VideoFrameWriter {
27  public:
28   Y4mVideoFrameWriterImpl(std::string output_file_name,
29                           int width,
30                           int height,
31                           int fps);
32   ~Y4mVideoFrameWriterImpl() override = default;
33 
34   bool WriteFrame(const webrtc::VideoFrame& frame) override;
35   void Close() override;
36 
37  private:
38   const int width_;
39   const int height_;
40 
41   std::unique_ptr<FrameWriter> frame_writer_;
42 };
43 
44 // Writes webrtc::VideoFrame to specified file with yuv frame writer
45 class YuvVideoFrameWriterImpl : public VideoFrameWriter {
46  public:
47   YuvVideoFrameWriterImpl(std::string output_file_name, int width, int height);
48   ~YuvVideoFrameWriterImpl() override = default;
49 
50   bool WriteFrame(const webrtc::VideoFrame& frame) override;
51   void Close() override;
52 
53  private:
54   const int width_;
55   const int height_;
56 
57   std::unique_ptr<FrameWriter> frame_writer_;
58 };
59 
60 }  // namespace test
61 }  // namespace webrtc
62 
63 #endif  // TEST_TESTSUPPORT_VIDEO_FRAME_WRITER_H_
64