diff --git a/.circleci/config.yml b/.circleci/config.yml index cd14797ec..741270d5d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,13 +5,13 @@ jobs: - image: ossrs/srs:dev steps: - checkout - - run: cd trunk && ./configure --without-rtc && make && ./configure && make + - run: cd trunk && ./configure --without-rtc && make && ./configure --with-utest && make test: docker: - image: ossrs/srs:dev steps: - checkout - - run: cd trunk && ./configure --gcov && make && ./objs/srs_utest && bash auto/coverage.sh + - run: cd trunk && ./configure --with-utest --gcov && make && ./objs/srs_utest && bash auto/coverage.sh workflows: version: 2 build_and_test: diff --git a/AUTHORS.txt b/AUTHORS.txt index e992742ce..a3198b218 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -60,4 +60,3 @@ CONTRIBUTORS ordered by first contribution. * HuyaJohn * yanghuiwen * Bepartofyou - diff --git a/README.md b/README.md index 7642b0969..d4481cdb7 100755 --- a/README.md +++ b/README.md @@ -13,22 +13,22 @@ SRS is a RTMP/HLS/WebRTC/SRT/GB28181 streaming cluster, high efficiency, stable ## Usage -**Step 1:** Get SRS. +**>>> Step 1:** Get SRS. ``` git clone https://gitee.com/winlinvip/srs.oschina.git srs && cd srs/trunk && git remote set-url origin https://github.com/ossrs/srs.git && git pull ``` -> Note: Repository too large? Please clone from these [mirrors](#mirrors) instead. +> Note: We use [mirrors(gitee)](#mirrors) here, but it's also ok to directly clone by `git clone https://github.com/ossrs/srs.git && cd srs/trunk` -**Step 2:** Build SRS. +**>>> Step 2:** Build SRS. ``` ./configure && make ``` -> Remark: Recommend Centos6 64bits, please read wiki([CN][v3_CN_Build],[EN][v3_EN_Build]). +> Remark: Recommend to use Centos7 64bits, please read wiki([CN][v3_CN_Build],[EN][v3_EN_Build]). > Note: You can also build SRS in docker, please read [docker][docker-dev]. @@ -38,13 +38,16 @@ cd srs/trunk && git remote set-url origin https://github.com/ossrs/srs.git && gi ./objs/srs -c conf/srs.conf ``` -**Whatever**, you can also directly run SRS in [docker][docker-srs3]: +**>>> Whatever**, you can also directly run SRS in [docker][docker-srs3]: ``` -docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3 +docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 \ + registry.cn-hangzhou.aliyuncs.com/ossrs/srs:3 ``` -**From here,** strongly recommend to read bellow wikis: +> Note: Again, we use [ACR](https://cr.console.aliyun.com/) here, you can directly run in docker hub by `docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3` + +**>>> From here,** strongly recommend to read bellow wikis: * Usage: How to delivery RTMP?([CN][v1_CN_SampleRTMP], [EN][v1_EN_SampleRTMP]) * Usage: How to delivery RTMP-Edge Cluster?([CN][v3_CN_SampleRTMPCluster], [EN][v3_EN_SampleRTMPCluster]) @@ -154,6 +157,9 @@ For previous versions, please read: ## V4 changes +* v4.0, 2020-03-28, Support multiple OS/Platform build cache. 4.0.16 +* v4.0, 2020-03-28, For [#1250][bug #1250], support macOS, OSX, MacbookPro, Apple Darwin. +* v4.0, 2020-03-22, Welcome maintainers [Runner365](https://github.com/runner365), [John](https://github.com/xiaozhihong) and [B.P.Y(Bepartofyou)](https://github.com/Bepartofyou). 4.0.15 * v4.0, 2020-03-22, For [#307][bug #307], support play with WebRTC. 4.0.14 * v4.0, 2020-03-13, For [#1636][bug #1636], fix bug for mux AAC to ADTS, never overwrite by RTMP sampling rate. 4.0.13 * v4.0, 2020-03-07, For [#1612][bug #1612], fix crash bug for RTSP. 4.0.12 @@ -171,6 +177,12 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-03-29, [3.0 beta4(3.0.139)][r3.0b4] released. 122674 lines. +* v3.0, 2020-03-28, Support multiple OS/Platform build cache. 3.0.139 +* v3.0, 2020-03-28, For [#1250][bug #1250], support macOS, OSX, MacbookPro, Apple Darwin. 3.0.138 +* v3.0, 2020-03-21, For [#1629][bug #1629], fix kickoff FLV client bug. 3.0.137 +* v3.0, 2020-03-21, For [#1619][bug #1619], configure without utest by default. 3.0.136 +* v3.0, 2020-03-21, For [#1651][bug #1651], fix return pnwrite of srs_write_large_iovs. 3.0.135 * v3.0, 2020-03-18, [3.0 beta3(3.0.134)][r3.0b3] released. 122509 lines. * v3.0, 2020-03-12, For [#1635][bug #1635], inotify watch ConfigMap for reload. 3.0.134 * v3.0, 2020-03-12, For [#1635][bug #1635], support auto reaload config by inotify. 3.0.129 @@ -778,6 +790,7 @@ For previous versions, please read: ## Releases +* 2020-03-29, [Release v3.0-b3][r3.0b4], 3.0 beta4, 3.0.139, 122674 lines. * 2020-03-18, [Release v3.0-b3][r3.0b3], 3.0 beta3, 3.0.134, 122509 lines. * 2020-03-05, [Release v3.0-b2][r3.0b2], 3.0 beta2, 3.0.123, 122170 lines. * 2020-02-14, [Release v3.0-b1][r3.0b1], 3.0 beta1, 3.0.117, 121964 lines. @@ -1138,6 +1151,8 @@ Maintainers of SRS project: * [Winlin](https://github.com/winlinvip): All areas of streaming server and documents. * [Wenjie](https://github.com/wenjiegit): The focus of his work is on the [HDS](https://github.com/simple-rtmp-server/srs/wiki/v2_CN_DeliveryHDS) module. * [Runner365](https://github.com/runner365): The focus of his work is on the [SRT](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_SRTWiki) module. +* [John](https://github.com/xiaozhihong): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_RTCWiki) module. +* [B.P.Y(Bepartofyou)](https://github.com/Bepartofyou): Focus on [WebRTC](https://github.com/simple-rtmp-server/srs/wiki/v4_CN_RTCWiki) module. A big THANK YOU goes to: @@ -1712,6 +1727,9 @@ Winlin [bug #1594]: https://github.com/ossrs/srs/issues/1594 [bug #1630]: https://github.com/ossrs/srs/issues/1630 [bug #1635]: https://github.com/ossrs/srs/issues/1635 +[bug #1651]: https://github.com/ossrs/srs/issues/1651 +[bug #1619]: https://github.com/ossrs/srs/issues/1619 +[bug #1629]: https://github.com/ossrs/srs/issues/1629 [bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy [bug #1631]: https://github.com/ossrs/srs/issues/1631 @@ -1721,6 +1739,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r3.0b4]: https://github.com/ossrs/srs/releases/tag/v3.0-b4 [r3.0b3]: https://github.com/ossrs/srs/releases/tag/v3.0-b3 [r3.0b2]: https://github.com/ossrs/srs/releases/tag/v3.0-b2 [r3.0b1]: https://github.com/ossrs/srs/releases/tag/v3.0-b1 diff --git a/trunk/3rdparty/ffmpeg-4.2-fit/.gitignore b/trunk/3rdparty/ffmpeg-4.2-fit/.gitignore index 9ce1b69cd..ee17ebc92 100644 --- a/trunk/3rdparty/ffmpeg-4.2-fit/.gitignore +++ b/trunk/3rdparty/ffmpeg-4.2-fit/.gitignore @@ -2,17 +2,20 @@ *.d *.pc *.o -config.asm -config.h _release + +# We should remove bellow files in depends.sh doc +config.asm +config.h ffbuild/config.fate ffbuild/config.log ffbuild/config.mak ffbuild/config.sh ffbuild/.config libavutil/lib.version -libavcodec/libavcodec.version libavutil/libavutil.version +libavutil/ffversion.h +libavutil/avconfig.h +libavcodec/libavcodec.version libswresample/libswresample.version -libavutil/ffversion.h \ No newline at end of file diff --git a/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h b/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h deleted file mode 100644 index 8558b3502..000000000 --- a/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h +++ /dev/null @@ -1,6 +0,0 @@ -/* Generated by ffmpeg configure */ -#ifndef AVUTIL_AVCONFIG_H -#define AVUTIL_AVCONFIG_H -#define AV_HAVE_BIGENDIAN 0 -#define AV_HAVE_FAST_UNALIGNED 0 -#endif /* AVUTIL_AVCONFIG_H */ diff --git a/trunk/3rdparty/st-srs/Makefile b/trunk/3rdparty/st-srs/Makefile index 304d44377..601d3e507 100644 --- a/trunk/3rdparty/st-srs/Makefile +++ b/trunk/3rdparty/st-srs/Makefile @@ -128,6 +128,7 @@ OTHER_FLAGS = -Wall endif ifeq ($(OS), DARWIN) +EXTRA_OBJS = $(TARGETDIR)/md_darwin.o LD = cc SFLAGS = -fPIC -fno-common DSO_SUFFIX = dylib @@ -139,8 +140,8 @@ CFLAGS += -arch ppc LDFLAGS += -arch ppc endif ifeq ($(INTEL), yes) -CFLAGS += -arch i386 -arch x86_64 -LDFLAGS += -arch i386 -arch x86_64 +CFLAGS += -arch x86_64 +LDFLAGS += -arch x86_64 endif LDFLAGS += -dynamiclib -install_name /sw/lib/libst.$(MAJOR).$(DSO_SUFFIX) -compatibility_version $(MAJOR) -current_version $(VERSION) OTHER_FLAGS = -Wall @@ -313,7 +314,9 @@ endif # for SRS # disable examples for ubuntu crossbuild failed. # @see https://github.com/winlinvip/simple-rtmp-server/issues/308 +ifeq ($(OS), LINUX) EXAMPLES = +endif ifeq ($(OS), DARWIN) LINKNAME = libst.$(DSO_SUFFIX) @@ -369,10 +372,13 @@ $(HEADER): public.h $(TARGETDIR)/md.o: md.S $(CC) $(CFLAGS) -c $< -o $@ +$(TARGETDIR)/md_darwin.o: md_darwin.S + $(CC) $(CFLAGS) -c $< -o $@ + $(TARGETDIR)/%.o: %.c common.h md.h $(CC) $(CFLAGS) -c $< -o $@ -examples:: +examples: $(SLIBRARY) @echo Making $@ @cd $@; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" OS="$(OS)" TARGETDIR="$(TARGETDIR)" diff --git a/trunk/3rdparty/st-srs/md.h b/trunk/3rdparty/st-srs/md.h index dc4ef54c9..8c0a222d6 100644 --- a/trunk/3rdparty/st-srs/md.h +++ b/trunk/3rdparty/st-srs/md.h @@ -120,26 +120,30 @@ #define MD_ALWAYS_UNSERIALIZED_ACCEPT #define MD_HAVE_SOCKLEN_T - #define MD_SETJMP(env) _setjmp(env) - #define MD_LONGJMP(env, val) _longjmp(env, val) + #define MD_USE_BUILTIN_SETJMP - #if defined(__ppc__) - #define MD_JB_SP 0 - #elif defined(__i386__) - #define MD_JB_SP 9 - #elif defined(__x86_64__) - #define MD_JB_SP 4 + #if defined(__amd64__) || defined(__x86_64__) + #define JB_SP 12 + #define MD_GET_SP(_t) *((long *)&((_t)->context[JB_SP])) #else #error Unknown CPU architecture #endif - - #define MD_INIT_CONTEXT(_thread, _sp, _main) \ - ST_BEGIN_MACRO \ - if (MD_SETJMP((_thread)->context)) \ - _main(); \ - *((long *)&((_thread)->context[MD_JB_SP])) = (long) (_sp); \ + + #define MD_INIT_CONTEXT(_thread, _sp, _main) \ + ST_BEGIN_MACRO \ + if (MD_SETJMP((_thread)->context)) \ + _main(); \ + MD_GET_SP(_thread) = (long) (_sp); \ ST_END_MACRO + #if defined(MD_USE_BUILTIN_SETJMP) + #define MD_SETJMP(env) _st_md_cxt_save(env) + #define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val) + + extern int _st_md_cxt_save(jmp_buf env); + extern void _st_md_cxt_restore(jmp_buf env, int val); + #endif + #define MD_GET_UTIME() \ struct timeval tv; \ (void) gettimeofday(&tv, NULL); \ diff --git a/trunk/3rdparty/st-srs/md_darwin.S b/trunk/3rdparty/st-srs/md_darwin.S new file mode 100644 index 000000000..6cd163d44 --- /dev/null +++ b/trunk/3rdparty/st-srs/md_darwin.S @@ -0,0 +1,76 @@ + +/* If user disable the ASM, such as avoiding bugs in ASM, donot compile it. */ +#if !defined(MD_ST_NO_ASM) + +#if defined(__amd64__) || defined(__x86_64__) + + /****************************************************************/ + + /* + * Internal __jmp_buf layout + */ + #define JB_RBX 0 + #define JB_RBP 1 + #define JB_R12 2 /* Backup IP, https://www.cnblogs.com/Five100Miles/p/8458561.html */ + #define JB_R13 3 /* Backup SP, https://www.cnblogs.com/Five100Miles/p/8458561.html */ + #define JB_R14 4 /* Backup LR, https://www.cnblogs.com/Five100Miles/p/8458561.html */ + #define JB_R15 5 /* Backup PC, https://www.cnblogs.com/Five100Miles/p/8458561.html */ + #define JB_RSP 6 + #define JB_PC 7 + + .file "md_darwin.S" + .text + + /* _st_md_cxt_save(__jmp_buf env) */ /* The env is rdi, http://blog.chinaunix.net/uid-20157960-id-1974354.html */ + .globl __st_md_cxt_save + .align 16 + __st_md_cxt_save: + /* + * Save registers. + */ + movq %rbx, (JB_RBX*8)(%rdi) /* Save rbx to env[0], *(int64_t*)(rdi+0)=rbx */ + movq %rbp, (JB_RBP*8)(%rdi) /* Save rbp to env[1], *(int64_t*)(rdi+1)=rbp */ + movq %r12, (JB_R12*8)(%rdi) /* Save r12 to env[2], *(int64_t*)(rdi+2)=r12 */ + movq %r13, (JB_R13*8)(%rdi) /* Save r13 to env[3], *(int64_t*)(rdi+3)=r13 */ + movq %r14, (JB_R14*8)(%rdi) /* Save r14 to env[4], *(int64_t*)(rdi+4)=r14 */ + movq %r15, (JB_R15*8)(%rdi) /* Save r15 to env[5], *(int64_t*)(rdi+5)=r15 */ + /* Save SP */ + leaq 8(%rsp), %rdx /* Save *(int64_t*)(rsp+8) to rdx, https://my.oschina.net/guonaihong/blog/508907 */ + movq %rdx, (JB_RSP*8)(%rdi) /* Save rdx(rsp) to env[6], *(int64_t*)(rdi+6)=rdx */ + /* Save PC we are returning to */ + movq (%rsp), %rax /* Save PC(parent function address) %(rsp) to rax */ + movq %rax, (JB_PC*8)(%rdi) /* Save rax(PC) to env[7], *(int64_t*)(rdi+7)=rax */ + xorq %rax, %rax /* Reset rax to 0 */ + ret + + + /****************************************************************/ + + /* _st_md_cxt_restore(__jmp_buf env, int val) */ /* The env is rdi, val is esi/rsi, http://blog.chinaunix.net/uid-20157960-id-1974354.html */ + .globl __st_md_cxt_restore + .align 16 + __st_md_cxt_restore: + /* + * Restore registers. + */ + movq (JB_RBX*8)(%rdi), %rbx /* Load rbx from env[0] */ + movq (JB_RBP*8)(%rdi), %rbp /* Load rbp from env[1] */ + movq (JB_R12*8)(%rdi), %r12 /* Load r12 from env[2] */ + movq (JB_R13*8)(%rdi), %r13 /* Load r13 from env[3] */ + movq (JB_R14*8)(%rdi), %r14 /* Load r14 from env[4] */ + movq (JB_R15*8)(%rdi), %r15 /* Load r15 from env[5] */ + /* Set return value */ /* The esi is param1 val, the eax is return value */ + test %esi, %esi /* if (!val) { */ + mov $01, %eax /* val=1; */ + cmove %eax, %esi /* } */ + mov %esi, %eax /* return val; */ + movq (JB_PC*8)(%rdi), %rdx /* Load rdx(PC) from env[7] */ + movq (JB_RSP*8)(%rdi), %rsp /* Load rsp from env[6] */ + /* Jump to saved PC */ + jmpq *%rdx /* Jump to rdx(PC) */ + + /****************************************************************/ + +#endif + +#endif diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 71e9d4818..3c4c77ea3 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -149,6 +149,11 @@ if [ $SRS_CROSS_BUILD = YES ]; then else srs_undefine_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H fi +if [ $SRS_OSX = YES ]; then + srs_define_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H +else + srs_undefine_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H +fi # prefix echo "" >> $SRS_AUTO_HEADERS_H diff --git a/trunk/auto/coverage.sh b/trunk/auto/coverage.sh index 0196fe9d5..55cb7ce46 100644 --- a/trunk/auto/coverage.sh +++ b/trunk/auto/coverage.sh @@ -17,7 +17,7 @@ mkdir -p $workdir && cd $workdir ret=$?; if [[ $ret -ne 0 ]]; then echo "Enter workdir failed, ret=$ret"; exit $ret; fi # Collect all *.gcno and *.gcda to objs/cover. -cd $workdir && (rm -rf src && cp -R ../../src . && cp -R ../src .) +cd $workdir && (rm -rf src && cp -R ../../src . && cp -R ../src/* src/) ret=$?; if [[ $ret -ne 0 ]]; then echo "Collect *.gcno and *.gcda failed, ret=$ret"; exit $ret; fi # Generate *.gcov for coverage. diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 36cc3a40d..01d2aaf5a 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -118,6 +118,7 @@ function Ubuntu_prepare() if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for ubuntu failed, ret=$ret"; exit $ret; fi fi + ##################################################################################### # for Centos, auto install tools by yum ##################################################################################### @@ -198,19 +199,124 @@ function Centos_prepare() if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for CentOS failed, ret=$ret"; exit $ret; fi fi + +##################################################################################### +# For OSX, auto install tools by brew +##################################################################################### +OS_IS_OSX=NO +function OSX_prepare() +{ + uname -s|grep Darwin >/dev/null 2>&1 + ret=$?; if [[ 0 -ne $ret ]]; then + if [ $SRS_OSX = YES ]; then + echo "OSX check failed, actual is `uname -s`" + exit 1; + fi + return 0; + fi + + # cross build for arm, install the cross build tool chain. + if [ $SRS_CROSS_BUILD = YES ]; then + echo "embeded(arm/mips) is invalid for OSX" + return 1 + fi + + OS_IS_OSX=YES + echo "OSX detected, install tools if needed" + # requires the osx when os + if [ $OS_IS_OSX = YES ]; then + if [ $SRS_OSX = NO ]; then + echo "OSX detected, must specifies the --osx" + exit 1 + fi + fi + + brew --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "install brew" + echo "ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"" + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "install brew success" + fi + + gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "install gcc" + echo "brew install gcc" + brew install gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "install gcc success" + fi + + g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "install gcc-c++" + echo "brew install gcc-c++" + brew install gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "install gcc-c++ success" + fi + + make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "install make" + echo "brew install make" + brew install make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "install make success" + fi + + patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "install patch" + echo "brew install patch" + brew install patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "install patch success" + fi + + unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "install unzip" + echo "brew install unzip" + brew install unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "install unzip success" + fi + + echo "OSX install tools success" + return 0 +} +# donot prepare tools, for srs-librtmp depends only gcc and g++. +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then + OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$ret"; exit $ret; fi +fi + ##################################################################################### # for Centos, auto install tools by yum ##################################################################################### # We must use a bash function instead of variable. function sed_utility() { - sed -i "$@" + if [ $OS_IS_OSX = YES ]; then + sed -i '' "$@" + else + sed -i "$@" + fi + ret=$?; if [[ $ret -ne 0 ]]; then - echo "sed -i \"$@\"" + if [ $OS_IS_OSX = YES ]; then + echo "sed -i '' \"$@\"" + else + echo "sed -i \"$@\"" + fi return $ret fi } SED="sed_utility" && echo "SED is $SED" +function _srs_link_file() +{ + tmp_dir=$1; if [[ $tmp_dir != *'/' ]]; then tmp_dir+='/'; fi + tmp_dest=$2; if [[ $tmp_dest != *'/' ]]; then tmp_dest+='/'; fi + tmp_prefix=$3; if [[ $tmp_prefix != *'/' ]]; then tmp_prefix+='/'; fi + + echo "LINK files at dir: $tmp_dir, dest: $tmp_dest, prefix: $tmp_prefix, pwd: `pwd`" + for file in `(cd $tmp_dir && find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.d' ! -name '*.log')`; do + basefile=`basename $file` && + #echo "ln -sf ${tmp_prefix}${tmp_dir}$basefile ${tmp_dest}$basefile" && + ln -sf ${tmp_prefix}${tmp_dir}$basefile ${tmp_dest}$basefile; + done +} + ##################################################################################### # check the os. ##################################################################################### @@ -220,7 +326,7 @@ SED="sed_utility" && echo "SED is $SED" # directly build on arm/mips, for example, pi or cubie, # export srs-librtmp # others is invalid. -if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then +if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then if [[ $SRS_PI = NO && $SRS_CUBIE = NO && $SRS_CROSS_BUILD = NO ]]; then echo "Your OS `uname -s` is not supported." exit 1 @@ -232,29 +338,49 @@ fi ##################################################################################### if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then # check the cross build flag file, if flag changed, need to rebuild the st. - _ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL" + _ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL" && _ST_LD=${SRS_TOOL_LD} && _ST_OBJ="LINUX_*" if [[ $SRS_VALGRIND == YES ]]; then _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_VALGRIND" fi + # for osx, use darwin for st, donot use epoll. + if [[ $SRS_OSX == YES ]]; then + _ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE" && _ST_LD=${SRS_TOOL_CC} && _ST_OBJ="DARWIN_*" + fi # Pass the global extra flags. if [[ $SRS_EXTRA_FLAGS != '' ]]; then _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_FLAGS" fi # Patched ST from https://github.com/ossrs/state-threads/tree/srs - if [[ -f ${SRS_OBJS}/st/libst.a ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/st/libst.a ]]; then echo "The state-threads is ok."; else echo "Building state-threads."; ( - rm -rf ${SRS_OBJS}/st-srs && cd ${SRS_OBJS} && - ln -sf ../3rdparty/st-srs && cd st-srs && - make clean && make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" \ - CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} && - cd .. && rm -f st && ln -sf st-srs/obj st + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && + # Create a hidden directory .src + cd ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && ln -sf ../../../3rdparty/st-srs .src && + # Link source files under .src + _srs_link_file .src/ ./ ./ && + for dir in `(cd .src && find . -maxdepth 1 -type d|grep '\./')`; do + dir=`basename $dir` && mkdir -p $dir && _srs_link_file .src/$dir/ $dir/ ../ + done && + # Link source files under .src/xxx, the first child dir. + for dir in `(cd .src && find . -maxdepth 1 -type d|grep '\./'|grep -v Linux|grep -v Darwin)`; do + mkdir -p $dir && + for file in `(cd .src/$dir && find . -maxdepth 1 -type f ! -name '*.o' ! -name '*.d')`; do + ln -sf ../.src/$dir/$file $dir/$file; + done; + done && + # Build source code. + make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" \ + CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${_ST_LD} RANDLIB=${SRS_TOOL_RANDLIB} && + cd .. && rm -f st && ln -sf st-srs/${_ST_OBJ} st ) fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build state-threads failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -rf st && ln -sf ${SRS_PLATFORM}/st-srs/${_ST_OBJ} st) if [ ! -f ${SRS_OBJS}/st/libst.a ]; then echo "Build state-threads static lib failed."; exit -1; fi fi @@ -269,7 +395,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then echo "Building srtp2."; ( rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS} && - unzip -q ../3rdparty/libsrtp-2.0.0.zip && cd libsrtp-2.0.0 && + rm -rf libsrtp-2.0.0 && unzip -q ../3rdparty/libsrtp-2.0.0.zip && cd libsrtp-2.0.0 && ./configure --prefix=`pwd`/_release && make ${SRS_JOBS} && make install && cd .. && rm -f srtp2 && ln -sf libsrtp-2.0.0/_release srtp2 ) @@ -328,19 +454,19 @@ fi # cherrypy for http hooks callback, CherryPy-3.2.4 ##################################################################################### if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then - if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/CherryPy-3.2.4/setup.py ]]; then echo "CherryPy-3.2.4 is ok."; else echo "Installing CherryPy-3.2.4"; ( - rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} && - unzip -q ../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 && + rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS}/${SRS_PLATFORM} && + unzip -q ../../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 && python setup.py install --user ) fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "build CherryPy-3.2.4 failed, ret=$ret"; exit $ret; fi - if [ ! -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi + if [ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi echo "Link players to cherrypy static-dir" rm -rf research/api-server/static-dir/players && @@ -373,21 +499,26 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then OPENSSL_CONFIG="./Configure linux-armv4" else # If not crossbuild, try to use exists libraries. - if [[ -f /usr/local/lib64/libssl.a && ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then - (mkdir -p ${SRS_OBJS}/openssl/lib && cd ${SRS_OBJS}/openssl/lib && + if [[ -f /usr/local/lib64/libssl.a && ! -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then + (mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && ln -sf /usr/local/lib64/libssl.a && ln -sf /usr/local/lib64/libcrypto.a) - (mkdir -p ${SRS_OBJS}/openssl/include && cd ${SRS_OBJS}/openssl/include && + (mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && ln -sf /usr/local/include/openssl) fi fi + # Which lib we use. + OPENSSL_LIB="openssl-1.1.0e/_release" + if [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_LIB}/lib/libssl.a ]]; then + OPENSSL_LIB="openssl" + fi # cross build not specified, if exists flag, need to rebuild for no-arm platform. - if [[ -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then echo "Openssl-1.1.0e is ok."; else echo "Building openssl-1.1.0e."; ( - rm -rf ${SRS_OBJS}/openssl-1.1.0e && cd ${SRS_OBJS} && - unzip -q ../3rdparty/openssl-1.1.0e.zip && cd openssl-1.1.0e && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/openssl-1.1.0e && cd ${SRS_OBJS}/${SRS_PLATFORM} && + unzip -q ../../3rdparty/openssl-1.1.0e.zip && cd openssl-1.1.0e && ${OPENSSL_CONFIG} --prefix=`pwd`/_release $OPENSSL_OPTIONS && make CC=${SRS_TOOL_CC} AR="${SRS_TOOL_AR} -rs" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} && make install_sw && cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl @@ -395,26 +526,53 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -rf openssl && ln -sf ${SRS_PLATFORM}/${OPENSSL_LIB} openssl) if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi fi +##################################################################################### +# srtp +##################################################################################### +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then + # Patched ST from https://github.com/ossrs/state-threads/tree/srs + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/srtp2/lib/libsrtp2.a ]]; then + echo "The srtp2 is ok."; + else + echo "Building srtp2."; + ( + rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} && + rm -rf libsrtp-2.0.0 && unzip -q ../../3rdparty/libsrtp-2.0.0.zip && cd libsrtp-2.0.0 && + ./configure --prefix=`pwd`/_release && make ${SRS_JOBS} && make install && + cd .. && rm -f srtp2 && ln -sf libsrtp-2.0.0/_release srtp2 + ) + fi + # check status + ret=$?; if [[ $ret -ne 0 ]]; then echo "Build srtp2 failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -f srtp2 && ln -sf ${SRS_PLATFORM}/libsrtp-2.0.0/_release srtp2) + if [ ! -f ${SRS_OBJS}/srtp2/lib/libsrtp2.a ]; then echo "Build srtp2 static lib failed."; exit -1; fi +fi + ##################################################################################### # libopus, for WebRTC to transcode AAC with Opus. ##################################################################################### if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then - if [[ -f ${SRS_OBJS}/opus/lib/libopus.a ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/opus/lib/libopus.a ]]; then echo "The opus-1.3.1 is ok."; else echo "Building opus-1.3.1."; ( - rm -rf ${SRS_OBJS}/opus-1.3.1 && cd ${SRS_OBJS} && - tar xf ../3rdparty/opus-1.3.1.tar.gz && cd opus-1.3.1 && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 && cd ${SRS_OBJS}/${SRS_PLATFORM} && + tar xf ../../3rdparty/opus-1.3.1.tar.gz && cd opus-1.3.1 && ./configure --prefix=`pwd`/_release --enable-static --disable-shared && make ${SRS_JOBS} && make install cd .. && rm -rf opus && ln -sf opus-1.3.1/_release opus ) fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build opus-1.3.1 failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -f opus && ln -sf ${SRS_PLATFORM}/opus-1.3.1/_release opus) if [ ! -f ${SRS_OBJS}/opus/lib/libopus.a ]; then echo "Build opus-1.3.1 failed."; exit -1; fi fi @@ -426,15 +584,32 @@ if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then if [[ $SRS_NASM == NO ]]; then FFMPEG_OPTIONS="--disable-asm --disable-x86asm --disable-inline-asm" fi - if [[ -f ${SRS_OBJS}/ffmpeg/lib/libavcodec.a ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/lib/libavcodec.a ]]; then echo "The ffmpeg-4.2-fit is ok."; else echo "Building ffmpeg-4.2-fit."; ( - rm -rf ${SRS_OBJS}/ffmpeg-4.2-fit && cd ${SRS_OBJS} && ABS_OBJS=`pwd` && - ln -sf ../3rdparty/ffmpeg-4.2-fit && cd ffmpeg-4.2-fit && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4.2-fit && mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4.2-fit && + # Create a hidden directory .src + cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4.2-fit && ABS_OBJS=`(cd .. && pwd)` && ln -sf ../../../3rdparty/ffmpeg-4.2-fit .src && + # Link source files under .src + _srs_link_file .src/ ./ ./ && + for dir in `(cd .src && find . -maxdepth 1 -type d|grep '\./')`; do + dir=`basename $dir` && mkdir -p $dir && _srs_link_file .src/$dir/ $dir/ ../ && + for dir2 in `(cd .src/$dir && find . -maxdepth 1 -type d|grep '\./')`; do + dir2=`basename $dir2` && mkdir -p $dir/$dir2 && _srs_link_file .src/$dir/$dir2/ $dir/$dir2/ ../../ && + for dir3 in `(cd .src/$dir/$dir2 && find . -maxdepth 1 -type d|grep '\./')`; do + dir3=`basename $dir3` && mkdir -p $dir/$dir2/$dir3 && _srs_link_file .src/$dir/$dir2/$dir3/ $dir/$dir2/$dir3/ ../../../; + done + done + done && + # We should remove some files(in .gitignore) to keep them in local generated. + (cd ffbuild && rm -f config.fate config.log config.mak config.sh .config) && + (cd libavutil && rm -f lib.version libavutil.version ffversion.h avconfig.h) && + (rm -rf doc && rm -f config.asm config.h libavcodec/libavcodec.version libswresample/libswresample.version) && + # Build source code. PKG_CONFIG_PATH=$ABS_OBJS/opus/lib/pkgconfig ./configure \ - --prefix=`pwd`/_release \ + --prefix=`pwd`/${SRS_PLATFORM}/_release \ --pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm ${FFMPEG_OPTIONS} \ --disable-programs --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages \ --disable-avdevice --disable-avformat --disable-swscale --disable-postproc --disable-avfilter --disable-network \ @@ -444,11 +619,13 @@ if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then --enable-decoder=aac --enable-decoder=aac_fixed --enable-decoder=aac_latm --enable-decoder=libopus --enable-encoder=aac \ --enable-encoder=opus --enable-encoder=libopus --enable-libopus && make ${SRS_JOBS} && make install && - cd .. && rm -rf ffmpeg && ln -sf ffmpeg-4.2-fit/_release ffmpeg + cd .. && rm -rf ffmpeg && ln -sf ffmpeg-4.2-fit/${SRS_PLATFORM}/_release ffmpeg ) fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build ffmpeg-4.2-fit failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -f ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg-4.2-fit/${SRS_PLATFORM}/_release ffmpeg) if [ ! -f ${SRS_OBJS}/ffmpeg/lib/libavcodec.a ]; then echo "Build ffmpeg-4.2-fit failed."; exit -1; fi fi @@ -456,16 +633,19 @@ fi # live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2. ##################################################################################### # Always link the ffmpeg tools if exists. -if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then - mkdir -p ${SRS_OBJS}/ffmpeg/bin && ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/ffmpeg/bin/ffmpeg +if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg ]]; then + mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin && + ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg fi if [ $SRS_FFMPEG_TOOL = YES ]; then - if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg ]]; then echo "ffmpeg-4.1 is ok."; else - echo "no ffmpeg-4.1 found, please run in docker ossrs/srs:dev"; + echo "no ffmpeg found, please use srs-docker or --without-ffmpeg"; exit -1; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg) fi ##################################################################################### @@ -513,18 +693,20 @@ fi # build utest code ##################################################################################### if [ $SRS_UTEST = YES ]; then - if [[ -f ${SRS_OBJS}/gtest/include/gtest/gtest.h ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gtest/include/gtest/gtest.h ]]; then echo "The gtest-1.6.0 is ok."; else echo "Build gtest-1.6.0"; ( - rm -rf ${SRS_OBJS}/gtest-1.6.0 && cd ${SRS_OBJS} && - unzip -q ../3rdparty/gtest-1.6.0.zip && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0 && cd ${SRS_OBJS}/${SRS_PLATFORM} && + unzip -q ../../3rdparty/gtest-1.6.0.zip && rm -rf gtest && ln -sf gtest-1.6.0 gtest ) fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gtest-1.6.0 failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -rf gtest && ln -sf ${SRS_PLATFORM}/gtest-1.6.0 gtest) if [ ! -f ${SRS_OBJS}/gtest/include/gtest/gtest.h ]; then echo "Build gtest-1.6.0 failed."; exit -1; fi fi @@ -532,13 +714,13 @@ fi # build gperf code ##################################################################################### if [ $SRS_GPERF = YES ]; then - if [[ -f ${SRS_OBJS}/gperf/bin/pprof ]]; then + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gperf/bin/pprof ]]; then echo "The gperftools-2.1 is ok."; else echo "Build gperftools-2.1"; ( - rm -rf ${SRS_OBJS}/gperftools-2.1 && cd ${SRS_OBJS} && - unzip -q ../3rdparty/gperftools-2.1.zip && cd gperftools-2.1 && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gperftools-2.1 && cd ${SRS_OBJS}/${SRS_PLATFORM} && + unzip -q ../../3rdparty/gperftools-2.1.zip && cd gperftools-2.1 && ./configure --prefix=`pwd`/_release --enable-frame-pointers && make ${SRS_JOBS} && make install && cd .. && rm -rf gperf && ln -sf gperftools-2.1/_release gperf && rm -rf pprof && ln -sf gperf/bin/pprof pprof @@ -546,10 +728,7 @@ if [ $SRS_GPERF = YES ]; then fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build gperftools-2.1 failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS} && rm -rf pprof && ln -sf ${SRS_PLATFORM}/gperf/bin/pprof pprof) if [ ! -f ${SRS_OBJS}/gperf/bin/pprof ]; then echo "Build gperftools-2.1 failed."; exit -1; fi fi - -##################################################################################### -# generated the test script -##################################################################################### -rm -rf ${SRS_OBJS}/srs.test && ln -sf `pwd`/scripts/srs.test objs/srs.test diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 97de92ec2..81b47cdd5 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -23,7 +23,7 @@ SRS_NGINX=NO SRS_FFMPEG_TOOL=NO SRS_LIBRTMP=NO SRS_RESEARCH=NO -SRS_UTEST=YES +SRS_UTEST=NO SRS_GPERF=NO # Performance test: tcmalloc SRS_GPERF_MC=NO # Performance test: gperf memory check SRS_GPERF_MD=NO # Performance test: gperf memory defence @@ -110,6 +110,8 @@ SRS_TOOL_AR=ar SRS_TOOL_LD=ld SRS_TOOL_RANDLIB=randlib SRS_EXTRA_FLAGS= +# Set the object files tag name. +SRS_BUILD_TAG= ##################################################################################### # menu @@ -182,6 +184,7 @@ Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuec --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. --with-nasm Build FFMPEG for RTC with nasm support. --without-nasm Build FFMPEG for RTC without nasm support, for CentOS6 nasm is too old. + --build-tag= Set the build object directory suffix. Conflicts: 1. --with-gmc vs --with-gmp: @@ -210,10 +213,6 @@ Remark: END } -function ignore_option() { - echo "ignore option \"$option\"" -} - function parse_user_option() { case "$option" in -h) help=yes ;; @@ -276,6 +275,7 @@ function parse_user_option() { --ld) SRS_TOOL_LD=${value} ;; --randlib) SRS_TOOL_RANDLIB=${value} ;; --extra-flags) SRS_EXTRA_FLAGS=${value} ;; + --build-tag) SRS_BUILD_TAG=${value} ;; --x86-x64) SRS_X86_X64=YES ;; --x86-64) SRS_X86_X64=YES ;; @@ -307,16 +307,16 @@ function parse_user_option() { --with-hls) SRS_HLS=YES ;; --with-dvr) SRS_DVR=YES ;; - --without-stream-caster) ignore_option ;; - --without-ingest) ignore_option ;; - --without-ssl) ignore_option ;; - --without-stat) ignore_option ;; - --without-transcode) ignore_option ;; - --without-http-callback) ignore_option ;; - --without-http-server) ignore_option ;; - --without-http-api) ignore_option ;; - --without-hls) ignore_option ;; - --without-dvr) ignore_option ;; + --without-stream-caster) echo "ignore option \"$option\"" ;; + --without-ingest) echo "ignore option \"$option\"" ;; + --without-ssl) echo "ignore option \"$option\"" ;; + --without-stat) echo "ignore option \"$option\"" ;; + --without-transcode) echo "ignore option \"$option\"" ;; + --without-http-callback) echo "ignore option \"$option\"" ;; + --without-http-server) echo "ignore option \"$option\"" ;; + --without-http-api) echo "ignore option \"$option\"" ;; + --without-hls) echo "ignore option \"$option\"" ;; + --without-dvr) echo "ignore option \"$option\"" ;; *) echo "$0: error: invalid option \"$option\"" @@ -407,7 +407,7 @@ function apply_user_presets() { SRS_HDS=YES SRS_LIBRTMP=YES SRS_RESEARCH=NO - SRS_UTEST=YES + SRS_UTEST=NO SRS_STATIC=NO fi @@ -434,7 +434,7 @@ function apply_user_presets() { SRS_HDS=YES SRS_LIBRTMP=YES SRS_RESEARCH=NO - SRS_UTEST=YES + SRS_UTEST=NO SRS_STATIC=NO fi @@ -565,6 +565,7 @@ function regenerate_options() { if [ $SRS_LOG_TRACE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace"; fi if [ $SRS_GCOV = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov"; fi if [[ $SRS_EXTRA_FLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_FLAGS\\\""; fi + if [[ $SRS_BUILD_TAG != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --build-tag=\\\"$SRS_BUILD_TAG\\\""; fi if [[ $SRS_TOOL_CC != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cc=$SRS_TOOL_CC"; fi if [[ $SRS_TOOL_CXX != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx=$SRS_TOOL_CXX"; fi if [[ $SRS_TOOL_AR != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ar=$SRS_TOOL_AR"; fi @@ -587,16 +588,12 @@ function check_option_conflicts() { echo "For crossbuild, must not use default toolchain, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR"; exit -1 fi - if [ $SRS_OSX = YES ]; then - echo "We don't support OSX, please use docker https://github.com/ossrs/srs-docker"; exit -1 - fi - if [[ $SRS_NGINX == YES ]]; then - echo "Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"; exit -1 + echo "Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"; exit -1; fi if [[ $SRS_FFMPEG_TOOL == YES ]]; then - echo "Don't support building FFMPEG, please use docker https://github.com/ossrs/srs-docker"; exit -1 + echo "Don't support building FFMPEG, please use docker https://github.com/ossrs/srs-docker"; exit -1; fi # TODO: FIXME: check more os. diff --git a/trunk/auto/setup_variables.sh b/trunk/auto/setup_variables.sh index 9d37edbf7..7a39fd166 100755 --- a/trunk/auto/setup_variables.sh +++ b/trunk/auto/setup_variables.sh @@ -1,3 +1,24 @@ #!/bin/bash # when options parsed, setup some variables, then build the depends. +OS_KERNEL_NAME=$(uname -s) +OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}') +OS_PREFIX="Platform" +SRS_PLATFORM="${OS_PREFIX}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}" +if [[ ${SRS_BUILD_TAG} != "" ]]; then + SRS_PLATFORM="${SRS_PLATFORM}-${SRS_BUILD_TAG}" +fi +echo "SRS_WORKDIR: ${SRS_WORKDIR}, SRS_OBJS_DIR: ${SRS_OBJS_DIR}, SRS_OBJS: ${SRS_OBJS}, SRS_PLATFORM: ${SRS_PLATFORM}" + +# For src object files on each platform. +( + mkdir -p ${SRS_OBJS_DIR} && cd ${SRS_OBJS_DIR} && + rm -rf src utest srs srs_utest research include lib srs_hls_ingester srs_mp4_parser && + mkdir -p ${SRS_PLATFORM}/src && ln -sf ${SRS_PLATFORM}/src && + mkdir -p ${SRS_PLATFORM}/utest && ln -sf ${SRS_PLATFORM}/utest && + mkdir -p ${SRS_PLATFORM}/research && ln -sf ${SRS_PLATFORM}/research && + mkdir -p ${SRS_PLATFORM}/include && ln -sf ${SRS_PLATFORM}/include && + mkdir -p ${SRS_PLATFORM}/lib && ln -sf ${SRS_PLATFORM}/lib +) +echo "Fast cleanup, if need to do full cleanup, please use: make clean" + diff --git a/trunk/auto/utest.sh b/trunk/auto/utest.sh index d8cce4a6f..e7ce6a4a1 100755 --- a/trunk/auto/utest.sh +++ b/trunk/auto/utest.sh @@ -16,13 +16,10 @@ mkdir -p ${SRS_OBJS}/utest # the prefix to generate the objs/utest/Makefile # dirs relative to current dir(objs/utest), it's trunk/objs/utest # trunk of srs, which contains the src dir, relative to objs/utest, it's trunk -SRS_TRUNK_PREFIX=../.. +SRS_TRUNK_PREFIX=../../.. # gest dir, relative to objs/utest, it's trunk/objs/gtest GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest -# the extra defines to compile utest. -EXTRA_DEFINES="" - cat << END > ${FILE} # user must run make the ${SRS_OBJS_DIR}/utest dir # at the same dir of Makefile. @@ -52,7 +49,7 @@ USER_DIR = . CPPFLAGS += -I\$(GTEST_DIR)/include # Flags passed to the C++ compiler. -CXXFLAGS += ${CXXFLAGS} -Wextra ${EXTRA_DEFINES} +CXXFLAGS += ${CXXFLAGS} -Wextra ${UTEST_EXTRA_DEFINES} # All tests produced by this Makefile. Remember to add new tests you # created to the list. diff --git a/trunk/configure b/trunk/configure index 0d5ebfb78..752bbbf23 100755 --- a/trunk/configure +++ b/trunk/configure @@ -26,16 +26,11 @@ BLACK="\\033[0m" # setup variables when options parsed. . auto/setup_variables.sh -# clean the exists, when not export srs-librtmp. -# do this only when the options is ok. -if [[ -f Makefile ]]; then -make clean -fi -# remove makefile +# We don't need to cleanup the exists files. rm -f ${SRS_WORKDIR}/${SRS_MAKEFILE} # create objs -mkdir -p ${SRS_OBJS} +mkdir -p ${SRS_OBJS}/${SRS_PLATFORM} # for export srs-librtmp, change target to it. . auto/generate-srs-librtmp-project.sh @@ -57,7 +52,7 @@ SrsLibrtmpSampleEntry="nossl" if [ $SRS_SSL = YES ]; then SrsLibrtmpSampleEntry="ssl";fi # utest make entry, (cd utest; make) SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\"" -if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/utest; \$(MAKE))"; fi +if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/${SRS_PLATFORM}/utest && \$(MAKE))"; fi ##################################################################################### # finger out modules to install. @@ -398,6 +393,11 @@ if [ $SRS_LIBRTMP = YES ]; then MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${LIBS_OBJS[@]}" BUILD_KEY="librtmp" LIB_NAME="lib/srs_librtmp" . auto/libs.sh fi +# For utest on mac. +# @see https://github.com/protocolbuffers/protobuf/issues/51#issuecomment-111044468 +if [[ $SRS_OSX == YES ]]; then + UTEST_EXTRA_DEFINES="-DGTEST_USE_OWN_TR1_TUPLE=1" +fi # # utest, the unit-test cases of srs, base on gtest1.6 if [ $SRS_UTEST = YES ]; then @@ -440,7 +440,9 @@ mv ${SRS_WORKDIR}/${SRS_MAKEFILE} ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk # generate phony header cat << END > ${SRS_WORKDIR}/${SRS_MAKEFILE} -.PHONY: default _default install install-api help clean server srs_ingest_hls librtmp utest _prepare_dir $__mphonys +.PHONY: default _default install install-api help clean destroy server srs_ingest_hls librtmp utest _prepare_dir $__mphonys +.PHONY: clean_srs clean_modules clean_openssl clean_nginx clean_cherrypy clean_srtp2 clean_opus +.PHONY: st ffmpeg # install prefix. SRS_PREFIX=${SRS_PREFIX} @@ -459,27 +461,69 @@ _default: server srs_ingest_hls librtmp utest __modules $__mdefaults @bash objs/_srs_build_summary.sh help: - @echo "Usage: make |||||||" - @echo " help display this help menu" - @echo " clean cleanup project" - @echo " server build the srs(simple rtmp server) over st(state-threads)" - @echo " librtmp build the client publish/play library, and samples" - @echo " utest build the utest for srs" - @echo " install install srs to the prefix path" - @echo " install-api install srs and api-server to the prefix path" - @echo " uninstall uninstall srs from prefix path" - @echo "@remark all modules will auto genearted and build" + @echo "Usage: make ||||||||" + @echo " help Display this help menu" + @echo " clean Cleanup project and all depends" + @echo " destroy Cleanup all files for this platform in ${SRS_OBJS_DIR}/${SRS_PLATFORM}" + @echo " server Build the srs and other modules in main" + @echo " librtmp Build the client publish/play library, and samples" + @echo " utest Build the utest for srs" + @echo " install Install srs to the prefix path" + @echo " install-api Install srs and api-server to the prefix path" + @echo " uninstall Uninstall srs from prefix path" + @echo "To rebuild special module:" + @echo " st Rebuild st-srs in ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs" + @echo " ffmpeg Rebuild ffmpeg in ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4.2-fit" @echo "For example:" @echo " make" @echo " make help" -clean: +doclean: (cd ${SRS_OBJS_DIR} && rm -rf srs srs_utest $__mcleanups) - (cd ${SRS_OBJS_DIR} && rm -rf src include lib) - (cd ${SRS_OBJS_DIR}/utest && rm -rf *.o *.a) + (cd ${SRS_OBJS_DIR} && rm -rf src/* include lib) + (mkdir -p ${SRS_OBJS_DIR}/utest && cd ${SRS_OBJS_DIR}/utest && rm -rf *.o *.a) (cd research/librtmp && make clean) (cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players) +clean: clean_srs clean_modules + @echo "You can clean each some components, see make help" + +destroy: + (cd ${SRS_OBJS_DIR} && rm -rf ${SRS_PLATFORM}) + +clean_srs: + (cd ${SRS_OBJS_DIR} && rm -rf srs srs_utest) + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf include/* lib/*) + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && find src -name "*.o" -delete) + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && find utest -name "*.o" -delete) + +clean_modules: + (cd ${SRS_OBJS_DIR} && rm -rf $__mdefaults) + +clean_openssl: + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf openssl*) + +clean_srtp2: + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf libsrtp-2.0.0) + +clean_opus: + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM} && rm -rf opus-1.3.1) + +clean_nginx: + (cd ${SRS_OBJS_DIR} && rm -rf nginx) + +clean_cherrypy: + (cd research/librtmp && make clean) + (cd research/api-server/static-dir && rm -rf crossdomain.xml forward live players) + +st: + (cd ${SRS_OBJS_DIR} && rm -f srs srs_utest) + (cd ${SRS_OBJS_DIR}/${SRS_PLATFORM}/st-srs && \$(MAKE) ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}") + +ffmpeg: + (cd ${SRS_OBJS_DIR} && rm -f srs srs_utest) + (cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4.2-fit && \$(MAKE) install-libs) + END # for Makefile of all modules. @@ -608,7 +652,7 @@ librtmp: server @echo "Building the client publish/play library." \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} librtmp @echo "Building the srs-librtmp example." - (cd research/librtmp; \$(MAKE) EXTRA_CXXFLAGS="${SrsGcov}" ${SrsLibrtmpSampleEntry}) + (cd research/librtmp && \$(MAKE) EXTRA_CXXFLAGS="${SrsGcov}" ${SrsLibrtmpSampleEntry}) END else @@ -684,6 +728,11 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then else echo -e "${GREEN}Warning: SRT is disabled.${BLACK}" fi + if [ $SRS_RTC = YES ]; then + echo -e "${YELLOW}Experiment: RTC is enabled. https://github.com/ossrs/srs/issues/307${BLACK}" + else + echo -e "${GREEN}Warning: RTC is disabled.${BLACK}" + fi if [ $SRS_DVR = YES ]; then echo -e "${GREEN}DVR is enabled.${BLACK}" else diff --git a/trunk/research/players/js/srs.page.js b/trunk/research/players/js/srs.page.js index 5e5d6c956..56ff81e45 100755 --- a/trunk/research/players/js/srs.page.js +++ b/trunk/research/players/js/srs.page.js @@ -58,7 +58,7 @@ function user_extra_params(query, params) { || key === 'filename' || key === 'host' || key === 'hostname' || key === 'http_port' || key === 'pathname' || key === 'port' || key === 'server' || key === 'stream' || key === 'buffer' - || key === 'schema' || key === 'vhost' + || key === 'schema' || key === 'vhost' || key === 'api' ) { continue; } @@ -211,6 +211,7 @@ function build_default_rtc_url(query) { var vhost = (!query.vhost)? window.location.hostname:query.vhost; var app = (!query.app)? "live":query.app; var stream = (!query.stream)? "livestream":query.stream; + var api = query.api? ':'+query.api : ''; // Note that ossrs.net provides only web service, // that is migrating to r.ossrs.net @@ -227,7 +228,7 @@ function build_default_rtc_url(query) { } queries = user_extra_params(query, queries); - var uri = "webrtc://" + server + "/" + app + "/" + stream + "?" + queries.join('&'); + var uri = "webrtc://" + server + api + "/" + app + "/" + stream + "?" + queries.join('&'); while (uri.lastIndexOf("?") == uri.length - 1) { uri = uri.substr(0, uri.length - 1); } diff --git a/trunk/research/players/js/winlin.utility.js b/trunk/research/players/js/winlin.utility.js index 18fcdd60c..1a2307a38 100644 --- a/trunk/research/players/js/winlin.utility.js +++ b/trunk/research/players/js/winlin.utility.js @@ -5,7 +5,7 @@ * depends: jquery1.10 * https://gitee.com/winlinvip/codes/rpn0c2ewbomj81augzk4y59 * @see: http://blog.csdn.net/win_lin/article/details/17994347 - * v 1.0.19 + * v 1.0.20 */ /** @@ -293,7 +293,9 @@ function __fill_query(query_string, obj) { function parse_rtmp_url(rtmp_url) { // @see: http://stackoverflow.com/questions/10469575/how-to-use-location-object-to-parse-url-without-redirecting-the-page-in-javascri var a = document.createElement("a"); - a.href = rtmp_url.replace("rtmp://", "http://").replace("webrtc://", "http://"); + a.href = rtmp_url.replace("rtmp://", "http://") + .replace("webrtc://", "http://") + .replace("rtc://", "http://"); var vhost = a.hostname; var app = a.pathname.substr(1, a.pathname.lastIndexOf("/") - 1); @@ -327,7 +329,19 @@ function parse_rtmp_url(rtmp_url) { if (rtmp_url.indexOf("://") > 0) { schema = rtmp_url.substr(0, rtmp_url.indexOf("://")); } - var port = (a.port == "")? (schema=="http"?"80":"1935"):a.port; + + var port = a.port; + if (!port) { + if (schema === 'http') { + port = 80; + } else if (schema === 'https') { + port = 443; + } else if (schema === 'rtmp') { + port = 1935; + } else if (schema === 'webrtc' || schema === 'rtc') { + port = 1985; + } + } var ret = { url: rtmp_url, diff --git a/trunk/research/players/jwplayer6.html b/trunk/research/players/jwplayer6.html index f6a2da33a..68955b071 100644 --- a/trunk/research/players/jwplayer6.html +++ b/trunk/research/players/jwplayer6.html @@ -94,7 +94,7 @@ - +