From 0b79de9d13d93c846ca7353f3345138ef7fb0496 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Fri, 19 Nov 2021 15:33:16 +0800 Subject: [PATCH] =?UTF-8?q?MediaSource:=20=E7=A6=81=E6=AD=A2=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=8E=A8=E9=80=81=E4=B8=80=E4=B8=AA=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=9A=84=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MediaSource.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index 53dd6951..faa6237e 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -418,7 +418,11 @@ void MediaSource::regist() { { //减小互斥锁临界区 lock_guard lock(s_media_source_mtx); - s_media_source_map[_schema][_vhost][_app][_stream_id] = shared_from_this(); + auto &ref = s_media_source_map[_schema][_vhost][_app][_stream_id]; + if (ref.lock()) { + throw std::invalid_argument("media source already existed:" + _schema + "/" + _vhost + "/" + _app + "/" + _stream_id); + } + ref = shared_from_this(); } emitEvent(true); }