关于crtmpserver编译运行及源码修改

1、x86 linux版本编译

X86平台有两种编译方式:使用cmake、直接使用make

一、使用cmake

Cd crtmpserver/built/cmake

Cmake .

Make

./crtmpserver ./crtmpserver.lua

 

注意:crtmpserver.luamediaFolder是用来保存服务器端flv文件的,默认的目录是mediaFolder="/Volumes/android/backup/media/"是针对android平台的,需要播放服务器端的flv文件时可以修改此目录。

使用静态编译时需要在CMakeList.txt文件的开始处加上下面一个设置SET(ENV{COMPILE_STATIC} "1")

 

二、使用make

Cd crtmpserver/built/make

Make -f linux.mk -f compile.mk

Cp crtmpserver/built/cmake/applications crtmpserver/built/make/output/static

Cd crtmpserver/built/make/output/static

./crtmpserver ./crtmpserver.lua

 

注意:crtmpserver.luamediaFolder是用来保存服务器端flv文件的,默认的目录是mediaFolder="/Volumes/android/backup/media/"是针对android平台的,需要播放服务器端的flv文件时可以修改此目录。同时crtmpserver运行时需要依赖applications目录的一些配置文件,否则初始化不成功,进程会自动退出。

 

2、arm版本编译(直接使用make方法编译)

Cd crtmpserver/built/make

Make -f linux-hisi-uclinux.mk -f compile.mk

Cp  crtmpserver/built/cmake/applications crtmpserver/built/make/output/static

Cd crtmpserver/built/make/output/static

./crtmpserver ./crtmpserver.lua

 

注意: crtmpserver.luamediaFolder是用来保存服务器端flv文件的,默认的目录是mediaFolder="/Volumes/android/backup/media/"是针对android平台的,需要播放服务器端的flv文件时可以修改此目录。同时crtmpserver运行时需要依赖applications目录的一些配置文件,否则初始化不成功,进程会自动退出。   

arm平台需要对源码做出修改方可使用:    

一、在arm平台运行时需要读取/etc/hosts文件,要是没有此文件,可以修改源码crtmpserver/sources/common/src/utils/misc/uri.cpp    323行处将if (ip == "") {......}括号中的内容改为                         ip = "127.0.0.1";

325 #if 0

326  FATAL("Unable to resolve host: %s", STR(uri.host()));

327  uri.Reset();

328  return false;

329 #endif 

二、运行crtmpserver目录下的tests测试程序时,会发现在x86版本可以正常执行,而arm版本则会报错,且执行crtmpserver时无论是推送流还拉取流播放时都不会成功,总会超时自动断开。此时就需要根据tests的报错对源码进行修改。修改的地方有三个:EHTONDENTOHDPhhd。在源码中搜索此三个关键字,修改处位于三个文件中variant.cppamf0serializer.cpp、 amf3serializer.cpp,相应修改如下:

EHTOND:在调用了EHTOND此的后面添加相应处理

    uint8_t *pBuffer = (uint8_t *) & val;

    uint64_t ui64_tmp = val;

    uint8_t *pBuffer_tmp = (uint8_t *) & ui64_tmp;

    pBuffer[0] = pBuffer_tmp[4];

    pBuffer[1] = pBuffer_tmp[5];

    pBuffer[2] = pBuffer_tmp[6];

    pBuffer[3] = pBuffer_tmp[7];

    pBuffer[4] = pBuffer_tmp[0];

    pBuffer[5] = pBuffer_tmp[1];

    pBuffer[6] = pBuffer_tmp[2];

pBuffer[7] = pBuffer_tmp[3];

 

ENTOHDP:在调用了ENTOHDP此的后面添加相应处理

        double ui64_tmp_1 = temp;

        uint8_t *pBuffer_1 = (uint8_t *) & temp;

        uint8_t *pBuffer_tmp_1 = (uint8_t *) & ui64_tmp_1;

        pBuffer_1[0] = pBuffer_tmp_1[4];

        pBuffer_1[1] = pBuffer_tmp_1[5];

        pBuffer_1[2] = pBuffer_tmp_1[6];

        pBuffer_1[3] = pBuffer_tmp_1[7];

        pBuffer_1[4] = pBuffer_tmp_1[0];

        pBuffer_1[5] = pBuffer_tmp_1[1];

        pBuffer_1[6] = pBuffer_tmp_1[2];

        pBuffer_1[7] = pBuffer_tmp_1[3];

 %hhd:在使用了%hhd处将%hhd修改为%d即可。此修改只出现在文件variant.cpp中,有两处得修改的地方。

 

总结:至于checkBW的警告并不影响服务器的正常使用,可消除可不管。消除的方法如下:将crtmpserver.lua中打开此配置enableCheckBandwidth=true,在源码中找到bool BaseRTMPAppProtocolHandler::ProcessInvoke此函数,在其判断中加入对此字段的解释:

 else if (functionName == "_checkbw") {

return ProcessInvokeCheckBandwidth(pFrom, request); }即可。

crtmpserver的编译需要依赖openssl、crypto、dl这几个库,要是没有的就要提前编译好,否则crtmpserver编译不了。

             


C++ RTMP Server Instructions how to compile and use C++ RTMP Server (a.k.a crtmpserver) Requirements: * GCC and other C++ tools * SVN * libdl, libssl, libcrypto (make sure you have the "devel" packages of libdl, ssl and crypto installed prior to compiling) In order to get the source code, issue the following command: svn co --username anonymous https://svn.rtmpd.com/crtmpserver/trunk crtmpserver When it asks for password, hit Enter key Compile the package. Do the following steps: cd crtmpserver/builders/cmake cmake . (this step will create all the Makefile's that are required. If some package is missing, the cmake will complain) make The compilation procedure should be finished within few minutes. After you compiled the package, it's time to test it. Run the following command: ./crtmpserver/crtmpserver crtmpserver/crtmpserver.lua If everything goes well, you'll get on your console a table with IP's, ports, protocols, and application names If you see this table, then crtmpserver is working. Lets test it the server. Follow these simple steps: * Download a simple FLV or MP4 file. You can dowload a sample file from here: http://www.mediacollege.com/adobe/flash/video/tutorial/example-flv.html * Place the file you downloaded into the crtmpserver/media folder * Download an FLV player. For this example, we'll use JW Player. Get it here: http://www.longtailvideo.com/players/jw-flv-player * Extract the JW Player to a directory which is accessible through your web server * Go to the extracted directory and create an HTML file which will include the player and play the file. Here's an example: <html> <body> <script type='text/javascript' src='swfobject.js'></script> <div id='mediaspace'>This text will be replaced</div> <script type='text/javascript'> var so = new SWFObject('player.swf','mpl','640','360','9'); so.addParam('allowfullscreen','true'); so.addParam('allowscriptaccess','always'); so.addParam('wmode','opaque'); so.addVariable('file','file-download'); so.addVariable('streamer','rtmp://127.0.0.1/flvplayback/'); so.write('mediaspace'); </script> </body> </html> * Change the 127.0.0.1 to either the IP of your crtmpserver or simply use a hostname of your machine * Replace file-download with the actual filename of your sample you download. Remeber to omit the .flv if it's an FLV file * Open a web browser and point it to to the web server IP/Hostname and the directory you installed the player (example: http://127.0.0.1/player) * You should see a player. Click the play button and the video should be played. If you see the video, then everything works well. Installing crtmpserver: * Go to the directory crtmpserver/cmake * Run the following command: cmake -DCRTMPSERVER_INSTALL_PREFIX=<path> (for example /usr/local/crtmpserver) * After previous command done start build project with command: make * After build comlete run command: make install * After install you has installed crtmpserver in <path>(in our case /usr/local/crtmpserver) * Now you can start crtmpserver with command: sudo <path>/sbin/crtmpserver --uid=<UID> <path>/etc/crtmpserver.lua in our case: sudo /usr/local/crtmpserver/sbin/crtmpserver --uid=<UID> /usr/local/crtmpserver/etc/crtmpserver.lua Also look into builders/packing directory. There are several OS specific builders. * in directory "debian" builder for Debian, also can be used for Ubuntu and other distributions based on debian * in directory "freebsd" builder(port) for FreeBSD crtmpserver settings * All crtmpserver settings are located in a detailed file calle: crtmpserver.lua
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值