2019-10-09 zlmediakit主要代码流程整理

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019-10-09 zlmediakit主要代码流程整理相关的知识,希望对你有一定的参考价值。

参考技术A rtsp_push
main
|
|->domain //两个参数 第一个playurl(rtsps/rtsp/rtmp/rtmps), 第二个pushurl
|
|->Logger::add //设置日志
|
|->Logger::setWriter
|
|->EventPollerPool::getPoller
|
|->new PlayerProxy //可指定拉流方式,默认tcp,PlayerProxy继承MediaPlayer
|
|->PlayerProxy::play //开始拉流播放
|
|->setOnPlayResult //lambda 做函数参数,这里为了方便理解,直接用层层调用的方式展示调用关系
|
|->setOnShutdown
|
|->MediaPlayer::play //PlayerProxy继承MediaPlayer, MediaPlayer继承PlayerBase
|
|->PlayerBase::createPlayer //根据url中带的rtsps/rtsp/rtmp/rtmps来创建对应实例,RtspPlayer/RtmpPlayer/
|
|->RtspPlayer::play //这里只看rtsp方式,创建tcp连接,开始收数据
|
|->RtspPlayer::play //重载,支持url中带用户名密码
|
|->RtspPlayer::teardown //如果是alive的 先调下teardown去关闭流,并清理下资源
|
|->TcpClient::startConnect //解析出ip port 和域名
|
|->Socket::connect //TcpClient中保存socket智能指针,创建tcp客户端,url可以是ip或域名
| //connect不成功,回调设置错误状态
|->SockUtil::connect//套接字工具类,封装了socket、网络的一些基本操作
|
|->TcpClient::onSockConnect //connect成功后,回调中再在网络线程中触发 senddescribe
| //这里为了方便显示调用顺序,实际onSockConnect是回调触发
|->RtspPlayer::onErr //被动断开连接回调,这里只看rtspplayer
|
|->onPlayResult_l
|
|->onFlush //这里并没有做什么
|
|->TcpClient::onSockRecv//
|
|->RtspPlayer::onRecv//这里已经开始收服务端的数据了
|
|->HttpRequestSplitter::input
|
|->RtspSplitter::onRecvContent
|
|->RtspPlayer::onWholeRtspPacket//这里就是收解析rtsp 包,describe/option/setup/play/pause/teardown 等返回消息
|
|->RtspSession::onManager//如果是udp 做超时检测
|
|->RtspPlayer::onConnect //连接服务器结果回调
|
|->RtspPlayer::sendDescribe//连接服务器成功后,发送describe
|
|->RtspPlayer::sendRtspRequest
|
|->RtspPlayer::sendRtspRequest//重载,支持md5 和 base64认证,这里不细走读了
|
|->RtspPlayer::handleResDESCRIBE //发送describe后处理函数,这里都是在RtspPlayer::onRecv中处理,调用关系不是如这个所示
|
|->sendDescribe //如果涉及鉴权,那对端回复401,客户端再回复describe
|
|->onCheckSDP //这里后续再补充详细流程
|
|->RtspPlayer::sendSetup //发送setup
|
|->sendRtspRequest //tcp/udp/multicast/ 这三种setup中带的不一样
|
|->RtspPlayer::handleResSETUP //发送setup后处理函数
|
|->RtspPlayer::pause //发送play
|
|->RtspPlayer::handleResPAUSE //收到200ok,设置play状态
|
|->MediaSource::Ptr mediaSource //RtspMediaSource rtsp/rtmp拉流都支持,这里只走读rtsp拉流方式
|
|->MediaSource::setListener

Linux/CentOS安装ZLMediaKit流媒体服务

一、centos linux下安装ffmpeg

1、下载解压

wget http://www.ffmpeg.org/releases/ffmpeg-3.1.tar.gz
tar -zxvf ffmpeg-3.1.tar.gz

2、 进入解压后目录,输入如下命令/usr/local/ffmpeg为自己指定的安装目录

cd ffmpeg-3.1
./configure --prefix=/usr/local/ffmpeg
make && make install

3、配置变量
vi /etc/profile
在最后PATH添加环境变量:
export PATH=$PATH:/usr/local/ffmpeg/bin
保存退出
查看是否生效
source /ect/profile 或者 . /etc/profile 设置生效
4、查看版本
ffmpeg -version 查看版本

注意:

若安装过程中出现以下错误:

yasm/nasm not found or too old. Use –disable-yasm for a crippled build.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file “config.log” produced by configure as this will help
solve the problem.

需要安装 yasm

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install
sudo yum -y install gcc
sudo yum -y install gcc-c++
gcc -v
sudo apt-get install cmake
cmake -version
或者
wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
tar -zxvf cmake-3.7.2.tar.gz
cd cmake-3.7.2/
./bootstrap       //此步可能遇到问题,见下文
gmake             //此步需要很长时间
gmake install
yum install openssl-devel
yum install SDL-devel
#国内用户推荐从同步镜像网站gitee下载 
git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit
cd ZLMediaKit
#千万不要忘记执行这句命令
git submodule update --init
cd ZLMediaKit
mkdir build
cd build
#macOS下可能需要这样指定openss路径:cmake .. -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2j/
cmake ..
make -j4

参考:
https://github.com/xia-chu/ZL...
https://www.cnblogs.com/zt199...
https://blog.csdn.net/jklinux...

以上是关于2019-10-09 zlmediakit主要代码流程整理的主要内容,如果未能解决你的问题,请参考以下文章

流媒体服务器之 ZLMediaKit介绍

centos6编译及安装ZLMediaKit

windows ZLMediaKit

怎么使用zlmediakit的websocket服务器功能

ZLMediaKit视频推流和播放步骤

ZLMediaKit+wvp-GB28181-pro,搭建28181协议视频平台