mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-29 14:45:55 +08:00
151 lines
6.5 KiB
C++
151 lines
6.5 KiB
C++
|
/*
|
|||
|
* MIT License
|
|||
|
*
|
|||
|
* Copyright (c) 2019 xiongziliang <771730766@qq.com>
|
|||
|
*
|
|||
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
|||
|
*
|
|||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
* in the Software without restriction, including without limitation the rights
|
|||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
* furnished to do so, subject to the following conditions:
|
|||
|
*
|
|||
|
* The above copyright notice and this permission notice shall be included in all
|
|||
|
* copies or substantial portions of the Software.
|
|||
|
*
|
|||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
* SOFTWARE.
|
|||
|
*/
|
|||
|
|
|||
|
#ifndef MK_EVENT_H
|
|||
|
#define MK_EVENT_H
|
|||
|
|
|||
|
#include "common.h"
|
|||
|
#include "event_objects.h"
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
|
|||
|
typedef struct{
|
|||
|
/**
|
|||
|
* 注册或反注册MediaSource事件广播
|
|||
|
* @param regist 注册为1,注销为0
|
|||
|
* @param sender 该MediaSource对象
|
|||
|
*/
|
|||
|
typedef void (*on_mk_media_changed)(int regist,mk_media_source sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 收到rtsp/rtmp推流事件广播,通过该事件控制推流鉴权
|
|||
|
* @see mk_publish_auth_invoker_do
|
|||
|
* @param url_info 推流url相关信息
|
|||
|
* @param invoker 执行invoker返回鉴权结果
|
|||
|
* @param sender 该tcp客户端相关信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_media_publish)(mk_media_info url_info,mk_publish_auth_invoker invoker,mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 播放rtsp/rtmp/http-flv/hls事件广播,通过该事件控制播放鉴权
|
|||
|
* @see mk_auth_invoker_do
|
|||
|
* @param url_info 播放url相关信息
|
|||
|
* @param invoker 执行invoker返回鉴权结果
|
|||
|
* @param sender 播放客户端相关信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_media_play)(mk_media_info url_info,mk_auth_invoker invoker,mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 未找到流后会广播该事件,请在监听该事件后去拉流或其他方式产生流,这样就能按需拉流了
|
|||
|
* @param url_info 播放url相关信息
|
|||
|
* @param sender 播放客户端相关信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_media_not_found)(mk_media_info url_info,mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 某个流无人消费时触发,目的为了实现无人观看时主动断开拉流等业务逻辑
|
|||
|
* @param sender 该MediaSource对象
|
|||
|
*/
|
|||
|
typedef void (*on_mk_media_no_reader)(mk_media_source sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 收到http api请求广播(包括GET/POST)
|
|||
|
* @param parser http请求内容对象
|
|||
|
* @param invoker 执行该invoker返回http回复
|
|||
|
* @param consumed 置1则说明我们要处理该事件
|
|||
|
* @param sender http客户端相关信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_http_request)(mk_parser parser, mk_http_response_invoker invoker, int *consumed,mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 在http文件服务器中,收到http访问文件或目录的广播,通过该事件控制访问http目录的权限
|
|||
|
* @param parser http请求内容对象
|
|||
|
* @param url_info 请求url相关信息
|
|||
|
* @param path 文件绝对路径
|
|||
|
* @param is_dir path是否为文件夹
|
|||
|
* @param invoker 执行invoker返回本次访问文件的结果
|
|||
|
* @param sender http客户端相关信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_http_access)(mk_parser parser, mk_media_info url_info, const char *path,int is_dir, mk_http_access_path_invoker invoker,mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 在http文件服务器中,收到http访问文件或目录前的广播,通过该事件可以控制http url到文件路径的映射
|
|||
|
* 在该事件中通过自行覆盖path参数,可以做到譬如根据虚拟主机或者app选择不同http根目录的目的
|
|||
|
* @param parser http请求内容对象
|
|||
|
* @param url_info 请求url相关信息
|
|||
|
* @param path 文件绝对路径,覆盖之可以重定向到其他文件
|
|||
|
* @param sender http客户端相关信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_http_before_access)(mk_parser parser, mk_media_info url_info,char *path, mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 该rtsp流是否需要认证?是的话调用invoker并传入realm,否则传入空的realm
|
|||
|
* @param url_info 请求rtsp url相关信息
|
|||
|
* @param invoker 执行invoker返回是否需要rtsp专属认证
|
|||
|
* @param sender rtsp客户端相关信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_rtsp_get_realm)(mk_media_info url_info, mk_rtsp_get_realm_invoker invoker, mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 请求认证用户密码事件,user_name为用户名,must_no_encrypt如果为true,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
|
|||
|
* 获取到密码后请调用invoker并输入对应类型的密码和密码类型,invoker执行时会匹配密码
|
|||
|
* @param url_info 请求rtsp url相关信息
|
|||
|
* @param realm rtsp认证realm
|
|||
|
* @param user_name rtsp认证用户名
|
|||
|
* @param must_no_encrypt 如果为true,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
|
|||
|
* @param invoker 执行invoker返回rtsp专属认证的密码
|
|||
|
* @param sender rtsp客户端信息
|
|||
|
*/
|
|||
|
typedef void (*on_mk_rtsp_auth)(mk_media_info url_info,const char *realm,const char *user_name, int must_no_encrypt, mk_rtsp_auth_invoker invoker, mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 录制mp4分片文件成功后广播
|
|||
|
*/
|
|||
|
typedef void (*on_mk_record_mp4)(mk_mp4_info mp4);
|
|||
|
|
|||
|
/**
|
|||
|
* shell登录鉴权
|
|||
|
*/
|
|||
|
typedef void (*on_mk_shell_login_mp4)(const char *user_name, const char *passwd,mk_auth_invoker invoker,mk_tcp_session sender);
|
|||
|
|
|||
|
/**
|
|||
|
* 停止rtsp/rtmp/http-flv会话后流量汇报事件广播
|
|||
|
* @param url_info 播放url相关信息
|
|||
|
* @param total_bytes 耗费上下行总流量,单位字节数
|
|||
|
* @param total_seconds 本次tcp会话时长,单位秒
|
|||
|
* @param is_player 客户端是否为播放器
|
|||
|
*/
|
|||
|
typedef void (*on_mk_flow_report)(mk_media_info url_info,uint64_t total_bytes,uint64_t total_seconds,int is_player,mk_tcp_session sender);
|
|||
|
} mk_events;
|
|||
|
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
#endif //MK_EVENT_H
|
|||
|
|