正在显示
4 个修改的文件
包含
178 行增加
和
8 行删除
| @@ -59,22 +59,28 @@ step 8: play live stream. <br/> | @@ -59,22 +59,28 @@ step 8: play live stream. <br/> | ||
| 59 | <pre> | 59 | <pre> |
| 60 | rtmp url: rtmp://demo:1935/live/livestream | 60 | rtmp url: rtmp://demo:1935/live/livestream |
| 61 | m3u8 url: http://demo:80/live/livestream.m3u8 | 61 | m3u8 url: http://demo:80/live/livestream.m3u8 |
| 62 | +for android: http://demo:80/live/livestream.html | ||
| 62 | </pre> | 63 | </pre> |
| 63 | step 9: play live stream auto transcoded<br/> | 64 | step 9: play live stream auto transcoded<br/> |
| 64 | <pre> | 65 | <pre> |
| 65 | rtmp url: rtmp://demo:1935/live/livestream_ld | 66 | rtmp url: rtmp://demo:1935/live/livestream_ld |
| 66 | m3u8 url: http://demo:80/live/livestream_ld.m3u8 | 67 | m3u8 url: http://demo:80/live/livestream_ld.m3u8 |
| 68 | +for android: http://demo:80/live/livestream_ld.html | ||
| 67 | rtmp url: rtmp://demo:1935/live/livestream_sd | 69 | rtmp url: rtmp://demo:1935/live/livestream_sd |
| 68 | m3u8 url: http://demo:80/live/livestream_sd.m3u8 | 70 | m3u8 url: http://demo:80/live/livestream_sd.m3u8 |
| 71 | +for android: http://demo:80/live/livestream_sd.html | ||
| 69 | </pre> | 72 | </pre> |
| 70 | step 10: play live stream auto forwarded, the hls dir change to /forward<br/> | 73 | step 10: play live stream auto forwarded, the hls dir change to /forward<br/> |
| 71 | <pre> | 74 | <pre> |
| 72 | rtmp url: rtmp://demo:19350/live/livestream | 75 | rtmp url: rtmp://demo:19350/live/livestream |
| 73 | m3u8 url: http://demo:80/forward/live/livestream.m3u8 | 76 | m3u8 url: http://demo:80/forward/live/livestream.m3u8 |
| 77 | +for android: http://demo:80/forward/live/livestream.html | ||
| 74 | rtmp url: rtmp://demo:19350/live/livestream_ld | 78 | rtmp url: rtmp://demo:19350/live/livestream_ld |
| 75 | m3u8 url: http://demo:80/forward/live/livestream_ld.m3u8 | 79 | m3u8 url: http://demo:80/forward/live/livestream_ld.m3u8 |
| 80 | +for android: http://demo:80/forward/live/livestream_ld.html | ||
| 76 | rtmp url: rtmp://demo:19350/live/livestream_sd | 81 | rtmp url: rtmp://demo:19350/live/livestream_sd |
| 77 | m3u8 url: http://demo:80/forward/live/livestream_sd.m3u8 | 82 | m3u8 url: http://demo:80/forward/live/livestream_sd.m3u8 |
| 83 | +for android: http://demo:80/forward/live/livestream_sd.html | ||
| 78 | </pre> | 84 | </pre> |
| 79 | 85 | ||
| 80 | ### Architecture | 86 | ### Architecture |
| @@ -3,6 +3,150 @@ | @@ -3,6 +3,150 @@ | ||
| 3 | # TODO: check gcc/g++ | 3 | # TODO: check gcc/g++ |
| 4 | echo "check gcc/g++/gdb/make/openssl-devel" | 4 | echo "check gcc/g++/gdb/make/openssl-devel" |
| 5 | echo "depends tools are ok" | 5 | echo "depends tools are ok" |
| 6 | +##################################################################################### | ||
| 7 | +# for Ubuntu | ||
| 8 | +##################################################################################### | ||
| 9 | +function Ubuntu_prepare() | ||
| 10 | +{ | ||
| 11 | + uname -v|grep Ubuntu >/dev/null 2>&1 | ||
| 12 | + ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 13 | + return; | ||
| 14 | + fi | ||
| 15 | + | ||
| 16 | + echo "Ubuntu detected, install tools if needed" | ||
| 17 | + | ||
| 18 | + apt-cache show libpcre3; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 19 | + echo "install libpcre3" | ||
| 20 | + require_sudoer "sudo apt-get install -y libpcre3" | ||
| 21 | + sudo apt-get install -y libpcre3 | ||
| 22 | + echo "install libpcre3 success" | ||
| 23 | + fi | ||
| 24 | + | ||
| 25 | + apt-cache show libpcre3-dev; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 26 | + echo "install libpcre3-dev" | ||
| 27 | + require_sudoer "sudo apt-get install -y libpcre3-dev" | ||
| 28 | + sudo apt-get install -y libpcre3-dev | ||
| 29 | + echo "install libpcre3-dev success" | ||
| 30 | + fi | ||
| 31 | + | ||
| 32 | + apt-cache show zlib1g-dev; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 33 | + echo "install zlib1g-dev" | ||
| 34 | + require_sudoer "sudo apt-get install -y zlib1g-dev" | ||
| 35 | + sudo apt-get install -y zlib1g-dev | ||
| 36 | + echo "install zlib1g-dev success" | ||
| 37 | + fi | ||
| 38 | + | ||
| 39 | + apt-cache show libfreetype6-dev; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 40 | + echo "install libfreetype6-dev" | ||
| 41 | + require_sudoer "sudo apt-get install -y libfreetype6-dev" | ||
| 42 | + sudo apt-get install -y libfreetype6-dev | ||
| 43 | + echo "install libfreetype6-dev success" | ||
| 44 | + fi | ||
| 45 | + | ||
| 46 | + apt-cache show gcc; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 47 | + echo "install gcc" | ||
| 48 | + require_sudoer "sudo apt-get install -y gcc" | ||
| 49 | + sudo apt-get install -y gcc | ||
| 50 | + echo "install gcc success" | ||
| 51 | + fi | ||
| 52 | + | ||
| 53 | + apt-cache show g++; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 54 | + echo "install g++" | ||
| 55 | + require_sudoer "sudo apt-get install -y g++" | ||
| 56 | + sudo apt-get install -y g++ | ||
| 57 | + echo "install g++ success" | ||
| 58 | + fi | ||
| 59 | + | ||
| 60 | + apt-cache show make; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 61 | + echo "install make" | ||
| 62 | + require_sudoer "sudo apt-get install -y make" | ||
| 63 | + sudo apt-get install -y make | ||
| 64 | + echo "install make success" | ||
| 65 | + fi | ||
| 66 | + | ||
| 67 | + apt-cache show autoconf; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 68 | + echo "install autoconf" | ||
| 69 | + require_sudoer "sudo apt-get install -y autoconf" | ||
| 70 | + sudo apt-get install -y autoconf | ||
| 71 | + echo "install autoconf success" | ||
| 72 | + fi | ||
| 73 | + | ||
| 74 | + apt-cache show libtool; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 75 | + echo "install libtool" | ||
| 76 | + require_sudoer "sudo apt-get install -y libtool" | ||
| 77 | + sudo apt-get install -y libtool | ||
| 78 | + echo "install libtool success" | ||
| 79 | + fi | ||
| 80 | + | ||
| 81 | + apt-cache show libssl-dev; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 82 | + echo "install libssl-dev" | ||
| 83 | + require_sudoer "sudo apt-get install -y libssl-dev" | ||
| 84 | + sudo apt-get install -y libssl-dev | ||
| 85 | + echo "install libssl-dev success" | ||
| 86 | + fi | ||
| 87 | +} | ||
| 88 | +Ubuntu_prepare | ||
| 89 | +##################################################################################### | ||
| 90 | +# for Centos | ||
| 91 | +##################################################################################### | ||
| 92 | +function Centos_prepare() | ||
| 93 | +{ | ||
| 94 | + if [[ ! -f /etc/redhat-release ]]; then | ||
| 95 | + return; | ||
| 96 | + fi | ||
| 97 | + | ||
| 98 | + echo "Centos detected, install tools if needed" | ||
| 99 | + | ||
| 100 | + gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 101 | + echo "install gcc" | ||
| 102 | + require_sudoer "sudo yum install -y gcc" | ||
| 103 | + sudo yum install -y gcc | ||
| 104 | + echo "install gcc success" | ||
| 105 | + fi | ||
| 106 | + | ||
| 107 | + g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 108 | + echo "install gcc-c++" | ||
| 109 | + require_sudoer "sudo yum install -y gcc-c++" | ||
| 110 | + sudo yum install -y gcc-c++ | ||
| 111 | + echo "install gcc-c++ success" | ||
| 112 | + fi | ||
| 113 | + | ||
| 114 | + make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 115 | + echo "install make" | ||
| 116 | + require_sudoer "sudo yum install -y make" | ||
| 117 | + sudo yum install -y make | ||
| 118 | + echo "install make success" | ||
| 119 | + fi | ||
| 120 | + | ||
| 121 | + automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 122 | + echo "install automake" | ||
| 123 | + require_sudoer "sudo yum install -y automake" | ||
| 124 | + sudo yum install -y automake | ||
| 125 | + echo "install automake success" | ||
| 126 | + fi | ||
| 127 | + | ||
| 128 | + autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 129 | + echo "install autoconf" | ||
| 130 | + require_sudoer "sudo yum install -y autoconf" | ||
| 131 | + sudo yum install -y autoconf | ||
| 132 | + echo "install autoconf success" | ||
| 133 | + fi | ||
| 134 | + | ||
| 135 | + libtool --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 136 | + echo "install libtool" | ||
| 137 | + require_sudoer "sudo yum install -y libtool" | ||
| 138 | + sudo yum install -y libtool | ||
| 139 | + echo "install libtool success" | ||
| 140 | + fi | ||
| 141 | + | ||
| 142 | + if [[ ! -d /usr/include/openssl ]]; then | ||
| 143 | + echo "install openssl-devel" | ||
| 144 | + require_sudoer "sudo yum install -y openssl-devel" | ||
| 145 | + sudo yum install -y openssl-devel | ||
| 146 | + echo "install openssl-devels success" | ||
| 147 | + fi | ||
| 148 | +} | ||
| 149 | +Centos_prepare | ||
| 6 | 150 | ||
| 7 | ##################################################################################### | 151 | ##################################################################################### |
| 8 | # st-1.9 | 152 | # st-1.9 |
| @@ -48,6 +192,16 @@ fi | @@ -48,6 +192,16 @@ fi | ||
| 48 | ##################################################################################### | 192 | ##################################################################################### |
| 49 | # nginx for HLS, nginx-1.5.0 | 193 | # nginx for HLS, nginx-1.5.0 |
| 50 | ##################################################################################### | 194 | ##################################################################################### |
| 195 | +function write_nginx_html5() | ||
| 196 | +{ | ||
| 197 | + cat<<END >> ${html_file} | ||
| 198 | +<video width="640" height="360" | ||
| 199 | + autoplay controls autobuffer | ||
| 200 | + src="${hls_stream}" | ||
| 201 | + type="application/vnd.apple.mpegurl"> | ||
| 202 | +</video> | ||
| 203 | +END | ||
| 204 | +} | ||
| 51 | if [ $SRS_HLS = YES ]; then | 205 | if [ $SRS_HLS = YES ]; then |
| 52 | if [[ -f ${SRS_OBJS}/nginx/sbin/nginx ]]; then | 206 | if [[ -f ${SRS_OBJS}/nginx/sbin/nginx ]]; then |
| 53 | echo "nginx-1.5.7 is ok."; | 207 | echo "nginx-1.5.7 is ok."; |
| @@ -72,6 +226,14 @@ if [ $SRS_HLS = YES ]; then | @@ -72,6 +226,14 @@ if [ $SRS_HLS = YES ]; then | ||
| 72 | 226 | ||
| 73 | # create forward dir | 227 | # create forward dir |
| 74 | mkdir -p ${SRS_OBJS}/nginx/html/forward | 228 | mkdir -p ${SRS_OBJS}/nginx/html/forward |
| 229 | + | ||
| 230 | + # generate default html pages for android. | ||
| 231 | + html_file=${SRS_OBJS}/nginx/html/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5 | ||
| 232 | + html_file=${SRS_OBJS}/nginx/html/live/livestream_ld.html && hls_stream=livestream_ld.m3u8 && write_nginx_html5 | ||
| 233 | + html_file=${SRS_OBJS}/nginx/html/live/livestream_sd.html && hls_stream=livestream_sd.m3u8 && write_nginx_html5 | ||
| 234 | + html_file=${SRS_OBJS}/nginx/html/forward/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5 | ||
| 235 | + html_file=${SRS_OBJS}/nginx/html/forward/live/livestream_ld.html && hls_stream=livestream_ld.m3u8 && write_nginx_html5 | ||
| 236 | + html_file=${SRS_OBJS}/nginx/html/forward/live/livestream_sd.html && hls_stream=livestream_sd.m3u8 && write_nginx_html5 | ||
| 75 | fi | 237 | fi |
| 76 | 238 | ||
| 77 | if [ $SRS_HLS = YES ]; then | 239 | if [ $SRS_HLS = YES ]; then |
| @@ -87,6 +249,7 @@ if [ $SRS_HTTP = YES ]; then | @@ -87,6 +249,7 @@ if [ $SRS_HTTP = YES ]; then | ||
| 87 | if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then | 249 | if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then |
| 88 | echo "CherryPy-3.2.4 is ok."; | 250 | echo "CherryPy-3.2.4 is ok."; |
| 89 | else | 251 | else |
| 252 | + require_sudoer "configure --with-http" | ||
| 90 | echo "install CherryPy-3.2.4"; | 253 | echo "install CherryPy-3.2.4"; |
| 91 | ( | 254 | ( |
| 92 | sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} && | 255 | sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} && |
| @@ -85,9 +85,9 @@ vhost dev { | @@ -85,9 +85,9 @@ vhost dev { | ||
| 85 | hls_path ./objs/nginx/html; | 85 | hls_path ./objs/nginx/html; |
| 86 | hls_fragment 5; | 86 | hls_fragment 5; |
| 87 | hls_window 30; | 87 | hls_window 30; |
| 88 | - forward 127.0.0.1:19350; | 88 | + #forward 127.0.0.1:19350; |
| 89 | http_hooks { | 89 | http_hooks { |
| 90 | - enabled on; | 90 | + enabled off; |
| 91 | on_connect http://127.0.0.1:8085/api/v1/clients; | 91 | on_connect http://127.0.0.1:8085/api/v1/clients; |
| 92 | on_close http://127.0.0.1:8085/api/v1/clients; | 92 | on_close http://127.0.0.1:8085/api/v1/clients; |
| 93 | on_publish http://127.0.0.1:8085/api/v1/streams; | 93 | on_publish http://127.0.0.1:8085/api/v1/streams; |
| @@ -96,7 +96,7 @@ vhost dev { | @@ -96,7 +96,7 @@ vhost dev { | ||
| 96 | on_stop http://127.0.0.1:8085/api/v1/sessions; | 96 | on_stop http://127.0.0.1:8085/api/v1/sessions; |
| 97 | } | 97 | } |
| 98 | transcode { | 98 | transcode { |
| 99 | - enabled on; | 99 | + enabled off; |
| 100 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 100 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 101 | engine dev { | 101 | engine dev { |
| 102 | enabled on; | 102 | enabled on; |
| @@ -15,14 +15,15 @@ BLACK="\\e[0m" | @@ -15,14 +15,15 @@ BLACK="\\e[0m" | ||
| 15 | # parse user options. | 15 | # parse user options. |
| 16 | . auto/options.sh | 16 | . auto/options.sh |
| 17 | 17 | ||
| 18 | -# if specifies http, requires sudo to install the CherryPy. | ||
| 19 | -if [ $SRS_HTTP = YES ]; then | 18 | +function require_sudoer() |
| 19 | +{ | ||
| 20 | sudo echo "" >/dev/null 2>&1 | 20 | sudo echo "" >/dev/null 2>&1 |
| 21 | - ret=$?; if [[ 0 -ne $ret ]]; then echo | ||
| 22 | - "--with-http requires sudoer, ret=$ret"; | 21 | + |
| 22 | + ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 23 | + echo "\"$1\" require sudoer failed. ret=$ret"; | ||
| 23 | exit $ret; | 24 | exit $ret; |
| 24 | fi | 25 | fi |
| 25 | -fi | 26 | +} |
| 26 | 27 | ||
| 27 | # clean the exists | 28 | # clean the exists |
| 28 | if [[ -f Makefile ]]; then | 29 | if [[ -f Makefile ]]; then |
-
请 注册 或 登录 后发表评论