mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
添加rtmps服务器
This commit is contained in:
parent
f9df7f5217
commit
7e85be7654
@ -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<RtspSession>(rtspPort);//默认554
|
||||
if(rtspPort) { rtspSrv->start<RtspSession>(rtspPort); }
|
||||
//rtsps服务器,端口默认322
|
||||
rtspSSLSrv->start<RtspSessionWithSSL>(rtspsPort);
|
||||
if(rtspsPort) { rtspSSLSrv->start<RtspSessionWithSSL>(rtspsPort); }
|
||||
|
||||
//rtmp服务器,端口默认1935
|
||||
rtmpSrv->start<RtmpSession>(rtmpPort);
|
||||
if(rtmpPort) { rtmpSrv->start<RtmpSession>(rtmpPort); }
|
||||
//rtmps服务器,端口默认19350
|
||||
if(rtmpsPort) { rtmpsSrv->start<RtmpSessionWithSSL>(rtmpsPort); }
|
||||
|
||||
//http服务器,端口默认80
|
||||
httpSrv->start<HttpSession>(httpPort);
|
||||
if(httpPort) { httpSrv->start<HttpSession>(httpPort); }
|
||||
//https服务器,端口默认443
|
||||
httpsSrv->start<HttpsSession>(httpsPort);
|
||||
if(httpsPort) { httpsSrv->start<HttpsSession>(httpsPort); }
|
||||
|
||||
//telnet远程调试服务器
|
||||
shellSrv->start<ShellSession>(shellPort);
|
||||
if(shellPort) { shellSrv->start<ShellSession>(shellPort); }
|
||||
|
||||
#if defined(ENABLE_RTPPROXY)
|
||||
if(rtpPort){
|
||||
//创建rtp udp服务器
|
||||
recver.initSock(rtp_proxy);
|
||||
recver.initSock(rtpPort);
|
||||
//创建rtp tcp服务器
|
||||
tcpRtpServer->start<RtpSession>(rtp_proxy);
|
||||
tcpRtpServer->start<RtpSession>(rtpPort);
|
||||
}
|
||||
#endif//defined(ENABLE_RTPPROXY)
|
||||
|
||||
}catch (std::exception &ex){
|
||||
|
@ -91,6 +91,12 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 支持ssl加密的rtmp服务器
|
||||
*/
|
||||
typedef TcpSessionWithSSL<RtmpSession> RtmpSessionWithSSL;
|
||||
|
||||
} /* namespace mediakit */
|
||||
|
||||
#endif /* SRC_RTMP_RTMPSESSION_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user