2019-12-18 11:47:49 +08:00
/*
2023-12-09 16:23:51 +08:00
* Copyright ( c ) 2016 - present The ZLMediaKit project authors . All Rights Reserved .
2019-12-18 11:45:33 +08:00
*
2023-12-09 16:23:51 +08:00
* This file is part of ZLMediaKit ( https : //github.com/ZLMediaKit/ZLMediaKit).
2019-12-18 11:45:33 +08:00
*
2023-12-09 16:23:51 +08:00
* Use of this source code is governed by MIT - like license that can be found in the
2020-04-04 20:30:09 +08:00
* LICENSE file in the root of the source tree . All contributing project authors
* may be found in the AUTHORS file in the root of the source tree .
2019-12-18 11:45:33 +08:00
*/
# ifndef MK_PLAYER_H_
# define MK_PLAYER_H_
2019-12-27 10:10:31 +08:00
# include "mk_common.h"
2022-05-25 15:38:32 +08:00
# include "mk_frame.h"
# include "mk_track.h"
2019-12-18 11:45:33 +08:00
# ifdef __cplusplus
extern " C " {
# endif
2023-02-26 21:45:14 +08:00
typedef struct mk_player_t * mk_player ;
2019-12-18 11:45:33 +08:00
/**
* 播 放 结 果 或 播 放 中 断 事 件 的 回 调
* @ param user_data 用 户 数 据 指 针
* @ param err_code 错 误 代 码 , 0 为 成 功
* @ param err_msg 错 误 提 示
2022-05-25 15:38:32 +08:00
* @ param tracks track列表
* @ param track_count track个数
2024-09-19 14:53:50 +08:00
* 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 : 38 d4c546 ]
2019-12-18 11:45:33 +08:00
*/
2022-05-25 15:38:32 +08:00
typedef void ( API_CALL * on_mk_play_event ) ( void * user_data , int err_code , const char * err_msg , mk_track tracks [ ] ,
int track_count ) ;
2019-12-18 11:45:33 +08:00
/**
2019-12-18 14:43:32 +08:00
* 创 建 一 个 播 放 器 , 支 持 rtmp [ s ] / rtsp [ s ]
2019-12-18 11:45:33 +08:00
* @ return 播 放 器 指 针
2024-09-19 14:53:50 +08:00
* Create a player that supports rtmp [ s ] / rtsp [ s ]
* @ return Player pointer
* [ AUTO - TRANSLATED : 509f 9 a50 ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT mk_player API_CALL mk_player_create ( ) ;
/**
* 销 毁 播 放 器
* @ param ctx 播 放 器 指 针
2024-09-19 14:53:50 +08:00
* Destroy the player
* @ param ctx Player pointer
* [ AUTO - TRANSLATED : 2448 eb93 ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_release ( mk_player ctx ) ;
/**
* 设 置 播 放 器 配 置 选 项
* @ param ctx 播 放 器 指 针
2022-05-25 15:38:32 +08:00
* @ param key 配 置 项 键 , 支 持 net_adapter / rtp_type / rtsp_user / rtsp_pwd / protocol_timeout_ms / media_timeout_ms / beat_interval_ms / wait_track_ready
2019-12-18 11:45:33 +08:00
* @ param val 配 置 项 值 , 如 果 是 整 形 , 需 要 转 换 成 统 一 转 换 成 string
2024-09-19 14:53:50 +08:00
* 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 : 12650e9 f ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_set_option ( mk_player ctx , const char * key , const char * val ) ;
/**
* 开 始 播 放 url
* @ param ctx 播 放 器 指 针
2019-12-18 14:43:32 +08:00
* @ param url rtsp [ s ] / rtmp [ s ] url
2024-09-19 14:53:50 +08:00
* Start playing the url
* @ param ctx Player pointer
* @ param url rtsp [ s ] / rtmp [ s ] url
* [ AUTO - TRANSLATED : dbec813f ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_play ( mk_player ctx , const char * url ) ;
/**
* 暂 停 或 恢 复 播 放 , 仅 对 点 播 有 用
* @ param ctx 播 放 器 指 针
* @ param pause 1 : 暂 停 播 放 , 0 : 恢 复 播 放
2024-09-19 14:53:50 +08:00
* Pause or resume playback , only useful for on - demand
* @ param ctx Player pointer
* @ param pause 1 : Pause playback , 0 : Resume playback
* [ AUTO - TRANSLATED : 28 eee990 ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_pause ( mk_player ctx , int pause ) ;
2021-08-09 18:28:43 +08:00
/**
* 倍 数 播 放 , 仅 对 点 播 有 用
* @ param ctx 播 放 器 指 针
* @ param speed 0.5 1.0 2.0
2024-09-19 14:53:50 +08:00
* Playback at a multiple , only useful for on - demand
* @ param ctx Player pointer
* @ param speed 0.5 1.0 2.0
* [ AUTO - TRANSLATED : 95249 ade ]
2021-08-09 18:28:43 +08:00
*/
API_EXPORT void API_CALL mk_player_speed ( mk_player ctx , float speed ) ;
2019-12-18 11:45:33 +08:00
/**
* 设 置 点 播 进 度 条
* @ param ctx 对 象 指 针
* @ param progress 取 值 范 围 未 0.0 ~ 1.0
2024-09-19 14:53:50 +08:00
* Set the on - demand progress bar
* @ param ctx Object pointer
* @ param progress Value range is 0.0 ~ 1.0
* [ AUTO - TRANSLATED : cede3a8f ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_seekto ( mk_player ctx , float progress ) ;
2021-08-09 18:28:43 +08:00
/**
* 设 置 点 播 进 度 条
* @ param ctx 对 象 指 针
2021-08-12 16:07:31 +08:00
* @ param seek_pos 取 值 范 围 相 对 于 开 始 时 间 增 量 单 位 秒
2024-09-19 14:53:50 +08:00
* 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 ]
2021-08-09 18:28:43 +08:00
*/
2021-08-12 16:07:31 +08:00
API_EXPORT void API_CALL mk_player_seekto_pos ( mk_player ctx , int seek_pos ) ;
2021-08-09 18:28:43 +08:00
2019-12-18 11:45:33 +08:00
/**
* 设 置 播 放 器 开 启 播 放 结 果 回 调 函 数
* @ param ctx 播 放 器 指 针
2020-04-26 19:02:40 +08:00
* @ param cb 回 调 函 数 指 针 , 设 置 null立即取消回调
2019-12-18 11:45:33 +08:00
* @ param user_data 用 户 数 据 指 针
2024-09-19 14:53:50 +08:00
* 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 : 1 c2daeaf ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_set_on_result ( mk_player ctx , on_mk_play_event cb , void * user_data ) ;
2023-02-11 15:14:18 +08:00
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 ) ;
2019-12-18 11:45:33 +08:00
/**
* 设 置 播 放 被 异 常 中 断 的 回 调
* @ param ctx 播 放 器 指 针
2020-04-26 19:02:40 +08:00
* @ param cb 回 调 函 数 指 针 , 设 置 null立即取消回调
2019-12-18 11:45:33 +08:00
* @ param user_data 用 户 数 据 指 针
2024-09-19 14:53:50 +08:00
* 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 : 18f 58697 ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_set_on_shutdown ( mk_player ctx , on_mk_play_event cb , void * user_data ) ;
2023-02-11 15:14:18 +08:00
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 ) ;
2019-12-18 11:45:33 +08:00
2024-09-19 14:53:50 +08:00
// /////////////////////////获取音视频相关信息接口在播放成功回调触发后才有效/////////////////////////////// [AUTO-TRANSLATED:4b53d8ff]
// * Get the duration of the on-demand program, if it is live, return 0, otherwise return the number of seconds
2020-04-18 18:46:20 +08:00
2019-12-18 11:45:33 +08:00
/**
* 获 取 点 播 节 目 时 长 , 如 果 是 直 播 返 回 0 , 否 则 返 回 秒 数
2024-09-19 14:53:50 +08:00
* Get the on - demand playback progress , value range is 0.0 ~ 1.0
* [ AUTO - TRANSLATED : 522140 b7 ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT float API_CALL mk_player_duration ( mk_player ctx ) ;
/**
2021-08-09 18:28:43 +08:00
* 获 取 点 播 播 放 进 度 , 取 值 范 围 0.0 ~ 1.0
2024-09-19 14:53:50 +08:00
* Get the on - demand playback progress position , value range is the increment relative to the start time , unit is seconds
* [ AUTO - TRANSLATED : 921795 a0 ]
2019-12-18 11:45:33 +08:00
*/
API_EXPORT float API_CALL mk_player_progress ( mk_player ctx ) ;
2021-08-09 18:28:43 +08:00
/**
* 获 取 点 播 播 放 进 度 位 置 , 取 值 范 围 相 对 于 开 始 时 间 增 量 单 位 秒
2024-09-19 14:53:50 +08:00
* Get the packet loss rate , valid for rtsp
* @ param ctx Object pointer
* @ param track_type 0 : Video , 1 : Audio
* [ AUTO - TRANSLATED : 058e5089 ]
2021-08-09 18:28:43 +08:00
*/
API_EXPORT int API_CALL mk_player_progress_pos ( mk_player ctx ) ;
2019-12-18 11:45:33 +08:00
/**
* 获 取 丢 包 率 , rtsp时有效
* @ param ctx 对 象 指 针
* @ param track_type 0 : 视 频 , 1 : 音 频
*/
API_EXPORT float API_CALL mk_player_loss_rate ( mk_player ctx , int track_type ) ;
# ifdef __cplusplus
}
# endif
# endif /* MK_PLAYER_H_ */