winlin

fix bug of hls and rename demo player stream to live/demo. change to 0.9.36

@@ -3,6 +3,11 @@ @@ -3,6 +3,11 @@
3 # @see full.conf for detail config. 3 # @see full.conf for detail config.
4 4
5 listen 19350; 5 listen 19350;
  6 +daemon on;
  7 +srs_log_tank file;
  8 +srs_log_file ./objs/demo.19350.log;
  9 +pid ./objs/srs.demo.19350.pid;
  10 +
6 vhost __defaultVhost__ { 11 vhost __defaultVhost__ {
7 enabled on; 12 enabled on;
8 gop_cache on; 13 gop_cache on;
@@ -3,6 +3,11 @@ @@ -3,6 +3,11 @@
3 # @see full.conf for detail config. 3 # @see full.conf for detail config.
4 4
5 listen 1935; 5 listen 1935;
  6 +daemon on;
  7 +srs_log_tank file;
  8 +srs_log_file ./objs/demo.log;
  9 +pid ./objs/srs.demo.pid;
  10 +
6 chunk_size 60000; 11 chunk_size 60000;
7 max_connections 2000; 12 max_connections 2000;
8 13
@@ -55,7 +55,7 @@ function build_default_rtmp_url() { @@ -55,7 +55,7 @@ function build_default_rtmp_url() {
55 var port = (query.port == undefined)? 1935:query.port; 55 var port = (query.port == undefined)? 1935:query.port;
56 var vhost = (query.vhost == undefined)? window.location.hostname:query.vhost; 56 var vhost = (query.vhost == undefined)? window.location.hostname:query.vhost;
57 var app = (query.app == undefined)? "live":query.app; 57 var app = (query.app == undefined)? "live":query.app;
58 - var stream = (query.stream == undefined)? "livestream":query.stream; 58 + var stream = (query.stream == undefined)? "demo":query.stream;
59 59
60 if (server == vhost || vhost == "") { 60 if (server == vhost || vhost == "") {
61 return "rtmp://" + server + ":" + port + "/" + app + "/" + stream; 61 return "rtmp://" + server + ":" + port + "/" + app + "/" + stream;
@@ -71,7 +71,7 @@ function build_default_publish_rtmp_url() { @@ -71,7 +71,7 @@ function build_default_publish_rtmp_url() {
71 var port = (query.port == undefined)? 1935:query.port; 71 var port = (query.port == undefined)? 1935:query.port;
72 var vhost = (query.vhost == undefined)? window.location.hostname:query.vhost; 72 var vhost = (query.vhost == undefined)? window.location.hostname:query.vhost;
73 var app = (query.app == undefined)? "live":query.app; 73 var app = (query.app == undefined)? "live":query.app;
74 - var stream = (query.stream == undefined)? "livestream":query.stream; 74 + var stream = (query.stream == undefined)? "demo":query.stream;
75 75
76 if (server == vhost || vhost == "") { 76 if (server == vhost || vhost == "") {
77 return "rtmp://" + server + ":" + port + "/" + app + "/" + stream; 77 return "rtmp://" + server + ":" + port + "/" + app + "/" + stream;
@@ -114,7 +114,7 @@ function build_default_hls_url() { @@ -114,7 +114,7 @@ function build_default_hls_url() {
114 114
115 var port = (query.hls_port == undefined)? window.location.port:query.hls_port; 115 var port = (query.hls_port == undefined)? window.location.port:query.hls_port;
116 var app = (query.app == undefined)? "live":query.app; 116 var app = (query.app == undefined)? "live":query.app;
117 - var stream = (query.stream == undefined)? "livestream":query.stream; 117 + var stream = (query.stream == undefined)? "demo":query.stream;
118 118
119 if (port == "" || port == null || port == undefined) { 119 if (port == "" || port == null || port == undefined) {
120 port = 80; 120 port = 80;
@@ -2,6 +2,6 @@ @@ -2,6 +2,6 @@
2 for((;;)); do \ 2 for((;;)); do \
3 ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \ 3 ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
4 -vcodec copy -acodec copy \ 4 -vcodec copy -acodec copy \
5 - -f flv -y rtmp://127.0.0.1/live?vhost=players/livestream; \ 5 + -f flv -y rtmp://127.0.0.1/live?vhost=players/demo; \
6 sleep 1; \ 6 sleep 1; \
7 done 7 done
@@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
2 src_dir='src' 2 src_dir='src'
3 if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi 3 if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi
4 4
5 -cmd="nohup ./objs/srs -c conf/demo.19350.conf > ./objs/demo.19350.log 2>&1 &" 5 +cmd="./objs/srs -c conf/demo.19350.conf"
6 echo "启动SRS转发服务器:$cmd" 6 echo "启动SRS转发服务器:$cmd"
7 pids=`ps aux|grep srs|grep "./objs"|grep "demo.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done 7 pids=`ps aux|grep srs|grep "./objs"|grep "demo.19350.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
8 -nohup ./objs/srs -c conf/demo.19350.conf > ./objs/demo.19350.log 2>&1 & 8 +./objs/srs -c conf/demo.19350.conf
9 ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi 9 ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi
10 10
11 echo "启动SRS转发服务器成功" 11 echo "启动SRS转发服务器成功"
@@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
2 src_dir='src' 2 src_dir='src'
3 if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi 3 if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi
4 4
5 -cmd="nohup ./objs/srs -c conf/demo.conf >./objs/demo.log 2>&1 &" 5 +cmd="./objs/srs -c conf/demo.conf"
6 echo "启动SRS服务器:$cmd" 6 echo "启动SRS服务器:$cmd"
7 pids=`ps aux|grep srs|grep "./objs"|grep "demo.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done 7 pids=`ps aux|grep srs|grep "./objs"|grep "demo.conf"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done
8 -nohup ./objs/srs -c conf/demo.conf >./objs/demo.log 2>&1 & 8 +./objs/srs -c conf/demo.conf
9 ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi 9 ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi
10 10
11 echo "启动SRS服务器成功" 11 echo "启动SRS服务器成功"
@@ -693,15 +693,17 @@ int SrsHlsMuxer::segment_close(string log_desc) @@ -693,15 +693,17 @@ int SrsHlsMuxer::segment_close(string log_desc)
693 693
694 // close the muxer of finished segment. 694 // close the muxer of finished segment.
695 srs_freep(current->muxer); 695 srs_freep(current->muxer);
  696 + std::string full_path = current->full_path;
  697 + current = NULL;
  698 +
696 // rename from tmp to real path 699 // rename from tmp to real path
697 - std::string tmp_file = current->full_path + ".tmp";  
698 - if (rename(tmp_file.c_str(), current->full_path.c_str()) < 0) { 700 + std::string tmp_file = full_path + ".tmp";
  701 + if (rename(tmp_file.c_str(), full_path.c_str()) < 0) {
699 ret = ERROR_HLS_WRITE_FAILED; 702 ret = ERROR_HLS_WRITE_FAILED;
700 srs_error("rename ts file failed, %s => %s. ret=%d", 703 srs_error("rename ts file failed, %s => %s. ret=%d",
701 - tmp_file.c_str(), current->full_path.c_str(), ret); 704 + tmp_file.c_str(), full_path.c_str(), ret);
702 return ret; 705 return ret;
703 } 706 }
704 - current = NULL;  
705 } else { 707 } else {
706 // reuse current segment index. 708 // reuse current segment index.
707 file_index--; 709 file_index--;
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "35" 34 +#define VERSION_REVISION "36"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "srs" 37 #define RTMP_SIG_SRS_KEY "srs"