diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 5a4e32ab42..1fd5788385 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);