From 4d28b99780c21269f0b2cbef9fbbfb6b0be5d5f1 Mon Sep 17 00:00:00 2001 From: lidaofu-hub <61726674+lidaofu-hub@users.noreply.github.com> Date: Sun, 4 Feb 2024 23:15:11 +0800 Subject: [PATCH] Add mk_proxy_player_create2 for support more proxy options (#3262) --- api/include/mk_proxyplayer.h | 12 ++++++++++++ api/source/mk_proxyplayer.cpp | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/api/include/mk_proxyplayer.h b/api/include/mk_proxyplayer.h index e851aa8c..e8d45b4a 100644 --- a/api/include/mk_proxyplayer.h +++ b/api/include/mk_proxyplayer.h @@ -12,6 +12,7 @@ #define MK_PROXY_PLAYER_H_ #include "mk_common.h" +#include "mk_util.h" #ifdef __cplusplus extern "C" { @@ -31,6 +32,17 @@ typedef struct mk_proxy_player_t *mk_proxy_player; */ 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); +/** + * 创建一个代理播放器 + * @param vhost 虚拟主机名,一般为__defaultVhost__ + * @param app 应用名 + * @param stream 流名 + * @param option ProtocolOption相关配置 + * @return 对象指针 + */ +API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create2(const char *vhost, const char *app, const char *stream, mk_ini option); + + /** * 销毁代理播放器 * @param ctx 对象指针 diff --git a/api/source/mk_proxyplayer.cpp b/api/source/mk_proxyplayer.cpp index 653a9868..0b98e8fe 100644 --- a/api/source/mk_proxyplayer.cpp +++ b/api/source/mk_proxyplayer.cpp @@ -10,6 +10,7 @@ #include "mk_proxyplayer.h" #include "Player/PlayerProxy.h" +#include "mk_util.h" using namespace toolkit; using namespace mediakit; @@ -23,6 +24,14 @@ API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create(const char *vhost, co return (mk_proxy_player) obj; } +API_EXPORT mk_proxy_player API_CALL mk_proxy_player_create2(const char *vhost, const char *app, const char *stream, mk_ini ini) { + assert(vhost && app && stream); + ProtocolOption option(*((mINI *)ini)); + PlayerProxy::Ptr *obj(new PlayerProxy::Ptr(new PlayerProxy(vhost, app, stream, option))); + return (mk_proxy_player)obj; +} + + API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx) { assert(ctx); PlayerProxy::Ptr *obj = (PlayerProxy::Ptr *) ctx;