mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-06 03:28:09 +08:00
初步完成Windows下的移植
This commit is contained in:
@@ -39,9 +39,11 @@ add_executable(${TEST_EXE_NAME} ${TEST_SRC})
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_static ${LINK_LIB_LIST})
|
||||
else(ANDROID)
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST} pthread)
|
||||
endif(ANDROID)
|
||||
elseif(WIN32)
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST})
|
||||
else()
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST} pthread)
|
||||
endif()
|
||||
|
||||
endforeach(TEST_SRC ${TEST_SRC_LIST})
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
@@ -29,8 +28,8 @@ int main(int argc, char *argv[]){
|
||||
signal(SIGINT, programExit);
|
||||
|
||||
if(argc != 5){
|
||||
FatalL << "\r\n测试方法:./test_benchmark player_count play_interval rtxp_url rtp_type\r\n"
|
||||
<< "例如你想每隔50毫秒启动共计100个播放器(tcp方式播放rtsp://127.0.0.1/live/0 )可以输入以下命令:\r\n"
|
||||
FatalL << "\r\n测试方法:./test_benchmark player_count play_interval rtxp_url rtp_type\r\n"
|
||||
<< "例如你想每隔50毫秒启动共计100个播放器(tcp方式播放rtsp://127.0.0.1/live/0 )可以输入以下命令:\r\n"
|
||||
<< "./test_benchmark 100 50 rtsp://127.0.0.1/live/0 0\r\n"
|
||||
<<endl;
|
||||
Logger::Destory();
|
||||
@@ -59,7 +58,7 @@ int main(int argc, char *argv[]){
|
||||
});
|
||||
|
||||
AsyncTaskThread::Instance().DoTaskDelay(0, 1000, [&](){
|
||||
InfoL << "存活播放器个数:" << alivePlayerCnt.load();
|
||||
InfoL << "存活播放器个数:" << alivePlayerCnt.load();
|
||||
return true;
|
||||
});
|
||||
EventPoller::Instance().runLoop();
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
//============================================================================
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "Http/HttpDownloader.h"
|
||||
#include "Http/HttpRequester.h"
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "Util/logger.h"
|
||||
#include "Util/onceToken.h"
|
||||
@@ -44,14 +43,14 @@ int main(int argc,char *argv[]){
|
||||
const_cast<RtmpPusher::Ptr &>(pusher).reset(new RtmpPusher(app,stream));
|
||||
|
||||
pusher->setOnShutdown([](const SockException &ex){
|
||||
WarnL << "已断开与服务器连接:" << ex.getErrCode() << " " << ex.what();
|
||||
WarnL << "已断开与服务器连接:" << ex.getErrCode() << " " << ex.what();
|
||||
});
|
||||
|
||||
pusher->setOnPublished([](const SockException &ex){
|
||||
if(ex){
|
||||
WarnL << "发布失败:" << ex.getErrCode() << " "<< ex.what();
|
||||
WarnL << "发布失败:" << ex.getErrCode() << " "<< ex.what();
|
||||
}else{
|
||||
InfoL << "发布成功,请用播放器打开:rtmp://jizan.iok.la/live/test";
|
||||
InfoL << "发布成功,请用播放器打开:rtmp://jizan.iok.la/live/test";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include "Common/config.h"
|
||||
#include "Rtsp/UDPServer.h"
|
||||
#include "Rtsp/RtspSession.h"
|
||||
#include "Rtmp/RtmpSession.h"
|
||||
@@ -18,22 +19,24 @@
|
||||
#include "Http/HttpsSession.h"
|
||||
#endif//ENABLE_OPENSSL
|
||||
|
||||
#include "Util/File.h"
|
||||
#include "Util/logger.h"
|
||||
#include "Util/onceToken.h"
|
||||
#include "Util/File.h"
|
||||
#include "Network/TcpServer.h"
|
||||
#include "Poller/EventPoller.h"
|
||||
#include "Thread/WorkThreadPool.h"
|
||||
#include "Device/PlayerProxy.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include "Shell/ShellSession.h"
|
||||
#include "Common/config.h"
|
||||
#include <map>
|
||||
using namespace ZL::Shell;
|
||||
#endif // !defined(_WIN32)
|
||||
|
||||
using namespace std;
|
||||
using namespace ZL::Util;
|
||||
using namespace ZL::Http;
|
||||
using namespace ZL::Rtsp;
|
||||
using namespace ZL::Rtmp;
|
||||
using namespace ZL::Shell;
|
||||
using namespace ZL::Thread;
|
||||
using namespace ZL::Network;
|
||||
using namespace ZL::DEV;
|
||||
@@ -42,10 +45,11 @@ void programExit(int arg) {
|
||||
EventPoller::Instance().shutdown();
|
||||
}
|
||||
int main(int argc,char *argv[]){
|
||||
setExePath(argv[0]);
|
||||
// setExePath(argv[0]);
|
||||
signal(SIGINT, programExit);
|
||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
||||
Config::loaIniConfig();
|
||||
DebugL << exePath();
|
||||
//support rtmp and rtsp url
|
||||
//just support H264+AAC
|
||||
auto urlList = {"rtmp://live.hkstv.hk.lxdns.com/live/hks",
|
||||
@@ -54,11 +58,11 @@ int main(int argc,char *argv[]){
|
||||
int i=0;
|
||||
for(auto url : urlList){
|
||||
//PlayerProxy构造函数前两个参数分别为应用名(app),流id(streamId)
|
||||
//比如说应用为live,流id为0,那么直播地址为:
|
||||
//比如说应用为live,流id为0,那么直播地址为:
|
||||
//http://127.0.0.1/live/0/hls.m3u8
|
||||
//rtsp://127.0.0.1/live/0
|
||||
//rtmp://127.0.0.1/live/0
|
||||
//录像地址为:
|
||||
//录像地址为:
|
||||
//http://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
|
||||
//rtsp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
|
||||
//rtmp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
|
||||
@@ -81,17 +85,20 @@ int main(int argc,char *argv[]){
|
||||
TcpServer<RtspSession>::Ptr rtspSrv(new TcpServer<RtspSession>());
|
||||
TcpServer<RtmpSession>::Ptr rtmpSrv(new TcpServer<RtmpSession>());
|
||||
TcpServer<HttpSession>::Ptr httpSrv(new TcpServer<HttpSession>());
|
||||
TcpServer<ShellSession>::Ptr shellSrv(new TcpServer<ShellSession>());
|
||||
|
||||
|
||||
rtspSrv->start(mINI::Instance()[Config::Rtsp::kPort]);
|
||||
rtmpSrv->start(mINI::Instance()[Config::Rtmp::kPort]);
|
||||
httpSrv->start(mINI::Instance()[Config::Http::kPort]);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
//简单的telnet服务器,可用于服务器调试,但是不能使用23端口
|
||||
//测试方法:telnet 127.0.0.1 8023
|
||||
//输入用户名和密码登录(user:test,pwd:123456),输入help命令查看帮助
|
||||
TcpServer<ShellSession>::Ptr shellSrv(new TcpServer<ShellSession>());
|
||||
ShellSession::addUser("test","123456");
|
||||
shellSrv->start(8023);
|
||||
#endif // !defined(_WIN32)
|
||||
|
||||
#ifdef ENABLE_OPENSSL
|
||||
TcpServer<HttpsSession>::Ptr httpsSrv(new TcpServer<HttpsSession>());
|
||||
@@ -103,7 +110,10 @@ int main(int argc,char *argv[]){
|
||||
rtspSrv.reset();
|
||||
rtmpSrv.reset();
|
||||
httpSrv.reset();
|
||||
|
||||
#if !defined(_WIN32)
|
||||
shellSrv.reset();
|
||||
#endif // !defined(_WIN32)
|
||||
|
||||
#ifdef ENABLE_OPENSSL
|
||||
httpsSrv.reset();
|
||||
|
||||
Reference in New Issue
Block a user