From b9294c87ccea73e2769d957a478cff32272829c1 Mon Sep 17 00:00:00 2001 From: xzl <771730766@qq.com> Date: Fri, 12 May 2017 16:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=99=A8=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E5=9C=A8=E4=B8=BB=E7=BA=BF=E7=A8=8B=E6=9E=90=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Player/PlayerBase.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Player/PlayerBase.cpp b/src/Player/PlayerBase.cpp index 466e373e..4d342885 100644 --- a/src/Player/PlayerBase.cpp +++ b/src/Player/PlayerBase.cpp @@ -21,13 +21,18 @@ namespace Player { PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) { string prefix = FindField(strUrl, NULL, "://"); + auto onDestory = [](PlayerBase *ptr){ + EventPoller::Instance().async([ptr](){ + delete ptr; + }); + }; if (strcasecmp("rtsp",prefix.data()) == 0) { - return PlayerBase::Ptr(new RtspPlayerImp()); + return PlayerBase::Ptr(new RtspPlayerImp(),onDestory); } if (strcasecmp("rtmp",prefix.data()) == 0) { - return PlayerBase::Ptr(new RtmpPlayerImp()); + return PlayerBase::Ptr(new RtmpPlayerImp(),onDestory); } - return PlayerBase::Ptr(new RtspPlayerImp()); + return PlayerBase::Ptr(new RtspPlayerImp(),onDestory); } } /* namespace Player */