diff --git a/README.md b/README.md index ef3636dd4..5ae2d02ca 100755 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ The ports used by SRS: ## V4 changes +* v4.0, 2021-05-18, Fix [#2355][bug #2355]: GB28181: Fix play by RTC bug. 4.0.116 * v4.0, 2021-05-15, SRT: Build SRT from source by SRS. 4.0.115 * v4.0, 2021-05-15, Rename SrsConsumer* to SrsLiveConsumer*. 4.0.114 * v4.0, 2021-05-15, Rename SrsRtcStream* to SrsRtcSource*. 4.0.113 @@ -1923,6 +1924,7 @@ Winlin [bug #2188]: https://github.com/ossrs/srs/issues/2188 [bug #1193]: https://github.com/ossrs/srs/issues/1193 [bug #2304]: https://github.com/ossrs/srs/issues/2304#issuecomment-826009290 +[bug #2355]: https://github.com/ossrs/srs/issues/2355 [bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy [bug #1631]: https://github.com/ossrs/srs/issues/1631 diff --git a/trunk/src/app/srs_app_gb28181.cpp b/trunk/src/app/srs_app_gb28181.cpp index d99ef0544..14bb3de45 100644 --- a/trunk/src/app/srs_app_gb28181.cpp +++ b/trunk/src/app/srs_app_gb28181.cpp @@ -51,6 +51,7 @@ using namespace std; #include #include #include +#include //#define W_PS_FILE //#define W_VIDEO_FILE @@ -1436,10 +1437,38 @@ srs_error_t SrsGb28181RtmpMuxer::initialize(SrsServer *s, SrsRequest* r) return srs_error_wrap(err, "create source"); } - //TODO: ??? - // if (!source->can_publish(false)) { - // return srs_error_new(ERROR_GB28181_SESSION_IS_EXIST, "stream %s busy", req->get_stream_url().c_str()); - // } + #ifdef SRS_RTC + SrsRtcSource *rtc = NULL; + bool rtc_server_enabled = _srs_config->get_rtc_server_enabled(); + bool rtc_enabled = _srs_config->get_rtc_enabled(req->vhost); + if (rtc_server_enabled && rtc_enabled) { + if ((err = _srs_rtc_sources->fetch_or_create(req, &rtc)) != srs_success) { + return srs_error_wrap(err, "create source"); + } + + if (!rtc->can_publish()) { + return srs_error_new(ERROR_RTC_SOURCE_BUSY, "gb28181 rtc stream %s busy", req->get_stream_url().c_str()); + } + } +#endif + + // Check whether RTMP stream is busy. + if (!source->can_publish(false)) { + return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "gb28181 rtmp: stream %s is busy", req->get_stream_url().c_str()); + } + + // Bridge to RTC streaming. +#if defined(SRS_RTC) && defined(SRS_FFMPEG_FIT) + if (rtc) { + SrsRtcFromRtmpBridger *bridger = new SrsRtcFromRtmpBridger(rtc); + if ((err = bridger->initialize(req)) != srs_success) { + srs_freep(bridger); + return srs_error_wrap(err, "bridger init"); + } + + source->set_bridger(bridger); + } +#endif if ((err = source->on_publish()) != srs_success) { return srs_error_wrap(err, "on publish"); diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 8f301a368..31be6ba1a 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -26,6 +26,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 115 +#define VERSION_REVISION 116 #endif