c api支持国标推流:#578

This commit is contained in:
xiongziliang 2020-11-21 22:13:08 +08:00
parent c512c1a02e
commit f05422bb65
4 changed files with 68 additions and 0 deletions

View File

@ -115,6 +115,16 @@ API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int forc
//MediaSource::seekTo() //MediaSource::seekTo()
API_EXPORT int API_CALL mk_media_source_seek_to(const mk_media_source ctx,uint32_t stamp); 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() //MediaSource::find()
API_EXPORT void API_CALL mk_media_source_find(const char *schema, API_EXPORT void API_CALL mk_media_source_find(const char *schema,
const char *vhost, const char *vhost,

View File

@ -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); 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的ssrc10
* @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 10
*/
API_EXPORT int API_CALL mk_media_stop_send_rtp(mk_media ctx);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -211,6 +211,22 @@ API_EXPORT int API_CALL mk_media_source_seek_to(const mk_media_source ctx,uint32
return src->seekTo(stamp); 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, API_EXPORT void API_CALL mk_media_source_find(const char *schema,
const char *vhost, const char *vhost,
const char *app, const char *app,

View File

@ -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; MediaHelper::Ptr* obj = (MediaHelper::Ptr*) ctx;
(*obj)->getChannel()->inputAudio((char*)data, len, dts); (*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);
}