From 816aa91a7fc4909c82e66f33758e23406113d8e0 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 13 Jan 2020 14:48:49 +0800 Subject: [PATCH 01/23] Fix utest bug, init fd --- trunk/src/utest/srs_utest_service.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trunk/src/utest/srs_utest_service.cpp b/trunk/src/utest/srs_utest_service.cpp index 7532e42a9..87a1c49d1 100644 --- a/trunk/src/utest/srs_utest_service.cpp +++ b/trunk/src/utest/srs_utest_service.cpp @@ -835,6 +835,7 @@ public: SrsSTCoroutine trd; srs_netfd_t fd; MockOnCycleThread3() : trd("mock", this, 0) { + fd = NULL; }; virtual ~MockOnCycleThread3() { trd.stop(); @@ -1087,6 +1088,7 @@ public: SrsSTCoroutine trd; srs_netfd_t fd; MockOnCycleThread4() : trd("mock", this, 0) { + fd = NULL; }; virtual ~MockOnCycleThread4() { trd.stop(); From 857c783efcf42bb11a9cb9e90f395f6b1dca5796 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 15 Jan 2020 19:51:33 +0800 Subject: [PATCH 02/23] For #1509, release coroutine when source is idle. 3.0.98 --- README.md | 2 ++ trunk/src/app/srs_app_dvr.cpp | 25 ++++++++++++++++++++++++- trunk/src/app/srs_app_dvr.hpp | 4 ++-- trunk/src/app/srs_app_hls.cpp | 24 +++++++++++++++++++++--- trunk/src/app/srs_app_hls.hpp | 3 +++ trunk/src/core/srs_core.hpp | 2 +- 6 files changed, 53 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d66e35146..31b8e31f2 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98 * v3.0, 2020-01-10, [3.0 alpha8(3.0.97)][r3.0a8] released. 121555 lines. * v3.0, 2020-01-09, For [#1042][bug #1042], improve test coverage for service. 3.0.97 * v3.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 3.0.96 @@ -1592,6 +1593,7 @@ Winlin [bug #1544]: https://github.com/ossrs/srs/issues/1544 [bug #1255]: https://github.com/ossrs/srs/issues/1255 [bug #1543]: https://github.com/ossrs/srs/issues/1543 +[bug #1509]: https://github.com/ossrs/srs/issues/1509 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_dvr.cpp b/trunk/src/app/srs_app_dvr.cpp index d29d22a23..507956aed 100644 --- a/trunk/src/app/srs_app_dvr.cpp +++ b/trunk/src/app/srs_app_dvr.cpp @@ -609,13 +609,25 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque return srs_error_wrap(err, "segmenter"); } + return err; +} + +srs_error_t SrsDvrPlan::on_publish() +{ + srs_error_t err = srs_success; + if ((err = async->start()) != srs_success) { return srs_error_wrap(err, "async"); } - + return err; } +void SrsDvrPlan::on_unpublish() +{ + async->stop(); +} + srs_error_t SrsDvrPlan::on_meta_data(SrsSharedPtrMessage* shared_metadata) { srs_error_t err = srs_success; @@ -699,6 +711,10 @@ SrsDvrSessionPlan::~SrsDvrSessionPlan() srs_error_t SrsDvrSessionPlan::on_publish() { srs_error_t err = srs_success; + + if ((err = SrsDvrPlan::on_publish()) != srs_success) { + return err; + } // support multiple publish. if (dvr_enabled) { @@ -724,6 +740,8 @@ srs_error_t SrsDvrSessionPlan::on_publish() void SrsDvrSessionPlan::on_unpublish() { + SrsDvrPlan::on_unpublish(); + // support multiple publish. if (!dvr_enabled) { return; @@ -766,6 +784,10 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, S srs_error_t SrsDvrSegmentPlan::on_publish() { srs_error_t err = srs_success; + + if ((err = SrsDvrPlan::on_publish()) != srs_success) { + return err; + } // support multiple publish. if (dvr_enabled) { @@ -791,6 +813,7 @@ srs_error_t SrsDvrSegmentPlan::on_publish() void SrsDvrSegmentPlan::on_unpublish() { + SrsDvrPlan::on_unpublish(); } srs_error_t SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format) diff --git a/trunk/src/app/srs_app_dvr.hpp b/trunk/src/app/srs_app_dvr.hpp index 62ea1cb1e..716d45e0e 100644 --- a/trunk/src/app/srs_app_dvr.hpp +++ b/trunk/src/app/srs_app_dvr.hpp @@ -185,8 +185,8 @@ public: virtual ~SrsDvrPlan(); public: virtual srs_error_t initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r); - virtual srs_error_t on_publish() = 0; - virtual void on_unpublish() = 0; + virtual srs_error_t on_publish(); + virtual void on_unpublish(); virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata); virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format); virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format); diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 0f18f74a5..72ec535ca 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -268,16 +268,27 @@ int SrsHlsMuxer::deviation() } srs_error_t SrsHlsMuxer::initialize() +{ + return srs_success; +} + +srs_error_t SrsHlsMuxer::on_publish(SrsRequest* req) { srs_error_t err = srs_success; - + if ((err = async->start()) != srs_success) { return srs_error_wrap(err, "async start"); } - + return err; } +srs_error_t SrsHlsMuxer::on_unpublish() +{ + async->stop(); + return srs_success; +} + srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, string path, string m3u8_file, string ts_file, srs_utime_t fragment, srs_utime_t window, bool ts_floor, double aof_ratio, bool cleanup, bool wait_keyframe, bool keys, @@ -899,8 +910,11 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req) // TODO: FIXME: support load exists m3u8, to continue publish stream. // for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase. + + if ((err = muxer->on_publish(req)) != srs_success) { + return srs_error_wrap(err, "muxer publish"); + } - // open muxer if ((err = muxer->update_config(req, entry_prefix, path, m3u8_file, ts_file, hls_fragment, hls_window, ts_floor, hls_aof_ratio, cleanup, wait_keyframe,hls_keys,hls_fragments_per_key, hls_key_file, hls_key_file_path, hls_key_url)) != srs_success ) { @@ -924,6 +938,10 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req) srs_error_t SrsHlsController::on_unpublish() { srs_error_t err = srs_success; + + if ((err = muxer->on_unpublish()) != srs_success) { + return srs_error_wrap(err, "muxer unpublish"); + } if ((err = muxer->flush_audio(tsmc)) != srs_success) { return srs_error_wrap(err, "hls: flush audio"); diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index 194c183fb..1dd72eba5 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -185,6 +185,9 @@ public: public: // Initialize the hls muxer. virtual srs_error_t initialize(); + // When publish or unpublish stream. + virtual srs_error_t on_publish(SrsRequest* req); + virtual srs_error_t on_unpublish(); // When publish, update the config for muxer. virtual srs_error_t update_config(SrsRequest* r, std::string entry_prefix, std::string path, std::string m3u8_file, std::string ts_file, diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 5a80e8f8e..b6aa58342 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 97 +#define VERSION_REVISION 98 // The macros generated by configure script. #include From 7240fe304092a91c97bc36fb3f0c1d34f41f506c Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 15 Jan 2020 21:26:02 +0800 Subject: [PATCH 03/23] For #1509, decrease the fast vector init size from 64KB to 64B. 3.0.99 --- README.md | 1 + trunk/auto/options.sh | 20 ++++---------------- trunk/auto/summary.sh | 5 +---- trunk/src/app/srs_app_config.cpp | 8 ++++---- trunk/src/app/srs_app_http_stream.cpp | 8 ++++---- trunk/src/app/srs_app_source.cpp | 4 ++-- trunk/src/core/srs_core.hpp | 2 +- 7 files changed, 17 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 31b8e31f2..f082fa7bb 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-15, For [#1509][bug #1509], decrease the fast vector init size from 64KB to 64B. 3.0.99 * v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98 * v3.0, 2020-01-10, [3.0 alpha8(3.0.97)][r3.0a8] released. 121555 lines. * v3.0, 2020-01-09, For [#1042][bug #1042], improve test coverage for service. 3.0.97 diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index a6436535c..d19e18356 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -122,6 +122,7 @@ Options: --with-research build the research tools. --with-utest build the utest for SRS. --with-gperf build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). + https://blog.csdn.net/win_lin/article/details/53503869 --with-gmc build memory check for SRS with gperf tools. --with-gmd build memory defense(corrupt memory) for SRS with gperf tools. --with-gmp build memory profile for SRS with gperf tools. @@ -198,6 +199,7 @@ Experts: --memory-watch enable memory watch to detect memory leaking(hurts performance). --export-librtmp-project= export srs-librtmp to specified project in path. --export-librtmp-single= export srs-librtmp to a single file(.h+.cpp) in path. + --with-valgrind support valgrind for memory check. --without-valgrind donot support valgrind for memory check. Workflow: @@ -207,10 +209,7 @@ Workflow: 4. generate detail features. Remark: - 1. both ubuntu12 and ubuntu14 are ok for SRS. - 2. the centos5, centos6 and centos7 are ok for SRS. - 3. all linux and unix-like os are ok for SRS. - 4. windows is absolutely impossible for SRS. + 1. For performance improving, read https://blog.csdn.net/win_lin/article/details/53503869 END } @@ -289,6 +288,7 @@ function parse_user_option() { --memory-watch) SRS_MEM_WATCH=YES ;; --export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;; --export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;; + --with-valgrind) SRS_VALGRIND=YES ;; --without-valgrind) SRS_VALGRIND=NO ;; --with-http-callback) SRS_HTTP_CALLBACK=YES ;; @@ -395,18 +395,6 @@ function apply_user_presets() { SRS_STATIC=NO fi - # for osx(darwin) - if [ $SRS_OSX = YES ]; then - SRS_HDS=YES - SRS_LIBRTMP=YES - SRS_RESEARCH=NO - SRS_UTEST=YES - SRS_STATIC=NO - # valgrind is not supported by macOS sierra, read - # https://stackoverflow.com/questions/40650338/valgrind-on-macos-sierra - SRS_VALGRIND=NO - fi - # if dev specified, open features if possible. if [ $SRS_DEV = YES ]; then SRS_HDS=YES diff --git a/trunk/auto/summary.sh b/trunk/auto/summary.sh index f19a27722..0af1673b1 100755 --- a/trunk/auto/summary.sh +++ b/trunk/auto/summary.sh @@ -43,16 +43,13 @@ echo -e " \${BLACK}+-------------------------------------------------------- echo -e " |\${GREEN}The main server usage: ./objs/srs -c conf/srs.conf, start the srs server\${BLACK}" echo -e " | ${SrsHlsSummaryColor}About HLS, please read https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS\${BLACK}" echo -e " | ${SrsDvrSummaryColor}About DVR, please read https://github.com/ossrs/srs/wiki/v3_CN_DVR\${BLACK}" -echo -e " | ${SrsNginxSummaryColor}About NGINX, please read https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS\${BLACK}" echo -e " | ${SrsSslSummaryColor}About SSL, please read https://github.com/ossrs/srs/wiki/v1_CN_RTMPHandshake\${BLACK}" -echo -e " | ${SrsFfmpegSummaryColor}About FFMPEG, please read https://github.com/ossrs/srs/wiki/v3_CN_FFMPEG\${BLACK}" echo -e " | ${SrsTranscodeSummaryColor}About transcoding, please read https://github.com/ossrs/srs/wiki/v3_CN_FFMPEG\${BLACK}" echo -e " | ${SrsIngestSummaryColor}About ingester, please read https://github.com/ossrs/srs/wiki/v1_CN_Ingest\${BLACK}" echo -e " | ${SrsHttpCallbackSummaryColor}About http-callback, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPCallback\${BLACK}" -echo -e " | ${SrsHttpServerSummaryColor}Aoubt embeded http-server, please read https://github.com/ossrs/srs/wiki/v2_CN_HTTPServer\${BLACK}" +echo -e " | ${SrsHttpServerSummaryColor}Aoubt http-server, please read https://github.com/ossrs/srs/wiki/v2_CN_HTTPServer\${BLACK}" echo -e " | ${SrsHttpApiSummaryColor}About http-api, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPApi\${BLACK}" echo -e " | ${SrsStreamCasterSummaryColor}About stream-caster, please read https://github.com/ossrs/srs/wiki/v2_CN_Streamer\${BLACK}" -echo -e " | ${SrsKafkaSummaryColor}About kafka, please read https://github.com/ossrs/srs/wiki/v3_CN_Kafka\${BLACK}" echo -e " | ${SrsValgrindSummaryColor}About VALGRIND, please read https://github.com/ossrs/state-threads/issues/2\${BLACK}" echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}" echo -e "\${GREEN}binaries, please read https://github.com/ossrs/srs/wiki/v2_CN_Build\${BLACK}" diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index a0277f3c9..20594b917 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -6771,22 +6771,22 @@ string SrsConfig::get_vhost_http_dir(string vhost) bool SrsConfig::get_vhost_http_remux_enabled(string vhost) { static bool DEFAULT = false; - + SrsConfDirective* conf = get_vhost(vhost); if (!conf) { return DEFAULT; } - + conf = conf->get("http_remux"); if (!conf) { return DEFAULT; } - + conf = conf->get("enabled"); if (!conf || conf->arg0().empty()) { return DEFAULT; } - + return SRS_CONF_PERFER_FALSE(conf->arg0()); } diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 21d84be59..dddacdf92 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -1023,7 +1023,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle if (it == tflvs.end()) { return err; } - + // hstrs always enabled. // for origin, the http stream will be mount already when publish, // so it must never enter this line for stream already mounted. @@ -1064,7 +1064,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle if (srs_string_count(upath, "/") != srs_string_count(entry->mount, "/")) { return err; } - + // convert to concreate class. SrsHttpMessage* hreq = dynamic_cast(request); srs_assert(hreq); @@ -1127,7 +1127,7 @@ srs_error_t SrsHttpStreamServer::initialize_flv_streaming() if (!conf->is_vhost()) { continue; } - + if ((err = initialize_flv_entry(conf->arg0())) != srs_success) { return srs_error_wrap(err, "init flv entries"); } @@ -1139,7 +1139,7 @@ srs_error_t SrsHttpStreamServer::initialize_flv_streaming() srs_error_t SrsHttpStreamServer::initialize_flv_entry(std::string vhost) { srs_error_t err = srs_success; - + if (!_srs_config->get_vhost_http_remux_enabled(vhost)) { return err; } diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 788773c80..b058f55a1 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -154,7 +154,7 @@ int64_t SrsRtmpJitter::get_time() SrsFastVector::SrsFastVector() { count = 0; - nb_msgs = SRS_PERF_MW_MSGS * 8; + nb_msgs = 8; msgs = new SrsSharedPtrMessage*[nb_msgs]; } @@ -212,7 +212,7 @@ void SrsFastVector::push_back(SrsSharedPtrMessage* msg) { // increase vector. if (count >= nb_msgs) { - int size = nb_msgs * 2; + int size = srs_max(SRS_PERF_MW_MSGS * 8, nb_msgs * 2); SrsSharedPtrMessage** buf = new SrsSharedPtrMessage*[size]; for (int i = 0; i < nb_msgs; i++) { buf[i] = msgs[i]; diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index b6aa58342..db851d3d4 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 98 +#define VERSION_REVISION 99 // The macros generated by configure script. #include From 0e750ab3eb5728acef822790f8df6ac7c21d4c64 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 16 Jan 2020 14:28:05 +0800 Subject: [PATCH 04/23] For #1575, use RTMP redirect as tcUrl and redirect2 as RTMP URL. 3.0.100 --- README.md | 2 ++ trunk/src/app/srs_app_edge.cpp | 11 ++++++++--- trunk/src/app/srs_app_rtmp_conn.cpp | 8 +++++--- trunk/src/app/srs_app_source.cpp | 2 +- trunk/src/core/srs_core.hpp | 2 +- trunk/src/protocol/srs_rtmp_stack.cpp | 13 ++++++++----- trunk/src/protocol/srs_rtmp_stack.hpp | 4 ++-- trunk/src/utest/srs_utest_rtmp.cpp | 22 ++++++++++++++++++++-- 8 files changed, 47 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f082fa7bb..5e1fed5a1 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-16, For [#1575][bug #1575], use RTMP redirect as tcUrl and redirect2 as RTMP URL. 3.0.100 * v3.0, 2020-01-15, For [#1509][bug #1509], decrease the fast vector init size from 64KB to 64B. 3.0.99 * v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98 * v3.0, 2020-01-10, [3.0 alpha8(3.0.97)][r3.0a8] released. 121555 lines. @@ -1595,6 +1596,7 @@ Winlin [bug #1255]: https://github.com/ossrs/srs/issues/1255 [bug #1543]: https://github.com/ossrs/srs/issues/1543 [bug #1509]: https://github.com/ossrs/srs/issues/1509 +[bug #1575]: https://github.com/ossrs/srs/issues/1575 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index 8d9d116a8..8a0592dcf 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -416,9 +416,14 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg, stri return err; } SrsAmf0Object* ex = prop->to_object(); - - if ((prop = ex->ensure_property_string("redirect")) == NULL) { - return err; + + // The redirect is tcUrl while redirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 + if ((prop = ex->ensure_property_string("redirect2")) == NULL) { + // TODO: FIXME: Remove it when SRS3 released, it's temporarily support for SRS3 alpha versions(a0 to a8). + if ((prop = ex->ensure_property_string("redirect")) == NULL) { + return err; + } } redirect = prop->to_str(); diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 6ed6ca712..f846df0dc 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -621,8 +621,10 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source) } return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str()); } - srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s", - req->host.c_str(), req->port, host.c_str(), port, url.c_str()); + + string rurl = srs_generate_rtmp_url(host, port, req->host, req->vhost, req->app, req->stream, req->param); + srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s, rurl=%s", + req->host.c_str(), req->port, host.c_str(), port, url.c_str(), rurl.c_str()); // Ignore if host or port is invalid. if (host.empty() || port == 0) { @@ -630,7 +632,7 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source) } bool accepted = false; - if ((err = rtmp->redirect(req, host, port, accepted)) != srs_success) { + if ((err = rtmp->redirect(req, rurl, accepted)) != srs_success) { srs_error_reset(err); } else { return srs_error_new(ERROR_CONTROL_REDIRECT, "redirected"); diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index b058f55a1..39e704226 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -217,7 +217,7 @@ void SrsFastVector::push_back(SrsSharedPtrMessage* msg) for (int i = 0; i < nb_msgs; i++) { buf[i] = msgs[i]; } - srs_warn("fast vector incrase %d=>%d", nb_msgs, size); + srs_info("fast vector incrase %d=>%d", nb_msgs, size); // use new array. srs_freepa(msgs); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index db851d3d4..283e34e95 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 99 +#define VERSION_REVISION 100 // The macros generated by configure script. #include diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index ae43916ce..bec1ad35c 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -2415,17 +2415,20 @@ srs_error_t SrsRtmpServer::response_connect_app(SrsRequest *req, const char* ser } #define SRS_RTMP_REDIRECT_TIMEOUT (3 * SRS_UTIME_SECONDS) -srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string host, int port, bool& accepted) +srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string url, bool& accepted) { srs_error_t err = srs_success; if (true) { - string url = srs_generate_rtmp_url(host, port, r->host, r->vhost, r->app, r->stream, r->param); - SrsAmf0Object* ex = SrsAmf0Any::object(); ex->set("code", SrsAmf0Any::number(302)); - ex->set("redirect", SrsAmf0Any::str(url.c_str())); - + + // The redirect is tcUrl while redirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 + string tcUrl = srs_path_dirname(url); + ex->set("redirect", SrsAmf0Any::str(tcUrl.c_str())); + ex->set("redirect2", SrsAmf0Any::str(url.c_str())); + SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); pkt->data->set(StatusLevel, SrsAmf0Any::str(StatusLevelError)); diff --git a/trunk/src/protocol/srs_rtmp_stack.hpp b/trunk/src/protocol/srs_rtmp_stack.hpp index 82c9bf006..c43c4ee17 100644 --- a/trunk/src/protocol/srs_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_rtmp_stack.hpp @@ -707,9 +707,9 @@ public: // @param server_ip the ip of server. virtual srs_error_t response_connect_app(SrsRequest* req, const char* server_ip = NULL); // Redirect the connection to another rtmp server. - // @param the hostname or ip of target. + // @param a RTMP url to redirect to. // @param whether the client accept the redirect. - virtual srs_error_t redirect(SrsRequest* r, std::string host, int port, bool& accepted); + virtual srs_error_t redirect(SrsRequest* r, std::string url, bool& accepted); // Reject the connect app request. virtual void response_connect_reject(SrsRequest* req, const char* desc); // Response client the onBWDone message. diff --git a/trunk/src/utest/srs_utest_rtmp.cpp b/trunk/src/utest/srs_utest_rtmp.cpp index 47ec84aa6..7acc3d4c2 100644 --- a/trunk/src/utest/srs_utest_rtmp.cpp +++ b/trunk/src/utest/srs_utest_rtmp.cpp @@ -1751,7 +1751,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) string host = "target.net"; int port = 8888; bool accepted = false; - HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted)); + string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param); + HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted)); if (true) { MockBufferIO tio; @@ -1776,6 +1777,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) prop = ex->get_property("redirect"); ASSERT_TRUE(prop && prop->is_string()); + // The recirect is tcUrl, not RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574995475 + EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str()); + + prop = ex->get_property("redirect2"); + ASSERT_TRUE(prop && prop->is_string()); + // The recirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str()); srs_freep(msg); @@ -1808,7 +1817,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) string host = "target.net"; int port = 8888; bool accepted = false; - HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted)); + string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param); + HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted)); EXPECT_TRUE(accepted); if (true) { @@ -1834,6 +1844,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) prop = ex->get_property("redirect"); ASSERT_TRUE(prop && prop->is_string()); + // The recirect is tcUrl, not RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574995475 + EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str()); + + prop = ex->get_property("redirect2"); + ASSERT_TRUE(prop && prop->is_string()); + // The recirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str()); srs_freep(msg); From 11c2ca3b0a15eddaf5b0df76560c986f54fcb9b0 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 16 Jan 2020 14:33:48 +0800 Subject: [PATCH 05/23] word the cr comment --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e1fed5a1..ceffbcfd9 100755 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ For previous versions, please read: ## V3 changes -* v3.0, 2020-01-16, For [#1575][bug #1575], use RTMP redirect as tcUrl and redirect2 as RTMP URL. 3.0.100 +* v3.0, 2020-01-16, For [#1575][bug #1575], correct RTMP redirect as tcUrl, add redirect2 as RTMP URL. 3.0.100 * v3.0, 2020-01-15, For [#1509][bug #1509], decrease the fast vector init size from 64KB to 64B. 3.0.99 * v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98 * v3.0, 2020-01-10, [3.0 alpha8(3.0.97)][r3.0a8] released. 121555 lines. From fea293d0b16f7e74f1af219f59b8d5be9d8b1ff2 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 16 Jan 2020 14:37:30 +0800 Subject: [PATCH 06/23] Fix #1042, improve test coverage for core/kernel/protocol/service. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ceffbcfd9..f82cc2465 100755 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ For previous versions, please read: - [x] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92]. - [x] Support listen at IPv4 and IPv6, read [#460][bug #460]. - [x] Support SO_REUSEPORT, to improve edge server performance, read [#775][bug #775]. +- [x] Improve test coverage for core/kernel/protocol/service. - [x] [Experimental] Support docker by [srs-docker](https://github.com/ossrs/srs-docker). - [x] [Experimental] Support DVR in MP4 format, read [#738][bug #738]. - [x] [Experimental] Support MPEG-DASH, the future live streaming protocol, read [#299][bug #299]. @@ -129,7 +130,6 @@ For previous versions, please read: - [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]) and [#1535][bug #1535]. - [x] [Deprecated] Support bandwidth testing([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]), please read [#1535][bug #1535]. - [x] [Deprecated] Support Adobe FMS/AMS token traverse([CN][v3_CN_DRM2], [EN][v3_EN_DRM2]) authentication, please read [#1535][bug #1535]. -- [ ] Utest cover almost all kernel code. - [ ] Enhanced forwarding with vhost and variables. - [ ] Support source cleanup for idle streams. - [ ] Support H.265 by pushing H.265 over RTMP, deliverying in HLS, read [#465][bug #465]. From 9dbd049e792f0811e12eb30be60559d2cacc3331 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 16 Jan 2020 17:56:55 +0800 Subject: [PATCH 07/23] For #1568, extract SrsSourceManager from SrsSource. --- trunk/src/app/srs_app_http_stream.cpp | 2 +- trunk/src/app/srs_app_rtmp_conn.cpp | 2 +- trunk/src/app/srs_app_server.cpp | 4 ++-- trunk/src/app/srs_app_source.cpp | 31 +++++++++++++++++-------- trunk/src/app/srs_app_source.hpp | 33 +++++++++++++++++++-------- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index dddacdf92..2a0d8e939 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -1089,7 +1089,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle } SrsSource* s = NULL; - if ((err = SrsSource::fetch_or_create(r, server, &s)) != srs_success) { + if ((err = _srs_sources->fetch_or_create(r, server, &s)) != srs_success) { return srs_error_wrap(err, "source create"); } srs_assert(s != NULL); diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index f846df0dc..5ffe4b0cd 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -496,7 +496,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle() // find a source to serve. SrsSource* source = NULL; - if ((err = SrsSource::fetch_or_create(req, server, &source)) != srs_success) { + if ((err = _srs_sources->fetch_or_create(req, server, &source)) != srs_success) { return srs_error_wrap(err, "rtmp: fetch source"); } srs_assert(source != NULL); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 8c6d21470..2a3039f1a 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -523,7 +523,7 @@ void SrsServer::dispose() // @remark don't dispose ingesters, for too slow. // dispose the source for hls and dvr. - SrsSource::dispose_all(); + _srs_sources->dispose(); // @remark don't dispose all connections, for too slow. @@ -952,7 +952,7 @@ srs_error_t SrsServer::do_cycle() } // notice the stream sources to cycle. - if ((err = SrsSource::cycle_all()) != srs_success) { + if ((err = _srs_sources->cycle()) != srs_success) { return srs_error_wrap(err, "source cycle"); } diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 39e704226..f48528015 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1635,9 +1635,17 @@ srs_error_t SrsMetaCache::update_vsh(SrsSharedPtrMessage* msg) return vformat->on_video(msg); } -std::map SrsSource::pool; +SrsSourceManager* _srs_sources = new SrsSourceManager(); -srs_error_t SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps) +SrsSourceManager::SrsSourceManager() +{ +} + +SrsSourceManager::~SrsSourceManager() +{ +} + +srs_error_t SrsSourceManager::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps) { srs_error_t err = srs_success; @@ -1665,7 +1673,7 @@ srs_error_t SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsS return err; } -SrsSource* SrsSource::fetch(SrsRequest* r) +SrsSource* SrsSourceManager::fetch(SrsRequest* r) { SrsSource* source = NULL; @@ -1679,12 +1687,12 @@ SrsSource* SrsSource::fetch(SrsRequest* r) // we always update the request of resource, // for origin auth is on, the token in request maybe invalid, // and we only need to update the token of request, it's simple. - source->req->update_auth(r); + source->update_auth(r); return source; } -void SrsSource::dispose_all() +void SrsSourceManager::dispose() { std::map::iterator it; for (it = pool.begin(); it != pool.end(); ++it) { @@ -1694,16 +1702,16 @@ void SrsSource::dispose_all() return; } -srs_error_t SrsSource::cycle_all() +srs_error_t SrsSourceManager::cycle() { int cid = _srs_context->get_id(); - srs_error_t err = do_cycle_all(); + srs_error_t err = do_cycle(); _srs_context->set_id(cid); return err; } -srs_error_t SrsSource::do_cycle_all() +srs_error_t SrsSourceManager::do_cycle() { srs_error_t err = srs_success; @@ -1744,7 +1752,7 @@ srs_error_t SrsSource::do_cycle_all() return err; } -void SrsSource::destroy() +void SrsSourceManager::destroy() { std::map::iterator it; for (it = pool.begin(); it != pool.end(); ++it) { @@ -1994,6 +2002,11 @@ bool SrsSource::inactive() return _can_publish; } +void SrsSource::update_auth(SrsRequest* r) +{ + req->update_auth(r); +} + bool SrsSource::can_publish(bool is_edge) { if (is_edge) { diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index 847857f33..b0696346e 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -438,32 +438,43 @@ public: virtual srs_error_t update_vsh(SrsSharedPtrMessage* msg); }; -// live streaming source. -class SrsSource : public ISrsReloadHandler +// The source manager to create and refresh all stream sources. +class SrsSourceManager { - friend class SrsOriginHub; private: - static std::map pool; + std::map pool; +public: + SrsSourceManager(); + virtual ~SrsSourceManager(); public: // create source when fetch from cache failed. // @param r the client request. // @param h the event handler for source. // @param pps the matched source, if success never be NULL. - static srs_error_t fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps); + virtual srs_error_t fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps); private: // Get the exists source, NULL when not exists. // update the request and return the exists source. - static SrsSource* fetch(SrsRequest* r); + virtual SrsSource* fetch(SrsRequest* r); public: // dispose and cycle all sources. - static void dispose_all(); - static srs_error_t cycle_all(); + virtual void dispose(); + virtual srs_error_t cycle(); private: - static srs_error_t do_cycle_all(); + virtual srs_error_t do_cycle(); public: // when system exit, destroy the sources, // For gmc to analysis mem leaks. - static void destroy(); + virtual void destroy(); +}; + +// Global singleton instance. +extern SrsSourceManager* _srs_sources; + +// live streaming source. +class SrsSource : public ISrsReloadHandler +{ + friend class SrsOriginHub; private: // For publish, it's the publish client id. // For edge, it's the edge ingest id. @@ -531,6 +542,8 @@ public: // Whether source is inactive, which means there is no publishing stream source. // @remark For edge, it's inactive util stream has been pulled from origin. virtual bool inactive(); + // Update the authentication information in request. + virtual void update_auth(SrsRequest* r); public: virtual bool can_publish(bool is_edge); virtual srs_error_t on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata); From bdd0b1f7a26f5fff31882fff8e65802157c0e084 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 18 Jan 2020 19:54:26 +0800 Subject: [PATCH 08/23] =?UTF-8?q?SRS=20is=20a=20live=20streaming=20cluster?= =?UTF-8?q?,=20high=20efficiency,=20stable=20and=20simple.=20SRS=E6=98=AF?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=B5=81=E5=AA=92=E4=BD=93=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E9=9B=86=E7=BE=A4=EF=BC=8C=E9=AB=98=E6=95=88=E3=80=81=E7=A8=B3?= =?UTF-8?q?=E5=AE=9A=E3=80=81=E6=98=93=E7=94=A8=EF=BC=8C=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E8=80=8C=E5=BF=AB=E4=B9=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f82cc2465..c35907843 100755 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![](https://codecov.io/gh/ossrs/srs/branch/3.0release/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/3.0release) [![](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat) -SRS/3.0,[OuXuli][release3],是一个简单的流媒体直播集群,简单的快乐。
-SRS(Simple RTMP Server) is a simple live streaming cluster, a simple joy. +SRS/3.0,[OuXuli][release3],是一个流媒体直播集群,高效、稳定、易用,简单而快乐。
+SRS(Simple RTMP Server) is a live streaming cluster, high efficiency, stable and simple. > Remark: Although SRS is licenced under [MIT][LICENSE], but there are some depended libraries which are distributed using their own licenses, please read [License Mixing][LicenseMixing]. From 390017968595501170c7bb3cf7c93bb7fbce8301 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 19 Jan 2020 11:22:35 +0800 Subject: [PATCH 09/23] For #307, #1070, define FLV CodecID for AV1 and Opus. 3.0.101 --- README.md | 3 +++ trunk/src/core/srs_core.hpp | 2 +- trunk/src/kernel/srs_kernel_codec.cpp | 7 ++++++- trunk/src/kernel/srs_kernel_codec.hpp | 2 ++ trunk/src/kernel/srs_kernel_ts.cpp | 1 + trunk/src/libs/srs_librtmp.cpp | 2 +- trunk/src/utest/srs_utest_kernel.cpp | 9 ++++++++- 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c35907843..bc8af04f6 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-19, For [#1070][bug #1070], define FLV CodecID for [AV1][bug #1070] and [opus][bug #307]. 3.0.101 * v3.0, 2020-01-16, For [#1575][bug #1575], correct RTMP redirect as tcUrl, add redirect2 as RTMP URL. 3.0.100 * v3.0, 2020-01-15, For [#1509][bug #1509], decrease the fast vector init size from 64KB to 64B. 3.0.99 * v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98 @@ -1597,6 +1598,8 @@ Winlin [bug #1543]: https://github.com/ossrs/srs/issues/1543 [bug #1509]: https://github.com/ossrs/srs/issues/1509 [bug #1575]: https://github.com/ossrs/srs/issues/1575 +[bug #307]: https://github.com/ossrs/srs/issues/307 +[bug #1070]: https://github.com/ossrs/srs/issues/1070 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 283e34e95..4c1d742bc 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 100 +#define VERSION_REVISION 101 // The macros generated by configure script. #include diff --git a/trunk/src/kernel/srs_kernel_codec.cpp b/trunk/src/kernel/srs_kernel_codec.cpp index a0b11f424..32678de19 100644 --- a/trunk/src/kernel/srs_kernel_codec.cpp +++ b/trunk/src/kernel/srs_kernel_codec.cpp @@ -43,6 +43,8 @@ string srs_video_codec_id2str(SrsVideoCodecId codec) return "VP6"; case SrsVideoCodecIdHEVC: return "HEVC"; + case SrsVideoCodecIdAV1: + return "AV1"; case SrsVideoCodecIdReserved: case SrsVideoCodecIdReserved1: case SrsVideoCodecIdReserved2: @@ -650,7 +652,10 @@ bool SrsFormat::is_aac_sequence_header() bool SrsFormat::is_avc_sequence_header() { - return vcodec && (vcodec->id == SrsVideoCodecIdAVC || vcodec->id == SrsVideoCodecIdHEVC) + bool h264 = vcodec->id == SrsVideoCodecIdAVC; + bool h265 = vcodec->id == SrsVideoCodecIdHEVC; + bool av1 = vcodec->id == SrsVideoCodecIdAV1; + return vcodec && (h264 || h265 || av1) && video && video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader; } diff --git a/trunk/src/kernel/srs_kernel_codec.hpp b/trunk/src/kernel/srs_kernel_codec.hpp index e25442edc..2f8d436b6 100644 --- a/trunk/src/kernel/srs_kernel_codec.hpp +++ b/trunk/src/kernel/srs_kernel_codec.hpp @@ -62,6 +62,8 @@ enum SrsVideoCodecId SrsVideoCodecIdAVC = 7, // See page 79 at @doc https://github.com/CDN-Union/H265/blob/master/Document/video_file_format_spec_v10_1_ksyun_20170615.doc SrsVideoCodecIdHEVC = 12, + // https://mp.weixin.qq.com/s/H3qI7zsON5sdf4oDJ9qlkg + SrsVideoCodecIdAV1 = 13, }; std::string srs_video_codec_id2str(SrsVideoCodecId codec); diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index 1c3b92edf..27d40315c 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -313,6 +313,7 @@ srs_error_t SrsTsContext::encode(ISrsStreamWriter* writer, SrsTsMessage* msg, Sr case SrsVideoCodecIdOn2VP6WithAlphaChannel: case SrsVideoCodecIdScreenVideoVersion2: case SrsVideoCodecIdHEVC: + case SrsVideoCodecIdAV1: vs = SrsTsStreamReserved; break; } diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index ee49069f4..a2f9728e0 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -1666,7 +1666,7 @@ int srs_mp4_to_flv_tag(srs_mp4_t mp4, srs_mp4_sample_t* s, char* type, uint32_t* // E.4.3.1 VIDEODATA, flv_v10_1.pdf, page 5 p.write_1bytes(uint8_t(s->frame_type<<4) | uint8_t(s->codec)); - if (s->codec == SrsVideoCodecIdAVC || s->codec == SrsVideoCodecIdHEVC) { + if (s->codec == SrsVideoCodecIdAVC || s->codec == SrsVideoCodecIdHEVC || s->codec == SrsVideoCodecIdAV1) { *type = SRS_RTMP_TYPE_VIDEO; p.write_1bytes(uint8_t(s->frame_trait == (uint16_t)SrsVideoAvcFrameTraitSequenceHeader? 0:1)); diff --git a/trunk/src/utest/srs_utest_kernel.cpp b/trunk/src/utest/srs_utest_kernel.cpp index c80e8fc58..5a113da84 100644 --- a/trunk/src/utest/srs_utest_kernel.cpp +++ b/trunk/src/utest/srs_utest_kernel.cpp @@ -3028,6 +3028,7 @@ VOID TEST(KernelCodecTest, CoverAll) EXPECT_TRUE("H264" == srs_video_codec_id2str(SrsVideoCodecIdAVC)); EXPECT_TRUE("VP6" == srs_video_codec_id2str(SrsVideoCodecIdOn2VP6)); EXPECT_TRUE("HEVC" == srs_video_codec_id2str(SrsVideoCodecIdHEVC)); + EXPECT_TRUE("AV1" == srs_video_codec_id2str(SrsVideoCodecIdAV1)); EXPECT_TRUE("Other" == srs_video_codec_id2str(SrsVideoCodecIdScreenVideo)); } @@ -3293,6 +3294,9 @@ VOID TEST(KernelCodecTest, IsSequenceHeaderSpecial) f.vcodec->id = SrsVideoCodecIdHEVC; EXPECT_FALSE(f.is_avc_sequence_header()); + f.vcodec->id = SrsVideoCodecIdAV1; + EXPECT_FALSE(f.is_avc_sequence_header()); + f.video->avc_packet_type = SrsVideoAvcFrameTraitSequenceHeader; EXPECT_TRUE(f.is_avc_sequence_header()); } @@ -4647,7 +4651,10 @@ VOID TEST(KernelTSTest, CoverContextEncode) err = ctx.encode(&f, &m, SrsVideoCodecIdHEVC, SrsAudioCodecIdOpus); HELPER_EXPECT_FAILED(err); - + + err = ctx.encode(&f, &m, SrsVideoCodecIdAV1, SrsAudioCodecIdOpus); + HELPER_EXPECT_FAILED(err); + err = ctx.encode_pat_pmt(&f, 0, SrsTsStreamReserved, 0, SrsTsStreamReserved); HELPER_EXPECT_FAILED(err); } From 9ac8585cf904b10e5a2e37a14355019d873354b2 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 19 Jan 2020 13:16:49 +0800 Subject: [PATCH 10/23] Fix codec check --- trunk/src/kernel/srs_kernel_codec.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trunk/src/kernel/srs_kernel_codec.cpp b/trunk/src/kernel/srs_kernel_codec.cpp index 32678de19..2f6c14bff 100644 --- a/trunk/src/kernel/srs_kernel_codec.cpp +++ b/trunk/src/kernel/srs_kernel_codec.cpp @@ -652,9 +652,9 @@ bool SrsFormat::is_aac_sequence_header() bool SrsFormat::is_avc_sequence_header() { - bool h264 = vcodec->id == SrsVideoCodecIdAVC; - bool h265 = vcodec->id == SrsVideoCodecIdHEVC; - bool av1 = vcodec->id == SrsVideoCodecIdAV1; + bool h264 = (vcodec && vcodec->id == SrsVideoCodecIdAVC); + bool h265 = (vcodec && vcodec->id == SrsVideoCodecIdHEVC); + bool av1 = (vcodec && vcodec->id == SrsVideoCodecIdAV1); return vcodec && (h264 || h265 || av1) && video && video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader; } From 86d04a70ed8fc8101092b0d9e078b6c862e2cab8 Mon Sep 17 00:00:00 2001 From: l <22312935+lam2003@users.noreply.github.com> Date: Sun, 19 Jan 2020 14:34:42 +0800 Subject: [PATCH 11/23] Fix #1580, fix cid range problem. 3.0.102 --- README.md | 2 ++ trunk/src/core/srs_core.hpp | 2 +- trunk/src/kernel/srs_kernel_flv.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc8af04f6..1846ef72d 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-19, For [#1580][bug #1580], fix cid range problem. 3.0.102 * v3.0, 2020-01-19, For [#1070][bug #1070], define FLV CodecID for [AV1][bug #1070] and [opus][bug #307]. 3.0.101 * v3.0, 2020-01-16, For [#1575][bug #1575], correct RTMP redirect as tcUrl, add redirect2 as RTMP URL. 3.0.100 * v3.0, 2020-01-15, For [#1509][bug #1509], decrease the fast vector init size from 64KB to 64B. 3.0.99 @@ -1600,6 +1601,7 @@ Winlin [bug #1575]: https://github.com/ossrs/srs/issues/1575 [bug #307]: https://github.com/ossrs/srs/issues/307 [bug #1070]: https://github.com/ossrs/srs/issues/1070 +[bug #1580]: https://github.com/ossrs/srs/issues/1580 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 4c1d742bc..7864d556b 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 101 +#define VERSION_REVISION 102 // The macros generated by configure script. #include diff --git a/trunk/src/kernel/srs_kernel_flv.cpp b/trunk/src/kernel/srs_kernel_flv.cpp index e897e1b38..63238b4c6 100644 --- a/trunk/src/kernel/srs_kernel_flv.cpp +++ b/trunk/src/kernel/srs_kernel_flv.cpp @@ -291,7 +291,7 @@ bool SrsSharedPtrMessage::check(int stream_id) // we donot use the complex basic header, // ensure the basic header is 1bytes. - if (ptr->header.perfer_cid < 2) { + if (ptr->header.perfer_cid < 2 || ptr->header.perfer_cid > 63) { srs_info("change the chunk_id=%d to default=%d", ptr->header.perfer_cid, RTMP_CID_ProtocolControl); ptr->header.perfer_cid = RTMP_CID_ProtocolControl; } From 1bf90a6e21573c9c41ecf21329cf71d34e2eaee8 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 19 Jan 2020 18:25:29 +0800 Subject: [PATCH 12/23] Ignore noreply user. --- trunk/scripts/new_authors.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/trunk/scripts/new_authors.sh b/trunk/scripts/new_authors.sh index f0a94123c..7bc0dadd0 100755 --- a/trunk/scripts/new_authors.sh +++ b/trunk/scripts/new_authors.sh @@ -11,6 +11,7 @@ for author in $authors; do echo $author| grep 'winterserver' >/dev/null 2>&1 && continue; echo $author| grep 'wenjie.zhao' >/dev/null 2>&1 && continue; echo $author| grep 'zhaowenjie' >/dev/null 2>&1 && continue; + echo $author| grep 'noreply' >/dev/null 2>&1 && continue; grep $author $AFILE 1>/dev/null 2>/dev/null && continue; From 84d69a51a4748446d406154a8c2d40b142c8d4f9 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 19 Jan 2020 18:27:27 +0800 Subject: [PATCH 13/23] Add new author lam2003 --- AUTHORS.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index aa1670a7f..89d65917f 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -51,4 +51,5 @@ CONTRIBUTORS ordered by first contribution. * Himer * xialixin * alphonsetai -* Michael.Ma \ No newline at end of file +* Michael.Ma +* lam2003 \ No newline at end of file From 024433f3271e6c7fb96dcd48a01b0bb85fc8511a Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 20 Jan 2020 10:44:46 +0800 Subject: [PATCH 14/23] For #1547, refine configure, remove some macros --- trunk/auto/auto_headers.sh | 3 - trunk/auto/depends.sh | 106 +-------------- trunk/auto/generate-srs-librtmp-single.sh | 7 - trunk/auto/options.sh | 154 ++++++++-------------- trunk/auto/utest.sh | 6 - trunk/configure | 2 +- 6 files changed, 63 insertions(+), 215 deletions(-) diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 10e76e99f..10b2afb77 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -40,9 +40,6 @@ function srs_undefine_macro() } # export the preset. -if [ $SRS_OSX = YES ]; then - srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H -fi if [ $SRS_X86_X64 = YES ]; then srs_define_macro "SRS_X86_X64" $SRS_AUTO_HEADERS_H fi diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index dd4471f62..7d301b637 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -185,101 +185,11 @@ fi ##################################################################################### # for Centos, auto install tools by yum ##################################################################################### -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 "Current OS `uname -s` is not OSX, please check your configure options." - exit 1; - fi - return 0; - fi - - OS_IS_OSX=YES - echo "Installing tools for OSX." - # requires the osx when os - if [ $OS_IS_OSX = YES ]; then - if [ $SRS_OSX = NO ]; then - echo "Invalid configure options for OSX, please specify --osx." - exit 1 - fi - fi - - brew --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing 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 "The brew is installed." - fi - - gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing gcc." - echo "brew install gcc" - brew install gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The gcc is installed." - fi - - g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing gcc-c++." - echo "brew install gcc-c++" - brew install gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The gcc-c++ is installed." - fi - - make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing make." - echo "brew install make" - brew install make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The make is installed." - fi - - patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing patch." - echo "brew install patch" - brew install patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The patch is installed." - fi - - unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing unzip." - echo "brew install unzip" - brew install unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The unzip is installed." - fi - - if [[ $SRS_VALGRIND == YES ]]; then - valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing valgrind." - echo "brew install valgrind" - brew install valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The valgrind is installed." - fi - fi - - echo "Tools for OSX are installed." - 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 "Install tools for OSX failed, ret=$ret"; exit $ret; fi -fi - # We must use a bash function instead of variable. function sed_utility() { - if [ $OS_IS_OSX = YES ]; then - sed -i '' "$@" - else - sed -i "$@" - fi - + sed -i "$@" ret=$?; if [[ $ret -ne 0 ]]; then - if [ $OS_IS_OSX = YES ]; then - echo "sed -i '' \"$@\"" - else - echo "sed -i \"$@\"" - fi + echo "sed -i \"$@\"" return $ret fi } @@ -294,7 +204,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 && $OS_IS_OSX = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then +if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = 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 @@ -307,10 +217,6 @@ 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" - # for osx, use darwin for st, donot use epoll. - if [ $OS_IS_OSX = YES ]; then - _ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE -I/usr/local/include" - fi if [[ $SRS_VALGRIND == YES ]]; then _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_VALGRIND" fi @@ -416,10 +322,6 @@ fi # openssl, for rtmp complex handshake ##################################################################################### # extra configure options -CONFIGURE_TOOL="./config" -if [ $SRS_OSX = YES ]; then - CONFIGURE_TOOL="./Configure darwin64-`uname -m`-cc" -fi OPENSSL_HOTFIX="-DOPENSSL_NO_HEARTBEATS" # @see http://www.openssl.org/news/secadv/20140407.txt # Affected users should upgrade to OpenSSL 1.1.0e. Users unable to immediately @@ -442,7 +344,7 @@ if [ $SRS_SSL = YES ]; then ( rm -rf ${SRS_OBJS}/openssl-1.1.0e && cd ${SRS_OBJS} && unzip -q ../3rdparty/openssl-1.1.0e.zip && cd openssl-1.1.0e && - $CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared no-threads $OPENSSL_HOTFIX && + ./config --prefix=`pwd`/_release -no-shared no-threads $OPENSSL_HOTFIX && make && make install_sw && cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl ) diff --git a/trunk/auto/generate-srs-librtmp-single.sh b/trunk/auto/generate-srs-librtmp-single.sh index 6def4b9a4..cb2174daa 100755 --- a/trunk/auto/generate-srs-librtmp-single.sh +++ b/trunk/auto/generate-srs-librtmp-single.sh @@ -1,12 +1,5 @@ #!/bin/bash -OS_IS_OSX=NO -uname -s|grep Darwin >/dev/null 2>&1 -ret=$?; if [[ 0 -eq $ret ]]; then - OS_IS_OSX=YES -fi -echo "Is OSX: ${OS_IS_OSX}" - # when export srs-librtmp single files # package the whole project to srs_librtmp.h and srs_librtmp.cpp # diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index d19e18356..e6c40439c 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -77,7 +77,6 @@ SRS_VALGRIND=NO SRS_X86_X64=NO # for osx system SRS_OSX=NO -SRS_ALLOW_OSX=NO # dev, open all features for dev, no gperf/prof/arm. SRS_DEV=NO # dev, open main server feature for dev, no utest/research/librtmp @@ -98,7 +97,7 @@ SRS_DISABLE_ALL=NO SRS_ENABLE_ALL=NO # ##################################################################################### -# We don't support crossbuild for ARM/MIPS, please directly build it on ARM/MIPS server. +# Whether enable crossbuild for ARM or MIPS. SRS_CROSS_BUILD=NO ##################################################################################### @@ -107,106 +106,79 @@ SRS_CROSS_BUILD=NO function show_help() { cat << END -Options: - -h, --help print this message - - --with-ssl enable rtmp complex handshake, requires openssl-devel installed. - --with-hds enable hds streaming, mux RTMP to F4M/F4V files. - --with-nginx enable delivery HTTP stream with nginx. - --with-stream-caster enable stream caster to serve other stream over other protocol. - --with-ffmpeg enable transcoding tool ffmpeg. - --with-transcode enable transcoding features. - --with-ingest enable ingest features. - --with-stat enable the data statistic, for http api. - --with-librtmp enable srs-librtmp, library for client. - --with-research build the research tools. - --with-utest build the utest for SRS. - --with-gperf build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). - https://blog.csdn.net/win_lin/article/details/53503869 - --with-gmc build memory check for SRS with gperf tools. - --with-gmd build memory defense(corrupt memory) for SRS with gperf tools. - --with-gmp build memory profile for SRS with gperf tools. - --with-gcp build cpu profile for SRS with gperf tools. - --with-gprof build SRS with gprof(GNU profile tool). - --with-arm-ubuntu12 cross build SRS on ubuntu12 for armhf(v7cpu). - --with-mips-ubuntu12 cross build SRS on ubuntu12 for mips. - - --without-ssl disable rtmp complex handshake. - --without-hds disable hds, the adobe http dynamic streaming. - --without-nginx disable delivery HTTP stream with nginx. - --without-stream-caster disable stream caster, only listen and serve RTMP/HTTP. - --without-ffmpeg disable the ffmpeg transcode tool feature. - --without-transcode disable the transcoding feature. - --without-ingest disable the ingest feature. - --without-stat disable the data statistic feature. - --without-librtmp disable srs-librtmp, library for client. - --without-research do not build the research tools. - --without-utest do not build the utest for SRS. - --without-gperf do not build SRS with gperf tools(without tcmalloc and gmd/gmc/gmp/gcp). - --without-gmc do not build memory check for SRS with gperf tools. - --without-gmd do not build memory defense for SRS with gperf tools. - --without-gmp do not build memory profile for SRS with gperf tools. - --without-gcp do not build cpu profile for SRS with gperf tools. - --without-gprof do not build srs with gprof(GNU profile tool). - --without-arm-ubuntu12 do not cross build srs on ubuntu12 for armhf(v7cpu). - --without-mips-ubuntu12 do not cross build srs on ubuntu12 for mips. - +Presets: + --x86-64, --x86-x64 [default] For x86/x64 cpu, common pc and servers. + --arm Enable crossbuild for ARM, should also set bellow toolchain options. + --mips Enable crossbuild for MIPS + +Features: + -h, --help Print this message and exit 0. + + --with-ssl Enable rtmp complex handshake, requires openssl-devel installed. + --with-hds Enable hds streaming, mux RTMP to F4M/F4V files. + --with-stream-caster Enable stream caster to serve other stream over other protocol. + --with-stat Enable the data statistic, for http api. + --with-librtmp Enable srs-librtmp, library for client. + --with-research Build the research tools. + --with-utest Build the utest for SRS. + + --without-ssl Disable rtmp complex handshake. + --without-hds Disable hds, the adobe http dynamic streaming. + --without-stream-caster Disable stream caster, only listen and serve RTMP/HTTP. + --without-stat Disable the data statistic feature. + --without-librtmp Disable srs-librtmp, library for client. + --without-research Do not build the research tools. + --without-utest Do not build the utest for SRS. + --prefix= The absolute installation path for srs. Default: $SRS_PREFIX --static Whether add '-static' to link options. --gcov Whether enable the GCOV compiler options. --jobs[=N] Allow N jobs at once; infinite jobs with no arg. - used for make in the configure, for example, to make ffmpeg. - --log-verbose whether enable the log verbose level. default: no. - --log-info whether enable the log info level. default: no. - --log-trace whether enable the log trace level. default: yes. + Used for make in the configure, for example, to make ffmpeg. + --log-verbose Whether enable the log verbose level. default: no. + --log-info Whether enable the log info level. default: no. + --log-trace Whether enable the log trace level. default: yes. -Presets: - --x86-x64 [default] for x86/x64 cpu, common pc and servers. - --osx for osx(darwin) system to build SRS. - --pi for raspberry-pi(directly build), open features hls/ssl/static. - --cubie for cubieboard(directly build), open features except ffmpeg/nginx. - --arm alias for --with-arm-ubuntu12, for ubuntu12, arm crossbuild - --mips alias for --with-mips-ubuntu12, for ubuntu12, mips crossbuild - --fast the most fast compile, nothing, only support vp6 RTMP. - --pure-rtmp only support RTMP with ssl. - --disable-all disable all features, only support vp6 RTMP. - --dev for dev, open all features, no nginx/gperf/gprof/arm. - --fast-dev for dev fast compile, the RTMP server, without librtmp/utest/research. - --demo for srs demo, @see: https://github.com/ossrs/srs/wiki/v1_CN_SampleDemo - --full enable all features, no gperf/gprof/arm. - --x86-64 alias for --x86-x64. +Performance: + https://blog.csdn.net/win_lin/article/details/53503869 + --with-valgrind Support valgrind for memory check. + --with-gperf Build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). + --with-gmc Build memory check for SRS with gperf tools. + --with-gmd Build memory defense(corrupt memory) for SRS with gperf tools. + --with-gmp Build memory profile for SRS with gperf tools. + --with-gcp Build cpu profile for SRS with gperf tools. + --with-gprof Build SRS with gprof(GNU profile tool). + + --without-valgrind Do not support valgrind for memory check. + --without-gperf Do not build SRS with gperf tools(without tcmalloc and gmd/gmc/gmp/gcp). + --without-gmc Do not build memory check for SRS with gperf tools. + --without-gmd Do not build memory defense for SRS with gperf tools. + --without-gmp Do not build memory profile for SRS with gperf tools. + --without-gcp Do not build cpu profile for SRS with gperf tools. + --without-gprof Do not build srs with gprof(GNU profile tool). Toolchain options: - --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Pass to ST as EXTRA_CFLAGS. + https://github.com/ossrs/srs/issues/1547#issuecomment-576078411 + --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. -Recomment to enable: - --with-http-api enable HTTP API, to communicate with SRS. - --with-http-callback enable HTTP hooks, build cherrypy as demo api server. - --with-http-server enable HTTP server to delivery http stream. - --with-hls enable HLS streaming, mux RTMP to M3U8/TS files. - --with-dvr enable DVR, record RTMP to FLV/MP4 files. - Conflicts: 1. --with-gmc vs --with-gmp: @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html 2. --with-gperf/gmc/gmp vs --with-gprof: - gperftools not compatible with gprof. + The gperftools not compatible with gprof. 3. --arm vs --with-ffmpeg/gperf/gmc/gmp/gprof: - the complex tools not available for arm. + The complex tools not available for arm. Experts: - --use-sys-ssl donot compile ssl, use system ssl(-lssl) if required. - --memory-watch enable memory watch to detect memory leaking(hurts performance). - --export-librtmp-project= export srs-librtmp to specified project in path. - --export-librtmp-single= export srs-librtmp to a single file(.h+.cpp) in path. - --with-valgrind support valgrind for memory check. - --without-valgrind donot support valgrind for memory check. + --use-sys-ssl Do not compile ssl, use system ssl(-lssl) if required. + --export-librtmp-project= Export srs-librtmp to specified project in path. + --export-librtmp-single= Export srs-librtmp to a single file(.h+.cpp) in path. Workflow: - 1. apply "Presets". if not specified, use default preset. - 2. apply "Options". user specified option will override the preset. - 3. check conflicts. @see Conflicts section. - 4. generate detail features. + 1. Apply "Presets". if not specified, use default preset. + 2. Apply "Features", "Performance" and others. user specified option will override the preset. + 3. Check conflicts, fail if exists conflicts. + 4. Generate Makefile. Remark: 1. For performance improving, read https://blog.csdn.net/win_lin/article/details/53503869 @@ -271,7 +243,7 @@ function parse_user_option() { --x86-x64) SRS_X86_X64=YES ;; --x86-64) SRS_X86_X64=YES ;; --osx) SRS_OSX=YES ;; - --allow-osx) SRS_ALLOW_OSX=YES ;; + --allow-osx) SRS_OSX=YES ;; --arm) SRS_CROSS_BUILD=YES ;; --mips) SRS_CROSS_BUILD=YES ;; --pi) SRS_PI=YES ;; @@ -608,15 +580,5 @@ function check_option_conflicts() { if [ $__check_ok = NO ]; then exit 1; fi - - if [[ $SRS_OSX == YES && $SRS_ALLOW_OSX == NO ]]; 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/auto/utest.sh b/trunk/auto/utest.sh index d658bf7f4..18b4978cd 100755 --- a/trunk/auto/utest.sh +++ b/trunk/auto/utest.sh @@ -23,12 +23,6 @@ GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest # the extra defines to compile utest. EXTRA_DEFINES="" -# for osx to disable the error. -# gtest/include/gtest/internal/gtest-port.h:499:13: fatal error: 'tr1/tuple' file not found -if [ $SRS_OSX = YES ]; then - EXTRA_DEFINES="$EXTRA_DEFINES -DGTEST_HAS_TR1_TUPLE=0" -fi - cat << END > ${FILE} # user must run make the ${SRS_OBJS_DIR}/utest dir # at the same dir of Makefile. diff --git a/trunk/configure b/trunk/configure index 3b366397f..876e3daa0 100755 --- a/trunk/configure +++ b/trunk/configure @@ -568,7 +568,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then echo "" echo "Configure summary:" echo " ${SRS_AUTO_USER_CONFIGURE}" - echo " ${SRS_AUTO_CONFIGURE}" + echo " ${SRS_AUTO_CONFIGURE}" if [ $SRS_HLS = YES ]; then echo -e "${GREEN}HLS is enabled.${BLACK}" else From a6fe4e80d36a06eef5a0e62f66ee78b6aa92c75b Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 20 Jan 2020 11:25:39 +0800 Subject: [PATCH 15/23] For #1547, remove the SRS_OSX macro in code --- trunk/auto/depends.sh | 2 +- trunk/src/app/srs_app_utility.cpp | 92 ++---------------------------- trunk/src/main/srs_main_server.cpp | 15 +---- trunk/src/utest/srs_utest.cpp | 5 -- trunk/src/utest/srs_utest_app.cpp | 5 -- 5 files changed, 9 insertions(+), 110 deletions(-) diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 7d301b637..d87ebd0cb 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -96,7 +96,7 @@ function Ubuntu_prepare() if [[ $SRS_VALGRIND == YES ]]; then if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then echo "Installing valgrind-dev." - require_sudoer "sudo apt-get install -y --force-yes valgrind-dev" + require_sudoer "sudo apt-get install -y --force-yes valgrind-dbg" sudo apt-get install -y --force-yes valgrind-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi echo "The valgrind-dev is installed." fi diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp index 2dc149ddc..04ece7184 100644 --- a/trunk/src/app/srs_app_utility.cpp +++ b/trunk/src/app/srs_app_utility.cpp @@ -31,9 +31,6 @@ #include #include -#ifdef SRS_OSX -#include -#endif #include #include #include @@ -329,7 +326,6 @@ SrsProcSystemStat* srs_get_system_proc_stat() bool get_proc_system_stat(SrsProcSystemStat& r) { -#ifndef SRS_OSX FILE* f = fopen("/proc/stat", "r"); if (f == NULL) { srs_warn("open system cpu stat failed, ignore"); @@ -359,10 +355,7 @@ bool get_proc_system_stat(SrsProcSystemStat& r) } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -370,7 +363,6 @@ bool get_proc_system_stat(SrsProcSystemStat& r) bool get_proc_self_stat(SrsProcSelfStat& r) { -#ifndef SRS_OSX FILE* f = fopen("/proc/self/stat", "r"); if (f == NULL) { srs_warn("open self cpu stat failed, ignore"); @@ -397,10 +389,7 @@ bool get_proc_self_stat(SrsProcSelfStat& r) &r.guest_time, &r.cguest_time); fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -495,7 +484,6 @@ SrsDiskStat* srs_get_disk_stat() bool srs_get_disk_vmstat_stat(SrsDiskStat& r) { -#ifndef SRS_OSX FILE* f = fopen("/proc/vmstat", "r"); if (f == NULL) { srs_warn("open vmstat failed, ignore"); @@ -515,10 +503,7 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat& r) } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -535,7 +520,6 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) return true; } -#ifndef SRS_OSX FILE* f = fopen("/proc/diskstats", "r"); if (f == NULL) { srs_warn("open vmstat failed, ignore"); @@ -600,10 +584,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -695,7 +676,6 @@ void srs_update_meminfo() { SrsMemInfo& r = _srs_system_meminfo; -#ifndef SRS_OSX FILE* f = fopen("/proc/meminfo", "r"); if (f == NULL) { srs_warn("open meminfo failed, ignore"); @@ -721,10 +701,7 @@ void srs_update_meminfo() } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.sample_time = srsu2ms(srs_get_system_time()); r.MemActive = r.MemTotal - r.MemFree; r.RealInUse = r.MemActive - r.Buffers - r.Cached; @@ -791,7 +768,6 @@ void srs_update_platform_info() r.srs_startup_time = srsu2ms(srs_get_system_startup_time()); -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/uptime", "r"); if (f == NULL) { @@ -820,43 +796,6 @@ void srs_update_platform_info() fclose(f); } -#else - // man 3 sysctl - if (true) { - struct timeval tv; - size_t len = sizeof(timeval); - - int mib[2]; - mib[0] = CTL_KERN; - mib[1] = KERN_BOOTTIME; - if (sysctl(mib, 2, &tv, &len, NULL, 0) < 0) { - srs_warn("sysctl boottime failed, ignore"); - return; - } - - time_t bsec = tv.tv_sec; - time_t csec = ::time(NULL); - r.os_uptime = difftime(csec, bsec); - } - - // man 3 sysctl - if (true) { - struct loadavg la; - size_t len = sizeof(loadavg); - - int mib[2]; - mib[0] = CTL_VM; - mib[1] = VM_LOADAVG; - if (sysctl(mib, 2, &la, &len, NULL, 0) < 0) { - srs_warn("sysctl loadavg failed, ignore"); - return; - } - - r.load_one_minutes = (double)la.ldavg[0] / la.fscale; - r.load_five_minutes = (double)la.ldavg[1] / la.fscale; - r.load_fifteen_minutes = (double)la.ldavg[2] / la.fscale; - } -#endif r.ok = true; } @@ -903,7 +842,6 @@ int srs_get_network_devices_count() void srs_update_network_devices() { -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/net/dev", "r"); if (f == NULL) { @@ -940,9 +878,6 @@ void srs_update_network_devices() fclose(f); } -#else - // TODO: FIXME: impelments it. -#endif } SrsNetworkRtmpServer::SrsNetworkRtmpServer() @@ -990,7 +925,6 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) int nb_tcp_mem = 0; int nb_udp4 = 0; -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/net/sockstat", "r"); if (f == NULL) { @@ -1020,20 +954,9 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) fclose(f); } -#else - // TODO: FIXME: impelments it. - nb_socks = 0; - nb_tcp4_hashed = 0; - nb_tcp_orphans = 0; - nb_tcp_tws = 0; - nb_tcp_total = 0; - nb_tcp_mem = 0; - nb_udp4 = 0; -#endif int nb_tcp_estab = 0; -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/net/snmp", "r"); if (f == NULL) { @@ -1063,10 +986,7 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) fclose(f); } -#else - // TODO: FIXME: impelments it. -#endif - + // @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c // TODO: FIXME: ignore the slabstat, @see: get_slabstat() if (true) { diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 3bfd9ebb1..85e3f193d 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -236,16 +236,6 @@ void show_macro_features() if (true) { stringstream ss; ss << "SRS on "; -#ifdef SRS_OSX - ss << "OSX"; -#endif -#ifdef SRS_PI - ss << "RespberryPi"; -#endif -#ifdef SRS_CUBIE - ss << "CubieBoard"; -#endif - #if defined(__amd64__) ss << " amd64"; #endif @@ -258,9 +248,8 @@ void show_macro_features() #if defined(__arm__) ss << "arm"; #endif - -#ifndef SRS_OSX - ss << ", glibc" << (int)__GLIBC__ << "." << (int)__GLIBC_MINOR__; +#if defined(__aarch64__) + ss << " aarch64"; #endif ss << ", conf:" << _srs_config->config() << ", limit:" << _srs_config->get_max_connections() diff --git a/trunk/src/utest/srs_utest.cpp b/trunk/src/utest/srs_utest.cpp index 74b702167..19f3d8499 100644 --- a/trunk/src/utest/srs_utest.cpp +++ b/trunk/src/utest/srs_utest.cpp @@ -46,23 +46,18 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext(); SrsConfig* _srs_config = NULL; SrsServer* _srs_server = NULL; -// Disable coroutine test for OSX. -#if !defined(SRS_OSX) #include -#endif // Initialize global settings. srs_error_t prepare_main() { srs_error_t err = srs_success; - #if !defined(SRS_OSX) if ((err = srs_st_init()) != srs_success) { return srs_error_wrap(err, "init st"); } srs_freep(_srs_context); _srs_context = new SrsThreadContext(); - #endif return err; } diff --git a/trunk/src/utest/srs_utest_app.cpp b/trunk/src/utest/srs_utest_app.cpp index 344cc0f43..5d158d5d6 100644 --- a/trunk/src/utest/srs_utest_app.cpp +++ b/trunk/src/utest/srs_utest_app.cpp @@ -27,9 +27,6 @@ using namespace std; #include #include -// Disable coroutine test for OSX. -#if !defined(SRS_OSX) - #include VOID TEST(AppCoroutineTest, Dummy) @@ -375,5 +372,3 @@ VOID TEST(AppFragmentTest, CheckDuration) } } -#endif - From 6af8e380172e937284f09868c2a8be63d0f14167 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 21 Jan 2020 10:28:25 +0800 Subject: [PATCH 16/23] For #1547, support setting cc/cxx/ar tools. 3.0.103 --- README.md | 2 ++ trunk/auto/depends.sh | 4 +-- trunk/auto/options.sh | 50 ++++++++++++++++++++++++++----------- trunk/configure | 12 ++++----- trunk/src/core/srs_core.hpp | 2 +- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1846ef72d..67015898b 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-21, For [#1547][bug #1547], support setting cc/cxx/ar tools. 3.0.103 * v3.0, 2020-01-19, For [#1580][bug #1580], fix cid range problem. 3.0.102 * v3.0, 2020-01-19, For [#1070][bug #1070], define FLV CodecID for [AV1][bug #1070] and [opus][bug #307]. 3.0.101 * v3.0, 2020-01-16, For [#1575][bug #1575], correct RTMP redirect as tcUrl, add redirect2 as RTMP URL. 3.0.100 @@ -1602,6 +1603,7 @@ Winlin [bug #307]: https://github.com/ossrs/srs/issues/307 [bug #1070]: https://github.com/ossrs/srs/issues/1070 [bug #1580]: https://github.com/ossrs/srs/issues/1580 +[bug #1547]: https://github.com/ossrs/srs/issues/1547 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index d87ebd0cb..b252cccac 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -221,8 +221,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_VALGRIND" fi # Pass the global extra flags. - if [[ $SRS_EXTRA_CFLAGS != '' ]]; then - _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_CFLAGS" + 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 diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index e6c40439c..7dd1ae0af 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -54,8 +54,6 @@ SRS_GCOV=NO SRS_LOG_VERBOSE=NO SRS_LOG_INFO=NO SRS_LOG_TRACE=NO -# The extra c/c++ flags to build SRS. Note that we also pass to ST as EXTRA_CFLAGS. -SRS_EXTRA_CFLAGS= # ################################################################ # experts @@ -97,8 +95,12 @@ SRS_DISABLE_ALL=NO SRS_ENABLE_ALL=NO # ##################################################################################### -# Whether enable crossbuild for ARM or MIPS. +# Toolchain crossbuild for ARM or MIPS. SRS_CROSS_BUILD=NO +SRS_TOOL_CC=gcc +SRS_TOOL_CXX=g++ +SRS_TOOL_AR=ar +SRS_EXTRA_FLAGS= ##################################################################################### # menu @@ -139,8 +141,7 @@ Features: --log-info Whether enable the log info level. default: no. --log-trace Whether enable the log trace level. default: yes. -Performance: - https://blog.csdn.net/win_lin/article/details/53503869 +Performance: @see https://blog.csdn.net/win_lin/article/details/53503869 --with-valgrind Support valgrind for memory check. --with-gperf Build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). --with-gmc Build memory check for SRS with gperf tools. @@ -157,8 +158,12 @@ Performance: --without-gcp Do not build cpu profile for SRS with gperf tools. --without-gprof Do not build srs with gprof(GNU profile tool). -Toolchain options: - https://github.com/ossrs/srs/issues/1547#issuecomment-576078411 +Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuecomment-576078411 + --arm Enable crossbuild for ARM. + --mips Enable crossbuild for MIPS. + --cc= Use c compiler CC, default is gcc. + --cxx= Use c++ compiler CXX, default is g++. + --ar= Use archive tool AR, default is ar. --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. Conflicts: @@ -232,20 +237,24 @@ function parse_user_option() { --without-mips-ubuntu12) SRS_CROSS_BUILD=NO ;; --jobs) SRS_JOBS=${value} ;; - --extra-flags) SRS_EXTRA_CFLAGS=${value} ;; --prefix) SRS_PREFIX=${value} ;; --static) SRS_STATIC=YES ;; --log-verbose) SRS_LOG_VERBOSE=YES ;; --log-info) SRS_LOG_INFO=YES ;; --log-trace) SRS_LOG_TRACE=YES ;; --gcov) SRS_GCOV=YES ;; - + + --arm) SRS_CROSS_BUILD=YES ;; + --mips) SRS_CROSS_BUILD=YES ;; + --cc) SRS_TOOL_CC=${value} ;; + --cxx) SRS_TOOL_CXX=${value} ;; + --ar) SRS_TOOL_AR=${value} ;; + --extra-flags) SRS_EXTRA_FLAGS=${value} ;; + --x86-x64) SRS_X86_X64=YES ;; --x86-64) SRS_X86_X64=YES ;; --osx) SRS_OSX=YES ;; --allow-osx) SRS_OSX=YES ;; - --arm) SRS_CROSS_BUILD=YES ;; - --mips) SRS_CROSS_BUILD=YES ;; --pi) SRS_PI=YES ;; --cubie) SRS_CUBIE=YES ;; --dev) SRS_DEV=YES ;; @@ -285,7 +294,7 @@ function parse_user_option_to_value_and_option() { case "$option" in -*=*) value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'` - option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/. ]*||'` + option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/. +]*||'` ;; *) value="" ;; esac @@ -507,7 +516,10 @@ SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}" if [ $SRS_LOG_INFO = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-info"; fi 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_CFLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_CFLAGS\\\""; fi + if [[ $SRS_EXTRA_FLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_FLAGS\\\""; 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 echo "User config: $SRS_AUTO_USER_CONFIGURE" echo "Detail config: ${SRS_AUTO_CONFIGURE}" } @@ -517,8 +529,16 @@ regenerate_options # check user options ##################################################################################### function check_option_conflicts() { - if [ $SRS_CROSS_BUILD = YES ]; then - echo "We don't support crossbuild for ARM/MIPS, please directly build it on ARM/MIPS server." + if [[ $SRS_TOOL_CC == '' ]]; then + echo "No c compiler" + exit -1 + fi + if [[ $SRS_TOOL_CXX == '' ]]; then + echo "No c++ compiler" + exit -1 + fi + if [[ $SRS_TOOL_AR == '' ]]; then + echo "No arhive tool" exit -1 fi diff --git a/trunk/configure b/trunk/configure index 876e3daa0..d09ebc09e 100755 --- a/trunk/configure +++ b/trunk/configure @@ -119,16 +119,16 @@ if [[ $SRS_GCOV == YES ]]; then CXXFLAGS="${CXXFLAGS} ${SrsGcov}"; fi # User configed options. -if [[ $SRS_EXTRA_CFLAGS != '' ]]; then - CXXFLAGS="${CXXFLAGS} $SRS_EXTRA_CFLAGS"; +if [[ $SRS_EXTRA_FLAGS != '' ]]; then + CXXFLAGS="${CXXFLAGS} $SRS_EXTRA_FLAGS"; fi # Start to generate the Makefile. cat << END >> ${SRS_OBJS}/${SRS_MAKEFILE} -GCC = gcc -CXX = g++ -AR = ar +GCC = ${SRS_TOOL_CC} +CXX = ${SRS_TOOL_CXX} +AR = ${SRS_TOOL_AR} ARFLAGS = -rs -LINK = g++ +LINK = ${SRS_TOOL_CXX} CXXFLAGS = ${CXXFLAGS} .PHONY: default srs srs_ingest_hls librtmp diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 7864d556b..402eb8553 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 102 +#define VERSION_REVISION 103 // The macros generated by configure script. #include From 0df108740a9444a9050762072ddbc22384939573 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 21 Jan 2020 13:59:43 +0800 Subject: [PATCH 17/23] Fix #1547, support crossbuild for ARM/MIPS. --- README.md | 3 +- trunk/auto/auto_headers.sh | 5 +++ trunk/auto/depends.sh | 61 +++++++++++++++------------- trunk/auto/options.sh | 24 +++++++++++ trunk/src/main/srs_main_server.cpp | 3 ++ trunk/src/service/srs_service_st.cpp | 7 +++- 6 files changed, 73 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 67015898b..5dd769ecf 100755 --- a/README.md +++ b/README.md @@ -146,7 +146,8 @@ For previous versions, please read: ## V3 changes -* v3.0, 2020-01-21, For [#1547][bug #1547], support setting cc/cxx/ar tools. 3.0.103 +* v3.0, 2020-01-21, Fix [#1547][bug #1547], support crossbuild for ARM/MIPS. +* v3.0, 2020-01-21, For [#1547][bug #1547], support setting cc/cxx/ar/ld/randlib tools. 3.0.103 * v3.0, 2020-01-19, For [#1580][bug #1580], fix cid range problem. 3.0.102 * v3.0, 2020-01-19, For [#1070][bug #1070], define FLV CodecID for [AV1][bug #1070] and [opus][bug #307]. 3.0.101 * v3.0, 2020-01-16, For [#1575][bug #1575], correct RTMP redirect as tcUrl, add redirect2 as RTMP URL. 3.0.100 diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 10b2afb77..87720b840 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -132,6 +132,11 @@ if [ $SRS_LOG_TRACE = YES ]; then else srs_undefine_macro "SRS_AUTO_TRACE" $SRS_AUTO_HEADERS_H fi +if [ $SRS_CROSS_BUILD = YES ]; then + srs_define_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H +else + srs_undefine_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H +fi # prefix echo "" >> $SRS_AUTO_HEADERS_H diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index b252cccac..1dd9841ec 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -232,7 +232,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then ( 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}" && + 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 ) fi @@ -321,38 +322,43 @@ fi ##################################################################################### # openssl, for rtmp complex handshake ##################################################################################### -# extra configure options -OPENSSL_HOTFIX="-DOPENSSL_NO_HEARTBEATS" +if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then + echo "Warning: Use system libssl, without compiling openssl." +fi # @see http://www.openssl.org/news/secadv/20140407.txt # Affected users should upgrade to OpenSSL 1.1.0e. Users unable to immediately # upgrade can alternatively recompile OpenSSL with -DOPENSSL_NO_HEARTBEATS. -if [ $SRS_SSL = YES ]; then - 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 && - 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 && - ln -sf /usr/local/include/openssl) - fi - if [ $SRS_USE_SYS_SSL = YES ]; then - echo "Warning: Use system libssl, without compiling openssl." +if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then + OPENSSL_HOTFIX="-DOPENSSL_NO_HEARTBEATS" + OPENSSL_CONFIG="./config" + # https://stackoverflow.com/questions/15539062/cross-compiling-of-openssl-for-linux-arm-v5te-linux-gnueabi-toolchain + if [[ $SRS_CROSS_BUILD == YES ]]; then + OPENSSL_CONFIG="./Configure linux-armv4" else - # cross build not specified, if exists flag, need to rebuild for no-arm platform. - if [[ -f ${SRS_OBJS}/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 && - ./config --prefix=`pwd`/_release -no-shared no-threads $OPENSSL_HOTFIX && - make && make install_sw && - cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl - ) + # 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 && + 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 && + ln -sf /usr/local/include/openssl) fi - # check status - ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi - if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi fi + # cross build not specified, if exists flag, need to rebuild for no-arm platform. + if [[ -f ${SRS_OBJS}/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 && + ${OPENSSL_CONFIG} --prefix=`pwd`/_release -no-shared -no-threads -no-asm $OPENSSL_HOTFIX && + make CC=${SRS_TOOL_CC} AR="${SRS_TOOL_AR} -rs" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} && make install_sw && + cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl + ) + fi + # check status + ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi + if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi fi ##################################################################################### @@ -447,4 +453,3 @@ 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 7dd1ae0af..4bc2ffc15 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -100,6 +100,8 @@ SRS_CROSS_BUILD=NO SRS_TOOL_CC=gcc SRS_TOOL_CXX=g++ SRS_TOOL_AR=ar +SRS_TOOL_LD=ld +SRS_TOOL_RANDLIB=randlib SRS_EXTRA_FLAGS= ##################################################################################### @@ -164,6 +166,8 @@ Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuec --cc= Use c compiler CC, default is gcc. --cxx= Use c++ compiler CXX, default is g++. --ar= Use archive tool AR, default is ar. + --ld= Use linker tool LD, default is ld. + --randlib= Use randlib tool RANDLIB, default is randlib. --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. Conflicts: @@ -249,6 +253,8 @@ function parse_user_option() { --cc) SRS_TOOL_CC=${value} ;; --cxx) SRS_TOOL_CXX=${value} ;; --ar) SRS_TOOL_AR=${value} ;; + --ld) SRS_TOOL_LD=${value} ;; + --randlib) SRS_TOOL_RANDLIB=${value} ;; --extra-flags) SRS_EXTRA_FLAGS=${value} ;; --x86-x64) SRS_X86_X64=YES ;; @@ -420,6 +426,14 @@ function apply_user_presets() { SRS_UTEST=NO SRS_STATIC=NO fi + + # if crossbuild, disable research and librtmp. + if [[ $SRS_CROSS_BUILD == YES ]]; then + SRS_LIBRTMP=NO + SRS_RESEARCH=NO + SRS_UTEST=NO + SRS_STATIC=NO + fi } apply_user_presets @@ -520,6 +534,8 @@ SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}" 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 + if [[ $SRS_TOOL_LD != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ld=$SRS_TOOL_LD"; fi + if [[ $SRS_TOOL_RANDLIB != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --randlib=$SRS_TOOL_RANDLIB"; fi echo "User config: $SRS_AUTO_USER_CONFIGURE" echo "Detail config: ${SRS_AUTO_CONFIGURE}" } @@ -541,6 +557,14 @@ function check_option_conflicts() { echo "No arhive tool" exit -1 fi + if [[ $SRS_TOOL_LD == '' ]]; then + echo "No linker tool" + exit -1 + fi + if [[ $SRS_TOOL_RANDLIB == '' ]]; then + echo "No randlib tool" + exit -1 + fi if [ $SRS_OSX = YES ]; then echo "We don't support OSX, please use docker https://github.com/ossrs/srs-docker" diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 85e3f193d..2141ddab5 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -251,6 +251,9 @@ void show_macro_features() #if defined(__aarch64__) ss << " aarch64"; #endif +#if defined(SRS_AUTO_CROSSBUILD) + ss << "(crossbuild)"; +#endif ss << ", conf:" << _srs_config->config() << ", limit:" << _srs_config->get_max_connections() << ", writev:" << sysconf(_SC_IOV_MAX) << ", encoding:" << (srs_is_little_endian()? "little-endian":"big-endian") diff --git a/trunk/src/service/srs_service_st.cpp b/trunk/src/service/srs_service_st.cpp index 6cd04ba93..d8d9c3892 100644 --- a/trunk/src/service/srs_service_st.cpp +++ b/trunk/src/service/srs_service_st.cpp @@ -115,7 +115,12 @@ srs_error_t srs_fd_reuseport(int fd) #if defined(SO_REUSEPORT) int v = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &v, sizeof(int)) == -1) { - return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd); + #ifdef SRS_AUTO_CROSSBUILD + srs_warn("SO_REUSEPORT disabled for crossbuild"); + return srs_success; + #else + return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd); + #endif } #else #warning "SO_REUSEPORT is not supported by your OS" From ba61fe8bc54efad30f8c94ea7c7638d4d71919d3 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 21 Jan 2020 15:22:55 +0800 Subject: [PATCH 18/23] Fix #1221, remove complex configure options. 3.0.104 --- README.md | 2 ++ trunk/auto/depends.sh | 9 +++++---- trunk/auto/options.sh | 25 ++++++++++++++----------- trunk/src/core/srs_core.hpp | 2 +- trunk/src/main/srs_main_server.cpp | 2 +- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5dd769ecf..6e07570b2 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-21, Fix [#1221][bug #1221], remove complex configure options. 3.0.104 * v3.0, 2020-01-21, Fix [#1547][bug #1547], support crossbuild for ARM/MIPS. * v3.0, 2020-01-21, For [#1547][bug #1547], support setting cc/cxx/ar/ld/randlib tools. 3.0.103 * v3.0, 2020-01-19, For [#1580][bug #1580], fix cid range problem. 3.0.102 @@ -1605,6 +1606,7 @@ Winlin [bug #1070]: https://github.com/ossrs/srs/issues/1070 [bug #1580]: https://github.com/ossrs/srs/issues/1580 [bug #1547]: https://github.com/ossrs/srs/issues/1547 +[bug #1221]: https://github.com/ossrs/srs/issues/1221 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 1dd9841ec..bf183c0a6 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -320,7 +320,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then fi ##################################################################################### -# openssl, for rtmp complex handshake +# openssl, for rtmp complex handshake and HLS encryption. ##################################################################################### if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then echo "Warning: Use system libssl, without compiling openssl." @@ -364,10 +364,11 @@ 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 +fi if [ $SRS_FFMPEG_TOOL = YES ]; then - 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 - fi if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then echo "ffmpeg-4.1 is ok."; else diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 4bc2ffc15..10b224da9 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -219,15 +219,10 @@ function parse_user_option() { --with-gprof) SRS_GPROF=YES ;; --with-arm-ubuntu12) SRS_CROSS_BUILD=YES ;; --with-mips-ubuntu12) SRS_CROSS_BUILD=YES ;; - - --without-ssl) SRS_SSL=NO ;; + --without-hds) SRS_HDS=NO ;; --without-nginx) SRS_NGINX=NO ;; --without-ffmpeg) SRS_FFMPEG_TOOL=NO ;; - --without-transcode) SRS_TRANSCODE=NO ;; - --without-ingest) SRS_INGEST=NO ;; - --without-stat) SRS_STAT=NO ;; - --without-stream-caster) SRS_STREAM_CASTER=NO ;; --without-librtmp) SRS_LIBRTMP=NO ;; --without-research) SRS_RESEARCH=NO ;; --without-utest) SRS_UTEST=NO ;; @@ -283,11 +278,19 @@ function parse_user_option() { --with-http-server) SRS_HTTP_SERVER=YES ;; --with-hls) SRS_HLS=YES ;; --with-dvr) SRS_DVR=YES ;; - --without-http-callback) SRS_HTTP_CALLBACK=NO ;; - --without-http-api) SRS_HTTP_API=NO ;; - --without-http-server) SRS_HTTP_SERVER=NO ;; - --without-hls) SRS_HLS=NO ;; - --without-dvr) SRS_DVR=NO ;; + + --without-stream-caster) ;& + --without-ingest) ;& + --without-ssl) ;& + --without-stat) ;& + --without-transcode) ;& + --without-http-callback) ;& + --without-http-server) ;& + --without-http-api) ;& + --without-hls) ;& + --without-dvr) + echo "ignore option \"$option\"" + ;; *) echo "$0: error: invalid option \"$option\"" diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 402eb8553..65995e1ba 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 103 +#define VERSION_REVISION 104 // The macros generated by configure script. #include diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 2141ddab5..25cfbaf30 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -119,7 +119,7 @@ srs_error_t do_main(int argc, char** argv) // config already applied to log. srs_trace("%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE); - srs_trace("contributors: " SRS_AUTO_CONSTRIBUTORS); + srs_trace("contributors: %s", SRS_AUTO_CONSTRIBUTORS); srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s", _srs_config->cwd().c_str(), cwd.c_str(), SRS_AUTO_BUILD_DATE, SRS_AUTO_USER_CONFIGURE, SRS_AUTO_UNAME); srs_trace("configure detail: " SRS_AUTO_CONFIGURE); From c3bf0cbe1bfdebb7506ab17fcd2f916f104eaf6d Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 21 Jan 2020 15:47:19 +0800 Subject: [PATCH 19/23] For #1547, check options for crossbuild. --- trunk/auto/options.sh | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 10b224da9..8e9fae371 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -335,7 +335,7 @@ function apply_user_presets() { # set default preset if not specifies if [[ $SRS_PURE_RTMP == NO && $SRS_FAST == NO && $SRS_DISABLE_ALL == NO && $SRS_ENABLE_ALL == NO && \ $SRS_DEV == NO && $SRS_FAST_DEV == NO && $SRS_DEMO == NO && $SRS_PI == NO && $SRS_CUBIE == NO && \ - $SRS_X86_X64 == NO && $SRS_OSX == NO \ + $SRS_X86_X64 == NO && $SRS_OSX == NO && $SRS_CROSS_BUILD == NO \ ]]; then SRS_X86_X64=YES; opt="--x86-x64 $opt"; fi @@ -548,40 +548,24 @@ regenerate_options # check user options ##################################################################################### function check_option_conflicts() { - if [[ $SRS_TOOL_CC == '' ]]; then - echo "No c compiler" - exit -1 + if [[ $SRS_TOOL_CC == '' || $SRS_TOOL_CXX == '' || $SRS_TOOL_AR == '' || $SRS_TOOL_LD == '' || $SRS_TOOL_RANDLIB == '' ]]; then + echo "No crossbuild tools, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR, ld: $SRS_TOOL_LD, randlib: $SRS_TOOL_RANDLIB"; exit -1 fi - if [[ $SRS_TOOL_CXX == '' ]]; then - echo "No c++ compiler" - exit -1 - fi - if [[ $SRS_TOOL_AR == '' ]]; then - echo "No arhive tool" - exit -1 - fi - if [[ $SRS_TOOL_LD == '' ]]; then - echo "No linker tool" - exit -1 - fi - if [[ $SRS_TOOL_RANDLIB == '' ]]; then - echo "No randlib tool" - exit -1 + + if [[ $SRS_CROSS_BUILD == YES && ($SRS_TOOL_CC == 'gcc' || $SRS_TOOL_CXX == 'g++' || $SRS_TOOL_AR == 'ar') ]]; then + 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 + 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. From 6107db91f5974e6e1c9949531def103580ec17f6 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 21 Jan 2020 16:14:15 +0800 Subject: [PATCH 20/23] Release 3.0 alpha9, 3.0a9, 3.0.105 --- README.md | 3 +++ trunk/src/core/srs_core.hpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e07570b2..9a8459899 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-21, [3.0 alpha9(3.0.105)][r3.0a9] released. 121577 lines. * v3.0, 2020-01-21, Fix [#1221][bug #1221], remove complex configure options. 3.0.104 * v3.0, 2020-01-21, Fix [#1547][bug #1547], support crossbuild for ARM/MIPS. * v3.0, 2020-01-21, For [#1547][bug #1547], support setting cc/cxx/ar/ld/randlib tools. 3.0.103 @@ -720,6 +721,7 @@ For previous versions, please read: ## Releases +* 2020-01-21, [Release v3.0-a9][r3.0a9], 3.0 alpha9, 3.0.105, 121577 lines. * 2020-01-10, [Release v3.0-a8][r3.0a8], 3.0 alpha8, 3.0.97, 121555 lines. * 2019-12-29, [Release v3.0-a7][r3.0a7], 3.0 alpha7, 3.0.90, 116356 lines. * 2019-12-26, [Release v3.0-a6][r3.0a6], 3.0 alpha6, 3.0.85, 116056 lines. @@ -1611,6 +1613,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r3.0a9]: https://github.com/ossrs/srs/releases/tag/v3.0-a9 [r3.0a8]: https://github.com/ossrs/srs/releases/tag/v3.0-a8 [r3.0a7]: https://github.com/ossrs/srs/releases/tag/v3.0-a7 [r3.0a6]: https://github.com/ossrs/srs/releases/tag/v3.0-a6 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 65995e1ba..732f4b120 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 104 +#define VERSION_REVISION 105 // The macros generated by configure script. #include From 235c889e14e8caa64cd5b9605369fda20de3e027 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 24 Jan 2020 15:35:14 +0800 Subject: [PATCH 21/23] Update config --- trunk/conf/dash.conf | 23 +++++++++++++++++++++++ trunk/conf/hls.conf | 5 +++++ 2 files changed, 28 insertions(+) create mode 100644 trunk/conf/dash.conf diff --git a/trunk/conf/dash.conf b/trunk/conf/dash.conf new file mode 100644 index 000000000..9d7f21fdd --- /dev/null +++ b/trunk/conf/dash.conf @@ -0,0 +1,23 @@ +# the config for srs to delivery dash +# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleDASH +# @see full.conf for detail config. + +listen 1935; +max_connections 1000; +daemon off; +srs_log_tank console; +http_server { + enabled on; + listen 8080; + dir ./objs/nginx/html; +} +vhost __defaultVhost__ { + dash { + enabled on; + dash_fragment 30; + dash_update_period 150; + dash_timeshift 300; + dash_path ./objs/nginx/html; + dash_mpd_file [app]/[stream].mpd; + } +} diff --git a/trunk/conf/hls.conf b/trunk/conf/hls.conf index d0fa42397..17416a294 100644 --- a/trunk/conf/hls.conf +++ b/trunk/conf/hls.conf @@ -6,6 +6,11 @@ listen 1935; max_connections 1000; daemon off; srs_log_tank console; +http_server { + enabled on; + listen 8080; + dir ./objs/nginx/html; +} vhost __defaultVhost__ { hls { enabled on; From 6864e1ca6d3b6ef0a202af44b6db9563af0e56ef Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 25 Jan 2020 12:56:01 +0800 Subject: [PATCH 22/23] Release 2.0r8, 2.0.272 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5c8526662..f897a24bf 100755 --- a/README.md +++ b/README.md @@ -295,6 +295,7 @@ Remark: ## Releases +* 2020-01-25, [Release v2.0-r8][r2.0r8], 2.0 release8, 2.0.272, 87292 lines. * 2018-11-29, [Release v2.0-r7][r2.0r7], 2.0 release7, 2.0.265, 86994 lines. * 2018-10-28, [Release v2.0-r6][r2.0r6], 2.0 release6, 2.0.263, 86994 lines. * 2018-10-28, [Release v2.0-r5][r2.0r5], 2.0 release5, 2.0.258, 86916 lines. @@ -338,6 +339,7 @@ Remark: ## History +* v2.0, 2020-01-25, [2.0 release8(2.0.272)][r2.0r8] released. 87292 lines. * v2.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 2.0.272 * v2.0, 2020-01-05, Merge [#1551][bug #1551], fix memory leak in RTSP stack. 2.0.270 * v2.0, 2019-12-26, For [#1488][bug #1488], pass client ip to http callback. 2.0.269 @@ -1367,6 +1369,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r2.0r8]: https://github.com/ossrs/srs/releases/tag/v2.0-r8 [r2.0r7]: https://github.com/ossrs/srs/releases/tag/v2.0-r7 [r2.0r6]: https://github.com/ossrs/srs/releases/tag/v2.0-r6 [r2.0r5]: https://github.com/ossrs/srs/releases/tag/v2.0-r5 From 978d5e993b680635174b57d79585ecd4449ab871 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 25 Jan 2020 15:04:34 +0800 Subject: [PATCH 23/23] Fix #1108, reap DVR tmp file when unpublish. 3.0.106 --- README.md | 2 ++ trunk/src/app/srs_app_dvr.cpp | 9 +++++++++ trunk/src/core/srs_core.hpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f926e33a..b0cf323d5 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-25, Fix [#1108][bug #1108], reap DVR tmp file when unpublish. 3.0.106 * v3.0, 2020-01-21, [3.0 alpha9(3.0.105)][r3.0a9] released. 121577 lines. * v3.0, 2020-01-21, Fix [#1221][bug #1221], remove complex configure options. 3.0.104 * v3.0, 2020-01-21, Fix [#1547][bug #1547], support crossbuild for ARM/MIPS. @@ -1610,6 +1611,7 @@ Winlin [bug #1580]: https://github.com/ossrs/srs/issues/1580 [bug #1547]: https://github.com/ossrs/srs/issues/1547 [bug #1221]: https://github.com/ossrs/srs/issues/1221 +[bug #1108]: https://github.com/ossrs/srs/issues/1108 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_dvr.cpp b/trunk/src/app/srs_app_dvr.cpp index 507956aed..aca14581a 100644 --- a/trunk/src/app/srs_app_dvr.cpp +++ b/trunk/src/app/srs_app_dvr.cpp @@ -813,7 +813,16 @@ srs_error_t SrsDvrSegmentPlan::on_publish() void SrsDvrSegmentPlan::on_unpublish() { + srs_error_t err = srs_success; + SrsDvrPlan::on_unpublish(); + + if ((err = segment->close()) != srs_success) { + srs_warn("ignore err %s", srs_error_desc(err).c_str()); + srs_freep(err); + } + + dvr_enabled = false; } srs_error_t SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format) diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 732f4b120..2bca91cdf 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 105 +#define VERSION_REVISION 106 // The macros generated by configure script. #include