add MediaTuple

This commit is contained in:
Johnny
2023-05-25 16:23:24 +08:00
committed by 夏楚
parent f4ee607feb
commit 0232caf068
41 changed files with 242 additions and 273 deletions

View File

@@ -90,8 +90,8 @@ void initEventListener() {
static onceToken s_token([]() {
//监听kBroadcastOnGetRtspRealm事件决定rtsp链接是否需要鉴权(传统的rtsp鉴权方案)才能访问
NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastOnGetRtspRealm, [](BroadcastOnGetRtspRealmArgs) {
DebugL << "RTSP是否需要鉴权事件" << args.getUrl() << " " << args._param_strs;
if (string("1") == args._streamid) {
DebugL << "RTSP是否需要鉴权事件" << args.getUrl() << " " << args.param_strs;
if (string("1") == args.stream) {
// live/1需要认证
//该流需要认证并且设置realm
invoker(REALM);
@@ -104,7 +104,7 @@ void initEventListener() {
//监听kBroadcastOnRtspAuth事件返回正确的rtsp鉴权用户密码
NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastOnRtspAuth, [](BroadcastOnRtspAuthArgs) {
DebugL << "RTSP播放鉴权:" << args.getUrl() << " " << args._param_strs;
DebugL << "RTSP播放鉴权:" << args.getUrl() << " " << args.param_strs;
DebugL << "RTSP用户" << user_name << (must_no_encrypt ? " Base64" : " MD5") << " 方式登录";
string user = user_name;
//假设我们异步读取数据库
@@ -134,14 +134,14 @@ void initEventListener() {
//监听rtsp/rtmp推流事件返回结果告知是否有推流权限
NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastMediaPublish, [](BroadcastMediaPublishArgs) {
DebugL << "推流鉴权:" << args.getUrl() << " " << args._param_strs;
DebugL << "推流鉴权:" << args.getUrl() << " " << args.param_strs;
invoker("", ProtocolOption());//鉴权成功
//invoker("this is auth failed message");//鉴权失败
});
//监听rtsp/rtsps/rtmp/http-flv播放事件返回结果告知是否有播放权限(rtsp通过kBroadcastOnRtspAuth或此事件都可以实现鉴权)
NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastMediaPlayed, [](BroadcastMediaPlayedArgs) {
DebugL << "播放鉴权:" << args.getUrl() << " " << args._param_strs;
DebugL << "播放鉴权:" << args.getUrl() << " " << args.param_strs;
invoker("");//鉴权成功
//invoker("this is auth failed message");//鉴权失败
});
@@ -182,14 +182,13 @@ void initEventListener() {
* 你可以在这个事件触发时再去拉流,这样就可以实现按需拉流
* 拉流成功后ZLMediaKit会把其立即转发给播放器(最大等待时间约为5秒如果5秒都未拉流成功播放器会播放失败)
*/
DebugL << "未找到流事件:" << args.getUrl() << " " << args._param_strs;
DebugL << "未找到流事件:" << args.getUrl() << " " << args.param_strs;
});
//监听播放或推流结束时消耗流量事件
NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastFlowReport, [](BroadcastFlowReportArgs) {
DebugL << "播放器(推流器)断开连接事件:" << args.getUrl() << " " << args._param_strs
<< "\r\n使用流量:" << totalBytes << " bytes,连接时长:" << totalDuration << "";
DebugL << "播放器(推流器)断开连接事件:" << args.getUrl() << " " << args.param_strs << "\r\n使用流量:" << totalBytes << " bytes,连接时长:" << totalDuration << "";
});