#ifndef LIVESTREAMSERVICE_H
#define LIVESTREAMSERVICE_H

#include "SensorGlobal.h"
#include <map>

class CLiveStreamPushModule;
class CLiveStreamHandler;

class CLiveStreamService
{
public:
    static bool PushCVMat(const std::string &strStreamName,const cv::Mat &iMat,int nFramerate)
    {
        if(nullptr == s_piInstance)
        {
            s_piInstance = new CLiveStreamService();
        }

        return s_piInstance->PushCVMatToStream(strStreamName,iMat,nFramerate);
    }

    static bool StartSaveToFile(const std::string &strStreamName,const std::string &strFileName)
    {
        if(nullptr == s_piInstance)
        {
            s_piInstance = new CLiveStreamService();
        }

        return s_piInstance->StartSaveStreamToFile(strStreamName,strFileName);
    }

    static bool StopSaveToFile(const std::string &strStreamName)
    {
        if(nullptr == s_piInstance)
        {
            s_piInstance = new CLiveStreamService();
        }

        return s_piInstance->StopSaveStreamToFile(strStreamName);
    }

private:
    CLiveStreamService();
    ~CLiveStreamService();

    void ReadConfig();
    bool PushCVMatToStream(const std::string &strStreamName,const cv::Mat &iMat,euint32 nFramerate);
    bool StartSaveStreamToFile(const string &strStreamName, const string &strFileName);
    bool StopSaveStreamToFile(const std::string &strStreamName);


    int m_nPort;
    int m_nMaxStreamNum;
    std::map<std::string,CLiveStreamHandler *> m_mapNameToHandler;
    CLiveStreamPushModule *m_piModule;


    static CLiveStreamService *s_piInstance;
};

#endif // LIVESTREAMSERVICE_H
