mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-23 09:22:21 +08:00
转协议选项抽象为ProtocolOption对象
This commit is contained in:
@@ -219,7 +219,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
|
||||
throw SockException(Err_shutdown, StrPrinter << err << ":" << full_url);
|
||||
}
|
||||
|
||||
auto onRes = [this, parser, full_url](const string &err, bool enableHls, bool enableMP4) {
|
||||
auto onRes = [this, parser, full_url](const string &err, const ProtocolOption &option) {
|
||||
if (!err.empty()) {
|
||||
sendRtspResponse("401 Unauthorized", { "Content-Type", "text/plain" }, err);
|
||||
shutdown(SockException(Err_shutdown, StrPrinter << "401 Unauthorized:" << err));
|
||||
@@ -275,7 +275,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
|
||||
_push_src = std::make_shared<RtspMediaSourceImp>(_media_info._vhost, _media_info._app, _media_info._streamid);
|
||||
//获取所有权
|
||||
_push_src_ownership = _push_src->getOwnership();
|
||||
_push_src->setProtocolTranslation(enableHls, enableMP4);
|
||||
_push_src->setProtocolOption(option);
|
||||
_push_src->setSdp(parser.Content());
|
||||
}
|
||||
|
||||
@@ -284,17 +284,17 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
|
||||
};
|
||||
|
||||
weak_ptr<RtspSession> weakSelf = dynamic_pointer_cast<RtspSession>(shared_from_this());
|
||||
Broadcast::PublishAuthInvoker invoker = [weakSelf, onRes](const string &err, bool enableHls, bool enableMP4) {
|
||||
Broadcast::PublishAuthInvoker invoker = [weakSelf, onRes](const string &err, const ProtocolOption &option) {
|
||||
auto strongSelf = weakSelf.lock();
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
strongSelf->async([weakSelf, onRes, err, enableHls, enableMP4]() {
|
||||
strongSelf->async([weakSelf, onRes, err, option]() {
|
||||
auto strongSelf = weakSelf.lock();
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
onRes(err, enableHls, enableMP4);
|
||||
onRes(err, option);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -302,9 +302,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
|
||||
auto flag = NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaPublish, MediaOriginType::rtsp_push, _media_info, invoker, static_cast<SockInfo &>(*this));
|
||||
if (!flag) {
|
||||
//该事件无人监听,默认不鉴权
|
||||
GET_CONFIG(bool, toHls, General::kPublishToHls);
|
||||
GET_CONFIG(bool, toMP4, General::kPublishToMP4);
|
||||
onRes("", toHls, toMP4);
|
||||
onRes("", ProtocolOption());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user