diff --git a/README.md b/README.md index 5e3a32517..9b5a5e177 100755 --- a/README.md +++ b/README.md @@ -234,6 +234,12 @@ Please select according to languages: ### V2 changes +* v2.0, 2018-11-11, Merge [#1261][bug #1261], Support `_definst_` for Wowza. 2.0.260 +* v2.0, 2018-11-11, Merge [#1263][bug #1263], Fix string trim bug. 2.0.259 +* v2.0, 2018-10-28, [2.0 release5(2.0.258)][r2.0r5] released. 86916 lines. +* v2.0, 2018-10-28, Fix [#1250][bug #1250], Support build on OSX10.14 Mojave. 2.0.258 +* v2.0, 2018-10-08, Merge [#1236][bug #1236], Fix sleep bug in us. 2.0.257 +* v2.0, 2018-10-08, Merge [#1237][bug #1237], Support param for transcoder. 2.0.256 * v2.0, 2018-08-12, [2.0 release4(2.0.255)][r2.0r4] released. 86915 lines. * v2.0, 2018-08-12, For [#1202][bug #1202], Support edge/forward to Aliyun CDN. 2.0.255 * v2.0, 2018-08-11, For [#910][bug #910], Support HTTP FLV with HTTP callback. 2.0.254 @@ -1453,6 +1459,11 @@ Winlin [bug #1110]: https://github.com/ossrs/srs/issues/1110 [bug #910]: https://github.com/ossrs/srs/issues/910 [bug #1202]: https://github.com/ossrs/srs/issues/1202 +[bug #1237]: https://github.com/ossrs/srs/issues/1237 +[bug #1236]: https://github.com/ossrs/srs/issues/1236 +[bug #1250]: https://github.com/ossrs/srs/issues/1250 +[bug #1263]: https://github.com/ossrs/srs/issues/1263 +[bug #1261]: https://github.com/ossrs/srs/issues/1261 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [bug #735]: https://github.com/ossrs/srs/issues/735 @@ -1475,6 +1486,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r2.0r5]: https://github.com/ossrs/srs/releases/tag/v2.0-r5 [r2.0r4]: https://github.com/ossrs/srs/releases/tag/v2.0-r4 [r2.0r3]: https://github.com/ossrs/srs/releases/tag/v2.0-r3 [r2.0r2]: https://github.com/ossrs/srs/releases/tag/v2.0-r2 diff --git a/trunk/3rdparty/ffmpeg-4.1.zip b/trunk/3rdparty/ffmpeg-4.1.zip new file mode 100644 index 000000000..18e5e58f6 Binary files /dev/null and b/trunk/3rdparty/ffmpeg-4.1.zip differ diff --git a/trunk/3rdparty/patches/6.st.osx10.14.build.patch b/trunk/3rdparty/patches/6.st.osx10.14.build.patch new file mode 100644 index 000000000..a6e376171 --- /dev/null +++ b/trunk/3rdparty/patches/6.st.osx10.14.build.patch @@ -0,0 +1,13 @@ +--- Makefile 2018-10-28 13:49:27.000000000 +0800 ++++ ../st-1.9-patch/Makefile 2018-10-28 13:50:07.000000000 +0800 +@@ -139,8 +139,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 diff --git a/trunk/3rdparty/x264-snapshot-20131129-2245-stable.zip b/trunk/3rdparty/x264-snapshot-20131129-2245-stable.zip deleted file mode 100644 index 82224512c..000000000 Binary files a/trunk/3rdparty/x264-snapshot-20131129-2245-stable.zip and /dev/null differ diff --git a/trunk/3rdparty/x264-snapshot-20181116-2245.zip b/trunk/3rdparty/x264-snapshot-20181116-2245.zip new file mode 100644 index 000000000..295c3a54c Binary files /dev/null and b/trunk/3rdparty/x264-snapshot-20181116-2245.zip differ diff --git a/trunk/auto/build_ffmpeg.sh b/trunk/auto/build_ffmpeg.sh index 64f912cd0..23a914d94 100755 --- a/trunk/auto/build_ffmpeg.sh +++ b/trunk/auto/build_ffmpeg.sh @@ -68,41 +68,42 @@ else ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build speex-1.2rc1 failed"; exit 1; fi fi -# x264 core.138 +# x264 core.157 if [[ -f ${ff_release_dir}/lib/libx264.a ]]; then echo "x264 is ok" else echo "build x264" cd $ff_current_dir && - rm -rf x264-snapshot-20131129-2245-stable && unzip -q ${ff_src_dir}/x264-snapshot-20131129-2245-stable.zip && - cd x264-snapshot-20131129-2245-stable && - chmod +w configure && patch -p0 <../../../3rdparty/patches/5.x264.osx.gcc.patch && - ./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=8 \ + rm -rf x264-snapshot-20181116-2245 && unzip -q ${ff_src_dir}/x264-snapshot-20181116-2245.zip && + cd x264-snapshot-20181116-2245 && +# chmod +w configure && patch -p0 <../../../3rdparty/patches/5.x264.osx.gcc.patch && + ./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=all \ --enable-static --disable-avs --disable-swscale --disable-lavf \ - --disable-ffms --disable-gpac && + --disable-ffms --disable-gpac --disable-cli && make ${SRS_JOBS} && make install ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build x264 failed"; exit 1; fi fi -# ffmpeg-3.2.4 +# ffmpeg-4.1 if [[ -f ${ff_release_dir}/bin/ffmpeg ]]; then - echo "ffmpeg-3.2.4 is ok" + echo "ffmpeg-4.1 is ok" else - echo "build ffmpeg-3.2.4" + echo "build ffmpeg-4.1" cd $ff_current_dir && - rm -rf ffmpeg-3.2.4 && unzip -q ${ff_src_dir}/ffmpeg-3.2.4.zip && + rm -rf ffmpeg-4.1 && unzip -q ${ff_src_dir}/ffmpeg-4.1.zip && echo "remove all so to force the ffmpeg to build in static" && rm -f ${ff_release_dir}/lib/*.so* && echo "export the dir to enable the build command canbe use." && export ffmpeg_exported_release_dir=${ff_release_dir} && - cd ffmpeg-3.2.4 && patch -p0 <../../../3rdparty/patches/6.ffmpeg.speex.patch && ./configure \ + cd ffmpeg-4.1 && + ./configure \ --enable-gpl --enable-nonfree \ --yasmexe=${ff_yasm_bin} \ --prefix=${ff_release_dir} --cc= \ --enable-static --disable-shared --disable-debug \ --extra-cflags='-I${ffmpeg_exported_release_dir}/include' \ --extra-ldflags='-L${ffmpeg_exported_release_dir}/lib -lm -ldl' \ - --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc \ + --disable-ffplay --disable-ffprobe --disable-doc \ --enable-postproc --enable-bzlib --enable-zlib --enable-parsers \ --enable-libx264 --enable-libmp3lame --enable-libfdk-aac --enable-libspeex \ --enable-pthreads --extra-libs=-lpthread \ diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index d3de37619..de6a2be88 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -464,6 +464,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then ( rm -rf ${SRS_OBJS}/state-threads-1.9.1 && cd ${SRS_OBJS} && tar xf ../3rdparty/state-threads-1.9.1.tar.gz && cd state-threads-1.9.1 && chmod +w * && + patch -p0 < ../../3rdparty/patches/6.st.osx10.14.build.patch && make ${_ST_MAKE} CC=${SrsArmCC} AR=${SrsArmAR} LD=${SrsArmLD} RANDLIB=${SrsArmRANDLIB} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" && cd .. && rm -f st && ln -sf state-threads-1.9.1/obj st && rm -f state-threads && ln -sf state-threads-1.9.1 state-threads && @@ -478,6 +479,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then ( rm -rf ${SRS_OBJS}/state-threads-1.9.1 && cd ${SRS_OBJS} && tar xf ../3rdparty/state-threads-1.9.1.tar.gz && cd state-threads-1.9.1 && chmod +w * && + patch -p0 < ../../3rdparty/patches/6.st.osx10.14.build.patch && make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" && cd .. && rm -f st && ln -sf state-threads-1.9.1/obj st && rm -f state-threads && ln -sf state-threads-1.9.1 state-threads && @@ -669,13 +671,13 @@ if [ $SRS_SSL = YES ]; then fi ##################################################################################### -# live transcoding, ffmpeg-3.2.4, x264-core138, lame-3.99.5, libaacplus-2.0.2. +# live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2. ##################################################################################### if [ $SRS_FFMPEG_TOOL = YES ]; then if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then - echo "ffmpeg-3.2.4 is ok."; + echo "ffmpeg-4.1 is ok."; else - echo "build ffmpeg-3.2.4"; + echo "build ffmpeg-4.1"; ( cd ${SRS_OBJS} && pwd_dir=`pwd` && rm -rf ffmepg.src && mkdir -p ffmpeg.src && cd ffmpeg.src && @@ -684,8 +686,8 @@ if [ $SRS_FFMPEG_TOOL = YES ]; then ) fi # check status - ret=$?; if [[ $ret -ne 0 ]]; then echo "build ffmpeg-3.2.4 failed, ret=$ret"; exit $ret; fi - if [ ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]; then echo "build ffmpeg-3.2.4 failed."; exit -1; fi + ret=$?; if [[ $ret -ne 0 ]]; then echo "build ffmpeg-4.1 failed, ret=$ret"; exit $ret; fi + if [ ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]; then echo "build ffmpeg-4.1 failed."; exit -1; fi fi ##################################################################################### diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index b3d0ee8f2..6a3ec550c 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -866,5 +866,15 @@ function check_option_conflicts() { if [ $__check_ok = NO ]; then exit 1; fi + + if [[ $SRS_OSX == YES ]]; then + macOSVersion=`sw_vers -productVersion` + macOSVersionMajor=`echo $macOSVersion|awk -F '.' '{print $1}'` + macOSVersionMinor=`echo $macOSVersion|awk -F '.' '{print $2}'` + if [[ $macOSVersionMajor -ge 10 && $macOSVersionMinor -ge 14 ]]; then + echo "macOS $macOSVersion is not supported, read https://github.com/ossrs/srs/issues/1250" + exit -1 + fi + fi } check_option_conflicts diff --git a/trunk/src/app/srs_app_encoder.cpp b/trunk/src/app/srs_app_encoder.cpp index ef7baac70..00370f93b 100644 --- a/trunk/src/app/srs_app_encoder.cpp +++ b/trunk/src/app/srs_app_encoder.cpp @@ -282,6 +282,7 @@ srs_error_t SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, Sr output = srs_string_replace(output, "[port]", srs_int2str(req->port)); output = srs_string_replace(output, "[app]", req->app); output = srs_string_replace(output, "[stream]", req->stream); + output = srs_string_replace(output, "[param]", req->param); output = srs_string_replace(output, "[engine]", engine->arg0()); std::string log_file = SRS_CONSTS_NULL_FILE; // disabled diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 0412fa789..2c635d9e9 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -303,7 +303,7 @@ string srs_string_trim_end(string str, string trim_chars) ret.erase(ret.end() - 1); // ok, matched, should reset the search - i = 0; + i = -1; } } @@ -321,7 +321,7 @@ string srs_string_trim_start(string str, string trim_chars) ret.erase(ret.begin()); // ok, matched, should reset the search - i = 0; + i = -1; } } @@ -340,7 +340,7 @@ string srs_string_remove(string str, string remove_chars) it = ret.erase(it); // ok, matched, should reset the search - i = 0; + i = -1; } else { ++it; } @@ -350,6 +350,32 @@ string srs_string_remove(string str, string remove_chars) return ret; } +string srs_erase_first_substr(string str, string erase_string) +{ + std::string ret = str; + + size_t pos = ret.find(erase_string); + + if (pos != std::string::npos) + { + ret.erase(pos, erase_string.length()); + } + return ret; +} + +string srs_erase_last_substr(string str, string erase_string) +{ + std::string ret = str; + + size_t pos = ret.rfind(erase_string); + + if (pos != std::string::npos) + { + ret.erase(pos, erase_string.length()); + } + return ret; +} + bool srs_string_ends_with(string str, string flag) { const size_t pos = str.rfind(flag); diff --git a/trunk/src/kernel/srs_kernel_utility.hpp b/trunk/src/kernel/srs_kernel_utility.hpp index 301ec7b95..150fea0ef 100644 --- a/trunk/src/kernel/srs_kernel_utility.hpp +++ b/trunk/src/kernel/srs_kernel_utility.hpp @@ -79,6 +79,10 @@ extern std::string srs_string_trim_end(std::string str, std::string trim_chars); extern std::string srs_string_trim_start(std::string str, std::string trim_chars); // remove char in remove_chars of str extern std::string srs_string_remove(std::string str, std::string remove_chars); +// remove first substring from str +extern std::string srs_erase_first_substr(std::string str, std::string erase_string); +// remove last substring from str +extern std::string srs_erase_last_substr(std::string str, std::string erase_string); // whether string end with extern bool srs_string_ends_with(std::string str, std::string flag); extern bool srs_string_ends_with(std::string str, std::string flag0, std::string flag1); diff --git a/trunk/src/utest/srs_utest_kernel.cpp b/trunk/src/utest/srs_utest_kernel.cpp index e2e66f794..aa43a70f7 100644 --- a/trunk/src/utest/srs_utest_kernel.cpp +++ b/trunk/src/utest/srs_utest_kernel.cpp @@ -1408,6 +1408,15 @@ VOID TEST(KernelUtilityTest, UtilityString) str1 = srs_string_replace(str, "o", "XX"); EXPECT_STREQ("HellXX, WXXrld! HellXX, SRS!", str1.c_str()); + + str1 = srs_string_trim_start(str, "x"); + EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str()); + + str1 = srs_string_trim_start(str, "S!R"); + EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str()); + + str1 = srs_string_trim_start(str, "lHe"); + EXPECT_STREQ("o, World! Hello, SRS!", str1.c_str()); str1 = srs_string_trim_end(str, "x"); EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str()); @@ -1415,7 +1424,7 @@ VOID TEST(KernelUtilityTest, UtilityString) str1 = srs_string_trim_end(str, "He"); EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str()); - str1 = srs_string_trim_end(str, "HeS!R"); + str1 = srs_string_trim_end(str, "S!R"); EXPECT_STREQ("Hello, World! Hello, ", str1.c_str()); str1 = srs_string_remove(str, "x"); @@ -1426,6 +1435,18 @@ VOID TEST(KernelUtilityTest, UtilityString) str1 = srs_string_remove(str, "ol"); EXPECT_STREQ("He, Wrd! He, SRS!", str1.c_str()); + + str1 = srs_erase_first_substr(str, "Hello"); + EXPECT_STREQ(", World! Hello, SRS!", str1.c_str()); + + str1 = srs_erase_first_substr(str, "XX"); + EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str()); + + str1 = srs_erase_last_substr(str, "Hello"); + EXPECT_STREQ("Hello, World! , SRS!", str1.c_str()); + + str1 = srs_erase_last_substr(str, "XX"); + EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str()); EXPECT_FALSE(srs_string_ends_with("Hello", "x")); EXPECT_TRUE(srs_string_ends_with("Hello", "o")); diff --git a/trunk/src/utest/srs_utest_protocol.cpp b/trunk/src/utest/srs_utest_protocol.cpp index 5a32a6ba2..c15c7bae3 100644 --- a/trunk/src/utest/srs_utest_protocol.cpp +++ b/trunk/src/utest/srs_utest_protocol.cpp @@ -556,6 +556,16 @@ VOID TEST(ProtocolUtilityTest, DiscoveryTcUrl) EXPECT_STREQ("live", app.c_str()); EXPECT_STREQ("show", stream.c_str()); EXPECT_EQ(19351, port); + + // _definst_ at the end of app + tcUrl = "rtmp://winlin.cn/live/_definst_"; stream= "show"; + srs_discovery_tc_url(tcUrl, schema, ip, vhost, app, stream, port, param); + EXPECT_STREQ("rtmp", schema.c_str()); + EXPECT_STREQ("winlin.cn", ip.c_str()); + EXPECT_STREQ("winlin.cn", vhost.c_str()); + EXPECT_STREQ("live", app.c_str()); + EXPECT_STREQ("show", stream.c_str()); + EXPECT_EQ(1935, port); } /**