mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
完善c api
This commit is contained in:
parent
39229f9e39
commit
2b971a188d
@ -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 @@
|
|||||||
#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 推流器指针
|
||||||
|
@ -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
|
|||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user