From 68718953d410a9a31a92d0b7ae0abcbc2800eef3 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 3 Dec 2019 13:05:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MediaSink.cpp | 11 +++-------- src/Common/MediaSink.h | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Common/MediaSink.cpp b/src/Common/MediaSink.cpp index c757b57c..64049dc5 100644 --- a/src/Common/MediaSink.cpp +++ b/src/Common/MediaSink.cpp @@ -49,14 +49,9 @@ void MediaSink::addTrack(const Track::Ptr &track_in) { _ticker.resetTime(); } - weak_ptr weakSelf = shared_from_this(); - track->addDelegate(std::make_shared([weakSelf](const Frame::Ptr &frame){ - auto strongSelf = weakSelf.lock(); - if(!strongSelf){ - return; - } - if(!strongSelf->_anyTrackUnReady){ - strongSelf->onTrackFrame(frame); + track->addDelegate(std::make_shared([this](const Frame::Ptr &frame){ + if(!_anyTrackUnReady){ + onTrackFrame(frame); } })); } diff --git a/src/Common/MediaSink.h b/src/Common/MediaSink.h index d117aae5..0f7fc92a 100644 --- a/src/Common/MediaSink.h +++ b/src/Common/MediaSink.h @@ -60,7 +60,7 @@ public: * 该类的作用是等待Track ready()返回true也就是就绪后再通知派生类进行下一步的操作 * 目的是输入Frame前由Track截取处理下,以便获取有效的信息(譬如sps pps aa_cfg) */ -class MediaSink : public MediaSinkInterface , public TrackSource , public std::enable_shared_from_this{ +class MediaSink : public MediaSinkInterface , public TrackSource{ public: typedef std::shared_ptr Ptr; MediaSink(){}