SRS
,即Simple-RTMP-Server
,是一个开源的视频服务器,出自国人之手。release版本下载地址https://github.com/ossrs/srs/releases,目前的最高版本是v2.0-r2
。
tar xvf v2.0-r2.tar.bz2
cd srs-2.0-r2/trunk
mkdir build
./configure --prefix=/home/longjing/srs/srs-2.0-r2/trunk/build --with-http-api --with-hls --with-http-server --with-ssl --with-stat --with-research --with-dvr --with-http-callback
make
make install
如果出现错误
rm -f LINUX_4.4.0-116-generic_DBG/md-pic.o; ln -s md.o LINUX_4.4.0-116-generic_DBG/md-pic.o
ld -shared -soname=libst.so.1 -lc LINUX_4.4.0-116-generic_DBG/sched-pic.o LINUX_4.4.0-116-generic_DBG/stk-pic.o LINUX_4.4.0-116-generic_DBG/sync-pic.o LINUX_4.4.0-116-generic_DBG/key-pic.o LINUX_4.4.0-116-generic_DBG/io-pic.o LINUX_4.4.0-116-generic_DBG/event-pic.o LINUX_4.4.0-116-generic_DBG/md-pic.o -o LINUX_4.4.0-116-generic_DBG/libst.so.1.9
LINUX_4.4.0-116-generic_DBG/sched-pic.o: In function `st_poll':
/root/srs/trunk/objs/st-1.9/sched.c:108: undefined reference to `__stack_chk_fail_local'
LINUX_4.4.0-116-generic_DBG/sync-pic.o: In function `st_utime':
/root/srs/trunk/objs/st-1.9/sync.c:70: undefined reference to `__stack_chk_fail_local'
LINUX_4.4.0-116-generic_DBG/io-pic.o: In function `_st_io_init':
/root/srs/trunk/objs/st-1.9/io.c:106: undefined reference to `__stack_chk_fail_local'
LINUX_4.4.0-116-generic_DBG/io-pic.o: In function `_st_netfd_new':
/root/srs/trunk/objs/st-1.9/io.c:166: undefined reference to `__stack_chk_fail_local'
LINUX_4.4.0-116-generic_DBG/io-pic.o: In function `st_netfd_poll':
/root/srs/trunk/objs/st-1.9/io.c:241: undefined reference to `__stack_chk_fail_local'
LINUX_4.4.0-116-generic_DBG/io-pic.o:/root/srs/trunk/objs/st-1.9/io.c:438: more undefined references to `__stack_chk_fail_local' follow
Makefile:356: recipe for target 'LINUX_4.4.0-116-generic_DBG/libst.so.1.9' failed
make[1]: *** [LINUX_4.4.0-116-generic_DBG/libst.so.1.9] Error 1
make[1]: Leaving directory '/root/srs/trunk/objs/st-1.9'
Makefile:441: recipe for target 'linux-debug' failed
make: *** [linux-debug] Error 2
build st-1.9 failed, ret=2
修改auto/depends.sh,搜索关键字st-1.9
,找到
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL
并将其修改为
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL -fno-stack-protector"
再重新configure
、make
即可。
listen 2935;
max_connections 1000;
daemon on;
srs_log_tank file;
srs_log_level error;
srs_log_file ./objs/srs.log;
http_server {
enabled on;
listen 8081;
dir ./objs/nginx/html;
}
vhost __defaultVhost__ {
hls {
enabled on;
hls_fragment 10;
hls_window 60;
hls_path ./objs/nginx/html;
hls_m3u8_file [app]/[stream].m3u8;
hls_ts_file [app]/[stream]-[seq].ts;
hls_cleanup on;
hls_dispose 30;
hls_on_error continue;
hls_storage disk;
hls_wait_keyframe on;
hls_acodec aac;
hls_vcodec h264;
}
}
./objs/srs -c conf/http.hls.conf
killall -1 srs
sudo ln -sf /home/xugaoxiang/build/etc/init.d/srs /etc/init.d/srs
修改srs中的ROOT和CONFIG
ROOT="/home/xugaoxiang/build"
CONFIG="./conf/http.hls.conf"
然后在命令行下执行
sudo update-rc.d srs defaults
可以先用
sudo /etc/init.d/srs start/stop/restart/status/reload
测试一下,正确无误后再重启系统。需要注意的是,只有runlevel是2、3、5、6才可以启动。需要的话,可以到/etc/rc*.d/下进行相应的修改。
如果想要删除srs服务,可以执行
sudo update-rc.d -f srs remove
修改源码src/app/srs_app_http_conn.cpp
,大概是292行
hdr->set("Access-Control-Allow-Origin", "*");
hdr->set("Access-Control-Allow-Methods", "GET, POST, HEAD, PUT, DELETE");
hdr->set("Access-Control-Allow-Headers", "Cache-Control,X-Proxy-Authorization,X-Requested-With,Content-Type");
srs-bench
是专门用来测试srs并发的工具,基于state-threads
。
git clone https://github.com/ossrs/srs-bench.git
cd srs-bench
./configure
make