From a44116800460997c71b8722e197d04e157c9c146 Mon Sep 17 00:00:00 2001 From: alexliyu7352 Date: Tue, 4 Jan 2022 14:47:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8D=E4=BD=BF=E7=94=A8re?= =?UTF-8?q?setWhenReplay=E9=80=89=E9=A1=B9=E6=97=B6,=20MediaSource?= =?UTF-8?q?=E4=BC=9A=E9=87=8D=E5=A4=8D=E6=B3=A8=E5=86=8C=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#1330)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MediaSource.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index faa6237e..414c7c76 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -419,7 +419,8 @@ void MediaSource::regist() { //减小互斥锁临界区 lock_guard lock(s_media_source_mtx); auto &ref = s_media_source_map[_schema][_vhost][_app][_stream_id]; - if (ref.lock()) { + // 增加判断, 防止当前流已注册时再次注册 + if (ref.lock() && ref.lock().get() != this) { throw std::invalid_argument("media source already existed:" + _schema + "/" + _vhost + "/" + _app + "/" + _stream_id); } ref = shared_from_this();