mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 02:34:26 +08:00
c api支持国标推流:#578
This commit is contained in:
parent
c512c1a02e
commit
f05422bb65
@ -115,6 +115,16 @@ API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int forc
|
||||
//MediaSource::seekTo()
|
||||
API_EXPORT int API_CALL mk_media_source_seek_to(const mk_media_source ctx,uint32_t stamp);
|
||||
|
||||
/**
|
||||
* rtp推流成功与否的回调(第一次成功后,后面将一直重试)
|
||||
*/
|
||||
typedef void(API_CALL *on_mk_media_source_send_rtp_result)(void *user_data, int err, const char *msg);
|
||||
|
||||
//MediaSource::startSendRtp,请参考mk_media_start_send_rtp,注意ctx参数类型不一样
|
||||
API_EXPORT void API_CALL mk_media_source_start_send_rtp(const mk_media_source ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int is_udp, on_mk_media_source_send_rtp_result cb, void *user_data);
|
||||
//MediaSource::stopSendRtp,请参考mk_media_stop_send_rtp,注意ctx参数类型不一样
|
||||
API_EXPORT int API_CALL mk_media_source_stop_send_rtp(const mk_media_source ctx);
|
||||
|
||||
//MediaSource::find()
|
||||
API_EXPORT void API_CALL mk_media_source_find(const char *schema,
|
||||
const char *vhost,
|
||||
|
@ -173,6 +173,30 @@ typedef void(API_CALL *on_mk_media_source_regist)(void *user_data, mk_media_sour
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_set_on_regist(mk_media ctx, on_mk_media_source_regist cb, void *user_data);
|
||||
|
||||
/**
|
||||
* rtp推流成功与否的回调(第一次成功后,后面将一直重试)
|
||||
*/
|
||||
typedef on_mk_media_source_send_rtp_result on_mk_media_send_rtp_result;
|
||||
|
||||
/**
|
||||
* 开始发送ps-rtp流
|
||||
* @param ctx 对象指针
|
||||
* @param dst_url 目标ip或域名
|
||||
* @param dst_port 目标端口
|
||||
* @param ssrc rtp的ssrc,10进制的字符串打印
|
||||
* @param is_udp 是否为udp
|
||||
* @param cb 启动成功或失败回调
|
||||
* @param user_data 回调用户指针
|
||||
*/
|
||||
API_EXPORT void API_CALL mk_media_start_send_rtp(mk_media ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int is_udp, on_mk_media_send_rtp_result cb, void *user_data);
|
||||
|
||||
/**
|
||||
* 停止ps-rtp发送
|
||||
* @param ctx 对象指针
|
||||
* @return 1成功,0失败
|
||||
*/
|
||||
API_EXPORT int API_CALL mk_media_stop_send_rtp(mk_media ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -211,6 +211,22 @@ API_EXPORT int API_CALL mk_media_source_seek_to(const mk_media_source ctx,uint32
|
||||
return src->seekTo(stamp);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_media_source_start_send_rtp(const mk_media_source ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int is_udp, on_mk_media_source_send_rtp_result cb, void *user_data){
|
||||
assert(ctx && dst_url && ssrc);
|
||||
MediaSource *src = (MediaSource *)ctx;
|
||||
src->startSendRtp(dst_url, dst_port, ssrc, is_udp, [cb, user_data](const SockException &ex){
|
||||
if (cb) {
|
||||
cb(user_data, ex.getErrCode(), ex.what());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
API_EXPORT int API_CALL mk_media_source_stop_send_rtp(const mk_media_source ctx){
|
||||
assert(ctx);
|
||||
MediaSource *src = (MediaSource *) ctx;
|
||||
return src->stopSendRtp();
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_media_source_find(const char *schema,
|
||||
const char *vhost,
|
||||
const char *app,
|
||||
|
@ -192,3 +192,21 @@ API_EXPORT void API_CALL mk_media_input_audio(mk_media ctx, void* data, int len,
|
||||
MediaHelper::Ptr* obj = (MediaHelper::Ptr*) ctx;
|
||||
(*obj)->getChannel()->inputAudio((char*)data, len, dts);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_media_start_send_rtp(mk_media ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int is_udp, on_mk_media_send_rtp_result cb, void *user_data){
|
||||
assert(ctx && dst_url && ssrc);
|
||||
MediaHelper::Ptr* obj = (MediaHelper::Ptr*) ctx;
|
||||
//sender参数无用
|
||||
(*obj)->getChannel()->startSendRtp(*(MediaSource *) 1, dst_url, dst_port, ssrc, is_udp, [cb, user_data](const SockException &ex){
|
||||
if (cb) {
|
||||
cb(user_data, ex.getErrCode(), ex.what());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
API_EXPORT int API_CALL mk_media_stop_send_rtp(mk_media ctx){
|
||||
assert(ctx);
|
||||
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
|
||||
//sender参数无用
|
||||
return (*obj)->getChannel()->stopSendRtp(*(MediaSource *) 1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user