ZLMediaKit/api/include/mk_event.h

151 lines
6.5 KiB
C++
Raw Normal View History

2019-12-23 18:50:46 +08:00
/*
* 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 10
* @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