mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-04-04 12:40:55 +08:00
AI automatically translates all comments in the code into English (#3917)
This commit is contained in:
@@ -44,53 +44,76 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//输出日志到shell
|
||||
// 输出日志到shell [AUTO-TRANSLATED:6523242b]
|
||||
// cpp
|
||||
// Output log to shell
|
||||
#define LOG_CONSOLE (1 << 0)
|
||||
//输出日志到文件
|
||||
// 输出日志到文件 [AUTO-TRANSLATED:8ffaf1e0]
|
||||
// Output log to file
|
||||
#define LOG_FILE (1 << 1)
|
||||
//输出日志到回调函数(mk_events::on_mk_log)
|
||||
// 输出日志到回调函数(mk_events::on_mk_log) [AUTO-TRANSLATED:616561c1]
|
||||
// Output log to callback function (mk_events::on_mk_log)
|
||||
#define LOG_CALLBACK (1 << 2)
|
||||
|
||||
//向下兼容
|
||||
// 向下兼容 [AUTO-TRANSLATED:5b800712]
|
||||
// Downward compatibility
|
||||
#define mk_env_init1 mk_env_init2
|
||||
|
||||
//回调user_data回调函数
|
||||
// 回调user_data回调函数 [AUTO-TRANSLATED:ced626fb]
|
||||
// Callback user_data callback function
|
||||
typedef void(API_CALL *on_user_data_free)(void *user_data);
|
||||
|
||||
typedef struct {
|
||||
// 线程数
|
||||
// 线程数 [AUTO-TRANSLATED:f7fc7650]
|
||||
// Number of threads
|
||||
int thread_num;
|
||||
|
||||
// 日志级别,支持0~4
|
||||
// 日志级别,支持0~4 [AUTO-TRANSLATED:f4d77bb5]
|
||||
// Log level, supports 0~4
|
||||
int log_level;
|
||||
//控制日志输出的掩模,请查看LOG_CONSOLE、LOG_FILE、LOG_CALLBACK等宏
|
||||
// 控制日志输出的掩模,请查看LOG_CONSOLE、LOG_FILE、LOG_CALLBACK等宏 [AUTO-TRANSLATED:71de1d10]
|
||||
// Control the mask of log output, please refer to LOG_CONSOLE, LOG_FILE, LOG_CALLBACK macros
|
||||
int log_mask;
|
||||
//文件日志保存路径,路径可以不存在(内部可以创建文件夹),设置为NULL关闭日志输出至文件
|
||||
// 文件日志保存路径,路径可以不存在(内部可以创建文件夹),设置为NULL关闭日志输出至文件 [AUTO-TRANSLATED:d0989d3c]
|
||||
// File log save path, the path can be non-existent (folders can be created internally), set to NULL to disable log output to file
|
||||
const char *log_file_path;
|
||||
//文件日志保存天数,设置为0关闭日志文件
|
||||
// 文件日志保存天数,设置为0关闭日志文件 [AUTO-TRANSLATED:04253cb0]
|
||||
// File log save days, set to 0 to disable log file
|
||||
int log_file_days;
|
||||
|
||||
// 配置文件是内容还是路径
|
||||
// 配置文件是内容还是路径 [AUTO-TRANSLATED:b946f030]
|
||||
// Is the configuration file content or path
|
||||
int ini_is_path;
|
||||
// 配置文件内容或路径,可以为NULL,如果该文件不存在,那么将导出默认配置至该文件
|
||||
// 配置文件内容或路径,可以为NULL,如果该文件不存在,那么将导出默认配置至该文件 [AUTO-TRANSLATED:aeaa4583]
|
||||
// Configuration file content or path, can be NULL, if the file does not exist, then the default configuration will be exported to the file
|
||||
const char *ini;
|
||||
|
||||
// ssl证书是内容还是路径
|
||||
// ssl证书是内容还是路径 [AUTO-TRANSLATED:820671ab]
|
||||
// Is the ssl certificate content or path
|
||||
int ssl_is_path;
|
||||
// ssl证书内容或路径,可以为NULL
|
||||
// ssl证书内容或路径,可以为NULL [AUTO-TRANSLATED:c32fffb6]
|
||||
// ssl certificate content or path, can be NULL
|
||||
const char *ssl;
|
||||
// 证书密码,可以为NULL
|
||||
// 证书密码,可以为NULL [AUTO-TRANSLATED:b8c9c173]
|
||||
// Certificate password, can be NULL
|
||||
const char *ssl_pwd;
|
||||
} mk_config;
|
||||
|
||||
/**
|
||||
* 初始化环境,调用该库前需要先调用此函数
|
||||
* @param cfg 库运行相关参数
|
||||
* Initialize the environment, you need to call this function before calling this library
|
||||
* @param cfg Library running related parameters
|
||||
|
||||
* [AUTO-TRANSLATED:58d6d220]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_env_init(const mk_config *cfg);
|
||||
|
||||
/**
|
||||
* 关闭所有服务器,请在main函数退出时调用
|
||||
* Close all servers, please call this function when exiting the main function
|
||||
|
||||
* [AUTO-TRANSLATED:f1148928]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_stop_all_server();
|
||||
|
||||
@@ -106,6 +129,19 @@ API_EXPORT void API_CALL mk_stop_all_server();
|
||||
* @param ssl_is_path ssl证书是内容还是路径
|
||||
* @param ssl ssl证书内容或路径,可以为NULL
|
||||
* @param ssl_pwd 证书密码,可以为NULL
|
||||
* mk_env_init version of basic type parameters, for easy calling by other languages
|
||||
* @param thread_num Number of threads
|
||||
* @param log_level Log level, supports 0~4
|
||||
* @param log_mask Log output mode mask, please refer to LOG_CONSOLE, LOG_FILE, LOG_CALLBACK macros
|
||||
* @param log_file_path File log save path, the path can be non-existent (folders can be created internally), set to NULL to disable log output to file
|
||||
* @param log_file_days File log save days, set to 0 to disable log file
|
||||
* @param ini_is_path Is the configuration file content or path
|
||||
* @param ini Configuration file content or path, can be NULL, if the file does not exist, then the default configuration will be exported to the file
|
||||
* @param ssl_is_path Is the ssl certificate content or path
|
||||
* @param ssl ssl certificate content or path, can be NULL
|
||||
* @param ssl_pwd Certificate password, can be NULL
|
||||
|
||||
* [AUTO-TRANSLATED:12901102]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_env_init2(int thread_num,
|
||||
int log_level,
|
||||
@@ -122,6 +158,11 @@ API_EXPORT void API_CALL mk_env_init2(int thread_num,
|
||||
* 设置日志文件
|
||||
* @param file_max_size 单个切片文件大小(MB)
|
||||
* @param file_max_count 切片文件个数
|
||||
* Set the log file
|
||||
* @param file_max_size Single slice file size (MB)
|
||||
* @param file_max_count Number of slice files
|
||||
|
||||
* [AUTO-TRANSLATED:59204140]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_set_log(int file_max_size, int file_max_count);
|
||||
|
||||
@@ -130,6 +171,12 @@ API_EXPORT void API_CALL mk_set_log(int file_max_size, int file_max_count);
|
||||
* @deprecated 请使用mk_ini_set_option替代
|
||||
* @param key 配置项名
|
||||
* @param val 配置项值
|
||||
* Set the configuration item
|
||||
* @deprecated Please use mk_ini_set_option instead
|
||||
* @param key Configuration item name
|
||||
* @param val Configuration item value
|
||||
|
||||
* [AUTO-TRANSLATED:93d02c07]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_set_option(const char *key, const char *val);
|
||||
|
||||
@@ -137,6 +184,11 @@ API_EXPORT void API_CALL mk_set_option(const char *key, const char *val);
|
||||
* 获取配置项的值
|
||||
* @deprecated 请使用mk_ini_get_option替代
|
||||
* @param key 配置项名
|
||||
* Get the value of the configuration item
|
||||
* @deprecated Please use mk_ini_get_option instead
|
||||
* @param key Configuration item name
|
||||
|
||||
* [AUTO-TRANSLATED:6222a231]
|
||||
*/
|
||||
API_EXPORT const char * API_CALL mk_get_option(const char *key);
|
||||
|
||||
@@ -146,6 +198,12 @@ API_EXPORT const char * API_CALL mk_get_option(const char *key);
|
||||
* @param port htt监听端口,推荐80,传入0则随机分配
|
||||
* @param ssl 是否为ssl类型服务器
|
||||
* @return 0:失败,非0:端口号
|
||||
* Create http[s] server
|
||||
* @param port htt listening port, recommended 80, pass in 0 to randomly allocate
|
||||
* @param ssl Whether it is an ssl type server
|
||||
* @return 0: failure, non-0: port number
|
||||
|
||||
* [AUTO-TRANSLATED:4ca78101]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_http_server_start(uint16_t port, int ssl);
|
||||
|
||||
@@ -154,6 +212,12 @@ API_EXPORT uint16_t API_CALL mk_http_server_start(uint16_t port, int ssl);
|
||||
* @param port rtsp监听端口,推荐554,传入0则随机分配
|
||||
* @param ssl 是否为ssl类型服务器
|
||||
* @return 0:失败,非0:端口号
|
||||
* Create rtsp[s] server
|
||||
* @param port rtsp listening port, recommended 554, pass in 0 to randomly allocate
|
||||
* @param ssl Whether it is an ssl type server
|
||||
* @return 0: failure, non-0: port number
|
||||
|
||||
* [AUTO-TRANSLATED:3d984d90]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_rtsp_server_start(uint16_t port, int ssl);
|
||||
|
||||
@@ -162,6 +226,12 @@ API_EXPORT uint16_t API_CALL mk_rtsp_server_start(uint16_t port, int ssl);
|
||||
* @param port rtmp监听端口,推荐1935,传入0则随机分配
|
||||
* @param ssl 是否为ssl类型服务器
|
||||
* @return 0:失败,非0:端口号
|
||||
* Create rtmp[s] server
|
||||
* @param port rtmp listening port, recommended 1935, pass in 0 to randomly allocate
|
||||
* @param ssl Whether it is an ssl type server
|
||||
* @return 0: failure, non-0: port number
|
||||
|
||||
* [AUTO-TRANSLATED:ed841271]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_rtmp_server_start(uint16_t port, int ssl);
|
||||
|
||||
@@ -169,6 +239,11 @@ API_EXPORT uint16_t API_CALL mk_rtmp_server_start(uint16_t port, int ssl);
|
||||
* 创建rtp服务器
|
||||
* @param port rtp监听端口(包括udp/tcp)
|
||||
* @return 0:失败,非0:端口号
|
||||
* Create rtp server
|
||||
* @param port rtp listening port (including udp/tcp)
|
||||
* @return 0: failure, non-0: port number
|
||||
|
||||
* [AUTO-TRANSLATED:f49af495]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_rtp_server_start(uint16_t port);
|
||||
|
||||
@@ -176,10 +251,16 @@ API_EXPORT uint16_t API_CALL mk_rtp_server_start(uint16_t port);
|
||||
* 创建rtc服务器
|
||||
* @param port rtc监听端口
|
||||
* @return 0:失败,非0:端口号
|
||||
* Create rtc server
|
||||
* @param port rtc listening port
|
||||
* @return 0: failure, non-0: port number
|
||||
|
||||
* [AUTO-TRANSLATED:df151854]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_rtc_server_start(uint16_t port);
|
||||
|
||||
//获取webrtc answer sdp回调函数
|
||||
// 获取webrtc answer sdp回调函数 [AUTO-TRANSLATED:10c93fa9]
|
||||
// Get webrtc answer sdp callback function
|
||||
typedef void(API_CALL *on_mk_webrtc_get_answer_sdp)(void *user_data, const char *answer, const char *err);
|
||||
|
||||
/**
|
||||
@@ -189,6 +270,14 @@ typedef void(API_CALL *on_mk_webrtc_get_answer_sdp)(void *user_data, const char
|
||||
* @param type webrtc插件类型,支持echo,play,push
|
||||
* @param offer webrtc offer sdp
|
||||
* @param url rtc url, 例如 rtc://__defaultVhost/app/stream?key1=val1&key2=val2
|
||||
* webrtc exchange sdp, generate answer sdp based on offer sdp
|
||||
* @param user_data Callback user pointer
|
||||
* @param cb Callback function
|
||||
* @param type webrtc plugin type, supports echo, play, push
|
||||
* @param offer webrtc offer sdp
|
||||
* @param url rtc url, for example rtc://__defaultVhost/app/stream?key1=val1&key2=val2
|
||||
|
||||
* [AUTO-TRANSLATED:ea79659b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_webrtc_get_answer_sdp(void *user_data, on_mk_webrtc_get_answer_sdp cb, const char *type,
|
||||
const char *offer, const char *url);
|
||||
@@ -200,6 +289,11 @@ API_EXPORT void API_CALL mk_webrtc_get_answer_sdp2(void *user_data, on_user_data
|
||||
* 创建srt服务器
|
||||
* @param port srt监听端口
|
||||
* @return 0:失败,非0:端口号
|
||||
* Create srt server
|
||||
* @param port srt listening port
|
||||
* @return 0: failure, non-0: port number
|
||||
|
||||
* [AUTO-TRANSLATED:250984c0]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_srt_server_start(uint16_t port);
|
||||
|
||||
@@ -208,6 +302,12 @@ API_EXPORT uint16_t API_CALL mk_srt_server_start(uint16_t port);
|
||||
* 创建shell服务器
|
||||
* @param port shell监听端口
|
||||
* @return 0:失败,非0:端口号
|
||||
* Create shell server
|
||||
* @param port shell listening port
|
||||
* @return 0: failure, non-0: port number
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:66ec9a2a]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_shell_server_start(uint16_t port);
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ typedef struct {
|
||||
* 注册或反注册MediaSource事件广播
|
||||
* @param regist 注册为1,注销为0
|
||||
* @param sender 该MediaSource对象
|
||||
* Register or unregister MediaSource event broadcast
|
||||
* @param regist Register as 1, unregister as 0
|
||||
* @param sender The MediaSource object
|
||||
|
||||
* [AUTO-TRANSLATED:d440a47c]
|
||||
*/
|
||||
void (API_CALL *on_mk_media_changed)(int regist,
|
||||
const mk_media_source sender);
|
||||
@@ -33,6 +38,13 @@ typedef struct {
|
||||
* @param url_info 推流url相关信息
|
||||
* @param invoker 执行invoker返回鉴权结果
|
||||
* @param sender 该tcp客户端相关信息
|
||||
* Receive rtsp/rtmp push stream event broadcast, control push stream authentication through this event
|
||||
* @see mk_publish_auth_invoker_do
|
||||
* @param url_info Push stream url related information
|
||||
* @param invoker Execute invoker to return authentication result
|
||||
* @param sender The tcp client related information
|
||||
|
||||
* [AUTO-TRANSLATED:2a607577]
|
||||
*/
|
||||
void (API_CALL *on_mk_media_publish)(const mk_media_info url_info,
|
||||
const mk_publish_auth_invoker invoker,
|
||||
@@ -44,6 +56,13 @@ typedef struct {
|
||||
* @param url_info 播放url相关信息
|
||||
* @param invoker 执行invoker返回鉴权结果
|
||||
* @param sender 播放客户端相关信息
|
||||
* Play rtsp/rtmp/http-flv/hls event broadcast, control playback authentication through this event
|
||||
* @see mk_auth_invoker_do
|
||||
* @param url_info Play url related information
|
||||
* @param invoker Execute invoker to return authentication result
|
||||
* @param sender Play client related information
|
||||
|
||||
* [AUTO-TRANSLATED:817c964d]
|
||||
*/
|
||||
void (API_CALL *on_mk_media_play)(const mk_media_info url_info,
|
||||
const mk_auth_invoker invoker,
|
||||
@@ -55,6 +74,13 @@ typedef struct {
|
||||
* @param sender 播放客户端相关信息
|
||||
* @return 1 直接关闭
|
||||
* 0 等待流注册
|
||||
* This event will be broadcast after the stream is not found. Please pull the stream or other methods to generate the stream after listening to this event, so that you can pull the stream on demand.
|
||||
* @param url_info Play url related information
|
||||
* @param sender Play client related information
|
||||
* @return 1 Close directly
|
||||
* 0 Wait for stream registration
|
||||
|
||||
* [AUTO-TRANSLATED:468e7356]
|
||||
*/
|
||||
int (API_CALL *on_mk_media_not_found)(const mk_media_info url_info,
|
||||
const mk_sock_info sender);
|
||||
@@ -62,6 +88,10 @@ typedef struct {
|
||||
/**
|
||||
* 某个流无人消费时触发,目的为了实现无人观看时主动断开拉流等业务逻辑
|
||||
* @param sender 该MediaSource对象
|
||||
* Triggered when a stream is not consumed by anyone, the purpose is to achieve business logic such as actively disconnecting the pull stream when no one is watching
|
||||
* @param sender The MediaSource object
|
||||
|
||||
* [AUTO-TRANSLATED:348078cb]
|
||||
*/
|
||||
void (API_CALL *on_mk_media_no_reader)(const mk_media_source sender);
|
||||
|
||||
@@ -71,6 +101,13 @@ typedef struct {
|
||||
* @param invoker 执行该invoker返回http回复
|
||||
* @param consumed 置1则说明我们要处理该事件
|
||||
* @param sender http客户端相关信息
|
||||
* Receive http api request broadcast (including GET/POST)
|
||||
* @param parser Http request content object
|
||||
* @param invoker Execute this invoker to return http reply
|
||||
* @param consumed Set to 1 if we want to handle this event
|
||||
* @param sender Http client related information
|
||||
|
||||
* [AUTO-TRANSLATED:eb15bc74]
|
||||
*/
|
||||
void (API_CALL *on_mk_http_request)(const mk_parser parser,
|
||||
const mk_http_response_invoker invoker,
|
||||
@@ -84,6 +121,14 @@ typedef struct {
|
||||
* @param is_dir path是否为文件夹
|
||||
* @param invoker 执行invoker返回本次访问文件的结果
|
||||
* @param sender http客户端相关信息
|
||||
* In the http file server, receive the broadcast of http access to files or directories, control the access permission of the http directory through this event
|
||||
* @param parser Http request content object
|
||||
* @param path File absolute path
|
||||
* @param is_dir Whether path is a folder
|
||||
* @param invoker Execute invoker to return the result of accessing the file this time
|
||||
* @param sender Http client related information
|
||||
|
||||
* [AUTO-TRANSLATED:c49b1702]
|
||||
*/
|
||||
void (API_CALL *on_mk_http_access)(const mk_parser parser,
|
||||
const char *path,
|
||||
@@ -97,6 +142,13 @@ typedef struct {
|
||||
* @param parser http请求内容对象
|
||||
* @param path 文件绝对路径,覆盖之可以重定向到其他文件
|
||||
* @param sender http客户端相关信息
|
||||
* In the http file server, receive the broadcast before http access to files or directories, you can control the mapping of http url to file path through this event
|
||||
* By overriding the path parameter in this event, you can achieve the purpose of selecting different http root directories according to virtual hosts or apps
|
||||
* @param parser Http request content object
|
||||
* @param path File absolute path, overriding it can redirect to other files
|
||||
* @param sender Http client related information
|
||||
|
||||
* [AUTO-TRANSLATED:8b167279]
|
||||
*/
|
||||
void (API_CALL *on_mk_http_before_access)(const mk_parser parser,
|
||||
char *path,
|
||||
@@ -107,6 +159,12 @@ typedef struct {
|
||||
* @param url_info 请求rtsp url相关信息
|
||||
* @param invoker 执行invoker返回是否需要rtsp专属认证
|
||||
* @param sender rtsp客户端相关信息
|
||||
* Does this rtsp stream need authentication? If so, call invoker and pass in realm, otherwise pass in empty realm
|
||||
* @param url_info Request rtsp url related information
|
||||
* @param invoker Execute invoker to return whether rtsp exclusive authentication is required
|
||||
* @param sender Rtsp client related information
|
||||
|
||||
* [AUTO-TRANSLATED:9bd81de9]
|
||||
*/
|
||||
void (API_CALL *on_mk_rtsp_get_realm)(const mk_media_info url_info,
|
||||
const mk_rtsp_get_realm_invoker invoker,
|
||||
@@ -121,6 +179,16 @@ typedef struct {
|
||||
* @param must_no_encrypt 如果为true,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
|
||||
* @param invoker 执行invoker返回rtsp专属认证的密码
|
||||
* @param sender rtsp客户端信息
|
||||
* Request authentication user password event, user_name is the username, must_no_encrypt if true, then you must provide plain text password (because it is base64 authentication method at this time), otherwise it will lead to authentication failure
|
||||
* After getting the password, please call invoker and input the corresponding type of password and password type, invoker will match the password when executing
|
||||
* @param url_info Request rtsp url related information
|
||||
* @param realm Rtsp authentication realm
|
||||
* @param user_name Rtsp authentication username
|
||||
* @param must_no_encrypt If true, then you must provide plain text password (because it is base64 authentication method at this time), otherwise it will lead to authentication failure
|
||||
* @param invoker Execute invoker to return the password of rtsp exclusive authentication
|
||||
* @param sender Rtsp client information
|
||||
|
||||
* [AUTO-TRANSLATED:833da340]
|
||||
*/
|
||||
void (API_CALL *on_mk_rtsp_auth)(const mk_media_info url_info,
|
||||
const char *realm,
|
||||
@@ -131,16 +199,25 @@ typedef struct {
|
||||
|
||||
/**
|
||||
* 录制mp4分片文件成功后广播
|
||||
* Broadcast after recording mp4 fragment file successfully
|
||||
|
||||
* [AUTO-TRANSLATED:eef1d414]
|
||||
*/
|
||||
void (API_CALL *on_mk_record_mp4)(const mk_record_info mp4);
|
||||
|
||||
/**
|
||||
* 录制ts分片文件成功后广播
|
||||
* Broadcast after recording ts fragment file successfully
|
||||
|
||||
* [AUTO-TRANSLATED:b91dc9fa]
|
||||
*/
|
||||
void (API_CALL *on_mk_record_ts)(const mk_record_info ts);
|
||||
|
||||
/**
|
||||
* shell登录鉴权
|
||||
* Shell login authentication
|
||||
|
||||
* [AUTO-TRANSLATED:95784c94]
|
||||
*/
|
||||
void (API_CALL *on_mk_shell_login)(const char *user_name,
|
||||
const char *passwd,
|
||||
@@ -153,6 +230,13 @@ typedef struct {
|
||||
* @param total_bytes 耗费上下行总流量,单位字节数
|
||||
* @param total_seconds 本次tcp会话时长,单位秒
|
||||
* @param is_player 客户端是否为播放器
|
||||
* Stop rtsp/rtmp/http-flv session after traffic reporting event broadcast
|
||||
* @param url_info Play url related information
|
||||
* @param total_bytes Total traffic consumed up and down, unit bytes
|
||||
* @param total_seconds The duration of this tcp session, unit seconds
|
||||
* @param is_player Whether the client is a player
|
||||
|
||||
* [AUTO-TRANSLATED:d81d1fc3]
|
||||
*/
|
||||
void (API_CALL *on_mk_flow_report)(const mk_media_info url_info,
|
||||
size_t total_bytes,
|
||||
@@ -168,6 +252,14 @@ typedef struct {
|
||||
* @param line 源文件行
|
||||
* @param function 源文件函数名
|
||||
* @param message 日志内容
|
||||
* Log output broadcast
|
||||
* @param level Log level
|
||||
* @param file Source file name
|
||||
* @param line Source file line
|
||||
* @param function Source file function name
|
||||
* @param message Log content
|
||||
|
||||
* [AUTO-TRANSLATED:5aa5cb8f]
|
||||
*/
|
||||
void (API_CALL *on_mk_log)(int level, const char *file, int line, const char *function, const char *message);
|
||||
|
||||
@@ -179,12 +271,25 @@ typedef struct {
|
||||
* @param ssrc ssrc的10进制打印,通过atoi转换为整型
|
||||
* @param err 错误代码
|
||||
* @param msg 错误提示
|
||||
* Send rtp stream failure callback, applicable to rtp sending triggered by mk_media_source_start_send_rtp/mk_media_start_send_rtp interface
|
||||
* @param vhost Virtual host
|
||||
* @param app Application name
|
||||
* @param stream Stream id
|
||||
* @param ssrc Ssrc's decimal print, convert to integer through atoi
|
||||
* @param err Error code
|
||||
* @param msg Error message
|
||||
|
||||
* [AUTO-TRANSLATED:c956e89b]
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* rtc sctp连接中/完成/失败/关闭回调
|
||||
* @param rtc_transport 数据通道对象
|
||||
* Rtc sctp connection in/complete/failure/close callback
|
||||
* @param rtc_transport Data channel object
|
||||
|
||||
* [AUTO-TRANSLATED:5455fb76]
|
||||
*/
|
||||
void (API_CALL *on_mk_rtc_sctp_connecting)(mk_rtc_transport rtc_transport);
|
||||
void (API_CALL *on_mk_rtc_sctp_connected)(mk_rtc_transport rtc_transport);
|
||||
@@ -196,6 +301,12 @@ typedef struct {
|
||||
* @param rtc_transport 数据通道对象
|
||||
* @param msg 数据
|
||||
* @param len 数据长度
|
||||
* Rtc data channel send data callback
|
||||
* @param rtc_transport Data channel object
|
||||
* @param msg Data
|
||||
* @param len Data length
|
||||
|
||||
* [AUTO-TRANSLATED:42f75e55]
|
||||
*/
|
||||
void (API_CALL *on_mk_rtc_sctp_send)(mk_rtc_transport rtc_transport, const uint8_t *msg, size_t len);
|
||||
|
||||
@@ -206,6 +317,14 @@ typedef struct {
|
||||
* @param ppid 协议id
|
||||
* @param msg 数据
|
||||
* @param len 数据长度
|
||||
* Rtc data channel receive data callback
|
||||
* @param rtc_transport Data channel object
|
||||
* @param streamId Stream id
|
||||
* @param ppid Protocol id
|
||||
* @param msg Data
|
||||
* @param len Data length
|
||||
|
||||
* [AUTO-TRANSLATED:3abda838]
|
||||
*/
|
||||
void (API_CALL *on_mk_rtc_sctp_received)(mk_rtc_transport rtc_transport, uint16_t streamId, uint32_t ppid, const uint8_t *msg, size_t len);
|
||||
|
||||
@@ -215,6 +334,10 @@ typedef struct {
|
||||
/**
|
||||
* 监听ZLMediaKit里面的事件
|
||||
* @param events 各个事件的结构体,这个对象在内部会再拷贝一次,可以设置为null以便取消监听
|
||||
* Listen to events in ZLMediaKit
|
||||
* @param events The structure of each event, this object will be copied again internally, it can be set to null to cancel listening
|
||||
|
||||
* [AUTO-TRANSLATED:d3418bc6]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_events_listen(const mk_events *events);
|
||||
|
||||
|
||||
@@ -19,30 +19,42 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////RecordInfo/////////////////////////////////////////////
|
||||
//RecordInfo对象的C映射
|
||||
// RecordInfo对象的C映射 [AUTO-TRANSLATED:2c7825a6]
|
||||
// RecordInfo object's C mapping
|
||||
typedef struct mk_record_info_t *mk_record_info;
|
||||
// GMT 标准时间,单位秒
|
||||
// GMT 标准时间,单位秒 [AUTO-TRANSLATED:3b827274]
|
||||
// GMT standard time, unit is seconds
|
||||
API_EXPORT uint64_t API_CALL mk_record_info_get_start_time(const mk_record_info ctx);
|
||||
// 录像长度,单位秒
|
||||
// 录像长度,单位秒 [AUTO-TRANSLATED:1dceac0c]
|
||||
// Recording length, unit is seconds
|
||||
API_EXPORT float API_CALL mk_record_info_get_time_len(const mk_record_info ctx);
|
||||
// 文件大小,单位 BYTE
|
||||
// 文件大小,单位 BYTE [AUTO-TRANSLATED:add20c50]
|
||||
// File size, unit is BYTE
|
||||
API_EXPORT size_t API_CALL mk_record_info_get_file_size(const mk_record_info ctx);
|
||||
// 文件路径
|
||||
// 文件路径 [AUTO-TRANSLATED:c5246c5d]
|
||||
// File path
|
||||
API_EXPORT const char *API_CALL mk_record_info_get_file_path(const mk_record_info ctx);
|
||||
// 文件名称
|
||||
// 文件名称 [AUTO-TRANSLATED:b5d7c753]
|
||||
// File name
|
||||
API_EXPORT const char *API_CALL mk_record_info_get_file_name(const mk_record_info ctx);
|
||||
// 文件夹路径
|
||||
// 文件夹路径 [AUTO-TRANSLATED:0e5c9d26]
|
||||
// Folder path
|
||||
API_EXPORT const char *API_CALL mk_record_info_get_folder(const mk_record_info ctx);
|
||||
// 播放路径
|
||||
// 播放路径 [AUTO-TRANSLATED:9b5c99f8]
|
||||
// Playback path
|
||||
API_EXPORT const char *API_CALL mk_record_info_get_url(const mk_record_info ctx);
|
||||
// 应用名称
|
||||
// 应用名称 [AUTO-TRANSLATED:2aa47ea2]
|
||||
// Application name
|
||||
API_EXPORT const char *API_CALL mk_record_info_get_vhost(const mk_record_info ctx);
|
||||
// 流 ID
|
||||
// 流 ID [AUTO-TRANSLATED:4bbe1cbe]
|
||||
// Stream ID
|
||||
API_EXPORT const char *API_CALL mk_record_info_get_app(const mk_record_info ctx);
|
||||
// 虚拟主机
|
||||
// 虚拟主机 [AUTO-TRANSLATED:aaae9cfe]
|
||||
// Virtual host
|
||||
API_EXPORT const char *API_CALL mk_record_info_get_stream(const mk_record_info ctx);
|
||||
|
||||
//// 下面宏保障用户代码兼容性, 二进制abi不兼容,用户需要重新编译链接 /////
|
||||
// // 下面宏保障用户代码兼容性, 二进制abi不兼容,用户需要重新编译链接 ///// [AUTO-TRANSLATED:e532a596]
|
||||
// // The following macros ensure user code compatibility, binary abi is incompatible, users need to recompile and link /////
|
||||
#define mk_mp4_info mk_record_info
|
||||
#define mk_mp4_info_get_start_time mk_record_info_get_start_time
|
||||
#define mk_mp4_info_get_time_len mk_record_info_get_time_len
|
||||
@@ -56,29 +68,40 @@ API_EXPORT const char *API_CALL mk_record_info_get_stream(const mk_record_info c
|
||||
#define mk_mp4_info_get_stream mk_record_info_get_stream
|
||||
|
||||
///////////////////////////////////////////Parser/////////////////////////////////////////////
|
||||
//Parser对象的C映射
|
||||
// Parser对象的C映射 [AUTO-TRANSLATED:6ceb91d6]
|
||||
// Parser object's C mapping
|
||||
typedef struct mk_parser_t *mk_parser;
|
||||
//Parser对象中Headers foreach回调
|
||||
// Parser对象中Headers foreach回调 [AUTO-TRANSLATED:4e0a6646]
|
||||
// Parser object's Headers foreach callback
|
||||
typedef void(API_CALL *on_mk_parser_header_cb)(void *user_data, const char *key, const char *val);
|
||||
//Parser::Method(),获取命令字,譬如GET/POST
|
||||
// Parser::Method(),获取命令字,譬如GET/POST [AUTO-TRANSLATED:904ebe57]
|
||||
// Parser::Method(), get the command word, such as GET/POST
|
||||
API_EXPORT const char* API_CALL mk_parser_get_method(const mk_parser ctx);
|
||||
//Parser::Url(),获取HTTP的访问url(不包括?后面的参数)
|
||||
// Parser::Url(),获取HTTP的访问url(不包括?后面的参数) [AUTO-TRANSLATED:75f320c5]
|
||||
// Parser::Url(), get the HTTP access url (excluding the parameters after ?)
|
||||
API_EXPORT const char* API_CALL mk_parser_get_url(const mk_parser ctx);
|
||||
//Parser::Params(),?后面的参数字符串
|
||||
// Parser::Params(),?后面的参数字符串 [AUTO-TRANSLATED:3745fec0]
|
||||
// Parser::Params(), the parameter string after ?
|
||||
API_EXPORT const char* API_CALL mk_parser_get_url_params(const mk_parser ctx);
|
||||
//Parser::getUrlArgs()["key"],获取?后面的参数中的特定参数
|
||||
// Parser::getUrlArgs()["key"],获取?后面的参数中的特定参数 [AUTO-TRANSLATED:425e4b61]
|
||||
// Parser::getUrlArgs()["key"], get the specific parameter in the parameters after ?
|
||||
API_EXPORT const char* API_CALL mk_parser_get_url_param(const mk_parser ctx,const char *key);
|
||||
//Parser::Tail(),获取协议相关信息,譬如 HTTP/1.1
|
||||
// Parser::Tail(),获取协议相关信息,譬如 HTTP/1.1 [AUTO-TRANSLATED:786534b6]
|
||||
// Parser::Tail(), get protocol related information, such as HTTP/1.1
|
||||
API_EXPORT const char* API_CALL mk_parser_get_tail(const mk_parser ctx);
|
||||
//Parser::getValues()["key"],获取HTTP头中特定字段
|
||||
// Parser::getValues()["key"],获取HTTP头中特定字段 [AUTO-TRANSLATED:1c210637]
|
||||
// Parser::getValues()["key"], get the specific field in the HTTP header
|
||||
API_EXPORT const char* API_CALL mk_parser_get_header(const mk_parser ctx,const char *key);
|
||||
//Parser::Content(),获取HTTP body
|
||||
// Parser::Content(),获取HTTP body [AUTO-TRANSLATED:fb05b253]
|
||||
// Parser::Content(), get the HTTP body
|
||||
API_EXPORT const char* API_CALL mk_parser_get_content(const mk_parser ctx, size_t *length);
|
||||
//循环获取所有header
|
||||
// 循环获取所有header [AUTO-TRANSLATED:9fd7571a]
|
||||
// Loop to get all headers
|
||||
API_EXPORT void API_CALL mk_parser_headers_for_each(const mk_parser ctx, on_mk_parser_header_cb cb, void *user_data);
|
||||
|
||||
///////////////////////////////////////////MediaInfo/////////////////////////////////////////////
|
||||
//MediaInfo对象的C映射
|
||||
// MediaInfo对象的C映射 [AUTO-TRANSLATED:f9649086]
|
||||
// MediaInfo object's C mapping
|
||||
typedef struct mk_media_info_t *mk_media_info;
|
||||
//MediaInfo::param_strs
|
||||
API_EXPORT const char* API_CALL mk_media_info_get_params(const mk_media_info ctx);
|
||||
@@ -97,9 +120,11 @@ API_EXPORT uint16_t API_CALL mk_media_info_get_port(const mk_media_info ctx);
|
||||
|
||||
|
||||
///////////////////////////////////////////MediaSource/////////////////////////////////////////////
|
||||
//MediaSource对象的C映射
|
||||
// MediaSource对象的C映射 [AUTO-TRANSLATED:feb50a09]
|
||||
// MediaSource object's C mapping
|
||||
typedef struct mk_media_source_t *mk_media_source;
|
||||
//查找MediaSource的回调函数
|
||||
// 查找MediaSource的回调函数 [AUTO-TRANSLATED:e8b54cf9]
|
||||
// Callback function to find MediaSource
|
||||
typedef void(API_CALL *on_mk_media_source_find_cb)(void *user_data, const mk_media_source ctx);
|
||||
|
||||
//MediaSource::getSchema()
|
||||
@@ -126,7 +151,8 @@ API_EXPORT int API_CALL mk_media_source_broadcast_msg(const mk_media_source ctx,
|
||||
API_EXPORT const char* API_CALL mk_media_source_get_origin_url(const mk_media_source ctx);
|
||||
// MediaSource::getOriginType()
|
||||
API_EXPORT int API_CALL mk_media_source_get_origin_type(const mk_media_source ctx);
|
||||
// MediaSource::getOriginTypeStr(), 使用后请用mk_free释放返回值
|
||||
// MediaSource::getOriginTypeStr(), 使用后请用mk_free释放返回值 [AUTO-TRANSLATED:d612ec22]
|
||||
// MediaSource::getOriginTypeStr(), please use mk_free to release the return value after use
|
||||
API_EXPORT const char *API_CALL mk_media_source_get_origin_type_str(const mk_media_source ctx);
|
||||
// MediaSource::getCreateStamp()
|
||||
API_EXPORT uint64_t API_CALL mk_media_source_get_create_stamp(const mk_media_source ctx);
|
||||
@@ -149,6 +175,20 @@ API_EXPORT uint64_t API_CALL mk_media_source_get_alive_second(const mk_media_sou
|
||||
* @param ctx 对象
|
||||
* @param force 是否强制关闭,如果强制关闭,在有人观看的情况下也会关闭
|
||||
* @return 0代表失败,1代表成功
|
||||
* Live sources are called MediaSource in ZLMediaKit,
|
||||
* Currently, there are 3 types, namely RtmpMediaSource, RtspMediaSource, HlsMediaSource
|
||||
* The source is generated in both passive and active ways:
|
||||
* Passive ways are rtsp/rtmp/rtp push stream, mp4 on-demand
|
||||
* Active ways include objects created by mk_media_create (DevChannel), objects created by mk_proxy_player_create (PlayerProxy)
|
||||
* You don't need to do anything for passive ways, ZLMediaKit has already adapted the MediaSource::close() event by default, which will close the live stream
|
||||
* For active ways, you need to set the callback of this event, you need to choose to delete the object yourself
|
||||
* You can set the callback through the mk_proxy_player_set_on_close and mk_media_set_on_close functions,
|
||||
* Please delete the object in the callback to complete the media closure, otherwise why call the mk_media_source_close function?
|
||||
* @param ctx object
|
||||
* @param force Whether to force closure, if forced closure, it will be closed even if someone is watching
|
||||
* @return 0 means failure, 1 means success
|
||||
|
||||
* [AUTO-TRANSLATED:9415a405]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force);
|
||||
//MediaSource::seekTo()
|
||||
@@ -156,15 +196,20 @@ API_EXPORT int API_CALL mk_media_source_seek_to(const mk_media_source ctx,uint32
|
||||
|
||||
/**
|
||||
* rtp推流成功与否的回调(第一次成功后,后面将一直重试)
|
||||
* Callback for whether rtp push stream is successful or not (after the first success, it will keep retrying)
|
||||
|
||||
* [AUTO-TRANSLATED:7e00f7fb]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_media_source_send_rtp_result)(void *user_data, uint16_t local_port, int err, const char *msg);
|
||||
|
||||
// MediaSource::startSendRtp,请参考mk_media_start_send_rtp,注意ctx参数类型不一样
|
||||
// MediaSource::startSendRtp,请参考mk_media_start_send_rtp,注意ctx参数类型不一样 [AUTO-TRANSLATED:515ab2e3]
|
||||
// MediaSource::startSendRtp, please refer to mk_media_start_send_rtp, note that the ctx parameter type is different
|
||||
API_EXPORT void API_CALL mk_media_source_start_send_rtp(const mk_media_source ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int con_type, on_mk_media_source_send_rtp_result cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_source_start_send_rtp2(const mk_media_source ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int con_type, on_mk_media_source_send_rtp_result cb, void *user_data, on_user_data_free user_data_free);
|
||||
API_EXPORT void API_CALL mk_media_source_start_send_rtp3(const mk_media_source ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int con_type, mk_ini options, on_mk_media_source_send_rtp_result cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_source_start_send_rtp4(const mk_media_source ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int con_type, mk_ini options, on_mk_media_source_send_rtp_result cb,void *user_data, on_user_data_free user_data_free);
|
||||
//MediaSource::stopSendRtp,请参考mk_media_stop_send_rtp,注意ctx参数类型不一样
|
||||
// MediaSource::stopSendRtp,请参考mk_media_stop_send_rtp,注意ctx参数类型不一样 [AUTO-TRANSLATED:415fe454]
|
||||
// MediaSource::stopSendRtp, please refer to mk_media_stop_send_rtp, note that the ctx parameter type is different
|
||||
API_EXPORT int API_CALL mk_media_source_stop_send_rtp(const mk_media_source ctx);
|
||||
|
||||
//MediaSource::find()
|
||||
@@ -186,18 +231,29 @@ API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_s
|
||||
const char *vhost, const char *app, const char *stream);
|
||||
|
||||
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
||||
// HttpBody对象的C映射 [AUTO-TRANSLATED:d8025ad9]
|
||||
// cpp
|
||||
//HttpBody对象的C映射
|
||||
typedef struct mk_http_body_t *mk_http_body;
|
||||
/**
|
||||
* 生成HttpStringBody
|
||||
* @param str 字符串指针
|
||||
* @param len 字符串长度,为0则用strlen获取
|
||||
* Generate HttpStringBody
|
||||
* @param str String pointer
|
||||
* @param len String length, if it is 0, use strlen to get it
|
||||
|
||||
* [AUTO-TRANSLATED:7f828392]
|
||||
*/
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str,size_t len);
|
||||
|
||||
/**
|
||||
* 生成HttpBufferBody
|
||||
* @param buffer mk_buffer对象
|
||||
* Generate HttpBufferBody
|
||||
* @param buffer mk_buffer object
|
||||
|
||||
* [AUTO-TRANSLATED:2d31a2e4]
|
||||
*/
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_buffer(mk_buffer buffer);
|
||||
|
||||
@@ -205,6 +261,10 @@ API_EXPORT mk_http_body API_CALL mk_http_body_from_buffer(mk_buffer buffer);
|
||||
/**
|
||||
* 生成HttpFileBody
|
||||
* @param file_path 文件完整路径
|
||||
* Generate HttpFileBody
|
||||
* @param file_path File full path
|
||||
|
||||
* [AUTO-TRANSLATED:4823ab7f]
|
||||
*/
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_file(const char *file_path);
|
||||
|
||||
@@ -212,16 +272,25 @@ API_EXPORT mk_http_body API_CALL mk_http_body_from_file(const char *file_path);
|
||||
* 生成HttpMultiFormBody
|
||||
* @param key_val 参数key-value
|
||||
* @param file_path 文件完整路径
|
||||
* Generate HttpMultiFormBody
|
||||
* @param key_val Parameter key-value
|
||||
* @param file_path File full path
|
||||
|
||||
* [AUTO-TRANSLATED:17976911]
|
||||
*/
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_multi_form(const char *key_val[],const char *file_path);
|
||||
|
||||
/**
|
||||
* 销毁HttpBody
|
||||
* Destroy HttpBody
|
||||
|
||||
* [AUTO-TRANSLATED:a1169b76]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_body_release(mk_http_body ctx);
|
||||
|
||||
///////////////////////////////////////////HttpResponseInvoker/////////////////////////////////////////////
|
||||
//HttpSession::HttpResponseInvoker对象的C映射
|
||||
// HttpSession::HttpResponseInvoker对象的C映射 [AUTO-TRANSLATED:89287e03]
|
||||
// HttpSession::HttpResponseInvoker对象的C映射
|
||||
typedef struct mk_http_response_invoker_t *mk_http_response_invoker;
|
||||
|
||||
/**
|
||||
@@ -229,6 +298,12 @@ typedef struct mk_http_response_invoker_t *mk_http_response_invoker;
|
||||
* @param response_code 譬如200
|
||||
* @param response_header 返回的http头,譬如 {"Content-Type","text/html",NULL} 必须以NULL结尾
|
||||
* @param response_body body对象
|
||||
* HttpSession::HttpResponseInvoker(const string &codeOut, const StrCaseMap &headerOut, const HttpBody::Ptr &body);
|
||||
* @param response_code For example 200
|
||||
* @param response_header The returned http header, for example {"Content-Type","text/html",NULL} must end with NULL
|
||||
* @param response_body Body object
|
||||
|
||||
* [AUTO-TRANSLATED:e006685a]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_response_invoker_do(const mk_http_response_invoker ctx,
|
||||
int response_code,
|
||||
@@ -240,6 +315,12 @@ API_EXPORT void API_CALL mk_http_response_invoker_do(const mk_http_response_invo
|
||||
* @param response_code 譬如200
|
||||
* @param response_header 返回的http头,譬如 {"Content-Type","text/html",NULL} 必须以NULL结尾
|
||||
* @param response_content 返回的content部分,譬如一个网页内容
|
||||
* HttpSession::HttpResponseInvoker(const string &codeOut, const StrCaseMap &headerOut, const string &body);
|
||||
* @param response_code For example 200
|
||||
* @param response_header The returned http header, for example {"Content-Type","text/html",NULL} must end with NULL
|
||||
* @param response_content The returned content part, for example a web page content
|
||||
|
||||
* [AUTO-TRANSLATED:0c3cf577]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_response_invoker_do_string(const mk_http_response_invoker ctx,
|
||||
int response_code,
|
||||
@@ -250,6 +331,12 @@ API_EXPORT void API_CALL mk_http_response_invoker_do_string(const mk_http_respon
|
||||
* @param request_parser 请求事件中的mk_parser对象,用于提取其中http头中的Range字段,通过该字段先fseek然后再发送文件部分片段
|
||||
* @param response_header 返回的http头,譬如 {"Content-Type","text/html",NULL} 必须以NULL结尾
|
||||
* @param response_file_path 返回的content部分,譬如/path/to/html/file
|
||||
* HttpSession::HttpResponseInvoker(const StrCaseMap &requestHeader,const StrCaseMap &responseHeader,const string &filePath);
|
||||
* @param request_parser The mk_parser object in the request event, used to extract the Range field in the http header, use this field to fseek first and then send the file part fragment
|
||||
* @param response_header The returned http header, for example {"Content-Type","text/html",NULL} must end with NULL
|
||||
* @param response_file_path The returned content part, for example /path/to/html/file
|
||||
|
||||
* [AUTO-TRANSLATED:8ed9ed9e]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_response_invoker_do_file(const mk_http_response_invoker ctx,
|
||||
const mk_parser request_parser,
|
||||
@@ -258,16 +345,24 @@ API_EXPORT void API_CALL mk_http_response_invoker_do_file(const mk_http_response
|
||||
/**
|
||||
* 克隆mk_http_response_invoker对象,通过克隆对象为堆对象,可以实现跨线程异步执行mk_http_response_invoker_do
|
||||
* 如果是同步执行mk_http_response_invoker_do,那么没必要克隆对象
|
||||
* Clone the mk_http_response_invoker object, by cloning the object to a heap object, you can achieve cross-thread asynchronous execution of mk_http_response_invoker_do
|
||||
* If you execute mk_http_response_invoker_do synchronously, then there is no need to clone the object
|
||||
|
||||
* [AUTO-TRANSLATED:54c98395]
|
||||
*/
|
||||
API_EXPORT mk_http_response_invoker API_CALL mk_http_response_invoker_clone(const mk_http_response_invoker ctx);
|
||||
|
||||
/**
|
||||
* 销毁堆上的克隆对象
|
||||
* Destroy the cloned object on the heap
|
||||
|
||||
* [AUTO-TRANSLATED:16c6a29b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_response_invoker_clone_release(const mk_http_response_invoker ctx);
|
||||
|
||||
///////////////////////////////////////////HttpAccessPathInvoker/////////////////////////////////////////////
|
||||
//HttpSession::HttpAccessPathInvoker对象的C映射
|
||||
// HttpSession::HttpAccessPathInvoker对象的C映射 [AUTO-TRANSLATED:beb105f4]
|
||||
// HttpSession::HttpAccessPathInvoker对象的C映射
|
||||
typedef struct mk_http_access_path_invoker_t *mk_http_access_path_invoker;
|
||||
|
||||
/**
|
||||
@@ -275,6 +370,12 @@ typedef struct mk_http_access_path_invoker_t *mk_http_access_path_invoker;
|
||||
* @param err_msg 如果为空,则代表鉴权通过,否则为错误提示,可以为null
|
||||
* @param access_path 运行或禁止访问的根目录,可以为null
|
||||
* @param cookie_life_second 鉴权cookie有效期
|
||||
* HttpSession::HttpAccessPathInvoker(const string &errMsg,const string &accessPath, int cookieLifeSecond);
|
||||
* @param err_msg If it is empty, it means that the authentication is passed, otherwise it is an error prompt, it can be null
|
||||
* @param access_path The root directory to run or prohibit access, it can be null
|
||||
* @param cookie_life_second Authentication cookie validity period
|
||||
*
|
||||
* [AUTO-TRANSLATED:105c76c4]
|
||||
**/
|
||||
API_EXPORT void API_CALL mk_http_access_path_invoker_do(const mk_http_access_path_invoker ctx,
|
||||
const char *err_msg,
|
||||
@@ -284,20 +385,32 @@ API_EXPORT void API_CALL mk_http_access_path_invoker_do(const mk_http_access_pat
|
||||
/**
|
||||
* 克隆mk_http_access_path_invoker对象,通过克隆对象为堆对象,可以实现跨线程异步执行mk_http_access_path_invoker_do
|
||||
* 如果是同步执行mk_http_access_path_invoker_do,那么没必要克隆对象
|
||||
* Clone the mk_http_access_path_invoker object, by cloning the object to a heap object, you can achieve cross-thread asynchronous execution of mk_http_access_path_invoker_do
|
||||
* If you execute mk_http_access_path_invoker_do synchronously, then there is no need to clone the object
|
||||
|
||||
* [AUTO-TRANSLATED:ad2a71e4]
|
||||
*/
|
||||
API_EXPORT mk_http_access_path_invoker API_CALL mk_http_access_path_invoker_clone(const mk_http_access_path_invoker ctx);
|
||||
|
||||
/**
|
||||
* 销毁堆上的克隆对象
|
||||
* Destroy the cloned object on the heap
|
||||
|
||||
* [AUTO-TRANSLATED:16c6a29b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_access_path_invoker_clone_release(const mk_http_access_path_invoker ctx);
|
||||
|
||||
///////////////////////////////////////////RtspSession::onGetRealm/////////////////////////////////////////////
|
||||
//RtspSession::onGetRealm对象的C映射
|
||||
// RtspSession::onGetRealm对象的C映射 [AUTO-TRANSLATED:2355d645]
|
||||
// RtspSession::onGetRealm对象的C映射
|
||||
typedef struct mk_rtsp_get_realm_invoker_t *mk_rtsp_get_realm_invoker;
|
||||
/**
|
||||
* 执行RtspSession::onGetRealm
|
||||
* @param realm 该rtsp流是否需要开启rtsp专属鉴权,至null或空字符串则不鉴权
|
||||
* Execute RtspSession::onGetRealm
|
||||
* @param realm Whether this rtsp stream needs to enable rtsp exclusive authentication, to null or empty string does not authenticate
|
||||
|
||||
* [AUTO-TRANSLATED:ed88a88b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtsp_get_realm_invoker_do(const mk_rtsp_get_realm_invoker ctx,
|
||||
const char *realm);
|
||||
@@ -305,22 +418,35 @@ API_EXPORT void API_CALL mk_rtsp_get_realm_invoker_do(const mk_rtsp_get_realm_in
|
||||
/**
|
||||
* 克隆mk_rtsp_get_realm_invoker对象,通过克隆对象为堆对象,可以实现跨线程异步执行mk_rtsp_get_realm_invoker_do
|
||||
* 如果是同步执行mk_rtsp_get_realm_invoker_do,那么没必要克隆对象
|
||||
* Clone the mk_rtsp_get_realm_invoker object, by cloning the object to a heap object, you can achieve cross-thread asynchronous execution of mk_rtsp_get_realm_invoker_do
|
||||
* If you execute mk_rtsp_get_realm_invoker_do synchronously, then there is no need to clone the object
|
||||
|
||||
* [AUTO-TRANSLATED:15fa6e77]
|
||||
*/
|
||||
API_EXPORT mk_rtsp_get_realm_invoker API_CALL mk_rtsp_get_realm_invoker_clone(const mk_rtsp_get_realm_invoker ctx);
|
||||
|
||||
/**
|
||||
* 销毁堆上的克隆对象
|
||||
* Destroy the cloned object on the heap
|
||||
|
||||
* [AUTO-TRANSLATED:16c6a29b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtsp_get_realm_invoker_clone_release(const mk_rtsp_get_realm_invoker ctx);
|
||||
|
||||
///////////////////////////////////////////RtspSession::onAuth/////////////////////////////////////////////
|
||||
//RtspSession::onAuth对象的C映射
|
||||
// RtspSession::onAuth对象的C映射 [AUTO-TRANSLATED:f3a1ebb7]
|
||||
// RtspSession::onAuth对象的C映射
|
||||
typedef struct mk_rtsp_auth_invoker_t *mk_rtsp_auth_invoker;
|
||||
|
||||
/**
|
||||
* 执行RtspSession::onAuth
|
||||
* @param encrypted 为true是则表明是md5加密的密码,否则是明文密码, 在请求明文密码时如果提供md5密码者则会导致认证失败
|
||||
* @param pwd_or_md5 明文密码或者md5加密的密码
|
||||
* Execute RtspSession::onAuth
|
||||
* @param encrypted If true, it means that the password is md5 encrypted, otherwise it is plain text password, if you provide md5 password when requesting plain text password, it will cause authentication failure
|
||||
* @param pwd_or_md5 Plain text password or md5 encrypted password
|
||||
|
||||
* [AUTO-TRANSLATED:f7152252]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtsp_auth_invoker_do(const mk_rtsp_auth_invoker ctx,
|
||||
int encrypted,
|
||||
@@ -329,16 +455,24 @@ API_EXPORT void API_CALL mk_rtsp_auth_invoker_do(const mk_rtsp_auth_invoker ctx,
|
||||
/**
|
||||
* 克隆mk_rtsp_auth_invoker对象,通过克隆对象为堆对象,可以实现跨线程异步执行mk_rtsp_auth_invoker_do
|
||||
* 如果是同步执行mk_rtsp_auth_invoker_do,那么没必要克隆对象
|
||||
* Clone the mk_rtsp_auth_invoker object, by cloning the object to a heap object, you can achieve cross-thread asynchronous execution of mk_rtsp_auth_invoker_do
|
||||
* If you execute mk_rtsp_auth_invoker_do synchronously, then there is no need to clone the object
|
||||
|
||||
* [AUTO-TRANSLATED:505859bd]
|
||||
*/
|
||||
API_EXPORT mk_rtsp_auth_invoker API_CALL mk_rtsp_auth_invoker_clone(const mk_rtsp_auth_invoker ctx);
|
||||
|
||||
/**
|
||||
* 销毁堆上的克隆对象
|
||||
* Destroy the cloned object on the heap
|
||||
|
||||
* [AUTO-TRANSLATED:16c6a29b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtsp_auth_invoker_clone_release(const mk_rtsp_auth_invoker ctx);
|
||||
|
||||
///////////////////////////////////////////Broadcast::PublishAuthInvoker/////////////////////////////////////////////
|
||||
//Broadcast::PublishAuthInvoker对象的C映射
|
||||
// Broadcast::PublishAuthInvoker对象的C映射 [AUTO-TRANSLATED:0eb37ee6]
|
||||
// Broadcast::PublishAuthInvoker对象的C映射
|
||||
typedef struct mk_publish_auth_invoker_t *mk_publish_auth_invoker;
|
||||
|
||||
/**
|
||||
@@ -346,6 +480,12 @@ typedef struct mk_publish_auth_invoker_t *mk_publish_auth_invoker;
|
||||
* @param err_msg 为空或null则代表鉴权成功
|
||||
* @param enable_hls 是否允许转换hls
|
||||
* @param enable_mp4 是否运行MP4录制
|
||||
* Execute Broadcast::PublishAuthInvoker
|
||||
* @param err_msg Empty or null means authentication success
|
||||
* @param enable_hls Whether to allow hls conversion
|
||||
* @param enable_mp4 Whether to allow MP4 recording
|
||||
|
||||
* [AUTO-TRANSLATED:ee8fb2b4]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_publish_auth_invoker_do(const mk_publish_auth_invoker ctx,
|
||||
const char *err_msg,
|
||||
@@ -357,37 +497,58 @@ API_EXPORT void API_CALL mk_publish_auth_invoker_do2(const mk_publish_auth_invok
|
||||
/**
|
||||
* 克隆mk_publish_auth_invoker对象,通过克隆对象为堆对象,可以实现跨线程异步执行mk_publish_auth_invoker_do
|
||||
* 如果是同步执行mk_publish_auth_invoker_do,那么没必要克隆对象
|
||||
* Clone the mk_publish_auth_invoker object, by cloning the object to a heap object, you can achieve cross-thread asynchronous execution of mk_publish_auth_invoker_do
|
||||
* If you execute mk_publish_auth_invoker_do synchronously, then there is no need to clone the object
|
||||
|
||||
* [AUTO-TRANSLATED:03357111]
|
||||
*/
|
||||
API_EXPORT mk_publish_auth_invoker API_CALL mk_publish_auth_invoker_clone(const mk_publish_auth_invoker ctx);
|
||||
|
||||
/**
|
||||
* 销毁堆上的克隆对象
|
||||
* Destroy the cloned object on the heap
|
||||
|
||||
* [AUTO-TRANSLATED:16c6a29b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_publish_auth_invoker_clone_release(const mk_publish_auth_invoker ctx);
|
||||
|
||||
///////////////////////////////////////////Broadcast::AuthInvoker/////////////////////////////////////////////
|
||||
//Broadcast::AuthInvoker对象的C映射
|
||||
// Broadcast::AuthInvoker对象的C映射 [AUTO-TRANSLATED:08f4186e]
|
||||
// Broadcast::AuthInvoker对象的C映射
|
||||
typedef struct mk_auth_invoker_t *mk_auth_invoker;
|
||||
|
||||
/**
|
||||
* 执行Broadcast::AuthInvoker
|
||||
* @param err_msg 为空或null则代表鉴权成功
|
||||
* Execute Broadcast::AuthInvoker
|
||||
* @param err_msg Empty or null means authentication success
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:7215fd9a]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_auth_invoker_do(const mk_auth_invoker ctx, const char *err_msg);
|
||||
|
||||
/**
|
||||
* 克隆mk_auth_invoker对象,通过克隆对象为堆对象,可以实现跨线程异步执行mk_auth_invoker_do
|
||||
* 如果是同步执行mk_auth_invoker_do,那么没必要克隆对象
|
||||
* Clone the mk_auth_invoker object. By cloning the object to a heap object, we can achieve asynchronous execution of mk_auth_invoker_do across threads.
|
||||
* If mk_auth_invoker_do is executed synchronously, there is no need to clone the object.
|
||||
|
||||
* [AUTO-TRANSLATED:2430560d]
|
||||
*/
|
||||
API_EXPORT mk_auth_invoker API_CALL mk_auth_invoker_clone(const mk_auth_invoker ctx);
|
||||
|
||||
/**
|
||||
* 销毁堆上的克隆对象
|
||||
* Destroy the cloned object on the heap.
|
||||
|
||||
* [AUTO-TRANSLATED:16c6a29b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_auth_invoker_clone_release(const mk_auth_invoker ctx);
|
||||
|
||||
///////////////////////////////////////////WebRtcTransport/////////////////////////////////////////////
|
||||
//WebRtcTransport对象的C映射
|
||||
// WebRtcTransport对象的C映射 [AUTO-TRANSLATED:20b208cc]
|
||||
// C mapping of the WebRtcTransport object
|
||||
typedef struct mk_rtc_transport_t *mk_rtc_transport;
|
||||
|
||||
/**
|
||||
@@ -397,6 +558,15 @@ typedef struct mk_rtc_transport_t *mk_rtc_transport;
|
||||
* @param ppid 协议id
|
||||
* @param msg 数据
|
||||
* @param len 数据长度
|
||||
* Send rtc data channel
|
||||
* @param ctx Data channel object
|
||||
* @param streamId Stream id
|
||||
* @param ppid Protocol id
|
||||
* @param msg Data
|
||||
* @param len Data length
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:a0ce3c9e]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtc_send_datachannel(const mk_rtc_transport ctx, uint16_t streamId, uint32_t ppid, const char* msg, size_t len);
|
||||
|
||||
|
||||
@@ -17,16 +17,22 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// 是否为关键帧 [AUTO-TRANSLATED:b999067c]
|
||||
// cpp
|
||||
//是否为关键帧
|
||||
#define MK_FRAME_FLAG_IS_KEY (1 << 0)
|
||||
//是否为配置帧(sps/pps/vps等)
|
||||
// 是否为配置帧(sps/pps/vps等) [AUTO-TRANSLATED:cf504832]
|
||||
// 是否为配置帧(sps/pps/vps等)
|
||||
#define MK_FRAME_FLAG_IS_CONFIG (1 << 1)
|
||||
//是否可丢弃的帧(sei/aud)
|
||||
// 是否可丢弃的帧(sei/aud) [AUTO-TRANSLATED:6481fe69]
|
||||
// 是否可丢弃的帧(sei/aud)
|
||||
#define MK_FRAME_FLAG_DROP_ABLE (1 << 2)
|
||||
//是否不可单独解码的帧(多slice的非vcl帧)
|
||||
// 是否不可单独解码的帧(多slice的非vcl帧) [AUTO-TRANSLATED:cb4da662]
|
||||
// 是否不可单独解码的帧(多slice的非vcl帧)
|
||||
#define MK_FRAME_FLAG_NOT_DECODE_ABLE (1 << 3)
|
||||
|
||||
//codec id常量定义
|
||||
// codec id常量定义 [AUTO-TRANSLATED:dbc838b6]
|
||||
// codec id常量定义
|
||||
API_EXPORT extern const int MKCodecH264;
|
||||
API_EXPORT extern const int MKCodecH265;
|
||||
API_EXPORT extern const int MKCodecAAC;
|
||||
@@ -41,6 +47,7 @@ API_EXPORT extern const int MKCodecJPEG;
|
||||
|
||||
typedef struct mk_frame_t *mk_frame;
|
||||
|
||||
// 用户自定义free回调函数 [AUTO-TRANSLATED:dc96ff2d]
|
||||
// 用户自定义free回调函数
|
||||
typedef void(API_CALL *on_mk_frame_data_release)(void *user_data, char *ptr);
|
||||
|
||||
@@ -54,6 +61,17 @@ typedef void(API_CALL *on_mk_frame_data_release)(void *user_data, char *ptr);
|
||||
* @param cb data指针free释放回调, 如果为空,内部会拷贝数据
|
||||
* @param user_data data指针free释放回调用户指针
|
||||
* @return frame对象引用
|
||||
* Create a frame object and return its reference.
|
||||
* @param codec_id Encoding and decoding type, please refer to MKCodecXXX definition.
|
||||
* @param dts Decoding timestamp, in milliseconds.
|
||||
* @param pts Display timestamp, in milliseconds.
|
||||
* @param data Single frame data.
|
||||
* @param size Single frame data length.
|
||||
* @param cb data pointer free release callback, if empty, the data will be copied internally.
|
||||
* @param user_data data pointer free release callback user pointer.
|
||||
* @return frame object reference.
|
||||
|
||||
* [AUTO-TRANSLATED:0481221b]
|
||||
*/
|
||||
API_EXPORT mk_frame API_CALL mk_frame_create(int codec_id, uint64_t dts, uint64_t pts, const char *data, size_t size,
|
||||
on_mk_frame_data_release cb, void *user_data);
|
||||
@@ -62,6 +80,10 @@ API_EXPORT mk_frame API_CALL mk_frame_create2(int codec_id, uint64_t dts, uint64
|
||||
/**
|
||||
* 减引用frame对象
|
||||
* @param frame 帧对象引用
|
||||
* Decrement the reference of the frame object.
|
||||
* @param frame Frame object reference.
|
||||
|
||||
* [AUTO-TRANSLATED:53b5a750]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_frame_unref(mk_frame frame);
|
||||
|
||||
@@ -69,51 +91,83 @@ API_EXPORT void API_CALL mk_frame_unref(mk_frame frame);
|
||||
* 引用frame对象
|
||||
* @param frame 被引用的frame对象
|
||||
* @return 新的对象引用
|
||||
* Reference the frame object.
|
||||
* @param frame The referenced frame object.
|
||||
* @return New object reference.
|
||||
|
||||
* [AUTO-TRANSLATED:f772813d]
|
||||
*/
|
||||
API_EXPORT mk_frame API_CALL mk_frame_ref(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 获取frame 编码codec类型,请参考MKCodecXXX定义
|
||||
* Get the frame encoding codec type, please refer to MKCodecXXX definition.
|
||||
|
||||
* [AUTO-TRANSLATED:b3a34bb8]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_frame_codec_id(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 获取帧编码codec名称
|
||||
* Get the frame encoding codec name.
|
||||
|
||||
* [AUTO-TRANSLATED:6c3129d7]
|
||||
*/
|
||||
API_EXPORT const char* API_CALL mk_frame_codec_name(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 帧是否为视频
|
||||
* Whether the frame is video.
|
||||
|
||||
* [AUTO-TRANSLATED:c43dbd4e]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_frame_is_video(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 获取帧数据指针
|
||||
* Get the frame data pointer.
|
||||
|
||||
* [AUTO-TRANSLATED:bf454f3b]
|
||||
*/
|
||||
API_EXPORT const char* API_CALL mk_frame_get_data(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 获取帧数据指针长度
|
||||
* Get the length of the frame data pointer.
|
||||
|
||||
* [AUTO-TRANSLATED:8a76acf2]
|
||||
*/
|
||||
API_EXPORT size_t API_CALL mk_frame_get_data_size(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 返回帧数据前缀长度,譬如H264/H265前缀一般是0x00 00 00 01,那么本函数返回4
|
||||
* Return the length of the frame data prefix, for example, the H264/H265 prefix is generally 0x00 00 00 01, then this function returns 4.
|
||||
|
||||
* [AUTO-TRANSLATED:352c7cfc]
|
||||
*/
|
||||
API_EXPORT size_t API_CALL mk_frame_get_data_prefix_size(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 获取解码时间戳,单位毫秒
|
||||
* Get the decoding timestamp, in milliseconds.
|
||||
|
||||
* [AUTO-TRANSLATED:049f1339]
|
||||
*/
|
||||
API_EXPORT uint64_t API_CALL mk_frame_get_dts(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 获取显示时间戳,单位毫秒
|
||||
* Get the display timestamp, in milliseconds.
|
||||
|
||||
* [AUTO-TRANSLATED:4ab081a7]
|
||||
*/
|
||||
API_EXPORT uint64_t API_CALL mk_frame_get_pts(mk_frame frame);
|
||||
|
||||
/**
|
||||
* 获取帧flag,请参考 MK_FRAME_FLAG
|
||||
* Get the frame flag, please refer to MK_FRAME_FLAG.
|
||||
|
||||
* [AUTO-TRANSLATED:6fdf971c]
|
||||
*/
|
||||
API_EXPORT uint32_t API_CALL mk_frame_get_flags(mk_frame frame);
|
||||
|
||||
@@ -126,18 +180,31 @@ typedef struct mk_frame_merger_t *mk_frame_merger;
|
||||
* 创建帧合并器
|
||||
* @param type 起始头类型,0: none, 1: h264_prefix/AnnexB(0x 00 00 00 01), 2: mp4_nal_size(avcC)
|
||||
* @return 帧合并器
|
||||
* Create a frame merger.
|
||||
* @param type Starting header type, 0: none, 1: h264_prefix/AnnexB(0x 00 00 00 01), 2: mp4_nal_size(avcC)
|
||||
* @return Frame merger.
|
||||
|
||||
* [AUTO-TRANSLATED:385eedd7]
|
||||
*/
|
||||
API_EXPORT mk_frame_merger API_CALL mk_frame_merger_create(int type);
|
||||
|
||||
/**
|
||||
* 销毁帧合并器
|
||||
* @param ctx 对象指针
|
||||
* Destroy the frame merger.
|
||||
* @param ctx Object pointer.
|
||||
|
||||
* [AUTO-TRANSLATED:0c9aad7b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_frame_merger_release(mk_frame_merger ctx);
|
||||
|
||||
/**
|
||||
* 清空merger对象缓冲,方便复用
|
||||
* @param ctx 对象指针
|
||||
* Clear the merger object buffer for reuse.
|
||||
* @param ctx Object pointer.
|
||||
|
||||
* [AUTO-TRANSLATED:6b1d2209]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_frame_merger_clear(mk_frame_merger ctx);
|
||||
|
||||
@@ -148,6 +215,14 @@ API_EXPORT void API_CALL mk_frame_merger_clear(mk_frame_merger ctx);
|
||||
* @param pts 显示时间戳
|
||||
* @param buffer 合并后数据buffer对象
|
||||
* @param have_key_frame 合并后数据中是否包含关键帧
|
||||
* Frame merging callback function.
|
||||
* @param user_data User data pointer.
|
||||
* @param dts Decoding timestamp.
|
||||
* @param pts Display timestamp.
|
||||
* @param buffer Merged data buffer object.
|
||||
* @param have_key_frame Whether the merged data contains a key frame.
|
||||
|
||||
* [AUTO-TRANSLATED:ff78df4f]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_frame_merger)(void *user_data, uint64_t dts, uint64_t pts, mk_buffer buffer, int have_key_frame);
|
||||
|
||||
@@ -157,12 +232,23 @@ typedef void(API_CALL *on_mk_frame_merger)(void *user_data, uint64_t dts, uint64
|
||||
* @param frame 帧数据
|
||||
* @param cb 帧合并回调函数
|
||||
* @param user_data 帧合并回调函数用户数据指针
|
||||
* Input frame to the merger object and merge.
|
||||
* @param ctx Object pointer.
|
||||
* @param frame Frame data.
|
||||
* @param cb Frame merging callback function.
|
||||
* @param user_data Frame merging callback function user data pointer.
|
||||
|
||||
* [AUTO-TRANSLATED:83aa1436]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_frame_merger_input(mk_frame_merger ctx, mk_frame frame, on_mk_frame_merger cb, void *user_data);
|
||||
|
||||
/**
|
||||
* 强制flush merger对象缓冲,调用此api前需要确保先调用mk_frame_merger_input函数并且回调参数有效
|
||||
* @param ctx 对象指针
|
||||
* Force flush the merger object buffer. Before calling this API, make sure to call the mk_frame_merger_input function first and the callback parameters are valid.
|
||||
* @param ctx Object pointer.
|
||||
|
||||
* [AUTO-TRANSLATED:42bb104c]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_frame_merger_flush(mk_frame_merger ctx);
|
||||
|
||||
@@ -178,6 +264,15 @@ typedef struct mk_mpeg_muxer_t *mk_mpeg_muxer;
|
||||
* @param size 帧数据长度
|
||||
* @param timestamp 时间戳
|
||||
* @param key_pos 是否关键帧
|
||||
* mpeg-ps/ts packer output callback function.
|
||||
* @param user_data User data pointer set during callback.
|
||||
* @param muxer Object.
|
||||
* @param frame Frame data.
|
||||
* @param size Frame data length.
|
||||
* @param timestamp Timestamp.
|
||||
* @param key_pos Whether it is a key frame.
|
||||
|
||||
* [AUTO-TRANSLATED:14c103a2]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_mpeg_muxer_frame)(void *user_data, mk_mpeg_muxer muxer, const char *frame, size_t size, uint64_t timestamp, int key_pos);
|
||||
|
||||
@@ -187,12 +282,23 @@ typedef void(API_CALL *on_mk_mpeg_muxer_frame)(void *user_data, mk_mpeg_muxer mu
|
||||
* @param user_data 回调用户数据指针
|
||||
* @param is_ps 是否是ps
|
||||
* @return 打包器对象
|
||||
* mpeg-ps/ts packer.
|
||||
* @param cb Packing callback function.
|
||||
* @param user_data Callback user data pointer.
|
||||
* @param is_ps Whether it is ps.
|
||||
* @return Packer object.
|
||||
|
||||
* [AUTO-TRANSLATED:6526b871]
|
||||
*/
|
||||
API_EXPORT mk_mpeg_muxer API_CALL mk_mpeg_muxer_create(on_mk_mpeg_muxer_frame cb, void *user_data, int is_ps);
|
||||
|
||||
/**
|
||||
* 删除mpeg-ps/ts 打包器
|
||||
* @param ctx 打包器
|
||||
* Delete the mpeg-ps/ts packer.
|
||||
* @param ctx Packer.
|
||||
|
||||
* [AUTO-TRANSLATED:0b533391]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_mpeg_muxer_release(mk_mpeg_muxer ctx);
|
||||
|
||||
@@ -200,6 +306,11 @@ API_EXPORT void API_CALL mk_mpeg_muxer_release(mk_mpeg_muxer ctx);
|
||||
* 添加音视频track
|
||||
* @param ctx mk_mpeg_muxer对象
|
||||
* @param track mk_track对象,音视频轨道
|
||||
* Add audio/video track.
|
||||
* @param ctx mk_mpeg_muxer object.
|
||||
* @param track mk_track object, audio/video track.
|
||||
|
||||
* [AUTO-TRANSLATED:f2082619]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_mpeg_muxer_init_track(mk_mpeg_muxer ctx, void* track);
|
||||
|
||||
@@ -208,6 +319,12 @@ API_EXPORT void API_CALL mk_mpeg_muxer_init_track(mk_mpeg_muxer ctx, void* track
|
||||
* 在单track(只有音频或视频)时,因为ZLMediaKit不知道后续是否还要添加track,所以会多等待3秒钟
|
||||
* 如果产生的流是单Track类型,请调用此函数以便加快流生成速度,当然不调用该函数,影响也不大(会多等待3秒)
|
||||
* @param ctx 对象指针
|
||||
* Call this function after the track is initialized.
|
||||
* In the case of a single track (only audio or video), because ZLMediaKit does not know whether to add more tracks later, it will wait for an additional 3 seconds.
|
||||
* If the generated stream is a single Track type, please call this function to speed up the stream generation. Of course, if you don't call this function, the impact is not big (it will wait for an additional 3 seconds).
|
||||
* @param ctx Object pointer.
|
||||
|
||||
* [AUTO-TRANSLATED:f40d41cb]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_mpeg_muxer_init_complete(mk_mpeg_muxer ctx);
|
||||
|
||||
@@ -216,6 +333,13 @@ API_EXPORT void API_CALL mk_mpeg_muxer_init_complete(mk_mpeg_muxer ctx);
|
||||
* @param ctx mk_mpeg_muxer对象
|
||||
* @param frame 帧对象
|
||||
* @return 1代表成功,0失败
|
||||
* Input frame object.
|
||||
* @param ctx mk_mpeg_muxer object.
|
||||
* @param frame Frame object.
|
||||
* @return 1 means success, 0 means failure.
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:46523906]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_mpeg_muxer_input_frame(mk_mpeg_muxer ctx, mk_frame frame);
|
||||
|
||||
|
||||
@@ -25,6 +25,13 @@ typedef struct mk_h264_splitter_t *mk_h264_splitter;
|
||||
* @param splitter 对象
|
||||
* @param frame 帧数据
|
||||
* @param size 帧数据长度
|
||||
* h264 frame splitter output callback function
|
||||
* @param user_data user data pointer set when setting the callback
|
||||
* @param splitter object
|
||||
* @param frame frame data
|
||||
* @param size frame data length
|
||||
|
||||
* [AUTO-TRANSLATED:3e4e4dfa]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_h264_splitter_frame)(void *user_data, mk_h264_splitter splitter, const char *frame, int size);
|
||||
|
||||
@@ -34,6 +41,13 @@ typedef void(API_CALL *on_mk_h264_splitter_frame)(void *user_data, mk_h264_split
|
||||
* @param user_data 回调用户数据指针
|
||||
* @param is_h265 是否是265
|
||||
* @return 分帧器对象
|
||||
* Create h264 frame splitter
|
||||
* @param cb frame splitting callback function
|
||||
* @param user_data callback user data pointer
|
||||
* @param is_h265 whether it is 265
|
||||
* @return frame splitter object
|
||||
|
||||
* [AUTO-TRANSLATED:6e06f68d]
|
||||
*/
|
||||
API_EXPORT mk_h264_splitter API_CALL mk_h264_splitter_create(on_mk_h264_splitter_frame cb, void *user_data, int is_h265);
|
||||
API_EXPORT mk_h264_splitter API_CALL mk_h264_splitter_create2(on_mk_h264_splitter_frame cb, void *user_data, on_user_data_free user_data_free, int is_h265);
|
||||
@@ -41,6 +55,10 @@ API_EXPORT mk_h264_splitter API_CALL mk_h264_splitter_create2(on_mk_h264_splitte
|
||||
/**
|
||||
* 删除h264分帧器
|
||||
* @param ctx 分帧器
|
||||
* Delete h264 frame splitter
|
||||
* @param ctx frame splitter
|
||||
|
||||
* [AUTO-TRANSLATED:e69bb6dd]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_h264_splitter_release(mk_h264_splitter ctx);
|
||||
|
||||
@@ -49,6 +67,13 @@ API_EXPORT void API_CALL mk_h264_splitter_release(mk_h264_splitter ctx);
|
||||
* @param ctx 分帧器
|
||||
* @param data h264/h265数据
|
||||
* @param size 数据长度
|
||||
* Input data and split frames
|
||||
* @param ctx frame splitter
|
||||
* @param data h264/h265 data
|
||||
* @param size data length
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:c6b93aed]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_h264_splitter_input_data(mk_h264_splitter ctx, const char *data, int size);
|
||||
|
||||
|
||||
@@ -27,18 +27,32 @@ typedef struct mk_http_downloader_t *mk_http_downloader;
|
||||
* @param code 错误代码,0代表成功
|
||||
* @param err_msg 错误提示
|
||||
* @param file_path 文件保存路径
|
||||
* @param user_data User data pointer
|
||||
* @param code Error code, 0 represents success
|
||||
* @param err_msg Error message
|
||||
* @param file_path File save path
|
||||
|
||||
* [AUTO-TRANSLATED:8f8ed7ef]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_download_complete)(void *user_data, int code, const char *err_msg, const char *file_path);
|
||||
|
||||
/**
|
||||
* 创建http[s]下载器
|
||||
* @return 下载器指针
|
||||
* Create http[s] downloader
|
||||
* @return Downloader pointer
|
||||
|
||||
* [AUTO-TRANSLATED:93112194]
|
||||
*/
|
||||
API_EXPORT mk_http_downloader API_CALL mk_http_downloader_create();
|
||||
|
||||
/**
|
||||
* 销毁http[s]下载器
|
||||
* @param ctx 下载器指针
|
||||
* Destroy http[s] downloader
|
||||
* @param ctx Downloader pointer
|
||||
|
||||
* [AUTO-TRANSLATED:8378a5a7]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_downloader_release(mk_http_downloader ctx);
|
||||
|
||||
@@ -49,6 +63,14 @@ API_EXPORT void API_CALL mk_http_downloader_release(mk_http_downloader ctx);
|
||||
* @param file 文件保存路径
|
||||
* @param cb 回调函数
|
||||
* @param user_data 用户数据指针
|
||||
* Start http[s] download
|
||||
* @param ctx Downloader pointer
|
||||
* @param url http[s] download url
|
||||
* @param file File save path
|
||||
* @param cb Callback function
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:8a2acf02]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_downloader_start(mk_http_downloader ctx, const char *url, const char *file, on_mk_download_complete cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_http_downloader_start2(mk_http_downloader ctx, const char *url, const char *file, on_mk_download_complete cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -66,16 +88,33 @@ typedef struct mk_http_requester_t *mk_http_requester;
|
||||
* @param user_data 用户数据指针
|
||||
* @param code 错误代码,0代表成功
|
||||
* @param err_msg 错误提示
|
||||
* Http request result callback
|
||||
* When code == 0, it means that the current http session is complete (http response has been received)
|
||||
* Users should get the mk_http_requester object through user_data
|
||||
* Then get the relevant response data through functions such as mk_http_requester_get_response
|
||||
* At the end of the callback, the object should be destroyed by calling the mk_http_requester_release function
|
||||
* Or reuse the object after calling the mk_http_requester_clear function
|
||||
* @param user_data User data pointer
|
||||
* @param code Error code, 0 represents success
|
||||
* @param err_msg Error message
|
||||
|
||||
* [AUTO-TRANSLATED:d24408ce]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_http_requester_complete)(void *user_data, int code, const char *err_msg);
|
||||
|
||||
/**
|
||||
* 创建HttpRequester
|
||||
* Create HttpRequester
|
||||
|
||||
* [AUTO-TRANSLATED:fa182fbc]
|
||||
*/
|
||||
API_EXPORT mk_http_requester API_CALL mk_http_requester_create();
|
||||
|
||||
/**
|
||||
* 在复用mk_http_requester对象时才需要用到此方法
|
||||
* This method is only needed when reusing the mk_http_requester object
|
||||
|
||||
* [AUTO-TRANSLATED:6854d97f]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_clear(mk_http_requester ctx);
|
||||
|
||||
@@ -83,17 +122,29 @@ API_EXPORT void API_CALL mk_http_requester_clear(mk_http_requester ctx);
|
||||
* 销毁HttpRequester
|
||||
* 如果调用了mk_http_requester_start函数且正在等待http回复,
|
||||
* 也可以调用mk_http_requester_release方法取消本次http请求
|
||||
* Destroy HttpRequester
|
||||
* If the mk_http_requester_start function is called and is waiting for the http response,
|
||||
* You can also call the mk_http_requester_release method to cancel the current http request
|
||||
|
||||
* [AUTO-TRANSLATED:5f533e28]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_release(mk_http_requester ctx);
|
||||
|
||||
/**
|
||||
* 设置HTTP方法,譬如GET/POST
|
||||
* Set HTTP method, such as GET/POST
|
||||
|
||||
* [AUTO-TRANSLATED:d4b641f1]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_set_method(mk_http_requester ctx,const char *method);
|
||||
|
||||
/**
|
||||
* 批量设置设置HTTP头
|
||||
* @param header 譬如 {"Content-Type","text/html",NULL} 必须以NULL结尾
|
||||
* Batch set HTTP headers
|
||||
* @param header For example, {"Content-Type","text/html",NULL} must end with NULL
|
||||
|
||||
* [AUTO-TRANSLATED:65124347]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_set_header(mk_http_requester ctx, const char *header[]);
|
||||
|
||||
@@ -102,18 +153,32 @@ API_EXPORT void API_CALL mk_http_requester_set_header(mk_http_requester ctx, con
|
||||
* @param key 譬如Content-Type
|
||||
* @param value 譬如 text/html
|
||||
* @param force 如果已经存在该key,是否强制替换
|
||||
* Add HTTP header
|
||||
* @param key For example, Content-Type
|
||||
* @param value For example, text/html
|
||||
* @param force If the key already exists, whether to force replacement
|
||||
|
||||
* [AUTO-TRANSLATED:79d32682]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_add_header(mk_http_requester ctx,const char *key,const char *value,int force);
|
||||
|
||||
/**
|
||||
* 设置消息体,
|
||||
* @param body mk_http_body对象,通过mk_http_body_from_string等函数生成,使用完毕后请调用mk_http_body_release释放之
|
||||
* Set message body,
|
||||
* @param body mk_http_body object, generated by functions such as mk_http_body_from_string, please call mk_http_body_release to release it after use
|
||||
|
||||
* [AUTO-TRANSLATED:85d0f139]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_set_body(mk_http_requester ctx, mk_http_body body);
|
||||
|
||||
/**
|
||||
* 在收到HTTP回复后可调用该方法获取状态码
|
||||
* @return 譬如 200 OK
|
||||
* You can call this method to get the status code after receiving the HTTP response
|
||||
* @return For example, 200 OK
|
||||
|
||||
* [AUTO-TRANSLATED:7757b21a]
|
||||
*/
|
||||
API_EXPORT const char* API_CALL mk_http_requester_get_response_status(mk_http_requester ctx);
|
||||
|
||||
@@ -121,6 +186,11 @@ API_EXPORT const char* API_CALL mk_http_requester_get_response_status(mk_http_re
|
||||
* 在收到HTTP回复后可调用该方法获取响应HTTP头
|
||||
* @param key HTTP头键名
|
||||
* @return HTTP头键值
|
||||
* You can call this method to get the response HTTP header after receiving the HTTP response
|
||||
* @param key HTTP header key name
|
||||
* @return HTTP header key value
|
||||
|
||||
* [AUTO-TRANSLATED:10f8ae74]
|
||||
*/
|
||||
API_EXPORT const char* API_CALL mk_http_requester_get_response_header(mk_http_requester ctx,const char *key);
|
||||
|
||||
@@ -128,12 +198,21 @@ API_EXPORT const char* API_CALL mk_http_requester_get_response_header(mk_http_re
|
||||
* 在收到HTTP回复后可调用该方法获取响应HTTP body
|
||||
* @param length 返回body长度,可以为null
|
||||
* @return body指针
|
||||
* You can call this method to get the response HTTP body after receiving the HTTP response
|
||||
* @param length Return body length, can be null
|
||||
* @return Body pointer
|
||||
|
||||
* [AUTO-TRANSLATED:764dbb38]
|
||||
*/
|
||||
API_EXPORT const char* API_CALL mk_http_requester_get_response_body(mk_http_requester ctx, size_t *length);
|
||||
|
||||
/**
|
||||
* 在收到HTTP回复后可调用该方法获取响应
|
||||
* @return 响应对象
|
||||
* You can call this method to get the response after receiving the HTTP response
|
||||
* @return Response object
|
||||
|
||||
* [AUTO-TRANSLATED:3800b175]
|
||||
*/
|
||||
API_EXPORT mk_parser API_CALL mk_http_requester_get_response(mk_http_requester ctx);
|
||||
|
||||
@@ -141,6 +220,11 @@ API_EXPORT mk_parser API_CALL mk_http_requester_get_response(mk_http_requester c
|
||||
* 设置回调函数
|
||||
* @param cb 回调函数,不能为空
|
||||
* @param user_data 用户数据指针
|
||||
* Set callback function
|
||||
* @param cb Callback function, cannot be empty
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:f04412b8]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_set_cb(mk_http_requester ctx,on_mk_http_requester_complete cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_http_requester_set_cb2(mk_http_requester ctx,on_mk_http_requester_complete cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -149,6 +233,11 @@ API_EXPORT void API_CALL mk_http_requester_set_cb2(mk_http_requester ctx,on_mk_h
|
||||
* 开始url请求
|
||||
* @param url 请求url,支持http/https
|
||||
* @param timeout_second 最大超时时间
|
||||
* Start url request
|
||||
* @param url Request url, supports http/https
|
||||
* @param timeout_second Maximum timeout time
|
||||
|
||||
* [AUTO-TRANSLATED:36986fec]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_http_requester_start(mk_http_requester ctx,const char *url, float timeout_second);
|
||||
|
||||
|
||||
@@ -33,6 +33,16 @@ typedef struct mk_media_t *mk_media;
|
||||
* @param hls_enabled 是否生成hls
|
||||
* @param mp4_enabled 是否生成mp4
|
||||
* @return 对象指针
|
||||
* Create a media source
|
||||
* @param vhost Virtual host name, generally __defaultVhost__
|
||||
* @param app Application name, recommended as live
|
||||
* @param stream Stream id, such as camera
|
||||
* @param duration Duration (in seconds), 0 for live broadcast
|
||||
* @param hls_enabled Whether to generate hls
|
||||
* @param mp4_enabled Whether to generate mp4
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:b5124a1e]
|
||||
*/
|
||||
API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream,
|
||||
float duration, int hls_enabled, int mp4_enabled);
|
||||
@@ -45,12 +55,25 @@ API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app,
|
||||
* @param duration 时长(单位秒),直播则为0
|
||||
* @param option ProtocolOption相关配置
|
||||
* @return 对象指针
|
||||
* Create a media source
|
||||
* @param vhost Virtual host name, generally __defaultVhost__
|
||||
* @param app Application name, recommended as live
|
||||
* @param stream Stream id, such as camera
|
||||
* @param duration Duration (in seconds), 0 for live broadcast
|
||||
* @param option ProtocolOption related configuration
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:870d86b0]
|
||||
*/
|
||||
API_EXPORT mk_media API_CALL mk_media_create2(const char *vhost, const char *app, const char *stream, float duration, mk_ini option);
|
||||
|
||||
/**
|
||||
* 销毁媒体源
|
||||
* @param ctx 对象指针
|
||||
* Destroy the media source
|
||||
* @param ctx Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:a63ad166]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_release(mk_media ctx);
|
||||
|
||||
@@ -58,6 +81,11 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx);
|
||||
* 添加音视频track
|
||||
* @param ctx mk_media对象
|
||||
* @param track mk_track对象,音视频轨道
|
||||
* Add audio and video tracks
|
||||
* @param ctx mk_media object
|
||||
* @param track mk_track object, audio and video track
|
||||
|
||||
* [AUTO-TRANSLATED:0e4ebe8d]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_init_track(mk_media ctx, mk_track track);
|
||||
|
||||
@@ -73,6 +101,19 @@ API_EXPORT void API_CALL mk_media_init_track(mk_media ctx, mk_track track);
|
||||
* @param height 视频高度
|
||||
* @param fps 视频fps
|
||||
* @return 1代表成功,0失败
|
||||
* Add video track, please use mk_media_init_track method
|
||||
* @param ctx Object pointer
|
||||
* @param codec_id 0:CodecH264/1:CodecH265
|
||||
* @param width Video width; Valid only during encoding
|
||||
* @param height Video height; Valid only during encoding
|
||||
* @param fps Video fps; Valid only during encoding
|
||||
* @param bit_rate Video bitrate, unit bps; Valid only during encoding
|
||||
* @param width Video width
|
||||
* @param height Video height
|
||||
* @param fps Video fps
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:c6944851]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_init_video(mk_media ctx, int codec_id, int width, int height, float fps, int bit_rate);
|
||||
|
||||
@@ -84,6 +125,15 @@ API_EXPORT int API_CALL mk_media_init_video(mk_media ctx, int codec_id, int widt
|
||||
* @param sample_bit 采样位数,只支持16
|
||||
* @param sample_rate 采样率
|
||||
* @return 1代表成功,0失败
|
||||
* Add audio track, please use mk_media_init_track method
|
||||
* @param ctx Object pointer
|
||||
* @param codec_id 2:CodecAAC/3:CodecG711A/4:CodecG711U/5:OPUS
|
||||
* @param channel Number of channels
|
||||
* @param sample_bit Sampling bit, only supports 16
|
||||
* @param sample_rate Sampling rate
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:5c5c7c7a]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_init_audio(mk_media ctx, int codec_id, int sample_rate, int channels, int sample_bit);
|
||||
|
||||
@@ -92,6 +142,12 @@ API_EXPORT int API_CALL mk_media_init_audio(mk_media ctx, int codec_id, int samp
|
||||
* 在单track(只有音频或视频)时,因为ZLMediaKit不知道后续是否还要添加track,所以会多等待3秒钟
|
||||
* 如果产生的流是单Track类型,请调用此函数以便加快流生成速度,当然不调用该函数,影响也不大(会多等待3秒)
|
||||
* @param ctx 对象指针
|
||||
* Call this function after h264/h265/aac initialization,
|
||||
* In single track (only audio or video), because ZLMediaKit does not know whether to add more tracks later, it will wait for 3 seconds.
|
||||
* If the generated stream is a single Track type, please call this function to speed up the stream generation speed. Of course, if you do not call this function, the impact is not big (it will wait for 3 seconds).
|
||||
* @param ctx Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:cd2bee12]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_init_complete(mk_media ctx);
|
||||
|
||||
@@ -100,6 +156,12 @@ API_EXPORT void API_CALL mk_media_init_complete(mk_media ctx);
|
||||
* @param ctx mk_media对象
|
||||
* @param frame 帧对象
|
||||
* @return 1代表成功,0失败
|
||||
* Input frame object
|
||||
* @param ctx mk_media object
|
||||
* @param frame Frame object
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:9f6ca231]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_input_frame(mk_media ctx, mk_frame frame);
|
||||
|
||||
@@ -111,6 +173,15 @@ API_EXPORT int API_CALL mk_media_input_frame(mk_media ctx, mk_frame frame);
|
||||
* @param dts 解码时间戳,单位毫秒
|
||||
* @param pts 播放时间戳,单位毫秒
|
||||
* @return 1代表成功,0失败
|
||||
* Input single frame H264 video, the starting byte of the frame can be 00 00 01, 00 00 00 01, please use mk_media_input_frame method
|
||||
* @param ctx Object pointer
|
||||
* @param data Single frame H264 data
|
||||
* @param len Number of bytes of single frame H264 data
|
||||
* @param dts Decode timestamp, unit milliseconds
|
||||
* @param pts Play timestamp, unit milliseconds
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:3b96ace8]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_input_h264(mk_media ctx, const void *data, int len, uint64_t dts, uint64_t pts);
|
||||
|
||||
@@ -122,6 +193,15 @@ API_EXPORT int API_CALL mk_media_input_h264(mk_media ctx, const void *data, int
|
||||
* @param dts 解码时间戳,单位毫秒
|
||||
* @param pts 播放时间戳,单位毫秒
|
||||
* @return 1代表成功,0失败
|
||||
* Input single frame H265 video, the starting byte of the frame can be 00 00 01, 00 00 00 01, please use mk_media_input_frame method
|
||||
* @param ctx Object pointer
|
||||
* @param data Single frame H265 data
|
||||
* @param len Number of bytes of single frame H265 data
|
||||
* @param dts Decode timestamp, unit milliseconds
|
||||
* @param pts Play timestamp, unit milliseconds
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:884739ba]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_input_h265(mk_media ctx, const void *data, int len, uint64_t dts, uint64_t pts);
|
||||
|
||||
@@ -131,6 +211,13 @@ API_EXPORT int API_CALL mk_media_input_h265(mk_media ctx, const void *data, int
|
||||
* @param yuv yuv420p数据
|
||||
* @param linesize yuv420p linesize
|
||||
* @param cts 视频采集时间戳,单位毫秒
|
||||
* Input YUV video data
|
||||
* @param ctx Object pointer
|
||||
* @param yuv yuv420p data
|
||||
* @param linesize yuv420p linesize
|
||||
* @param cts Video capture timestamp, unit milliseconds
|
||||
|
||||
* [AUTO-TRANSLATED:9c97805c]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_input_yuv(mk_media ctx, const char *yuv[3], int linesize[3], uint64_t cts);
|
||||
|
||||
@@ -142,6 +229,15 @@ API_EXPORT void API_CALL mk_media_input_yuv(mk_media ctx, const char *yuv[3], in
|
||||
* @param dts 时间戳,毫秒
|
||||
* @param adts adts头,可以为null
|
||||
* @return 1代表成功,0失败
|
||||
* Input single frame AAC audio (specify adts header separately), please use mk_media_input_frame method
|
||||
* @param ctx Object pointer
|
||||
* @param data Single frame AAC data without adts header, adts header 7 bytes
|
||||
* @param len Number of bytes of single frame AAC data
|
||||
* @param dts Timestamp, milliseconds
|
||||
* @param adts adts header, can be null
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:11e0503d]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_input_aac(mk_media ctx, const void *data, int len, uint64_t dts, void *adts);
|
||||
|
||||
@@ -152,6 +248,14 @@ API_EXPORT int API_CALL mk_media_input_aac(mk_media ctx, const void *data, int l
|
||||
* @param len 单帧PCM数据字节数
|
||||
* @param dts 时间戳,毫秒
|
||||
* @return 1代表成功,0失败
|
||||
* Input single frame PCM audio, this function is valid only when ENABLE_FAAC is compiled
|
||||
* @param ctx Object pointer
|
||||
* @param data Single frame PCM data
|
||||
* @param len Number of bytes of single frame PCM data
|
||||
* @param dts Timestamp, milliseconds
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:70f7488b]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_input_pcm(mk_media ctx, void *data, int len, uint64_t pts);
|
||||
|
||||
@@ -162,6 +266,14 @@ API_EXPORT int API_CALL mk_media_input_pcm(mk_media ctx, void *data, int len, ui
|
||||
* @param len 单帧音频数据字节数
|
||||
* @param dts 时间戳,毫秒
|
||||
* @return 1代表成功,0失败
|
||||
* Input single frame OPUS/G711 audio frame, please use mk_media_input_frame method
|
||||
* @param ctx Object pointer
|
||||
* @param data Single frame audio data
|
||||
* @param len Number of bytes of single frame audio data
|
||||
* @param dts Timestamp, milliseconds
|
||||
* @return 1 for success, 0 for failure
|
||||
|
||||
* [AUTO-TRANSLATED:4ffeabd6]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_input_audio(mk_media ctx, const void* data, int len, uint64_t dts);
|
||||
|
||||
@@ -171,6 +283,13 @@ API_EXPORT int API_CALL mk_media_input_audio(mk_media ctx, const void* data, int
|
||||
* 你应该通过该事件调用mk_media_release函数并且释放其他资源
|
||||
* 如果你不调用mk_media_release函数,那么MediaSource.close()操作将无效
|
||||
* @param user_data 用户数据指针,通过mk_media_set_on_close函数设置
|
||||
* MediaSource.close() callback event
|
||||
* When you choose to close an associated MediaSource, it will eventually trigger this callback
|
||||
* You should call mk_media_release function and release other resources through this event
|
||||
* If you do not call mk_media_release function, then the MediaSource.close() operation will be invalid
|
||||
* @param user_data User data pointer, set by mk_media_set_on_close function
|
||||
|
||||
* [AUTO-TRANSLATED:20191b2d]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_media_close)(void *user_data);
|
||||
|
||||
@@ -181,6 +300,14 @@ typedef void(API_CALL *on_mk_media_close)(void *user_data);
|
||||
* @param ctx 对象指针
|
||||
* @param cb 回调指针
|
||||
* @param user_data 用户数据指针
|
||||
* Listen to MediaSource.close() event
|
||||
* When you choose to close an associated MediaSource, it will eventually trigger this callback
|
||||
* You should call mk_media_release function and release other resources through this event
|
||||
* @param ctx Object pointer
|
||||
* @param cb Callback pointer
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:35d9db20]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_set_on_close(mk_media ctx, on_mk_media_close cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_set_on_close2(mk_media ctx, on_mk_media_close cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -190,6 +317,12 @@ API_EXPORT void API_CALL mk_media_set_on_close2(mk_media ctx, on_mk_media_close
|
||||
* @param user_data 用户数据指针,通过mk_media_set_on_seek设置
|
||||
* @param stamp_ms seek至的时间轴位置,单位毫秒
|
||||
* @return 1代表将处理seek请求,0代表忽略该请求
|
||||
* Triggered when the client receives a seek request
|
||||
* @param user_data User data pointer, set by mk_media_set_on_seek
|
||||
* @param stamp_ms Seek to the timeline position, unit milliseconds
|
||||
* @return 1 means the seek request will be processed, 0 means the request will be ignored
|
||||
|
||||
* [AUTO-TRANSLATED:c3301852]
|
||||
*/
|
||||
typedef int(API_CALL *on_mk_media_seek)(void *user_data,uint32_t stamp_ms);
|
||||
|
||||
@@ -197,6 +330,11 @@ typedef int(API_CALL *on_mk_media_seek)(void *user_data,uint32_t stamp_ms);
|
||||
* 收到客户端的pause或resume请求时触发该回调
|
||||
* @param user_data 用户数据指针,通过mk_media_set_on_pause设置
|
||||
* @param pause 1:暂停, 0: 恢复
|
||||
* Triggered when the client receives a pause or resume request
|
||||
* @param user_data User data pointer, set by mk_media_set_on_pause
|
||||
* @param pause 1: pause, 0: resume
|
||||
|
||||
* [AUTO-TRANSLATED:4f8aa828]
|
||||
*/
|
||||
typedef int(API_CALL* on_mk_media_pause)(void* user_data, int pause);
|
||||
|
||||
@@ -204,6 +342,11 @@ typedef int(API_CALL* on_mk_media_pause)(void* user_data, int pause);
|
||||
* 收到客户端的speed请求时触发该回调
|
||||
* @param user_data 用户数据指针,通过mk_media_set_on_pause设置
|
||||
* @param speed 0.5 1.0 2.0
|
||||
* Triggered when the client receives a speed request
|
||||
* @param user_data User data pointer, set by mk_media_set_on_pause
|
||||
* @param speed 0.5 1.0 2.0
|
||||
|
||||
* [AUTO-TRANSLATED:51bd090d]
|
||||
*/
|
||||
typedef int(API_CALL* on_mk_media_speed)(void* user_data, float speed);
|
||||
|
||||
@@ -212,6 +355,12 @@ typedef int(API_CALL* on_mk_media_speed)(void* user_data, float speed);
|
||||
* @param ctx 对象指针
|
||||
* @param cb 回调指针
|
||||
* @param user_data 用户数据指针
|
||||
* Listen to player seek request event
|
||||
* @param ctx Object pointer
|
||||
* @param cb Callback pointer
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:50c723d0]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_set_on_seek(mk_media ctx, on_mk_media_seek cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_set_on_seek2(mk_media ctx, on_mk_media_seek cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -221,6 +370,12 @@ API_EXPORT void API_CALL mk_media_set_on_seek2(mk_media ctx, on_mk_media_seek cb
|
||||
* @param ctx 对象指针
|
||||
* @param cb 回调指针
|
||||
* @param user_data 用户数据指针
|
||||
* Listen to player pause request event
|
||||
* @param ctx Object pointer
|
||||
* @param cb Callback pointer
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:bd6e9068]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_set_on_pause(mk_media ctx, on_mk_media_pause cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_set_on_pause2(mk_media ctx, on_mk_media_pause cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -230,6 +385,12 @@ API_EXPORT void API_CALL mk_media_set_on_pause2(mk_media ctx, on_mk_media_pause
|
||||
* @param ctx 对象指针
|
||||
* @param cb 回调指针
|
||||
* @param user_data 用户数据指针
|
||||
* Listen to player pause request event
|
||||
* @param ctx Object pointer
|
||||
* @param cb Callback pointer
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:bd6e9068]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_set_on_speed(mk_media ctx, on_mk_media_speed cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_set_on_speed2(mk_media ctx, on_mk_media_speed cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -238,6 +399,11 @@ API_EXPORT void API_CALL mk_media_set_on_speed2(mk_media ctx, on_mk_media_speed
|
||||
* 获取总的观看人数
|
||||
* @param ctx 对象指针
|
||||
* @return 观看人数
|
||||
* Get the total number of viewers
|
||||
* @param ctx Object pointer
|
||||
* @return Number of viewers
|
||||
|
||||
* [AUTO-TRANSLATED:56635caf]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_total_reader_count(mk_media ctx);
|
||||
|
||||
@@ -246,6 +412,12 @@ API_EXPORT int API_CALL mk_media_total_reader_count(mk_media ctx);
|
||||
* @param user_data 设置回调时的用户数据指针
|
||||
* @param sender 生成的MediaSource对象
|
||||
* @param regist 1为注册事件,0为注销事件
|
||||
* MediaSource registration or deregistration event
|
||||
* @param user_data User data pointer set when setting the callback
|
||||
* @param sender Generated MediaSource object
|
||||
* @param regist 1 for registration event, 0 for deregistration event
|
||||
|
||||
* [AUTO-TRANSLATED:4585bbef]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_media_source_regist)(void *user_data, mk_media_source sender, int regist);
|
||||
|
||||
@@ -254,12 +426,21 @@ typedef void(API_CALL *on_mk_media_source_regist)(void *user_data, mk_media_sour
|
||||
* @param ctx 对象指针
|
||||
* @param cb 回调指针
|
||||
* @param user_data 用户数据指针
|
||||
* Set MediaSource registration or deregistration event callback function
|
||||
* @param ctx Object pointer
|
||||
* @param cb Callback pointer
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:1c3b45be]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_set_on_regist(mk_media ctx, on_mk_media_source_regist cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_set_on_regist2(mk_media ctx, on_mk_media_source_regist cb, void *user_data, on_user_data_free user_data_free);
|
||||
|
||||
/**
|
||||
* rtp推流成功与否的回调(第一次成功后,后面将一直重试)
|
||||
* Callback for whether rtp streaming is successful or not (after the first success, it will retry continuously)
|
||||
|
||||
* [AUTO-TRANSLATED:7e00f7fb]
|
||||
*/
|
||||
typedef on_mk_media_source_send_rtp_result on_mk_media_send_rtp_result;
|
||||
|
||||
@@ -273,6 +454,17 @@ typedef on_mk_media_source_send_rtp_result on_mk_media_send_rtp_result;
|
||||
* @param options 选项
|
||||
* @param cb 启动成功或失败回调
|
||||
* @param user_data 回调用户指针
|
||||
* Start sending a ps-rtp stream (distinguished by ssrc), this api is thread-safe
|
||||
* @param ctx Object pointer
|
||||
* @param dst_url Target ip or domain name
|
||||
* @param dst_port Target port
|
||||
* @param ssrc rtp's ssrc, 10-base string print
|
||||
* @param con_type 0: tcp active, 1: udp active, 2: tcp passive, 3: udp passive
|
||||
* @param options Options
|
||||
* @param cb Start success or failure callback
|
||||
* @param user_data Callback user pointer
|
||||
|
||||
* [AUTO-TRANSLATED:dbf694a0]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_start_send_rtp(mk_media ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int con_type, on_mk_media_send_rtp_result cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_media_start_send_rtp2(mk_media ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int con_type, on_mk_media_send_rtp_result cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -282,12 +474,23 @@ API_EXPORT void API_CALL mk_media_start_send_rtp4(mk_media ctx, const char *dst_
|
||||
* 停止某路或全部ps-rtp发送,此api线程安全
|
||||
* @param ctx 对象指针
|
||||
* @param ssrc rtp的ssrc,10进制的字符串打印,如果为null或空字符串,则停止所有rtp推流
|
||||
* Stop a certain route or all ps-rtp sending, this api is thread-safe
|
||||
* @param ctx Object pointer
|
||||
* @param ssrc rtp's ssrc, 10-base string print, if it is null or empty string, stop all rtp streaming
|
||||
|
||||
* [AUTO-TRANSLATED:6fb2b1df]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_stop_send_rtp(mk_media ctx, const char *ssrc);
|
||||
|
||||
/**
|
||||
* 获取所属线程
|
||||
* @param ctx 对象指针
|
||||
* Get the belonging thread
|
||||
* @param ctx Object pointer
|
||||
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:85a157e8]
|
||||
*/
|
||||
API_EXPORT mk_thread API_CALL mk_media_get_owner_thread(mk_media ctx);
|
||||
|
||||
|
||||
@@ -28,6 +28,14 @@ typedef struct mk_player_t *mk_player;
|
||||
* @param err_msg 错误提示
|
||||
* @param tracks track列表
|
||||
* @param track_count track个数
|
||||
* Callback for playback result or playback interruption event
|
||||
* @param user_data User data pointer
|
||||
* @param err_code Error code, 0 for success
|
||||
* @param err_msg Error message
|
||||
* @param tracks Track list
|
||||
* @param track_count Number of tracks
|
||||
|
||||
* [AUTO-TRANSLATED:38d4c546]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_play_event)(void *user_data, int err_code, const char *err_msg, mk_track tracks[],
|
||||
int track_count);
|
||||
@@ -35,12 +43,20 @@ typedef void(API_CALL *on_mk_play_event)(void *user_data, int err_code, const ch
|
||||
/**
|
||||
* 创建一个播放器,支持rtmp[s]/rtsp[s]
|
||||
* @return 播放器指针
|
||||
* Create a player that supports rtmp[s]/rtsp[s]
|
||||
* @return Player pointer
|
||||
|
||||
* [AUTO-TRANSLATED:509f9a50]
|
||||
*/
|
||||
API_EXPORT mk_player API_CALL mk_player_create();
|
||||
|
||||
/**
|
||||
* 销毁播放器
|
||||
* @param ctx 播放器指针
|
||||
* Destroy the player
|
||||
* @param ctx Player pointer
|
||||
|
||||
* [AUTO-TRANSLATED:2448eb93]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_release(mk_player ctx);
|
||||
|
||||
@@ -49,6 +65,12 @@ API_EXPORT void API_CALL mk_player_release(mk_player ctx);
|
||||
* @param ctx 播放器指针
|
||||
* @param key 配置项键,支持 net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/wait_track_ready
|
||||
* @param val 配置项值,如果是整形,需要转换成统一转换成string
|
||||
* Set player configuration options
|
||||
* @param ctx Player pointer
|
||||
* @param key Configuration key, supports net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/wait_track_ready
|
||||
* @param val Configuration value, if it is an integer, it needs to be converted to a string
|
||||
|
||||
* [AUTO-TRANSLATED:12650e9f]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_set_option(mk_player ctx, const char *key, const char *val);
|
||||
|
||||
@@ -56,6 +78,11 @@ API_EXPORT void API_CALL mk_player_set_option(mk_player ctx, const char *key, co
|
||||
* 开始播放url
|
||||
* @param ctx 播放器指针
|
||||
* @param url rtsp[s]/rtmp[s] url
|
||||
* Start playing the url
|
||||
* @param ctx Player pointer
|
||||
* @param url rtsp[s]/rtmp[s] url
|
||||
|
||||
* [AUTO-TRANSLATED:dbec813f]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url);
|
||||
|
||||
@@ -63,6 +90,11 @@ API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url);
|
||||
* 暂停或恢复播放,仅对点播有用
|
||||
* @param ctx 播放器指针
|
||||
* @param pause 1:暂停播放,0:恢复播放
|
||||
* Pause or resume playback, only useful for on-demand
|
||||
* @param ctx Player pointer
|
||||
* @param pause 1: Pause playback, 0: Resume playback
|
||||
|
||||
* [AUTO-TRANSLATED:28eee990]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_pause(mk_player ctx, int pause);
|
||||
|
||||
@@ -70,6 +102,11 @@ API_EXPORT void API_CALL mk_player_pause(mk_player ctx, int pause);
|
||||
* 倍数播放,仅对点播有用
|
||||
* @param ctx 播放器指针
|
||||
* @param speed 0.5 1.0 2.0
|
||||
* Playback at a multiple, only useful for on-demand
|
||||
* @param ctx Player pointer
|
||||
* @param speed 0.5 1.0 2.0
|
||||
|
||||
* [AUTO-TRANSLATED:95249ade]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_speed(mk_player ctx, float speed);
|
||||
|
||||
@@ -77,6 +114,11 @@ API_EXPORT void API_CALL mk_player_speed(mk_player ctx, float speed);
|
||||
* 设置点播进度条
|
||||
* @param ctx 对象指针
|
||||
* @param progress 取值范围未 0.0~1.0
|
||||
* Set the on-demand progress bar
|
||||
* @param ctx Object pointer
|
||||
* @param progress Value range is 0.0~1.0
|
||||
|
||||
* [AUTO-TRANSLATED:cede3a8f]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress);
|
||||
|
||||
@@ -84,6 +126,11 @@ API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress);
|
||||
* 设置点播进度条
|
||||
* @param ctx 对象指针
|
||||
* @param seek_pos 取值范围 相对于开始时间增量 单位秒
|
||||
* Set the on-demand progress bar
|
||||
* @param ctx Object pointer
|
||||
* @param seek_pos Value range is the increment relative to the start time, unit is seconds
|
||||
|
||||
* [AUTO-TRANSLATED:cddea627]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_seekto_pos(mk_player ctx, int seek_pos);
|
||||
|
||||
@@ -92,6 +139,12 @@ API_EXPORT void API_CALL mk_player_seekto_pos(mk_player ctx, int seek_pos);
|
||||
* @param ctx 播放器指针
|
||||
* @param cb 回调函数指针,设置null立即取消回调
|
||||
* @param user_data 用户数据指针
|
||||
* Set the player to enable playback result callback function
|
||||
* @param ctx Player pointer
|
||||
* @param cb Callback function pointer, set null to immediately cancel the callback
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:1c2daeaf]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_set_on_result(mk_player ctx, on_mk_play_event cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_player_set_on_result2(mk_player ctx, on_mk_play_event cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -101,24 +154,43 @@ API_EXPORT void API_CALL mk_player_set_on_result2(mk_player ctx, on_mk_play_even
|
||||
* @param ctx 播放器指针
|
||||
* @param cb 回调函数指针,设置null立即取消回调
|
||||
* @param user_data 用户数据指针
|
||||
* Set the callback for playback being abnormally interrupted
|
||||
* @param ctx Player pointer
|
||||
* @param cb Callback function pointer, set null to immediately cancel the callback
|
||||
* @param user_data User data pointer
|
||||
|
||||
///////////////////////////Audio and video related information interfaces are only valid after the playback success callback is triggered///////////////////////////////
|
||||
* [AUTO-TRANSLATED:18f58697]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_player_set_on_shutdown(mk_player ctx, on_mk_play_event cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_player_set_on_shutdown2(mk_player ctx, on_mk_play_event cb, void *user_data, on_user_data_free user_data_free);
|
||||
|
||||
///////////////////////////获取音视频相关信息接口在播放成功回调触发后才有效///////////////////////////////
|
||||
// /////////////////////////获取音视频相关信息接口在播放成功回调触发后才有效/////////////////////////////// [AUTO-TRANSLATED:4b53d8ff]
|
||||
// * Get the duration of the on-demand program, if it is live, return 0, otherwise return the number of seconds
|
||||
|
||||
/**
|
||||
* 获取点播节目时长,如果是直播返回0,否则返回秒数
|
||||
* Get the on-demand playback progress, value range is 0.0~1.0
|
||||
|
||||
* [AUTO-TRANSLATED:522140b7]
|
||||
*/
|
||||
API_EXPORT float API_CALL mk_player_duration(mk_player ctx);
|
||||
|
||||
/**
|
||||
* 获取点播播放进度,取值范围 0.0~1.0
|
||||
* Get the on-demand playback progress position, value range is the increment relative to the start time, unit is seconds
|
||||
|
||||
* [AUTO-TRANSLATED:921795a0]
|
||||
*/
|
||||
API_EXPORT float API_CALL mk_player_progress(mk_player ctx);
|
||||
|
||||
/**
|
||||
* 获取点播播放进度位置,取值范围 相对于开始时间增量 单位秒
|
||||
* Get the packet loss rate, valid for rtsp
|
||||
* @param ctx Object pointer
|
||||
* @param track_type 0: Video, 1: Audio
|
||||
|
||||
* [AUTO-TRANSLATED:058e5089]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_player_progress_pos(mk_player ctx);
|
||||
|
||||
|
||||
@@ -29,6 +29,16 @@ typedef struct mk_proxy_player_t *mk_proxy_player;
|
||||
* @param hls_enabled 是否生成hls
|
||||
* @param mp4_enabled 是否生成mp4
|
||||
* @return 对象指针
|
||||
* Create a proxy player
|
||||
* @param vhost Virtual host name, generally __defaultVhost__
|
||||
* @param app Application name
|
||||
* @param stream Stream name
|
||||
* @param rtp_type rtsp playback method: RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
|
||||
* @param hls_enabled Whether to generate hls
|
||||
* @param mp4_enabled Whether to generate mp4
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:1d4f13f4]
|
||||
*/
|
||||
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *vhost, const char *app, const char *stream, int hls_enabled, int mp4_enabled);
|
||||
|
||||
@@ -40,6 +50,14 @@ API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *vhost, co
|
||||
* @param stream 流名
|
||||
* @param option ProtocolOption相关配置
|
||||
* @return 对象指针
|
||||
* Create a proxy player
|
||||
* @param vhost Virtual host name, generally __defaultVhost__
|
||||
* @param app Application name
|
||||
* @param stream Stream name
|
||||
* @param option ProtocolOption related configuration
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:4c6208df]
|
||||
*/
|
||||
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create2(const char *vhost, const char *app, const char *stream, mk_ini option);
|
||||
|
||||
@@ -54,6 +72,17 @@ API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create2(const char *vhost, c
|
||||
* @param mp4_enabled 是否生成mp4
|
||||
* @param retry_count 重试次数,当<0无限次重试
|
||||
* @return 对象指针
|
||||
* Create a proxy player
|
||||
* @param vhost Virtual host name, generally __defaultVhost__
|
||||
* @param app Application name
|
||||
* @param stream Stream name
|
||||
* @param rtp_type rtsp playback method: RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
|
||||
* @param hls_enabled Whether to generate hls
|
||||
* @param mp4_enabled Whether to generate mp4
|
||||
* @param retry_count Retry count, when <0 retry infinitely
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:e25286c3]
|
||||
*/
|
||||
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create3(const char *vhost, const char *app, const char *stream, int hls_enabled, int mp4_enabled, int retry_count);
|
||||
|
||||
@@ -66,6 +95,15 @@ API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create3(const char *vhost, c
|
||||
* @param option ProtocolOption相关配置
|
||||
* @param retry_count 重试次数,当<0无限次重试
|
||||
* @return 对象指针
|
||||
* Create a proxy player
|
||||
* @param vhost Virtual host name, generally __defaultVhost__
|
||||
* @param app Application name
|
||||
* @param stream Stream name
|
||||
* @param option ProtocolOption related configuration
|
||||
* @param retry_count Retry count, when <0 retry infinitely
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:2cb296d1]
|
||||
*/
|
||||
API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create4(const char *vhost, const char *app, const char *stream, mk_ini option, int retry_count);
|
||||
|
||||
@@ -73,6 +111,10 @@ API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create4(const char *vhost, c
|
||||
/**
|
||||
* 销毁代理播放器
|
||||
* @param ctx 对象指针
|
||||
* Destroy the proxy player
|
||||
* @param ctx Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:fe451691]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx);
|
||||
|
||||
@@ -81,6 +123,12 @@ API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx);
|
||||
* @param ctx 代理播放器指针
|
||||
* @param key 配置项键,支持 net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/rtsp_speed
|
||||
* @param val 配置项值,如果是整形,需要转换成统一转换成string
|
||||
* Set proxy player configuration options
|
||||
* @param ctx Proxy player pointer
|
||||
* @param key Configuration item key, supports net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/rtsp_speed
|
||||
* @param val Configuration item value, if it is an integer, it needs to be converted to a unified string
|
||||
|
||||
* [AUTO-TRANSLATED:78938fba]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const char *key, const char *val);
|
||||
|
||||
@@ -88,6 +136,11 @@ API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const c
|
||||
* 开始播放
|
||||
* @param ctx 对象指针
|
||||
* @param url 播放url,支持rtsp/rtmp
|
||||
* Start playback
|
||||
* @param ctx Object pointer
|
||||
* @param url Playback url, supports rtsp/rtmp
|
||||
|
||||
* [AUTO-TRANSLATED:9597bafb]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *url);
|
||||
|
||||
@@ -97,9 +150,17 @@ API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *u
|
||||
* 你应该通过该事件调用mk_proxy_player_release函数并且释放其他资源
|
||||
* 如果你不调用mk_proxy_player_release函数,那么MediaSource.close()操作将无效
|
||||
* @param user_data 用户数据指针,通过mk_proxy_player_set_on_close函数设置
|
||||
* MediaSource.close() callback event
|
||||
* When you choose to close an associated MediaSource, it will eventually trigger this callback
|
||||
* You should call mk_proxy_player_release function through this event and release other resources
|
||||
* If you do not call mk_proxy_player_release function, then MediaSource.close() operation will be invalid
|
||||
* @param user_data User data pointer, set by mk_proxy_player_set_on_close function
|
||||
|
||||
* [AUTO-TRANSLATED:c99b6bfd]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_proxy_player_cb)(void *user_data, int err, const char *what, int sys_err);
|
||||
// 保持兼容
|
||||
// 保持兼容 [AUTO-TRANSLATED:94139ca7]
|
||||
// Keep compatible
|
||||
#define on_mk_proxy_player_close on_mk_proxy_player_cb
|
||||
|
||||
/**
|
||||
@@ -109,6 +170,14 @@ typedef void(API_CALL *on_mk_proxy_player_cb)(void *user_data, int err, const ch
|
||||
* @param ctx 对象指针
|
||||
* @param cb 回调指针
|
||||
* @param user_data 用户数据指针
|
||||
* Listen for MediaSource.close() event
|
||||
* When you choose to close an associated MediaSource, it will eventually trigger this callback
|
||||
* You should call mk_proxy_player_release function through this event and release other resources
|
||||
* @param ctx Object pointer
|
||||
* @param cb Callback pointer
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:174060d4]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_proxy_player_set_on_close(mk_proxy_player ctx, on_mk_proxy_player_cb cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_proxy_player_set_on_close2(mk_proxy_player ctx, on_mk_proxy_player_cb cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -119,6 +188,13 @@ API_EXPORT void API_CALL mk_proxy_player_set_on_close2(mk_proxy_player ctx, on_m
|
||||
* @param cb 回调指针
|
||||
* @param user_data 用户数据指针
|
||||
* @param user_data_free 用户数据释放回调
|
||||
* Set the proxy's first playback result callback. If the first playback fails, it can be considered a startup failure.
|
||||
* @param ctx Object pointer
|
||||
* @param cb Callback pointer
|
||||
* @param user_data User data pointer
|
||||
* @param user_data_free User data release callback
|
||||
|
||||
* [AUTO-TRANSLATED:1f34852a]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_proxy_player_set_on_play_result(mk_proxy_player ctx, on_mk_proxy_player_cb cb, void *user_data, on_user_data_free user_data_free);
|
||||
|
||||
@@ -126,6 +202,11 @@ API_EXPORT void API_CALL mk_proxy_player_set_on_play_result(mk_proxy_player ctx,
|
||||
* 获取总的观看人数
|
||||
* @param ctx 对象指针
|
||||
* @return 观看人数
|
||||
* Get the total number of viewers
|
||||
* @param ctx Object pointer
|
||||
* @return Number of viewers
|
||||
|
||||
* [AUTO-TRANSLATED:56635caf]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_proxy_player_total_reader_count(mk_proxy_player ctx);
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@ typedef struct mk_pusher_t *mk_pusher;
|
||||
* @param user_data 用户数据指针
|
||||
* @param err_code 错误代码,0为成功
|
||||
* @param err_msg 错误提示
|
||||
* Callback for streaming result or streaming interruption event
|
||||
* @param user_data User data pointer
|
||||
* @param err_code Error code, 0 for success
|
||||
* @param err_msg Error message
|
||||
|
||||
* [AUTO-TRANSLATED:6e7d5c79]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_push_event)(void *user_data,int err_code,const char *err_msg);
|
||||
|
||||
@@ -38,6 +44,17 @@ typedef void(API_CALL *on_mk_push_event)(void *user_data,int err_code,const char
|
||||
* @param app 绑定的MediaSource对象的应用名,一般为live
|
||||
* @param stream 绑定的MediaSource对象的流id
|
||||
* @return 对象指针
|
||||
* Bind the MediaSource object and create an rtmp[s]/rtsp[s] pusher
|
||||
* MediaSource is generated by mk_media_create or mk_proxy_player_create or streaming
|
||||
* The MediaSource object must be registered
|
||||
*
|
||||
* @param schema Protocol to which the bound MediaSource object belongs, supporting rtsp/rtmp
|
||||
* @param vhost Virtual host of the bound MediaSource object, generally __defaultVhost__
|
||||
* @param app Application name of the bound MediaSource object, generally live
|
||||
* @param stream Stream id of the bound MediaSource object
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:9366fdbc]
|
||||
*/
|
||||
API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vhost,const char *app, const char *stream);
|
||||
|
||||
@@ -48,12 +65,24 @@ API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vh
|
||||
*
|
||||
* @param src MediaSource对象
|
||||
* @return 对象指针
|
||||
* Bind the MediaSource object and create an rtmp[s]/rtsp[s] pusher
|
||||
* MediaSource is generated by mk_media_create or mk_proxy_player_create or streaming
|
||||
* The MediaSource object must be registered
|
||||
*
|
||||
* @param src MediaSource object
|
||||
* @return Object pointer
|
||||
|
||||
* [AUTO-TRANSLATED:34ca024a]
|
||||
*/
|
||||
API_EXPORT mk_pusher API_CALL mk_pusher_create_src(mk_media_source src);
|
||||
|
||||
/**
|
||||
* 释放推流器
|
||||
* @param ctx 推流器指针
|
||||
* Release the pusher
|
||||
* @param ctx Pusher pointer
|
||||
|
||||
* [AUTO-TRANSLATED:55fd6b8b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_pusher_release(mk_pusher ctx);
|
||||
|
||||
@@ -62,6 +91,12 @@ API_EXPORT void API_CALL mk_pusher_release(mk_pusher ctx);
|
||||
* @param ctx 推流器指针
|
||||
* @param key 配置项键,支持 net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms
|
||||
* @param val 配置项值,如果是整形,需要转换成统一转换成string
|
||||
* Set the pusher configuration options
|
||||
* @param ctx Pusher pointer
|
||||
* @param key Configuration item key, supports net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms
|
||||
* @param val Configuration item value, if it is an integer, it needs to be converted to a unified string
|
||||
|
||||
* [AUTO-TRANSLATED:0e3ce06d]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_pusher_set_option(mk_pusher ctx, const char *key, const char *val);
|
||||
|
||||
@@ -69,6 +104,11 @@ API_EXPORT void API_CALL mk_pusher_set_option(mk_pusher ctx, const char *key, co
|
||||
* 开始推流
|
||||
* @param ctx 推流器指针
|
||||
* @param url 推流地址,支持rtsp[s]/rtmp[s]
|
||||
* Start streaming
|
||||
* @param ctx Pusher pointer
|
||||
* @param url Streaming address, supports rtsp[s]/rtmp[s]
|
||||
|
||||
* [AUTO-TRANSLATED:45c0a836]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_pusher_publish(mk_pusher ctx,const char *url);
|
||||
|
||||
@@ -77,6 +117,12 @@ API_EXPORT void API_CALL mk_pusher_publish(mk_pusher ctx,const char *url);
|
||||
* @param ctx 推流器指针
|
||||
* @param cb 回调函数指针,不得为null
|
||||
* @param user_data 用户数据指针
|
||||
* Set the pusher streaming result callback function
|
||||
* @param ctx Pusher pointer
|
||||
* @param cb Callback function pointer, must not be null
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:a45fb6e4]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_pusher_set_on_result(mk_pusher ctx, on_mk_push_event cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_pusher_set_on_result2(mk_pusher ctx, on_mk_push_event cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -86,6 +132,12 @@ API_EXPORT void API_CALL mk_pusher_set_on_result2(mk_pusher ctx, on_mk_push_even
|
||||
* @param ctx 推流器指针
|
||||
* @param cb 回调函数指针,不得为null
|
||||
* @param user_data 用户数据指针
|
||||
* Set the callback for the streaming being abnormally interrupted
|
||||
* @param ctx Pusher pointer
|
||||
* @param cb Callback function pointer, must not be null
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:9e11a215]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_pusher_set_on_shutdown(mk_pusher ctx, on_mk_push_event cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_pusher_set_on_shutdown2(mk_pusher ctx, on_mk_push_event cb, void *user_data, on_user_data_free user_data_free);
|
||||
|
||||
@@ -17,19 +17,28 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////flv录制/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////flv录制///////////////////////////////////////////// [AUTO-TRANSLATED:a084663f]
|
||||
// /////////////////////////////////////////flv录制/////////////////////////////////////////////
|
||||
|
||||
typedef struct mk_flv_recorder_t *mk_flv_recorder;
|
||||
|
||||
/**
|
||||
* 创建flv录制器
|
||||
* @return
|
||||
* Create flv recorder
|
||||
* @return
|
||||
|
||||
* [AUTO-TRANSLATED:7582cde1]
|
||||
*/
|
||||
API_EXPORT mk_flv_recorder API_CALL mk_flv_recorder_create();
|
||||
|
||||
/**
|
||||
* 释放flv录制器
|
||||
* @param ctx
|
||||
* Release flv recorder
|
||||
* @param ctx
|
||||
|
||||
* [AUTO-TRANSLATED:c33c76bb]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_flv_recorder_release(mk_flv_recorder ctx);
|
||||
|
||||
@@ -41,10 +50,20 @@ API_EXPORT void API_CALL mk_flv_recorder_release(mk_flv_recorder ctx);
|
||||
* @param stream 绑定的RtmpMediaSource的 stream名
|
||||
* @param file_path 文件存放地址
|
||||
* @return 0:开始超过,-1:失败,打开文件失败或该RtmpMediaSource不存在
|
||||
* Start recording flv
|
||||
* @param ctx flv recorder
|
||||
* @param vhost virtual host
|
||||
* @param app app name of the bound RtmpMediaSource
|
||||
* @param stream stream name of the bound RtmpMediaSource
|
||||
* @param file_path file storage address
|
||||
* @return 0: start exceeds, -1: failure, file opening fails or the RtmpMediaSource does not exist
|
||||
|
||||
* [AUTO-TRANSLATED:194cf3de]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *vhost, const char *app, const char *stream, const char *file_path);
|
||||
|
||||
///////////////////////////////////////////hls/mp4录制/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////hls/mp4录制///////////////////////////////////////////// [AUTO-TRANSLATED:99c61c68]
|
||||
// /////////////////////////////////////////hls/mp4录制/////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 获取录制状态
|
||||
@@ -53,6 +72,14 @@ API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *v
|
||||
* @param app 应用名
|
||||
* @param stream 流id
|
||||
* @return 录制状态,0:未录制, 1:正在录制
|
||||
* Get recording status
|
||||
* @param type 0: hls, 1: MP4
|
||||
* @param vhost virtual host
|
||||
* @param app application name
|
||||
* @param stream stream id
|
||||
* @return recording status, 0: not recording, 1: recording
|
||||
|
||||
* [AUTO-TRANSLATED:0b1d374a]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_recorder_is_recording(int type, const char *vhost, const char *app, const char *stream);
|
||||
|
||||
@@ -65,6 +92,16 @@ API_EXPORT int API_CALL mk_recorder_is_recording(int type, const char *vhost, co
|
||||
* @param customized_path 录像文件保存自定义目录,默认为空或null则自动生成
|
||||
* @param max_second mp4录制最大切片时间,单位秒,置0则采用配置文件配置
|
||||
* @return 1代表成功,0代表失败
|
||||
* Start recording
|
||||
* @param type 0: hls-ts, 1: MP4, 2: hls-fmp4, 3: http-fmp4, 4: http-ts
|
||||
* @param vhost virtual host
|
||||
* @param app application name
|
||||
* @param stream stream id
|
||||
* @param customized_path custom directory for saving recording files, defaults to empty or null, automatically generated
|
||||
* @param max_second maximum slice time for mp4 recording, in seconds, set to 0 to use the configuration file configuration
|
||||
* @return 1 represents success, 0 represents failure
|
||||
|
||||
* [AUTO-TRANSLATED:0a1c8c3e]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_recorder_start(int type, const char *vhost, const char *app, const char *stream, const char *customized_path, size_t max_second);
|
||||
|
||||
@@ -75,6 +112,15 @@ API_EXPORT int API_CALL mk_recorder_start(int type, const char *vhost, const cha
|
||||
* @param app 应用名
|
||||
* @param stream 流id
|
||||
* @return 1:成功,0:失败
|
||||
* Stop recording
|
||||
* @param type 0: hls-ts, 1: MP4, 2: hls-fmp4, 3: http-fmp4, 4: http-ts
|
||||
* @param vhost virtual host
|
||||
* @param app application name
|
||||
* @param stream stream id
|
||||
* @return 1: success, 0: failure
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:df1638e7]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_recorder_stop(int type, const char *vhost, const char *app, const char *stream);
|
||||
|
||||
|
||||
@@ -22,12 +22,22 @@ typedef struct mk_rtp_server_t *mk_rtp_server;
|
||||
* @param tcp_mode tcp模式(0: 不监听端口 1: 监听端口 2: 主动连接到服务端)
|
||||
* @param stream_id 该端口绑定的流id
|
||||
* @return
|
||||
* Create GB28181 RTP server
|
||||
* @param port Listening port, 0 for random
|
||||
* @param tcp_mode tcp mode (0: not listening to port 1: listening to port 2: actively connect to the server)
|
||||
* @param stream_id Stream id bound to this port
|
||||
* @return
|
||||
|
||||
* [AUTO-TRANSLATED:0c5fd548]
|
||||
*/
|
||||
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int tcp_mode, const char *stream_id);
|
||||
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create2(uint16_t port, int tcp_mode, const char *vhost, const char *app, const char *stream_id);
|
||||
|
||||
/**
|
||||
* TCP 主动模式时连接到服务器是否成功的回调
|
||||
* Callback for whether the connection to the server is successful in TCP active mode
|
||||
|
||||
* [AUTO-TRANSLATED:752e915a]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_rtp_server_connected)(void *user_data, int err, const char *what, int sys_err);
|
||||
|
||||
@@ -39,6 +49,15 @@ typedef void(API_CALL *on_mk_rtp_server_connected)(void *user_data, int err, con
|
||||
* @param cb 连接到服务器是否成功的回调
|
||||
* @param user_data 用户数据指针
|
||||
* @return
|
||||
* Connect to the server in TCP active mode
|
||||
* @param @param ctx Server object
|
||||
* @param dst_url Server address
|
||||
* @param dst_port Server port
|
||||
* @param cb Callback for whether the connection to the server is successful
|
||||
* @param user_data User data pointer
|
||||
* @return
|
||||
|
||||
* [AUTO-TRANSLATED:e827d45a]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtp_server_connect(mk_rtp_server ctx, const char *dst_url, uint16_t dst_port, on_mk_rtp_server_connected cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_rtp_server_connect2(mk_rtp_server ctx, const char *dst_url, uint16_t dst_port, on_mk_rtp_server_connected cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -46,6 +65,10 @@ API_EXPORT void API_CALL mk_rtp_server_connect2(mk_rtp_server ctx, const char *d
|
||||
/**
|
||||
* 销毁GB28181 RTP 服务器
|
||||
* @param ctx 服务器对象
|
||||
* Destroy GB28181 RTP server
|
||||
* @param ctx Server object
|
||||
|
||||
* [AUTO-TRANSLATED:828e02f0]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtp_server_release(mk_rtp_server ctx);
|
||||
|
||||
@@ -53,12 +76,21 @@ API_EXPORT void API_CALL mk_rtp_server_release(mk_rtp_server ctx);
|
||||
* 获取本地监听的端口号
|
||||
* @param ctx 服务器对象
|
||||
* @return 端口号
|
||||
* Get the local listening port number
|
||||
* @param ctx Server object
|
||||
* @return Port number
|
||||
|
||||
* [AUTO-TRANSLATED:90fe5d22]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_rtp_server_port(mk_rtp_server ctx);
|
||||
|
||||
/**
|
||||
* GB28181 RTP 服务器接收流超时时触发
|
||||
* @param user_data 用户数据指针
|
||||
* Triggered when the GB28181 RTP server receives a stream timeout
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:04d56f24]
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_rtp_server_detach)(void *user_data);
|
||||
|
||||
@@ -67,6 +99,13 @@ typedef void(API_CALL *on_mk_rtp_server_detach)(void *user_data);
|
||||
* @param ctx 服务器对象
|
||||
* @param cb 回调函数
|
||||
* @param user_data 回调函数用户数据指针
|
||||
* Listen for B28181 RTP server receiving stream timeout events
|
||||
* @param ctx Server object
|
||||
* @param cb Callback function
|
||||
* @param user_data Callback function user data pointer
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:a88c239f]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_rtp_server_set_on_detach(mk_rtp_server ctx, on_mk_rtp_server_detach cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_rtp_server_set_on_detach2(mk_rtp_server ctx, on_mk_rtp_server_detach cb, void *user_data, on_user_data_free user_data_free);
|
||||
|
||||
@@ -29,6 +29,14 @@ typedef void(API_CALL *on_mk_buffer_free)(void *user_data, void *data);
|
||||
* @param cb 数据指针free回调函数,该参数置空时,内部会拷贝数据
|
||||
* @param user_data 数据指针free回调函数on_mk_buffer_free第一个参数
|
||||
* @return buffer对象
|
||||
* Create a buffer object
|
||||
* @param data Data pointer
|
||||
* @param len Data length
|
||||
* @param cb Data pointer free callback function. This parameter is set to null, the data will be copied internally
|
||||
* @param user_data The first parameter of the data pointer free callback function on_mk_buffer_free
|
||||
* @return buffer object
|
||||
|
||||
* [AUTO-TRANSLATED:933f9ad8]
|
||||
*/
|
||||
API_EXPORT mk_buffer API_CALL mk_buffer_from_char(const char *data, size_t len, on_mk_buffer_free cb, void *user_data);
|
||||
API_EXPORT mk_buffer API_CALL mk_buffer_from_char2(const char *data, size_t len, on_mk_buffer_free cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -38,7 +46,8 @@ API_EXPORT const char* API_CALL mk_buffer_get_data(mk_buffer buffer);
|
||||
API_EXPORT size_t API_CALL mk_buffer_get_size(mk_buffer buffer);
|
||||
|
||||
///////////////////////////////////////////SockInfo/////////////////////////////////////////////
|
||||
//SockInfo对象的C映射
|
||||
// SockInfo对象的C映射 [AUTO-TRANSLATED:6bc64f0f]
|
||||
// C mapping of SockInfo object
|
||||
typedef struct mk_sock_info_t *mk_sock_info;
|
||||
|
||||
//SockInfo::get_peer_ip()
|
||||
@@ -52,24 +61,28 @@ API_EXPORT uint16_t API_CALL mk_sock_info_local_port(const mk_sock_info ctx);
|
||||
|
||||
#ifndef SOCK_INFO_API_RENAME
|
||||
#define SOCK_INFO_API_RENAME
|
||||
//mk_tcp_session对象转换成mk_sock_info对象后再获取网络相关信息
|
||||
// mk_tcp_session对象转换成mk_sock_info对象后再获取网络相关信息 [AUTO-TRANSLATED:bd727f26]
|
||||
// Get network information after converting mk_tcp_session object to mk_sock_info object
|
||||
#define mk_tcp_session_peer_ip(x,buf) mk_sock_info_peer_ip(mk_tcp_session_get_sock_info(x),buf)
|
||||
#define mk_tcp_session_local_ip(x,buf) mk_sock_info_local_ip(mk_tcp_session_get_sock_info(x),buf)
|
||||
#define mk_tcp_session_peer_port(x) mk_sock_info_peer_port(mk_tcp_session_get_sock_info(x))
|
||||
#define mk_tcp_session_local_port(x) mk_sock_info_local_port(mk_tcp_session_get_sock_info(x))
|
||||
|
||||
//mk_tcp_client对象转换成mk_sock_info对象后再获取网络相关信息
|
||||
// mk_tcp_client对象转换成mk_sock_info对象后再获取网络相关信息 [AUTO-TRANSLATED:e642eaac]
|
||||
// Get network information after converting mk_tcp_client object to mk_sock_info object
|
||||
#define mk_tcp_client_peer_ip(x,buf) mk_sock_info_peer_ip(mk_tcp_client_get_sock_info(x),buf)
|
||||
#define mk_tcp_client_local_ip(x,buf) mk_sock_info_local_ip(mk_tcp_client_get_sock_info(x),buf)
|
||||
#define mk_tcp_client_peer_port(x) mk_sock_info_peer_port(mk_tcp_client_get_sock_info(x))
|
||||
#define mk_tcp_client_local_port(x) mk_sock_info_local_port(mk_tcp_client_get_sock_info(x))
|
||||
#endif
|
||||
///////////////////////////////////////////TcpSession/////////////////////////////////////////////
|
||||
//TcpSession对象的C映射
|
||||
// TcpSession对象的C映射 [AUTO-TRANSLATED:df12e714]
|
||||
// C mapping of TcpSession object
|
||||
typedef struct mk_tcp_session_t *mk_tcp_session;
|
||||
typedef struct mk_tcp_session_ref_t *mk_tcp_session_ref;
|
||||
|
||||
//获取基类指针以便获取其网络相关信息
|
||||
// 获取基类指针以便获取其网络相关信息 [AUTO-TRANSLATED:725bdbd0]
|
||||
// Get the base class pointer to get its network information
|
||||
API_EXPORT mk_sock_info API_CALL mk_tcp_session_get_sock_info(const mk_tcp_session ctx);
|
||||
|
||||
//TcpSession::safeShutdown()
|
||||
@@ -78,24 +91,34 @@ API_EXPORT void API_CALL mk_tcp_session_shutdown(const mk_tcp_session ctx,int er
|
||||
API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx, const char *data, size_t len);
|
||||
API_EXPORT void API_CALL mk_tcp_session_send_buffer(const mk_tcp_session ctx, mk_buffer buffer);
|
||||
|
||||
//切换到该对象所在线程后再TcpSession::send()
|
||||
// 切换到该对象所在线程后再TcpSession::send() [AUTO-TRANSLATED:8a8f72ac]
|
||||
// Switch to the thread where the object is located, then TcpSession::send()
|
||||
API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx, const char *data, size_t len);
|
||||
API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ctx, mk_buffer buffer);
|
||||
|
||||
//创建mk_tcp_session的强引用
|
||||
// 创建mk_tcp_session的强引用 [AUTO-TRANSLATED:9dff998d]
|
||||
// Create a strong reference to mk_tcp_session
|
||||
API_EXPORT mk_tcp_session_ref API_CALL mk_tcp_session_ref_from(const mk_tcp_session ctx);
|
||||
//删除mk_tcp_session的强引用
|
||||
// 删除mk_tcp_session的强引用 [AUTO-TRANSLATED:583848b0]
|
||||
// Delete the strong reference to mk_tcp_session
|
||||
API_EXPORT void mk_tcp_session_ref_release(const mk_tcp_session_ref ref);
|
||||
//根据强引用获取mk_tcp_session
|
||||
// 根据强引用获取mk_tcp_session [AUTO-TRANSLATED:4bf1f7a0]
|
||||
// Get mk_tcp_session according to the strong reference
|
||||
API_EXPORT mk_tcp_session mk_tcp_session_from_ref(const mk_tcp_session_ref ref);
|
||||
|
||||
///////////////////////////////////////////自定义tcp服务/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////自定义tcp服务///////////////////////////////////////////// [AUTO-TRANSLATED:25f12aa6]
|
||||
// /////////////////////////////////////////Custom tcp service/////////////////////////////////////////////
|
||||
|
||||
typedef struct {
|
||||
/**
|
||||
* 收到mk_tcp_session创建对象
|
||||
* @param server_port 服务器端口号
|
||||
* @param session 会话处理对象
|
||||
* Receive mk_tcp_session create object
|
||||
* @param server_port Server port number
|
||||
* @param session Session processing object
|
||||
|
||||
* [AUTO-TRANSLATED:58183e28]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_session_create)(uint16_t server_port,mk_tcp_session session);
|
||||
|
||||
@@ -104,6 +127,12 @@ typedef struct {
|
||||
* @param server_port 服务器端口号
|
||||
* @param session 会话处理对象
|
||||
* @param buffer 数据
|
||||
* Receive data sent by the client
|
||||
* @param server_port Server port number
|
||||
* @param session Session processing object
|
||||
* @param buffer Data
|
||||
|
||||
* [AUTO-TRANSLATED:ff2132fa]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_session_data)(uint16_t server_port,mk_tcp_session session, mk_buffer buffer);
|
||||
|
||||
@@ -111,6 +140,11 @@ typedef struct {
|
||||
* 每隔2秒的定时器,用于管理超时等任务
|
||||
* @param server_port 服务器端口号
|
||||
* @param session 会话处理对象
|
||||
* Timer every 2 seconds, used to manage timeout tasks
|
||||
* @param server_port Server port number
|
||||
* @param session Session processing object
|
||||
|
||||
* [AUTO-TRANSLATED:5d36ea59]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_session_manager)(uint16_t server_port,mk_tcp_session session);
|
||||
|
||||
@@ -120,19 +154,30 @@ typedef struct {
|
||||
* @param session 会话处理对象
|
||||
* @param code 错误代码
|
||||
* @param msg 错误提示
|
||||
* Generally triggered by client disconnecting tcp
|
||||
* @param server_port Server port number
|
||||
* @param session Session processing object
|
||||
* @param code Error code
|
||||
* @param msg Error message
|
||||
|
||||
* [AUTO-TRANSLATED:a2e6ce8b]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_session_disconnect)(uint16_t server_port,mk_tcp_session session,int code,const char *msg);
|
||||
} mk_tcp_session_events;
|
||||
|
||||
|
||||
typedef enum {
|
||||
//普通的tcp
|
||||
// 普通的tcp [AUTO-TRANSLATED:b4035d33]
|
||||
// Ordinary tcp
|
||||
mk_type_tcp = 0,
|
||||
//ssl类型的tcp
|
||||
// ssl类型的tcp [AUTO-TRANSLATED:88792584]
|
||||
// ssl type tcp
|
||||
mk_type_ssl = 1,
|
||||
//基于websocket的连接
|
||||
// 基于websocket的连接 [AUTO-TRANSLATED:01f3223d]
|
||||
// Websocket based connection
|
||||
mk_type_ws = 2,
|
||||
//基于ssl websocket的连接
|
||||
// 基于ssl websocket的连接 [AUTO-TRANSLATED:86411da9]
|
||||
// Ssl websocket based connection
|
||||
mk_type_wss = 3
|
||||
}mk_tcp_type;
|
||||
|
||||
@@ -141,6 +186,12 @@ typedef enum {
|
||||
* 该函数只对mk_tcp_server_server_start启动的服务类型有效
|
||||
* @param session 会话对象
|
||||
* @param user_data 用户数据指针
|
||||
* Attach user data to the tcp session object
|
||||
* This function is only valid for services started by mk_tcp_server_server_start
|
||||
* @param session Session object
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:272bd460]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_tcp_session_set_user_data(mk_tcp_session session, void *user_data);
|
||||
API_EXPORT void API_CALL mk_tcp_session_set_user_data2(mk_tcp_session session, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -150,6 +201,12 @@ API_EXPORT void API_CALL mk_tcp_session_set_user_data2(mk_tcp_session session, v
|
||||
* 该函数只对mk_tcp_server_server_start启动的服务类型有效
|
||||
* @param session tcp会话对象
|
||||
* @return 用户数据指针
|
||||
* Get the user data attached to the tcp session object
|
||||
* This function is only valid for services started by mk_tcp_server_server_start
|
||||
* @param session Tcp session object
|
||||
* @return User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:8047a5a4]
|
||||
*/
|
||||
API_EXPORT void* API_CALL mk_tcp_session_get_user_data(mk_tcp_session session);
|
||||
|
||||
@@ -157,19 +214,29 @@ API_EXPORT void* API_CALL mk_tcp_session_get_user_data(mk_tcp_session session);
|
||||
* 开启tcp服务器
|
||||
* @param port 监听端口号,0则为随机
|
||||
* @param type 服务器类型
|
||||
* Start tcp server
|
||||
* @param port Listening port number, 0 is random
|
||||
* @param type Server type
|
||||
|
||||
* [AUTO-TRANSLATED:ad27f0ed]
|
||||
*/
|
||||
API_EXPORT uint16_t API_CALL mk_tcp_server_start(uint16_t port, mk_tcp_type type);
|
||||
|
||||
/**
|
||||
* 监听tcp服务器事件
|
||||
* Listen for tcp server events
|
||||
|
||||
* [AUTO-TRANSLATED:7ca82a56]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_tcp_server_events_listen(const mk_tcp_session_events *events);
|
||||
|
||||
|
||||
///////////////////////////////////////////自定义tcp客户端/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////自定义tcp客户端///////////////////////////////////////////// [AUTO-TRANSLATED:e5ae198e]
|
||||
// /////////////////////////////////////////Custom tcp client/////////////////////////////////////////////
|
||||
|
||||
typedef struct mk_tcp_client_t *mk_tcp_client;
|
||||
//获取基类指针以便获取其网络相关信息
|
||||
// 获取基类指针以便获取其网络相关信息 [AUTO-TRANSLATED:725bdbd0]
|
||||
// Get the base class pointer to get its network information
|
||||
API_EXPORT mk_sock_info API_CALL mk_tcp_client_get_sock_info(const mk_tcp_client ctx);
|
||||
|
||||
typedef struct {
|
||||
@@ -178,6 +245,12 @@ typedef struct {
|
||||
* @param client tcp客户端
|
||||
* @param code 0为连接成功,否则为失败原因
|
||||
* @param msg 连接失败错误提示
|
||||
* Tcp client connects to server successfully or fails callback
|
||||
* @param client Tcp client
|
||||
* @param code 0 for successful connection, otherwise for failure reason
|
||||
* @param msg Connection failure error message
|
||||
|
||||
* [AUTO-TRANSLATED:2b38e72a]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_client_connect)(mk_tcp_client client,int code,const char *msg);
|
||||
|
||||
@@ -187,6 +260,13 @@ typedef struct {
|
||||
* @param client tcp客户端
|
||||
* @param code 错误代码
|
||||
* @param msg 错误提示
|
||||
* Tcp client disconnects from tcp server callback
|
||||
* Generally caused by eof event
|
||||
* @param client Tcp client
|
||||
* @param code Error code
|
||||
* @param msg Error message
|
||||
|
||||
* [AUTO-TRANSLATED:5658c1c5]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_client_disconnect)(mk_tcp_client client,int code,const char *msg);
|
||||
|
||||
@@ -194,12 +274,21 @@ typedef struct {
|
||||
* 收到tcp服务器发来的数据
|
||||
* @param client tcp客户端
|
||||
* @param buffer 数据
|
||||
* Receive data sent by the tcp server
|
||||
* @param client Tcp client
|
||||
* @param buffer Data
|
||||
|
||||
* [AUTO-TRANSLATED:4a225334]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_client_data)(mk_tcp_client client, mk_buffer buffer);
|
||||
|
||||
/**
|
||||
* 每隔2秒的定时器,用于管理超时等任务
|
||||
* @param client tcp客户端
|
||||
* Timer every 2 seconds, used to manage timeout tasks
|
||||
* @param client Tcp client
|
||||
|
||||
* [AUTO-TRANSLATED:05f637ef]
|
||||
*/
|
||||
void (API_CALL *on_mk_tcp_client_manager)(mk_tcp_client client);
|
||||
} mk_tcp_client_events;
|
||||
@@ -210,12 +299,23 @@ typedef struct {
|
||||
* @param user_data 用户数据指针
|
||||
* @param type 客户端类型
|
||||
* @return 客户端对象
|
||||
* Create tcp client
|
||||
* @param events Callback function structure
|
||||
* @param user_data User data pointer
|
||||
* @param type Client type
|
||||
* @return Client object
|
||||
|
||||
* [AUTO-TRANSLATED:01191226]
|
||||
*/
|
||||
API_EXPORT mk_tcp_client API_CALL mk_tcp_client_create(mk_tcp_client_events *events, mk_tcp_type type);
|
||||
|
||||
/**
|
||||
* 释放tcp客户端
|
||||
* @param ctx 客户端对象
|
||||
* Release the tcp client
|
||||
* @param ctx Client object
|
||||
|
||||
* [AUTO-TRANSLATED:b3a75d23]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_tcp_client_release(mk_tcp_client ctx);
|
||||
|
||||
@@ -225,6 +325,13 @@ API_EXPORT void API_CALL mk_tcp_client_release(mk_tcp_client ctx);
|
||||
* @param host 服务器ip或域名
|
||||
* @param port 服务器端口号
|
||||
* @param time_out_sec 超时时间
|
||||
* Initiate connection
|
||||
* @param ctx Client object
|
||||
* @param host Server ip or domain name
|
||||
* @param port Server port number
|
||||
* @param time_out_sec Timeout time
|
||||
|
||||
* [AUTO-TRANSLATED:dd45e0fa]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_tcp_client_connect(mk_tcp_client ctx, const char *host, uint16_t port, float time_out_sec);
|
||||
|
||||
@@ -234,6 +341,13 @@ API_EXPORT void API_CALL mk_tcp_client_connect(mk_tcp_client ctx, const char *ho
|
||||
* @param ctx 客户端对象
|
||||
* @param data 数据指针
|
||||
* @param len 数据长度,等于0时,内部通过strlen获取
|
||||
* Non-thread-safe data sending
|
||||
* Developers can call this function if they can ensure that it is within the network thread of this object
|
||||
* @param ctx Client object
|
||||
* @param data Data pointer
|
||||
* @param len Data length, 0 means get it by strlen internally
|
||||
|
||||
* [AUTO-TRANSLATED:a5e2ac86]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_tcp_client_send(mk_tcp_client ctx, const char *data, int len);
|
||||
API_EXPORT void API_CALL mk_tcp_client_send_buffer(mk_tcp_client ctx, mk_buffer buffer);
|
||||
@@ -243,6 +357,12 @@ API_EXPORT void API_CALL mk_tcp_client_send_buffer(mk_tcp_client ctx, mk_buffer
|
||||
* @param ctx 客户端对象
|
||||
* @param data 数据指针
|
||||
* @param len 数据长度,等于0时,内部通过strlen获取
|
||||
* Send data after switching to the network thread of this object
|
||||
* @param ctx Client object
|
||||
* @param data Data pointer
|
||||
* @param len Data length, 0 means get it by strlen internally
|
||||
|
||||
* [AUTO-TRANSLATED:95dc75f8]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_tcp_client_send_safe(mk_tcp_client ctx, const char *data, int len);
|
||||
API_EXPORT void API_CALL mk_tcp_client_send_buffer_safe(mk_tcp_client ctx, mk_buffer buffer);
|
||||
@@ -251,6 +371,11 @@ API_EXPORT void API_CALL mk_tcp_client_send_buffer_safe(mk_tcp_client ctx, mk_bu
|
||||
* 客户端附着用户数据
|
||||
* @param ctx 客户端对象
|
||||
* @param user_data 用户数据指针
|
||||
* Client attaches user data
|
||||
* @param ctx Client object
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:a9d4840b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_tcp_client_set_user_data(mk_tcp_client ctx, void *user_data);
|
||||
API_EXPORT void API_CALL mk_tcp_client_set_user_data2(mk_tcp_client ctx, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -259,6 +384,12 @@ API_EXPORT void API_CALL mk_tcp_client_set_user_data2(mk_tcp_client ctx, void *u
|
||||
* 获取客户端对象上附着的用户数据
|
||||
* @param ctx 客户端对象
|
||||
* @return 用户数据指针
|
||||
* Get the user data attached to the client object
|
||||
* @param ctx Client object
|
||||
* @return User data pointer
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:7f74985b]
|
||||
*/
|
||||
API_EXPORT void* API_CALL mk_tcp_client_get_user_data(mk_tcp_client ctx);
|
||||
|
||||
|
||||
@@ -19,13 +19,19 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////事件线程/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////事件线程///////////////////////////////////////////// [AUTO-TRANSLATED:6d564b3b]
|
||||
// /////////////////////////////////////////事件线程/////////////////////////////////////////////
|
||||
typedef struct mk_thread_t *mk_thread;
|
||||
|
||||
/**
|
||||
* 获取tcp会话对象所在事件线程
|
||||
* @param ctx tcp会话对象
|
||||
* @return 对象所在事件线程
|
||||
* Get the event thread where the tcp session object is located
|
||||
* @param ctx tcp session object
|
||||
* @return The event thread where the object is located
|
||||
|
||||
* [AUTO-TRANSLATED:17da57ec]
|
||||
*/
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_tcp_session(mk_tcp_session ctx);
|
||||
|
||||
@@ -33,6 +39,11 @@ API_EXPORT mk_thread API_CALL mk_thread_from_tcp_session(mk_tcp_session ctx);
|
||||
* 获取tcp客户端对象所在事件线程
|
||||
* @param ctx tcp客户端
|
||||
* @return 对象所在事件线程
|
||||
* Get the event thread where the tcp client object is located
|
||||
* @param ctx tcp client
|
||||
* @return The event thread where the object is located
|
||||
|
||||
* [AUTO-TRANSLATED:15d4174b]
|
||||
*/
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_tcp_client(mk_tcp_client ctx);
|
||||
|
||||
@@ -41,6 +52,12 @@ API_EXPORT mk_thread API_CALL mk_thread_from_tcp_client(mk_tcp_client ctx);
|
||||
* 如果在事件线程内执行此函数将返回本事件线程
|
||||
* 事件线程指的是定时器、网络io事件线程
|
||||
* @return 事件线程
|
||||
* Get an event thread randomly from the event thread pool according to the load balancing algorithm
|
||||
* If this function is executed within the event thread, it will return the current event thread
|
||||
* Event thread refers to timer, network io event thread
|
||||
* @return Event thread
|
||||
|
||||
* [AUTO-TRANSLATED:5da37e1f]
|
||||
*/
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_pool();
|
||||
|
||||
@@ -49,6 +66,12 @@ API_EXPORT mk_thread API_CALL mk_thread_from_pool();
|
||||
* 后台线程本质与事件线程相同,只是优先级更低,同时可以执行短时间的阻塞任务
|
||||
* ZLMediaKit中后台线程用于dns解析、mp4点播时的文件解复用
|
||||
* @return 后台线程
|
||||
* Get a thread randomly from the background thread pool according to the load balancing algorithm
|
||||
* Background threads are essentially the same as event threads, but they have lower priority and can execute short-term blocking tasks
|
||||
* Background threads in ZLMediaKit are used for dns resolution, file demultiplexing during mp4 on-demand
|
||||
* @return Background thread
|
||||
|
||||
* [AUTO-TRANSLATED:3b552537]
|
||||
*/
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_pool_work();
|
||||
|
||||
@@ -60,6 +83,13 @@ typedef struct mk_thread_pool_t *mk_thread_pool;
|
||||
* @param n_thread 线程个数,0时为cpu个数
|
||||
* @param priority 线程优先级,分为PRIORITY_LOWEST = 0,PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_HIGHEST
|
||||
* @return 线程池
|
||||
* Create a thread pool
|
||||
* @param name Thread pool name, for debugging
|
||||
* @param n_thread Number of threads, 0 for the number of cpus
|
||||
* @param priority Thread priority, divided into PRIORITY_LOWEST = 0,PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_HIGHEST
|
||||
* @return Thread pool
|
||||
|
||||
* [AUTO-TRANSLATED:177acea2]
|
||||
*/
|
||||
API_EXPORT mk_thread_pool API_CALL mk_thread_pool_create(const char *name, size_t n_thread, int priority);
|
||||
|
||||
@@ -67,6 +97,11 @@ API_EXPORT mk_thread_pool API_CALL mk_thread_pool_create(const char *name, size_
|
||||
* 销毁线程池
|
||||
* @param pool 线程池
|
||||
* @return 0:成功
|
||||
* Destroy the thread pool
|
||||
* @param pool Thread pool
|
||||
* @return 0: Success
|
||||
|
||||
* [AUTO-TRANSLATED:1f1b3582]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_thread_pool_release(mk_thread_pool pool);
|
||||
|
||||
@@ -74,10 +109,16 @@ API_EXPORT int API_CALL mk_thread_pool_release(mk_thread_pool pool);
|
||||
* 从线程池获取一个线程
|
||||
* @param pool 线程池
|
||||
* @return 线程
|
||||
* Get a thread from the thread pool
|
||||
* @param pool Thread pool
|
||||
* @return Thread
|
||||
|
||||
* [AUTO-TRANSLATED:f47de48e]
|
||||
*/
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_thread_pool(mk_thread_pool pool);
|
||||
|
||||
///////////////////////////////////////////线程切换/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////线程切换///////////////////////////////////////////// [AUTO-TRANSLATED:5fc795bf]
|
||||
// /////////////////////////////////////////线程切换/////////////////////////////////////////////
|
||||
typedef void (API_CALL *on_mk_async)(void *user_data);
|
||||
|
||||
/**
|
||||
@@ -85,6 +126,12 @@ typedef void (API_CALL *on_mk_async)(void *user_data);
|
||||
* @param ctx 事件线程
|
||||
* @param cb 回调函数
|
||||
* @param user_data 用户数据指针
|
||||
* Switch to the event thread and execute asynchronously
|
||||
* @param ctx Event thread
|
||||
* @param cb Callback function
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:55773ed5]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_async_do(mk_thread ctx, on_mk_async cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_async_do2(mk_thread ctx, on_mk_async cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -95,6 +142,13 @@ API_EXPORT void API_CALL mk_async_do2(mk_thread ctx, on_mk_async cb, void *user_
|
||||
* @param ms 延时时间,单位毫秒
|
||||
* @param cb 回调函数
|
||||
* @param user_data 用户数据指针
|
||||
* Switch to the event thread and execute with delay
|
||||
* @param ctx Event thread
|
||||
* @param ms Delay time, in milliseconds
|
||||
* @param cb Callback function
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:35dfdb0e]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_async_do_delay(mk_thread ctx, size_t ms, on_mk_async cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_async_do_delay2(mk_thread ctx, size_t ms, on_mk_async cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -104,15 +158,26 @@ API_EXPORT void API_CALL mk_async_do_delay2(mk_thread ctx, size_t ms, on_mk_asyn
|
||||
* @param ctx 事件线程
|
||||
* @param cb 回调函数
|
||||
* @param user_data 用户数据指针
|
||||
* Switch to the event thread and execute synchronously
|
||||
* @param ctx Event thread
|
||||
* @param cb Callback function
|
||||
* @param user_data User data pointer
|
||||
|
||||
* [AUTO-TRANSLATED:1326dfb2]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_sync_do(mk_thread ctx, on_mk_async cb, void *user_data);
|
||||
|
||||
///////////////////////////////////////////定时器/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////定时器///////////////////////////////////////////// [AUTO-TRANSLATED:7f76781c]
|
||||
// /////////////////////////////////////////定时器/////////////////////////////////////////////
|
||||
typedef struct mk_timer_t *mk_timer;
|
||||
|
||||
/**
|
||||
* 定时器触发事件
|
||||
* @return 下一次触发延时(单位毫秒),返回0则不再重复
|
||||
* Timer trigger event
|
||||
* @return Next trigger delay (in milliseconds), return 0 to stop repeating
|
||||
|
||||
* [AUTO-TRANSLATED:f8846f56]
|
||||
*/
|
||||
typedef uint64_t (API_CALL *on_mk_timer)(void *user_data);
|
||||
|
||||
@@ -123,6 +188,14 @@ typedef uint64_t (API_CALL *on_mk_timer)(void *user_data);
|
||||
* @param cb 回调函数
|
||||
* @param user_data 用户数据指针
|
||||
* @return 定时器对象
|
||||
* Create a timer
|
||||
* @param ctx Thread object
|
||||
* @param delay_ms Execution delay, in milliseconds
|
||||
* @param cb Callback function
|
||||
* @param user_data User data pointer
|
||||
* @return Timer object
|
||||
|
||||
* [AUTO-TRANSLATED:2d47864a]
|
||||
*/
|
||||
API_EXPORT mk_timer API_CALL mk_timer_create(mk_thread ctx, uint64_t delay_ms, on_mk_timer cb, void *user_data);
|
||||
API_EXPORT mk_timer API_CALL mk_timer_create2(mk_thread ctx, uint64_t delay_ms, on_mk_timer cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -130,31 +203,49 @@ API_EXPORT mk_timer API_CALL mk_timer_create2(mk_thread ctx, uint64_t delay_ms,
|
||||
/**
|
||||
* 销毁和取消定时器
|
||||
* @param ctx 定时器对象
|
||||
* Destroy and cancel the timer
|
||||
* @param ctx Timer object
|
||||
|
||||
* [AUTO-TRANSLATED:3fdb8534]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_timer_release(mk_timer ctx);
|
||||
|
||||
///////////////////////////////////////////信号量/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////信号量///////////////////////////////////////////// [AUTO-TRANSLATED:f41da57a]
|
||||
// /////////////////////////////////////////信号量/////////////////////////////////////////////
|
||||
|
||||
typedef struct mk_sem_t *mk_sem;
|
||||
|
||||
/**
|
||||
* 创建信号量
|
||||
* Create a semaphore
|
||||
|
||||
* [AUTO-TRANSLATED:dcd83058]
|
||||
*/
|
||||
API_EXPORT mk_sem API_CALL mk_sem_create();
|
||||
|
||||
/**
|
||||
* 销毁信号量
|
||||
* Destroy the semaphore
|
||||
|
||||
* [AUTO-TRANSLATED:b298797b]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_sem_release(mk_sem sem);
|
||||
|
||||
/**
|
||||
* 信号量加n
|
||||
* Increase the semaphore by n
|
||||
|
||||
* [AUTO-TRANSLATED:1f455c5d]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_sem_post(mk_sem sem, size_t n);
|
||||
|
||||
/**
|
||||
* 信号量减1
|
||||
* @param sem
|
||||
* Decrease the semaphore by 1
|
||||
* @param sem
|
||||
|
||||
* [AUTO-TRANSLATED:626595d8]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_sem_wait(mk_sem sem);
|
||||
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//音视频轨道
|
||||
// 音视频轨道 [AUTO-TRANSLATED:cec3b225]
|
||||
// Audio and video track
|
||||
typedef struct mk_track_t *mk_track;
|
||||
//输出frame回调
|
||||
// 输出frame回调 [AUTO-TRANSLATED:4daee75b]
|
||||
// Output frame callback
|
||||
typedef void(API_CALL *on_mk_frame_out)(void *user_data, mk_frame frame);
|
||||
|
||||
//track创建参数
|
||||
// track创建参数 [AUTO-TRANSLATED:31a3c487]
|
||||
// Track creation parameters
|
||||
typedef union {
|
||||
struct {
|
||||
int width;
|
||||
@@ -42,12 +45,22 @@ typedef union {
|
||||
* @param codec_id 请参考MKCodecXXX 常量定义
|
||||
* @param args 视频或音频参数
|
||||
* @return track对象引用
|
||||
* Create a track object reference
|
||||
* @param codec_id Please refer to the MKCodecXXX constant definition
|
||||
* @param args Video or audio parameters
|
||||
* @return Track object reference
|
||||
|
||||
* [AUTO-TRANSLATED:d53f3578]
|
||||
*/
|
||||
API_EXPORT mk_track API_CALL mk_track_create(int codec_id, codec_args *args);
|
||||
|
||||
/**
|
||||
* 减引用track对象
|
||||
* @param track track对象
|
||||
* Decrement the reference count of the track object
|
||||
* @param track Track object
|
||||
|
||||
* [AUTO-TRANSLATED:50d6180e]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_track_unref(mk_track track);
|
||||
|
||||
@@ -55,36 +68,59 @@ API_EXPORT void API_CALL mk_track_unref(mk_track track);
|
||||
* 引用track对象
|
||||
* @param track track对象
|
||||
* @return 新的track引用对象
|
||||
* Increment the reference count of the track object
|
||||
* @param track Track object
|
||||
* @return New track reference object
|
||||
|
||||
* [AUTO-TRANSLATED:6492cbb1]
|
||||
*/
|
||||
API_EXPORT mk_track API_CALL mk_track_ref(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取track 编码codec类型,请参考MKCodecXXX定义
|
||||
* Get the track encoding codec type, please refer to the MKCodecXXX definition
|
||||
|
||||
* [AUTO-TRANSLATED:f90ed835]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_codec_id(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取编码codec名称
|
||||
* Get the encoding codec name
|
||||
|
||||
* [AUTO-TRANSLATED:f46d430e]
|
||||
*/
|
||||
API_EXPORT const char* API_CALL mk_track_codec_name(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取比特率信息
|
||||
* Get the bitrate information
|
||||
|
||||
* [AUTO-TRANSLATED:de8b48fe]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_bit_rate(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取轨道是否已就绪,1: 已就绪,0:未就绪
|
||||
* Get whether the track is ready, 1: ready, 0: not ready
|
||||
|
||||
* [AUTO-TRANSLATED:926d1a1a]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_ready(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取累计帧数
|
||||
* Get the cumulative frame count
|
||||
|
||||
* [AUTO-TRANSLATED:c30a45c6]
|
||||
*/
|
||||
API_EXPORT uint64_t API_CALL mk_track_frames(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取时间,单位毫秒
|
||||
* Get the time, in milliseconds
|
||||
|
||||
* [AUTO-TRANSLATED:37b0e1f9]
|
||||
*/
|
||||
API_EXPORT uint64_t API_CALL mk_track_duration(mk_track track);
|
||||
|
||||
@@ -93,6 +129,12 @@ API_EXPORT uint64_t API_CALL mk_track_duration(mk_track track);
|
||||
* @param track track对象
|
||||
* @param cb frame输出回调
|
||||
* @param user_data frame输出回调用户指针参数
|
||||
* Listen for frame output events
|
||||
* @param track Track object
|
||||
* @param cb Frame output callback
|
||||
* @param user_data Frame output callback user pointer parameter
|
||||
|
||||
* [AUTO-TRANSLATED:5cbd8347]
|
||||
*/
|
||||
API_EXPORT void *API_CALL mk_track_add_delegate(mk_track track, on_mk_frame_out cb, void *user_data);
|
||||
API_EXPORT void *API_CALL mk_track_add_delegate2(mk_track track, on_mk_frame_out cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -101,61 +143,99 @@ API_EXPORT void *API_CALL mk_track_add_delegate2(mk_track track, on_mk_frame_out
|
||||
* 取消frame输出事件监听
|
||||
* @param track track对象
|
||||
* @param tag mk_track_add_delegate返回值
|
||||
* Cancel the frame output event listener
|
||||
* @param track Track object
|
||||
* @param tag Return value of mk_track_add_delegate
|
||||
|
||||
* [AUTO-TRANSLATED:83a9fd9f]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_track_del_delegate(mk_track track, void *tag);
|
||||
|
||||
/**
|
||||
* 输入frame到track,通常你不需要调用此api
|
||||
* Input frame to track, you usually don't need to call this api
|
||||
|
||||
* [AUTO-TRANSLATED:ca3b03e8]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_track_input_frame(mk_track track, mk_frame frame);
|
||||
|
||||
/**
|
||||
* track是否为视频
|
||||
* Whether the track is video
|
||||
|
||||
* [AUTO-TRANSLATED:22573187]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_is_video(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取视频宽度
|
||||
* Get the video width
|
||||
|
||||
* [AUTO-TRANSLATED:06a849c6]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_video_width(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取视频高度
|
||||
* Get the video height
|
||||
|
||||
* [AUTO-TRANSLATED:27b5ed6e]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_video_height(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取视频帧率
|
||||
* Get the video frame rate
|
||||
|
||||
* [AUTO-TRANSLATED:3c19a388]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_video_fps(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取视频累计关键帧数
|
||||
* Get the cumulative number of video keyframes
|
||||
|
||||
* [AUTO-TRANSLATED:0e70e666]
|
||||
*/
|
||||
API_EXPORT uint64_t API_CALL mk_track_video_key_frames(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取视频GOP关键帧间隔
|
||||
* Get the video GOP keyframe interval
|
||||
|
||||
* [AUTO-TRANSLATED:ea8d3729]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_video_gop_size(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取视频累计关键帧间隔(毫秒)
|
||||
* Get the cumulative video keyframe interval (milliseconds)
|
||||
|
||||
* [AUTO-TRANSLATED:194b1e80]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_video_gop_interval_ms(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取音频采样率
|
||||
* Get the audio sample rate
|
||||
|
||||
* [AUTO-TRANSLATED:bf0e046b]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_audio_sample_rate(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取音频通道数
|
||||
* Get the number of audio channels
|
||||
|
||||
* [AUTO-TRANSLATED:ccb5d776]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_audio_channel(mk_track track);
|
||||
|
||||
/**
|
||||
* 获取音频位数,一般为16bit
|
||||
* Get the audio bit depth, usually 16bit
|
||||
|
||||
* [AUTO-TRANSLATED:11e36409]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_track_audio_sample_bit(mk_track track);
|
||||
|
||||
|
||||
@@ -19,17 +19,24 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//解码器对象
|
||||
// 解码器对象 [AUTO-TRANSLATED:14f75955]
|
||||
// cpp
|
||||
// Decoder object
|
||||
typedef struct mk_decoder_t *mk_decoder;
|
||||
//解码后的frame
|
||||
// 解码后的frame [AUTO-TRANSLATED:acb96f85]
|
||||
// Decoded frame
|
||||
typedef struct mk_frame_pix_t *mk_frame_pix;
|
||||
//SwsContext的包装
|
||||
// SwsContext的包装 [AUTO-TRANSLATED:4f7ae38f]
|
||||
// SwsContext wrapper
|
||||
typedef struct mk_swscale_t *mk_swscale;
|
||||
//FFmpeg原始解码帧对象
|
||||
// FFmpeg原始解码帧对象 [AUTO-TRANSLATED:ed99009b]
|
||||
// FFmpeg original decoded frame object
|
||||
typedef struct AVFrame AVFrame;
|
||||
//FFmpeg编解码器对象
|
||||
// FFmpeg编解码器对象 [AUTO-TRANSLATED:12b26186]
|
||||
// FFmpeg codec object
|
||||
typedef struct AVCodecContext AVCodecContext;
|
||||
//解码输出回调
|
||||
// 解码输出回调 [AUTO-TRANSLATED:1a380eed]
|
||||
// Decode output callback
|
||||
typedef void(API_CALL *on_mk_decode)(void *user_data, mk_frame_pix frame);
|
||||
|
||||
/**
|
||||
@@ -37,6 +44,12 @@ typedef void(API_CALL *on_mk_decode)(void *user_data, mk_frame_pix frame);
|
||||
* @param track track对象
|
||||
* @param thread_num 解码线程数,0时为自动
|
||||
* @return 返回解码器对象,NULL代表失败
|
||||
* Create decoder
|
||||
* @param track track object
|
||||
* @param thread_num Number of decoding threads, 0 for automatic
|
||||
* @return Returns the decoder object, NULL indicates failure
|
||||
|
||||
* [AUTO-TRANSLATED:d01b3192]
|
||||
*/
|
||||
API_EXPORT mk_decoder API_CALL mk_decoder_create(mk_track track, int thread_num);
|
||||
|
||||
@@ -47,6 +60,14 @@ API_EXPORT mk_decoder API_CALL mk_decoder_create(mk_track track, int thread_num)
|
||||
* @param codec_name_list 偏好的ffmpeg codec name列表,以NULL结尾,譬如:{"libopenh264", "h264_nvdec", NULL};
|
||||
* 在数组中越前,优先级越高;如果指定的codec不存在,或跟mk_track_codec_id类型不匹配时,则使用内部默认codec列表
|
||||
* @return 返回解码器对象,NULL代表失败
|
||||
* Create decoder
|
||||
* @param track track object
|
||||
* @param thread_num Number of decoding threads, 0 for automatic
|
||||
* @param codec_name_list Preferred ffmpeg codec name list, ending with NULL, for example: {"libopenh264", "h264_nvdec", NULL};
|
||||
* The higher the priority in the array, the higher the priority; if the specified codec does not exist, or does not match the mk_track_codec_id type, the internal default codec list will be used
|
||||
* @return Returns the decoder object, NULL indicates failure
|
||||
|
||||
* [AUTO-TRANSLATED:078aba31]
|
||||
*/
|
||||
API_EXPORT mk_decoder API_CALL mk_decoder_create2(mk_track track, int thread_num, const char *codec_name_list[]);
|
||||
|
||||
@@ -54,6 +75,11 @@ API_EXPORT mk_decoder API_CALL mk_decoder_create2(mk_track track, int thread_num
|
||||
* 销毁解码器
|
||||
* @param ctx 解码器对象
|
||||
* @param flush_frame 是否等待所有帧解码成功
|
||||
* Destroy decoder
|
||||
* @param ctx Decoder object
|
||||
* @param flush_frame Whether to wait for all frames to be decoded successfully
|
||||
|
||||
* [AUTO-TRANSLATED:1a4d9663]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_decoder_release(mk_decoder ctx, int flush_frame);
|
||||
|
||||
@@ -63,11 +89,21 @@ API_EXPORT void API_CALL mk_decoder_release(mk_decoder ctx, int flush_frame);
|
||||
* @param frame 帧对象
|
||||
* @param async 是否异步解码
|
||||
* @param enable_merge 是否合并帧解码,有些情况下,需要把时间戳相同的slice合并输入到解码器才能解码
|
||||
* Decode audio and video frames
|
||||
* @param ctx Decoder
|
||||
* @param frame Frame object
|
||||
* @param async Whether to decode asynchronously
|
||||
* @param enable_merge Whether to merge frame decoding, in some cases, it is necessary to merge slices with the same timestamp into the decoder before decoding
|
||||
|
||||
* [AUTO-TRANSLATED:87df4c4d]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_decoder_decode(mk_decoder ctx, mk_frame frame, int async, int enable_merge);
|
||||
|
||||
/**
|
||||
* 设置异步解码最大帧缓存积压数限制
|
||||
* Set the maximum frame cache backlog limit for asynchronous decoding
|
||||
|
||||
* [AUTO-TRANSLATED:1e3e413d]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_decoder_set_max_async_frame_size(mk_decoder ctx, size_t size);
|
||||
|
||||
@@ -76,6 +112,12 @@ API_EXPORT void API_CALL mk_decoder_set_max_async_frame_size(mk_decoder ctx, siz
|
||||
* @param ctx 解码器
|
||||
* @param cb 回调函数
|
||||
* @param user_data 回调函数用户指针参数
|
||||
* Set decode output callback
|
||||
* @param ctx Decoder
|
||||
* @param cb Callback function
|
||||
* @param user_data User pointer parameter of the callback function
|
||||
|
||||
* [AUTO-TRANSLATED:a90f8764]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_decoder_set_cb(mk_decoder ctx, on_mk_decode cb, void *user_data);
|
||||
API_EXPORT void API_CALL mk_decoder_set_cb2(mk_decoder ctx, on_mk_decode cb, void *user_data, on_user_data_free user_data_free);
|
||||
@@ -83,6 +125,10 @@ API_EXPORT void API_CALL mk_decoder_set_cb2(mk_decoder ctx, on_mk_decode cb, voi
|
||||
/**
|
||||
* 获取FFmpeg原始AVCodecContext对象
|
||||
* @param ctx 解码器
|
||||
* Get the FFmpeg original AVCodecContext object
|
||||
* @param ctx Decoder
|
||||
|
||||
* [AUTO-TRANSLATED:73ed5496]
|
||||
*/
|
||||
API_EXPORT const AVCodecContext* API_CALL mk_decoder_get_context(mk_decoder ctx);
|
||||
|
||||
@@ -92,12 +138,21 @@ API_EXPORT const AVCodecContext* API_CALL mk_decoder_get_context(mk_decoder ctx)
|
||||
* 创建解码帧mk_frame_pix新引用
|
||||
* @param frame 原始引用
|
||||
* @return 新引用
|
||||
* Create a new reference to the mk_frame_pix decoding frame
|
||||
* @param frame Original reference
|
||||
* @return New reference
|
||||
|
||||
* [AUTO-TRANSLATED:ca58ab5d]
|
||||
*/
|
||||
API_EXPORT mk_frame_pix API_CALL mk_frame_pix_ref(mk_frame_pix frame);
|
||||
|
||||
/**
|
||||
* 解码帧mk_frame_pix减引用
|
||||
* @param frame 原始引用
|
||||
* Decrease the reference of the decoding frame mk_frame_pix
|
||||
* @param frame Original reference
|
||||
|
||||
* [AUTO-TRANSLATED:1581d0a9]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_frame_pix_unref(mk_frame_pix frame);
|
||||
|
||||
@@ -105,6 +160,11 @@ API_EXPORT void API_CALL mk_frame_pix_unref(mk_frame_pix frame);
|
||||
* 从FFmpeg AVFrame转换为mk_frame_pix
|
||||
* @param frame FFmpeg AVFrame
|
||||
* @return mk_frame_pix对象
|
||||
* Convert from FFmpeg AVFrame to mk_frame_pix
|
||||
* @param frame FFmpeg AVFrame
|
||||
* @return mk_frame_pix object
|
||||
|
||||
* [AUTO-TRANSLATED:adfb43d5]
|
||||
*/
|
||||
API_EXPORT mk_frame_pix API_CALL mk_frame_pix_from_av_frame(AVFrame *frame);
|
||||
|
||||
@@ -114,6 +174,13 @@ API_EXPORT mk_frame_pix API_CALL mk_frame_pix_from_av_frame(AVFrame *frame);
|
||||
* @param line_size 平面数据line size
|
||||
* @param plane 数据平面个数
|
||||
* @return mk_frame_pix对象
|
||||
* Create a mk_frame_pix object without memory copy
|
||||
* @param plane_data Multiple plane data, get its data pointer through mk_buffer_get_data
|
||||
* @param line_size Plane data line size
|
||||
* @param plane Number of data planes
|
||||
* @return mk_frame_pix object
|
||||
|
||||
* [AUTO-TRANSLATED:b720d2e2]
|
||||
*/
|
||||
API_EXPORT mk_frame_pix API_CALL mk_frame_pix_from_buffer(mk_buffer plane_data[], int line_size[], int plane);
|
||||
|
||||
@@ -121,6 +188,11 @@ API_EXPORT mk_frame_pix API_CALL mk_frame_pix_from_buffer(mk_buffer plane_data[]
|
||||
* 获取FFmpeg AVFrame对象
|
||||
* @param frame 解码帧mk_frame_pix
|
||||
* @return FFmpeg AVFrame对象
|
||||
* Get the FFmpeg AVFrame object
|
||||
* @param frame Decoded frame mk_frame_pix
|
||||
* @return FFmpeg AVFrame object
|
||||
|
||||
* [AUTO-TRANSLATED:03142bdc]
|
||||
*/
|
||||
API_EXPORT AVFrame* API_CALL mk_frame_pix_get_av_frame(mk_frame_pix frame);
|
||||
|
||||
@@ -132,12 +204,23 @@ API_EXPORT AVFrame* API_CALL mk_frame_pix_get_av_frame(mk_frame_pix frame);
|
||||
* @param width 目标宽度,置0时,则与输入时一致
|
||||
* @param height 目标高度,置0时,则与输入时一致
|
||||
* @return SwsContext wrapper 实例
|
||||
* Create an instance of the ffmpeg SwsContext wrapper
|
||||
* @param output AVPixelFormat type, AV_PIX_FMT_BGR24==3
|
||||
* @param width Target width, set to 0, then it is the same as the input
|
||||
* @param height Target height, set to 0, then it is the same as the input
|
||||
* @return SwsContext wrapper instance
|
||||
|
||||
* [AUTO-TRANSLATED:417474cb]
|
||||
*/
|
||||
API_EXPORT mk_swscale mk_swscale_create(int output, int width, int height);
|
||||
|
||||
/**
|
||||
* 释放ffmpeg SwsContext wrapper实例
|
||||
* @param ctx SwsContext wrapper实例
|
||||
* Release the ffmpeg SwsContext wrapper instance
|
||||
* @param ctx SwsContext wrapper instance
|
||||
|
||||
* [AUTO-TRANSLATED:8eaaea2f]
|
||||
*/
|
||||
API_EXPORT void mk_swscale_release(mk_swscale ctx);
|
||||
|
||||
@@ -147,6 +230,13 @@ API_EXPORT void mk_swscale_release(mk_swscale ctx);
|
||||
* @param frame pix frame
|
||||
* @param out 转换后存放的数据指针,用户需要确保提前申请并大小足够
|
||||
* @return sws_scale()返回值:the height of the output slice
|
||||
* Use SwsContext to convert pix format
|
||||
* @param ctx SwsContext wrapper instance
|
||||
* @param frame pix frame
|
||||
* @param out Data pointer to store the converted data, the user needs to ensure that the application is applied in advance and the size is sufficient
|
||||
* @return sws_scale() return value: the height of the output slice
|
||||
|
||||
* [AUTO-TRANSLATED:3018afe4]
|
||||
*/
|
||||
API_EXPORT int mk_swscale_input_frame(mk_swscale ctx, mk_frame_pix frame, uint8_t *out);
|
||||
|
||||
@@ -155,6 +245,13 @@ API_EXPORT int mk_swscale_input_frame(mk_swscale ctx, mk_frame_pix frame, uint8_
|
||||
* @param ctx SwsContext wrapper实例
|
||||
* @param frame pix frame
|
||||
* @return 新的pix frame对象,需要使用mk_frame_pix_unref销毁
|
||||
* Use SwsContext to convert pix format
|
||||
* @param ctx SwsContext wrapper instance
|
||||
* @param frame pix frame
|
||||
* @return New pix frame object, needs to be destroyed using mk_frame_pix_unref
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:5b4e98a3]
|
||||
*/
|
||||
API_EXPORT mk_frame_pix mk_swscale_input_frame2(mk_swscale ctx, mk_frame_pix frame);
|
||||
|
||||
|
||||
@@ -20,12 +20,19 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* 释放mk api内部malloc的资源
|
||||
* Release resources allocated by mk api internally
|
||||
|
||||
* [AUTO-TRANSLATED:92ecfef5]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_free(void *ptr);
|
||||
|
||||
/**
|
||||
* 获取本程序可执行文件路径
|
||||
* @return 文件路径,使用完后需要自己mk_free
|
||||
* Get the path of the executable file of this program
|
||||
* @return File path, need to be mk_free after use
|
||||
|
||||
* [AUTO-TRANSLATED:5f1fae7f]
|
||||
*/
|
||||
API_EXPORT char* API_CALL mk_util_get_exe_path();
|
||||
|
||||
@@ -33,12 +40,21 @@ API_EXPORT char* API_CALL mk_util_get_exe_path();
|
||||
* 获取本程序可执行文件相同目录下文件的绝对路径
|
||||
* @param relative_path 同目录下文件的路径相对,可以为null
|
||||
* @return 文件路径,使用完后需要自己mk_free
|
||||
* Get the absolute path of the file in the same directory as the executable file of this program
|
||||
* @param relative_path The path of the file in the same directory, can be null
|
||||
* @return File path, need to be mk_free after use
|
||||
|
||||
* [AUTO-TRANSLATED:80442e8e]
|
||||
*/
|
||||
API_EXPORT char* API_CALL mk_util_get_exe_dir(const char *relative_path);
|
||||
|
||||
/**
|
||||
* 获取unix标准的系统时间戳
|
||||
* @return 当前系统时间戳
|
||||
* Get the Unix standard system timestamp
|
||||
* @return Current system timestamp
|
||||
|
||||
* [AUTO-TRANSLATED:feddaa5b]
|
||||
*/
|
||||
API_EXPORT uint64_t API_CALL mk_util_get_current_millisecond();
|
||||
|
||||
@@ -46,6 +62,11 @@ API_EXPORT uint64_t API_CALL mk_util_get_current_millisecond();
|
||||
* 获取时间字符串
|
||||
* @param fmt 时间格式,譬如%Y-%m-%d %H:%M:%S
|
||||
* @return 时间字符串,使用完后需要自己mk_free
|
||||
* Get the time string
|
||||
* @param fmt Time format, such as %Y-%m-%d %H:%M:%S
|
||||
* @return Time string, need to be mk_free after use
|
||||
|
||||
* [AUTO-TRANSLATED:c5a6c984]
|
||||
*/
|
||||
API_EXPORT char* API_CALL mk_util_get_current_time_string(const char *fmt);
|
||||
|
||||
@@ -54,6 +75,12 @@ API_EXPORT char* API_CALL mk_util_get_current_time_string(const char *fmt);
|
||||
* @param buf 二进制数据
|
||||
* @param len 数据长度
|
||||
* @return 可打印的调试信息,使用完后需要自己mk_free
|
||||
* Print binary data as string
|
||||
* @param buf Binary data
|
||||
* @param len Data length
|
||||
* @return Printable debug information, need to be mk_free after use
|
||||
|
||||
* [AUTO-TRANSLATED:5b76b3a5]
|
||||
*/
|
||||
API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len);
|
||||
|
||||
@@ -62,12 +89,19 @@ typedef struct mk_ini_t *mk_ini;
|
||||
|
||||
/**
|
||||
* 创建ini配置对象
|
||||
* Create ini configuration object
|
||||
|
||||
* [AUTO-TRANSLATED:b8ce40cc]
|
||||
*/
|
||||
API_EXPORT mk_ini API_CALL mk_ini_create();
|
||||
|
||||
/**
|
||||
* 返回全局默认ini配置
|
||||
* @return 全局默认ini配置,请勿用mk_ini_release释放它
|
||||
* Return the global default ini configuration
|
||||
* @return Global default ini configuration, do not use mk_ini_release to release it
|
||||
|
||||
* [AUTO-TRANSLATED:057ea031]
|
||||
*/
|
||||
API_EXPORT mk_ini API_CALL mk_ini_default();
|
||||
|
||||
@@ -75,6 +109,11 @@ API_EXPORT mk_ini API_CALL mk_ini_default();
|
||||
* 加载ini配置文件内容
|
||||
* @param ini ini对象
|
||||
* @param str 配置文件内容
|
||||
* Load ini configuration file content
|
||||
* @param ini Ini object
|
||||
* @param str Configuration file content
|
||||
|
||||
* [AUTO-TRANSLATED:b9366be5]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_ini_load_string(mk_ini ini, const char *str);
|
||||
|
||||
@@ -82,11 +121,19 @@ API_EXPORT void API_CALL mk_ini_load_string(mk_ini ini, const char *str);
|
||||
* 加载ini配置文件
|
||||
* @param ini ini对象
|
||||
* @param file 配置文件路径
|
||||
* Load ini configuration file
|
||||
* @param ini Ini object
|
||||
* @param file Configuration file path
|
||||
|
||||
* [AUTO-TRANSLATED:688e0471]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_ini_load_file(mk_ini ini, const char *file);
|
||||
|
||||
/**
|
||||
* 销毁ini配置对象
|
||||
* Destroy ini configuration object
|
||||
|
||||
* [AUTO-TRANSLATED:b6286ab8]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_ini_release(mk_ini ini);
|
||||
|
||||
@@ -95,6 +142,12 @@ API_EXPORT void API_CALL mk_ini_release(mk_ini ini);
|
||||
* @param ini 配置对象
|
||||
* @param key 配置名,两段式,如:field.key
|
||||
* @param value 配置值
|
||||
* Add or overwrite configuration item
|
||||
* @param ini Configuration object
|
||||
* @param key Configuration name, two-part, such as: field.key
|
||||
* @param value Configuration value
|
||||
|
||||
* [AUTO-TRANSLATED:1b2c8bfa]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_ini_set_option(mk_ini ini, const char *key, const char *value);
|
||||
API_EXPORT void API_CALL mk_ini_set_option_int(mk_ini ini, const char *key, int value);
|
||||
@@ -104,6 +157,12 @@ API_EXPORT void API_CALL mk_ini_set_option_int(mk_ini ini, const char *key, int
|
||||
* @param ini 配置对象
|
||||
* @param key 配置名,两段式,如:field.key
|
||||
* @return 配置不存在返回NULL,否则返回配置值
|
||||
* Get configuration item
|
||||
* @param ini Configuration object
|
||||
* @param key Configuration name, two-part, such as: field.key
|
||||
* @return NULL if the configuration does not exist, otherwise return the configuration value
|
||||
|
||||
* [AUTO-TRANSLATED:4df4bc65]
|
||||
*/
|
||||
API_EXPORT const char *API_CALL mk_ini_get_option(mk_ini ini, const char *key);
|
||||
|
||||
@@ -112,6 +171,12 @@ API_EXPORT const char *API_CALL mk_ini_get_option(mk_ini ini, const char *key);
|
||||
* @param ini 配置对象
|
||||
* @param key 配置名,两段式,如:field.key
|
||||
* @return 1: 成功,0: 该配置不存在
|
||||
* Delete configuration item
|
||||
* @param ini Configuration object
|
||||
* @param key Configuration name, two-part, such as: field.key
|
||||
* @return 1: Success, 0: The configuration does not exist
|
||||
|
||||
* [AUTO-TRANSLATED:dbbbdca3]
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_ini_del_option(mk_ini ini, const char *key);
|
||||
|
||||
@@ -119,6 +184,11 @@ API_EXPORT int API_CALL mk_ini_del_option(mk_ini ini, const char *key);
|
||||
* 导出为配置文件内容
|
||||
* @param ini 配置对象
|
||||
* @return 配置文件内容字符串,用完后需要自行mk_free
|
||||
* Export to configuration file content
|
||||
* @param ini Configuration object
|
||||
* @return Configuration file content string, need to be mk_free after use
|
||||
|
||||
* [AUTO-TRANSLATED:94620b68]
|
||||
*/
|
||||
API_EXPORT char *API_CALL mk_ini_dump_string(mk_ini ini);
|
||||
|
||||
@@ -126,19 +196,30 @@ API_EXPORT char *API_CALL mk_ini_dump_string(mk_ini ini);
|
||||
* 导出配置文件到文件
|
||||
* @param ini 配置对象
|
||||
* @param file 配置文件路径
|
||||
* Export configuration file to file
|
||||
* @param ini Configuration object
|
||||
* @param file Configuration file path
|
||||
|
||||
* [AUTO-TRANSLATED:8fac58af]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_ini_dump_file(mk_ini ini, const char *file);
|
||||
///////////////////////////////////////////统计/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////统计///////////////////////////////////////////// [AUTO-TRANSLATED:964becb9]
|
||||
// /////////////////////////////////////////统计/////////////////////////////////////////////
|
||||
|
||||
typedef void(API_CALL *on_mk_get_statistic_cb)(void *user_data, mk_ini ini);
|
||||
|
||||
/**
|
||||
* 获取内存数据统计
|
||||
* @param ini 存放统计结果
|
||||
* Get memory data statistics
|
||||
* @param ini Store statistical results
|
||||
|
||||
* [AUTO-TRANSLATED:48d8035c]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_get_statistic(on_mk_get_statistic_cb cb, void *user_data, on_user_data_free free_cb);
|
||||
|
||||
///////////////////////////////////////////日志/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////日志///////////////////////////////////////////// [AUTO-TRANSLATED:b1bd4de8]
|
||||
// /////////////////////////////////////////日志/////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 打印日志
|
||||
@@ -148,10 +229,20 @@ API_EXPORT void API_CALL mk_get_statistic(on_mk_get_statistic_cb cb, void *user_
|
||||
* @param line __LINE__
|
||||
* @param fmt printf类型的格式控制字符串
|
||||
* @param ... 不定长参数
|
||||
* Print log
|
||||
* @param level Log level, support 0~4
|
||||
* @param file __FILE__
|
||||
* @param function __FUNCTION__
|
||||
* @param line __LINE__
|
||||
* @param fmt printf type format control string
|
||||
* @param ... Variable length parameters
|
||||
|
||||
* [AUTO-TRANSLATED:f19956e7]
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...);
|
||||
|
||||
// 以下宏可以替换printf使用
|
||||
// 以下宏可以替换printf使用 [AUTO-TRANSLATED:73b59437]
|
||||
// The following macros can replace printf
|
||||
#define log_printf(lev, ...) mk_log_printf(lev, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define log_trace(...) log_printf(0, ##__VA_ARGS__)
|
||||
#define log_debug(...) log_printf(1, ##__VA_ARGS__)
|
||||
|
||||
@@ -93,20 +93,24 @@ API_EXPORT void API_CALL mk_env_init2(int thread_num,
|
||||
int ssl_is_path,
|
||||
const char *ssl,
|
||||
const char *ssl_pwd) {
|
||||
//确保只初始化一次
|
||||
// 确保只初始化一次 [AUTO-TRANSLATED:e4b32b0f]
|
||||
// Ensure initialization only happens once
|
||||
static onceToken token([&]() {
|
||||
if (log_mask & LOG_CONSOLE) {
|
||||
//控制台日志
|
||||
// 控制台日志 [AUTO-TRANSLATED:5c00e83f]
|
||||
// Console log
|
||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("ConsoleChannel", (LogLevel) log_level));
|
||||
}
|
||||
|
||||
if (log_mask & LOG_CALLBACK) {
|
||||
//广播日志
|
||||
// 广播日志 [AUTO-TRANSLATED:67556df8]
|
||||
// Broadcast log
|
||||
Logger::Instance().add(std::make_shared<EventChannel>("EventChannel", (LogLevel) log_level));
|
||||
}
|
||||
|
||||
if (log_mask & LOG_FILE) {
|
||||
//日志文件
|
||||
// 日志文件 [AUTO-TRANSLATED:afacc934]
|
||||
// Log file
|
||||
auto channel = std::make_shared<FileChannel>("FileChannel",
|
||||
log_file_path ? File::absolutePath("", log_file_path) :
|
||||
exeDir() + "log/", (LogLevel) log_level);
|
||||
@@ -114,15 +118,18 @@ API_EXPORT void API_CALL mk_env_init2(int thread_num,
|
||||
Logger::Instance().add(channel);
|
||||
}
|
||||
|
||||
//异步日志线程
|
||||
// 异步日志线程 [AUTO-TRANSLATED:1cc193a1]
|
||||
// Asynchronous log thread
|
||||
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
||||
|
||||
//设置线程数
|
||||
// 设置线程数 [AUTO-TRANSLATED:22ec5cc9]
|
||||
// Set thread count
|
||||
EventPollerPool::setPoolSize(thread_num);
|
||||
WorkThreadPool::setPoolSize(thread_num);
|
||||
|
||||
if (ini && ini[0]) {
|
||||
//设置配置文件
|
||||
// 设置配置文件 [AUTO-TRANSLATED:2216856d]
|
||||
// Set configuration file
|
||||
if (ini_is_path) {
|
||||
try {
|
||||
mINI::Instance().parseFile(ini);
|
||||
@@ -136,7 +143,8 @@ API_EXPORT void API_CALL mk_env_init2(int thread_num,
|
||||
}
|
||||
|
||||
if (ssl && ssl[0]) {
|
||||
//设置ssl证书
|
||||
// 设置ssl证书 [AUTO-TRANSLATED:e441027c]
|
||||
// Set SSL certificate
|
||||
SSL_Initor::Instance().loadCertificate(ssl, true, ssl_pwd ? ssl_pwd : "", ssl_is_path);
|
||||
}
|
||||
});
|
||||
@@ -157,7 +165,8 @@ API_EXPORT void API_CALL mk_set_option(const char *key, const char *val) {
|
||||
return;
|
||||
}
|
||||
mINI::Instance()[key] = val;
|
||||
//广播配置文件热加载
|
||||
// 广播配置文件热加载 [AUTO-TRANSLATED:7ae561f3]
|
||||
// Broadcast configuration file hot reload
|
||||
NOTICE_EMIT(BroadcastReloadConfigArgs, Broadcast::kBroadcastReloadConfig);
|
||||
}
|
||||
|
||||
@@ -226,7 +235,8 @@ API_EXPORT uint16_t API_CALL mk_rtmp_server_start(uint16_t port, int ssl) {
|
||||
API_EXPORT uint16_t API_CALL mk_rtp_server_start(uint16_t port){
|
||||
#ifdef ENABLE_RTPPROXY
|
||||
try {
|
||||
//创建rtp 服务器
|
||||
// 创建rtp 服务器 [AUTO-TRANSLATED:480fda83]
|
||||
// Create RTP server
|
||||
rtpServer = std::make_shared<RtpServer>();
|
||||
rtpServer->start(port);
|
||||
return rtpServer->getPort();
|
||||
@@ -244,7 +254,8 @@ API_EXPORT uint16_t API_CALL mk_rtp_server_start(uint16_t port){
|
||||
API_EXPORT uint16_t API_CALL mk_rtc_server_start(uint16_t port) {
|
||||
#ifdef ENABLE_WEBRTC
|
||||
try {
|
||||
//创建rtc udp服务器
|
||||
// 创建rtc udp服务器 [AUTO-TRANSLATED:9287972e]
|
||||
// Create RTC UDP server
|
||||
rtcServer_udp = std::make_shared<UdpServer>();
|
||||
rtcServer_udp->setOnCreateSocket([](const EventPoller::Ptr &poller, const Buffer::Ptr &buf, struct sockaddr *, int) {
|
||||
if (!buf) {
|
||||
@@ -252,13 +263,15 @@ API_EXPORT uint16_t API_CALL mk_rtc_server_start(uint16_t port) {
|
||||
}
|
||||
auto new_poller = WebRtcSession::queryPoller(buf);
|
||||
if (!new_poller) {
|
||||
//该数据对应的webrtc对象未找到,丢弃之
|
||||
// 该数据对应的webrtc对象未找到,丢弃之 [AUTO-TRANSLATED:d401f8cb]
|
||||
// The WebRTC object corresponding to this data was not found, discard it
|
||||
return Socket::Ptr();
|
||||
}
|
||||
return Socket::createSocket(new_poller, false);
|
||||
});
|
||||
rtcServer_udp->start<WebRtcSession>(port);
|
||||
//创建rtc tcp服务器
|
||||
// 创建rtc tcp服务器 [AUTO-TRANSLATED:1eefd92f]
|
||||
// Create RTC TCP server
|
||||
rtcServer_tcp = std::make_shared<TcpServer>();
|
||||
rtcServer_tcp->start<WebRtcSession>(rtcServer_udp->getPort());
|
||||
return rtcServer_udp->getPort();
|
||||
@@ -328,7 +341,8 @@ API_EXPORT uint16_t API_CALL mk_srt_server_start(uint16_t port) {
|
||||
}
|
||||
auto new_poller = SRT::SrtSession::queryPoller(buf);
|
||||
if (!new_poller) {
|
||||
//握手第一阶段
|
||||
// 握手第一阶段 [AUTO-TRANSLATED:6b3abcd4]
|
||||
// Handshake stage one
|
||||
return Socket::createSocket(poller, false);
|
||||
}
|
||||
return Socket::createSocket(new_poller, false);
|
||||
|
||||
@@ -228,7 +228,8 @@ API_EXPORT mk_track API_CALL mk_media_source_get_track(const mk_media_source ctx
|
||||
API_EXPORT float API_CALL mk_media_source_get_track_loss(const mk_media_source ctx, const mk_track track) {
|
||||
assert(ctx);
|
||||
MediaSource *src = (MediaSource *)ctx;
|
||||
// rtp推流只有一个统计器,但是可能有多个track,如果短时间多次获取间隔丢包率,第二次会获取为-1
|
||||
// rtp推流只有一个统计器,但是可能有多个track,如果短时间多次获取间隔丢包率,第二次会获取为-1 [AUTO-TRANSLATED:b30fec2c]
|
||||
// RTP streaming has only one statistics object, but there may be multiple tracks. If the packet loss rate is obtained multiple times in a short period, the second time will be obtained as -1
|
||||
return src->getLossRate((*((Track::Ptr *)track))->getTrackType());
|
||||
}
|
||||
|
||||
@@ -608,7 +609,8 @@ API_EXPORT void API_CALL mk_rtc_send_datachannel(const mk_rtc_transport ctx, uin
|
||||
std::string msg_str(msg, len);
|
||||
std::weak_ptr<WebRtcTransport> weak_trans = transport->shared_from_this();
|
||||
transport->getPoller()->async([streamId, ppid, msg_str, weak_trans]() {
|
||||
// 切换线程后再操作
|
||||
// 切换线程后再操作 [AUTO-TRANSLATED:12d77fca]
|
||||
// Operate after switching threads
|
||||
if (auto trans = weak_trans.lock()) {
|
||||
trans->sendDatachannel(streamId, ppid, msg_str.c_str(), msg_str.size());
|
||||
}
|
||||
|
||||
@@ -45,12 +45,14 @@ H264Splitter::~H264Splitter() {
|
||||
ssize_t H264Splitter::onRecvHeader(const char *data, size_t len) {
|
||||
auto frame = Factory::getFrameFromPtr(_h265 ? CodecH265 : CodecH264, (char *)data, len, 0, 0);
|
||||
if (_have_decode_frame && (frame->decodeAble() || frame->configFrame())) {
|
||||
// 缓存中存在可解码帧,且下一帧是可解码帧或者配置帧,那么flush缓存
|
||||
// 缓存中存在可解码帧,且下一帧是可解码帧或者配置帧,那么flush缓存 [AUTO-TRANSLATED:2c52093b]
|
||||
// Flush the cache if there are decodable frames in the cache and the next frame is a decodable frame or a configuration frame.
|
||||
_cb(_buffer.data(), _buffer.size());
|
||||
_buffer.assign(data, len);
|
||||
_have_decode_frame = frame->decodeAble();
|
||||
} else {
|
||||
// 还需要缓存
|
||||
// 还需要缓存 [AUTO-TRANSLATED:a4dc19cb]
|
||||
// Still need to cache
|
||||
_buffer.append(data, len);
|
||||
_have_decode_frame = _have_decode_frame || frame->decodeAble();
|
||||
}
|
||||
@@ -59,10 +61,12 @@ ssize_t H264Splitter::onRecvHeader(const char *data, size_t len) {
|
||||
|
||||
const char *H264Splitter::onSearchPacketTail(const char *data, size_t len) {
|
||||
for (size_t i = 2; len > 2 && i < len - 2; ++i) {
|
||||
//判断0x00 00 01
|
||||
// 判断0x00 00 01 [AUTO-TRANSLATED:afa3d4c2]
|
||||
// Determine if it is 0x00 00 01
|
||||
if (data[i] == 0 && data[i + 1] == 0 && data[i + 2] == 1) {
|
||||
if (i > 0 && data[i - 1] == 0) {
|
||||
//找到0x00 00 00 01
|
||||
// 找到0x00 00 00 01 [AUTO-TRANSLATED:96a10021]
|
||||
// Find 0x00 00 00 01
|
||||
return data + i - 1;
|
||||
}
|
||||
return data + i;
|
||||
|
||||
@@ -21,7 +21,8 @@ public:
|
||||
using Ptr = std::shared_ptr<MediaHelper>;
|
||||
MediaHelper(const char *vhost, const char *app, const char *stream, float duration, const ProtocolOption &option) {
|
||||
_poller = EventPollerPool::Instance().getPoller();
|
||||
// 在poller线程中创建DevChannel(MultiMediaSourceMuxer)对象,确保严格的线程安全限制
|
||||
// 在poller线程中创建DevChannel(MultiMediaSourceMuxer)对象,确保严格的线程安全限制 [AUTO-TRANSLATED:d5063d7a]
|
||||
// Create a DevChannel (MultiMediaSourceMuxer) object in the poller thread to ensure strict thread safety restrictions
|
||||
auto tuple = MediaTuple{vhost, app, stream};
|
||||
_poller->sync([&]() { _channel = std::make_shared<DevChannel>(tuple, duration, option); });
|
||||
}
|
||||
@@ -58,14 +59,17 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// 通知其停止推流
|
||||
// 通知其停止推流 [AUTO-TRANSLATED:d69d10d8]
|
||||
// Notify it to stop streaming
|
||||
bool close(MediaSource &sender) override {
|
||||
if (!_on_close) {
|
||||
//未设置回调,没法关闭
|
||||
// 未设置回调,没法关闭 [AUTO-TRANSLATED:2c1423fe]
|
||||
// No callback is set, so it cannot be closed
|
||||
WarnL << "请使用mk_media_set_on_close函数设置回调函数!";
|
||||
return false;
|
||||
}
|
||||
//请在回调中调用mk_media_release函数释放资源,否则MediaSource::close()操作不会生效
|
||||
// 请在回调中调用mk_media_release函数释放资源,否则MediaSource::close()操作不会生效 [AUTO-TRANSLATED:da067eb0]
|
||||
// Please call the mk_media_release function to release resources in the callback, otherwise the MediaSource::close() operation will not take effect
|
||||
_on_close(_on_close_data.get());
|
||||
WarnL << "close media: " << sender.getUrl();
|
||||
return true;
|
||||
@@ -78,7 +82,8 @@ protected:
|
||||
return _on_seek(_on_seek_data.get(), stamp);
|
||||
}
|
||||
|
||||
// 通知暂停或恢复
|
||||
// 通知暂停或恢复 [AUTO-TRANSLATED:ee3c219f]
|
||||
// Notify pause or resume
|
||||
bool pause(MediaSource &sender, bool pause) override {
|
||||
if (!_on_pause) {
|
||||
return false;
|
||||
@@ -86,7 +91,8 @@ protected:
|
||||
return _on_pause(_on_pause_data.get(), pause);
|
||||
}
|
||||
|
||||
//通知倍数播放
|
||||
// 通知倍数播放 [AUTO-TRANSLATED:12e66e3f]
|
||||
// Notify playback speed
|
||||
bool speed(MediaSource &sender, float speed) override {
|
||||
if (!_on_speed) {
|
||||
return false;
|
||||
@@ -297,7 +303,8 @@ API_EXPORT void API_CALL mk_media_start_send_rtp2(mk_media ctx, const char *dst_
|
||||
args.close_delay_ms = 30 * 1000;
|
||||
args.con_type = (mediakit::MediaSourceEvent::SendRtpArgs::ConType)con_type;
|
||||
|
||||
// sender参数无用
|
||||
// sender参数无用 [AUTO-TRANSLATED:21590ae5]
|
||||
// The sender parameter is useless
|
||||
auto ref = *obj;
|
||||
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
(*obj)->getChannel()->getOwnerPoller(MediaSource::NullMediaSource())->async([args, ref, cb, ptr]() {
|
||||
@@ -335,7 +342,8 @@ API_EXPORT void API_CALL mk_media_start_send_rtp4(mk_media ctx, const char *dst_
|
||||
args.close_delay_ms = (*ini_ptr)["close_delay_ms"].empty() ? 30000 : (*ini_ptr)["close_delay_ms"].as<int>();
|
||||
args.rtcp_timeout_ms = (*ini_ptr)["rtcp_timeout_ms"].empty() ? 30000 : (*ini_ptr)["rtcp_timeout_ms"].as<int>();
|
||||
args.rtcp_send_interval_ms = (*ini_ptr)["rtcp_send_interval_ms"].empty() ? 5000 : (*ini_ptr)["rtcp_send_interval_ms"].as<int>();
|
||||
// sender参数无用
|
||||
// sender参数无用 [AUTO-TRANSLATED:21590ae5]
|
||||
// The sender parameter is useless
|
||||
auto ref = *obj;
|
||||
std::shared_ptr<void> ptr(
|
||||
user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
@@ -351,7 +359,8 @@ API_EXPORT void API_CALL mk_media_start_send_rtp4(mk_media ctx, const char *dst_
|
||||
API_EXPORT void API_CALL mk_media_stop_send_rtp(mk_media ctx, const char *ssrc) {
|
||||
assert(ctx);
|
||||
MediaHelper::Ptr *obj = (MediaHelper::Ptr *)ctx;
|
||||
// sender参数无用
|
||||
// sender参数无用 [AUTO-TRANSLATED:21590ae5]
|
||||
// The sender parameter is useless
|
||||
auto ref = *obj;
|
||||
string ssrc_str = ssrc ? ssrc : "";
|
||||
(*obj)->getChannel()->getOwnerPoller(MediaSource::NullMediaSource())->async([ref, ssrc_str]() {
|
||||
|
||||
@@ -57,14 +57,16 @@ public:
|
||||
void onEvent(bool is_shutdown, const SockException &ex){
|
||||
lock_guard<recursive_mutex> lck(_mtx);
|
||||
if (is_shutdown) {
|
||||
//播放中断
|
||||
// 播放中断 [AUTO-TRANSLATED:9b841156]
|
||||
// Play interrupted
|
||||
if (_on_shutdown) {
|
||||
_on_shutdown(_on_shutdown_data.get(), ex.getErrCode(), ex.what(), nullptr, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//播放结果
|
||||
// 播放结果 [AUTO-TRANSLATED:15f1e8fe]
|
||||
// Play result
|
||||
if (_on_play) {
|
||||
auto cpp_tracks = _player->getTracks(false);
|
||||
mk_track tracks[TrackMax] = {nullptr};
|
||||
@@ -118,7 +120,8 @@ API_EXPORT void API_CALL mk_player_set_option(mk_player ctx,const char* key,cons
|
||||
auto player = obj.getPlayer();
|
||||
string key_str(key), val_str(val);
|
||||
player->getPoller()->async([key_str,val_str,player](){
|
||||
//切换线程后再操作
|
||||
// 切换线程后再操作 [AUTO-TRANSLATED:b8f01c71]
|
||||
// Operate after switching threads
|
||||
(*player)[key_str] = val_str;
|
||||
});
|
||||
}
|
||||
@@ -128,7 +131,8 @@ API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url) {
|
||||
auto player = obj.getPlayer();
|
||||
string url_str(url);
|
||||
player->getPoller()->async([url_str,player](){
|
||||
//切换线程后再操作
|
||||
// 切换线程后再操作 [AUTO-TRANSLATED:b8f01c71]
|
||||
// Operate after switching threads
|
||||
player->play(url_str);
|
||||
});
|
||||
}
|
||||
@@ -138,7 +142,8 @@ API_EXPORT void API_CALL mk_player_pause(mk_player ctx, int pause) {
|
||||
MediaPlayerForC &obj = **((MediaPlayerForC::Ptr *)ctx);
|
||||
auto player = obj.getPlayer();
|
||||
player->getPoller()->async([pause,player](){
|
||||
//切换线程后再操作
|
||||
// 切换线程后再操作 [AUTO-TRANSLATED:b8f01c71]
|
||||
// Operate after switching threads
|
||||
player->pause(pause);
|
||||
});
|
||||
}
|
||||
@@ -148,7 +153,8 @@ API_EXPORT void API_CALL mk_player_speed(mk_player ctx, float speed) {
|
||||
MediaPlayerForC &obj = **((MediaPlayerForC::Ptr *) ctx);
|
||||
auto player = obj.getPlayer();
|
||||
player->getPoller()->async([speed, player]() {
|
||||
//切换线程后再操作
|
||||
// 切换线程后再操作 [AUTO-TRANSLATED:b8f01c71]
|
||||
// Operate after switching threads
|
||||
player->speed(speed);
|
||||
});
|
||||
}
|
||||
@@ -158,7 +164,8 @@ API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress) {
|
||||
MediaPlayerForC &obj = **((MediaPlayerForC::Ptr *)ctx);
|
||||
auto player = obj.getPlayer();
|
||||
player->getPoller()->async([progress,player](){
|
||||
//切换线程后再操作
|
||||
// 切换线程后再操作 [AUTO-TRANSLATED:b8f01c71]
|
||||
// Operate after switching threads
|
||||
player->seekTo(progress);
|
||||
});
|
||||
}
|
||||
@@ -168,7 +175,8 @@ API_EXPORT void API_CALL mk_player_seekto_pos(mk_player ctx, int seek_pos) {
|
||||
MediaPlayerForC &obj = **((MediaPlayerForC::Ptr *) ctx);
|
||||
auto player = obj.getPlayer();
|
||||
player->getPoller()->async([seek_pos, player]() {
|
||||
//切换线程后再操作
|
||||
// 切换线程后再操作 [AUTO-TRANSLATED:b8f01c71]
|
||||
// Operate after switching threads
|
||||
player->seekTo((uint32_t) seek_pos);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const c
|
||||
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *) ctx);
|
||||
std::string key_str(key), val_str(val);
|
||||
obj->getPoller()->async([obj,key_str,val_str](){
|
||||
//切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:b78259f9]
|
||||
// Switch threads and then operate
|
||||
(*obj)[key_str] = val_str;
|
||||
});
|
||||
}
|
||||
@@ -63,7 +64,8 @@ API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *u
|
||||
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *) ctx);
|
||||
std::string url_str(url);
|
||||
obj->getPoller()->async([obj,url_str](){
|
||||
//切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:b78259f9]
|
||||
// Switch threads and then operate
|
||||
obj->play(url_str);
|
||||
});
|
||||
}
|
||||
@@ -77,7 +79,8 @@ API_EXPORT void API_CALL mk_proxy_player_set_on_close2(mk_proxy_player ctx, on_m
|
||||
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *)ctx);
|
||||
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
obj->getPoller()->async([obj, cb, ptr]() {
|
||||
// 切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:bae49fee]
|
||||
// Switch threads and then operate
|
||||
obj->setOnClose([cb, ptr](const SockException &ex) {
|
||||
if (cb) {
|
||||
cb(ptr.get(), ex.getErrCode(), ex.what(), ex.getCustomCode());
|
||||
@@ -91,7 +94,8 @@ API_EXPORT void API_CALL mk_proxy_player_set_on_play_result(mk_proxy_player ctx,
|
||||
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *)ctx);
|
||||
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
obj->getPoller()->async([obj, cb, ptr]() {
|
||||
// 切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:bae49fee]
|
||||
// Switch threads and then operate
|
||||
obj->setPlayCallbackOnce([cb, ptr](const SockException &ex) {
|
||||
if (cb) {
|
||||
cb(ptr.get(), ex.getErrCode(), ex.what(), ex.getCustomCode());
|
||||
|
||||
@@ -39,7 +39,8 @@ API_EXPORT void API_CALL mk_pusher_set_option(mk_pusher ctx, const char *key, co
|
||||
MediaPusher::Ptr &obj = *((MediaPusher::Ptr *)ctx);
|
||||
std::string key_str(key), val_str(val);
|
||||
obj->getPoller()->async([obj,key_str,val_str](){
|
||||
//切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:b78259f9]
|
||||
// Switch threads and then operate
|
||||
(*obj)[key_str] = val_str;
|
||||
});
|
||||
}
|
||||
@@ -49,7 +50,8 @@ API_EXPORT void API_CALL mk_pusher_publish(mk_pusher ctx,const char *url){
|
||||
MediaPusher::Ptr &obj = *((MediaPusher::Ptr *)ctx);
|
||||
std::string url_str(url);
|
||||
obj->getPoller()->async([obj,url_str](){
|
||||
//切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:b78259f9]
|
||||
// Switch threads and then operate
|
||||
obj->publish(url_str);
|
||||
});
|
||||
}
|
||||
@@ -63,7 +65,8 @@ API_EXPORT void API_CALL mk_pusher_set_on_result2(mk_pusher ctx, on_mk_push_even
|
||||
MediaPusher::Ptr &obj = *((MediaPusher::Ptr *)ctx);
|
||||
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
obj->getPoller()->async([obj, cb, ptr]() {
|
||||
// 切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:bae49fee]
|
||||
// Switch threads and then operate
|
||||
obj->setOnPublished([cb, ptr](const SockException &ex) { cb(ptr.get(), ex.getErrCode(), ex.what()); });
|
||||
});
|
||||
}
|
||||
@@ -77,7 +80,8 @@ API_EXPORT void API_CALL mk_pusher_set_on_shutdown2(mk_pusher ctx, on_mk_push_ev
|
||||
MediaPusher::Ptr &obj = *((MediaPusher::Ptr *)ctx);
|
||||
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
obj->getPoller()->async([obj, cb, ptr]() {
|
||||
// 切换线程再操作
|
||||
// 切换线程再操作 [AUTO-TRANSLATED:bae49fee]
|
||||
// Switch threads and then operate
|
||||
obj->setOnShutdown([cb, ptr](const SockException &ex) { cb(ptr.get(), ex.getErrCode(), ex.what()); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *v
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////hls/mp4录制/////////////////////////////////////////////
|
||||
// /////////////////////////////////////////hls/mp4录制///////////////////////////////////////////// [AUTO-TRANSLATED:99c61c68]
|
||||
// /////////////////////////////////////////hls/mp4 recording/////////////////////////////////////////////
|
||||
|
||||
static inline bool isRecording(Recorder::type type, const string &vhost, const string &app, const string &stream_id){
|
||||
auto src = MediaSource::find(vhost, app, stream_id);
|
||||
|
||||
@@ -242,11 +242,13 @@ API_EXPORT uint16_t API_CALL mk_tcp_server_start(uint16_t port, mk_tcp_type type
|
||||
s_tcp_server[type]->start<SessionWithSSL<SessionForC> >(port);
|
||||
break;
|
||||
case mk_type_ws:
|
||||
//此处你也可以修改WebSocketHeader::BINARY
|
||||
// 此处你也可以修改WebSocketHeader::BINARY [AUTO-TRANSLATED:706abaab]
|
||||
// You can also modify WebSocketHeader::BINARY here
|
||||
s_tcp_server[type]->start<WebSocketSession<SessionForC, HttpSession, WebSocketHeader::TEXT> >(port);
|
||||
break;
|
||||
case mk_type_wss:
|
||||
//此处你也可以修改WebSocketHeader::BINARY
|
||||
// 此处你也可以修改WebSocketHeader::BINARY [AUTO-TRANSLATED:706abaab]
|
||||
// You can also modify WebSocketHeader::BINARY here
|
||||
s_tcp_server[type]->start<WebSocketSession<SessionForC, HttpsSession, WebSocketHeader::TEXT> >(port);
|
||||
break;
|
||||
default:
|
||||
@@ -307,10 +309,12 @@ TcpClientForC::Ptr *mk_tcp_client_create_l(mk_tcp_client_events *events, mk_tcp_
|
||||
case mk_type_ssl:
|
||||
return (TcpClientForC::Ptr *)new std::shared_ptr<SessionWithSSL<TcpClientForC> >(new SessionWithSSL<TcpClientForC>(events));
|
||||
case mk_type_ws:
|
||||
//此处你也可以修改WebSocketHeader::BINARY
|
||||
// 此处你也可以修改WebSocketHeader::BINARY [AUTO-TRANSLATED:706abaab]
|
||||
// You can also modify WebSocketHeader::BINARY here
|
||||
return (TcpClientForC::Ptr *)new std::shared_ptr<WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, false> >(new WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, false>(events));
|
||||
case mk_type_wss:
|
||||
//此处你也可以修改WebSocketHeader::BINARY
|
||||
// 此处你也可以修改WebSocketHeader::BINARY [AUTO-TRANSLATED:706abaab]
|
||||
// You can also modify WebSocketHeader::BINARY
|
||||
return (TcpClientForC::Ptr *)new std::shared_ptr<WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, true> >(new WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, true>(events));
|
||||
default:
|
||||
return nullptr;
|
||||
|
||||
@@ -134,7 +134,8 @@ API_EXPORT void API_CALL mk_timer_release(mk_timer ctx){
|
||||
class WorkThreadPoolForC : public TaskExecutorGetterImp {
|
||||
public:
|
||||
WorkThreadPoolForC(const char *name, size_t n_thread, int priority) {
|
||||
//最低优先级
|
||||
// 最低优先级 [AUTO-TRANSLATED:cd1f0dbc]
|
||||
// Lowest priority
|
||||
addPoller(name, n_thread, (ThreadPool::Priority) priority, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ API_EXPORT mk_ini API_CALL mk_ini_default() {
|
||||
|
||||
static void emit_ini_file_reload(mk_ini ini) {
|
||||
if (ini == mk_ini_default()) {
|
||||
// 广播配置文件热加载
|
||||
// 广播配置文件热加载 [AUTO-TRANSLATED:86a0c1be]
|
||||
// Broadcast configuration hot reload
|
||||
NOTICE_EMIT(BroadcastReloadConfigArgs, Broadcast::kBroadcastReloadConfig);
|
||||
}
|
||||
}
|
||||
@@ -223,7 +224,8 @@ API_EXPORT void API_CALL mk_get_statistic(on_mk_get_statistic_cb func, void *use
|
||||
(*obj).emplace(prefix + pr.first, std::move(pr.second));
|
||||
}
|
||||
}
|
||||
// 触发回调
|
||||
// 触发回调 [AUTO-TRANSLATED:ae2ff258]
|
||||
// Trigger callback
|
||||
cb(*obj);
|
||||
});
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ static void on_h264_frame(void *user_data, mk_h264_splitter splitter, const char
|
||||
}
|
||||
|
||||
|
||||
//按照json转义规则转义webrtc answer sdp
|
||||
// 按照json转义规则转义webrtc answer sdp [AUTO-TRANSLATED:b9373d68]
|
||||
// Escape the webrtc answer sdp according to json escape rules
|
||||
static char *escape_string(const char *ptr){
|
||||
char *escaped = malloc(2 * strlen(ptr));
|
||||
char *ptr_escaped = escaped;
|
||||
@@ -108,8 +109,16 @@ static void on_mk_webrtc_get_answer_sdp_func(void *user_data, const char *answer
|
||||
* @param invoker 执行该invoker返回http回复
|
||||
* @param consumed 置1则说明我们要处理该事件
|
||||
* @param sender http客户端相关信息
|
||||
* Receive http api request broadcast (including GET/POST)
|
||||
* @param parser http request content object
|
||||
* @param invoker Execute this invoker to return http reply
|
||||
* @param consumed Set to 1 if we want to handle this event
|
||||
* @param sender http client related information
|
||||
|
||||
* [AUTO-TRANSLATED:39435e52]
|
||||
*/
|
||||
//测试url : http://127.0.0.1/api/test
|
||||
// 测试url : http://127.0.0.1/api/test [AUTO-TRANSLATED:4776d7a3]
|
||||
// Test url: http://127.0.0.1/api/test
|
||||
void API_CALL on_mk_http_request(const mk_parser parser,
|
||||
const mk_http_response_invoker invoker,
|
||||
int *consumed,
|
||||
@@ -119,7 +128,8 @@ void API_CALL on_mk_http_request(const mk_parser parser,
|
||||
*consumed = 1;
|
||||
|
||||
if (strcmp(url, "/index/api/webrtc") == 0) {
|
||||
//拦截api: /index/api/webrtc
|
||||
// 拦截api: /index/api/webrtc [AUTO-TRANSLATED:1db21d1c]
|
||||
// Intercept api: /index/api/webrtc
|
||||
char rtc_url[1024];
|
||||
snprintf(rtc_url, sizeof(rtc_url), "rtc://%s/%s/%s?%s", mk_parser_get_header(parser, "Host"),
|
||||
mk_parser_get_url_param(parser, "app"), mk_parser_get_url_param(parser, "stream"),
|
||||
@@ -179,7 +189,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
mk_media media = mk_media_create("__defaultVhost__", "live", "test", 0, 0, 0);
|
||||
//h264的codec
|
||||
// h264的codec [AUTO-TRANSLATED:940c6a32]
|
||||
// h264 codec
|
||||
//mk_media_init_video(media, 0, 0, 0, 0, 2 * 104 * 1024);
|
||||
codec_args v_args = {0};
|
||||
mk_track v_track = mk_track_create(MKCodecH264, &v_args);
|
||||
@@ -187,7 +198,8 @@ int main(int argc, char *argv[]) {
|
||||
mk_media_init_complete(media);
|
||||
mk_track_unref(v_track);
|
||||
|
||||
//创建h264分帧器
|
||||
// 创建h264分帧器 [AUTO-TRANSLATED:5775837d]
|
||||
// Create h264 frame splitter
|
||||
mk_h264_splitter splitter = mk_h264_splitter_create(on_h264_frame, media, 0);
|
||||
signal(SIGINT, s_on_exit);// 设置退出信号
|
||||
|
||||
@@ -197,7 +209,8 @@ int main(int argc, char *argv[]) {
|
||||
if (size > 0) {
|
||||
mk_h264_splitter_input_data(splitter, buf, size);
|
||||
} else {
|
||||
//文件读完了,重新开始
|
||||
// 文件读完了,重新开始 [AUTO-TRANSLATED:035fb238]
|
||||
// File read finished, start again
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,23 +69,27 @@ void API_CALL on_regist(void *user_data, mk_media_source sender, int regist) {
|
||||
Context *ptr = (Context *)user_data;
|
||||
const char *schema = mk_media_source_get_schema(sender);
|
||||
if (strstr(ptr->url, schema) != ptr->url) {
|
||||
// 协议匹配失败
|
||||
// 协议匹配失败 [AUTO-TRANSLATED:436784d0]
|
||||
// Protocol matching failed
|
||||
return;
|
||||
}
|
||||
|
||||
if (!regist) {
|
||||
// 注销
|
||||
// 注销 [AUTO-TRANSLATED:ebc5be28]
|
||||
// Log out
|
||||
if (ptr->pusher) {
|
||||
mk_pusher_release(ptr->pusher);
|
||||
ptr->pusher = NULL;
|
||||
}
|
||||
} else {
|
||||
// 注册
|
||||
// 注册 [AUTO-TRANSLATED:e2df30a6]
|
||||
// Register
|
||||
if (!ptr->pusher) {
|
||||
ptr->pusher = mk_pusher_create_src(sender);
|
||||
mk_pusher_set_on_result2(ptr->pusher, on_push_result, ptr, NULL);
|
||||
mk_pusher_set_on_shutdown2(ptr->pusher, on_push_shutdown, ptr, NULL);
|
||||
// 开始推流
|
||||
// 开始推流 [AUTO-TRANSLATED:df3972ff]
|
||||
// Start streaming
|
||||
mk_pusher_publish(ptr->pusher, ptr->url);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +119,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
mk_media media = mk_media_create("__defaultVhost__", "live", "test", 0, 0, 0);
|
||||
// h264的codec
|
||||
// h264的codec [AUTO-TRANSLATED:e840179e]
|
||||
// h264 codec
|
||||
codec_args v_args = { 0 };
|
||||
mk_track v_track = mk_track_create(MKCodecH264, &v_args);
|
||||
mk_media_init_track(media, v_track);
|
||||
@@ -128,7 +133,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
mk_media_set_on_regist2(media, on_regist, ctx, release_context);
|
||||
|
||||
// 创建h264分帧器
|
||||
// 创建h264分帧器 [AUTO-TRANSLATED:72254159]
|
||||
// Create h264 frame splitter
|
||||
mk_h264_splitter splitter = mk_h264_splitter_create(on_h264_frame, media, 0);
|
||||
signal(SIGINT, s_on_exit); // 设置退出信号
|
||||
signal(SIGTERM, s_on_exit); // 设置退出信号
|
||||
@@ -139,7 +145,8 @@ int main(int argc, char *argv[]) {
|
||||
if (size > 0) {
|
||||
mk_h264_splitter_input_data(splitter, buf, size);
|
||||
} else {
|
||||
// 文件读完了,重新开始
|
||||
// 文件读完了,重新开始 [AUTO-TRANSLATED:ffffe75c]
|
||||
// File read finished, start again
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ int main(int argc, char *argv[]) {
|
||||
mk_http_requester_set_cb(requester, on_requester_complete, &ctx);
|
||||
mk_http_requester_start(requester, "http://www.baidu.com/baidu", 10);
|
||||
|
||||
//等待http请求完毕
|
||||
// 等待http请求完毕 [AUTO-TRANSLATED:0c1d7dea]
|
||||
// Wait for the HTTP request to complete
|
||||
mk_sem_wait(sem);
|
||||
|
||||
mk_sem_release(sem);
|
||||
|
||||
@@ -33,14 +33,16 @@ void API_CALL on_frame_decode(void *user_data, mk_frame_pix frame) {
|
||||
int align = 32;
|
||||
size_t pixel_size = 3;
|
||||
size_t raw_linesize = w * pixel_size;
|
||||
// 对齐后的宽度
|
||||
// 对齐后的宽度 [AUTO-TRANSLATED:f9bfe888]
|
||||
// Aligned width
|
||||
size_t aligned_linesize = (raw_linesize + align - 1) & ~(align - 1);
|
||||
size_t total_size = aligned_linesize * h;
|
||||
uint8_t* brg24 = malloc(total_size);
|
||||
mk_swscale_input_frame(ctx->swscale, frame, brg24);
|
||||
free(brg24);
|
||||
#else
|
||||
//todo 此处转换为opencv对象
|
||||
// todo 此处转换为opencv对象 [AUTO-TRANSLATED:37358ee1]
|
||||
// todo Convert to opencv object here
|
||||
cv::Mat *mat = new cv::Mat();
|
||||
mat->create(h, w, CV_8UC3);
|
||||
mk_swscale_input_frame(ctx->swscale, frame, (uint8_t *) mat->data);
|
||||
@@ -60,7 +62,8 @@ void API_CALL on_mk_play_event_func(void *user_data, int err_code, const char *e
|
||||
log_info("got video track: %s", mk_track_codec_name(tracks[i]));
|
||||
ctx->video_decoder = mk_decoder_create(tracks[i], 0);
|
||||
mk_decoder_set_cb(ctx->video_decoder, on_frame_decode, user_data);
|
||||
//监听track数据回调
|
||||
// 监听track数据回调 [AUTO-TRANSLATED:8295ebf6]
|
||||
// Listen to track data callback
|
||||
mk_track_add_delegate(tracks[i], on_track_frame_out, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,8 @@ void API_CALL on_mk_media_source_regist_func(void *user_data, mk_media_source se
|
||||
Context *ctx = (Context *) user_data;
|
||||
const char *schema = mk_media_source_get_schema(sender);
|
||||
if (strncmp(schema, ctx->push_url, strlen(schema)) == 0) {
|
||||
//判断是否为推流协议相关的流注册或注销事件
|
||||
// 判断是否为推流协议相关的流注册或注销事件 [AUTO-TRANSLATED:00a88a17]
|
||||
// Determine if it is a stream registration or deregistration event related to the streaming protocol
|
||||
release_pusher(&(ctx->pusher));
|
||||
if (regist) {
|
||||
ctx->pusher = mk_pusher_create_src(sender);
|
||||
@@ -131,17 +132,20 @@ int main(int argc, char *argv[]){
|
||||
return -1;
|
||||
}
|
||||
|
||||
//可以通过
|
||||
// 可以通过 [AUTO-TRANSLATED:9a320d61]
|
||||
// Can be achieved through
|
||||
//rtmp://127.0.0.1/live/test
|
||||
//rtsp://127.0.0.1/live/test
|
||||
//播放mk_media的数据
|
||||
// 播放mk_media的数据 [AUTO-TRANSLATED:623dc58f]
|
||||
// Playing the data of mk_media
|
||||
mk_rtsp_server_start(554, 0);
|
||||
mk_rtmp_server_start(1935, 0);
|
||||
|
||||
Context *ctx = (Context *) malloc(sizeof(Context));
|
||||
memset(ctx, 0, sizeof(Context));
|
||||
|
||||
//推流给自己测试,当然也可以推流给其他服务器测试
|
||||
// 推流给自己测试,当然也可以推流给其他服务器测试 [AUTO-TRANSLATED:616e4dc2]
|
||||
// Stream to yourself for testing, of course, you can also stream to other servers for testing
|
||||
context_start(ctx, argv[1], argv[2]);
|
||||
|
||||
log_info("enter any key to exit");
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
* 注册或反注册MediaSource事件广播
|
||||
* @param regist 注册为1,注销为0
|
||||
* @param sender 该MediaSource对象
|
||||
* Register or unregister MediaSource event broadcast
|
||||
* @param regist Register as 1, unregister as 0
|
||||
* @param sender The MediaSource object
|
||||
|
||||
* [AUTO-TRANSLATED:8bb75918]
|
||||
*/
|
||||
void API_CALL on_mk_media_changed(int regist,
|
||||
const mk_media_source sender) {
|
||||
@@ -34,6 +39,13 @@ void API_CALL on_mk_media_changed(int regist,
|
||||
* @param url_info 推流url相关信息
|
||||
* @param invoker 执行invoker返回鉴权结果
|
||||
* @param sender 该tcp客户端相关信息
|
||||
* Receive rtsp/rtmp push stream event broadcast, control push stream authentication through this event
|
||||
* @see mk_publish_auth_invoker_do
|
||||
* @param url_info Push stream url related information
|
||||
* @param invoker Execute invoker to return authentication result
|
||||
* @param sender The tcp client related information
|
||||
|
||||
* [AUTO-TRANSLATED:72053c81]
|
||||
*/
|
||||
void API_CALL on_mk_media_publish(const mk_media_info url_info,
|
||||
const mk_publish_auth_invoker invoker,
|
||||
@@ -52,7 +64,8 @@ void API_CALL on_mk_media_publish(const mk_media_info url_info,
|
||||
mk_media_info_get_stream(url_info),
|
||||
mk_media_info_get_params(url_info));
|
||||
|
||||
//允许推流,并且允许转hls/mp4
|
||||
// 允许推流,并且允许转hls/mp4 [AUTO-TRANSLATED:4b2d0e4e]
|
||||
// Allow push stream, and allow to convert to hls/mp4
|
||||
mk_publish_auth_invoker_do(invoker, NULL, 1, 1);
|
||||
}
|
||||
|
||||
@@ -62,6 +75,13 @@ void API_CALL on_mk_media_publish(const mk_media_info url_info,
|
||||
* @param url_info 播放url相关信息
|
||||
* @param invoker 执行invoker返回鉴权结果
|
||||
* @param sender 播放客户端相关信息
|
||||
* Play rtsp/rtmp/http-flv/hls event broadcast, control playback authentication through this event
|
||||
* @see mk_auth_invoker_do
|
||||
* @param url_info Play url related information
|
||||
* @param invoker Execute invoker to return authentication result
|
||||
* @param sender Play client related information
|
||||
|
||||
* [AUTO-TRANSLATED:fc351667]
|
||||
*/
|
||||
void API_CALL on_mk_media_play(const mk_media_info url_info,
|
||||
const mk_auth_invoker invoker,
|
||||
@@ -81,7 +101,8 @@ void API_CALL on_mk_media_play(const mk_media_info url_info,
|
||||
mk_media_info_get_stream(url_info),
|
||||
mk_media_info_get_params(url_info));
|
||||
|
||||
//允许播放
|
||||
// 允许播放 [AUTO-TRANSLATED:b940f821]
|
||||
// Allow playback
|
||||
mk_auth_invoker_do(invoker, NULL);
|
||||
}
|
||||
|
||||
@@ -91,6 +112,13 @@ void API_CALL on_mk_media_play(const mk_media_info url_info,
|
||||
* @param sender 播放客户端相关信息
|
||||
* @return 1 直接关闭
|
||||
* 0 等待流注册
|
||||
* This event will be broadcast after the stream is not found. Please pull the stream or other methods to generate the stream after listening to this event, so that you can pull the stream on demand
|
||||
* @param url_info Play url related information
|
||||
* @param sender Play client related information
|
||||
* @return 1 Close directly
|
||||
* 0 Wait for stream registration
|
||||
|
||||
* [AUTO-TRANSLATED:71caa7d8]
|
||||
*/
|
||||
int API_CALL on_mk_media_not_found(const mk_media_info url_info,
|
||||
const mk_sock_info sender) {
|
||||
@@ -113,6 +141,10 @@ int API_CALL on_mk_media_not_found(const mk_media_info url_info,
|
||||
/**
|
||||
* 某个流无人消费时触发,目的为了实现无人观看时主动断开拉流等业务逻辑
|
||||
* @param sender 该MediaSource对象
|
||||
* Triggered when no one consumes a certain stream, the purpose is to achieve business logic such as actively disconnecting the pull stream when no one is watching
|
||||
* @param sender The MediaSource object
|
||||
|
||||
* [AUTO-TRANSLATED:d2881c87]
|
||||
*/
|
||||
void API_CALL on_mk_media_no_reader(const mk_media_source sender) {
|
||||
log_printf(LOG_LEV,
|
||||
@@ -123,7 +155,8 @@ void API_CALL on_mk_media_no_reader(const mk_media_source sender) {
|
||||
mk_media_source_get_stream(sender));
|
||||
}
|
||||
|
||||
//按照json转义规则转义webrtc answer sdp
|
||||
// 按照json转义规则转义webrtc answer sdp [AUTO-TRANSLATED:b9373d68]
|
||||
// Escape webrtc answer sdp according to json escape rules
|
||||
static char *escape_string(const char *ptr){
|
||||
char *escaped = malloc(2 * strlen(ptr));
|
||||
char *ptr_escaped = escaped;
|
||||
@@ -203,8 +236,16 @@ void API_CALL on_get_statistic_cb(void *user_data, mk_ini ini) {
|
||||
* @param invoker 执行该invoker返回http回复
|
||||
* @param consumed 置1则说明我们要处理该事件
|
||||
* @param sender http客户端相关信息
|
||||
* Receive http api request broadcast (including GET/POST)
|
||||
* @param parser Http request content object
|
||||
* @param invoker Execute this invoker to return http reply
|
||||
* @param consumed Set to 1 if we want to handle this event
|
||||
* @param sender Http client related information
|
||||
|
||||
* [AUTO-TRANSLATED:39435e52]
|
||||
*/
|
||||
//测试url : http://127.0.0.1/api/test
|
||||
// 测试url : http://127.0.0.1/api/test [AUTO-TRANSLATED:4776d7a3]
|
||||
// Test url : http://127.0.0.1/api/test
|
||||
void API_CALL on_mk_http_request(const mk_parser parser,
|
||||
const mk_http_response_invoker invoker,
|
||||
int *consumed,
|
||||
@@ -230,7 +271,8 @@ void API_CALL on_mk_http_request(const mk_parser parser,
|
||||
const char *url = mk_parser_get_url(parser);
|
||||
*consumed = 1;
|
||||
|
||||
//拦截api: /api/test
|
||||
// 拦截api: /api/test [AUTO-TRANSLATED:262baadf]
|
||||
// Intercept api: /api/test
|
||||
if (strcmp(url, "/api/test") == 0) {
|
||||
const char *response_header[] = { "Content-Type", "text/html", NULL };
|
||||
const char *content = "<html>"
|
||||
@@ -247,7 +289,8 @@ void API_CALL on_mk_http_request(const mk_parser parser,
|
||||
mk_http_response_invoker_do(invoker, 200, response_header, body);
|
||||
mk_http_body_release(body);
|
||||
} else if (strcmp(url, "/index/api/webrtc") == 0) {
|
||||
//拦截api: /index/api/webrtc
|
||||
// 拦截api: /index/api/webrtc [AUTO-TRANSLATED:1db21d1c]
|
||||
// Intercept api: /index/api/webrtc
|
||||
char rtc_url[1024];
|
||||
snprintf(rtc_url, sizeof(rtc_url), "rtc://%s/%s/%s?%s", mk_parser_get_header(parser, "Host"),
|
||||
mk_parser_get_url_param(parser, "app"), mk_parser_get_url_param(parser, "stream"),
|
||||
@@ -256,7 +299,8 @@ void API_CALL on_mk_http_request(const mk_parser parser,
|
||||
mk_webrtc_get_answer_sdp(mk_http_response_invoker_clone(invoker), on_mk_webrtc_get_answer_sdp_func,
|
||||
mk_parser_get_url_param(parser, "type"), mk_parser_get_content(parser, NULL), rtc_url);
|
||||
} else if (strcmp(url, "/index/api/getStatistic") == 0) {
|
||||
//拦截api: /index/api/webrtc
|
||||
// 拦截api: /index/api/webrtc [AUTO-TRANSLATED:1db21d1c]
|
||||
// Intercept api: /index/api/webrtc
|
||||
mk_get_statistic(on_get_statistic_cb, mk_http_response_invoker_clone(invoker), (on_user_data_free) mk_http_response_invoker_clone_release);
|
||||
} else {
|
||||
*consumed = 0;
|
||||
@@ -271,6 +315,14 @@ void API_CALL on_mk_http_request(const mk_parser parser,
|
||||
* @param is_dir path是否为文件夹
|
||||
* @param invoker 执行invoker返回本次访问文件的结果
|
||||
* @param sender http客户端相关信息
|
||||
* In the http file server, receive the broadcast of http access to files or directories, control the access permission of http directory through this event
|
||||
* @param parser Http request content object
|
||||
* @param path File absolute path
|
||||
* @param is_dir Whether path is a folder
|
||||
* @param invoker Execute invoker to return the result of accessing the file this time
|
||||
* @param sender Http client related information
|
||||
|
||||
* [AUTO-TRANSLATED:2db5fc1e]
|
||||
*/
|
||||
void API_CALL on_mk_http_access(const mk_parser parser,
|
||||
const char *path,
|
||||
@@ -296,7 +348,8 @@ void API_CALL on_mk_http_access(const mk_parser parser,
|
||||
mk_parser_get_header(parser,"User-Agent"),
|
||||
mk_parser_get_content(parser,NULL));
|
||||
|
||||
//有访问权限,每次访问文件都需要鉴权
|
||||
// 有访问权限,每次访问文件都需要鉴权 [AUTO-TRANSLATED:6ade8f21]
|
||||
// Has access permission, each access to the file needs authentication
|
||||
mk_http_access_path_invoker_do(invoker, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -306,6 +359,13 @@ void API_CALL on_mk_http_access(const mk_parser parser,
|
||||
* @param parser http请求内容对象
|
||||
* @param path 文件绝对路径,覆盖之可以重定向到其他文件
|
||||
* @param sender http客户端相关信息
|
||||
* In the http file server, receive the broadcast before http access to files or directories, through this event you can control the mapping of http url to file path
|
||||
* By overriding the path parameter in this event, you can achieve the purpose of selecting different http root directories according to virtual hosts or apps
|
||||
* @param parser Http request content object
|
||||
* @param path File absolute path, override it to redirect to other files
|
||||
* @param sender Http client related information
|
||||
|
||||
* [AUTO-TRANSLATED:e166f6cb]
|
||||
*/
|
||||
void API_CALL on_mk_http_before_access(const mk_parser parser,
|
||||
char *path,
|
||||
@@ -328,7 +388,8 @@ void API_CALL on_mk_http_before_access(const mk_parser parser,
|
||||
mk_parser_get_tail(parser),
|
||||
mk_parser_get_header(parser, "User-Agent"),
|
||||
mk_parser_get_content(parser,NULL));
|
||||
//覆盖path的值可以重定向文件
|
||||
// 覆盖path的值可以重定向文件 [AUTO-TRANSLATED:7b03ed02]
|
||||
// Overriding the value of path can redirect files
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,6 +397,12 @@ void API_CALL on_mk_http_before_access(const mk_parser parser,
|
||||
* @param url_info 请求rtsp url相关信息
|
||||
* @param invoker 执行invoker返回是否需要rtsp专属认证
|
||||
* @param sender rtsp客户端相关信息
|
||||
* Does this rtsp stream need authentication? If so, call invoker and pass in realm, otherwise pass in empty realm
|
||||
* @param url_info Request rtsp url related information
|
||||
* @param invoker Execute invoker to return whether rtsp exclusive authentication is required
|
||||
* @param sender Rtsp client related information
|
||||
|
||||
* [AUTO-TRANSLATED:3308f34e]
|
||||
*/
|
||||
void API_CALL on_mk_rtsp_get_realm(const mk_media_info url_info,
|
||||
const mk_rtsp_get_realm_invoker invoker,
|
||||
@@ -354,7 +421,8 @@ void API_CALL on_mk_rtsp_get_realm(const mk_media_info url_info,
|
||||
mk_media_info_get_stream(url_info),
|
||||
mk_media_info_get_params(url_info));
|
||||
|
||||
//rtsp播放默认鉴权
|
||||
// rtsp播放默认鉴权 [AUTO-TRANSLATED:3a820721]
|
||||
// Rtsp playback default authentication
|
||||
mk_rtsp_get_realm_invoker_do(invoker, "zlmediakit");
|
||||
}
|
||||
|
||||
@@ -367,6 +435,16 @@ void API_CALL on_mk_rtsp_get_realm(const mk_media_info url_info,
|
||||
* @param must_no_encrypt 如果为1,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
|
||||
* @param invoker 执行invoker返回rtsp专属认证的密码
|
||||
* @param sender rtsp客户端信息
|
||||
* Request authentication user password event, user_name is the username, must_no_encrypt if it is 1, then you must provide plain text password (because it is base64 authentication method at this time), otherwise it will lead to authentication failure
|
||||
* After getting the password, please call invoker and enter the corresponding type of password and password type, invoker will match the password when executing
|
||||
* @param url_info Request rtsp url related information
|
||||
* @param realm Rtsp authentication realm
|
||||
* @param user_name Rtsp authentication username
|
||||
* @param must_no_encrypt If it is 1, then you must provide plain text password (because it is base64 authentication method at this time), otherwise it will lead to authentication failure
|
||||
* @param invoker Execute invoker to return the password of rtsp exclusive authentication
|
||||
* @param sender Rtsp client information
|
||||
|
||||
* [AUTO-TRANSLATED:28391926]
|
||||
*/
|
||||
void API_CALL on_mk_rtsp_auth(const mk_media_info url_info,
|
||||
const char *realm,
|
||||
@@ -391,12 +469,16 @@ void API_CALL on_mk_rtsp_auth(const mk_media_info url_info,
|
||||
mk_media_info_get_params(url_info),
|
||||
realm,user_name,(int)must_no_encrypt);
|
||||
|
||||
//rtsp播放用户名跟密码一致
|
||||
// rtsp播放用户名跟密码一致 [AUTO-TRANSLATED:31cc5970]
|
||||
// Rtsp playback username and password are consistent
|
||||
mk_rtsp_auth_invoker_do(invoker,0,user_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 录制mp4分片文件成功后广播
|
||||
* Broadcast after recording mp4 fragment file successfully
|
||||
|
||||
* [AUTO-TRANSLATED:0fdeba0d]
|
||||
*/
|
||||
void API_CALL on_mk_record_mp4(const mk_record_info mp4) {
|
||||
log_printf(LOG_LEV,
|
||||
@@ -424,6 +506,9 @@ void API_CALL on_mk_record_mp4(const mk_record_info mp4) {
|
||||
|
||||
/**
|
||||
* shell登录鉴权
|
||||
* Shell login authentication
|
||||
|
||||
* [AUTO-TRANSLATED:cc20f95e]
|
||||
*/
|
||||
void API_CALL on_mk_shell_login(const char *user_name,
|
||||
const char *passwd,
|
||||
@@ -438,7 +523,8 @@ void API_CALL on_mk_shell_login(const char *user_name,
|
||||
mk_sock_info_peer_ip(sender,ip + 32),
|
||||
mk_sock_info_peer_port(sender),
|
||||
user_name, passwd);
|
||||
//允许登录shell
|
||||
// 允许登录shell [AUTO-TRANSLATED:64a9b374]
|
||||
// Allow login shell
|
||||
mk_auth_invoker_do(invoker, NULL);
|
||||
}
|
||||
|
||||
@@ -450,6 +536,15 @@ void API_CALL on_mk_shell_login(const char *user_name,
|
||||
* @param is_player 客户端是否为播放器
|
||||
* @param peer_ip 客户端ip
|
||||
* @param peer_port 客户端端口号
|
||||
* Stop rtsp/rtmp/http-flv session after traffic report event broadcast
|
||||
* @param url_info Play url related information
|
||||
* @param total_bytes Total traffic consumed up and down, unit is byte
|
||||
* @param total_seconds The duration of this tcp session, unit is second
|
||||
* @param is_player Whether the client is a player
|
||||
* @param peer_ip Client ip
|
||||
* @param peer_port Client port number
|
||||
|
||||
* [AUTO-TRANSLATED:6757a1c3]
|
||||
*/
|
||||
void API_CALL on_mk_flow_report(const mk_media_info url_info,
|
||||
size_t total_bytes,
|
||||
|
||||
@@ -14,18 +14,24 @@
|
||||
#include "mk_mediakit.h"
|
||||
|
||||
#define LOG_LEV 4
|
||||
//修改此宏,可以选择协议类型
|
||||
// 修改此宏,可以选择协议类型 [AUTO-TRANSLATED:7a3e6a3a]
|
||||
// Modify this macro to choose the protocol type
|
||||
#define TCP_TYPE mk_type_ws
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct {
|
||||
mk_tcp_session _session;
|
||||
//下面你可以夹杂你的私货数据
|
||||
// 下面你可以夹杂你的私货数据 [AUTO-TRANSLATED:99451203]
|
||||
// You can insert your private data below
|
||||
char your_some_useful_data[1024];
|
||||
} tcp_session_user_data;
|
||||
/**
|
||||
* 当tcp客户端连接服务器时触发
|
||||
* @param session 会话处理对象
|
||||
* Triggered when the tcp client connects to the server
|
||||
* @param session Session processing object
|
||||
|
||||
* [AUTO-TRANSLATED:0030d1a6]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_session_create(uint16_t server_port,mk_tcp_session session){
|
||||
char ip[64];
|
||||
@@ -40,6 +46,12 @@ void API_CALL on_mk_tcp_session_create(uint16_t server_port,mk_tcp_session sessi
|
||||
* @param session 会话处理对象
|
||||
* @param data 数据指针
|
||||
* @param len 数据长度
|
||||
* Receive data sent from the tcp client
|
||||
* @param session Session processing object
|
||||
* @param data Data pointer
|
||||
* @param len Data length
|
||||
|
||||
* [AUTO-TRANSLATED:f8f01265]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_session_data(uint16_t server_port,mk_tcp_session session, mk_buffer buffer){
|
||||
char ip[64];
|
||||
@@ -55,6 +67,10 @@ void API_CALL on_mk_tcp_session_data(uint16_t server_port,mk_tcp_session session
|
||||
/**
|
||||
* 每隔2秒的定时器,用于管理超时等任务
|
||||
* @param session 会话处理对象
|
||||
* Timer every 2 seconds, used to manage timeout tasks
|
||||
* @param session Session processing object
|
||||
|
||||
* [AUTO-TRANSLATED:f664481f]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_session_manager(uint16_t server_port,mk_tcp_session session){
|
||||
char ip[64];
|
||||
@@ -67,6 +83,13 @@ void API_CALL on_mk_tcp_session_manager(uint16_t server_port,mk_tcp_session sess
|
||||
* @param session 会话处理对象
|
||||
* @param code 错误代码
|
||||
* @param msg 错误提示
|
||||
* Generally triggered by the client disconnecting tcp
|
||||
* You can call the mk_tcp_session_send_safe function in this event
|
||||
* @param session Session processing object
|
||||
* @param code Error code
|
||||
* @param msg Error message
|
||||
|
||||
* [AUTO-TRANSLATED:62628263]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_session_disconnect(uint16_t server_port,mk_tcp_session session,int code,const char *msg){
|
||||
char ip[64];
|
||||
@@ -78,7 +101,8 @@ void API_CALL on_mk_tcp_session_disconnect(uint16_t server_port,mk_tcp_session s
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct {
|
||||
mk_tcp_client client;
|
||||
//下面你可以夹杂你的私货数据
|
||||
// 下面你可以夹杂你的私货数据 [AUTO-TRANSLATED:99451203]
|
||||
// You can insert your private data below
|
||||
char your_some_useful_data[1024];
|
||||
int count;
|
||||
} tcp_client_user_data;
|
||||
@@ -88,11 +112,18 @@ typedef struct {
|
||||
* @param client tcp客户端
|
||||
* @param code 0为连接成功,否则为失败原因
|
||||
* @param msg 连接失败错误提示
|
||||
* Callback for successful or failed connection of tcp client to server
|
||||
* @param client Tcp client
|
||||
* @param code 0 for successful connection, otherwise the reason for failure
|
||||
* @param msg Connection failure error message
|
||||
|
||||
* [AUTO-TRANSLATED:0737893b]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_client_connect(mk_tcp_client client,int code,const char *msg){
|
||||
log_printf(LOG_LEV,"connect result:%d %s",code,msg);
|
||||
if(code == 0){
|
||||
//连接上后我们发送一个hello world测试数据
|
||||
// 连接上后我们发送一个hello world测试数据 [AUTO-TRANSLATED:9eb05433]
|
||||
// After connecting, we send a hello world test data
|
||||
mk_tcp_client_send(client,"hello world",0);
|
||||
}else{
|
||||
tcp_client_user_data *user_data = mk_tcp_client_get_user_data(client);
|
||||
@@ -107,10 +138,18 @@ void API_CALL on_mk_tcp_client_connect(mk_tcp_client client,int code,const char
|
||||
* @param client tcp客户端
|
||||
* @param code 错误代码
|
||||
* @param msg 错误提示
|
||||
* Callback for disconnection between tcp client and tcp server
|
||||
* Generally caused by eof event
|
||||
* @param client Tcp client
|
||||
* @param code Error code
|
||||
* @param msg Error message
|
||||
|
||||
* [AUTO-TRANSLATED:9cfff388]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_client_disconnect(mk_tcp_client client,int code,const char *msg){
|
||||
log_printf(LOG_LEV,"disconnect:%d %s",code,msg);
|
||||
//服务器主动断开了,我们销毁对象
|
||||
// 服务器主动断开了,我们销毁对象 [AUTO-TRANSLATED:4b142ba4]
|
||||
// The server actively disconnected, we destroy the object
|
||||
tcp_client_user_data *user_data = mk_tcp_client_get_user_data(client);
|
||||
mk_tcp_client_release(client);
|
||||
free(user_data);
|
||||
@@ -121,6 +160,12 @@ void API_CALL on_mk_tcp_client_disconnect(mk_tcp_client client,int code,const ch
|
||||
* @param client tcp客户端
|
||||
* @param data 数据指针
|
||||
* @param len 数据长度
|
||||
* Receive data sent from the tcp server
|
||||
* @param client Tcp client
|
||||
* @param data Data pointer
|
||||
* @param len Data length
|
||||
|
||||
* [AUTO-TRANSLATED:d152eff2]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_client_data(mk_tcp_client client, mk_buffer buffer){
|
||||
log_printf(LOG_LEV, "data[%d]:%s", mk_buffer_get_size(buffer), mk_buffer_get_data(buffer));
|
||||
@@ -129,6 +174,10 @@ void API_CALL on_mk_tcp_client_data(mk_tcp_client client, mk_buffer buffer){
|
||||
/**
|
||||
* 每隔2秒的定时器,用于管理超时等任务
|
||||
* @param client tcp客户端
|
||||
* Timer every 2 seconds, used to manage timeout tasks
|
||||
* @param client Tcp client
|
||||
|
||||
* [AUTO-TRANSLATED:ba842db3]
|
||||
*/
|
||||
void API_CALL on_mk_tcp_client_manager(mk_tcp_client client){
|
||||
tcp_client_user_data *user_data = mk_tcp_client_get_user_data(client);
|
||||
@@ -137,7 +186,8 @@ void API_CALL on_mk_tcp_client_manager(mk_tcp_client client){
|
||||
mk_tcp_client_send(client,buf,0);
|
||||
|
||||
if(++user_data->count == 5){
|
||||
//发送5遍后主动释放对象
|
||||
// 发送5遍后主动释放对象 [AUTO-TRANSLATED:43ce72ca]
|
||||
// Release the object after sending 5 times
|
||||
mk_tcp_client_release(client);
|
||||
free(user_data);
|
||||
}
|
||||
@@ -171,7 +221,8 @@ void test_client(){
|
||||
mk_tcp_client_set_user_data(client,user_data);
|
||||
|
||||
mk_tcp_client_connect(client, "121.40.165.18", 8800, 3);
|
||||
//你可以连接127.0.0.1 80测试
|
||||
// 你可以连接127.0.0.1 80测试 [AUTO-TRANSLATED:68544f6e]
|
||||
// You can connect to 127.0.0.1 80 to test
|
||||
// mk_tcp_client_connect(client, "127.0.0.1", 80, 3);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user