sprang | 3911c26 | 2016-04-15 08:24:14 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 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 WEBRTC_MODULES_VIDEO_CODING_UTILITY_IVF_FILE_WRITER_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_UTILITY_IVF_FILE_WRITER_H_ |
| 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | |
| 17 | #include "webrtc/base/constructormagic.h" |
| 18 | #include "webrtc/base/timeutils.h" |
| 19 | #include "webrtc/modules/include/module_common_types.h" |
| 20 | #include "webrtc/video_frame.h" |
| 21 | #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class IvfFileWriter { |
| 26 | public: |
| 27 | ~IvfFileWriter(); |
| 28 | |
| 29 | static std::unique_ptr<IvfFileWriter> Open(const std::string& file_name, |
kjellander | 02b3d27 | 2016-04-20 12:05:54 | [diff] [blame] | 30 | VideoCodecType codec_type); |
sprang | 3911c26 | 2016-04-15 08:24:14 | [diff] [blame] | 31 | bool WriteFrame(const EncodedImage& encoded_image); |
| 32 | bool Close(); |
| 33 | |
| 34 | private: |
| 35 | IvfFileWriter(const std::string& path_name, |
| 36 | std::unique_ptr<FileWrapper> file, |
kjellander | 02b3d27 | 2016-04-20 12:05:54 | [diff] [blame] | 37 | VideoCodecType codec_type); |
sprang | 3911c26 | 2016-04-15 08:24:14 | [diff] [blame] | 38 | bool WriteHeader(); |
| 39 | bool InitFromFirstFrame(const EncodedImage& encoded_image); |
| 40 | |
kjellander | 02b3d27 | 2016-04-20 12:05:54 | [diff] [blame] | 41 | const VideoCodecType codec_type_; |
sprang | 3911c26 | 2016-04-15 08:24:14 | [diff] [blame] | 42 | size_t num_frames_; |
| 43 | uint16_t width_; |
| 44 | uint16_t height_; |
| 45 | int64_t last_timestamp_; |
| 46 | bool using_capture_timestamps_; |
| 47 | rtc::TimestampWrapAroundHandler wrap_handler_; |
| 48 | const std::string file_name_; |
| 49 | std::unique_ptr<FileWrapper> file_; |
| 50 | |
| 51 | RTC_DISALLOW_COPY_AND_ASSIGN(IvfFileWriter); |
| 52 | }; |
| 53 | |
| 54 | } // namespace webrtc |
| 55 | |
| 56 | #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_IVF_FILE_WRITER_H_ |