推流鉴权事件支持是否允许转rtsp/rtmp、hls 、mp4

This commit is contained in:
xiongziliang
2019-09-10 11:06:31 +08:00
parent 15539bc27e
commit e67894a085
10 changed files with 92 additions and 38 deletions

View File

@@ -256,7 +256,7 @@ void RtspSession::handleReq_RECORD(const Parser &parser){
send_SessionNotFound();
throw SockException(Err_shutdown,_aTrackInfo.empty() ? "can not find any availabe track when record" : "session not found when record");
}
auto onRes = [this](const string &err){
auto onRes = [this](const string &err,bool enableRtxp,bool enableHls,bool enableMP4){
bool authSuccess = err.empty();
if(!authSuccess){
sendRtspResponse("401 Unauthorized", {"Content-Type", "text/plain"}, err);
@@ -264,6 +264,9 @@ void RtspSession::handleReq_RECORD(const Parser &parser){
return;
}
//设置转协议
_pushSrc->setProtocolTranslation(enableRtxp,enableHls,enableMP4);
_StrPrinter rtp_info;
for(auto &track : _aTrackInfo){
if (track->_inited == false) {
@@ -284,17 +287,17 @@ void RtspSession::handleReq_RECORD(const Parser &parser){
};
weak_ptr<RtspSession> weakSelf = dynamic_pointer_cast<RtspSession>(shared_from_this());
Broadcast::AuthInvoker invoker = [weakSelf,onRes](const string &err){
Broadcast::PublishAuthInvoker invoker = [weakSelf,onRes](const string &err,bool enableRtxp,bool enableHls,bool enableMP4){
auto strongSelf = weakSelf.lock();
if(!strongSelf){
return;
}
strongSelf->async([weakSelf,onRes,err](){
strongSelf->async([weakSelf,onRes,err,enableRtxp,enableHls,enableMP4](){
auto strongSelf = weakSelf.lock();
if(!strongSelf){
return;
}
onRes(err);
onRes(err,enableRtxp,enableHls,enableMP4);
});
};
@@ -302,7 +305,7 @@ void RtspSession::handleReq_RECORD(const Parser &parser){
auto flag = NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaPublish,_mediaInfo,invoker,*this);
if(!flag){
//该事件无人监听,默认不鉴权
onRes("");
onRes("",true,true,false);
}
}