1 /* 2 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. 3 * 4 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). 5 * 6 * Use of this source code is governed by MIT license that can be found in the 7 * LICENSE file in the root of the source tree. All contributing project authors 8 * may be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MK_PROXY_PLAYER_H_ 12 #define MK_PROXY_PLAYER_H_ 13 14 #include "mk_common.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 typedef void *mk_proxy_player; 21 22 /** 23 * 创建一个代理播放器 24 * @param vhost 虚拟主机名,一般为__defaultVhost__ 25 * @param app 应用名 26 * @param stream 流名 27 * @param rtp_type rtsp播放方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2 28 * @param hls_enabled 是否生成hls 29 * @param mp4_enabled 是否生成mp4 30 * @return 对象指针 31 */ 32 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); 33 34 /** 35 * 销毁代理播放器 36 * @param ctx 对象指针 37 */ 38 API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx); 39 40 /** 41 * 设置代理播放器配置选项 42 * @param ctx 代理播放器指针 43 * @param key 配置项键,支持 net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms 44 * @param val 配置项值,如果是整形,需要转换成统一转换成string 45 */ 46 API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const char *key, const char *val); 47 48 /** 49 * 开始播放 50 * @param ctx 对象指针 51 * @param url 播放url,支持rtsp/rtmp 52 */ 53 API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *url); 54 55 /** 56 * MediaSource.close()回调事件 57 * 在选择关闭一个关联的MediaSource时,将会最终触发到该回调 58 * 你应该通过该事件调用mk_proxy_player_release函数并且释放其他资源 59 * 如果你不调用mk_proxy_player_release函数,那么MediaSource.close()操作将无效 60 * @param user_data 用户数据指针,通过mk_proxy_player_set_on_close函数设置 61 */ 62 typedef void(API_CALL *on_mk_proxy_player_close)(void *user_data, int err, const char *what, int sys_err); 63 64 /** 65 * 监听MediaSource.close()事件 66 * 在选择关闭一个关联的MediaSource时,将会最终触发到该回调 67 * 你应该通过该事件调用mk_proxy_player_release函数并且释放其他资源 68 * @param ctx 对象指针 69 * @param cb 回调指针 70 * @param user_data 用户数据指针 71 */ 72 API_EXPORT void API_CALL mk_proxy_player_set_on_close(mk_proxy_player ctx, on_mk_proxy_player_close cb, void *user_data); 73 74 /** 75 * 获取总的观看人数 76 * @param ctx 对象指针 77 * @return 观看人数 78 */ 79 API_EXPORT int API_CALL mk_proxy_player_total_reader_count(mk_proxy_player ctx); 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif /* MK_PROXY_PLAYER_H_ */ 86