ffe81045
Hu Chunming
优化目录xml解析;优化sipse...
|
1
2
|
#ifndef __SIPSERVER_H__
#define __SIPSERVER_H__
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
3
4
5
6
7
8
9
10
11
12
|
extern "C" {
#include <osip2/osip_mt.h>
#include <eXosip2/eXosip.h>
}
#include <map>
#include <string>
#include <thread>
#include <chrono>
|
1116447e
Hu Chunming
代码逻辑有花
|
13
|
#include <mutex>
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
14
15
|
#include "./Message/CatalogParser.h"
|
ffe81045
Hu Chunming
优化目录xml解析;优化sipse...
|
16
|
#include "sip_header.h"
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
17
18
19
|
using namespace std;
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
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
|
class Client {
public:
Client(string ip, int port, string device) :
mIp(ip),
mPort(port),
mRtpPort(0),
mDevice(device),
mIsReg(false){
}
~Client() = default;
public:
void setRtpPort(int rtpPort) {
mRtpPort = rtpPort;
}
void setReg(bool isReg) {
mIsReg = isReg;
}
string getDevice() const{
return mDevice;
}
string getIp() const{
return mIp;
}
int getPort() const{
return mPort;
}
|
1116447e
Hu Chunming
代码逻辑有花
|
49
50
51
52
53
54
55
56
|
unsigned long getHeartBeat() {
return mHeartBeatTime;
}
void updateHeartBeat(unsigned long ts) {
mHeartBeatTime = ts;
}
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
57
|
private:
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
58
59
60
|
string mIp; // client ip
int mPort; // client port
string mDevice;// 340200000013200000024
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
61
|
bool mIsReg;
|
1116447e
Hu Chunming
代码逻辑有花
|
62
63
|
int mRtpPort;
unsigned long mHeartBeatTime{0};
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
64
65
66
67
68
69
|
};
class SipServer {
public:
|
74d1e6a8
Hu Chunming
完成gb28181大体的代码,未完...
|
70
71
72
73
74
75
76
77
78
|
static SipServer* getInstance(){
static SipServer* singleton = nullptr;
if (singleton == nullptr){
singleton = new SipServer();
}
return singleton;
}
public:
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
79
80
|
SipServer();
~SipServer();
|
74d1e6a8
Hu Chunming
完成gb28181大体的代码,未完...
|
81
|
|
ffe81045
Hu Chunming
优化目录xml解析;优化sipse...
|
82
|
bool Init(ServerInfo* pInfo);
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
83
|
|
74d1e6a8
Hu Chunming
完成gb28181大体的代码,未完...
|
84
|
int RequestInvite_UDP(const char* dst_channel, int rtpPort);
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
85
|
|
74d1e6a8
Hu Chunming
完成gb28181大体的代码,未完...
|
86
|
int RequestInvite_TCP_a(const char* dst_channel, int rtpPort);
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
87
|
|
fe625b06
Hu Chunming
设备状态的检查与定时更新
|
88
|
void close();
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
89
90
91
|
public:
void event_loop();
|
fe625b06
Hu Chunming
设备状态的检查与定时更新
|
92
|
void timing_getcatlog();
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
93
94
95
96
97
98
|
private:
int init_sip_server();
int sip_event_handle(eXosip_event_t *evtp);
void RequestCatalog(Client* client);
|
fe625b06
Hu Chunming
设备状态的检查与定时更新
|
99
|
void cacheCatalog();
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
100
101
102
103
104
105
106
107
108
109
110
111
|
void response_message_answer(eXosip_event_t *evtp,int code);
void response_register(eXosip_event_t *evtp);
void response_register_401unauthorized(eXosip_event_t *evt);
void response_message(eXosip_event_t *evtp);
void response_invite_ack(eXosip_event_t *evtp);
int request_bye(eXosip_event_t* evtp);// 通知相机停止推流
int parse_xml(const char* data, const char* s_mark, bool with_s_make, const char* e_mark, bool with_e_make, char* dest);
void dump_request(eXosip_event_t *evtp);
void dump_response(eXosip_event_t *evtp);
int clearClientMap();
|
0af3b245
Hu Chunming
添加多nvr和多摄像头管理
|
112
113
114
|
void deleteClientByDevice(string device);
Client* get_parent_by_id(string id);
|
fe625b06
Hu Chunming
设备状态的检查与定时更新
|
115
|
bool check_device_status(string id);
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
116
117
118
119
120
121
122
|
private:
bool mQuit{ false };
eXosip_t *mSipCtx;
ServerInfo mInfo;
std::map<std::string, Client *> mClientMap;// <DeviceID,SipClient>
|
1116447e
Hu Chunming
代码逻辑有花
|
123
|
mutex m_client_map_mtx;
|
0af3b245
Hu Chunming
添加多nvr和多摄像头管理
|
124
|
std::map<std::string, DeviceInfo> m_device_map;
|
1116447e
Hu Chunming
代码逻辑有花
|
125
|
mutex m_device_map_mtx;
|
c8285c8d
Hu Chunming
GB28181 UDP 有重大进展...
|
126
127
128
129
130
|
thread* m_event_loop_thread;
};
|
ffe81045
Hu Chunming
优化目录xml解析;优化sipse...
|
131
|
#endif //__SIPSERVER_H__
|