#pragma once

#include <iostream>
#include <map>
#include <time.h>
#include <dirent.h>
#include <time.h>
#include <cstdlib>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
// opencv
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
#include "Util/logger.h"
#include "DataSource.h"

using namespace toolkit;
using namespace std;
//using namespace cv;

namespace MIVA
{
    class recorder
    {
    public:
        recorder() {}
        ~recorder() {}

        static std::shared_ptr<recorder> CreateNew();

        void Start();

        void Finish();

        void ConsumerData(std::string Pid,cv::Mat& frame);

        std::string GetFileName(std::string Pid);

    private:
        struct Writer{
            std::string fileName = "";
            std::shared_ptr<cv::VideoWriter> videoWriter = nullptr;
        };
        map<std::string, Writer> videoWriters;
    public:
        bool enable = true;
        bool RecordEnable = true;
        int outType = 0;  // 0  图片 1视频
        std::string outDir = "";
        std::string Dir = "./video/";
        using Ptr = std::shared_ptr<recorder>;
    };
} // namespace name