diff --git a/server/main.cpp b/server/main.cpp index 55ea061e..cd1ee8a0 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -75,8 +75,10 @@ onceToken token1([](){ namespace Rtmp { #define RTMP_FIELD "rtmp." const string kPort = RTMP_FIELD"port"; +const string kSSLPort = RTMP_FIELD"sslport"; onceToken token1([](){ mINI::Instance()[kPort] = 1935; + mINI::Instance()[kSSLPort] = 19350; },nullptr); } //namespace RTMP @@ -255,9 +257,10 @@ int start_main(int argc,char *argv[]) { uint16_t rtspPort = mINI::Instance()[Rtsp::kPort]; uint16_t rtspsPort = mINI::Instance()[Rtsp::kSSLPort]; uint16_t rtmpPort = mINI::Instance()[Rtmp::kPort]; + uint16_t rtmpsPort = mINI::Instance()[Rtmp::kSSLPort]; uint16_t httpPort = mINI::Instance()[Http::kPort]; uint16_t httpsPort = mINI::Instance()[Http::kSSLPort]; - uint16_t rtp_proxy = mINI::Instance()[RtpProxy::kPort]; + uint16_t rtpPort = mINI::Instance()[RtpProxy::kPort]; //设置poller线程数,该函数必须在使用ZLToolKit网络相关对象之前调用才能生效 EventPollerPool::setPoolSize(threads); @@ -265,38 +268,51 @@ int start_main(int argc,char *argv[]) { //简单的telnet服务器,可用于服务器调试,但是不能使用23端口,否则telnet上了莫名其妙的现象 //测试方法:telnet 127.0.0.1 9000 TcpServer::Ptr shellSrv(new TcpServer()); + + //rtsp[s]服务器, 可用于诸如亚马逊echo show这样的设备访问 TcpServer::Ptr rtspSrv(new TcpServer()); - TcpServer::Ptr rtmpSrv(new TcpServer()); - TcpServer::Ptr httpSrv(new TcpServer()); - //如果支持ssl,还可以开启https服务器 - TcpServer::Ptr httpsSrv(new TcpServer()); - //支持ssl加密的rtsp服务器,可用于诸如亚马逊echo show这样的设备访问 TcpServer::Ptr rtspSSLSrv(new TcpServer()); + //rtmp[s]服务器 + TcpServer::Ptr rtmpSrv(new TcpServer()); + TcpServer::Ptr rtmpsSrv(new TcpServer()); + + //http[s]服务器 + TcpServer::Ptr httpSrv(new TcpServer()); + TcpServer::Ptr httpsSrv(new TcpServer()); + #if defined(ENABLE_RTPPROXY) + //GB28181 rtp推流端口,支持UDP/TCP UdpRecver recver; TcpServer::Ptr tcpRtpServer(new TcpServer()); #endif//defined(ENABLE_RTPPROXY) try { //rtsp服务器,端口默认554 - rtspSrv->start(rtspPort);//默认554 + if(rtspPort) { rtspSrv->start(rtspPort); } //rtsps服务器,端口默认322 - rtspSSLSrv->start(rtspsPort); + if(rtspsPort) { rtspSSLSrv->start(rtspsPort); } + //rtmp服务器,端口默认1935 - rtmpSrv->start(rtmpPort); + if(rtmpPort) { rtmpSrv->start(rtmpPort); } + //rtmps服务器,端口默认19350 + if(rtmpsPort) { rtmpsSrv->start(rtmpsPort); } + //http服务器,端口默认80 - httpSrv->start(httpPort); + if(httpPort) { httpSrv->start(httpPort); } //https服务器,端口默认443 - httpsSrv->start(httpsPort); + if(httpsPort) { httpsSrv->start(httpsPort); } + //telnet远程调试服务器 - shellSrv->start(shellPort); + if(shellPort) { shellSrv->start(shellPort); } #if defined(ENABLE_RTPPROXY) - //创建rtp udp服务器 - recver.initSock(rtp_proxy); - //创建rtp tcp服务器 - tcpRtpServer->start(rtp_proxy); + if(rtpPort){ + //创建rtp udp服务器 + recver.initSock(rtpPort); + //创建rtp tcp服务器 + tcpRtpServer->start(rtpPort); + } #endif//defined(ENABLE_RTPPROXY) }catch (std::exception &ex){ diff --git a/src/Rtmp/RtmpSession.h b/src/Rtmp/RtmpSession.h index da76c627..f88d2eb6 100644 --- a/src/Rtmp/RtmpSession.h +++ b/src/Rtmp/RtmpSession.h @@ -91,6 +91,12 @@ private: }; + +/** + * 支持ssl加密的rtmp服务器 + */ +typedef TcpSessionWithSSL RtmpSessionWithSSL; + } /* namespace mediakit */ #endif /* SRC_RTMP_RTMPSESSION_H_ */