派生自 development/c++

pansen
2019-03-07 979bc003bce710bf300bc2bd87a8278585678763
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// Created by ps on 19-3-1.
//
 
#ifndef GB28181SDK_GB28181SERVER_H
#define GB28181SDK_GB28181SERVER_H
 
#include <iostream>
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "28181SDK.h"
#include "SpinLock.hpp"
 
struct MysqlDBServerCfg {
    std::string Host; //连接数据库的ip地址
    int Port;//连接数据库的端口
    std::string UserName;//连接数据库的用户名
    std::string Passwd;//连接数据库的密码
    std::string DBName;//连接数据库的表名
    int DBConnCount;//连接数据库的数量
};
 
struct GBServerCfg {
    std::string SvrIp;  // 国标服务的ip地址  (本机的ip地址)
    std::string SvrNatIp;       //注意: 此处如果没有穿网ip地址不需要配置 (一般部署公网时使用)
    int SvrPort;  // 国标服务监听的端口
    std::string SvrPubID; // 国标服务器的ID
    bool bMD5Auth; // 是否需要MD5加密
    std::string UserName;// 国标服务的用户名    (下级设备注册的用户名)
    std::string Passwd; // 国标服务的密码    (下级设备注册的密码)
    int SubScribeTime; // 订阅时间  如果为0 表示不订阅
};
 
struct UpperPFCfg {
    std::string Name;
    std::string PublicID;
    std::string AuthUserName;
    std::string AuthPasswd;
    std::string IpAddr;
    int Port;
    int RegisterItv;
    int KeepAliveItv;
};
 
class GB28181Server {
public:
    GB28181Server();
 
    virtual ~GB28181Server();
 
    void setMysqlConnParam(const MysqlDBServerCfg &_MysqlConnParam);
 
    void setGBServerParam(const GBServerCfg &_GBServerParam);
 
    void setUpperPlatform(const UpperPFCfg &_upperinfo);
 
    bool initServer();
 
private:
    // mysql数据库的配置信息
    MysqlConnParam_T MysqlConnParam;
 
    //  国标服务的配置信息
    GBServerParam_T GBServerParam;
 
    UpperPlatform_T upperinfo;
 
    static bool bGetLoaclRes;
 
private:
    //打印事件回调信息
    static void enventcallback(int eventtype, int eventparam, int datalen, char *data) {
        printf("eventtype:%d, eventparam:%d, datalen:%d, data:%s\n", eventtype, eventparam, datalen, data);
        if (eventtype == 2) {
//            GB28181Server::bGetLoaclRes = true;
        } else if (eventtype == 1 && eventparam == 1) {
            C_GetResource(NULL);
        }
    }
 
};
 
 
#endif //GB28181SDK_GB28181SERVER_H