2017-04-01 16:35:56 +08:00
|
|
|
/*
|
|
|
|
* PlayerBase.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2016年12月1日
|
|
|
|
* Author: xzl
|
|
|
|
*/
|
|
|
|
|
2017-04-25 11:35:41 +08:00
|
|
|
#include <algorithm>
|
2017-04-01 16:35:56 +08:00
|
|
|
#include "PlayerBase.h"
|
|
|
|
#include "Rtsp/Rtsp.h"
|
2017-04-25 11:35:41 +08:00
|
|
|
#include "Rtsp/RtspPlayerImp.h"
|
|
|
|
#include "Rtmp/RtmpPlayerImp.h"
|
2017-04-01 16:35:56 +08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ZL::Rtmp;
|
|
|
|
using namespace ZL::Rtsp;
|
|
|
|
|
|
|
|
namespace ZL {
|
|
|
|
namespace Player {
|
|
|
|
|
|
|
|
|
|
|
|
PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) {
|
|
|
|
string prefix = FindField(strUrl, NULL, "://");
|
2017-05-12 16:10:30 +08:00
|
|
|
auto onDestory = [](PlayerBase *ptr){
|
|
|
|
EventPoller::Instance().async([ptr](){
|
|
|
|
delete ptr;
|
|
|
|
});
|
|
|
|
};
|
2017-04-01 16:35:56 +08:00
|
|
|
if (strcasecmp("rtsp",prefix.data()) == 0) {
|
2017-05-12 16:10:30 +08:00
|
|
|
return PlayerBase::Ptr(new RtspPlayerImp(),onDestory);
|
2017-04-01 16:35:56 +08:00
|
|
|
}
|
|
|
|
if (strcasecmp("rtmp",prefix.data()) == 0) {
|
2017-05-12 16:10:30 +08:00
|
|
|
return PlayerBase::Ptr(new RtmpPlayerImp(),onDestory);
|
2017-04-01 16:35:56 +08:00
|
|
|
}
|
2017-05-12 16:10:30 +08:00
|
|
|
return PlayerBase::Ptr(new RtspPlayerImp(),onDestory);
|
2017-04-01 16:35:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace Player */
|
|
|
|
} /* namespace ZL */
|