1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #ifndef _RTPSERVER_H_
- #define _RTPSERVER_H_
- #include <QTcpServer>
- #include <QList>
- #include "spdlog/spdlog.h"
- #include "Rtpcommon.h"
- #include "GlobalVariable.h"
- #include "RtpOneRoadThread.h"
- /**
- * RTP监听服务,监听客户端发起的数据接受请求
- * 功能:
- * 1、监听客户端的连接请求,获取客户端发送过来的UDP端口
- * 2、创建一个RTP数据对象,负责发送数据
- * 接收的数据:
- * 0是登录,1是心跳,2是注销
- */
- class RTPServer : public QObject
- {
- Q_OBJECT
- public:
- explicit RTPServer(QObject *parent = nullptr);
- ~RTPServer();
- /**
- * @brief 启动RTP服务
- * @param port 监听端口
- * @return 成功返回true,失败返回false
- */
- bool startServer(int port);
- private slots:
- /* 处理新连接 */
- void do_newConnection();
- /* 断开连接 */
- void do_disconnect();
- /* 接收消息 */
- void do_receiveMessage();
- private:
- /* 处理登录请求 */
- void handleLogin(RtpSendClientInfo_t& clientInfo);
- /* 处理心跳请求 */
- void handleHeartbeat(RtpSendClientInfo_t& clientInfo);
- /* 处理注销请求 */
- void handleLogout(RtpSendClientInfo_t& clientInfo);
- /* 获取发送UDP数据的指针 */
- bool getSendUdpSocketPtr(SoundCardRoadInfo_t roadInfo);
- private:
- std::shared_ptr<spdlog::logger> m_logger = nullptr; /* 日志记录器 */
- QTcpServer *m_tcpServer; /* TCP服务器对象 */
- int m_port; /* 监听端口 */
- QList<QTcpSocket*> m_listClients; /* 客户端连接列表,用于管理多个客户端连接 */
- /* 录音通道线程列表,键为录音通道ID,值为对应的RTP线程对象 */
- QMap<SoundCardRoadInfo_t, RTPOneRoadThread*> m_mapRoadThreads;
- };
- #endif // _RTPSERVER_H_
|