diff --git a/README.md b/README.md index e3cfefdf6..164f74075 100755 --- a/README.md +++ b/README.md @@ -182,6 +182,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 @@ -1929,6 +1930,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/configure b/trunk/configure index 37a9398bd..bf05bf4ff 100755 --- a/trunk/configure +++ b/trunk/configure @@ -283,13 +283,10 @@ if [[ $SRS_FFMPEG_FIT == YES ]]; then MODULE_FILES+=("srs_app_rtc_codec") fi if [[ $SRS_GB28181 == YES ]]; then - MODULE_FILES+=("srs_app_gb28181" "srs_app_gb28181_sip") -fi -if [[ $SRS_GB28181 == YES || $SRS_RTC == YES ]]; then - MODULE_FILES+=("srs_app_rtc_jitbuffer") + MODULE_FILES+=("srs_app_gb28181" "srs_app_gb28181_sip" "srs_app_gb28181_jitter") fi if [[ $SRS_GB28181 == YES ]]; then - MODULE_FILES+=("srs_app_sip") + MODULE_FILES+=("srs_app_gb28181_stack") ModuleLibIncs+=(${LibIconvRoot}) fi diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index d0b257163..af2f9fad7 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -326,6 +326,23 @@ srs_error_t srs_config_transform_vhost(SrsConfDirective* root) dir->name = "http_server"; continue; } + + // SRS4.0, removed the support of configs: + // rtc_server { perf_stat; queue_length; } + if (dir->name == "rtc_server") { + std::vector::iterator it; + for (it = dir->directives.begin(); it != dir->directives.end();) { + SrsConfDirective* conf = *it; + + if (conf->name == "perf_stat" || conf->name == "queue_length") { + dir->directives.erase(it); + srs_freep(conf); + continue; + } + + ++it; + } + } if (!dir->is_vhost()) { continue; diff --git a/trunk/src/app/srs_app_gb28181.cpp b/trunk/src/app/srs_app_gb28181.cpp index d99ef0544..3fd610428 100644 --- a/trunk/src/app/srs_app_gb28181.cpp +++ b/trunk/src/app/srs_app_gb28181.cpp @@ -50,7 +50,8 @@ using namespace std; #include #include #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/app/srs_app_gb28181.hpp b/trunk/src/app/srs_app_gb28181.hpp index 268fb895b..07bd0cfa2 100644 --- a/trunk/src/app/srs_app_gb28181.hpp +++ b/trunk/src/app/srs_app_gb28181.hpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/trunk/src/app/srs_app_rtc_jitbuffer.cpp b/trunk/src/app/srs_app_gb28181_jitter.cpp similarity index 99% rename from trunk/src/app/srs_app_rtc_jitbuffer.cpp rename to trunk/src/app/srs_app_gb28181_jitter.cpp index 40a1b6fbd..852060e17 100644 --- a/trunk/src/app/srs_app_rtc_jitbuffer.cpp +++ b/trunk/src/app/srs_app_gb28181_jitter.cpp @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include #include @@ -1201,7 +1201,7 @@ SrsRtpFrameBufferEnum SrsRtpJitterBuffer::InsertPacket(uint16_t seq, uint32_t ts //CountFrame(*frame); // if (previous_state != kStateDecodable && // previous_state != kStateComplete) { - // /*CountFrame(*frame);*/ //????????????????????�?? by ylr + // /*CountFrame(*frame); // if (continuous) { // // Signal that we have a complete session. // frame_event_->Set(); @@ -1213,7 +1213,7 @@ SrsRtpFrameBufferEnum SrsRtpJitterBuffer::InsertPacket(uint16_t seq, uint32_t ts case kDecodableSession: { // *retransmitted = (frame->GetNackCount() > 0); - if (true || continuous) { + if (continuous) { decodable_frames_.InsertFrame(frame); FindAndInsertContinuousFrames(*frame); } else { @@ -1522,7 +1522,9 @@ bool SrsRtpJitterBuffer::NextMaybeIncompleteTimestamp(uint32_t* timestamp) SrsRtpFrameBuffer* oldest_frame; if (decodable_frames_.empty()) { - if (incomplete_frames_.size() <= 1) { + //in order to solve the problem of bad network, we can wait for more incomplete frames + //ex fps=15 + if (incomplete_frames_.size() < 15) { return false; } diff --git a/trunk/src/app/srs_app_rtc_jitbuffer.hpp b/trunk/src/app/srs_app_gb28181_jitter.hpp similarity index 99% rename from trunk/src/app/srs_app_rtc_jitbuffer.hpp rename to trunk/src/app/srs_app_gb28181_jitter.hpp index eef613c08..021b17cd4 100644 --- a/trunk/src/app/srs_app_rtc_jitbuffer.hpp +++ b/trunk/src/app/srs_app_gb28181_jitter.hpp @@ -21,8 +21,8 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef SRS_APP_RTC_RTP_JITBUFFER_HPP -#define SRS_APP_RTC_RTP_JITBUFFER_HPP +#ifndef SRS_APP_GB28181_RTP_JITBUFFER_HPP +#define SRS_APP_GB28181_RTP_JITBUFFER_HPP #include diff --git a/trunk/src/app/srs_app_gb28181_sip.cpp b/trunk/src/app/srs_app_gb28181_sip.cpp index 1ca695c6d..1f82f8510 100644 --- a/trunk/src/app/srs_app_gb28181_sip.cpp +++ b/trunk/src/app/srs_app_gb28181_sip.cpp @@ -43,7 +43,7 @@ using namespace std; #include #include #include -#include +#include #include diff --git a/trunk/src/app/srs_app_gb28181_sip.hpp b/trunk/src/app/srs_app_gb28181_sip.hpp index 23dd99c33..477610d7a 100644 --- a/trunk/src/app/srs_app_gb28181_sip.hpp +++ b/trunk/src/app/srs_app_gb28181_sip.hpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include diff --git a/trunk/src/app/srs_app_sip.cpp b/trunk/src/app/srs_app_gb28181_stack.cpp similarity index 99% rename from trunk/src/app/srs_app_sip.cpp rename to trunk/src/app/srs_app_gb28181_stack.cpp index c7ff221f0..198a270c6 100644 --- a/trunk/src/app/srs_app_sip.cpp +++ b/trunk/src/app/srs_app_gb28181_stack.cpp @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #if !defined(SRS_EXPORT_LIBRTMP) diff --git a/trunk/src/app/srs_app_sip.hpp b/trunk/src/app/srs_app_gb28181_stack.hpp similarity index 98% rename from trunk/src/app/srs_app_sip.hpp rename to trunk/src/app/srs_app_gb28181_stack.hpp index eea753797..67651e740 100644 --- a/trunk/src/app/srs_app_sip.hpp +++ b/trunk/src/app/srs_app_gb28181_stack.hpp @@ -21,8 +21,8 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef SRS_PROTOCOL_SIP_HPP -#define SRS_PROTOCOL_SIP_HPP +#ifndef SRS_APP_GB28181_STACK_HPP +#define SRS_APP_GB28181_STACK_HPP #include 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