winlin

add nginx and used as http server

... ... @@ -21,7 +21,7 @@ step 2: start srs <br/>
</pre>
step 3(optional): start nginx for HLS <br/>
<pre>
sudo ./objs/nginx/_release/sbin/nginx
sudo ./objs/nginx/sbin/nginx
</pre>
step 4: publish live stream <br/>
<pre>
... ...
不能预览此文件类型
... ... @@ -12,7 +12,7 @@ vhost __defaultVhost__ {
enabled on;
gop_cache on;
hls on;
hls_path ./hls;
hls_path ./objs/nginx/html;
}
# the vhost disabled.
vhost removed.vhost.com {
... ... @@ -28,8 +28,17 @@ vhost no-hls.vhost.com {
# default: on
hls on;
# the hls output path.
# default: ./hls
hls_path /data/nginx/html/hls;
# the app dir is auto created under the hls_path.
# for example, for rtmp stream:
# rtmp://127.0.0.1/live/livestream
# http://127.0.0.1/live/livestream.m3u8
# where hls_path is /hls, srs will create the following files:
# /hls/live the app dir for all streams.
# /hls/live/livestream.m3u8 the HLS m3u8 file.
# /hls/live/livestream-1.ts the HLS media/ts file.
# in a word, the hls_path is for vhost.
# default: ./objs/nginx/html
hls_path /data/nginx/html;
}
# the vhost with hls disabled.
vhost no-hls.vhost.com {
... ...
... ... @@ -46,6 +46,28 @@ ret=$?; if [[ $ret -ne 0 ]]; then echo "build http-parser-2.1 failed, ret=$ret";
if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/http_parser.h ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
# nginx for HLS, nginx-1.5.0
if [[ -f ${GLOBAL_DIR_OBJS}/nginx-1.5.0/_release/sbin/nginx ]]; then
echo "nginx-1.5.0 is ok.";
else
echo "build nginx-1.5.0";
(
rm -rf ${GLOBAL_DIR_OBJS}/nginx-1.5.0 && cd ${GLOBAL_DIR_OBJS} &&
unzip -q ../3rdparty/nginx-1.5.0.zip && cd nginx-1.5.0 &&
./configure --prefix=`pwd`/_release && make && make install &&
ln -sf `pwd`/_release ../nginx
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build nginx-1.5.0 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${GLOBAL_DIR_OBJS}/nginx-1.5.0/_release/sbin/nginx ]; then echo "build nginx-1.5.0 failed."; exit -1; fi
# use current user to config nginx,
# srs will write ts/m3u8 file use current user,
# nginx default use nobody, so cannot read the ts/m3u8 created by srs.
cp ${GLOBAL_DIR_OBJS}/nginx/conf/nginx.conf ${GLOBAL_DIR_OBJS}/nginx/conf/nginx.conf.bk
sed -i "s/^.user nobody;/user `whoami`;/g" ${GLOBAL_DIR_OBJS}/nginx/conf/nginx.conf
#####################################################################################
# generate Makefile.
#####################################################################################
... ... @@ -141,3 +163,5 @@ echo 'configure ok! '
echo "you can:"
echo "\" make \" to build the srs(simple rtmp server)."
echo "\" make help \" to get the usage of make"
echo "\" sudo ./objs/nginx/sbin/nginx \" to start the nginx http server for hls"
echo "\" ./objs/simple_rtmp_server -c conf/srs.conf \" to start the srs live server"
... ...
... ... @@ -63,7 +63,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(void)0
// current release version
#define RTMP_SIG_SRS_VERSION "0.4.0"
#define RTMP_SIG_SRS_VERSION "0.5.0"
// server info.
#define RTMP_SIG_SRS_KEY "srs"
#define RTMP_SIG_SRS_ROLE "origin server"
... ...
... ... @@ -37,7 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// default vhost for rtmp
#define RTMP_VHOST_DEFAULT "__defaultVhost__"
#define SRS_CONF_DEFAULT_HLS_PATH "./hls"
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
class SrsFileBuffer
{
... ...