#pragma once #include #include #include #include #include "utils.h" class FrameFileWriterReader { public: FrameFileWriterReader(); void openNewFileForWriting(int deviceID); void openCurrentFileForReading(); // leave filename blank if you want the filename to be generated from the date void setCurrentFilename(std::string filename = ""); void writeFrame(std::vector points, std::vector colors, uint64_t timestamp, int deviceID); bool readFrame(std::vector &outPoints, std::vector &outColors); bool openedForWriting() { return m_bFileOpenedForWriting; } bool openedForReading() { return m_bFileOpenedForReading; } void closeFileIfOpened(); ~FrameFileWriterReader(); private: void resetTimer(); int getRecordingTimeMilliseconds(); FILE *m_pFileHandle = nullptr; bool m_bFileOpenedForWriting = false; bool m_bFileOpenedForReading = false; std::string m_sFilename = ""; std::chrono::steady_clock::time_point recording_start_time; };