#ifndef __MAS_DEFINITION_H #define __MAS_DEFINITION_H #define NAMESPACE_MAS_BEGIN namespace masd { #define NAMESPACE_MAS_END }; #define NAMESPACE_MASDB_BEGIN namespace masdb { #define NAMESPACE_MASDB_END }; #include "Types.h" #include "Logger.h" #include "ExHeaders.h" #include #include NAMESPACE_MAS_BEGIN #define PROGRAM_ROOT_PATH "/usr/local/mas/" #define DYNAMIC_ROOT_PATH "/var/mas/" #define LOG_FILE_PATH DYNAMIC_ROOT_PATH"log/" #define LOCK_FILE DYNAMIC_ROOT_PATH"mas.lock" #define RECORD_FILE_PATH DYNAMIC_ROOT_PATH"file/record/" #define RECORD_QUERY_PATH DYNAMIC_ROOT_PATH"file/record_query/" #define MC_LOG_FILE_PATH LOG_FILE_PATH"log/mediacenter.log" #define MS_LOG_FILE_PATH LOG_FILE_PATH"log/mediasource.log" #define MP4_FILE_PATH DYNAMIC_ROOT_PATH"file/mp4/" #define UPLOAD_FILE_PATH DYNAMIC_ROOT_PATH"file/upload/" #define DET_LIB_PATH PROGRAM_ROOT_PATH"libs/detector/" #define STRA_LIB_PATH PROGRAM_ROOT_PATH"libs/strategy/" #define WEB_ROOT_PATH PROGRAM_ROOT_PATH"wwwroot/" #define HTTP_SERVER_PORT 80 #define WEBSOCKET_SERVER_PORT 51920 #define CLI_SERVER_PORT 51930 #define WSS_SERVER_PORT 51940 #define HTTP_FILE_SERVER_PORT 51960 #define MC_PORT 51970 // HTTP MEDIA ENUM #define MAS_ERROR_CODE_MAP(ITEM) \ ITEM(0, OK, "成功") \ ITEM(1, FAILED, "一般性失败") \ ITEM(2, NULL_OBJ, "请求结构为空") \ ITEM(3, DUPLICATED, "重复请求") \ ITEM(4, NOT_INITED, "未初始化") \ ITEM(5, DB_ERROR, "数据相关库错误") \ ITEM(6, USER_ERROR, "用户相关错误") \ ITEM(7, PWD_ERROR, "密码相关错误") \ ITEM(8, NOT_LOGIN, "未登录") \ ITEM(9, TOKEN_ERROR, "token相关错误") \ ITEM(10, SDK_FAILED, "sdk相关错误") \ ITEM(11, EVENT_REQ_NULL, "记录查询请求内容错误") \ ITEM(12, NOT_SUPPORT, "操作不支持") \ ITEM(13, PLAY_FAILED, "播放失败") \ ITEM(14, DEV_NOT_FOUND, "设备不存在") \ ITEM(15, RSC_NOT_FOUND, "资源不存在") \ ITEM(16, RSC_IN_USE, "资源正在使用") \ ITEM(17, SCENE_NOT_WORK, "场景未启动") \ ITEM(18, SCENE_IN_WORK, "场景已启动") \ ITEM(19, REQ_PARAMS_ERROR, "请求参数错误") \ ITEM(20, ADDR_DUPLICATE, "地址重复") \ ITEM(21, QC_PARAMS_ERROR, "查询条件参数错误") \ typedef enum __MAS_ERROR_TYPE { #define XX(num, name, des) MEC_##name = num, MAS_ERROR_CODE_MAP(XX) #undef XX } EN_MAS_ERROR; typedef enum __MAS_ENCODE_FORMAT_CODE { MEF_UNKNOWN = 0x00, MEF_VIDEO_H264 = 0x01, MEF_VIDEO_H265 = 0x02, MEF_VIDEO_JPEG = 0x03, MEF_VIDEO_MP2P = 0x04, MEF_VIDEO_MAX = 0x05, MEF_AUDIO_PCM = 0x10, MEF_AUDIO_G711A = 0x20, MEF_AUDIO_G711U = 0x30, MEF_AUDIO_MAX = 0x40, } EN_MAS_ENCODE_FORMAT; typedef enum __MAS_RSC_STREAM_TYPE { EMRST_MAIN = 0, EMRST_SUB = 1, } EN_MAS_RSC_STREAM_TYPE; typedef enum __MAS_STREAM_TYPE_CODE { MST_UNKNOWN = 0x00, MST_AUDIO = 0x01, MST_VIDEO = 0x02, MST_MIXED = 0x03, } EN_MAS_STREAM_TYPE; typedef enum __MAS_STREAM_ENPACK_CODE { MSP_UNKNOWN = 0x00, MSP_RTP = 0x01, MSP_FRAME = 0x02 } EN_MAS_STREAM_ENPACK; typedef enum __MAS_STREAM_ENCODE_CODE { MSC_UNKNOWN = 0x00, MSC_H264 = 0x01, MSC_H265 = 0x02, MSC_JPEG = 0x03, MSC_PNG = 0x04, MSC_YUV = 0x05, MSC_RGB = 0x06 } EN_MAS_STREAM_ENCODE; typedef enum __MAS_STREAM_FRAME_CODE { MSF_UNKNOWN = 0x00, MSF_I_FRAME = 0x01, MSF_P_FRAME = 0x02, MSF_B_FRAME = 0x03, MSF_ELSE_FRAME = 0x04 } EN_MAS_STREAM_FRAME; typedef enum __MAS_DETECT_INTERVAL_CODE { MDI_UNKNOWN = 0x00, MDI_ALL_DETECT = 0x01, MDI_DETECT_I = 0x02, } EN_MAS_DETECT_INTERVAL; typedef enum __MAS_MEDIA_FILE_TYPE_CODE { MFT_UNKNOWN = 0x00, MFT_WORD = 0x01, MFT_AUDIO = 0x02, MFT_PIC = 0x04, MFT_VIDEO = 0x08 } EN_MAS_MEDIA_FILE_TYPE; typedef enum __BUFFER_TYPE { MRT_EMPTY = 0x00, MRT_PCAP = 0x01, MRT_RTP = 0x02, MRT_PS = 0x03, MRT_H264 = 0x04, MRT_H265 = 0x05, MRT_YUV_420 = 0x06, MRT_YUV_422 = 0x07, MRT_YUV_444 = 0x08, MRT_RGB = 0x09, // rgb24 MRT_BGR = 0x0a, // bgr24 MRT_JPEG = 0x0b, MRT_PCM = 0x0c, MRT_G711A = 0x0d, MRT_G711U = 0x0e, MRT_G729A = 0x0f, MRT_G729B = 0x10, MRT_G729C = 0x11, MRT_INDEX_FILE = 0xa0, } EN_BUFFER_TYPE; typedef enum __MAS_SRC_TYPE { EMST_DEV, EMST_NET, EMST_FILE, } EN_MAS_SRC_TYPE; typedef enum __MAS_SRC_SUB_TYPE { MSST_RTSP = 3, MSST_RTMP, MSST_UDP, MSST_TCP, } EN_MAS_SRC_SUB_TYPE; typedef enum __MAS_PLAN_TYPE_CODE { MPT_DAY = 0x00, MPT_WEEK = 0x01, MPT_MONTH = 0x02, MPT_SPECIAL = 0x03 } EN_MAS_PLAN_TYPE; #ifndef TIME_NOW #define TIME_NOW std::chrono::steady_clock::now() #endif #ifndef TIME_POINT #define TIME_POINT std::chrono::steady_clock::time_point #endif #ifndef DURATION #define DURATION(Num) std::chrono::steady_clock::duration(Num) #endif #ifndef ZERO_POINT #define ZERO_POINT DURATION(0) #endif #ifndef TIME_STAMP_NOW #define TIME_STAMP_NOW std::chrono::duration_cast \ (std::chrono::system_clock::now().time_since_epoch()).count() #endif using SecondDuration = std::chrono::seconds; using MinuteDuration = std::chrono::minutes; NAMESPACE_MAS_END #endif