From 9ab579c6e8b90db7678cd53b5f0a5d2d26a58348 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 07:06:16 +0800 Subject: [PATCH 01/12] refine the configure test script. --- README.md | 2 +- trunk/scripts/test_configure.sh | 117 +++++++++++++++++++++++--------- 2 files changed, 85 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index ddc221c2e..e950fbf44 100755 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ cd simple-rtmp-server/trunk * Usage: How to deploy SRS on ARM?([CN][v1_CN_SampleARM], [EN][v1_EN_SampleARM]) * Usage: How to ingest file/stream/device to SRS?([CN][v1_CN_SampleIngest], [EN][v1_EN_SampleIngest]) * Usage: How to use SRS-HTTP-server to delivery HTTP/HLS stream?([CN][v2_CN_SampleHTTP], [EN][v2_EN_SampleHTTP]) -* Usage: How to show the demo of [CN][v1_CN_SampleDemo], [EN][v1_EN_SampleDemo]) +* Usage: How to show the demo of ([CN][v1_CN_SampleDemo], [EN][v1_EN_SampleDemo]) * Usage: How to publish h.264 raw stream to [CN][v2_CN_SrsLibrtmp2], [EN][v2_EN_SrsLibrtmp2]) * Usage: Solution using SRS?([CN][v1_CN_Sample], [EN][v1_EN_Sample]) * Usage: Why SRS?([CN][v1_CN_Product], [EN][v1_EN_Product]) diff --git a/trunk/scripts/test_configure.sh b/trunk/scripts/test_configure.sh index 379759ef0..c28423b16 100755 --- a/trunk/scripts/test_configure.sh +++ b/trunk/scripts/test_configure.sh @@ -19,175 +19,181 @@ ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi item="./configure" ok_msg "test \" ${item} \"" -(./configure && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --x86-x64" ok_msg "test \" ${item} \"" -(./configure --x86-x64 && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all" ok_msg "test \" ${item} \"" -(./configure --disable-all && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast" ok_msg "test \" ${item} \"" -(./configure --fast && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --pure-rtmp" ok_msg "test \" ${item} \"" -(./configure --pure-rtmp && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --rtmp-hls" ok_msg "test \" ${item} \"" -(./configure --rtmp-hls && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ssl" ok_msg "test \" ${item} \"" -(./configure --fast --with-ssl && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-hls" ok_msg "test \" ${item} \"" -(./configure --fast --with-hls && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-dvr" ok_msg "test \" ${item} \"" -(./configure --fast --with-dvr && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-nginx" ok_msg "test \" ${item} \"" -(./configure --fast --with-nginx && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-http-callback" ok_msg "test \" ${item} \"" -(./configure --fast --with-http-callback && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-http-server" ok_msg "test \" ${item} \"" -(./configure --fast --with-http-server && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-http-api" ok_msg "test \" ${item} \"" -(./configure --fast --with-http-api && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ffmpeg" ok_msg "test \" ${item} \"" -(./configure --fast --with-ffmpeg && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-transcode" ok_msg "test \" ${item} \"" -(./configure --fast --with-transcode && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ingest" ok_msg "test \" ${item} \"" -(./configure --fast --with-ingest && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-librtmp" ok_msg "test \" ${item} \"" -(./configure --fast --with-librtmp && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-research" ok_msg "test \" ${item} \"" -(./configure --fast --with-research && make) >>$log 2>&1 +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +item="./configure --fast--with-stream-caster" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-utest" ok_msg "test \" ${item} \"" -(./configure --fast --with-utest && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ssl --with-utest" ok_msg "test \" ${item} \"" -(./configure --fast --with-ssl --with-utest && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf" ok_msg "test \" ${item} \"" -(./configure --fast --with-gperf && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf --with-gmc" ok_msg "test \" ${item} \"" -(./configure --fast --with-gperf --with-gmc && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf --with-gmp" ok_msg "test \" ${item} \"" -(./configure --fast --with-gperf --with-gmp && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf --with-gcp" ok_msg "test \" ${item} \"" -(./configure --fast --with-gperf --with-gcp && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gprof" ok_msg "test \" ${item} \"" -(./configure --fast --with-gprof && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-verbose" ok_msg "test \" ${item} \"" -(./configure --fast --log-verbose && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-info" ok_msg "test \" ${item} \"" -(./configure --fast --log-info && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-trace" ok_msg "test \" ${item} \"" -(./configure --fast --log-trace && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-info --log-verbose --log-trace" ok_msg "test \" ${item} \"" -(./configure --fast --log-info --log-verbose --log-trace && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" @@ -196,25 +202,70 @@ ok_msg "test \" ${item} \" success" ####################################################################################################### item="./configure --dev" ok_msg "test \" ${item} \"" -(./configure --dev && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast-dev" ok_msg "test \" ${item} \"" -(./configure --fast-dev && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --demo" ok_msg "test \" ${item} \"" -(./configure --demo && make) >>$log 2>&1 +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --full" ok_msg "test \" ${item} \"" -(./configure --full && make) >>$log 2>&1 +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +####################################################################################################### +####################################################################################################### +####################################################################################################### +item="./configure --disable-all --with-ssl" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +item="./configure --disable-all --with-hls --with-ssl --with-http-server --with-http-api" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +item="./configure --disable-all --with-ssl --with-hls --with-nginx" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +item="./configure --disable-all --with-ssl --with-hls --with-nginx --with-ffmpeg --with-transcode" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +item="./configure --disable-all --with-ssl --with-ffmpeg --with-transcode" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +item="./configure --disable-all --with-ssl --with-ffmpeg --with-ingest" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + +item="./configure --disable-all --with-hls --with-ssl --with-http-server" +ok_msg "test \" ${item} \"" +($item && make) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" From c1b9541b5c2bb14423ae29dc896645a658e05f30 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 07:22:44 +0800 Subject: [PATCH 02/12] support disable all --- trunk/src/app/srs_app_hls.cpp | 10 +++++----- trunk/src/app/srs_app_hls.hpp | 10 +++++----- trunk/src/main/srs_main_ingest_hls.cpp | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index f62a4b668..46af33a29 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -23,11 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -/** -* the HLS section, only available when HLS enabled. -*/ -#ifdef SRS_AUTO_HLS - #include #include #include @@ -72,6 +67,11 @@ ISrsHlsHandler::~ISrsHlsHandler() { } +/** + * * the HLS section, only available when HLS enabled. + * */ +#ifdef SRS_AUTO_HLS + SrsHlsCacheWriter::SrsHlsCacheWriter(bool write_cache, bool write_file) { should_write_cache = write_cache; diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index ccfd72a7e..c47e2114e 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -29,11 +29,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -/** -* the HLS section, only available when HLS enabled. -*/ -#ifdef SRS_AUTO_HLS - #include #include @@ -86,6 +81,11 @@ public: virtual int on_hls_unpublish(SrsRequest* req) = 0; }; +/** + * * the HLS section, only available when HLS enabled. + * */ +#ifdef SRS_AUTO_HLS + /** * write to file and cache. */ diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index f63301166..c90f3318b 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -61,6 +61,8 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext(); SrsConfig* _srs_config = NULL; SrsServer* _srs_server = NULL; +#if defined(SRS_AUTO_HTTP_PARSER) + /** * main entrance. */ @@ -1402,3 +1404,15 @@ int proxy_hls2rtmp(string hls, string rtmp) return ret; } +#else + +int main(int argc, char** argv) +{ +#ifndef SRS_AUTO_HTTP_PARSER + srs_error("ingest requires http-api or http-server"); +#endif + return -1; +} + +#endif + From 02c4741d644da590dd3217d84a06ca85e0f6247f Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 07:30:37 +0800 Subject: [PATCH 03/12] add usage and make jobs support for configure test script --- trunk/scripts/srs.test | 8 +++- trunk/scripts/test_configure.sh | 85 +++++++++++++++++---------------- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/trunk/scripts/srs.test b/trunk/scripts/srs.test index eda09c6cf..da122ebf8 100755 --- a/trunk/scripts/srs.test +++ b/trunk/scripts/srs.test @@ -1,5 +1,11 @@ #!/bin/bash -bash scripts/test_configure.sh && ./objs/srs_utest +echo "Usage: $0 [-jN]" +echo " -jN The make jobs, for example, -j8 to use 8cpu to make" + +params="$@" +echo "params is: $params" + +bash scripts/test_configure.sh $params && ./objs/srs_utest ret=$?; if [[ 0 -ne $ret ]]; then echo "configure test and utest failed."; exit $ret; fi echo "configure test and utest success"; diff --git a/trunk/scripts/test_configure.sh b/trunk/scripts/test_configure.sh index c28423b16..6e80ef5b7 100755 --- a/trunk/scripts/test_configure.sh +++ b/trunk/scripts/test_configure.sh @@ -1,5 +1,8 @@ #!/bin/bash +params="$@" +echo "params is: $params" + # discover the current work dir, the log and access. echo "argv[0]=$0" if [[ ! -f $0 ]]; then @@ -19,181 +22,181 @@ ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi item="./configure" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --x86-x64" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --pure-rtmp" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --rtmp-hls" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ssl" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-hls" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-dvr" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-nginx" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-http-callback" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-http-server" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-http-api" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ffmpeg" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-transcode" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ingest" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-librtmp" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-research" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast--with-stream-caster" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-utest" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-ssl --with-utest" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf --with-gmc" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf --with-gmp" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gperf --with-gcp" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --with-gprof" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-verbose" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-info" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-trace" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast --log-info --log-verbose --log-trace" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" @@ -202,25 +205,25 @@ ok_msg "test \" ${item} \" success" ####################################################################################################### item="./configure --dev" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --fast-dev" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --demo" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --full" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" @@ -229,43 +232,43 @@ ok_msg "test \" ${item} \" success" ####################################################################################################### item="./configure --disable-all --with-ssl" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all --with-hls --with-ssl --with-http-server --with-http-api" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all --with-ssl --with-hls --with-nginx" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all --with-ssl --with-hls --with-nginx --with-ffmpeg --with-transcode" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all --with-ssl --with-ffmpeg --with-transcode" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all --with-ssl --with-ffmpeg --with-ingest" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" item="./configure --disable-all --with-hls --with-ssl --with-http-server" ok_msg "test \" ${item} \"" -($item && make) >>$log 2>&1 +($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" From eb488e3bdeee7708e5680a769b7873560ae10d3c Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 07:32:51 +0800 Subject: [PATCH 04/12] fix the test configure script bug --- trunk/scripts/test_configure.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk/scripts/test_configure.sh b/trunk/scripts/test_configure.sh index 6e80ef5b7..6fb7c4fe9 100755 --- a/trunk/scripts/test_configure.sh +++ b/trunk/scripts/test_configure.sh @@ -128,7 +128,7 @@ ok_msg "test \" ${item} \"" ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" -item="./configure --fast--with-stream-caster" +item="./configure --fast --with-stream-caster" ok_msg "test \" ${item} \"" ($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi From fec8422d6b9d3a8ecaf164e175f01b2d35fa415d Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 10:23:40 +0800 Subject: [PATCH 05/12] fix bug of configure. --- trunk/auto/auto_headers.sh | 6 +-- trunk/auto/depends.sh | 2 +- trunk/auto/options.sh | 63 +++++++++++++------------- trunk/configure | 2 +- trunk/src/app/srs_app_caster_flv.cpp | 12 ++--- trunk/src/app/srs_app_caster_flv.hpp | 8 ++-- trunk/src/app/srs_app_heartbeat.cpp | 2 +- trunk/src/app/srs_app_heartbeat.hpp | 2 +- trunk/src/app/srs_app_http_client.cpp | 2 +- trunk/src/app/srs_app_http_client.hpp | 2 +- trunk/src/app/srs_app_http_conn.cpp | 7 ++- trunk/src/app/srs_app_http_conn.hpp | 11 +++-- trunk/src/app/srs_app_server.cpp | 8 ++-- trunk/src/app/srs_app_server.hpp | 2 +- trunk/src/main/srs_main_ingest_hls.cpp | 6 +-- trunk/src/main/srs_main_server.cpp | 2 +- 16 files changed, 70 insertions(+), 67 deletions(-) diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 928c35ca5..635b9edb8 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -76,10 +76,10 @@ fi echo "" >> $SRS_AUTO_HEADERS_H # auto headers in depends. -if [ $SRS_HTTP_PARSER = YES ]; then - echo "#define SRS_AUTO_HTTP_PARSER" >> $SRS_AUTO_HEADERS_H +if [ $SRS_HTTP_CORE = YES ]; then + echo "#define SRS_AUTO_HTTP_CORE" >> $SRS_AUTO_HEADERS_H else - echo "#undef SRS_AUTO_HTTP_PARSER" >> $SRS_AUTO_HEADERS_H + echo "#undef SRS_AUTO_HTTP_CORE" >> $SRS_AUTO_HEADERS_H fi if [ $SRS_HTTP_SERVER = YES ]; then diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 0fde6acb9..7b7356e7e 100644 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -426,7 +426,7 @@ fi # http-parser-2.1 ##################################################################################### # check the arm flag file, if flag changed, need to rebuild the st. -if [ $SRS_HTTP_PARSER = YES ]; then +if [ $SRS_HTTP_CORE = YES ]; then # ok, arm specified, if the flag filed does not exists, need to rebuild. if [ $SRS_EMBEDED_CPU = YES ]; then if [[ -f ${SRS_OBJS}/_flag.st.hp.tmp && -f ${SRS_OBJS}/hp/http_parser.h && -f ${SRS_OBJS}/hp/libhttp_parser.a ]]; then diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 5864e9cf4..14c2602a8 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -45,7 +45,7 @@ SRS_GPROF=RESERVED ################################################################ # libraries SRS_FFMPEG_STUB=RESERVED -SRS_HTTP_PARSER=RESERVED +SRS_HTTP_CORE=RESERVED # arguments SRS_PREFIX=/usr/local/srs SRS_JOBS=1 @@ -376,7 +376,7 @@ function apply_user_presets() { SRS_TRANSCODE=NO SRS_INGEST=NO SRS_STAT=NO - SRS_HTTP_PARSER=NO + SRS_HTTP_CORE=NO SRS_HTTP_CALLBACK=NO SRS_HTTP_SERVER=NO SRS_STREAM_CASTER=NO @@ -403,7 +403,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=YES @@ -430,7 +430,7 @@ function apply_user_presets() { SRS_TRANSCODE=NO SRS_INGEST=NO SRS_STAT=NO - SRS_HTTP_PARSER=NO + SRS_HTTP_CORE=NO SRS_HTTP_CALLBACK=NO SRS_HTTP_SERVER=NO SRS_STREAM_CASTER=NO @@ -457,7 +457,7 @@ function apply_user_presets() { SRS_TRANSCODE=NO SRS_INGEST=NO SRS_STAT=NO - SRS_HTTP_PARSER=NO + SRS_HTTP_CORE=NO SRS_HTTP_CALLBACK=NO SRS_HTTP_SERVER=NO SRS_STREAM_CASTER=NO @@ -484,7 +484,7 @@ function apply_user_presets() { SRS_TRANSCODE=NO SRS_INGEST=NO SRS_STAT=NO - SRS_HTTP_PARSER=NO + SRS_HTTP_CORE=NO SRS_HTTP_CALLBACK=NO SRS_HTTP_SERVER=NO SRS_STREAM_CASTER=NO @@ -511,7 +511,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -539,7 +539,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -566,7 +566,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -593,7 +593,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -620,7 +620,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -647,7 +647,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -674,7 +674,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -701,7 +701,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -728,7 +728,7 @@ function apply_user_presets() { SRS_TRANSCODE=YES SRS_INGEST=YES SRS_STAT=YES - SRS_HTTP_PARSER=YES + SRS_HTTP_CORE=YES SRS_HTTP_CALLBACK=YES SRS_HTTP_SERVER=YES SRS_STREAM_CASTER=NO @@ -761,11 +761,11 @@ function apply_user_detail_options() { if [ $SRS_TRANSCODE = YES ]; then SRS_FFMPEG_STUB=YES; fi if [ $SRS_INGEST = YES ]; then SRS_FFMPEG_STUB=YES; fi - # if http-xxxx specified, open the SRS_HTTP_PARSER - SRS_HTTP_PARSER=NO - if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_HTTP_PARSER=YES; fi - if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_PARSER=YES; fi - if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_PARSER=YES; fi + # if http-xxxx specified, open the SRS_HTTP_CORE + SRS_HTTP_CORE=NO + if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_HTTP_CORE=YES; fi + if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_CORE=YES; fi + if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_CORE=YES; fi # parse the jobs for make if [[ "" -eq SRS_JOBS ]]; then @@ -790,7 +790,7 @@ function apply_user_detail_options() { SRS_TRANSCODE=NO SRS_INGEST=NO SRS_STAT=NO - SRS_HTTP_PARSER=NO + SRS_HTTP_CORE=NO SRS_HTTP_CALLBACK=NO SRS_HTTP_SERVER=NO SRS_STREAM_CASTER=NO @@ -855,13 +855,14 @@ function check_option_conflicts() { if [ $SRS_GPERF_MP = YES ]; then echo "gperf-mp depends on gperf, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_GPERF_CP = YES ]; then echo "gperf-cp depends on gperf, see: ./configure --help"; __check_ok=NO; fi fi - if [ $SRS_GPERF_MC = YES ]; then - if [ $SRS_GPERF_MP = YES ]; then - echo "gperf-mc not compatible with gperf-mp, see: ./configure --help"; - echo "@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html"; - echo "Note that since the heap-checker uses the heap-profiling framework internally, it is not possible to run both the heap-checker and heap profiler at the same time"; - __check_ok=NO - fi + if [[ $SRS_GPERF_MC = YES && $SRS_GPERF_MP = YES ]]; then + echo "gperf-mc not compatible with gperf-mp, see: ./configure --help"; + echo "@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html"; + echo "Note that since the heap-checker uses the heap-profiling framework internally, it is not possible to run both the heap-checker and heap profiler at the same time"; + __check_ok=NO + fi + if [[ $SRS_HTTP_CORE = NO && $SRS_STREAM_CASTER = YES ]]; then + echo "stream-caster depends on http-api or http-server, see: ./configure --help"; __check_ok=NO; fi # generate the group option: SRS_GPERF __gperf_slow=NO @@ -885,10 +886,8 @@ function check_option_conflicts() { fi # if x86/x64 or directly build, never use static - if [ $SRS_X86_X64 = YES ]; then - if [ $SRS_STATIC = YES ]; then - echo "x86/x64 should never use static, see: ./configure --help"; __check_ok=NO; - fi + if [[ $SRS_X86_X64 = YES && $SRS_STATIC = YES ]]; then + echo "x86/x64 should never use static, see: ./configure --help"; __check_ok=NO; fi # TODO: FIXME: check more os. diff --git a/trunk/configure b/trunk/configure index 1daf241fc..c234a810f 100755 --- a/trunk/configure +++ b/trunk/configure @@ -115,7 +115,7 @@ END LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a" # hp(http-parser) the http request/url parser, for SRS to support HTTP callback. LibHttpParserRoot=""; LibHttpParserfile="" -if [ $SRS_HTTP_PARSER = YES ]; then LibHttpParserRoot="${SRS_OBJS_DIR}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi +if [ $SRS_HTTP_CORE = YES ]; then LibHttpParserRoot="${SRS_OBJS_DIR}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi # openssl-1.0.1f, for the RTMP complex handshake. LibSSLRoot="";LibSSLfile="" if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a"; fi fi diff --git a/trunk/src/app/srs_app_caster_flv.cpp b/trunk/src/app/srs_app_caster_flv.cpp index 146820f42..6d886f687 100644 --- a/trunk/src/app/srs_app_caster_flv.cpp +++ b/trunk/src/app/srs_app_caster_flv.cpp @@ -33,7 +33,6 @@ using namespace std; #include #include #include -#include #include #include #include @@ -89,9 +88,10 @@ void SrsAppCasterFlv::remove(SrsConnection* c) } } -int SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) +int SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) { - SrsDynamicHttpConn* conn = dynamic_cast(r->connection()); + SrsHttpMessage* msg = dynamic_cast(r); + SrsDynamicHttpConn* conn = dynamic_cast(msg->connection()); srs_assert(conn); std::string app = srs_path_dirname(r->path()); @@ -134,13 +134,13 @@ SrsDynamicHttpConn::~SrsDynamicHttpConn() srs_freep(pprint); } -int SrsDynamicHttpConn::on_got_http_message(SrsHttpMessage* msg) +int SrsDynamicHttpConn::on_got_http_message(ISrsHttpMessage* msg) { int ret = ERROR_SUCCESS; return ret; } -int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string o) +int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string o) { int ret = ERROR_SUCCESS; @@ -430,7 +430,7 @@ int SrsHttpFileReader::read(void* buf, size_t count, ssize_t* pnread) } int total_read = 0; - while (total_read < count) { + while (total_read < (int)count) { int nread = 0; if ((ret = http->read((char*)buf + total_read, (int)(count - total_read), &nread)) != ERROR_SUCCESS) { return ret; diff --git a/trunk/src/app/srs_app_caster_flv.hpp b/trunk/src/app/srs_app_caster_flv.hpp index 58de503f9..cf0d11f86 100644 --- a/trunk/src/app/srs_app_caster_flv.hpp +++ b/trunk/src/app/srs_app_caster_flv.hpp @@ -37,7 +37,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. class SrsConfDirective; class SrsHttpServeMux; -class SrsHttpConn; class SrsRtmpClient; class SrsStSocket; class SrsRequest; @@ -48,7 +47,6 @@ class SrsFlvDecoder; #include #include #include -#include #include #include @@ -75,7 +73,7 @@ public: virtual void remove(SrsConnection* c); // ISrsHttpHandler public: - virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r); + virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); }; /** @@ -96,9 +94,9 @@ public: SrsDynamicHttpConn(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m); virtual ~SrsDynamicHttpConn(); public: - virtual int on_got_http_message(SrsHttpMessage* msg); + virtual int on_got_http_message(ISrsHttpMessage* msg); public: - virtual int proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string o); + virtual int proxy(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string o); private: virtual int do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec); virtual int rtmp_write_packet(char type, u_int32_t timestamp, char* data, int size); diff --git a/trunk/src/app/srs_app_heartbeat.cpp b/trunk/src/app/srs_app_heartbeat.cpp index 165e38e90..349545f3c 100644 --- a/trunk/src/app/srs_app_heartbeat.cpp +++ b/trunk/src/app/srs_app_heartbeat.cpp @@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE #include using namespace std; diff --git a/trunk/src/app/srs_app_heartbeat.hpp b/trunk/src/app/srs_app_heartbeat.hpp index 6aad01b67..31995ac51 100644 --- a/trunk/src/app/srs_app_heartbeat.hpp +++ b/trunk/src/app/srs_app_heartbeat.hpp @@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE /** * the http heartbeat to api-server to notice api diff --git a/trunk/src/app/srs_app_http_client.cpp b/trunk/src/app/srs_app_http_client.cpp index 60ec8e44e..07c8cfe43 100644 --- a/trunk/src/app/srs_app_http_client.cpp +++ b/trunk/src/app/srs_app_http_client.cpp @@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE #include diff --git a/trunk/src/app/srs_app_http_client.hpp b/trunk/src/app/srs_app_http_client.hpp index 8a2dc88b7..b05def7ca 100644 --- a/trunk/src/app/srs_app_http_client.hpp +++ b/trunk/src/app/srs_app_http_client.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE #include diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index e7e259456..36544b1f5 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#if defined(SRS_AUTO_HTTP_PARSER) || defined(SRS_AUTO_HTTP_SERVER) +#if defined(SRS_AUTO_HTTP_CORE) || defined(SRS_AUTO_HTTP_SERVER) #include #include @@ -55,7 +55,7 @@ using namespace std; #endif -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE SrsHttpResponseWriter::SrsHttpResponseWriter(SrsStSocket* io) { @@ -2423,6 +2423,9 @@ int SrsHttpServer::initialize_hls_streaming() return ret; } +#endif + +#ifdef SRS_AUTO_HTTP_CORE SrsHttpConn::SrsHttpConn(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m) : SrsConnection(cm, fd) { diff --git a/trunk/src/app/srs_app_http_conn.hpp b/trunk/src/app/srs_app_http_conn.hpp index f1d55d06d..21b73defb 100644 --- a/trunk/src/app/srs_app_http_conn.hpp +++ b/trunk/src/app/srs_app_http_conn.hpp @@ -30,11 +30,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE #include #endif -#if defined(SRS_AUTO_HTTP_PARSER) || defined(SRS_AUTO_HTTP_SERVER) +#ifdef SRS_AUTO_HTTP_CORE #include #include @@ -69,7 +69,7 @@ class SrsHttpMessage; #endif -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE // the http chunked header size, // for writev, there always one chunk to send it. @@ -214,7 +214,7 @@ public: virtual int update(std::string url, http_parser* header, SrsFastBuffer* body, std::vector& headers ); -private: +public: virtual SrsConnection* connection(); public: virtual u_int8_t method(); @@ -711,6 +711,9 @@ private: virtual int initialize_hls_streaming(); }; +#endif + +#ifdef SRS_AUTO_HTTP_CORE class SrsHttpConn : public SrsConnection { private: diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 49eef6f64..208ee4036 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -495,7 +495,7 @@ SrsServer::SrsServer() #ifdef SRS_AUTO_HTTP_SERVER http_stream_mux = new SrsHttpServer(this); #endif -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE http_heartbeat = NULL; #endif #ifdef SRS_AUTO_INGEST @@ -530,7 +530,7 @@ void SrsServer::destroy() srs_freep(http_stream_mux); #endif -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE srs_freep(http_heartbeat); #endif @@ -589,7 +589,7 @@ int SrsServer::initialize(ISrsServerCycle* cycle_handler) } #endif -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE srs_assert(!http_heartbeat); http_heartbeat = new SrsHttpHeartbeat(); #endif @@ -971,7 +971,7 @@ int SrsServer::do_cycle() srs_info("update network server kbps info."); resample_kbps(); } - #ifdef SRS_AUTO_HTTP_PARSER + #ifdef SRS_AUTO_HTTP_CORE if (_srs_config->get_heartbeat_enabled()) { if ((i % heartbeat_max_resolution) == 0) { srs_info("do http heartbeat, for internal server to report."); diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index 8dbcb47f1..587adc8f0 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -240,7 +240,7 @@ private: #ifdef SRS_AUTO_HTTP_SERVER SrsHttpServer* http_stream_mux; #endif -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE SrsHttpHeartbeat* http_heartbeat; #endif #ifdef SRS_AUTO_INGEST diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index c90f3318b..c2902f019 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -61,7 +61,7 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext(); SrsConfig* _srs_config = NULL; SrsServer* _srs_server = NULL; -#if defined(SRS_AUTO_HTTP_PARSER) +#if defined(SRS_AUTO_HTTP_CORE) /** * main entrance. @@ -72,7 +72,7 @@ int main(int argc, char** argv) srs_assert(srs_is_little_endian()); // directly failed when compile limited. -#if !defined(SRS_AUTO_HTTP_PARSER) +#if !defined(SRS_AUTO_HTTP_CORE) srs_error("depends on http-parser."); exit(-1); #endif @@ -1408,7 +1408,7 @@ int proxy_hls2rtmp(string hls, string rtmp) int main(int argc, char** argv) { -#ifndef SRS_AUTO_HTTP_PARSER +#ifndef SRS_AUTO_HTTP_CORE srs_error("ingest requires http-api or http-server"); #endif return -1; diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 41d8f084f..fddd9702b 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -96,7 +96,7 @@ void show_macro_features() srs_warn("check feature http server: off"); #endif -#ifdef SRS_AUTO_HTTP_PARSER +#ifdef SRS_AUTO_HTTP_CORE srs_trace("check feature http parser: on"); #else srs_warn("check feature http parser: off"); From ca01bd407b7cec77ae743d5ef448519a43c19a14 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 10:55:46 +0800 Subject: [PATCH 06/12] fix the bug of test configure script. --- trunk/scripts/test_configure.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk/scripts/test_configure.sh b/trunk/scripts/test_configure.sh index 6fb7c4fe9..e2626e098 100755 --- a/trunk/scripts/test_configure.sh +++ b/trunk/scripts/test_configure.sh @@ -128,7 +128,7 @@ ok_msg "test \" ${item} \"" ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" -item="./configure --fast --with-stream-caster" +item="./configure --fast --with-stream-caster --with-http-api" ok_msg "test \" ${item} \"" ($item && make $params) >>$log 2>&1 ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi From 1150cde8291e97639f2b71720fdb9ee59d338f9d Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 11:12:52 +0800 Subject: [PATCH 07/12] fix the verbose build failed. --- trunk/scripts/test_configure.sh | 9 +++++++++ trunk/src/app/srs_app_server.cpp | 8 ++++---- trunk/src/protocol/srs_rtmp_stack.cpp | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/trunk/scripts/test_configure.sh b/trunk/scripts/test_configure.sh index e2626e098..a1dd7a6e2 100755 --- a/trunk/scripts/test_configure.sh +++ b/trunk/scripts/test_configure.sh @@ -272,4 +272,13 @@ ok_msg "test \" ${item} \"" ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" +####################################################################################################### +####################################################################################################### +####################################################################################################### +item="./configure --without-utest" +ok_msg "test \" ${item} \"" +($item && make $params) >>$log 2>&1 +ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi +ok_msg "test \" ${item} \" success" + echo "success" diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 208ee4036..d4b519831 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -154,9 +154,9 @@ int SrsStreamListener::listen(string i, int p) return ret; } - srs_info("listen thread cid=%d, current_cid=%d, " + srs_info("listen thread current_cid=%d, " "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", - pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port); + _srs_context->get_id(), p, type, listener->fd(), i.c_str(), p); srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd()); @@ -327,9 +327,9 @@ int SrsUdpStreamListener::listen(string i, int p) return ret; } - srs_info("listen thread cid=%d, current_cid=%d, " + srs_info("listen thread current_cid=%d, " "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", - pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port); + _srs_context->get_id(), p, type, listener->fd(), i.c_str(), p); // notify the handler the fd changed. if ((ret = caster->on_stfd_change(listener->stfd())) != ERROR_SUCCESS) { diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index c0ca5e9b5..738a7d81f 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -961,8 +961,8 @@ int SrsProtocol::recv_interlaced_message(SrsCommonMessage** pmsg) return ret; } srs_verbose("read message header success. " - "fmt=%d, mh_size=%d, ext_time=%d, size=%d, message(type=%d, size=%d, time=%"PRId64", sid=%d)", - fmt, mh_size, chunk->extended_timestamp, (chunk->msg? chunk->msg->size : 0), chunk->header.message_type, + "fmt=%d, ext_time=%d, size=%d, message(type=%d, size=%d, time=%"PRId64", sid=%d)", + fmt, chunk->extended_timestamp, (chunk->msg? chunk->msg->size : 0), chunk->header.message_type, chunk->header.payload_length, chunk->header.timestamp, chunk->header.stream_id); // read msg payload from chunk stream. From 7e04975b8dcc921eaf07c8d59f4e07f1ee12251b Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 11:38:10 +0800 Subject: [PATCH 08/12] fix the test configure script --- trunk/scripts/srs.test | 1 + trunk/scripts/test_configure.sh | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/trunk/scripts/srs.test b/trunk/scripts/srs.test index da122ebf8..5e7a573c1 100755 --- a/trunk/scripts/srs.test +++ b/trunk/scripts/srs.test @@ -9,3 +9,4 @@ echo "params is: $params" bash scripts/test_configure.sh $params && ./objs/srs_utest ret=$?; if [[ 0 -ne $ret ]]; then echo "configure test and utest failed."; exit $ret; fi echo "configure test and utest success"; + diff --git a/trunk/scripts/test_configure.sh b/trunk/scripts/test_configure.sh index a1dd7a6e2..e2626e098 100755 --- a/trunk/scripts/test_configure.sh +++ b/trunk/scripts/test_configure.sh @@ -272,13 +272,4 @@ ok_msg "test \" ${item} \"" ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi ok_msg "test \" ${item} \" success" -####################################################################################################### -####################################################################################################### -####################################################################################################### -item="./configure --without-utest" -ok_msg "test \" ${item} \"" -($item && make $params) >>$log 2>&1 -ret=$?; if [[ $ret -ne 0 ]]; then failed_msg "test \" ${item} \" failed. ret=$ret"; exit $ret; fi -ok_msg "test \" ${item} \" success" - echo "success" From 4864e796d6d3f88c7d48b12e8eac5f5acf9dd76a Mon Sep 17 00:00:00 2001 From: zhengfl Date: Wed, 27 May 2015 16:16:15 +0800 Subject: [PATCH 09/12] =?UTF-8?q?fix=20#408:Queue=E4=B8=A2=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=BA=94=E8=AF=A5=E4=B8=A2?= =?UTF-8?q?=E5=BC=83SequenceHeader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/src/app/srs_app_source.cpp | 67 +++++++++++++++----------------- 1 file changed, 32 insertions(+), 35 deletions(-) mode change 100644 => 100755 trunk/src/app/srs_app_source.cpp diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp old mode 100644 new mode 100755 index 7e6dfafe3..bafa2d7a8 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -357,52 +357,49 @@ int SrsMessageQueue::dump_packets(SrsConsumer* consumer, bool atc, int tba, int void SrsMessageQueue::shrink() { - int iframe_index = -1; + SrsSharedPtrMessage* video_sh = NULL; + SrsSharedPtrMessage* audio_sh = NULL; + int msgs_size = (int)msgs.size(); - // issue the first iframe. - // skip the first frame, whatever the type of it, - // for when we shrinked, the first is the iframe, - // we will directly remove the gop next time. - for (int i = 1; i < (int)msgs.size(); i++) { + // remove all msg + // igone the sequence header + for (int i = 0; i < (int)msgs.size(); i++) { SrsSharedPtrMessage* msg = msgs.at(i); - - if (msg->is_video()) { - if (SrsFlvCodec::video_is_keyframe(msg->payload, msg->size)) { - // the max frame index to remove. - iframe_index = i; - - // set the start time, we will remove until this frame. - av_start_time = msg->timestamp; - - break; - } + + if (msg->is_video() && SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) { + srs_freep(video_sh); + video_sh = msg; + continue; } + else if (msg->is_audio() && SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) { + srs_freep(audio_sh); + audio_sh = msg; + continue; + } + + srs_freep(msg); } - - // no iframe, for audio, clear the queue. - // it is ok to clear for audio, for the shrink tell us the queue is full. - // for video, we clear util the I-Frame, for the decoding must start from I-frame, - // for audio, it's ok to clear any data, also we can clear the whole queue. - // @see: https://github.com/simple-rtmp-server/srs/issues/134 - if (iframe_index < 0) { - clear(); - return; + msgs.clear(); + + // update av_start_time + av_start_time = av_end_time; + //push_back secquence header and update timestamp + if (video_sh) { + video_sh->timestamp = av_end_time; + msgs.push_back(video_sh); + } + if (audio_sh) { + audio_sh->timestamp = av_end_time; + msgs.push_back(audio_sh); } if (_ignore_shrink) { srs_info("shrink the cache queue, size=%d, removed=%d, max=%.2f", - (int)msgs.size(), iframe_index, queue_size_ms / 1000.0); + (int)msgs.size(), msgs_size - (int)msgs.size(), queue_size_ms / 1000.0); } else { srs_trace("shrink the cache queue, size=%d, removed=%d, max=%.2f", - (int)msgs.size(), iframe_index, queue_size_ms / 1000.0); + (int)msgs.size(), msgs_size - (int)msgs.size(), queue_size_ms / 1000.0); } - - // remove the first gop from the front - for (int i = 0; i < iframe_index; i++) { - SrsSharedPtrMessage* msg = msgs.at(i); - srs_freep(msg); - } - msgs.erase(msgs.begin(), msgs.begin() + iframe_index); } void SrsMessageQueue::clear() From 385ee893f50b43c228838e13fabdb1c9334525b8 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 May 2015 23:43:44 +0800 Subject: [PATCH 10/12] update readme --- trunk/src/app/srs_app_listener.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index 42d77414f..2648ab95c 100644 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -113,18 +113,18 @@ int SrsUdpListener::listen() if ((_fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { ret = ERROR_SOCKET_CREATE; - srs_error("create linux socket error. port=%d, ret=%d", ip.c_str(), port, ret); + srs_error("create linux socket error. ip=%s, port=%d, ret=%d", ip.c_str(), port, ret); return ret; } - srs_verbose("create linux socket success. port=%d, fd=%d", ip.c_str(), port, _fd); + srs_verbose("create linux socket success. ip=%s, port=%d, fd=%d", ip.c_str(), port, _fd); int reuse_socket = 1; if (setsockopt(_fd, SOL_SOCKET, SO_REUSEADDR, &reuse_socket, sizeof(int)) == -1) { ret = ERROR_SOCKET_SETREUSE; - srs_error("setsockopt reuse-addr error. port=%d, ret=%d", ip.c_str(), port, ret); + srs_error("setsockopt reuse-addr error. ip=%s, port=%d, ret=%d", ip.c_str(), port, ret); return ret; } - srs_verbose("setsockopt reuse-addr success. port=%d, fd=%d", ip.c_str(), port, _fd); + srs_verbose("setsockopt reuse-addr success. ip=%s, port=%d, fd=%d", ip.c_str(), port, _fd); sockaddr_in addr; addr.sin_family = AF_INET; From e5461d2df96943775549db1567287ef884c3477f Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 28 May 2015 07:03:38 +0800 Subject: [PATCH 11/12] refine code --- trunk/src/app/srs_app_log.cpp | 7 +++++-- trunk/src/app/srs_app_log.hpp | 2 +- trunk/src/app/srs_app_server.cpp | 2 +- trunk/src/app/srs_app_st.cpp | 2 +- trunk/src/app/srs_app_st.hpp | 2 +- trunk/src/kernel/srs_kernel_log.cpp | 3 ++- trunk/src/kernel/srs_kernel_log.hpp | 2 +- trunk/src/main/srs_main_ingest_hls.cpp | 2 +- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/trunk/src/app/srs_app_log.cpp b/trunk/src/app/srs_app_log.cpp index b6a43bac3..ba8cc0bf1 100644 --- a/trunk/src/app/srs_app_log.cpp +++ b/trunk/src/app/srs_app_log.cpp @@ -43,10 +43,13 @@ SrsThreadContext::~SrsThreadContext() { } -void SrsThreadContext::generate_id() +int SrsThreadContext::generate_id() { static int id = 100; - cache[st_thread_self()] = id++; + + int gid = id++; + cache[st_thread_self()] = gid; + return gid; } int SrsThreadContext::get_id() diff --git a/trunk/src/app/srs_app_log.hpp b/trunk/src/app/srs_app_log.hpp index 9645079fa..c997df3e8 100644 --- a/trunk/src/app/srs_app_log.hpp +++ b/trunk/src/app/srs_app_log.hpp @@ -51,7 +51,7 @@ public: SrsThreadContext(); virtual ~SrsThreadContext(); public: - virtual void generate_id(); + virtual int generate_id(); virtual int get_id(); }; diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index d4b519831..a954a8a1f 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -607,7 +607,7 @@ int SrsServer::initialize_st() int ret = ERROR_SUCCESS; // init st - if ((ret = srs_init_st()) != ERROR_SUCCESS) { + if ((ret = srs_st_init()) != ERROR_SUCCESS) { srs_error("init st failed. ret=%d", ret); return ret; } diff --git a/trunk/src/app/srs_app_st.cpp b/trunk/src/app/srs_app_st.cpp index bf73a4bb2..453560795 100644 --- a/trunk/src/app/srs_app_st.cpp +++ b/trunk/src/app/srs_app_st.cpp @@ -42,7 +42,7 @@ bool srs_st_epoll_is_supported(void) } #endif -int srs_init_st() +int srs_st_init() { int ret = ERROR_SUCCESS; diff --git a/trunk/src/app/srs_app_st.hpp b/trunk/src/app/srs_app_st.hpp index 545547058..37581e737 100644 --- a/trunk/src/app/srs_app_st.hpp +++ b/trunk/src/app/srs_app_st.hpp @@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include // initialize st, requires epoll. -extern int srs_init_st(); +extern int srs_st_init(); // close the netfd, and close the underlayer fd. extern void srs_close_stfd(st_netfd_t& stfd); diff --git a/trunk/src/kernel/srs_kernel_log.cpp b/trunk/src/kernel/srs_kernel_log.cpp index 78cf3fad0..8c6f872c8 100644 --- a/trunk/src/kernel/srs_kernel_log.cpp +++ b/trunk/src/kernel/srs_kernel_log.cpp @@ -66,8 +66,9 @@ ISrsThreadContext::~ISrsThreadContext() { } -void ISrsThreadContext::generate_id() +int ISrsThreadContext::generate_id() { + return 0; } int ISrsThreadContext::get_id() diff --git a/trunk/src/kernel/srs_kernel_log.hpp b/trunk/src/kernel/srs_kernel_log.hpp index 93f6b1d2b..966e39fbe 100644 --- a/trunk/src/kernel/srs_kernel_log.hpp +++ b/trunk/src/kernel/srs_kernel_log.hpp @@ -102,7 +102,7 @@ public: ISrsThreadContext(); virtual ~ISrsThreadContext(); public: - virtual void generate_id(); + virtual int generate_id(); virtual int get_id(); }; diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index c2902f019..f9a4397f2 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -1378,7 +1378,7 @@ int proxy_hls2rtmp(string hls, string rtmp) int ret = ERROR_SUCCESS; // init st. - if ((ret = srs_init_st()) != ERROR_SUCCESS) { + if ((ret = srs_st_init()) != ERROR_SUCCESS) { srs_error("init st failed. ret=%d", ret); return ret; } From 394e070b2ef2fbcc8eeba817bbdcc036ba995582 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 28 May 2015 14:59:12 +0800 Subject: [PATCH 12/12] support dolphin --- trunk/src/app/srs_app_config.cpp | 46 ++++++++++++++++++++++++++++++-- trunk/src/app/srs_app_config.hpp | 14 ++++++++++ trunk/src/app/srs_app_server.cpp | 5 ++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 356b85bab..23e8c92a2 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -364,6 +364,8 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector& args, SrsConfig::SrsConfig() { + dolphin = false; + show_help = false; show_version = false; test_conf = false; @@ -378,6 +380,25 @@ SrsConfig::~SrsConfig() srs_freep(root); } +bool SrsConfig::is_dolphin() +{ + return dolphin; +} + +void SrsConfig::set_config_directive(SrsConfDirective* parent, string dir, string value) +{ + SrsConfDirective* d = parent->get(dir); + + if (!d) { + d = new SrsConfDirective(); + d->name = dir; + parent->directives.push_back(d); + } + + d->args.clear(); + d->args.push_back(value); +} + void SrsConfig::subscribe(ISrsReloadHandler* handler) { std::vector::iterator it; @@ -1260,6 +1281,19 @@ int SrsConfig::parse_argv(int& i, char** argv) show_help = false; test_conf = true; break; + case 'p': + dolphin = true; + if (*p) { + dolphin_port = p; + continue; + } + if (argv[++i]) { + dolphin_port = argv[i]; + continue; + } + ret = ERROR_SYSTEM_CONFIG_INVALID; + srs_error("option \"-p\" requires params, ret=%d", ret); + return ret; case 'v': case 'V': show_help = false; @@ -1269,11 +1303,11 @@ int SrsConfig::parse_argv(int& i, char** argv) show_help = false; if (*p) { config_file = p; - return ret; + continue; } if (argv[++i]) { config_file = argv[i]; - return ret; + continue; } ret = ERROR_SYSTEM_CONFIG_INVALID; srs_error("option \"-c\" requires parameter, ret=%d", ret); @@ -1844,6 +1878,14 @@ int SrsConfig::parse_buffer(SrsConfigBuffer* buffer) if ((ret = root->parse(buffer)) != ERROR_SUCCESS) { return ret; } + + // mock by dolphin mode. + // for the dolphin will start srs with specified params. + if (dolphin) { + set_config_directive(root, "listen", dolphin_port); + set_config_directive(root, "daemon", "off"); + set_config_directive(root, "srs_log_tank", "console"); + } return ret; } diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 6e2a1b353..fd822c68f 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -266,6 +266,12 @@ class SrsConfig { // user command private: + /** + * whether srs is run in dolphin mode. + * @see https://github.com/simple-rtmp-server/srs-dolphin + */ + bool dolphin; + std::string dolphin_port; /** * whether show help and exit. */ @@ -309,6 +315,14 @@ private: public: SrsConfig(); virtual ~SrsConfig(); +// dolphin +public: + /** + * whether srs is in dolphin mode. + */ + virtual bool is_dolphin(); +private: + virtual void set_config_directive(SrsConfDirective* parent, std::string dir, std::string value); // reload public: /** diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index a954a8a1f..7c092949a 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -639,6 +639,11 @@ int SrsServer::acquire_pid_file() { int ret = ERROR_SUCCESS; + // when srs in dolphin mode, no need the pid file. + if (_srs_config->is_dolphin()) { + return ret; + } + std::string pid_file = _srs_config->get_pid_file(); // -rw-r--r--