mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-30 16:27:36 +08:00
f71a32bc8c
测试用例
60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
//============================================================================
|
|
// Name : main.cpp
|
|
// Author : 熊子良
|
|
// Version :
|
|
//============================================================================
|
|
|
|
|
|
#include <signal.h>
|
|
#include <unistd.h>
|
|
#include <iostream>
|
|
#include "Util/SqlPool.h"
|
|
#include "Util/logger.h"
|
|
#include "Util/onceToken.h"
|
|
#include "Rtsp/UDPServer.h"
|
|
#include "Rtsp/RtspSession.h"
|
|
#include "Rtmp/RtmpSession.h"
|
|
#include "Network/TcpServer.h"
|
|
#include "Poller/EventPoller.hpp"
|
|
#include "Thread/WorkThreadPool.h"
|
|
#include "Http/HttpSession.h"
|
|
|
|
using namespace std;
|
|
using namespace ZL::Util;
|
|
using namespace ZL::Http;
|
|
using namespace ZL::Rtsp;
|
|
using namespace ZL::Rtmp;
|
|
using namespace ZL::Thread;
|
|
using namespace ZL::Network;
|
|
|
|
void programExit(int arg) {
|
|
EventPoller::Instance().shutdown();
|
|
}
|
|
int main(int argc,char *argv[]){
|
|
signal(SIGINT, programExit);
|
|
|
|
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
|
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
|
|
|
TcpServer<RtspSession>::Ptr rtspSrv(new TcpServer<RtspSession>());
|
|
TcpServer<RtmpSession>::Ptr rtmpSrv(new TcpServer<RtmpSession>());
|
|
TcpServer<HttpSession>::Ptr httpSrv(new TcpServer<HttpSession>());
|
|
rtspSrv->start(mINI::Instance()[Config::Rtsp::kPort]);
|
|
rtmpSrv->start(mINI::Instance()[Config::Rtmp::kPort]);
|
|
httpSrv->start(mINI::Instance()[Config::Http::kPort]);
|
|
|
|
EventPoller::Instance().runLoop();
|
|
|
|
rtspSrv.reset();
|
|
rtmpSrv.reset();
|
|
httpSrv.reset();
|
|
static onceToken token(nullptr, []() {
|
|
UDPServer::Destory();
|
|
WorkThreadPool::Destory();
|
|
EventPoller::Destory();
|
|
Logger::Destory();
|
|
});
|
|
return 0;
|
|
}
|
|
|