播放器统一在主线程析构

This commit is contained in:
xzl 2017-05-12 16:10:30 +08:00
parent fd9df3f5cf
commit b9294c87cc

View File

@ -21,13 +21,18 @@ namespace Player {
PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) { PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) {
string prefix = FindField(strUrl, NULL, "://"); string prefix = FindField(strUrl, NULL, "://");
auto onDestory = [](PlayerBase *ptr){
EventPoller::Instance().async([ptr](){
delete ptr;
});
};
if (strcasecmp("rtsp",prefix.data()) == 0) { if (strcasecmp("rtsp",prefix.data()) == 0) {
return PlayerBase::Ptr(new RtspPlayerImp()); return PlayerBase::Ptr(new RtspPlayerImp(),onDestory);
} }
if (strcasecmp("rtmp",prefix.data()) == 0) { 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 */ } /* namespace Player */