初步提交2.0版本,支持虚拟主机

This commit is contained in:
xiongziliang
2018-02-02 18:06:08 +08:00
parent 1262c4c51d
commit bd72a69d33
44 changed files with 354 additions and 730 deletions

View File

@@ -111,43 +111,6 @@ API_EXPORT int API_CALL initRtmpServer(unsigned short port) {
}
}
API_EXPORT void API_CALL listenEvent_onPlay(onEventPlay cb,void *userData){
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtspSessionPlay,
[cb,userData](BroadcastRtspSessionPlayArgs){
static unordered_map<string, void *> s_timerKeyMap;
static mutex s_mtx;
uint64_t tag;
{
lock_guard<mutex> lck(s_mtx);
//每个stream随机分配一个内存地址并且不重复
tag = (uint64_t)&s_timerKeyMap[stream];
}
string appTmp(app);
string streamTmp(stream);
AsyncTaskThread::Instance().CancelTask(tag);
int i = 2;
AsyncTaskThread::Instance().DoTaskDelay(tag,50,[cb,userData,appTmp,streamTmp,i](){
InfoL << "listenEvent_onPlay:" << appTmp << " " << streamTmp << " " << i;
cb(userData,appTmp.data(),streamTmp.data());
return (--const_cast<int &>(i)) > 0;
});
});
}
API_EXPORT void API_CALL listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData){
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtspSrcRegisted,
[cb,userData](BroadcastRtspSrcRegistedArgs){
cb(userData,app,stream);
});
}
API_EXPORT void API_CALL listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData){
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtmpSrcRegisted,
[cb,userData](BroadcastRtmpSrcRegistedArgs){
cb(userData,app,stream);
});
}
API_EXPORT void API_CALL log_printf(LogType level,const char* file, const char* function, int line,const char *fmt,...){
LogInfoMaker info((LogLevel)level,file,function,line);

View File

@@ -75,39 +75,6 @@ API_EXPORT int API_CALL initRtspServer(unsigned short port);
*/
API_EXPORT int API_CALL initRtmpServer(unsigned short port);
/*
* 描述:播放事件回调函数定义
* 参数:userData:用户数据指针strApp:应用名,strStream:流名称
*/
typedef void (API_CALL *onEventPlay)(void *userData,const char *strApp,const char *strStream);
/*
* 描述:监听事件
* 参数:cb:回调函数指针,userData:用户数据指针
* 返回值:无
*/
API_EXPORT void API_CALL listenEvent_onPlay(onEventPlay cb,void *userData);
/*
* 描述:注册RTSP事件
* 参数:userData:用户数据指针strApp:应用名,strStream:流名称
*/
typedef void (API_CALL *onEventRegistMediaSrc)(void *userData,const char *strApp,const char *strStream);
/*
* 描述:监听事件
* 参数:cb:回调函数指针,userData:用户数据指针
* 返回值:无
*/
API_EXPORT void API_CALL listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData);
/*
* 描述:监听事件
* 参数:cb:回调函数指针,userData:用户数据指针
* 返回值:无
*/
API_EXPORT void API_CALL listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData);
/////////////////////////日志////////////////////////////////

View File

@@ -50,7 +50,7 @@ static onceToken s_token([](){
//////////////////////////Rtsp media///////////////////////////
API_EXPORT MediaContext API_CALL createMedia(const char *appName,const char *mediaName) {
DevChannel::Ptr ret(new DevChannel(appName,mediaName));
DevChannel::Ptr ret(new DevChannel(DEFAULT_VHOST,appName,mediaName));
lock_guard<recursive_mutex> lck(s_mtxMapMedia);
s_mapMedia.emplace((void *) (ret.get()), ret);
return ret.get();

View File

@@ -43,7 +43,7 @@ static onceToken s_token([](){
},nullptr);
API_EXPORT ProxyPlayerContext API_CALL createProxyPlayer(const char *app,const char *stream,int rtp_type){
PlayerProxy::Ptr ret(new PlayerProxy(app,stream));
PlayerProxy::Ptr ret(new PlayerProxy(DEFAULT_VHOST,app,stream));
(*ret)[RtspPlayer::kRtpType] = rtp_type;
lock_guard<recursive_mutex> lck(s_mtxMapProxyPlayer);