#pragma once #include "camera.hpp" #include "frame_result.hpp" #include #include #include #include namespace cms { struct PipelineConfig; // H.264/MP4 plus a matching frame index and per-frame inference records. // finish() flushes the encoder and marks the session replayable. class SessionWriter { public: explicit SessionWriter(PipelineConfig const& config); void write(FrameResult const& result, nlohmann::json const& stages, nlohmann::json const* source = nullptr); void finish(); private: std::filesystem::path directory_; std::ofstream index_; cv::VideoWriter video_; int width_{},height_{}; std::uint64_t count_{}; bool finished_{}; }; class SessionReader { public: explicit SessionReader(PipelineConfig& config); std::optional read(); private: std::filesystem::path directory_; std::ifstream index_; cv::VideoCapture video_; int width_{},height_{}; std::uint64_t count_{},lastFrame_{},expectedCount_{}; }; }