winlin

add nginx and used as http server

@@ -21,7 +21,7 @@ step 2: start srs <br/> @@ -21,7 +21,7 @@ step 2: start srs <br/>
21 </pre> 21 </pre>
22 step 3(optional): start nginx for HLS <br/> 22 step 3(optional): start nginx for HLS <br/>
23 <pre> 23 <pre>
24 -sudo ./objs/nginx/_release/sbin/nginx 24 +sudo ./objs/nginx/sbin/nginx
25 </pre> 25 </pre>
26 step 4: publish live stream <br/> 26 step 4: publish live stream <br/>
27 <pre> 27 <pre>
不能预览此文件类型
@@ -12,7 +12,7 @@ vhost __defaultVhost__ { @@ -12,7 +12,7 @@ vhost __defaultVhost__ {
12 enabled on; 12 enabled on;
13 gop_cache on; 13 gop_cache on;
14 hls on; 14 hls on;
15 - hls_path ./hls; 15 + hls_path ./objs/nginx/html;
16 } 16 }
17 # the vhost disabled. 17 # the vhost disabled.
18 vhost removed.vhost.com { 18 vhost removed.vhost.com {
@@ -28,8 +28,17 @@ vhost no-hls.vhost.com { @@ -28,8 +28,17 @@ vhost no-hls.vhost.com {
28 # default: on 28 # default: on
29 hls on; 29 hls on;
30 # the hls output path. 30 # the hls output path.
31 - # default: ./hls  
32 - hls_path /data/nginx/html/hls; 31 + # the app dir is auto created under the hls_path.
  32 + # for example, for rtmp stream:
  33 + # rtmp://127.0.0.1/live/livestream
  34 + # http://127.0.0.1/live/livestream.m3u8
  35 + # where hls_path is /hls, srs will create the following files:
  36 + # /hls/live the app dir for all streams.
  37 + # /hls/live/livestream.m3u8 the HLS m3u8 file.
  38 + # /hls/live/livestream-1.ts the HLS media/ts file.
  39 + # in a word, the hls_path is for vhost.
  40 + # default: ./objs/nginx/html
  41 + hls_path /data/nginx/html;
33 } 42 }
34 # the vhost with hls disabled. 43 # the vhost with hls disabled.
35 vhost no-hls.vhost.com { 44 vhost no-hls.vhost.com {
@@ -46,6 +46,28 @@ ret=$?; if [[ $ret -ne 0 ]]; then echo "build http-parser-2.1 failed, ret=$ret"; @@ -46,6 +46,28 @@ ret=$?; if [[ $ret -ne 0 ]]; then echo "build http-parser-2.1 failed, ret=$ret";
46 if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/http_parser.h ]]; then echo "build http-parser-2.1 failed"; exit -1; fi 46 if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/http_parser.h ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
47 if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi 47 if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
48 48
  49 +# nginx for HLS, nginx-1.5.0
  50 +if [[ -f ${GLOBAL_DIR_OBJS}/nginx-1.5.0/_release/sbin/nginx ]]; then
  51 + echo "nginx-1.5.0 is ok.";
  52 +else
  53 + echo "build nginx-1.5.0";
  54 + (
  55 + rm -rf ${GLOBAL_DIR_OBJS}/nginx-1.5.0 && cd ${GLOBAL_DIR_OBJS} &&
  56 + unzip -q ../3rdparty/nginx-1.5.0.zip && cd nginx-1.5.0 &&
  57 + ./configure --prefix=`pwd`/_release && make && make install &&
  58 + ln -sf `pwd`/_release ../nginx
  59 + )
  60 +fi
  61 +# check status
  62 +ret=$?; if [[ $ret -ne 0 ]]; then echo "build nginx-1.5.0 failed, ret=$ret"; exit $ret; fi
  63 +if [ ! -f ${GLOBAL_DIR_OBJS}/nginx-1.5.0/_release/sbin/nginx ]; then echo "build nginx-1.5.0 failed."; exit -1; fi
  64 +
  65 +# use current user to config nginx,
  66 +# srs will write ts/m3u8 file use current user,
  67 +# nginx default use nobody, so cannot read the ts/m3u8 created by srs.
  68 +cp ${GLOBAL_DIR_OBJS}/nginx/conf/nginx.conf ${GLOBAL_DIR_OBJS}/nginx/conf/nginx.conf.bk
  69 +sed -i "s/^.user nobody;/user `whoami`;/g" ${GLOBAL_DIR_OBJS}/nginx/conf/nginx.conf
  70 +
49 ##################################################################################### 71 #####################################################################################
50 # generate Makefile. 72 # generate Makefile.
51 ##################################################################################### 73 #####################################################################################
@@ -141,3 +163,5 @@ echo 'configure ok! ' @@ -141,3 +163,5 @@ echo 'configure ok! '
141 echo "you can:" 163 echo "you can:"
142 echo "\" make \" to build the srs(simple rtmp server)." 164 echo "\" make \" to build the srs(simple rtmp server)."
143 echo "\" make help \" to get the usage of make" 165 echo "\" make help \" to get the usage of make"
  166 +echo "\" sudo ./objs/nginx/sbin/nginx \" to start the nginx http server for hls"
  167 +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. @@ -63,7 +63,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63 (void)0 63 (void)0
64 64
65 // current release version 65 // current release version
66 -#define RTMP_SIG_SRS_VERSION "0.4.0" 66 +#define RTMP_SIG_SRS_VERSION "0.5.0"
67 // server info. 67 // server info.
68 #define RTMP_SIG_SRS_KEY "srs" 68 #define RTMP_SIG_SRS_KEY "srs"
69 #define RTMP_SIG_SRS_ROLE "origin server" 69 #define RTMP_SIG_SRS_ROLE "origin server"
@@ -37,7 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -37,7 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 // default vhost for rtmp 37 // default vhost for rtmp
38 #define RTMP_VHOST_DEFAULT "__defaultVhost__" 38 #define RTMP_VHOST_DEFAULT "__defaultVhost__"
39 39
40 -#define SRS_CONF_DEFAULT_HLS_PATH "./hls" 40 +#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
41 41
42 class SrsFileBuffer 42 class SrsFileBuffer
43 { 43 {