mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-21 01:13:37 +08:00
修复播放器析构时调用虚函数的bug
This commit is contained in:
parent
84129aefdf
commit
13bbb7b057
@ -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){
|
||||
|
Loading…
Reference in New Issue
Block a user