From 0773e79fd1fee6cbb4af406f9e427dbd28bd23c1 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Sat, 11 Feb 2023 11:40:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=BD=AC=E5=8D=8F=E8=AE=AE=E5=88=9B=E5=BB=BAmk=5Fmedia?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/include/mk_media.h | 12 ++++++++++++ api/source/mk_media.cpp | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/api/include/mk_media.h b/api/include/mk_media.h index 834a960e..a7efc0d0 100755 --- a/api/include/mk_media.h +++ b/api/include/mk_media.h @@ -16,6 +16,7 @@ #include "mk_frame.h" #include "mk_events_objects.h" #include "mk_thread.h" +#include "mk_util.h" #ifdef __cplusplus extern "C" { @@ -36,6 +37,17 @@ typedef void *mk_media; 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); +/** + * 创建一个媒体源 + * @param vhost 虚拟主机名,一般为__defaultVhost__ + * @param app 应用名,推荐为live + * @param stream 流id,例如camera + * @param duration 时长(单位秒),直播则为0 + * @param option ProtocolOption相关配置 + * @return 对象指针 + */ +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 对象指针 diff --git a/api/source/mk_media.cpp b/api/source/mk_media.cpp index 5a2df445..7200e46e 100755 --- a/api/source/mk_media.cpp +++ b/api/source/mk_media.cpp @@ -163,6 +163,14 @@ API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, return (mk_media) obj; } +API_EXPORT mk_media API_CALL mk_media_create2(const char *vhost, const char *app, const char *stream, float duration, mk_ini ini) { + assert(vhost && app && stream && ini); + ProtocolOption option(*((mINI *)ini)); + MediaHelper::Ptr *obj(new MediaHelper::Ptr(new MediaHelper(vhost, app, stream, duration, option))); + (*obj)->attachEvent(); + return (mk_media) obj; +} + API_EXPORT void API_CALL mk_media_release(mk_media ctx) { assert(ctx); MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;