#ifndef _RTPSERVER_H_ #define _RTPSERVER_H_ #include #include #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 m_logger = nullptr; /* 日志记录器 */ QTcpServer *m_tcpServer; /* TCP服务器对象 */ int m_port; /* 监听端口 */ QList m_listClients; /* 客户端连接列表,用于管理多个客户端连接 */ /* 录音通道线程列表,键为录音通道ID,值为对应的RTP线程对象 */ QMap m_mapRoadThreads; }; #endif // _RTPSERVER_H_