From c3302eec1eb9c8542701b7fd5d723da0be3c9490 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 29 Dec 2019 13:38:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96hls=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8=E8=AE=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/HlsMediaSource.cpp | 3 ++- src/Record/HlsMediaSource.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Record/HlsMediaSource.cpp b/src/Record/HlsMediaSource.cpp index 8dd0a702..e5b0af23 100644 --- a/src/Record/HlsMediaSource.cpp +++ b/src/Record/HlsMediaSource.cpp @@ -39,6 +39,7 @@ void HlsCookieData::addReaderCount(){ if(src){ src->modifyReaderCount(true); _added = true; + _src = src; } } @@ -46,7 +47,7 @@ void HlsCookieData::addReaderCount(){ HlsCookieData::~HlsCookieData() { if(_added){ - auto src = dynamic_pointer_cast(MediaSource::find(HLS_SCHEMA,_info._vhost,_info._app,_info._streamid)); + auto src = _src.lock(); if(src){ src->modifyReaderCount(false); } diff --git a/src/Record/HlsMediaSource.h b/src/Record/HlsMediaSource.h index 89a96772..a402b1cb 100644 --- a/src/Record/HlsMediaSource.h +++ b/src/Record/HlsMediaSource.h @@ -30,6 +30,7 @@ #include "Common/MediaSource.h" namespace mediakit{ +class HlsMediaSource; class HlsCookieData{ public: HlsCookieData(const MediaInfo &info); @@ -41,6 +42,7 @@ private: uint64_t _bytes = 0; MediaInfo _info; bool _added = false; + weak_ptr _src; }; class HlsMediaSource : public MediaSource {