From c30aa479a76a78b8bd4ea7bceb2df6cf44aa0f23 Mon Sep 17 00:00:00 2001 From: chundonglinlin Date: Wed, 12 Jan 2022 09:12:29 +0800 Subject: [PATCH] RTC: Fix both rtmp and rtc streams can be published at the same time. (#2875) --- trunk/src/app/srs_app_rtc_conn.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 5a4e32ab4..1fd578838 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1183,20 +1183,20 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcSourceDescripti } source->set_publish_stream(this); + // TODO: FIMXE: Check it in SrsRtcConnection::add_publisher? + SrsLiveSource *rtmp = _srs_sources->fetch(r); + if (rtmp && !rtmp->can_publish(false)) { + return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str()); + } + // Bridge to rtmp #if defined(SRS_RTC) && defined(SRS_FFMPEG_FIT) bool rtc_to_rtmp = _srs_config->get_rtc_to_rtmp(req_->vhost); if (rtc_to_rtmp) { - SrsLiveSource *rtmp = NULL; if ((err = _srs_sources->fetch_or_create(r, _srs_hybrid->srs()->instance(), &rtmp)) != srs_success) { return srs_error_wrap(err, "create source"); } - // TODO: FIMXE: Check it in SrsRtcConnection::add_publisher? - if (!rtmp->can_publish(false)) { - return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str()); - } - // Disable GOP cache for RTC2RTMP bridger, to keep the streams in sync, // especially for stream merging. rtmp->set_cache(false);