diff --git a/Home.md b/Home.md index bcf49bc..b24631b 100644 --- a/Home.md +++ b/Home.md @@ -1,87 +1 @@ -# 怎么使用ZLMediaKit -## 1、服务器: -``` - TcpServer::Ptr rtspSrv(new TcpServer()); - TcpServer::Ptr rtmpSrv(new TcpServer()); - TcpServer::Ptr httpSrv(new TcpServer()); - TcpServer::Ptr httpsSrv(new TcpServer()); - - rtspSrv->start(mINI::Instance()[Config::Rtsp::kPort]); - rtmpSrv->start(mINI::Instance()[Config::Rtmp::kPort]); - httpSrv->start(mINI::Instance()[Config::Http::kPort]); - httpsSrv->start(mINI::Instance()[Config::Http::kSSLPort]); - EventPoller::Instance().runLoop(); -``` - -## 2、播放器: -``` - MediaPlayer::Ptr player(new MediaPlayer()); - player->setOnPlayResult([](const SockException &ex) { - InfoL << "OnPlayResult:" << ex.what(); - }); - player->setOnShutdown([](const SockException &ex) { - ErrorL << "OnShutdown:" << ex.what(); - }); - player->setOnVideoCB([&](const H264Frame &frame){ - //在这里解码H264并显示 - }); - player->setOnAudioCB([&](const AdtsFrame &frame){ - //在这里解码AAC并播放 - }); - //支持rtmp、rtsp - player->play("rtsp://192.168.0.122/","admin","123456",(PlayerBase::eRtpType)atoi(argv[4])); - EventPoller::Instance().runLoop(); -``` -## 3、代理服务器: -``` - //support rtmp and rtsp url - //just support H264+AAC - auto urlList = {"rtmp://live.hkstv.hk.lxdns.com/live/hks", - "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"}; - map proxyMap; - int i=0; - for(auto url : urlList){ - //PlayerProxy构造函数前两个参数分别为应用名(app),流id(streamId) - //比如说应用为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 - PlayerProxy::Ptr player(new PlayerProxy("live",to_string(i++).data())); - player->play(url); - proxyMap.emplace(string(url),player); - } -``` - -# 怎么测试服务器性能? - ZLMediaKit提供了测试性能的示例,代码在tests/test_benchmark.cpp。由于ZLTookKit默认关闭了tcp客户端多线程的支持,如果需要提高测试并发量,需要在编译ZLToolKit时启用ENABLE_ASNC_TCP_CLIENT宏,具体操作如下: -``` - #编译ZLToolKit - cd ZLToolKit - mkdir -p build - cd build -DENABLE_ASNC_TCP_CLIENT - cmake .. - make -j4 - sudo make install -``` - - -# github下载太慢了,有其他下载方式吗? -你可以在通过开源中国获取最新的代码,地址为: - -[ZLToolKit](http://git.oschina.net/xiahcu/ZLToolKit) - -[ZLMediaKit](http://git.oschina.net/xiahcu/ZLMediaKit) - - -# 怎么联系作者 - -你可以直接发邮件给我 :<771730766@qq.com> - -也可以加入QQ群@我:542509000 - -请尽量在github上通过发布Issues的方式来反馈或获取帮助 - +[ZLMediaKit高并发实现原理](https://github.com/xiongziliang/ZLMediaKit/wiki/ZLMediaKit%E9%AB%98%E5%B9%B6%E5%8F%91%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86) \ No newline at end of file