Commit 2b971a18 by xia-chu

完善c api

parent 39229f9e
...@@ -42,22 +42,22 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx); ...@@ -42,22 +42,22 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx);
/** /**
* 添加视频轨道 * 添加视频轨道
* @param ctx 对象指针 * @param ctx 对象指针
* @param track_id 0:CodecH264/1:CodecH265 * @param codec_id 0:CodecH264/1:CodecH265
* @param width 视频宽度 * @param width 视频宽度
* @param height 视频高度 * @param height 视频高度
* @param fps 视频fps * @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 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 channel 通道数
* @param sample_bit 采样位数,只支持16 * @param sample_bit 采样位数,只支持16
* @param sample_rate 采样率 * @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完毕后调用此函数, * 初始化h264/h265/aac完毕后调用此函数,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define MK_PUSHER_H #define MK_PUSHER_H
#include "mk_common.h" #include "mk_common.h"
#include "mk_events_objects.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -29,7 +30,7 @@ typedef void(API_CALL *on_mk_push_event)(void *user_data,int err_code,const char ...@@ -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对象并创建rtmp[s]/rtsp[s]推流器
* MediaSource通过mk_media_create或mk_proxy_player_create生成 * MediaSource通过mk_media_create或mk_proxy_player_create或推流生成
* 该MediaSource对象必须已注册 * 该MediaSource对象必须已注册
* *
* @param schema 绑定的MediaSource对象所属协议,支持rtsp/rtmp * @param schema 绑定的MediaSource对象所属协议,支持rtsp/rtmp
...@@ -41,6 +42,16 @@ typedef void(API_CALL *on_mk_push_event)(void *user_data,int err_code,const char ...@@ -41,6 +42,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); 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 推流器指针 * @param ctx 推流器指针
*/ */
......
...@@ -131,22 +131,22 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx) { ...@@ -131,22 +131,22 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx) {
delete obj; 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); assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx; MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
VideoInfo info; VideoInfo info;
info.codecId = (CodecId)track_id; info.codecId = (CodecId)codec_id;
info.iFrameRate = fps; info.iFrameRate = fps;
info.iWidth = width; info.iWidth = width;
info.iHeight = height; info.iHeight = height;
(*obj)->getChannel()->initVideo(info); (*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); assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx; MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
AudioInfo info; AudioInfo info;
info.codecId = (CodecId)track_id; info.codecId = (CodecId)codec_id;
info.iSampleRate = sample_rate; info.iSampleRate = sample_rate;
info.iChannel = channels; info.iChannel = channels;
info.iSampleBit = sample_bit; info.iSampleBit = sample_bit;
......
...@@ -19,6 +19,13 @@ API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vh ...@@ -19,6 +19,13 @@ API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vh
return obj; 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){ API_EXPORT void API_CALL mk_pusher_release(mk_pusher ctx){
assert(ctx); assert(ctx);
MediaPusher::Ptr *obj = (MediaPusher::Ptr *)ctx; MediaPusher::Ptr *obj = (MediaPusher::Ptr *)ctx;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论