diff --git a/trunk/3rdparty/libsrtp-2-fit/crypto/math/datatypes.c b/trunk/3rdparty/libsrtp-2-fit/crypto/math/datatypes.c index 8a342e2af..5a9e1a938 100644 --- a/trunk/3rdparty/libsrtp-2-fit/crypto/math/datatypes.c +++ b/trunk/3rdparty/libsrtp-2-fit/crypto/math/datatypes.c @@ -79,7 +79,7 @@ int octet_get_weight(uint8_t octet) /* the value MAX_PRINT_STRING_LEN is defined in datatypes.h */ -char bit_string[MAX_PRINT_STRING_LEN]; +static char bit_string[MAX_PRINT_STRING_LEN]; uint8_t srtp_nibble_to_hex_char(uint8_t nibble) { diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 856725075..398b7791a 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -327,6 +327,23 @@ OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$re ##################################################################################### OS_IS_LOONGARCH=$(uname -p|grep -q loongarch && echo YES) +##################################################################################### +# For windows with cygwin64 +##################################################################################### +OS_IS_WINDOWS_CYGWIN64=NO +function windows_cygwin64_prepare() +{ +# TODO auto install cygwin64 tools ? + if [[ $OSTYPE == cygwin ]]; then + OS_IS_WINDOWS_CYGWIN64=YES + SRS_WINDOWS=YES + fi + + return 0 +} + +windows_cygwin64_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "windows_cygwin64 prepare failed, ret=$ret"; exit $ret; fi + ##################################################################################### # for Centos, auto install tools by yum ##################################################################################### @@ -368,11 +385,12 @@ function _srs_link_file() ##################################################################################### # Only supports: # linux, centos/ubuntu as such, +# windows(with cygwin64 toolchain) # cross build for embeded system, for example, mips or arm, # 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 && $OS_IS_OSX = NO && $SRS_CROSS_BUILD = NO ]]; then +if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO && $SRS_CROSS_BUILD = NO && $OS_IS_WINDOWS_CYGWIN64 = NO ]]; then echo "Your OS `uname -s` is not supported." exit 1 fi @@ -392,6 +410,10 @@ fi if [[ $SRS_OSX == YES ]]; then _ST_MAKE=darwin-debug && _ST_OBJ="DARWIN_`uname -r`_DBG" fi +# for windows/cygwin +if [[ $OS_IS_WINDOWS_CYGWIN64 = YES ]]; then + _ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG" +fi # Whether enable debug stats. if [[ $SRS_DEBUG_STATS == YES ]]; then _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DDEBUG_STATS" @@ -410,27 +432,24 @@ fi _ST_MAKE_ARGS="${_ST_MAKE} STATIC_ONLY=${_ST_STATIC_ONLY}" _ST_MAKE_ARGS="${_ST_MAKE_ARGS} CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB}" # Patched ST from https://github.com/ossrs/state-threads/tree/srs -if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/libst.a ]]; then - echo "The state-threads is ok."; +if [[ -f ${SRS_3RD_ST_STORE_PATH}/libst.a ]]; then + rm -rf ${SRS_3RD_ST_PATH} && + cp -rf ${SRS_3RD_ST_STORE_PATH} ${SRS_OBJS} && + echo -e "The state-threads is ok."; else echo "Building state-threads."; ( - 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/ ./ ./ && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && + cp -rf ${SRS_WORKDIR}/3rdparty/st-srs ${SRS_OBJS}/${SRS_PLATFORM} && + cd ${SRS_OBJS}/${SRS_PLATFORM}/st-srs && # Build source code. env EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" make ${_ST_MAKE_ARGS} && - cd .. && rm -rf st && ln -sf st-srs/${_ST_OBJ} st + cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/* ${SRS_3RD_ST_PATH} && + cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/st-srs/${_ST_OBJ}/* ${SRS_3RD_ST_STORE_PATH} ) 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}/${SRS_PLATFORM} && rm -rf st && ln -sf st-srs/${_ST_OBJ} st) -(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 ##################################################################################### # nginx for HLS, nginx-1.5.0 @@ -453,23 +472,23 @@ html_file=${SRS_OBJS}/nginx/html/live/livestream.html && hls_stream=livestream.m # copy players to nginx html dir. rm -rf ${SRS_OBJS}/nginx/html/players && -ln -sf `pwd`/research/players ${SRS_OBJS}/nginx/html/players +cp -rf `pwd`/research/players ${SRS_OBJS}/nginx/html/ # for favicon.ico rm -rf ${SRS_OBJS}/nginx/html/favicon.ico && -ln -sf `pwd`/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico +cp -f `pwd`/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico # For srs-console. rm -rf ${SRS_OBJS}/nginx/html/console && -ln -sf `pwd`/research/console ${SRS_OBJS}/nginx/html/console +cp -rf `pwd`/research/console ${SRS_OBJS}/nginx/html/ # For SRS signaling. rm -rf ${SRS_OBJS}/nginx/html/demos && -ln -sf `pwd`/3rdparty/signaling/www/demos ${SRS_OBJS}/nginx/html/demos +cp -rf `pwd`/3rdparty/signaling/www/demos ${SRS_OBJS}/nginx/html/ # For home page index.html rm -rf ${SRS_OBJS}/nginx/html/index.html && -ln -sf `pwd`/research/api-server/static-dir/index.html ${SRS_OBJS}/nginx/html/index.html +cp -f `pwd`/research/api-server/static-dir/index.html ${SRS_OBJS}/nginx/html/index.html # nginx.html to detect whether nginx is alive echo "Nginx is ok." > ${SRS_OBJS}/nginx/html/nginx.html @@ -526,15 +545,15 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then if [[ $SRS_CROSS_BUILD_ARCH == "arm" ]]; then OPENSSL_CONFIG="./Configure linux-armv4"; fi if [[ $SRS_CROSS_BUILD_ARCH == "aarch64" ]]; then OPENSSL_CONFIG="./Configure linux-aarch64"; fi if [[ $SRS_CROSS_BUILD_ARCH == "mipsel" ]]; then OPENSSL_CONFIG="./Configure linux-mips32"; fi - elif [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then + elif [[ ! -f ${SRS_3RD_OPENSSL_STORE_PATH}/lib/libssl.a ]]; then # Try to use exists libraries. - if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == NO ]]; then - (mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && - ln -sf /usr/local/ssl/lib/libssl.a && ln -sf /usr/local/ssl/lib/libcrypto.a && - mkdir -p /usr/local/ssl/lib/pkgconfig && ln -sf /usr/local/ssl/lib/pkgconfig) - (mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && - ln -sf /usr/local/ssl/include/openssl) - fi + #if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == NO ]]; then + # (mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib && + # ln -sf /usr/local/ssl/lib/libssl.a && ln -sf /usr/local/ssl/lib/libcrypto.a && + # mkdir -p /usr/local/ssl/lib/pkgconfig && ln -sf /usr/local/ssl/lib/pkgconfig) + # (mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && cd ${SRS_OBJS}/${SRS_PLATFORM}/openssl/include && + # ln -sf /usr/local/ssl/include/openssl) + #fi # Warning if not use the system ssl. if [[ -f /usr/local/ssl/lib/libssl.a && $SRS_SSL_LOCAL == YES ]]; then echo "Warning: Local openssl is on, ignore system openssl" @@ -553,10 +572,10 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then # Use 1.0 if required. if [[ $SRS_SSL_1_0 == YES ]]; then OPENSSL_AR="$SRS_TOOL_AR -r" # For openssl 1.0, MUST specifies the args for ar or build faild. - OPENSSL_CANDIDATE="openssl-OpenSSL_1_0_2u" && OPENSSL_UNZIP="tar xf ../../3rdparty/$OPENSSL_CANDIDATE.tar.gz" + OPENSSL_CANDIDATE="openssl-OpenSSL_1_0_2u" && OPENSSL_UNZIP="tar xf ${SRS_WORKDIR}/3rdparty/$OPENSSL_CANDIDATE.tar.gz" else OPENSSL_AR="$SRS_TOOL_AR" - OPENSSL_CANDIDATE="openssl-1.1-fit" && OPENSSL_UNZIP="cp -R ../../3rdparty/$OPENSSL_CANDIDATE ." + OPENSSL_CANDIDATE="openssl-1.1-fit" && OPENSSL_UNZIP="cp -R ${SRS_WORKDIR}/3rdparty/$OPENSSL_CANDIDATE ." fi # # https://wiki.openssl.org/index.php/Compilation_and_Installation#Configure_Options @@ -567,28 +586,27 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then #OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-ssl2 -no-comp -no-idea -no-hw -no-engine -no-dso -no-err -no-nextprotoneg -no-psk -no-srp -no-ec2m -no-weak-ssl-ciphers" # # cross build not specified, if exists flag, need to rebuild for no-arm platform. - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/$OPENSSL_CANDIDATE/_release/lib/libssl.a ]]; then + if [[ -f ${SRS_3RD_OPENSSL_STORE_PATH}/lib/libssl.a ]]; then + rm -rf ${SRS_3RD_OPENSSL_PATH} && + cp -rf ${SRS_3RD_OPENSSL_STORE_PATH} ${SRS_OBJS} && echo "The $OPENSSL_CANDIDATE is ok."; else echo "Building $OPENSSL_CANDIDATE."; ( - rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} && cd ${SRS_OBJS}/${SRS_PLATFORM} && - ${OPENSSL_UNZIP} && cd $OPENSSL_CANDIDATE && ${OPENSSL_CONFIG} --prefix=`pwd`/_release $OPENSSL_OPTIONS && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} && + cd ${SRS_OBJS}/${SRS_PLATFORM} && + ${OPENSSL_UNZIP} && cd $OPENSSL_CANDIDATE && ${OPENSSL_CONFIG} --prefix=${SRS_3RD_OPENSSL_STORE_PATH} $OPENSSL_OPTIONS && make CC=${SRS_TOOL_CC} AR="${OPENSSL_AR}" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} && make install_sw && - cd .. && rm -rf openssl && ln -sf $OPENSSL_CANDIDATE/_release openssl + cp -rf ${SRS_3RD_OPENSSL_STORE_PATH} ${SRS_OBJS} ) fi # Which lib we use. - OPENSSL_LIB="$OPENSSL_CANDIDATE/_release" - if [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_LIB}/lib/libssl.a ]]; then - OPENSSL_LIB="openssl" - fi + #OPENSSL_LIB="$OPENSSL_CANDIDATE/_release" + #if [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_LIB}/lib/libssl.a ]]; then + # OPENSSL_LIB="openssl" + #fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build $OPENSSL_CANDIDATE failed, ret=$ret"; exit $ret; fi - # Always update the links. - (cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf openssl && ln -sf $OPENSSL_CANDIDATE/_release openssl) - (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_CANDIDATE failed."; exit -1; fi fi ##################################################################################### @@ -599,7 +617,7 @@ if [[ $SRS_RTC == YES ]]; then # If use ASM for SRTP, we enable openssl(with ASM). if [[ $SRS_SRTP_ASM == YES ]]; then SRTP_OPTIONS="--enable-openssl" - SRTP_CONFIGURE="env PKG_CONFIG_PATH=$(cd ${SRS_OBJS}/${SRS_PLATFORM} && pwd)/openssl/lib/pkgconfig ./configure" + SRTP_CONFIGURE="env PKG_CONFIG_PATH=${SRS_3RD_OPENSSL_PATH}/lib/pkgconfig ./configure" else SRTP_CONFIGURE="./configure" fi @@ -610,25 +628,24 @@ if [[ $SRS_RTC == YES ]]; then SRTP_OPTIONS="$SRTP_OPTIONS --build=loongarch64-unknown-linux-gnu" fi # Patched ST from https://github.com/ossrs/state-threads/tree/srs - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/_release/lib/libsrtp2.a ]]; then + if [[ -f ${SRS_3RD_SRTP2_STORE_PATH}/lib/libsrtp2.a ]]; then + rm -rf ${SRS_3RD_SRTP2_PATH} && + cp -rf ${SRS_3RD_SRTP2_STORE_PATH} ${SRS_OBJS} && echo "The libsrtp-2-fit is ok."; else echo "Building libsrtp-2-fit."; ( - rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} && - rm -rf libsrtp-2-fit && cp -R ../../3rdparty/libsrtp-2-fit . && cd libsrtp-2-fit && - patch -p0 crypto/math/datatypes.c ../../../3rdparty/patches/srtp/gcc10-01.patch && - $SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=`pwd`/_release && + rm -rf ${SRS_3RD_SRTP2_PATH} && + cd ${SRS_OBJS}/${SRS_PLATFORM} && + rm -rf libsrtp-2-fit && + cp -R ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit . && + cd libsrtp-2-fit && + patch -p0 crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/gcc10-01.patch && + $SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_3RD_SRTP2_STORE_PATH} && make ${SRS_JOBS} && make install && - cd .. && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2 + cp -rf ${SRS_3RD_SRTP2_STORE_PATH} ${SRS_OBJS} ) fi - # check status - ret=$?; if [[ $ret -ne 0 ]]; then echo "Build libsrtp-2-fit failed, ret=$ret"; exit $ret; fi - # Always update the links. - (cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2) - (cd ${SRS_OBJS} && rm -rf srtp2 && ln -sf ${SRS_PLATFORM}/libsrtp-2-fit/_release srtp2) - if [ ! -f ${SRS_OBJS}/srtp2/lib/libsrtp2.a ]; then echo "Build libsrtp-2-fit static lib failed."; exit -1; fi fi ##################################################################################### @@ -643,24 +660,25 @@ if [[ $SRS_RTC == YES && $SRS_CROSS_BUILD == NO ]]; then if [[ $OS_IS_LOONGARCH = YES ]]; then OPUS_OPTIONS="$OPUS_OPTIONS --build=loongarch64-unknown-linux-gnu" fi - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1/_release/lib/libopus.a ]]; then + if [[ -f ${SRS_3RD_OPUS_STORE_PATH}/lib/libopus.a ]]; then + rm -rf ${SRS_3RD_OPUS_PATH} && + cp -rf ${SRS_3RD_OPUS_STORE_PATH} ${SRS_OBJS} && echo "The opus-1.3.1 is ok."; else echo "Building 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 $OPUS_OPTIONS && - make ${SRS_JOBS} && make install && - cd .. && rm -rf opus && ln -sf opus-1.3.1/_release opus + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/opus-1.3.1 && + cd ${SRS_OBJS}/${SRS_PLATFORM} && + tar xf ${SRS_WORKDIR}/3rdparty/opus-1.3.1.tar.gz && + cd opus-1.3.1 && + ./configure --prefix=${SRS_3RD_OPUS_STORE_PATH} --enable-static $OPUS_OPTIONS && + make ${SRS_JOBS} && + make install && + cp -rf ${SRS_3RD_OPUS_STORE_PATH} ${SRS_OBJS} ) 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}/${SRS_PLATFORM} && rm -rf opus && ln -sf opus-1.3.1/_release opus) - (cd ${SRS_OBJS} && rm -rf 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 ##################################################################################### @@ -671,7 +689,7 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then if [[ $SRS_CROSS_BUILD == YES ]]; then FFMPEG_CONFIGURE=./configure else - FFMPEG_CONFIGURE="env PKG_CONFIG_PATH=$(cd ${SRS_OBJS}/${SRS_PLATFORM} && pwd)/opus/lib/pkgconfig ./configure" + FFMPEG_CONFIGURE="env PKG_CONFIG_PATH=${SRS_3RD_OPUS_STORE_PATH}/lib/pkgconfig ./configure" fi # If disable nasm, disable all ASMs. @@ -695,17 +713,19 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then FFMPEG_OPTIONS="$FFMPEG_OPTIONS --enable-decoder=libopus --enable-encoder=libopus --enable-libopus" fi - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit/_release/lib/libavcodec.a ]]; then + if [[ -f ${SRS_3RD_FFMPEG_STORE_PATH}/lib/libavcodec.a ]]; then + rm -rf ${SRS_3RD_FFMPEG_PATH} && + cp -rf ${SRS_3RD_FFMPEG_STORE_PATH} ${SRS_OBJS} && echo "The ffmpeg-4-fit is ok."; else echo "Building ffmpeg-4-fit."; ( - rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && - # Create a hidden directory .src - cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && cp -R ../../../3rdparty/ffmpeg-4-fit/* . && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && + cp -rf ${SRS_WORKDIR}/3rdparty/ffmpeg-4-fit ${SRS_OBJS}/${SRS_PLATFORM} && + cd ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg-4-fit && # Build source code. $FFMPEG_CONFIGURE \ - --prefix=`pwd`/_release --pkg-config=pkg-config \ + --prefix=${SRS_3RD_FFMPEG_STORE_PATH} --pkg-config=pkg-config \ --pkg-config-flags="--static" --extra-libs="-lpthread" --extra-libs="-lm" \ --disable-everything ${FFMPEG_OPTIONS} \ --disable-programs --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages \ @@ -740,31 +760,26 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then fi fi && make ${SRS_JOBS} && make install && - cd .. && rm -rf ffmpeg && ln -sf ffmpeg-4-fit/_release ffmpeg + cp -rf ${SRS_3RD_FFMPEG_STORE_PATH} ${SRS_OBJS} ) fi # check status ret=$?; if [[ $ret -ne 0 ]]; then echo "Build ffmpeg-4-fit failed, ret=$ret"; exit $ret; fi - # Always update the links. - (cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf ffmpeg && ln -sf ffmpeg-4-fit/_release ffmpeg) - (cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg-4-fit/_release ffmpeg) - if [ ! -f ${SRS_OBJS}/ffmpeg/lib/libavcodec.a ]; then echo "Build ffmpeg-4-fit failed."; exit -1; fi fi ##################################################################################### # live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2. ##################################################################################### # Guess whether the ffmpeg is. -SYSTEMP_FFMPEG_BIN=/usr/local/bin/ffmpeg -if [[ ! -f $SYSTEMP_FFMPEG_BIN ]]; then SYSTEMP_FFMPEG_BIN=/usr/local/ffmpeg/bin/ffmpeg; fi +SYSTEMP_FFMPEG_BIN=`which ffmpeg` # Always link the ffmpeg tools if exists. -if [[ -f $SYSTEMP_FFMPEG_BIN && ! -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg ]]; then - mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin && - ln -sf $SYSTEMP_FFMPEG_BIN ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg && - (cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg) +if [[ -f $SYSTEMP_FFMPEG_BIN && ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then + mkdir -p ${SRS_OBJS}/ffmpeg/bin && + cp -f $SYSTEMP_FFMPEG_BIN ${SRS_OBJS}/ffmpeg/bin/ fi if [ $SRS_FFMPEG_TOOL = YES ]; then - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg/bin/ffmpeg ]]; then + if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then + cp -f $SYSTEMP_FFMPEG_BIN ${SRS_OBJS}/ffmpeg/bin/ && echo "ffmpeg-4.1 is ok."; else echo -e "${RED}Error: No FFmpeg found at /usr/local/bin/ffmpeg${BLACK}" @@ -773,22 +788,20 @@ if [ $SRS_FFMPEG_TOOL = YES ]; then echo -e "${RED} or disable it by --without-ffmpeg${BLACK}" exit -1; fi - # Always update the links. - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/ffmpeg ]]; then - (cd ${SRS_OBJS} && rm -rf ffmpeg && ln -sf ${SRS_PLATFORM}/ffmpeg) - fi fi ##################################################################################### # SRT module, https://github.com/ossrs/srs/issues/1147#issuecomment-577469119 ##################################################################################### if [[ $SRS_SRT == YES ]]; then - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/srt/lib/libsrt.a ]]; then + if [[ -f ${SRS_3RD_SRT_STORE_PATH}/lib/libsrt.a ]]; then + rm -rf SRS_3RD_SRT_PATH && + cp -rf ${SRS_3RD_SRT_STORE_PATH} ${SRS_OBJS} && echo "libsrt-1-fit is ok."; else echo "Build srt-1-fit" ( - if [[ ! -d ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/pkgconfig ]]; then + if [[ ! -d ${SRS_3RD_OPENSSL_STORE_PATH}/lib/pkgconfig ]]; then echo "OpenSSL pkgconfig no found, build srt-1-fit failed."; exit -1; fi @@ -799,45 +812,46 @@ if [[ $SRS_SRT == YES ]]; then else LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=0" fi + + if [[ $SRS_WINDOWS == YES ]]; then + LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix" + fi + # Start build libsrt. - rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit && cd ${SRS_OBJS}/${SRS_PLATFORM} && - cp -R ../../3rdparty/srt-1-fit srt-1-fit && cd srt-1-fit && - PKG_CONFIG_PATH=../openssl/lib/pkgconfig ./configure --prefix=`pwd`/_release $LIBSRT_OPTIONS && + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/srt-1-fit && + cd ${SRS_OBJS}/${SRS_PLATFORM} && + cp -rf ${SRS_WORKDIR}/3rdparty/srt-1-fit ${SRS_OBJS}/${SRS_PLATFORM} && + cd srt-1-fit && + PKG_CONFIG_PATH=${SRS_3RD_OPENSSL_PATH}/lib/pkgconfig ./configure --prefix=${SRS_3RD_SRT_STORE_PATH} $LIBSRT_OPTIONS && make ${SRS_JOBS} && make install && - cd .. && rm -rf srt && ln -sf srt-1-fit/_release srt && + # If exists lib64 of libsrt, link it to lib - if [[ -d srt/lib64 ]]; then - cd srt && ln -sf lib64 lib - fi + if [[ -d ${SRS_3RD_SRT_STORE_PATH}/lib64 ]]; then + mv ${SRS_3RD_SRT_STORE_PATH}/lib64 ${SRS_3RD_SRT_STORE_PATH}/lib + fi && + + cp -rf ${SRS_3RD_SRT_STORE_PATH} ${SRS_OBJS} ) ret=$?; if [[ $ret -ne 0 ]]; then echo "Build srt-1-fit failed, ret=$ret"; exit $ret; fi fi - # Always update the links. - (cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf srt && ln -sf srt-1-fit/_release srt) - (cd ${SRS_OBJS} && rm -rf srt && ln -sf ${SRS_PLATFORM}/srt-1-fit/_release srt) - if [ ! -f ${SRS_OBJS}/srt/lib/libsrt.a ]; then echo "Build srt-1-fit failed."; exit -1; fi fi ##################################################################################### # build utest code ##################################################################################### if [ $SRS_UTEST = YES ]; then - if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0/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}/${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 + rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/gtest && cd ${SRS_OBJS}/${SRS_PLATFORM} && + unzip -q ${SRS_WORKDIR}/3rdparty/gtest-1.6.0.zip && + mv ${SRS_OBJS}/${SRS_PLATFORM}/gtest-1.6.0 ${SRS_OBJS}/${SRS_PLATFORM}/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}/${SRS_PLATFORM} && rm -rf gtest && ln -sf gtest-1.6.0 gtest) - (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 ##################################################################################### diff --git a/trunk/auto/setup_variables.sh b/trunk/auto/setup_variables.sh index cf9b1a98b..1cea717f4 100755 --- a/trunk/auto/setup_variables.sh +++ b/trunk/auto/setup_variables.sh @@ -5,6 +5,10 @@ OS_KERNEL_NAME=$(uname -s) OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}') OS_PREFIX="Platform" +if [[ $OSTYPE == cygwin ]]; then + OS_KERNRL_RELEASE=$(uname -r|awk -F '(' '{print $1}') +fi + # Build platform cache. SRS_PLATFORM="${SRS_BUILD_TAG}${OS_PREFIX}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}" # Build platform cache with gcc version. @@ -23,17 +27,55 @@ if [[ $SRS_CROSS_BUILD == YES ]]; then SRS_PLATFORM="${SRS_PLATFORM}-CROSSBUILD-$(echo $SRS_TOOL_CC|awk -F - '{print $1}')" fi +#TODO find the link lib in objs/Platform_some_platfomr/3rdpatry/some-lib +# 3rdparty lib path +# eg: objs/st, objs/ffmpeg etc. +SRS_3RD_ST_PATH=${SRS_OBJS}/st +SRS_3RD_FFMPEG_PATH=${SRS_OBJS}/ffmpeg +SRS_3RD_OPUS_PATH=${SRS_OBJS}/opus +SRS_3RD_SRTP2_PATH=${SRS_OBJS}/srtp2 +SRS_3RD_OPENSSL_PATH=${SRS_OBJS}/openssl +SRS_3RD_SRT_PATH=${SRS_OBJS}/srt + +# 3rdparty lib store path +# eg: objs/Platform-CYGWIN_NT-10.0-3.2.0-GCC11.2.0-SRS5-x86_64/3rdpatry/st +SRS_3RD_ST_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/st +SRS_3RD_FFMPEG_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/ffmpeg +SRS_3RD_OPUS_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/opus +SRS_3RD_SRTP2_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2 +SRS_3RD_OPENSSL_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/openssl +SRS_3RD_SRT_STORE_PATH=${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt + 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 + # on windows, clean *.exe + rm -rf srs.exe srs_utest.exe srs_hls_ingester.exe srs_mp4_parser.exe && + mkdir -p ${SRS_PLATFORM}/src && + mkdir -p ${SRS_PLATFORM}/research && + mkdir -p ${SRS_PLATFORM}/include && + mkdir -p ${SRS_PLATFORM}/lib && + mkdir -p ${SRS_PLATFORM}/utest && + + rm -rf st ffmpeg opus srtp2 openssl srt && + # objs/some-lib + mkdir -p ${SRS_3RD_ST_PATH} && + mkdir -p ${SRS_3RD_FFMPEG_PATH} && + mkdir -p ${SRS_3RD_OPUS_PATH} && + mkdir -p ${SRS_3RD_SRTP2_PATH} && + mkdir -p ${SRS_3RD_OPENSSL_PATH} && + mkdir -p ${SRS_3RD_SRT_STORE_PATH} && + + # objs/Platform_some_platform/3rdpatry/some-lib + mkdir -p ${SRS_3RD_ST_STORE_PATH} && + mkdir -p ${SRS_3RD_FFMPEG_STORE_PATH} && + mkdir -p ${SRS_3RD_OPUS_STORE_PATH} && + mkdir -p ${SRS_3RD_SRTP2_STORE_PATH} && + mkdir -p ${SRS_3RD_OPENSSL_STORE_PATH} && + mkdir -p ${SRS_3RD_SRT_STORE_PATH} ) if [[ $SRS_CLEAN == NO ]]; then 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 d77964e96..f24b8f6b4 100755 --- a/trunk/auto/utest.sh +++ b/trunk/auto/utest.sh @@ -9,16 +9,16 @@ # $MODULE_DIR the src dir of utest code. ie. src/utest # $LINK_OPTIONS the link options for utest. ie. -lpthread -ldl -FILE=${SRS_OBJS}/utest/${SRS_MAKEFILE} +FILE=${SRS_OBJS}/${SRS_PLATFORM}/utest/${SRS_MAKEFILE} # create dir for Makefile -mkdir -p ${SRS_OBJS}/utest +mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/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=../../.. # gest dir, relative to objs/utest, it's trunk/objs/gtest -GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest +GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/${SRS_PLATFORM}/gtest cat << END > ${FILE} # user must run make the ${SRS_OBJS_DIR}/utest dir diff --git a/trunk/configure b/trunk/configure index 5dd33e621..6bb47e3b3 100755 --- a/trunk/configure +++ b/trunk/configure @@ -4,7 +4,7 @@ # the main output dir, all configure and make output are in this dir. ##################################################################################### # create the main objs -SRS_WORKDIR="." +SRS_WORKDIR=`pwd` SRS_OBJS_DIR="objs" SRS_OBJS="${SRS_WORKDIR}/${SRS_OBJS_DIR}" SRS_MAKEFILE="Makefile" @@ -87,6 +87,9 @@ CppStd="-ansi" if [[ $SRS_CXX11 == YES ]]; then CppStd="-std=c++11" fi +if [[ $SRS_WINDOWS == YES ]]; then + CppStd="-std=gnu++11" +fi if [[ $SRS_CXX14 == YES ]]; then CppStd="-std=c++14" fi @@ -164,7 +167,7 @@ fi # srt code path if [[ $SRS_SRT == YES ]]; then - SrsSRTRoot="${SRS_WORKDIR}/src/srt" + SrsSRTRoot="src/srt" LibSRTRoot="${SRS_OBJS_DIR}/srt/include"; LibSRTfile="${SRS_OBJS_DIR}/srt/lib/libsrt.a" if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-L${SRS_OBJS_DIR}/srt/lib -lsrt"; fi fi @@ -188,10 +191,15 @@ if [[ $SRS_GCOV == YES ]]; then fi # For FFMPEG/RTC on Linux. -if [[ $SRS_OSX != YES && $SRS_RTC == YES && $SRS_FFMPEG_FIT == YES ]]; then +if [[ $SRS_OSX != YES && $SRS_WINDOWS != YES && $SRS_RTC == YES && $SRS_FFMPEG_FIT == YES ]]; then SrsLinkOptions="${SrsLinkOptions} -lrt"; fi +# For FFMPEG/RTC on windows. +if [[ $SRS_WINDOWS == YES && $SRS_FFMPEG_FIT == YES ]]; then + SrsLinkOptions="${SrsLinkOptions} -lbcrypt"; +fi + ##################################################################################### # Modules, compile each module, then link to binary # diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 9ba3357eb..9a64f079e 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -13,7 +13,7 @@ #include #include #include -#ifndef SRS_OSX +#if !defined(SRS_OSX) && !defined(SRS_WINDOWS) #include #endif using namespace std; @@ -370,7 +370,7 @@ srs_error_t SrsInotifyWorker::start() { srs_error_t err = srs_success; -#ifndef SRS_OSX +#if !defined(SRS_OSX) && !defined(SRS_WINDOWS) // Whether enable auto reload config. bool auto_reload = _srs_config->inotify_auto_reload(); if (!auto_reload && _srs_in_docker && _srs_config->auto_reload_for_docker()) { @@ -450,7 +450,7 @@ srs_error_t SrsInotifyWorker::cycle() { srs_error_t err = srs_success; -#ifndef SRS_OSX +#if !defined(SRS_OSX) && !defined(SRS_WINDOWS) string config_path = _srs_config->config(); string config_file = srs_path_basename(config_path); string k8s_file = "..data"; diff --git a/trunk/src/app/srs_app_uuid.cpp b/trunk/src/app/srs_app_uuid.cpp index 721efbf7b..4429f246e 100644 --- a/trunk/src/app/srs_app_uuid.cpp +++ b/trunk/src/app/srs_app_uuid.cpp @@ -226,10 +226,6 @@ static inline __attribute__((const)) int is_power_of_2(unsigned long num) return (num != 0 && ((num & (num - 1)) == 0)); } -#ifndef HAVE_LOFF_T -typedef int64_t loff_t; -#endif - #if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD) #include #include @@ -1075,8 +1071,6 @@ void uuid_generate(uuid_t out) #include #include -#include - //#include "randutils.h" #ifdef HAVE_TLS diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp index d1067eefb..0324c4a99 100644 --- a/trunk/src/kernel/srs_kernel_error.hpp +++ b/trunk/src/kernel/srs_kernel_error.hpp @@ -101,6 +101,7 @@ #define ERROR_SOCKET_SETREUSEADDR 1079 #define ERROR_SOCKET_SETCLOSEEXEC 1080 #define ERROR_SOCKET_ACCEPT 1081 +#define ERROR_ST_SET_SELECT 1082 /////////////////////////////////////////////////////// // RTMP protocol error. diff --git a/trunk/src/protocol/srs_service_st.cpp b/trunk/src/protocol/srs_service_st.cpp index 65fa523f4..dbeb6b8d7 100644 --- a/trunk/src/protocol/srs_service_st.cpp +++ b/trunk/src/protocol/srs_service_st.cpp @@ -48,9 +48,15 @@ srs_error_t srs_st_init() // Select the best event system available on the OS. In Linux this is // epoll(). On BSD it will be kqueue. - if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) { - return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name()); +#ifdef SRS_WINDOWS + if (st_set_eventsys(ST_EVENTSYS_SELECT) == -1) { + return srs_error_new(ERROR_ST_SET_SELECT, "st enable st failed, current is %s", st_get_eventsys_name()); } +#else + if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) { + return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name()); + } +#endif // Before ST init, we might have already initialized the background cid. SrsContextId cid = _srs_context->get_id();