From eba35e2ac0d7163330148c4bcedb98870bb87d98 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 8 Apr 2014 15:28:34 +0800 Subject: [PATCH] refine the macro SRS_FFMPEG to SRS_FFMPEG_STUB, SRS_FFMPEG_TOOL to build ffmpeg tool --- trunk/auto/depends.sh | 14 +++++++------- trunk/auto/options.sh | 24 ++++++++++++------------ trunk/configure | 8 ++++---- trunk/src/app/srs_app_encoder.cpp | 2 +- trunk/src/app/srs_app_ffmpeg.cpp | 2 +- trunk/src/app/srs_app_ffmpeg.hpp | 2 +- trunk/src/app/srs_app_ingest.cpp | 3 ++- trunk/src/app/srs_app_server.cpp | 3 +++ 8 files changed, 31 insertions(+), 27 deletions(-) diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 24a88efce..42da51139 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -487,7 +487,7 @@ fi ##################################################################################### # live transcoding, ffmpeg-2.1, x264-core138, lame-3.99.5, libaacplus-2.0.2. ##################################################################################### -if [ $SRS_FFMPEG = YES ]; then +if [ $SRS_FFMPEG_TOOL = YES ]; then if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then echo "ffmpeg-2.1 is ok."; else @@ -506,13 +506,13 @@ fi # whatever the FFMPEG tools, if transcode and ingest specified, # srs always compile the FFMPEG tool stub which used to start the FFMPEG process. -__SRS_FFMPEG=NO -if [ $SRS_TRANSCODE = YES ]; then __SRS_FFMPEG=YES; fi -if [ $SRS_INGEST = YES ]; then __SRS_FFMPEG=YES; fi -if [ $__SRS_FFMPEG = YES ]; then - echo "#define SRS_FFMPEG" >> $SRS_AUTO_HEADERS_H +__SRS_FFMPEG_STUB=NO +if [ $SRS_TRANSCODE = YES ]; then __SRS_FFMPEG_STUB=YES; fi +if [ $SRS_INGEST = YES ]; then __SRS_FFMPEG_STUB=YES; fi +if [ $__SRS_FFMPEG_STUB = YES ]; then + echo "#define SRS_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H else - echo "#undef SRS_FFMPEG" >> $SRS_AUTO_HEADERS_H + echo "#undef SRS_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H fi if [ $SRS_TRANSCODE = YES ]; then diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index dbff8b4d5..ebea5122f 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -16,7 +16,7 @@ help=no SRS_HLS=RESERVED SRS_NGINX=RESERVED SRS_SSL=RESERVED -SRS_FFMPEG=RESERVED +SRS_FFMPEG_TOOL=RESERVED SRS_TRANSCODE=RESERVED SRS_INGEST=RESERVED SRS_HTTP_PARSER=RESERVED @@ -75,7 +75,7 @@ do --with-ssl) SRS_SSL=YES ;; --with-hls) SRS_HLS=YES ;; --with-nginx) SRS_NGINX=YES ;; - --with-ffmpeg) SRS_FFMPEG=YES ;; + --with-ffmpeg) SRS_FFMPEG_TOOL=YES ;; --with-transcode) SRS_TRANSCODE=YES ;; --with-ingest) SRS_INGEST=YES ;; --with-http-callback) SRS_HTTP_CALLBACK=YES ;; @@ -95,7 +95,7 @@ do --without-ssl) SRS_SSL=NO ;; --without-hls) SRS_HLS=NO ;; --without-nginx) SRS_NGINX=NO ;; - --without-ffmpeg) SRS_FFMPEG=NO ;; + --without-ffmpeg) SRS_FFMPEG_TOOL=NO ;; --without-transcode) SRS_TRANSCODE=NO ;; --without-ingest) SRS_INGEST=NO ;; --without-http-callback) SRS_HTTP_CALLBACK=NO ;; @@ -136,15 +136,15 @@ if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_PARSER=YES; fi if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_PARSER=YES; fi # if transcode specified, try ffmpeg if possible. -if [ $SRS_TRANSCODE = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi -if [ $SRS_INGEST = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi +if [ $SRS_TRANSCODE = YES ]; then if [ $SRS_FFMPEG_TOOL = RESERVED ]; then SRS_FFMPEG_TOOL=YES; fi fi +if [ $SRS_INGEST = YES ]; then if [ $SRS_FFMPEG_TOOL = RESERVED ]; then SRS_FFMPEG_TOOL=YES; fi fi # if arm specified, set some default to disabled. if [ $SRS_ARM_UBUNTU12 = YES ]; then if [ $SRS_HLS = RESERVED ]; then SRS_HLS=YES; fi SRS_NGINX=NO if [ $SRS_SSL = RESERVED ]; then SRS_SSL=YES; fi - SRS_FFMPEG=NO + SRS_FFMPEG_TOOL=NO if [ $SRS_TRANSCODE = RESERVED ]; then SRS_TRANSCODE=YES; fi if [ $SRS_INGEST = RESERVED ]; then SRS_INGEST=YES; fi if [ $SRS_HTTP_PARSER = RESERVED ]; then SRS_HTTP_PARSER=YES; fi @@ -169,7 +169,7 @@ else if [ $SRS_HLS = RESERVED ]; then SRS_HLS=YES; fi if [ $SRS_NGINX = RESERVED ]; then SRS_NGINX=NO; fi if [ $SRS_SSL = RESERVED ]; then SRS_SSL=YES; fi - if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=NO; fi + if [ $SRS_FFMPEG_TOOL = RESERVED ]; then SRS_FFMPEG_TOOL=NO; fi if [ $SRS_TRANSCODE = RESERVED ]; then SRS_TRANSCODE=NO; fi if [ $SRS_INGEST = RESERVED ]; then SRS_INGEST=NO; fi if [ $SRS_HTTP_PARSER = RESERVED ]; then SRS_HTTP_PARSER=YES; fi @@ -196,7 +196,7 @@ if [ $SRS_DEV = YES ]; then SRS_HLS=YES SRS_NGINX=NO SRS_SSL=YES - SRS_FFMPEG=YES + SRS_FFMPEG_TOOL=YES SRS_TRANSCODE=YES SRS_INGEST=YES SRS_HTTP_PARSER=YES @@ -222,7 +222,7 @@ if [ $SRS_PI = YES ]; then SRS_HLS=YES SRS_NGINX=NO SRS_SSL=YES - SRS_FFMPEG=NO + SRS_FFMPEG_TOOL=NO SRS_TRANSCODE=YES SRS_INGEST=YES SRS_HTTP_PARSER=YES @@ -348,7 +348,7 @@ fi fi # check arm, if arm enabled, only allow st/ssl/librtmp, # user should disable all other features if [ $SRS_ARM_UBUNTU12 = YES ]; then - if [ $SRS_FFMPEG = YES ]; then echo "ffmpeg for arm is not available, see: ./configure --help"; __check_ok=NO; fi + if [ $SRS_FFMPEG_TOOL = YES ]; then echo "ffmpeg for arm is not available, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_BWTC = YES ]; then echo "bwtc for arm is not available, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_RESEARCH = YES ]; then echo "research for arm is not available, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_GPERF = YES ]; then echo "gperf for arm is not available, see: ./configure --help"; __check_ok=NO; fi @@ -362,7 +362,7 @@ fi if [ $SRS_HLS = RESERVED ]; then echo "you must specifies the hls, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_NGINX = RESERVED ]; then echo "you must specifies the nginx, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_SSL = RESERVED ]; then echo "you must specifies the ssl, see: ./configure --help"; __check_ok=NO; fi -if [ $SRS_FFMPEG = RESERVED ]; then echo "you must specifies the ffmpeg, see: ./configure --help"; __check_ok=NO; fi +if [ $SRS_FFMPEG_TOOL = RESERVED ]; then echo "you must specifies the ffmpeg, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_HTTP_CALLBACK = RESERVED ]; then echo "you must specifies the http-callback, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_HTTP_SERVER = RESERVED ]; then echo "you must specifies the http-server, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_HTTP_API = RESERVED ]; then echo "you must specifies the http-api, see: ./configure --help"; __check_ok=NO; fi @@ -388,7 +388,7 @@ if [ $SRS_PI = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --pi"; fi if [ $SRS_HLS = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-hls"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-hls"; fi if [ $SRS_NGINX = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-nginx"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-nginx"; fi if [ $SRS_SSL = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-ssl"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-ssl"; fi -if [ $SRS_FFMPEG = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-ffmpeg"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-ffmpeg"; fi +if [ $SRS_FFMPEG_TOOL = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-ffmpeg"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-ffmpeg"; fi if [ $SRS_TRANSCODE = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-transcode"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-transcode"; fi if [ $SRS_INGEST = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-ingest"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-ingest"; fi if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-http-callback"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-http-callback"; fi diff --git a/trunk/configure b/trunk/configure index fc9ae6866..720ae4728 100755 --- a/trunk/configure +++ b/trunk/configure @@ -16,7 +16,7 @@ BLACK="\\e[0m" ##################################################################################### # parse user options, set the variables like: -# srs features: SRS_SSL/SRS_HLS/SRS_NGINX/SRS_FFMPEG/SRS_HTTP_CALLBACK/...... +# srs features: SRS_SSL/SRS_HLS/SRS_NGINX/SRS_FFMPEG_TOOL/SRS_HTTP_CALLBACK/...... # build options: SRS_JOBS ##################################################################################### SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp" @@ -84,7 +84,7 @@ if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS}/utest; \$(MAKE) SrsHlsSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HLS = YES ]; then SrsHlsSummaryColor="\${GREEN}"; fi SrsNginxSummaryColor="\${GREEN}{disabled} "; if [ $SRS_NGINX = YES ]; then SrsNginxSummaryColor="\${GREEN}"; fi SrsSslSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_SSL = YES ]; then SrsSslSummaryColor="\${GREEN}"; fi -SrsFfmpegSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_FFMPEG = YES ]; then SrsFfmpegSummaryColor="\${GREEN}"; fi +SrsFfmpegSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_FFMPEG_TOOL = YES ]; then SrsFfmpegSummaryColor="\${GREEN}"; fi SrsTranscodeSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_TRANSCODE = YES ]; then SrsTranscodeSummaryColor="\${GREEN}"; fi SrsIngestSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_INGEST = YES ]; then SrsIngestSummaryColor="\${GREEN}"; fi SrsHttpCallbackSummaryColor="\${YELLOW}{disabled} "; if [ $SRS_HTTP_CALLBACK = YES ]; then SrsHttpCallbackSummaryColor="\${GREEN}"; fi @@ -520,7 +520,7 @@ if [ $SRS_SSL = YES ]; then else echo -e "${YELLOW}warning: without rtmp complex handshake support, donot support h264/aac to adobe flash player${BLACK}" fi -if [ $SRS_FFMPEG = YES ]; then +if [ $SRS_FFMPEG_TOOL = YES ]; then echo -e "${GREEN}transcode/mux/ingest tool FFMPEG is enabled${BLACK}" else echo -e "${YELLOW}warning: without transcode/mux/ingest tool FFMPEG support${BLACK}" @@ -613,7 +613,7 @@ if [ $SRS_NGINX = YES ]; then echo "\" sudo ./objs/nginx/sbin/nginx \" to start the nginx http server for hls" echo "\" http://$ip \" rtmp players(OSMF/JWPlayer)" fi -if [ $SRS_FFMPEG = YES ]; then +if [ $SRS_FFMPEG_TOOL = YES ]; then echo -e "\" ./objs/ffmpeg/bin/ffmpeg \" is used for live stream transcoding" fi if [ $SRS_HTTP_CALLBACK = YES ]; then diff --git a/trunk/src/app/srs_app_encoder.cpp b/trunk/src/app/srs_app_encoder.cpp index 8bdea5bfd..b1811b00e 100644 --- a/trunk/src/app/srs_app_encoder.cpp +++ b/trunk/src/app/srs_app_encoder.cpp @@ -289,7 +289,7 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir // write ffmpeg info to log file. log_file = _srs_config->get_ffmpeg_log_dir(); log_file += "/"; - log_file += "encoder"; + log_file += "ffmpeg-encoder"; log_file += "-"; log_file += req->vhost; log_file += "-"; diff --git a/trunk/src/app/srs_app_ffmpeg.cpp b/trunk/src/app/srs_app_ffmpeg.cpp index 8e7b1c3b1..ce7d9a4df 100644 --- a/trunk/src/app/srs_app_ffmpeg.cpp +++ b/trunk/src/app/srs_app_ffmpeg.cpp @@ -39,7 +39,7 @@ using namespace std; #include #include -#ifdef SRS_FFMPEG +#ifdef SRS_FFMPEG_STUB #define SRS_ENCODER_COPY "copy" #define SRS_ENCODER_NO_VIDEO "vn" diff --git a/trunk/src/app/srs_app_ffmpeg.hpp b/trunk/src/app/srs_app_ffmpeg.hpp index 92ae68424..55aa46310 100644 --- a/trunk/src/app/srs_app_ffmpeg.hpp +++ b/trunk/src/app/srs_app_ffmpeg.hpp @@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#ifdef SRS_FFMPEG +#ifdef SRS_FFMPEG_STUB #include #include diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index 3c84c8a58..23811058a 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -246,7 +246,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S // write ffmpeg info to log file. log_file = _srs_config->get_ffmpeg_log_dir(); log_file += "/"; - log_file += "ingest"; + log_file += "ffmpeg-ingest"; log_file += "-"; log_file += vhost->arg0(); log_file += "-"; @@ -305,6 +305,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S std::string vcodec = _srs_config->get_engine_vcodec(engine); std::string acodec = _srs_config->get_engine_acodec(engine); + // whatever the engine config, use copy as default. if (!engine || !_srs_config->get_engine_enabled(engine) || vcodec.empty() || acodec.empty()) { if ((ret = ffmpeg->initialize_copy()) != ERROR_SUCCESS) { return ret; diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index b31ec9023..ce7f5f475 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -163,6 +163,9 @@ SrsServer::SrsServer() srs_assert(_srs_config); _srs_config->subscribe(this); + // donot new object in constructor, + // for some global instance is not ready now, + // new these objects in initialize instead. #ifdef SRS_HTTP_API http_api_handler = NULL; #endif