2017-04-05 09:39:16 +08:00
|
|
|
//============================================================================
|
|
|
|
// 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"
|
2017-04-19 17:47:07 +08:00
|
|
|
#include "Http/HttpsSession.h"
|
|
|
|
#include "Util/SSLBox.h"
|
2017-04-20 11:56:31 +08:00
|
|
|
#ifdef ENABLE_HKDEVICE
|
|
|
|
#include "test/DeviceHK.h"
|
|
|
|
#endif //ENABLE_HKDEVICE
|
2017-04-05 09:39:16 +08:00
|
|
|
|
|
|
|
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>());
|
2017-04-20 11:56:31 +08:00
|
|
|
|
|
|
|
#ifdef ENABLE_HKDEVICE
|
|
|
|
DeviceHK::Ptr dev(new DeviceHK());
|
|
|
|
dev->connectDevice( connectInfo("192.168.0.211", 8000, "admin", "password"), [dev](bool success,const connectResult &result) {
|
|
|
|
if(success) {
|
|
|
|
dev->addAllChannel();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
#endif //ENABLE_HKDEVICE
|
|
|
|
|
2017-04-19 17:47:07 +08:00
|
|
|
SSL_Initor::Instance().loadServerPem((exeDir() + ".HttpServer.pem").data());
|
2017-04-05 09:39:16 +08:00
|
|
|
|
|
|
|
TcpServer<RtspSession>::Ptr rtspSrv(new TcpServer<RtspSession>());
|
|
|
|
TcpServer<RtmpSession>::Ptr rtmpSrv(new TcpServer<RtmpSession>());
|
|
|
|
TcpServer<HttpSession>::Ptr httpSrv(new TcpServer<HttpSession>());
|
2017-04-19 17:47:07 +08:00
|
|
|
TcpServer<HttpsSession>::Ptr httpsSrv(new TcpServer<HttpsSession>());
|
2017-04-05 09:39:16 +08:00
|
|
|
rtspSrv->start(mINI::Instance()[Config::Rtsp::kPort]);
|
|
|
|
rtmpSrv->start(mINI::Instance()[Config::Rtmp::kPort]);
|
|
|
|
httpSrv->start(mINI::Instance()[Config::Http::kPort]);
|
2017-04-19 17:47:07 +08:00
|
|
|
httpsSrv->start(mINI::Instance()[Config::Http::kSSLPort]);
|
2017-04-05 09:39:16 +08:00
|
|
|
|
|
|
|
EventPoller::Instance().runLoop();
|
|
|
|
|
|
|
|
rtspSrv.reset();
|
|
|
|
rtmpSrv.reset();
|
|
|
|
httpSrv.reset();
|
2017-04-19 17:47:07 +08:00
|
|
|
httpsSrv.reset();
|
2017-04-05 09:39:16 +08:00
|
|
|
static onceToken token(nullptr, []() {
|
|
|
|
UDPServer::Destory();
|
|
|
|
WorkThreadPool::Destory();
|
|
|
|
EventPoller::Destory();
|
|
|
|
Logger::Destory();
|
|
|
|
});
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|