From 2b971a188d00937f3a7a519cb81231c85dfc31bd Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Tue, 2 Feb 2021 15:11:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84c=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/include/mk_media.h | 8 ++++---- api/include/mk_pusher.h | 13 ++++++++++++- api/source/mk_media.cpp | 8 ++++---- api/source/mk_pusher.cpp | 7 +++++++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/api/include/mk_media.h b/api/include/mk_media.h index 2423ffba..712e25cf 100755 --- a/api/include/mk_media.h +++ b/api/include/mk_media.h @@ -42,22 +42,22 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx); /** * 添加视频轨道 * @param ctx 对象指针 - * @param track_id 0:CodecH264/1:CodecH265 + * @param codec_id 0:CodecH264/1:CodecH265 * @param width 视频宽度 * @param height 视频高度 * @param fps 视频fps */ -API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int track_id, int width, int height, float fps); +API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int codec_id, int width, int height, float fps); /** * 添加音频轨道 * @param ctx 对象指针 - * @param track_id 2:CodecAAC/3:CodecG711A/4:CodecG711U/5:OPUS + * @param codec_id 2:CodecAAC/3:CodecG711A/4:CodecG711U/5:OPUS * @param channel 通道数 * @param sample_bit 采样位数,只支持16 * @param sample_rate 采样率 */ -API_EXPORT void API_CALL mk_media_init_audio(mk_media ctx, int track_id, int sample_rate, int channels, int sample_bit); +API_EXPORT void API_CALL mk_media_init_audio(mk_media ctx, int codec_id, int sample_rate, int channels, int sample_bit); /** * 初始化h264/h265/aac完毕后调用此函数, diff --git a/api/include/mk_pusher.h b/api/include/mk_pusher.h index 4beb9d10..ab94350b 100644 --- a/api/include/mk_pusher.h +++ b/api/include/mk_pusher.h @@ -12,6 +12,7 @@ #define MK_PUSHER_H #include "mk_common.h" +#include "mk_events_objects.h" #ifdef __cplusplus extern "C" { @@ -29,7 +30,7 @@ typedef void(API_CALL *on_mk_push_event)(void *user_data,int err_code,const char /** * 绑定的MediaSource对象并创建rtmp[s]/rtsp[s]推流器 - * MediaSource通过mk_media_create或mk_proxy_player_create生成 + * MediaSource通过mk_media_create或mk_proxy_player_create或推流生成 * 该MediaSource对象必须已注册 * * @param schema 绑定的MediaSource对象所属协议,支持rtsp/rtmp @@ -40,6 +41,16 @@ typedef void(API_CALL *on_mk_push_event)(void *user_data,int err_code,const char */ API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vhost,const char *app, const char *stream); +/** + * 绑定的MediaSource对象并创建rtmp[s]/rtsp[s]推流器 + * MediaSource通过mk_media_create或mk_proxy_player_create或推流生成 + * 该MediaSource对象必须已注册 + * + * @param src MediaSource对象 + * @return 对象指针 + */ +API_EXPORT mk_pusher API_CALL mk_pusher_create_src(mk_media_source src); + /** * 释放推流器 * @param ctx 推流器指针 diff --git a/api/source/mk_media.cpp b/api/source/mk_media.cpp index fefee282..8c20c87d 100755 --- a/api/source/mk_media.cpp +++ b/api/source/mk_media.cpp @@ -131,22 +131,22 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx) { delete obj; } -API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int track_id, int width, int height, float fps){ +API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int codec_id, int width, int height, float fps){ assert(ctx); MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx; VideoInfo info; - info.codecId = (CodecId)track_id; + info.codecId = (CodecId)codec_id; info.iFrameRate = fps; info.iWidth = width; info.iHeight = height; (*obj)->getChannel()->initVideo(info); } -API_EXPORT void API_CALL mk_media_init_audio(mk_media ctx, int track_id, int sample_rate, int channels, int sample_bit){ +API_EXPORT void API_CALL mk_media_init_audio(mk_media ctx, int codec_id, int sample_rate, int channels, int sample_bit){ assert(ctx); MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx; AudioInfo info; - info.codecId = (CodecId)track_id; + info.codecId = (CodecId)codec_id; info.iSampleRate = sample_rate; info.iChannel = channels; info.iSampleBit = sample_bit; diff --git a/api/source/mk_pusher.cpp b/api/source/mk_pusher.cpp index 5ef6323a..ae68e12d 100644 --- a/api/source/mk_pusher.cpp +++ b/api/source/mk_pusher.cpp @@ -19,6 +19,13 @@ API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vh return obj; } +API_EXPORT mk_pusher API_CALL mk_pusher_create_src(mk_media_source ctx){ + assert(ctx); + MediaSource *src = (MediaSource *)ctx; + MediaPusher::Ptr *obj = new MediaPusher::Ptr(new MediaPusher(src->shared_from_this())); + return obj; +} + API_EXPORT void API_CALL mk_pusher_release(mk_pusher ctx){ assert(ctx); MediaPusher::Ptr *obj = (MediaPusher::Ptr *)ctx;