<commit_before>//------------------------------------------------------------------------------
// File: factory.hpp
//
// Desc: Device factory - Manage IP Camera.
//
// Copyright (c) 2014-2018 opencvr.com. All rights reserved.
//------------------------------------------------------------------------------

#ifndef __VSC_FACTORY_H_
#define __VSC_FACTORY_H_
#include "confdb.hpp"
#include "device.hpp"
#include "vdb.hpp"
#include "vhdfsdb.hpp"
#include "vplay.hpp"
#include "sysdb.hpp"
#include "hdddevice.hpp"
#include <QThread>
#include <qdebug.h>

typedef enum
{
    FACTORY_DEVICE_ADD = 1,
    FACTORY_DEVICE_DEL,
    FACTORY_DEVICE_ONLINE,
    FACTORY_DEVICE_OFFLINE,
    FACTORY_DEVICE_RECORDING_ON,
    FACTORY_DEVICE_RECORDING_OFF,
    /* The Camera group has been change */
    FACTORY_DEVICE_GROUP_CHANGE,
    FACTORY_VMS_ADD,
    FACTORY_VMS_DEL,
    FACTORY_VIPC_ADD,
    FACTORY_VIPC_DEL,
    /* Camera view add and del */
    FACTORY_VIEW_ADD,
    FACTORY_VIEW_DEL,
    /* Camera group add and del */
    FACTORY_VGROUP_ADD,
    FACTORY_VGROUP_DEL,
    FACTORY_DEVICE_LAST
} FactoryDeviceChangeType;


class FactoryDeviceChangeData
{
public:
	FactoryDeviceChangeType type;
	int id;
};

typedef BOOL (*FactoryDeviceChangeNotify)(void* pParam, 
		FactoryDeviceChangeData data);

typedef std::list<LPDevice> DeviceList;
typedef std::list<DeviceParam> DeviceParamList;
typedef std::map<int, LPDevice> DeviceMap;
typedef std::map<int, DeviceParam> DeviceParamMap;
typedef std::map<int, VIPCDeviceParam> VIPCDeviceParamMap;
typedef std::map<void *, FactoryDeviceChangeNotify> DeviceChangeNofityMap;
#define FACTORY_DEVICE_ID_MAX 4096

class Factory;
class FactoryHddTask:public QThread
{
	Q_OBJECT
public:
	FactoryHddTask(Factory &pFactory);
	~FactoryHddTask();
public:
	void run();
private:
	Factory &m_Factory;
};

/* Fatory is Qthread for callback in Qt GUI */
class Factory: public QThread
{
    Q_OBJECT
public:
    Factory();
    ~Factory();
public:
	/* Init function */
	BOOL Init();
	s32 InitAddDevice(DeviceParam & pParam, u32 nIndex);
	
public:
	BOOL RegDeviceChangeNotify(void * pData, FactoryDeviceChangeNotify callback);
	BOOL CallDeviceChange(FactoryDeviceChangeData data);
	
public:
	BOOL GetLicense(astring &strLicense, astring &strHostId, 
							int &ch, int &type);
	BOOL SetLicense(astring &strLicense);
	BOOL InitLicense();

public:
	BOOL GetAutoLogin();
	BOOL AuthUser(astring &strUser, astring &strPasswd);
	BOOL GetUserData(VSCUserData &pData);
	BOOL SetUserData(VSCUserData &pData);

/* Emap function */
public:
	BOOL GetEmapData(VSCEmapData &pData);
	BOOL SetEmapData(VSCEmapData &pData);
	BOOL AddEmapCamera(s32 nIndex, u32 x, u32 y, u32 w, u32 h);
	BOOL DelEmapCamera(s32 nIndex);
	BOOL GetEmapCamera(s32 nIndex, u32 &x, u32 &y, u32 &w, u32 &h);
	
	BOOL GetEmapFile(astring &strFile);
	BOOL SetEmapFile(astring &strFile);

public:
	BOOL GetHdfsRecordConf(VSCHdfsRecordData &pData);
	BOOL SetHdfsRecordConf(VSCHdfsRecordData &pData);
	BOOL GetLang(VSCLangType &pLang);
	BOOL SetLang(VSCLangType &pLang);

	/* OpenCVR API port */
	BOOL GetOAPIPort(u16 &pPort);
	BOOL SetOAPIPort(u16 &pPort);

	/* Defualt HW HWAccel enable or disable */
	BOOL GetDefaultHWAccel(BOOL &pHWAccel);
	BOOL SetDefaultHWAccel(BOOL &pHWAccel);

public:
	/* UI can use this for display device tree */
	BOOL GetDeviceParamMap(DeviceParamMap &pMap);
       BOOL GetVIPCDeviceParamMap(VIPCDeviceParamMap &pMap);
       /* Device function */
	s32 AddDevice(DeviceParam & pParam);
	s32 GetDeviceParamById(DeviceParam & pParam, s32 nIndex);
	BOOL GetDeviceRtspUrl(astring & strUrl, s32 nIndex);
	s32 GetDeviceParamByIdTryLock(DeviceParam & pParam, s32 nIndex);
	BOOL DelDevice(s32 nIndex);
	BOOL UpdateDeviceGroup(s32 nIndex, s32 nGroup);<commit_msg>add rtsp server conf<commit_after>//------------------------------------------------------------------------------
// File: factory.hpp
//
// Desc: Device factory - Manage IP Camera.
//
// Copyright (c) 2014-2018 opencvr.com. All rights reserved.
//------------------------------------------------------------------------------

#ifndef __VSC_FACTORY_H_
#define __VSC_FACTORY_H_
#include "confdb.hpp"
#include "device.hpp"
#include "vdb.hpp"
#include "vhdfsdb.hpp"
#include "vplay.hpp"
#include "sysdb.hpp"
#include "hdddevice.hpp"
#include <QThread>
#include <qdebug.h>

typedef enum
{
    FACTORY_DEVICE_ADD = 1,
    FACTORY_DEVICE_DEL,
    FACTORY_DEVICE_ONLINE,
    FACTORY_DEVICE_OFFLINE,
    FACTORY_DEVICE_RECORDING_ON,
    FACTORY_DEVICE_RECORDING_OFF,
    /* The Camera group has been change */
    FACTORY_DEVICE_GROUP_CHANGE,
    FACTORY_VMS_ADD,
    FACTORY_VMS_DEL,
    FACTORY_VIPC_ADD,
    FACTORY_VIPC_DEL,
    /* Camera view add and del */
    FACTORY_VIEW_ADD,
    FACTORY_VIEW_DEL,
    /* Camera group add and del */
    FACTORY_VGROUP_ADD,
    FACTORY_VGROUP_DEL,
    FACTORY_DEVICE_LAST
} FactoryDeviceChangeType;


class FactoryDeviceChangeData
{
public:
	FactoryDeviceChangeType type;
	int id;
};

typedef BOOL (*FactoryDeviceChangeNotify)(void* pParam, 
		FactoryDeviceChangeData data);

typedef std::list<LPDevice> DeviceList;
typedef std::list<DeviceParam> DeviceParamList;
typedef std::map<int, LPDevice> DeviceMap;
typedef std::map<int, DeviceParam> DeviceParamMap;
typedef std::map<int, VIPCDeviceParam> VIPCDeviceParamMap;
typedef std::map<void *, FactoryDeviceChangeNotify> DeviceChangeNofityMap;
#define FACTORY_DEVICE_ID_MAX 4096

class Factory;
class FactoryHddTask:public QThread
{
	Q_OBJECT
public:
	FactoryHddTask(Factory &pFactory);
	~FactoryHddTask();
public:
	void run();
private:
	Factory &m_Factory;
};

/* Fatory is Qthread for callback in Qt GUI */
class Factory: public QThread
{
    Q_OBJECT
public:
    Factory();
    ~Factory();
public:
	/* Init function */
	BOOL Init();
	s32 InitAddDevice(DeviceParam & pParam, u32 nIndex);
	
public:
	BOOL RegDeviceChangeNotify(void * pData, FactoryDeviceChangeNotify callback);
	BOOL CallDeviceChange(FactoryDeviceChangeData data);
	
public:
	BOOL GetLicense(astring &strLicense, astring &strHostId, 
							int &ch, int &type);
	BOOL SetLicense(astring &strLicense);
	BOOL InitLicense();

public:
	BOOL GetAutoLogin();
	BOOL AuthUser(astring &strUser, astring &strPasswd);
	BOOL GetUserData(VSCUserData &pData);
	BOOL SetUserData(VSCUserData &pData);

/* Emap function */
public:
	BOOL GetEmapData(VSCEmapData &pData);
	BOOL SetEmapData(VSCEmapData &pData);
	BOOL AddEmapCamera(s32 nIndex, u32 x, u32 y, u32 w, u32 h);
	BOOL DelEmapCamera(s32 nIndex);
	BOOL GetEmapCamera(s32 nIndex, u32 &x, u32 &y, u32 &w, u32 &h);
	
	BOOL GetEmapFile(astring &strFile);
	BOOL SetEmapFile(astring &strFile);

public:
	BOOL GetHdfsRecordConf(VSCHdfsRecordData &pData);
	BOOL SetHdfsRecordConf(VSCHdfsRecordData &pData);
	BOOL GetLang(VSCLangType &pLang);
	BOOL SetLang(VSCLangType &pLang);

	/* OpenCVR API port */
	BOOL GetOAPIPort(u16 &pPort);
	BOOL SetOAPIPort(u16 &pPort);

	/* Defualt HW HWAccel enable or disable */
	BOOL GetDefaultHWAccel(BOOL &pHWAccel);
	BOOL SetDefaultHWAccel(BOOL &pHWAccel);

	BOOL GetRTSPServer(BOOL &pAuth, astring &pMultiAddr, u16 &pPort);
	BOOL SetRTSPServer(BOOL &pAuth, astring &pMultiAddr, u16 &pPort);

public:
	/* UI can use this for display device tree */
	BOOL GetDeviceParamMap(DeviceParamMap &pMap);
       BOOL GetVIPCDeviceParamMap(VIPCDeviceParamMap &pMap);
       /* Device function */
	s32 AddDevice(DeviceParam & pParam);
	s32 GetDeviceParamById(DeviceParam & pParam, s32 nIndex);
	BOOL GetDeviceRtspUrl(astring & strUrl, s32 nIndex);
	s32 GetDeviceParamByIdTryLock(DeviceParam & pParam, s32 nIndex);
	BOOL DelDevice(s32 nIndex);
	BOOL UpdateDeviceGroup(s32 nIndex, s32 nGroup);
{'fraction_non_alphanumeric': 0.13830065359477126, 'fraction_numerical': 0.01647058823529412, 'mean_word_length': 4.152188552188552, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6689514', 'n_tokens_mistral': 2802, 'n_tokens_neox': 2670, 'n_words': 634}