Blame view

src/decoder/gb28181/websocket/WebsocketClient.h 1.77 KB
d8fe994c   Hu Chunming   提交解码代码
1
2
3
4
5
6
7
8
  #include <map>
  #include <mutex>
  
  #include <websocketpp/config/asio_no_tls_client.hpp>
  #include <websocketpp/client.hpp>
  
  #include "Message/CatalogParser.h"
  
c027963f   Hu Chunming   ffmpeg6.1.1版本的接收rtp
9
  #include "../rtp2/RTPReceiver2.h"
d8fe994c   Hu Chunming   提交解码代码
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
  
  typedef websocketpp::client<websocketpp::config::asio_client> client;
  typedef websocketpp::config::asio_client::message_type::ptr message_ptr;
  
  class WebsocketClient
  {
  public:
      static WebsocketClient* getInstance(){
  		static WebsocketClient* singleton = nullptr;
  		if (singleton == nullptr){
  			singleton = new WebsocketClient();
  		}
  		return singleton;
  	}
  
  public:
      int init();
  
      void close();
  
      void terminate();
  
      int GetMinRtpPort();
      int GetMaxRtpPort();
  
c027963f   Hu Chunming   ffmpeg6.1.1版本的接收rtp
35
36
      int InviteUdp(std::string sip_channel_id, int rtp_port, RTPReceiver2* r);
      int InviteTcp(std::string sip_channel_id, int rtp_port, RTPReceiver2* r);
d8fe994c   Hu Chunming   提交解码代码
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  
      int ByeInvite(std::string sip_channel_id, int rtp_port);
  
      int DeleteReceiverPair(std::string sip_channel_id, int rtp_port);
  
  public:
      void on_open(websocketpp::connection_hdl hdl);
      void on_close(websocketpp::connection_hdl hdl);
  
      void on_message(websocketpp::connection_hdl hdl, message_ptr msg);
  
      void on_fail(websocketpp::connection_hdl hdl);
  
  private:
      bool readCfg();
      int connect();
      int reconnect();
      int check_connect();
      void send_text(std::string msg);
  
      int msg_parser(websocketpp::connection_hdl hdl, string msg);
  
c027963f   Hu Chunming   ffmpeg6.1.1版本的接收rtp
59
      void cache_receiver(std::string sip_channel_id, int rtp_port, RTPReceiver2* r);
d8fe994c   Hu Chunming   提交解码代码
60
61
62
63
64
65
66
67
68
69
70
71
72
  
      void response_invite_failed(std::string rKey);
  
  private:
    client m_client;
    websocketpp::lib::shared_ptr<websocketpp::lib::thread> thread_;
    websocketpp::connection_hdl m_hdl;
    std::string uri;
  
    ServerInfo mInfo;
  
    bool mbClosed{false};
  
c027963f   Hu Chunming   ffmpeg6.1.1版本的接收rtp
73
    std::map<string, RTPReceiver2*> m_receiver_map;
d8fe994c   Hu Chunming   提交解码代码
74
75
    std::mutex m_receiver_map_mtx;
  };