完善c api

This commit is contained in:
xia-chu 2021-02-02 15:11:16 +08:00
parent 39229f9e39
commit 2b971a188d
4 changed files with 27 additions and 9 deletions

View File

@ -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完毕后调用此函数

View File

@ -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
/** /**
* 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
@ -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); 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

View File

@ -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;

View File

@ -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;