ZLMediaKit/api/include/mk_events.h

194 lines
8.0 KiB
C++
Raw Normal View History

2019-12-23 18:50:46 +08:00
/*
2023-12-09 16:23:51 +08:00
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
2019-12-23 18:50:46 +08:00
*
2023-12-09 16:23:51 +08:00
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
2019-12-23 18:50:46 +08:00
*
2023-12-09 16:23:51 +08:00
* Use of this source code is governed by MIT-like license that can be found in the
2020-04-04 20:30:09 +08:00
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
2019-12-23 18:50:46 +08:00
*/
2019-12-24 13:56:53 +08:00
#ifndef MK_EVENTS_H
#define MK_EVENTS_H
2019-12-23 18:50:46 +08:00
#include "mk_common.h"
#include "mk_events_objects.h"
2019-12-24 16:02:41 +08:00
2019-12-23 18:50:46 +08:00
#ifdef __cplusplus
extern "C" {
#endif
2019-12-24 16:02:41 +08:00
typedef struct {
2019-12-23 18:50:46 +08:00
/**
* MediaSource事件广播
* @param regist 10
* @param sender MediaSource对象
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_media_changed)(int regist,
const mk_media_source sender);
2019-12-23 18:50:46 +08:00
/**
* rtsp/rtmp推流事件广播
* @see mk_publish_auth_invoker_do
* @param url_info url相关信息
* @param invoker invoker返回鉴权结果
* @param sender tcp客户端相关信息
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_media_publish)(const mk_media_info url_info,
const mk_publish_auth_invoker invoker,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* rtsp/rtmp/http-flv/hls事件广播
* @see mk_auth_invoker_do
* @param url_info url相关信息
* @param invoker invoker返回鉴权结果
* @param sender
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_media_play)(const mk_media_info url_info,
const mk_auth_invoker invoker,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* 广
* @param url_info url相关信息
* @param sender
* @return 1
* 0
2019-12-23 18:50:46 +08:00
*/
int (API_CALL *on_mk_media_not_found)(const mk_media_info url_info,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
*
* @param sender MediaSource对象
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_media_no_reader)(const mk_media_source sender);
2019-12-23 18:50:46 +08:00
/**
* http api请求广播(GET/POST)
* @param parser http请求内容对象
* @param invoker invoker返回http回复
* @param consumed 1
* @param sender http客户端相关信息
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_http_request)(const mk_parser parser,
const mk_http_response_invoker invoker,
int *consumed,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* http文件服务器中,http访问文件或目录的广播,访http目录的权限
* @param parser http请求内容对象
* @param path
* @param is_dir path是否为文件夹
* @param invoker invoker返回本次访问文件的结果
* @param sender http客户端相关信息
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_http_access)(const mk_parser parser,
const char *path,
int is_dir,
const mk_http_access_path_invoker invoker,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* http文件服务器中,http访问文件或目录前的广播,http url到文件路径的映射
* path参数app选择不同http根目录的目的
* @param parser http请求内容对象
* @param path ,
* @param sender http客户端相关信息
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_http_before_access)(const mk_parser parser,
char *path,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* rtsp流是否需要认证invoker并传入realm,realm
* @param url_info rtsp url相关信息
* @param invoker invoker返回是否需要rtsp专属认证
* @param sender rtsp客户端相关信息
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_rtsp_get_realm)(const mk_media_info url_info,
const mk_rtsp_get_realm_invoker invoker,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* 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客户端信息
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_rtsp_auth)(const mk_media_info url_info,
const char *realm,
const char *user_name,
int must_no_encrypt,
const mk_rtsp_auth_invoker invoker,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* mp4分片文件成功后广播
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_record_mp4)(const mk_mp4_info mp4);
2019-12-23 18:50:46 +08:00
/**
* shell登录鉴权
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_shell_login)(const char *user_name,
const char *passwd,
const mk_auth_invoker invoker,
const mk_sock_info sender);
2019-12-23 18:50:46 +08:00
/**
* rtsp/rtmp/http-flv会话后流量汇报事件广播
* @param url_info url相关信息
* @param total_bytes
* @param total_seconds tcp会话时长
* @param is_player
*/
2019-12-24 16:02:41 +08:00
void (API_CALL *on_mk_flow_report)(const mk_media_info url_info,
size_t total_bytes,
size_t total_seconds,
int is_player,
2020-04-23 22:04:59 +08:00
const mk_sock_info sender);
/**
* 广
* @param level
* @param file
* @param line
2021-08-30 20:43:03 +08:00
* @param function
* @param message
*/
2021-08-30 20:43:03 +08:00
void (API_CALL *on_mk_log)(int level, const char *file, int line, const char *function, const char *message);
/**
* rtp流失败回调mk_media_source_start_send_rtp/mk_media_start_send_rtp接口触发的rtp发送
* @param vhost
* @param app
* @param stream id
* @param ssrc ssrc的10进制打印atoi转换为整型
* @param err
* @param msg
*/
void(API_CALL *on_mk_media_send_rtp_stop)(const char *vhost, const char *app, const char *stream, const char *ssrc, int err, const char *msg);
2019-12-23 18:50:46 +08:00
} mk_events;
2019-12-24 13:56:53 +08:00
/**
* ZLMediaKit里面的事件
* @param events ,null以便取消监听
*/
API_EXPORT void API_CALL mk_events_listen(const mk_events *events);
2019-12-23 18:50:46 +08:00
#ifdef __cplusplus
}
#endif
2019-12-24 13:56:53 +08:00
#endif //MK_EVENTS_H