winlin

fix #191: configure --export-librtmp-project and --export-librtmp-single. 2.0.11.

@@ -228,7 +228,7 @@ Supported operating systems and hardware: @@ -228,7 +228,7 @@ Supported operating systems and hardware:
228 * 2013-10-17, Created.<br/> 228 * 2013-10-17, Created.<br/>
229 229
230 ## History 230 ## History
231 -* v2.0, 2014-11-08, fix [#191](https://github.com/winlinvip/simple-rtmp-server/issues/191), configure --export-librtmp. 2.0.10. 231 +* v2.0, 2014-11-08, fix [#191](https://github.com/winlinvip/simple-rtmp-server/issues/191), configure --export-librtmp-project and --export-librtmp-single. 2.0.11.
232 * v2.0, 2014-11-08, fix [#66](https://github.com/winlinvip/simple-rtmp-server/issues/66), srs-librtmp support write h264 raw packet. 2.0.9. 232 * v2.0, 2014-11-08, fix [#66](https://github.com/winlinvip/simple-rtmp-server/issues/66), srs-librtmp support write h264 raw packet. 2.0.9.
233 * v2.0, 2014-10-25, fix [#185](https://github.com/winlinvip/simple-rtmp-server/issues/185), AMF0 support 0x0B the date type codec. 2.0.7. 233 * v2.0, 2014-10-25, fix [#185](https://github.com/winlinvip/simple-rtmp-server/issues/185), AMF0 support 0x0B the date type codec. 2.0.7.
234 * v2.0, 2014-10-24, fix [#186](https://github.com/winlinvip/simple-rtmp-server/issues/186), hotfix for bug #186, drop connect args when not object. 2.0.6. 234 * v2.0, 2014-10-24, fix [#186](https://github.com/winlinvip/simple-rtmp-server/issues/186), hotfix for bug #186, drop connect args when not object. 2.0.6.
@@ -126,7 +126,7 @@ function Ubuntu_prepare() @@ -126,7 +126,7 @@ function Ubuntu_prepare()
126 return 0 126 return 0
127 } 127 }
128 # donot prepare tools, for srs-librtmp depends only gcc and g++. 128 # donot prepare tools, for srs-librtmp depends only gcc and g++.
129 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 129 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
130 Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Ubuntu prepare failed, ret=$ret"; exit $ret; fi 130 Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Ubuntu prepare failed, ret=$ret"; exit $ret; fi
131 fi 131 fi
132 ##################################################################################### 132 #####################################################################################
@@ -217,14 +217,14 @@ function Centos_prepare() @@ -217,14 +217,14 @@ function Centos_prepare()
217 return 0 217 return 0
218 } 218 }
219 # donot prepare tools, for srs-librtmp depends only gcc and g++. 219 # donot prepare tools, for srs-librtmp depends only gcc and g++.
220 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 220 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
221 Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, ret=$ret"; exit $ret; fi 221 Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, ret=$ret"; exit $ret; fi
222 fi 222 fi
223 223
224 ##################################################################################### 224 #####################################################################################
225 # st-1.9 225 # st-1.9
226 ##################################################################################### 226 #####################################################################################
227 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 227 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
228 # check the arm flag file, if flag changed, need to rebuild the st. 228 # check the arm flag file, if flag changed, need to rebuild the st.
229 _ST_MAKE=linux-debug 229 _ST_MAKE=linux-debug
230 if [ $SRS_EMBEDED_CPU = YES ]; then 230 if [ $SRS_EMBEDED_CPU = YES ]; then
@@ -343,7 +343,7 @@ function write_nginx_html5() @@ -343,7 +343,7 @@ function write_nginx_html5()
343 END 343 END
344 } 344 }
345 # create the nginx dir, for http-server if not build nginx 345 # create the nginx dir, for http-server if not build nginx
346 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 346 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
347 mkdir -p ${SRS_OBJS}/nginx 347 mkdir -p ${SRS_OBJS}/nginx
348 fi 348 fi
349 # make nginx 349 # make nginx
@@ -372,7 +372,7 @@ if [ $__SRS_BUILD_NGINX = YES ]; then @@ -372,7 +372,7 @@ if [ $__SRS_BUILD_NGINX = YES ]; then
372 fi 372 fi
373 373
374 # the demo dir. 374 # the demo dir.
375 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 375 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
376 # create forward dir 376 # create forward dir
377 mkdir -p ${SRS_OBJS}/nginx/html/live && 377 mkdir -p ${SRS_OBJS}/nginx/html/live &&
378 mkdir -p ${SRS_OBJS}/nginx/html/forward/live 378 mkdir -p ${SRS_OBJS}/nginx/html/forward/live
@@ -595,7 +595,7 @@ fi @@ -595,7 +595,7 @@ fi
595 ##################################################################################### 595 #####################################################################################
596 # build research code, librtmp 596 # build research code, librtmp
597 ##################################################################################### 597 #####################################################################################
598 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 598 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
599 if [ $SRS_RESEARCH = YES ]; then 599 if [ $SRS_RESEARCH = YES ]; then
600 mkdir -p ${SRS_OBJS}/research 600 mkdir -p ${SRS_OBJS}/research
601 601
  1 +#!/bin/bash
  2 +
  3 +# when export srs-librtmp project
  4 +# set the SRS_WORKDIR and SRS_OBJS,
  5 +# then copy the srs-librtmp needed files.
  6 +#
  7 +# params:
  8 +# $SRS_WORKDIR the work dir. ie. .
  9 +# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
  10 +# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
  11 +# $SRS_EXPORT_LIBRTMP_PROJECT the export srs-librtmp project path. ie. srs-librtmp
  12 +#
  13 +
  14 +if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  15 + if [[ -d ${SRS_EXPORT_LIBRTMP_PROJECT} ]]; then
  16 + echo -e "${RED}srs-librtmp target dir exists: ${SRS_EXPORT_LIBRTMP_PROJECT}. ${BLACK}"
  17 + exit 1
  18 + fi
  19 + # create target
  20 + SRS_WORKDIR=${SRS_EXPORT_LIBRTMP_PROJECT} && SRS_OBJS=${SRS_WORKDIR}/${SRS_OBJS_DIR} && mkdir -p ${SRS_OBJS} &&
  21 + # copy src to target
  22 + _CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/research/librtmp && mkdir -p ${_CPT} && cp research/librtmp/*.c research/librtmp/Makefile ${_CPT} &&
  23 + _CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/auto && mkdir -p ${_CPT} && cp auto/generate_header.sh auto/generate-srs-librtmp-single.sh ${_CPT} &&
  24 + _CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/core && mkdir -p ${_CPT} && cp src/core/* ${_CPT} &&
  25 + _CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/kernel && mkdir -p ${_CPT} && cp src/kernel/* ${_CPT} &&
  26 + _CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/rtmp && mkdir -p ${_CPT} && cp src/rtmp/* ${_CPT} &&
  27 + _CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/libs && mkdir -p ${_CPT} && cp src/libs/* ${_CPT}
  28 + # check ret
  29 + ret=$?; if [[ $ret -ne 0 ]]; then echo "export src failed, ret=$ret"; exit $ret; fi
  30 +fi
  1 +#!/bin/bash
  2 +
  3 +# when export srs-librtmp single files
  4 +# package the whole project to srs_librtmp.h and srs_librtmp.cpp
  5 +#
  6 +# params:
  7 +# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
  8 +# $SRS_EXPORT_LIBRTMP_SINGLE the export srs-librtmp single path. ie. srs-librtmp
  9 +#
  10 +
  11 +# the target dir must created
  12 +if [[ ! -d $SRS_EXPORT_LIBRTMP_SINGLE ]]; then
  13 + echo -e "${RED}error, target dir not created: $SRS_EXPORT_LIBRTMP_SINGLE${BLACK}"
  14 + exit -1
  15 +fi
  16 +
  17 +# generate the srs_librtmp.h
  18 +cp $SRS_EXPORT_LIBRTMP_SINGLE/src/libs/srs_librtmp.hpp $SRS_EXPORT_LIBRTMP_SINGLE/srs_librtmp.h
  19 +
  20 +# create srs_librtmp.cpp
  21 +FILE=$SRS_EXPORT_LIBRTMP_SINGLE/srs_librtmp.cpp
  22 +cat << END >$FILE
  23 +/*
  24 +The MIT License (MIT)
  25 +
  26 +Copyright (c) 2013-2014 winlin
  27 +
  28 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  29 +this software and associated documentation files (the "Software"), to deal in
  30 +the Software without restriction, including without limitation the rights to
  31 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  32 +the Software, and to permit persons to whom the Software is furnished to do so,
  33 +subject to the following conditions:
  34 +
  35 +The above copyright notice and this permission notice shall be included in all
  36 +copies or substantial portions of the Software.
  37 +
  38 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  40 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  41 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  42 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  43 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  44 +*/
  45 +
  46 +#include "srs_librtmp.h"
  47 +
  48 +END
  49 +# build objs auto files to cpp
  50 +cat $SRS_EXPORT_LIBRTMP_SINGLE/$SRS_OBJS_DIR/srs_auto_headers.hpp >>$FILE
  51 +ret=$?; if [[ $ret -ne 0 ]]; then
  52 + echo -e "${RED}failed to generate the srs_librtmp.cpp${BLACK}"
  53 + exit $ret
  54 +fi
  55 +# module to cpp files.
  56 +function build_module_hpp()
  57 +{
  58 + echo "build files ${SRS_LIBRTMP_OBJS} to $FILE"
  59 + for item in ${SRS_LIBRTMP_OBJS[*]}; do
  60 + FILE_NAME="${item%.*}"
  61 + echo "// following is generated by ${FILE_NAME}.hpp" >> $FILE &&
  62 + sed -i "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp &&
  63 + cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp >>$FILE
  64 + ret=$?; if [[ $ret -ne 0 ]]; then
  65 + echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.hpp. {${BLACK}"
  66 + exit $ret
  67 + fi
  68 + done
  69 +}
  70 +SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_hpp
  71 +SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_hpp
  72 +SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_hpp
  73 +SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_hpp
  74 +# module to cpp files.
  75 +function build_module_cpp()
  76 +{
  77 + echo "build files ${SRS_LIBRTMP_OBJS} to $FILE"
  78 + for item in ${SRS_LIBRTMP_OBJS[*]}; do
  79 + FILE_NAME="${item%.*}"
  80 + echo "// following is generated by ${FILE_NAME}.cpp" >> $FILE &&
  81 + sed -i "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp &&
  82 + cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp >>$FILE
  83 + ret=$?; if [[ $ret -ne 0 ]]; then
  84 + echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.cpp. {${BLACK}"
  85 + exit $ret
  86 + fi
  87 + done
  88 +}
  89 +SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_cpp
  90 +SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_cpp
  91 +SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_cpp
  92 +SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_cpp
  93 +
  94 +# create example.cpp
  95 +FILE=$SRS_EXPORT_LIBRTMP_SINGLE/example.c
  96 +COMPILE='gcc example.c srs_librtmp.cpp -g -O0 -lstdc++ -o example'
  97 +cat << END >$FILE
  98 +/**
  99 +# Example to use srs-librtmp
  100 +# see: https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_SrsLibrtmp
  101 +${COMPILE}
  102 +*/
  103 +#include <stdio.h>
  104 +#include "srs_librtmp.h"
  105 +
  106 +int main(int argc, char** argv)
  107 +{
  108 + printf("Example for srs-librtmp\n");
  109 + printf("SRS(simple-rtmp-server) client librtmp library.\n");
  110 + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
  111 +
  112 + srs_rtmp_t rtmp = srs_rtmp_create("rtmp://ossrs.net/live/livestream");
  113 + srs_trace("create rtmp success");
  114 + srs_rtmp_destroy(rtmp);
  115 +
  116 + return 0;
  117 +}
  118 +
  119 +END
  120 +
  121 +# compile the example
  122 +(cd $SRS_EXPORT_LIBRTMP_SINGLE && `${COMPILE}` && ./example && rm -f example)
  123 +ret=$?; if [[ $ret -ne 0 ]]; then
  124 + echo "(cd $SRS_EXPORT_LIBRTMP_SINGLE && ${COMPILE} && ./example && rm -f example)"
  125 + echo -e "${RED}failed to compile example.${BLACK}"
  126 + exit $ret
  127 +fi
  128 +
  129 +# clear the files for srs-librtmp project, generated by generate-srs-librtmp-project.sh
  130 +(cd $SRS_EXPORT_LIBRTMP_SINGLE && rm -rf auto $SRS_OBJS_DIR research src Makefile)
@@ -58,8 +58,10 @@ SRS_LOG_TRACE=RESERVED @@ -58,8 +58,10 @@ SRS_LOG_TRACE=RESERVED
58 # experts 58 # experts
59 # donot compile ssl, use system ssl(-lssl) if required. 59 # donot compile ssl, use system ssl(-lssl) if required.
60 SRS_USE_SYS_SSL=NO 60 SRS_USE_SYS_SSL=NO
61 -# export the srs-librtmp to specified path, NO to disable it.  
62 -SRS_EXPORT_LIBRTMP=NO 61 +# export the srs-librtmp to specified project, NO to disable it.
  62 +SRS_EXPORT_LIBRTMP_PROJECT=NO
  63 +# export the srs-librtmp to a single .h and .c, NO to disable it.
  64 +SRS_EXPORT_LIBRTMP_SINGLE=NO
63 # 65 #
64 ################################################################ 66 ################################################################
65 # presets 67 # presets
@@ -183,8 +185,9 @@ Conflicts: @@ -183,8 +185,9 @@ Conflicts:
183 the complex tools not available for arm. 185 the complex tools not available for arm.
184 186
185 Experts: 187 Experts:
186 - --use-sys-ssl donot compile ssl, use system ssl(-lssl) if required.  
187 - --export-librtmp=<path> export srs-librtmp to specified path. 188 + --use-sys-ssl donot compile ssl, use system ssl(-lssl) if required.
  189 + --export-librtmp-project=<path> export srs-librtmp to specified project in path.
  190 + --export-librtmp-single=<path> export srs-librtmp to a single file(.h+.cpp) in path.
188 191
189 Workflow: 192 Workflow:
190 1. apply "Presets". if not specified, use default preset. 193 1. apply "Presets". if not specified, use default preset.
@@ -266,7 +269,8 @@ function parse_user_option() { @@ -266,7 +269,8 @@ function parse_user_option() {
266 --full) SRS_ENABLE_ALL=YES ;; 269 --full) SRS_ENABLE_ALL=YES ;;
267 270
268 --use-sys-ssl) SRS_USE_SYS_SSL=YES ;; 271 --use-sys-ssl) SRS_USE_SYS_SSL=YES ;;
269 - --export-librtmp) SRS_EXPORT_LIBRTMP=${value} ;; 272 + --export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;;
  273 + --export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;;
270 274
271 *) 275 *)
272 echo "$0: error: invalid option \"$option\"" 276 echo "$0: error: invalid option \"$option\""
@@ -701,8 +705,13 @@ function apply_user_detail_options() { @@ -701,8 +705,13 @@ function apply_user_detail_options() {
701 export SRS_JOBS="--jobs=${SRS_JOBS}" 705 export SRS_JOBS="--jobs=${SRS_JOBS}"
702 fi 706 fi
703 707
  708 + # if specified export single file, export project first.
  709 + if [ $SRS_EXPORT_LIBRTMP_SINGLE != NO ]; then
  710 + SRS_EXPORT_LIBRTMP_PROJECT=$SRS_EXPORT_LIBRTMP_SINGLE
  711 + fi
  712 +
704 # disable almost all features for export srs-librtmp. 713 # disable almost all features for export srs-librtmp.
705 - if [ $SRS_EXPORT_LIBRTMP != NO ]; then 714 + if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
706 SRS_HLS=NO 715 SRS_HLS=NO
707 SRS_DVR=NO 716 SRS_DVR=NO
708 SRS_NGINX=NO 717 SRS_NGINX=NO
@@ -21,7 +21,7 @@ SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then @@ -21,7 +21,7 @@ SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then
21 SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi 21 SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
22 SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi 22 SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi
23 23
24 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 24 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
25 cat <<END > ${SRS_OBJS}/${SRS_BUILD_SUMMARY} 25 cat <<END > ${SRS_OBJS}/${SRS_BUILD_SUMMARY}
26 #!/bin/bash 26 #!/bin/bash
27 27
@@ -25,30 +25,14 @@ BLACK="\\e[0m" @@ -25,30 +25,14 @@ BLACK="\\e[0m"
25 . auto/options.sh 25 . auto/options.sh
26 26
27 # for export srs-librtmp, change target to it. 27 # for export srs-librtmp, change target to it.
28 -if [ $SRS_EXPORT_LIBRTMP != NO ]; then  
29 - if [[ -d ${SRS_EXPORT_LIBRTMP} ]]; then  
30 - echo -e "${RED}srs-librtmp target dir exists: ${SRS_EXPORT_LIBRTMP}. ${BLACK}"  
31 - exit 1  
32 - fi  
33 - # create target  
34 - SRS_WORKDIR=${SRS_EXPORT_LIBRTMP} && SRS_OBJS=${SRS_WORKDIR}/${SRS_OBJS_DIR} && mkdir -p ${SRS_OBJS} &&  
35 - # copy src to target  
36 - _CPT=${SRS_EXPORT_LIBRTMP}/research/librtmp && mkdir -p ${_CPT} && cp research/librtmp/*.c research/librtmp/Makefile ${_CPT} &&  
37 - _CPT=${SRS_EXPORT_LIBRTMP}/auto && mkdir -p ${_CPT} && cp auto/generate_header.sh ${_CPT} &&  
38 - _CPT=${SRS_EXPORT_LIBRTMP}/src/core && mkdir -p ${_CPT} && cp src/core/* ${_CPT} &&  
39 - _CPT=${SRS_EXPORT_LIBRTMP}/src/kernel && mkdir -p ${_CPT} && cp src/kernel/* ${_CPT} &&  
40 - _CPT=${SRS_EXPORT_LIBRTMP}/src/rtmp && mkdir -p ${_CPT} && cp src/rtmp/* ${_CPT} &&  
41 - _CPT=${SRS_EXPORT_LIBRTMP}/src/libs && mkdir -p ${_CPT} && cp src/libs/* ${_CPT}  
42 - # check ret  
43 - ret=$?; if [[ $ret -ne 0 ]]; then echo "export src failed, ret=$ret"; exit $ret; fi  
44 -fi 28 +. auto/generate-srs-librtmp-project.sh
45 29
46 # the auto generated variables. 30 # the auto generated variables.
47 SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp" 31 SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
48 32
49 # clean the exists, when not export srs-librtmp. 33 # clean the exists, when not export srs-librtmp.
50 # do this only when the options is ok. 34 # do this only when the options is ok.
51 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 35 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
52 if [[ -f Makefile ]]; then 36 if [[ -f Makefile ]]; then
53 make clean 37 make clean
54 fi 38 fi
@@ -186,7 +170,7 @@ clean: @@ -186,7 +170,7 @@ clean:
186 END 170 END
187 171
188 # if export librtmp, donot build the srs server. 172 # if export librtmp, donot build the srs server.
189 -if [ $SRS_EXPORT_LIBRTMP != NO ]; then 173 +if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
190 cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE} 174 cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
191 server: _prepare_dir 175 server: _prepare_dir
192 @echo "donot build the srs(simple rtmp server) for srs-librtmp" 176 @echo "donot build the srs(simple rtmp server) for srs-librtmp"
@@ -202,7 +186,7 @@ END @@ -202,7 +186,7 @@ END
202 fi 186 fi
203 187
204 # disable install entry for srs-librtmp 188 # disable install entry for srs-librtmp
205 -if [ $SRS_EXPORT_LIBRTMP != NO ]; then 189 +if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
206 cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE} 190 cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
207 uninstall: 191 uninstall:
208 @echo "disable uninstall for srs-librtmp" 192 @echo "disable uninstall for srs-librtmp"
@@ -395,7 +379,7 @@ RTMP_INCS="src/rtmp"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh @@ -395,7 +379,7 @@ RTMP_INCS="src/rtmp"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh
395 RTMP_OBJS="${MODULE_OBJS[@]}" 379 RTMP_OBJS="${MODULE_OBJS[@]}"
396 # 380 #
397 #App Module 381 #App Module
398 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 382 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
399 MODULE_ID="APP" 383 MODULE_ID="APP"
400 MODULE_DEPENDS=("CORE" "KERNEL" "RTMP") 384 MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
401 ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS_DIR}) 385 ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS_DIR})
@@ -418,7 +402,7 @@ LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh @@ -418,7 +402,7 @@ LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
418 LIBS_OBJS="${MODULE_OBJS[@]}" 402 LIBS_OBJS="${MODULE_OBJS[@]}"
419 # 403 #
420 #Main Module 404 #Main Module
421 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 405 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
422 MODULE_ID="MAIN" 406 MODULE_ID="MAIN"
423 MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP") 407 MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
424 ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot}) 408 ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot})
@@ -432,7 +416,7 @@ fi @@ -432,7 +416,7 @@ fi
432 # then link to a binary, for example, objs/srs 416 # then link to a binary, for example, objs/srs
433 # 417 #
434 # disable all app when export librtmp 418 # disable all app when export librtmp
435 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 419 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
436 # all main entrances 420 # all main entrances
437 MAIN_ENTRANCES=("srs_main_server") 421 MAIN_ENTRANCES=("srs_main_server")
438 # 422 #
@@ -464,13 +448,27 @@ if [ $SRS_UTEST = YES ]; then @@ -464,13 +448,27 @@ if [ $SRS_UTEST = YES ]; then
464 LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh 448 LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
465 fi 449 fi
466 450
  451 +# for srs-librtmp single file,
  452 +# package the whole project to srs_librtmp.h and srs_librtmp.cpp
  453 +if [ $SRS_EXPORT_LIBRTMP_SINGLE != NO ]; then
  454 + echo "package the whole project to srs_librtmp.h and srs_librtmp.cpp"
  455 + . $SRS_EXPORT_LIBRTMP_SINGLE/auto/generate-srs-librtmp-single.sh
  456 + echo -e "${GREEN}Please use the srs-librtmp files: ${BLACK}"
  457 + echo -e "${GREEN} $SRS_EXPORT_LIBRTMP_PROJECT/srs_librtmp.h ${BLACK}"
  458 + echo -e "${GREEN} $SRS_EXPORT_LIBRTMP_PROJECT/srs_librtmp.cpp ${BLACK}"
  459 + echo -e "${GREEN} $SRS_EXPORT_LIBRTMP_PROJECT/example.c ${BLACK}"
  460 +elif [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  461 + echo -e "${GREEN}Please use the srs-librtmp project: ${BLACK}"
  462 + echo -e "${GREEN} cd $SRS_EXPORT_LIBRTMP_PROJECT && make ${BLACK}"
  463 +fi
  464 +
467 echo 'configure ok! ' 465 echo 'configure ok! '
468 466
469 ##################################################################################### 467 #####################################################################################
470 # when configure success, prepare build 468 # when configure success, prepare build
471 ##################################################################################### 469 #####################################################################################
472 # create objs/logs for ffmpeg to write log. 470 # create objs/logs for ffmpeg to write log.
473 -if [ $SRS_EXPORT_LIBRTMP = NO ]; then 471 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
474 mkdir -p ${SRS_OBJS}/logs 472 mkdir -p ${SRS_OBJS}/logs
475 fi 473 fi
476 474
@@ -478,127 +476,131 @@ fi @@ -478,127 +476,131 @@ fi
478 # configure summary 476 # configure summary
479 ##################################################################################### 477 #####################################################################################
480 # summary 478 # summary
481 -echo ""  
482 -echo "configure summary:"  
483 -echo " ${SRS_AUTO_USER_CONFIGURE}"  
484 -echo " ${SRS_AUTO_CONFIGURE}"  
485 -if [ $SRS_HLS = YES ]; then  
486 - echo -e "${GREEN}HLS is enabled${BLACK}"  
487 -else  
488 - echo -e "${YELLOW}warning: without HLS support${BLACK}"  
489 -fi  
490 -if [ $SRS_NGINX = YES ]; then  
491 - echo -e "${GREEN}Nginx http server is enabled${BLACK}"  
492 -else  
493 - echo -e "${GREEN}note: Nginx http server is disabled${BLACK}"  
494 -fi  
495 -if [ $SRS_DVR = YES ]; then  
496 - echo -e "${GREEN}DVR is enabled${BLACK}"  
497 -else  
498 - echo -e "${YELLOW}warning: without DVR support${BLACK}"  
499 -fi  
500 -if [ $SRS_SSL = YES ]; then  
501 - echo -e "${GREEN}rtmp complex handshake is enabled${BLACK}"  
502 -else  
503 - echo -e "${YELLOW}warning: without rtmp complex handshake support, donot support h264/aac to adobe flash player${BLACK}"  
504 -fi  
505 -if [ $SRS_FFMPEG_TOOL = YES ]; then  
506 - echo -e "${GREEN}transcode/mux/ingest tool FFMPEG is enabled${BLACK}"  
507 -else  
508 - echo -e "${YELLOW}warning: without transcode/mux/ingest tool FFMPEG support${BLACK}"  
509 -fi  
510 -if [ $SRS_TRANSCODE = YES ]; then  
511 - echo -e "${GREEN}transcoding RTMP stream is enabled${BLACK}"  
512 -else  
513 - echo -e "${YELLOW}warning: without transcoding RTMP stream support${BLACK}"  
514 -fi  
515 -if [ $SRS_INGEST = YES ]; then  
516 - echo -e "${GREEN}ingest file/stream/device is enabled${BLACK}"  
517 -else  
518 - echo -e "${YELLOW}warning: without ingest file/stream/device support${BLACK}"  
519 -fi  
520 -if [ $SRS_HTTP_CALLBACK = YES ]; then  
521 - echo -e "${GREEN}http hooks callback over CherryPy is enabled${BLACK}"  
522 -else  
523 - echo -e "${YELLOW}warning: without http hooks callback over CherryPy support${BLACK}"  
524 -fi  
525 -if [ $SRS_HTTP_SERVER = YES ]; then  
526 - echo -e "${GREEN}http server to delivery http stream is enabled${BLACK}"  
527 -else  
528 - echo -e "${YELLOW}warning: without http server to delivery http stream support${BLACK}"  
529 -fi  
530 -if [ $SRS_HTTP_API = YES ]; then  
531 - echo -e "${GREEN}http api to manage server is enabled${BLACK}"  
532 -else  
533 - echo -e "${YELLOW}warning: without http api to manage server support${BLACK}"  
534 -fi  
535 -if [ $SRS_LIBRTMP = YES ]; then  
536 - echo -e "${GREEN}srs-librtmp for client is enabled${BLACK}"  
537 -else  
538 - echo -e "${YELLOW}note: srs-librtmp for client is disabled${BLACK}"  
539 -fi  
540 -if [ $SRS_RESEARCH = YES ]; then  
541 - echo -e "${GREEN}research tools are builded${BLACK}"  
542 -else  
543 - echo -e "${GREEN}note: research tools are not builded${BLACK}"  
544 -fi  
545 -if [ $SRS_UTEST = YES ]; then  
546 - echo -e "${GREEN}utest for srs are builded${BLACK}"  
547 -else  
548 - echo -e "${YELLOW}note: utest for srs are not builded${BLACK}"  
549 -fi  
550 -if [ $SRS_GPERF = YES ]; then  
551 - echo -e "${GREEN}gperf(tcmalloc) for srs are builded${BLACK}"  
552 -else  
553 - echo -e "${GREEN}note: gperf(tcmalloc) for srs are not builded${BLACK}"  
554 -fi  
555 -if [ $SRS_GPERF_MC = YES ]; then  
556 - echo -e "${YELLOW}gmc(gperf memory check) for srs are builded -- Performance may suffer${BLACK}"  
557 -else  
558 - echo -e "${GREEN}note: gmc(gperf memory check) for srs are not builded${BLACK}"  
559 -fi  
560 -if [ $SRS_GPERF_MP = YES ]; then  
561 - echo -e "${YELLOW}gmp(gperf memory profile) for srs are builded -- Performance may suffer${BLACK}"  
562 -else  
563 - echo -e "${GREEN}note: gmp(gperf memory profile) for srs are not builded${BLACK}"  
564 -fi  
565 -if [ $SRS_GPERF_CP = YES ]; then  
566 - echo -e "${YELLOW}gcp(gperf cpu profile) for srs are builded -- Performance may suffer${BLACK}"  
567 -else  
568 - echo -e "${GREEN}note: gcp(gperf cpu profile) for srs are not builded${BLACK}"  
569 -fi  
570 -if [ $SRS_GPROF = YES ]; then  
571 - echo -e "${YELLOW}gprof(GNU profile tool) for srs are builded -- Performance may suffer${BLACK}"  
572 -else  
573 - echo -e "${GREEN}note: gprof(GNU profile tool) for srs are not builded${BLACK}"  
574 -fi  
575 -if [ $SRS_ARM_UBUNTU12 = YES ]; then  
576 - echo -e "${GREEN}arm-ubuntu12(armhf, v7cpu) for srs are builded${BLACK}"  
577 -else  
578 - echo -e "${GREEN}note: arm-ubuntu12(armhf, v7cpu) for srs are not builded${BLACK}"  
579 -fi  
580 -if [ $SRS_MIPS_UBUNTU12 = YES ]; then  
581 - echo -e "${GREEN}mips-ubuntu12 for srs are builded${BLACK}"  
582 -else  
583 - echo -e "${GREEN}note: mips-ubuntu12 for srs are not builded${BLACK}" 479 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  480 + echo ""
  481 + echo "configure summary:"
  482 + echo " ${SRS_AUTO_USER_CONFIGURE}"
  483 + echo " ${SRS_AUTO_CONFIGURE}"
  484 + if [ $SRS_HLS = YES ]; then
  485 + echo -e "${GREEN}HLS is enabled${BLACK}"
  486 + else
  487 + echo -e "${YELLOW}warning: without HLS support${BLACK}"
  488 + fi
  489 + if [ $SRS_NGINX = YES ]; then
  490 + echo -e "${GREEN}Nginx http server is enabled${BLACK}"
  491 + else
  492 + echo -e "${GREEN}note: Nginx http server is disabled${BLACK}"
  493 + fi
  494 + if [ $SRS_DVR = YES ]; then
  495 + echo -e "${GREEN}DVR is enabled${BLACK}"
  496 + else
  497 + echo -e "${YELLOW}warning: without DVR support${BLACK}"
  498 + fi
  499 + if [ $SRS_SSL = YES ]; then
  500 + echo -e "${GREEN}rtmp complex handshake is enabled${BLACK}"
  501 + else
  502 + echo -e "${YELLOW}warning: without rtmp complex handshake support, donot support h264/aac to adobe flash player${BLACK}"
  503 + fi
  504 + if [ $SRS_FFMPEG_TOOL = YES ]; then
  505 + echo -e "${GREEN}transcode/mux/ingest tool FFMPEG is enabled${BLACK}"
  506 + else
  507 + echo -e "${YELLOW}warning: without transcode/mux/ingest tool FFMPEG support${BLACK}"
  508 + fi
  509 + if [ $SRS_TRANSCODE = YES ]; then
  510 + echo -e "${GREEN}transcoding RTMP stream is enabled${BLACK}"
  511 + else
  512 + echo -e "${YELLOW}warning: without transcoding RTMP stream support${BLACK}"
  513 + fi
  514 + if [ $SRS_INGEST = YES ]; then
  515 + echo -e "${GREEN}ingest file/stream/device is enabled${BLACK}"
  516 + else
  517 + echo -e "${YELLOW}warning: without ingest file/stream/device support${BLACK}"
  518 + fi
  519 + if [ $SRS_HTTP_CALLBACK = YES ]; then
  520 + echo -e "${GREEN}http hooks callback over CherryPy is enabled${BLACK}"
  521 + else
  522 + echo -e "${YELLOW}warning: without http hooks callback over CherryPy support${BLACK}"
  523 + fi
  524 + if [ $SRS_HTTP_SERVER = YES ]; then
  525 + echo -e "${GREEN}http server to delivery http stream is enabled${BLACK}"
  526 + else
  527 + echo -e "${YELLOW}warning: without http server to delivery http stream support${BLACK}"
  528 + fi
  529 + if [ $SRS_HTTP_API = YES ]; then
  530 + echo -e "${GREEN}http api to manage server is enabled${BLACK}"
  531 + else
  532 + echo -e "${YELLOW}warning: without http api to manage server support${BLACK}"
  533 + fi
  534 + if [ $SRS_LIBRTMP = YES ]; then
  535 + echo -e "${GREEN}srs-librtmp for client is enabled${BLACK}"
  536 + else
  537 + echo -e "${YELLOW}note: srs-librtmp for client is disabled${BLACK}"
  538 + fi
  539 + if [ $SRS_RESEARCH = YES ]; then
  540 + echo -e "${GREEN}research tools are builded${BLACK}"
  541 + else
  542 + echo -e "${GREEN}note: research tools are not builded${BLACK}"
  543 + fi
  544 + if [ $SRS_UTEST = YES ]; then
  545 + echo -e "${GREEN}utest for srs are builded${BLACK}"
  546 + else
  547 + echo -e "${YELLOW}note: utest for srs are not builded${BLACK}"
  548 + fi
  549 + if [ $SRS_GPERF = YES ]; then
  550 + echo -e "${GREEN}gperf(tcmalloc) for srs are builded${BLACK}"
  551 + else
  552 + echo -e "${GREEN}note: gperf(tcmalloc) for srs are not builded${BLACK}"
  553 + fi
  554 + if [ $SRS_GPERF_MC = YES ]; then
  555 + echo -e "${YELLOW}gmc(gperf memory check) for srs are builded -- Performance may suffer${BLACK}"
  556 + else
  557 + echo -e "${GREEN}note: gmc(gperf memory check) for srs are not builded${BLACK}"
  558 + fi
  559 + if [ $SRS_GPERF_MP = YES ]; then
  560 + echo -e "${YELLOW}gmp(gperf memory profile) for srs are builded -- Performance may suffer${BLACK}"
  561 + else
  562 + echo -e "${GREEN}note: gmp(gperf memory profile) for srs are not builded${BLACK}"
  563 + fi
  564 + if [ $SRS_GPERF_CP = YES ]; then
  565 + echo -e "${YELLOW}gcp(gperf cpu profile) for srs are builded -- Performance may suffer${BLACK}"
  566 + else
  567 + echo -e "${GREEN}note: gcp(gperf cpu profile) for srs are not builded${BLACK}"
  568 + fi
  569 + if [ $SRS_GPROF = YES ]; then
  570 + echo -e "${YELLOW}gprof(GNU profile tool) for srs are builded -- Performance may suffer${BLACK}"
  571 + else
  572 + echo -e "${GREEN}note: gprof(GNU profile tool) for srs are not builded${BLACK}"
  573 + fi
  574 + if [ $SRS_ARM_UBUNTU12 = YES ]; then
  575 + echo -e "${GREEN}arm-ubuntu12(armhf, v7cpu) for srs are builded${BLACK}"
  576 + else
  577 + echo -e "${GREEN}note: arm-ubuntu12(armhf, v7cpu) for srs are not builded${BLACK}"
  578 + fi
  579 + if [ $SRS_MIPS_UBUNTU12 = YES ]; then
  580 + echo -e "${GREEN}mips-ubuntu12 for srs are builded${BLACK}"
  581 + else
  582 + echo -e "${GREEN}note: mips-ubuntu12 for srs are not builded${BLACK}"
  583 + fi
584 fi 584 fi
585 585
586 ##################################################################################### 586 #####################################################################################
587 # next step 587 # next step
588 ##################################################################################### 588 #####################################################################################
589 -ip=`ifconfig|grep "inet addr"| grep -v "127.0.0.1"|awk '{print $2}'|awk -F ':' 'NR==1 {print $2}'`  
590 -echo ""  
591 -echo "to run 3rdparty application:"  
592 -if [ $SRS_NGINX = YES ]; then  
593 - echo "\" sudo ./objs/nginx/sbin/nginx \" to start the nginx http server for hls"  
594 -fi  
595 -if [ $SRS_FFMPEG_TOOL = YES ]; then  
596 - echo -e "\" ./objs/ffmpeg/bin/ffmpeg \" is used for live stream transcoding"  
597 -fi  
598 -if [ $SRS_HTTP_CALLBACK = YES ]; then  
599 - echo -e "\" python ./research/api-server/server.py 8085 \" to start the api-server" 589 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  590 + ip=`ifconfig|grep "inet addr"| grep -v "127.0.0.1"|awk '{print $2}'|awk -F ':' 'NR==1 {print $2}'`
  591 + echo ""
  592 + echo "to run 3rdparty application:"
  593 + if [ $SRS_NGINX = YES ]; then
  594 + echo "\" sudo ./objs/nginx/sbin/nginx \" to start the nginx http server for hls"
  595 + fi
  596 + if [ $SRS_FFMPEG_TOOL = YES ]; then
  597 + echo -e "\" ./objs/ffmpeg/bin/ffmpeg \" is used for live stream transcoding"
  598 + fi
  599 + if [ $SRS_HTTP_CALLBACK = YES ]; then
  600 + echo -e "\" python ./research/api-server/server.py 8085 \" to start the api-server"
  601 + fi
  602 + echo ""
  603 + echo "to build:"
  604 + echo "\" make \" to build the srs(simple rtmp server)."
  605 + echo "\" make help \" to get the usage of make"
600 fi 606 fi
601 -echo ""  
602 -echo "to build:"  
603 -echo "\" make \" to build the srs(simple rtmp server)."  
604 -echo "\" make help \" to get the usage of make"  
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 10 34 +#define VERSION_REVISION 11
35 // server info. 35 // server info.
36 #define RTMP_SIG_SRS_KEY "SRS" 36 #define RTMP_SIG_SRS_KEY "SRS"
37 #define RTMP_SIG_SRS_ROLE "origin/edge server" 37 #define RTMP_SIG_SRS_ROLE "origin/edge server"
@@ -30,10 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -30,10 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #include <sstream> 30 #include <sstream>
31 using namespace std; 31 using namespace std;
32 32
33 -// undefine the log of librtmp for the srs use its log.  
34 -#undef srs_trace  
35 -#undef srs_verbose  
36 -  
37 #include <srs_kernel_error.hpp> 33 #include <srs_kernel_error.hpp>
38 #include <srs_protocol_rtmp.hpp> 34 #include <srs_protocol_rtmp.hpp>
39 #include <srs_lib_simple_socket.hpp> 35 #include <srs_lib_simple_socket.hpp>
@@ -48,7 +44,7 @@ using namespace std; @@ -48,7 +44,7 @@ using namespace std;
48 #include <srs_kernel_file.hpp> 44 #include <srs_kernel_file.hpp>
49 #include <srs_lib_bandwidth.hpp> 45 #include <srs_lib_bandwidth.hpp>
50 46
51 -// if user want to define log, define the folowing macro. 47 +// if want to use your log, define the folowing macro.
52 #ifndef SRS_RTMP_USER_DEFINED_LOG 48 #ifndef SRS_RTMP_USER_DEFINED_LOG
53 // kernel module. 49 // kernel module.
54 ISrsLog* _srs_log = new ISrsLog(); 50 ISrsLog* _srs_log = new ISrsLog();