| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 virtual bool WriteFrame(uint8_t* frame_buffer) = 0; | 35 virtual bool WriteFrame(uint8_t* frame_buffer) = 0; |
| 36 | 36 |
| 37 // Closes the output file if open. Essentially makes this class impossible | 37 // Closes the output file if open. Essentially makes this class impossible |
| 38 // to use anymore. Will also be invoked by the destructor. | 38 // to use anymore. Will also be invoked by the destructor. |
| 39 virtual void Close() = 0; | 39 virtual void Close() = 0; |
| 40 | 40 |
| 41 // Frame length in bytes of a single frame image. | 41 // Frame length in bytes of a single frame image. |
| 42 virtual size_t FrameLength() = 0; | 42 virtual size_t FrameLength() = 0; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 class FrameWriterImpl : public FrameWriter { | 45 // Writes raw I420 frames in sequence. |
| 46 class YuvFrameWriterImpl : public FrameWriter { |
| 46 public: | 47 public: |
| 47 // Creates a file handler. The input file is assumed to exist and be readable | 48 // Creates a file handler. The input file is assumed to exist and be readable |
| 48 // and the output file must be writable. | 49 // and the output file must be writable. |
| 49 // Parameters: | 50 // Parameters: |
| 50 // output_filename The file to write. Will be overwritten if already | 51 // output_filename The file to write. Will be overwritten if already |
| 51 // existing. | 52 // existing. |
| 52 // frame_length_in_bytes The size of each frame. | 53 // width, height Size of each frame to read. |
| 53 // For YUV: 3*width*height/2 | 54 YuvFrameWriterImpl(std::string output_filename, int width, int height); |
| 54 FrameWriterImpl(std::string output_filename, size_t frame_length_in_bytes); | 55 ~YuvFrameWriterImpl() override; |
| 55 ~FrameWriterImpl() override; | |
| 56 bool Init() override; | 56 bool Init() override; |
| 57 bool WriteFrame(uint8_t* frame_buffer) override; | 57 bool WriteFrame(uint8_t* frame_buffer) override; |
| 58 void Close() override; | 58 void Close() override; |
| 59 size_t FrameLength() override; | 59 size_t FrameLength() override; |
| 60 | 60 |
| 61 protected: |
| 62 const std::string output_filename_; |
| 63 size_t frame_length_in_bytes_; |
| 64 const int width_; |
| 65 const int height_; |
| 66 FILE* output_file_; |
| 67 }; |
| 68 |
| 69 // Writes raw I420 frames in sequence, but with Y4M file and frame headers for |
| 70 // more convenient playback in external media players. |
| 71 class Y4mFrameWriterImpl : public YuvFrameWriterImpl { |
| 72 public: |
| 73 Y4mFrameWriterImpl(std::string output_filename, |
| 74 int width, |
| 75 int height, |
| 76 int frame_rate); |
| 77 ~Y4mFrameWriterImpl() override; |
| 78 bool Init() override; |
| 79 bool WriteFrame(uint8_t* frame_buffer) override; |
| 80 |
| 61 private: | 81 private: |
| 62 std::string output_filename_; | 82 const int frame_rate_; |
| 63 size_t frame_length_in_bytes_; | |
| 64 FILE* output_file_; | |
| 65 }; | 83 }; |
| 66 | 84 |
| 67 } // namespace test | 85 } // namespace test |
| 68 } // namespace webrtc | 86 } // namespace webrtc |
| 69 | 87 |
| 70 #endif // WEBRTC_TEST_TESTSUPPORT_FRAME_WRITER_H_ | 88 #endif // WEBRTC_TEST_TESTSUPPORT_FRAME_WRITER_H_ |
| OLD | NEW |