MAS_Definition.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. #ifndef __MAS_DEFINITION_H
  2. #define __MAS_DEFINITION_H
  3. #define NAMESPACE_MAS_BEGIN namespace masd {
  4. #define NAMESPACE_MAS_END };
  5. #define NAMESPACE_MASDB_BEGIN namespace masdb {
  6. #define NAMESPACE_MASDB_END };
  7. #include "Types.h"
  8. #include "Logger.h"
  9. #include "ExHeaders.h"
  10. #include <chrono>
  11. #include <atomic>
  12. NAMESPACE_MAS_BEGIN
  13. #define PROGRAM_ROOT_PATH "/usr/local/mas/"
  14. #define DYNAMIC_ROOT_PATH "/var/mas/"
  15. #define LOG_FILE_PATH DYNAMIC_ROOT_PATH"log/"
  16. #define LOCK_FILE DYNAMIC_ROOT_PATH"mas.lock"
  17. #define RECORD_FILE_PATH DYNAMIC_ROOT_PATH"file/record/"
  18. #define RECORD_QUERY_PATH DYNAMIC_ROOT_PATH"file/record_query/"
  19. #define MC_LOG_FILE_PATH LOG_FILE_PATH"log/mediacenter.log"
  20. #define MS_LOG_FILE_PATH LOG_FILE_PATH"log/mediasource.log"
  21. #define MP4_FILE_PATH DYNAMIC_ROOT_PATH"file/mp4/"
  22. #define UPLOAD_FILE_PATH DYNAMIC_ROOT_PATH"file/upload/"
  23. #define DET_LIB_PATH PROGRAM_ROOT_PATH"libs/detector/"
  24. #define STRA_LIB_PATH PROGRAM_ROOT_PATH"libs/strategy/"
  25. #define WEB_ROOT_PATH PROGRAM_ROOT_PATH"wwwroot/"
  26. #define HTTP_SERVER_PORT 80
  27. #define WEBSOCKET_SERVER_PORT 51920
  28. #define CLI_SERVER_PORT 51930
  29. #define WSS_SERVER_PORT 51940
  30. #define HTTP_FILE_SERVER_PORT 51960
  31. #define MC_PORT 51970
  32. // HTTP MEDIA ENUM
  33. #define MAS_ERROR_CODE_MAP(ITEM) \
  34. ITEM(0, OK, "成功") \
  35. ITEM(1, FAILED, "一般性失败") \
  36. ITEM(2, NULL_OBJ, "请求结构为空") \
  37. ITEM(3, DUPLICATED, "重复请求") \
  38. ITEM(4, NOT_INITED, "未初始化") \
  39. ITEM(5, DB_ERROR, "数据相关库错误") \
  40. ITEM(6, USER_ERROR, "用户相关错误") \
  41. ITEM(7, PWD_ERROR, "密码相关错误") \
  42. ITEM(8, NOT_LOGIN, "未登录") \
  43. ITEM(9, TOKEN_ERROR, "token相关错误") \
  44. ITEM(10, SDK_FAILED, "sdk相关错误") \
  45. ITEM(11, EVENT_REQ_NULL, "记录查询请求内容错误") \
  46. ITEM(12, NOT_SUPPORT, "操作不支持") \
  47. ITEM(13, PLAY_FAILED, "播放失败") \
  48. ITEM(14, DEV_NOT_FOUND, "设备不存在") \
  49. ITEM(15, RSC_NOT_FOUND, "资源不存在") \
  50. ITEM(16, RSC_IN_USE, "资源正在使用") \
  51. ITEM(17, SCENE_NOT_WORK, "场景未启动") \
  52. ITEM(18, SCENE_IN_WORK, "场景已启动") \
  53. ITEM(19, REQ_PARAMS_ERROR, "请求参数错误") \
  54. ITEM(20, ADDR_DUPLICATE, "地址重复") \
  55. ITEM(21, QC_PARAMS_ERROR, "查询条件参数错误") \
  56. typedef enum __MAS_ERROR_TYPE {
  57. #define XX(num, name, des) MEC_##name = num,
  58. MAS_ERROR_CODE_MAP(XX)
  59. #undef XX
  60. } EN_MAS_ERROR;
  61. typedef enum __MAS_ENCODE_FORMAT_CODE {
  62. MEF_UNKNOWN = 0x00,
  63. MEF_VIDEO_H264 = 0x01,
  64. MEF_VIDEO_H265 = 0x02,
  65. MEF_VIDEO_JPEG = 0x03,
  66. MEF_VIDEO_MP2P = 0x04,
  67. MEF_VIDEO_MAX = 0x05,
  68. MEF_AUDIO_PCM = 0x10,
  69. MEF_AUDIO_G711A = 0x20,
  70. MEF_AUDIO_G711U = 0x30,
  71. MEF_AUDIO_MAX = 0x40,
  72. } EN_MAS_ENCODE_FORMAT;
  73. typedef enum __MAS_RSC_STREAM_TYPE {
  74. EMRST_MAIN = 0,
  75. EMRST_SUB = 1,
  76. } EN_MAS_RSC_STREAM_TYPE;
  77. typedef enum __MAS_STREAM_TYPE_CODE {
  78. MST_UNKNOWN = 0x00,
  79. MST_AUDIO = 0x01,
  80. MST_VIDEO = 0x02,
  81. MST_MIXED = 0x03,
  82. } EN_MAS_STREAM_TYPE;
  83. typedef enum __MAS_STREAM_ENPACK_CODE {
  84. MSP_UNKNOWN = 0x00,
  85. MSP_RTP = 0x01,
  86. MSP_FRAME = 0x02
  87. } EN_MAS_STREAM_ENPACK;
  88. typedef enum __MAS_STREAM_ENCODE_CODE {
  89. MSC_UNKNOWN = 0x00,
  90. MSC_H264 = 0x01,
  91. MSC_H265 = 0x02,
  92. MSC_JPEG = 0x03,
  93. MSC_PNG = 0x04,
  94. MSC_YUV = 0x05,
  95. MSC_RGB = 0x06
  96. } EN_MAS_STREAM_ENCODE;
  97. typedef enum __MAS_STREAM_FRAME_CODE {
  98. MSF_UNKNOWN = 0x00,
  99. MSF_I_FRAME = 0x01,
  100. MSF_P_FRAME = 0x02,
  101. MSF_B_FRAME = 0x03,
  102. MSF_ELSE_FRAME = 0x04
  103. } EN_MAS_STREAM_FRAME;
  104. typedef enum __MAS_DETECT_INTERVAL_CODE {
  105. MDI_UNKNOWN = 0x00,
  106. MDI_ALL_DETECT = 0x01,
  107. MDI_DETECT_I = 0x02,
  108. } EN_MAS_DETECT_INTERVAL;
  109. typedef enum __MAS_MEDIA_FILE_TYPE_CODE {
  110. MFT_UNKNOWN = 0x00,
  111. MFT_WORD = 0x01,
  112. MFT_AUDIO = 0x02,
  113. MFT_PIC = 0x04,
  114. MFT_VIDEO = 0x08
  115. } EN_MAS_MEDIA_FILE_TYPE;
  116. typedef enum __BUFFER_TYPE {
  117. MRT_EMPTY = 0x00,
  118. MRT_PCAP = 0x01,
  119. MRT_RTP = 0x02,
  120. MRT_PS = 0x03,
  121. MRT_H264 = 0x04,
  122. MRT_H265 = 0x05,
  123. MRT_YUV_420 = 0x06,
  124. MRT_YUV_422 = 0x07,
  125. MRT_YUV_444 = 0x08,
  126. MRT_RGB = 0x09, // rgb24
  127. MRT_BGR = 0x0a, // bgr24
  128. MRT_JPEG = 0x0b,
  129. MRT_PCM = 0x0c,
  130. MRT_G711A = 0x0d,
  131. MRT_G711U = 0x0e,
  132. MRT_G729A = 0x0f,
  133. MRT_G729B = 0x10,
  134. MRT_G729C = 0x11,
  135. MRT_INDEX_FILE = 0xa0,
  136. } EN_BUFFER_TYPE;
  137. typedef enum __MAS_SRC_TYPE {
  138. EMST_DEV,
  139. EMST_NET,
  140. EMST_FILE,
  141. } EN_MAS_SRC_TYPE;
  142. typedef enum __MAS_SRC_SUB_TYPE {
  143. MSST_RTSP = 3,
  144. MSST_RTMP,
  145. MSST_UDP,
  146. MSST_TCP,
  147. } EN_MAS_SRC_SUB_TYPE;
  148. typedef enum __MAS_PLAN_TYPE_CODE {
  149. MPT_DAY = 0x00,
  150. MPT_WEEK = 0x01,
  151. MPT_MONTH = 0x02,
  152. MPT_SPECIAL = 0x03
  153. } EN_MAS_PLAN_TYPE;
  154. #ifndef TIME_NOW
  155. #define TIME_NOW std::chrono::steady_clock::now()
  156. #endif
  157. #ifndef TIME_POINT
  158. #define TIME_POINT std::chrono::steady_clock::time_point
  159. #endif
  160. #ifndef DURATION
  161. #define DURATION(Num) std::chrono::steady_clock::duration(Num)
  162. #endif
  163. #ifndef ZERO_POINT
  164. #define ZERO_POINT DURATION(0)
  165. #endif
  166. #ifndef TIME_STAMP_NOW
  167. #define TIME_STAMP_NOW std::chrono::duration_cast<std::chrono::milliseconds> \
  168. (std::chrono::system_clock::now().time_since_epoch()).count()
  169. #endif
  170. using SecondDuration = std::chrono::seconds;
  171. using MinuteDuration = std::chrono::minutes;
  172. NAMESPACE_MAS_END
  173. #endif