mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-03 08:57:32 +08:00
大幅优化性能
This commit is contained in:
@@ -56,6 +56,13 @@ void MediaPlayer::play(const char* strUrl) {
|
||||
m_parser->play(strUrl);
|
||||
}
|
||||
|
||||
TaskExecutor::Ptr MediaPlayer::getExecutor(){
|
||||
auto parser = dynamic_pointer_cast<SocketHelper>(m_parser);
|
||||
if(!parser){
|
||||
return nullptr;
|
||||
}
|
||||
return parser->getExecutor();
|
||||
}
|
||||
|
||||
void MediaPlayer::pause(bool bPause) {
|
||||
if (m_parser) {
|
||||
|
||||
@@ -33,10 +33,12 @@
|
||||
#include "PlayerBase.h"
|
||||
#include "Rtsp/RtspPlayer.h"
|
||||
#include "Rtmp/RtmpPlayer.h"
|
||||
#include "Thread/TaskExecutor.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZL::Rtsp;
|
||||
using namespace ZL::Rtmp;
|
||||
using namespace ZL::Thread;
|
||||
|
||||
namespace ZL {
|
||||
namespace Player {
|
||||
@@ -50,6 +52,7 @@ public:
|
||||
void play(const char* strUrl) override;
|
||||
void pause(bool bPause) override;
|
||||
void teardown() override;
|
||||
TaskExecutor::Ptr getExecutor();
|
||||
private:
|
||||
string m_strPrefix;
|
||||
|
||||
|
||||
@@ -46,18 +46,13 @@ const char PlayerBase::kRtspPwdIsMD5[] = "rtsp_pwd_md5";
|
||||
|
||||
PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) {
|
||||
string prefix = FindField(strUrl, NULL, "://");
|
||||
auto onDestory = [](PlayerBase *ptr){
|
||||
ASYNC_TRACE([ptr](){
|
||||
delete ptr;
|
||||
});
|
||||
};
|
||||
if (strcasecmp("rtsp",prefix.data()) == 0) {
|
||||
return PlayerBase::Ptr(new RtspPlayerImp(),onDestory);
|
||||
return PlayerBase::Ptr(new RtspPlayerImp());
|
||||
}
|
||||
if (strcasecmp("rtmp",prefix.data()) == 0) {
|
||||
return PlayerBase::Ptr(new RtmpPlayerImp(),onDestory);
|
||||
return PlayerBase::Ptr(new RtmpPlayerImp());
|
||||
}
|
||||
return PlayerBase::Ptr(new RtspPlayerImp(),onDestory);
|
||||
return PlayerBase::Ptr(new RtspPlayerImp());
|
||||
}
|
||||
|
||||
} /* namespace Player */
|
||||
|
||||
Reference in New Issue
Block a user