diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index c4997f6f7..b680ca369 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -198,7 +198,7 @@ if [ ! -f ${SRS_OBJS}/st-1.9/obj/libst.so ]; then echo "build st-1.9 failed."; e ##################################################################################### # http-parser-2.1 ##################################################################################### -if [ $SRS_HTTP = YES ]; then +if [ $SRS_HTTP_CALLBACK = YES ]; then if [[ -f ${SRS_OBJS}/http-parser-2.1/http_parser.h && -f ${SRS_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then echo "http-parser-2.1 is ok."; else @@ -284,11 +284,11 @@ fi ##################################################################################### # cherrypy for http hooks callback, CherryPy-3.2.4 ##################################################################################### -if [ $SRS_HTTP = YES ]; then +if [ $SRS_HTTP_CALLBACK = YES ]; then if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then echo "CherryPy-3.2.4 is ok."; else - require_sudoer "configure --with-http" + require_sudoer "configure --with-http-callback" echo "install CherryPy-3.2.4"; ( sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} && @@ -301,10 +301,10 @@ if [ $SRS_HTTP = YES ]; then if [ ! -f ${SRS_OBJS}/nginx/sbin/nginx ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi fi -if [ $SRS_HTTP = YES ]; then - echo "#define SRS_HTTP" >> $SRS_AUTO_HEADERS_H +if [ $SRS_HTTP_CALLBACK = YES ]; then + echo "#define SRS_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H else - echo "#undef SRS_HTTP" >> $SRS_AUTO_HEADERS_H + echo "#undef SRS_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H fi echo "link players to cherrypy static-dir" @@ -322,7 +322,7 @@ ln -sf `pwd`/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forwa # only when the nginx is ok, # if api-server not enalbed, use nginx as demo. if [ $SRS_HLS = YES ]; then - if [ $SRS_HTTP = YES ]; then + if [ $SRS_HTTP_CALLBACK = YES ]; then # override the default index. rm -f ${SRS_OBJS}/nginx/html/index.html && ln -sf `pwd`/research/players/nginx_index.html ${SRS_OBJS}/nginx/html/index.html diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 7f5e0e75d..c5917afb6 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -14,7 +14,7 @@ help=no SRS_HLS=RESERVED SRS_SSL=RESERVED SRS_FFMPEG=RESERVED -SRS_HTTP=RESERVED +SRS_HTTP_CALLBACK=RESERVED SRS_LIBRTMP=RESERVED # srs-librtmp SRS_BWTC=RESERVED # srs-bandwidth-test client SRS_RESEARCH=RESERVED @@ -31,7 +31,7 @@ SRS_JOBS=1 SRS_HLS=YES SRS_SSL=YES SRS_FFMPEG=YES -SRS_HTTP=YES +SRS_HTTP_CALLBACK=YES SRS_LIBRTMP=YES SRS_BWTC=NO SRS_RESEARCH=NO @@ -65,7 +65,7 @@ do --with-ssl) SRS_SSL=YES ;; --with-hls) SRS_HLS=YES ;; --with-ffmpeg) SRS_FFMPEG=YES ;; - --with-http) SRS_HTTP=YES ;; + --with-http-callback) SRS_HTTP_CALLBACK=YES ;; --with-librtmp) SRS_LIBRTMP=YES ;; --with-bwtc) SRS_BWTC=YES ;; --with-research) SRS_RESEARCH=YES ;; @@ -79,7 +79,7 @@ do --without-ssl) SRS_SSL=NO ;; --without-hls) SRS_HLS=NO ;; --without-ffmpeg) SRS_FFMPEG=NO ;; - --without-http) SRS_HTTP=NO ;; + --without-http-callback) SRS_HTTP_CALLBACK=NO ;; --without-librtmp) SRS_LIBRTMP=NO ;; --without-bwtc) SRS_BWTC=NO ;; --without-research) SRS_RESEARCH=NO ;; @@ -120,7 +120,7 @@ if [ $help = yes ]; then --with-ssl enable rtmp complex handshake, requires openssl-devel installed. to delivery h264 video and aac audio to flash player. --with-hls enable hls streaming, build nginx as http server for hls. - --with-http enable http hooks, build cherrypy as demo api server. + --with-http-callback enable http hooks, build cherrypy as demo api server. srs will call the http hooks, such as: on_connect. --with-ffmpeg enable transcoding with ffmpeg. --with-librtmp enable srs-librtmp, library for client. @@ -135,7 +135,7 @@ if [ $help = yes ]; then --without-ssl disable rtmp complex handshake. --without-hls disable hls, rtmp streaming only. - --without-http disable http, http hooks callback. + --without-http-callback disable http, http hooks callback. --without-ffmpeg disable the ffmpeg transcoding feature. --without-librtmp disable srs-librtmp, library for client. --without-bwtc disable srs bandwidth test client tool. @@ -185,7 +185,7 @@ fi fi if [ $SRS_HLS = RESERVED ]; then echo "you must specifies the hls, 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_HTTP = RESERVED ]; then echo "you must specifies the http, see: ./configure --help"; __check_ok=NO; fi +if [ $SRS_HTTP_CALLBACK = RESERVED ]; then echo "you must specifies the http, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_LIBRTMP = RESERVED ]; then echo "you must specifies the librtmp, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_BWTC = RESERVED ]; then echo "you must specifies the bwtc, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_RESEARCH = RESERVED ]; then echo "you must specifies the research, see: ./configure --help"; __check_ok=NO; fi @@ -204,7 +204,7 @@ SRS_CONFIGURE="" if [ $SRS_HLS = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-hls"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-hls"; 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_HTTP = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-http"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-http"; fi +if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-http-callback"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-http-callback"; fi if [ $SRS_LIBRTMP = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-librtmp"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-librtmp"; fi if [ $SRS_BWTC = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-bwtc"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-bwtc"; fi if [ $SRS_RESEARCH = YES ]; then SRS_CONFIGURE="${SRS_CONFIGURE} --with-research"; else SRS_CONFIGURE="${SRS_CONFIGURE} --without-research"; fi diff --git a/trunk/conf/ffmpeg.conf b/trunk/conf/ffmpeg.conf new file mode 100755 index 000000000..a9f4fd429 --- /dev/null +++ b/trunk/conf/ffmpeg.conf @@ -0,0 +1,29 @@ +listen 1935; +vhost __defaultVhost__ { + transcode { + enabled on; + ffmpeg ./objs/ffmpeg/bin/ffmpeg; + engine ff { + enabled on; + vfilter { + } + vcodec libx264; + vbitrate 500; + vfps 25; + vwidth 768; + vheight 320; + vthreads 12; + vprofile main; + vpreset medium; + vparams { + } + acodec libaacplus; + abitrate 70; + asample_rate 44100; + achannels 2; + aparams { + } + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; + } + } +} diff --git a/trunk/configure b/trunk/configure index 4b4b57aeb..4d234ba58 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_FFMPEG/SRS_HTTP/SRS_RESEARCH/SRS_UTEST +# srs features: SRS_SSL/SRS_HLS/SRS_FFMPEG/SRS_HTTP_CALLBACK/SRS_RESEARCH/SRS_UTEST # build options: SRS_JOBS ##################################################################################### # parse options, exit with error when parse options invalid. @@ -61,7 +61,7 @@ if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS}/utest; \$(MAKE) SrsHlsSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_HLS = YES ]; then SrsHlsSummaryColor="\$(GREEN)"; fi SrsSslSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_SSL = YES ]; then SrsSslSummaryColor="\$(GREEN)"; fi SrsFfmpegSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_FFMPEG = YES ]; then SrsFfmpegSummaryColor="\$(GREEN)"; fi -SrsHttpSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_HTTP = YES ]; then SrsHttpSummaryColor="\$(GREEN)"; fi +SrsHttpCallbackSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_HTTP_CALLBACK = YES ]; then SrsHttpCallbackSummaryColor="\$(GREEN)"; fi SrsLibrtmpSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_LIBRTMP = YES ]; then SrsLibrtmpSummaryColor="\$(GREEN)"; fi SrsLibrtmpSSLSummaryColor="\$(YELLOW)(disabled) "; if [ $SRS_LIBRTMP = YES ]; then if [ $SRS_SSL = YES ]; then SrsLibrtmpSSLSummaryColor="\$(GREEN)"; fi fi SrsBWTCSummaryColor="\$(GREEN)(disabled) "; if [ $SRS_BWTC = YES ]; then SrsBWTCSummaryColor="\$(GREEN)"; fi @@ -129,8 +129,8 @@ default: bandwidth librtmp-sample utest @echo -e " | ${SrsSslSummaryColor}ssl: support RTMP complex handshake for client required, for instance, flash\$(BLACK)" @echo -e " | ${SrsFfmpegSummaryColor}ffmpeg @see: https://github.com/winlinvip/simple-rtmp-server/wiki/FFMPEG\$(BLACK)" @echo -e " | ${SrsFfmpegSummaryColor}ffmpeg: support transcoding RTMP stream with FFMPEG\$(BLACK)" - @echo -e " | ${SrsHttpSummaryColor}http @see: https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPCallback\$(BLACK)" - @echo -e " | ${SrsHttpSummaryColor}http: support http callback for authentication and event injection\$(BLACK)" + @echo -e " | ${SrsHttpCallbackSummaryColor}http @see: https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPCallback\$(BLACK)" + @echo -e " | ${SrsHttpCallbackSummaryColor}http: support http callback for authentication and event injection\$(BLACK)" @echo -e " \$(BLACK)+------------------------------------------------------------------------------------\$(BLACK)" @echo -e "\$(GREEN)binaries @see: https://github.com/winlinvip/simple-rtmp-server/wiki/Build\$(BLACK)" @@ -256,7 +256,7 @@ END LibSTRoot="${SRS_OBJS}/st"; LibSTfile="${LibSTRoot}/libst.a" # hp(http-parser) the http request/url parser, for SRS to support HTTP callback. LibHttpParserRoot=""; LibHttpParserfile="" -if [ $SRS_HTTP = YES ]; then LibHttpParserRoot="${SRS_OBJS}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi +if [ $SRS_HTTP_CALLBACK = YES ]; then LibHttpParserRoot="${SRS_OBJS}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi # openssl-1.0.1f, for the RTMP complex handshake. LibSSLRoot="";LibSSLfile="" if [ $SRS_SSL = YES ]; then LibSSLRoot="${SRS_OBJS}/openssl/include"; LibSSLfile="${SRS_OBJS}/openssl/lib/libssl.a ${SRS_OBJS}/openssl/lib/libcrypto.a"; fi @@ -383,7 +383,7 @@ if [ $SRS_FFMPEG = YES ]; then else echo -e "${YELLOW}warning: without live stream transcoding over FFMPEG support${BLACK}" fi -if [ $SRS_HTTP = YES ]; then +if [ $SRS_HTTP_CALLBACK = YES ]; then echo -e "${GREEN}http hooks callback over CherryPy is enabled${BLACK}" else echo -e "${YELLOW}warning: without http hooks callback over CherryPy support${BLACK}" @@ -449,7 +449,7 @@ fi if [ $SRS_FFMPEG = YES ]; then echo -e "\" ./objs/ffmpeg/bin/ffmpeg \" is used for live stream transcoding" fi -if [ $SRS_HTTP = YES ]; then +if [ $SRS_HTTP_CALLBACK = YES ]; then echo -e "\" python ./research/api-server/server.py 8085 \" to start the api-server" fi echo "\" ./objs/srs -c conf/srs.conf \" to start the srs live server" diff --git a/trunk/src/app/srs_app_client.cpp b/trunk/src/app/srs_app_client.cpp index 6958e726f..1b37035bf 100644 --- a/trunk/src/app/srs_app_client.cpp +++ b/trunk/src/app/srs_app_client.cpp @@ -52,7 +52,7 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd) skt = new SrsSocket(client_stfd); rtmp = new SrsRtmpServer(skt); refer = new SrsRefer(); -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK http_hooks = new SrsHttpHooks(); #endif bandwidth = new SrsBandwidth(); @@ -70,7 +70,7 @@ SrsClient::~SrsClient() srs_freep(rtmp); srs_freep(skt); srs_freep(refer); -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK srs_freep(http_hooks); #endif srs_freep(bandwidth); @@ -720,7 +720,7 @@ int SrsClient::on_connect() { int ret = ERROR_SUCCESS; -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK // HTTP: on_connect SrsConfDirective* on_connect = _srs_config->get_vhost_on_connect(req->vhost); if (!on_connect) { @@ -742,7 +742,7 @@ int SrsClient::on_connect() void SrsClient::on_close() { -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK // whatever the ret code, notify the api hooks. // HTTP: on_close SrsConfDirective* on_close = _srs_config->get_vhost_on_close(req->vhost); @@ -762,7 +762,7 @@ int SrsClient::on_publish() { int ret = ERROR_SUCCESS; -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK // HTTP: on_publish SrsConfDirective* on_publish = _srs_config->get_vhost_on_publish(req->vhost); if (!on_publish) { @@ -784,7 +784,7 @@ int SrsClient::on_publish() void SrsClient::on_unpublish() { -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK // whatever the ret code, notify the api hooks. // HTTP: on_unpublish SrsConfDirective* on_unpublish = _srs_config->get_vhost_on_unpublish(req->vhost); @@ -804,7 +804,7 @@ int SrsClient::on_play() { int ret = ERROR_SUCCESS; -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK // HTTP: on_play SrsConfDirective* on_play = _srs_config->get_vhost_on_play(req->vhost); if (!on_play) { @@ -826,7 +826,7 @@ int SrsClient::on_play() void SrsClient::on_stop() { -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK // whatever the ret code, notify the api hooks. // HTTP: on_stop SrsConfDirective* on_stop = _srs_config->get_vhost_on_stop(req->vhost); diff --git a/trunk/src/app/srs_app_client.hpp b/trunk/src/app/srs_app_client.hpp index 655a2e447..475219aca 100644 --- a/trunk/src/app/srs_app_client.hpp +++ b/trunk/src/app/srs_app_client.hpp @@ -42,7 +42,7 @@ class SrsRefer; class SrsConsumer; class SrsCommonMessage; class SrsSocket; -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK class SrsHttpHooks; #endif class SrsBandwidth; @@ -59,7 +59,7 @@ private: SrsSocket* skt; SrsRtmpServer* rtmp; SrsRefer* refer; -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK SrsHttpHooks* http_hooks; #endif SrsBandwidth* bandwidth; diff --git a/trunk/src/app/srs_app_http.cpp b/trunk/src/app/srs_app_http.cpp index f710da64c..fd640c02b 100644 --- a/trunk/src/app/srs_app_http.cpp +++ b/trunk/src/app/srs_app_http.cpp @@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK #include diff --git a/trunk/src/app/srs_app_http.hpp b/trunk/src/app/srs_app_http.hpp index 81e4a2557..357911254 100644 --- a/trunk/src/app/srs_app_http.hpp +++ b/trunk/src/app/srs_app_http.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#ifdef SRS_HTTP +#ifdef SRS_HTTP_CALLBACK class SrsRequest; class SrsSocket;