Commit 13bbb7b0 by xiongziliang

修复播放器析构时调用虚函数的bug

parent 84129aef
......@@ -36,7 +36,6 @@ MediaPlayer::MediaPlayer() {
}
MediaPlayer::~MediaPlayer() {
teardown();
}
void MediaPlayer::play(const char* strUrl) {
string strPrefix = FindField(strUrl, NULL, "://");
......
......@@ -41,14 +41,20 @@ const char PlayerBase::kRtspPwdIsMD5[] = "rtsp_pwd_md5";
PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) {
static auto releasePlayer = [](PlayerBase *ptr){
onceToken token(nullptr,[&](){
delete ptr;
});
ptr->teardown();
};
string prefix = FindField(strUrl, NULL, "://");
if (strcasecmp("rtsp",prefix.data()) == 0) {
return PlayerBase::Ptr(new RtspPlayerImp());
return PlayerBase::Ptr(new RtspPlayerImp(),releasePlayer);
}
if (strcasecmp("rtmp",prefix.data()) == 0) {
return PlayerBase::Ptr(new RtmpPlayerImp());
return PlayerBase::Ptr(new RtmpPlayerImp(),releasePlayer);
}
return PlayerBase::Ptr(new RtspPlayerImp());
return PlayerBase::Ptr(new RtspPlayerImp(),releasePlayer);
}
///////////////////////////Demuxer//////////////////////////////
......
......@@ -46,7 +46,6 @@ RtmpPlayer::RtmpPlayer() {
}
RtmpPlayer::~RtmpPlayer() {
teardown();
DebugL << endl;
}
void RtmpPlayer::teardown() {
......
......@@ -45,7 +45,6 @@ public:
RtmpPlayerImp(){};
virtual ~RtmpPlayerImp(){
DebugL<<endl;
teardown();
};
float getProgress() const override{
if(getDuration() > 0){
......
......@@ -55,7 +55,6 @@ RtspPlayer::RtspPlayer(void){
_pktPool.setSize(64);
}
RtspPlayer::~RtspPlayer(void) {
RtspPlayer::teardown();
DebugL<<endl;
}
void RtspPlayer::teardown(){
......
......@@ -47,7 +47,6 @@ public:
RtspPlayerImp(){};
virtual ~RtspPlayerImp(){
DebugL<<endl;
teardown();
};
float getProgress() const override{
if(getDuration() > 0){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论