cheliequan
2023-01-29 dccc1ca1304dc1fcb86c8e24edd491509269b3e7
main.cpp
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <map>
#include <memory>
#include <string>
#include <thread>
@@ -44,13 +45,144 @@
    // }
    // 时间规则
    std::vector<protomsg::CameraTimerule> list;
    if (dbapi_get_time_rules(handle, list)) {
        printf("CameraTimerule:\n");
    // std::vector<protomsg::CameraTimerule> list;
    // if (dbapi_get_time_rules(handle, list)) {
    //     for (unsigned int i = 0; i < list.size(); i++) {
    //         printf("CameraTimerule: %s\n", list[i].id().c_str());
    //     }
    // }
    // 系统授权信息
    // printf("isExpired:%d\n", dbapi_get_server_get_is_sys_expired(handle));
    // 摄像机
    std::vector<protomsg::Camera> list;
    char *runType = (char *)"1"; // 1 实时 0 轮询
    if (dbapi_get_cameras_by_runType(handle, list, runType, false)) {
        for (unsigned int i = 0; i < list.size(); i++) {
            printf("Camera: %s\n", list[i].id().c_str());
        }
    }
    //系统授权信息
    printf("isExpired:%d\n", dbapi_get_server_get_is_sys_expired(handle));
    string json;
    dbapi_get_json_by_cameralist(list, json);
   printf("Camera list to json:%s\n", json.c_str());
   /* [
   {
      "addr": "财务室",
      "alias": "",
      "brand": "",
      "coordTransform": "",
      "floor": -9999,
      "id": "2bdee058-43d9-4e95-9ba1-2f56920f6d7c",
      "ip": "",
      "is_running": false,
      "latitude": 0,
      "linkCams": null,
      "longitude": 0,
      "name": "5.152(财务室)",
      "password": "",
      "port": 0,
      "reserved": "",
      "resolution_height": 0,
      "resolution_width": 0,
      "rtsp": "rtsp://admin:a1234567@192.168.5.152:554/h264/ch1/main/av_stream",
      "runServerName": "189服务",
      "run_enable": false,
      "run_server_id": "DSVAD010120190703",
      "run_type": -1,
      "snapshot_url": "192.168.20.189:6700/71,1c82608f5aab92?collection=DSVAD010120190703-persistent",
      "status": -2,
      "tasks": [
         {
            "hasRule": true,
            "taskname": "离岗"
         }
      ],
      "type": 0,
      "username": "",
      "voiceEnable": false,
      "voiceId": ""
   },
   {
      "addr": "产品旁2",
      "alias": "",
      "brand": "",
      "coordTransform": "",
      "floor": -9999,
      "id": "d05618a4-7cdd-4b64-888c-2b1c29d3f32a",
      "ip": "",
      "is_running": false,
      "latitude": 0,
      "linkCams": null,
      "longitude": 0,
      "name": "5.151(产品旁)",
      "password": "",
      "port": 0,
      "reserved": "",
      "resolution_height": 0,
      "resolution_width": 0,
      "rtsp": "rtsp://admin:a1234567@192.168.5.151:554/h265/ch1/main/av_stream",
      "runServerName": "189服务",
      "run_enable": false,
      "run_server_id": "DSVAD010120190703",
      "run_type": -1,
      "snapshot_url": "192.168.20.189:6700/72,1c9ea52ffe3560?collection=DSVAD010120190703-persistent",
      "status": -2,
      "tasks": [
         {
            "hasRule": true,
            "taskname": "入侵"
         },
         {
            "hasRule": true,
            "taskname": "产品区域人员离岗"
         },
         {
            "hasRule": true,
            "taskname": "脱岗"
         }
      ],
      "type": 0,
      "username": "",
      "voiceEnable": false,
      "voiceId": ""
   },
   {
      "addr": "渣油装车10号",
      "alias": "",
      "brand": "",
      "coordTransform": "",
      "floor": -9999,
      "id": "8be6055f-639c-4ea0-bcec-99b6b5b95499",
      "ip": "",
      "is_running": false,
      "latitude": 0,
      "linkCams": null,
      "longitude": 0,
      "name": "渣油装车10号",
      "password": "",
      "port": 0,
      "reserved": "",
      "resolution_height": 0,
      "resolution_width": 0,
      "rtsp": "rtsp://admin:a1234567@192.168.5.53:554/h264/ch1/main/av_stream",
      "runServerName": "189服务",
      "run_enable": true,
      "run_server_id": "DSVAD010120190703",
      "run_type": -1,
      "snapshot_url": "192.168.20.189:6700/72,1c8f82b46690a6?collection=DSVAD010120190703-persistent",
      "status": -2,
      "tasks": null,
      "type": 0,
      "username": "",
      "voiceEnable": false,
      "voiceId": ""
   }
]*/
    return 0;
}