mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
support access to NVR, gb28181 system sub domain
This commit is contained in:
parent
28bde1d448
commit
7826c743e4
2 changed files with 386 additions and 100 deletions
|
@ -41,6 +41,7 @@ class SrsSipRequest;
|
|||
class SrsGb28181Config;
|
||||
class SrsSipStack;
|
||||
class SrsGb28181SipService;
|
||||
class SrsGb28181Device;
|
||||
|
||||
enum SrsGb28181SipSessionStatusType{
|
||||
SrsGb28181SipSessionUnkonw = 0,
|
||||
|
@ -51,6 +52,19 @@ enum SrsGb28181SipSessionStatusType{
|
|||
SrsGb28181SipSessionBye = 5,
|
||||
};
|
||||
|
||||
class SrsGb28181Device
|
||||
{
|
||||
public:
|
||||
SrsGb28181Device();
|
||||
virtual ~SrsGb28181Device();
|
||||
public:
|
||||
std::string device_id;
|
||||
std::string device_status;
|
||||
SrsGb28181SipSessionStatusType invite_status;
|
||||
srs_utime_t invite_time;
|
||||
SrsSipRequest req_inivate;
|
||||
};
|
||||
|
||||
class SrsGb28181SipSession: public ISrsCoroutineHandler, public ISrsConnection
|
||||
{
|
||||
private:
|
||||
|
@ -67,6 +81,7 @@ private:
|
|||
srs_utime_t _alive_time;
|
||||
srs_utime_t _invite_time;
|
||||
srs_utime_t _reg_expires;
|
||||
srs_utime_t _query_catalog_time;
|
||||
|
||||
std::string _peer_ip;
|
||||
int _peer_port;
|
||||
|
@ -75,10 +90,16 @@ private:
|
|||
int _fromlen;
|
||||
SrsSipRequest *req;
|
||||
|
||||
std::map<std::string, SrsGb28181Device*> _device_list;
|
||||
//std::map<std::string, int> _device_status;
|
||||
|
||||
public:
|
||||
SrsGb28181SipSession(SrsGb28181SipService *c, SrsSipRequest* r);
|
||||
virtual ~SrsGb28181SipSession();
|
||||
|
||||
private:
|
||||
void destroy();
|
||||
|
||||
public:
|
||||
void set_register_status(SrsGb28181SipSessionStatusType s) { _register_status = s;}
|
||||
void set_alive_status(SrsGb28181SipSessionStatusType s) { _alive_status = s;}
|
||||
|
@ -94,7 +115,6 @@ public:
|
|||
void set_sockaddr_len(int l) { _fromlen = l;}
|
||||
void set_request(SrsSipRequest *r) { req->copy(r);}
|
||||
|
||||
|
||||
SrsGb28181SipSessionStatusType register_status() { return _register_status;}
|
||||
SrsGb28181SipSessionStatusType alive_status() { return _alive_status;}
|
||||
SrsGb28181SipSessionStatusType invite_status() { return _invite_status;}
|
||||
|
@ -110,6 +130,10 @@ public:
|
|||
SrsSipRequest request() { return *req;}
|
||||
|
||||
std::string session_id() { return _session_id;}
|
||||
public:
|
||||
void update_device_list(std::map<std::string, std::string> devlist);
|
||||
SrsGb28181Device *get_device_info(std::string chid);
|
||||
void dumps(SrsJsonObject* obj);
|
||||
|
||||
public:
|
||||
virtual srs_error_t serve();
|
||||
|
@ -130,6 +154,7 @@ private:
|
|||
srs_netfd_t lfd;
|
||||
|
||||
std::map<std::string, SrsGb28181SipSession*> sessions;
|
||||
std::map<std::string, SrsGb28181SipSession*> sessions_by_callid;
|
||||
public:
|
||||
SrsGb28181SipService(SrsConfDirective* c);
|
||||
virtual ~SrsGb28181SipService();
|
||||
|
@ -140,15 +165,16 @@ public:
|
|||
virtual void set_stfd(srs_netfd_t fd);
|
||||
private:
|
||||
void destroy();
|
||||
srs_error_t on_udp_sip(std::string host, int port, char* buf, int nb_buf, sockaddr* from, int fromlen);
|
||||
srs_error_t on_udp_sip(std::string host, int port, std::string recv_msg, sockaddr* from, int fromlen);
|
||||
public:
|
||||
int send_message(sockaddr* f, int l, std::stringstream& ss);
|
||||
|
||||
int send_ack(SrsSipRequest *req, sockaddr *f, int l);
|
||||
int send_status(SrsSipRequest *req, sockaddr *f, int l);
|
||||
|
||||
int send_invite(SrsSipRequest *req, std::string ip, int port, uint32_t ssrc);
|
||||
int send_bye(SrsSipRequest *req);
|
||||
int send_invite(SrsSipRequest *req, std::string ip, int port, uint32_t ssrc, std::string chid);
|
||||
int send_bye(SrsSipRequest *req, std::string chid);
|
||||
int send_query_catalog(SrsSipRequest *req);
|
||||
|
||||
// The SIP command is transmitted through HTTP API,
|
||||
// and the body content is transmitted to the device,
|
||||
|
@ -165,6 +191,7 @@ public:
|
|||
//
|
||||
//
|
||||
int send_sip_raw_data(SrsSipRequest *req, std::string data);
|
||||
int query_sip_session(std::string sid, SrsJsonArray* arr);
|
||||
|
||||
public:
|
||||
srs_error_t fetch_or_create_sip_session(SrsSipRequest *req, SrsGb28181SipSession** sess);
|
||||
|
@ -172,6 +199,9 @@ public:
|
|||
void remove_session(std::string id);
|
||||
SrsGb28181Config* get_config();
|
||||
|
||||
void sip_session_map_by_callid(SrsGb28181SipSession *sess, std::string call_id);
|
||||
void sip_session_unmap_by_callid(std::string call_id);
|
||||
SrsGb28181SipSession* fetch_session_by_callid(std::string call_id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue