video_frame_writer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef TEST_TESTSUPPORT_VIDEO_FRAME_WRITER_H_
  11. #define TEST_TESTSUPPORT_VIDEO_FRAME_WRITER_H_
  12. #include <memory>
  13. #include <string>
  14. #include "api/video/video_frame.h"
  15. #include "rtc_base/buffer.h"
  16. #include "test/testsupport/frame_writer.h"
  17. namespace webrtc {
  18. namespace test {
  19. class VideoFrameWriter {
  20. public:
  21. virtual ~VideoFrameWriter() = default;
  22. virtual bool WriteFrame(const webrtc::VideoFrame& frame) = 0;
  23. virtual void Close() = 0;
  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. bool WriteFrame(const webrtc::VideoFrame& frame) override;
  34. void Close() override;
  35. private:
  36. const int width_;
  37. const int height_;
  38. std::unique_ptr<FrameWriter> frame_writer_;
  39. };
  40. // Writes webrtc::VideoFrame to specified file with yuv frame writer
  41. class YuvVideoFrameWriterImpl : public VideoFrameWriter {
  42. public:
  43. YuvVideoFrameWriterImpl(std::string output_file_name, int width, int height);
  44. ~YuvVideoFrameWriterImpl() override = default;
  45. bool WriteFrame(const webrtc::VideoFrame& frame) override;
  46. void Close() override;
  47. private:
  48. const int width_;
  49. const int height_;
  50. std::unique_ptr<FrameWriter> frame_writer_;
  51. };
  52. } // namespace test
  53. } // namespace webrtc
  54. #endif // TEST_TESTSUPPORT_VIDEO_FRAME_WRITER_H_