mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 02:34:26 +08:00
完善c sdk对象描述元信息,防止隐式指针转换错误
void* 类型指针很容易存在隐式转换错误,用户无法察觉
This commit is contained in:
parent
8f108395a5
commit
dc8508c58f
@ -18,7 +18,7 @@ extern "C" {
|
||||
|
||||
///////////////////////////////////////////MP4Info/////////////////////////////////////////////
|
||||
//MP4Info对象的C映射
|
||||
typedef void* mk_mp4_info;
|
||||
typedef struct mk_mp4_info_t *mk_mp4_info;
|
||||
// GMT 标准时间,单位秒
|
||||
API_EXPORT uint64_t API_CALL mk_mp4_info_get_start_time(const mk_mp4_info ctx);
|
||||
// 录像长度,单位秒
|
||||
@ -42,7 +42,7 @@ API_EXPORT const char* API_CALL mk_mp4_info_get_stream(const mk_mp4_info ctx);
|
||||
|
||||
///////////////////////////////////////////Parser/////////////////////////////////////////////
|
||||
//Parser对象的C映射
|
||||
typedef void* mk_parser;
|
||||
typedef struct mk_parser_t *mk_parser;
|
||||
//Parser::Method(),获取命令字,譬如GET/POST
|
||||
API_EXPORT const char* API_CALL mk_parser_get_method(const mk_parser ctx);
|
||||
//Parser::Url(),获取HTTP的访问url(不包括?后面的参数)
|
||||
@ -60,7 +60,7 @@ API_EXPORT const char* API_CALL mk_parser_get_content(const mk_parser ctx, size_
|
||||
|
||||
///////////////////////////////////////////MediaInfo/////////////////////////////////////////////
|
||||
//MediaInfo对象的C映射
|
||||
typedef void* mk_media_info;
|
||||
typedef struct mk_media_info_t *mk_media_info;
|
||||
//MediaInfo::_param_strs
|
||||
API_EXPORT const char* API_CALL mk_media_info_get_params(const mk_media_info ctx);
|
||||
//MediaInfo::_schema
|
||||
@ -79,7 +79,7 @@ API_EXPORT uint16_t API_CALL mk_media_info_get_port(const mk_media_info ctx);
|
||||
|
||||
///////////////////////////////////////////MediaSource/////////////////////////////////////////////
|
||||
//MediaSource对象的C映射
|
||||
typedef void* mk_media_source;
|
||||
typedef struct mk_media_source_t *mk_media_source;
|
||||
//查找MediaSource的回调函数
|
||||
typedef void(API_CALL *on_mk_media_source_find_cb)(void *user_data, const mk_media_source ctx);
|
||||
|
||||
@ -138,7 +138,7 @@ API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_s
|
||||
|
||||
///////////////////////////////////////////HttpBody/////////////////////////////////////////////
|
||||
//HttpBody对象的C映射
|
||||
typedef void* mk_http_body;
|
||||
typedef struct mk_http_body_t *mk_http_body;
|
||||
/**
|
||||
* 生成HttpStringBody
|
||||
* @param str 字符串指针
|
||||
@ -173,7 +173,7 @@ API_EXPORT void API_CALL mk_http_body_release(mk_http_body ctx);
|
||||
|
||||
///////////////////////////////////////////HttpResponseInvoker/////////////////////////////////////////////
|
||||
//HttpSession::HttpResponseInvoker对象的C映射
|
||||
typedef void* mk_http_response_invoker;
|
||||
typedef struct mk_http_response_invoker_t *mk_http_response_invoker;
|
||||
|
||||
/**
|
||||
* HttpSession::HttpResponseInvoker(const string &codeOut, const StrCaseMap &headerOut, const HttpBody::Ptr &body);
|
||||
@ -219,7 +219,8 @@ API_EXPORT void API_CALL mk_http_response_invoker_clone_release(const mk_http_re
|
||||
|
||||
///////////////////////////////////////////HttpAccessPathInvoker/////////////////////////////////////////////
|
||||
//HttpSession::HttpAccessPathInvoker对象的C映射
|
||||
typedef void* mk_http_access_path_invoker;
|
||||
typedef struct mk_http_access_path_invoker_t *mk_http_access_path_invoker;
|
||||
|
||||
/**
|
||||
* HttpSession::HttpAccessPathInvoker(const string &errMsg,const string &accessPath, int cookieLifeSecond);
|
||||
* @param err_msg 如果为空,则代表鉴权通过,否则为错误提示,可以为null
|
||||
@ -244,7 +245,7 @@ API_EXPORT void API_CALL mk_http_access_path_invoker_clone_release(const mk_http
|
||||
|
||||
///////////////////////////////////////////RtspSession::onGetRealm/////////////////////////////////////////////
|
||||
//RtspSession::onGetRealm对象的C映射
|
||||
typedef void* mk_rtsp_get_realm_invoker;
|
||||
typedef struct mk_rtsp_get_realm_invoker_t *mk_rtsp_get_realm_invoker;
|
||||
/**
|
||||
* 执行RtspSession::onGetRealm
|
||||
* @param realm 该rtsp流是否需要开启rtsp专属鉴权,至null或空字符串则不鉴权
|
||||
@ -265,7 +266,7 @@ API_EXPORT void API_CALL mk_rtsp_get_realm_invoker_clone_release(const mk_rtsp_g
|
||||
|
||||
///////////////////////////////////////////RtspSession::onAuth/////////////////////////////////////////////
|
||||
//RtspSession::onAuth对象的C映射
|
||||
typedef void* mk_rtsp_auth_invoker;
|
||||
typedef struct mk_rtsp_auth_invoker_t *mk_rtsp_auth_invoker;
|
||||
|
||||
/**
|
||||
* 执行RtspSession::onAuth
|
||||
@ -289,7 +290,7 @@ API_EXPORT void API_CALL mk_rtsp_auth_invoker_clone_release(const mk_rtsp_auth_i
|
||||
|
||||
///////////////////////////////////////////Broadcast::PublishAuthInvoker/////////////////////////////////////////////
|
||||
//Broadcast::PublishAuthInvoker对象的C映射
|
||||
typedef void* mk_publish_auth_invoker;
|
||||
typedef struct mk_publish_auth_invoker_t *mk_publish_auth_invoker;
|
||||
|
||||
/**
|
||||
* 执行Broadcast::PublishAuthInvoker
|
||||
@ -315,7 +316,7 @@ API_EXPORT void API_CALL mk_publish_auth_invoker_clone_release(const mk_publish_
|
||||
|
||||
///////////////////////////////////////////Broadcast::AuthInvoker/////////////////////////////////////////////
|
||||
//Broadcast::AuthInvoker对象的C映射
|
||||
typedef void* mk_auth_invoker;
|
||||
typedef struct mk_auth_invoker_t *mk_auth_invoker;
|
||||
|
||||
/**
|
||||
* 执行Broadcast::AuthInvoker
|
||||
|
@ -39,7 +39,7 @@ API_EXPORT extern const int MKCodecVP9;
|
||||
API_EXPORT extern const int MKCodecAV1;
|
||||
API_EXPORT extern const int MKCodecJPEG;
|
||||
|
||||
typedef void *mk_frame;
|
||||
typedef struct mk_frame_t *mk_frame;
|
||||
|
||||
// 用户自定义free回调函数
|
||||
typedef void(API_CALL *on_mk_frame_data_release)(void *user_data, char *ptr);
|
||||
|
@ -17,7 +17,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *mk_h264_splitter;
|
||||
typedef struct mk_h264_splitter_t *mk_h264_splitter;
|
||||
|
||||
/**
|
||||
* h264 分帧器输出回调函数
|
||||
|
@ -20,7 +20,7 @@ extern "C" {
|
||||
|
||||
///////////////////////////////////////////HttpDownloader/////////////////////////////////////////////
|
||||
|
||||
typedef void *mk_http_downloader;
|
||||
typedef struct mk_http_downloader_t *mk_http_downloader;
|
||||
|
||||
/**
|
||||
* @param user_data 用户数据指针
|
||||
@ -54,7 +54,7 @@ API_EXPORT void API_CALL mk_http_downloader_start(mk_http_downloader ctx, const
|
||||
API_EXPORT void API_CALL mk_http_downloader_start2(mk_http_downloader ctx, const char *url, const char *file, on_mk_download_complete cb, void *user_data, on_user_data_free user_data_free);
|
||||
|
||||
///////////////////////////////////////////HttpRequester/////////////////////////////////////////////
|
||||
typedef void *mk_http_requester;
|
||||
typedef struct mk_http_requester_t *mk_http_requester;
|
||||
|
||||
/**
|
||||
* http请求结果回调
|
||||
|
@ -22,7 +22,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *mk_media;
|
||||
typedef struct mk_media_t *mk_media;
|
||||
|
||||
/**
|
||||
* 创建一个媒体源
|
||||
|
@ -19,7 +19,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* mk_player;
|
||||
typedef struct mk_player_t *mk_player;
|
||||
|
||||
/**
|
||||
* 播放结果或播放中断事件的回调
|
||||
|
@ -17,7 +17,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *mk_proxy_player;
|
||||
typedef struct mk_proxy_player_t *mk_proxy_player;
|
||||
|
||||
/**
|
||||
* 创建一个代理播放器
|
||||
|
@ -18,7 +18,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* mk_pusher;
|
||||
typedef struct mk_pusher_t *mk_pusher;
|
||||
|
||||
/**
|
||||
* 推流结果或推流中断事件的回调
|
||||
|
@ -19,7 +19,7 @@ extern "C" {
|
||||
|
||||
///////////////////////////////////////////flv录制/////////////////////////////////////////////
|
||||
|
||||
typedef void* mk_flv_recorder;
|
||||
typedef struct mk_flv_recorder_t *mk_flv_recorder;
|
||||
|
||||
/**
|
||||
* 创建flv录制器
|
||||
|
@ -14,7 +14,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* mk_rtp_server;
|
||||
typedef struct mk_rtp_server_t *mk_rtp_server;
|
||||
|
||||
/**
|
||||
* 创建GB28181 RTP 服务器
|
||||
|
@ -19,7 +19,7 @@ extern "C" {
|
||||
|
||||
///////////////////////////////////////////Buffer::Ptr/////////////////////////////////////////////
|
||||
|
||||
typedef void *mk_buffer;
|
||||
typedef struct mk_buffer_t *mk_buffer;
|
||||
typedef void(API_CALL *on_mk_buffer_free)(void *user_data, void *data);
|
||||
|
||||
/**
|
||||
@ -39,7 +39,7 @@ API_EXPORT size_t API_CALL mk_buffer_get_size(mk_buffer buffer);
|
||||
|
||||
///////////////////////////////////////////SockInfo/////////////////////////////////////////////
|
||||
//SockInfo对象的C映射
|
||||
typedef void* mk_sock_info;
|
||||
typedef struct mk_sock_info_t *mk_sock_info;
|
||||
|
||||
//SockInfo::get_peer_ip()
|
||||
API_EXPORT const char* API_CALL mk_sock_info_peer_ip(const mk_sock_info ctx, char *buf);
|
||||
@ -66,8 +66,8 @@ API_EXPORT uint16_t API_CALL mk_sock_info_local_port(const mk_sock_info ctx);
|
||||
#endif
|
||||
///////////////////////////////////////////TcpSession/////////////////////////////////////////////
|
||||
//TcpSession对象的C映射
|
||||
typedef void* mk_tcp_session;
|
||||
typedef void* mk_tcp_session_ref;
|
||||
typedef struct mk_tcp_session_t *mk_tcp_session;
|
||||
typedef struct mk_tcp_session_ref_t *mk_tcp_session_ref;
|
||||
|
||||
//获取基类指针以便获取其网络相关信息
|
||||
API_EXPORT mk_sock_info API_CALL mk_tcp_session_get_sock_info(const mk_tcp_session ctx);
|
||||
@ -168,7 +168,7 @@ API_EXPORT void API_CALL mk_tcp_server_events_listen(const mk_tcp_session_events
|
||||
|
||||
///////////////////////////////////////////自定义tcp客户端/////////////////////////////////////////////
|
||||
|
||||
typedef void* mk_tcp_client;
|
||||
typedef struct mk_tcp_client_t *mk_tcp_client;
|
||||
//获取基类指针以便获取其网络相关信息
|
||||
API_EXPORT mk_sock_info API_CALL mk_tcp_client_get_sock_info(const mk_tcp_client ctx);
|
||||
|
||||
|
@ -20,7 +20,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////事件线程/////////////////////////////////////////////
|
||||
typedef void* mk_thread;
|
||||
typedef struct mk_thread_t *mk_thread;
|
||||
|
||||
/**
|
||||
* 获取tcp会话对象所在事件线程
|
||||
@ -52,7 +52,7 @@ API_EXPORT mk_thread API_CALL mk_thread_from_pool();
|
||||
*/
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_pool_work();
|
||||
|
||||
typedef void* mk_thread_pool;
|
||||
typedef struct mk_thread_pool_t *mk_thread_pool;
|
||||
|
||||
/**
|
||||
* 创建线程池
|
||||
@ -108,7 +108,7 @@ API_EXPORT void API_CALL mk_async_do_delay2(mk_thread ctx, size_t ms, on_mk_asyn
|
||||
API_EXPORT void API_CALL mk_sync_do(mk_thread ctx, on_mk_async cb, void *user_data);
|
||||
|
||||
///////////////////////////////////////////定时器/////////////////////////////////////////////
|
||||
typedef void* mk_timer;
|
||||
typedef struct mk_timer_t *mk_timer;
|
||||
|
||||
/**
|
||||
* 定时器触发事件
|
||||
@ -135,7 +135,7 @@ API_EXPORT void API_CALL mk_timer_release(mk_timer ctx);
|
||||
|
||||
///////////////////////////////////////////信号量/////////////////////////////////////////////
|
||||
|
||||
typedef void* mk_sem;
|
||||
typedef struct mk_sem_t *mk_sem;
|
||||
|
||||
/**
|
||||
* 创建信号量
|
||||
|
@ -19,7 +19,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
//音视频轨道
|
||||
typedef void* mk_track;
|
||||
typedef struct mk_track_t *mk_track;
|
||||
//输出frame回调
|
||||
typedef void(API_CALL *on_mk_frame_out)(void *user_data, mk_frame frame);
|
||||
|
||||
|
@ -20,11 +20,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
//解码器对象
|
||||
typedef void *mk_decoder;
|
||||
typedef struct mk_decoder_t *mk_decoder;
|
||||
//解码后的frame
|
||||
typedef void *mk_frame_pix;
|
||||
typedef struct mk_frame_pix_t *mk_frame_pix;
|
||||
//SwsContext的包装
|
||||
typedef void *mk_swscale;
|
||||
typedef struct mk_swscale_t *mk_swscale;
|
||||
//FFmpeg原始解码帧对象
|
||||
typedef struct AVFrame AVFrame;
|
||||
//FFmpeg编解码器对象
|
||||
|
@ -58,7 +58,7 @@ API_EXPORT char* API_CALL mk_util_get_current_time_string(const char *fmt);
|
||||
API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len);
|
||||
|
||||
///////////////////////////////////////////mk ini/////////////////////////////////////////////
|
||||
typedef void* mk_ini;
|
||||
typedef struct mk_ini_t *mk_ini;
|
||||
|
||||
/**
|
||||
* 创建ini配置对象
|
||||
|
@ -245,14 +245,14 @@ API_EXPORT void API_CALL mk_media_source_find(const char *schema,
|
||||
on_mk_media_source_find_cb cb) {
|
||||
assert(schema && vhost && app && stream && cb);
|
||||
auto src = MediaSource::find(schema, vhost, app, stream, from_mp4);
|
||||
cb(user_data, src.get());
|
||||
cb(user_data, (mk_media_source)src.get());
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_source_find_cb cb, const char *schema,
|
||||
const char *vhost, const char *app, const char *stream) {
|
||||
assert(cb);
|
||||
MediaSource::for_each_media([&](const MediaSource::Ptr &src) {
|
||||
cb(user_data, src.get());
|
||||
cb(user_data, (mk_media_source)src.get());
|
||||
}, schema ? schema : "", vhost ? vhost : "", app ? app : "", stream ? stream : "");
|
||||
}
|
||||
|
||||
@ -263,17 +263,17 @@ API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_
|
||||
if(!len){
|
||||
len = strlen(str);
|
||||
}
|
||||
return new HttpBody::Ptr(new HttpStringBody(std::string(str, len)));
|
||||
return (mk_http_body)new HttpBody::Ptr(new HttpStringBody(std::string(str, len)));
|
||||
}
|
||||
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_buffer(mk_buffer buffer) {
|
||||
assert(buffer);
|
||||
return new HttpBody::Ptr(new HttpBufferBody(*((Buffer::Ptr *) buffer)));
|
||||
return (mk_http_body)new HttpBody::Ptr(new HttpBufferBody(*((Buffer::Ptr *) buffer)));
|
||||
}
|
||||
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_file(const char *file_path){
|
||||
assert(file_path);
|
||||
return new HttpBody::Ptr(new HttpFileBody(file_path));
|
||||
return (mk_http_body)new HttpBody::Ptr(new HttpFileBody(file_path));
|
||||
}
|
||||
|
||||
template <typename C = StrCaseMap>
|
||||
@ -294,7 +294,7 @@ static C get_http_header( const char *response_header[]){
|
||||
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_multi_form(const char *key_val[],const char *file_path){
|
||||
assert(key_val && file_path);
|
||||
return new HttpBody::Ptr(new HttpMultiFormBody(get_http_header<HttpArgs>(key_val),file_path));
|
||||
return (mk_http_body)new HttpBody::Ptr(new HttpMultiFormBody(get_http_header<HttpArgs>(key_val),file_path));
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_http_body_release(mk_http_body ctx){
|
||||
@ -338,7 +338,7 @@ API_EXPORT void API_CALL mk_http_response_invoker_do(const mk_http_response_invo
|
||||
API_EXPORT mk_http_response_invoker API_CALL mk_http_response_invoker_clone(const mk_http_response_invoker ctx){
|
||||
assert(ctx);
|
||||
HttpSession::HttpResponseInvoker *invoker = (HttpSession::HttpResponseInvoker *)ctx;
|
||||
return new HttpSession::HttpResponseInvoker (*invoker);
|
||||
return (mk_http_response_invoker)new HttpSession::HttpResponseInvoker (*invoker);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_http_response_invoker_clone_release(const mk_http_response_invoker ctx){
|
||||
@ -362,7 +362,7 @@ API_EXPORT void API_CALL mk_http_access_path_invoker_do(const mk_http_access_pat
|
||||
API_EXPORT mk_http_access_path_invoker API_CALL mk_http_access_path_invoker_clone(const mk_http_access_path_invoker ctx){
|
||||
assert(ctx);
|
||||
HttpSession::HttpAccessPathInvoker *invoker = (HttpSession::HttpAccessPathInvoker *)ctx;
|
||||
return new HttpSession::HttpAccessPathInvoker(*invoker);
|
||||
return (mk_http_access_path_invoker)new HttpSession::HttpAccessPathInvoker(*invoker);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_http_access_path_invoker_clone_release(const mk_http_access_path_invoker ctx){
|
||||
@ -382,7 +382,7 @@ API_EXPORT void API_CALL mk_rtsp_get_realm_invoker_do(const mk_rtsp_get_realm_in
|
||||
API_EXPORT mk_rtsp_get_realm_invoker API_CALL mk_rtsp_get_realm_invoker_clone(const mk_rtsp_get_realm_invoker ctx){
|
||||
assert(ctx);
|
||||
RtspSession::onGetRealm *invoker = (RtspSession::onGetRealm *)ctx;
|
||||
return new RtspSession::onGetRealm (*invoker);
|
||||
return (mk_rtsp_get_realm_invoker)new RtspSession::onGetRealm (*invoker);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_rtsp_get_realm_invoker_clone_release(const mk_rtsp_get_realm_invoker ctx){
|
||||
@ -403,7 +403,7 @@ API_EXPORT void API_CALL mk_rtsp_auth_invoker_do(const mk_rtsp_auth_invoker ctx,
|
||||
API_EXPORT mk_rtsp_auth_invoker API_CALL mk_rtsp_auth_invoker_clone(const mk_rtsp_auth_invoker ctx){
|
||||
assert(ctx);
|
||||
RtspSession::onAuth *invoker = (RtspSession::onAuth *)ctx;
|
||||
return new RtspSession::onAuth(*invoker);
|
||||
return (mk_rtsp_auth_invoker)new RtspSession::onAuth(*invoker);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_rtsp_auth_invoker_clone_release(const mk_rtsp_auth_invoker ctx){
|
||||
@ -428,7 +428,7 @@ API_EXPORT void API_CALL mk_publish_auth_invoker_do(const mk_publish_auth_invoke
|
||||
API_EXPORT mk_publish_auth_invoker API_CALL mk_publish_auth_invoker_clone(const mk_publish_auth_invoker ctx){
|
||||
assert(ctx);
|
||||
Broadcast::PublishAuthInvoker *invoker = (Broadcast::PublishAuthInvoker *)ctx;
|
||||
return new Broadcast::PublishAuthInvoker(*invoker);
|
||||
return (mk_publish_auth_invoker)new Broadcast::PublishAuthInvoker(*invoker);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_publish_auth_invoker_clone_release(const mk_publish_auth_invoker ctx){
|
||||
@ -447,7 +447,7 @@ API_EXPORT void API_CALL mk_auth_invoker_do(const mk_auth_invoker ctx, const cha
|
||||
API_EXPORT mk_auth_invoker API_CALL mk_auth_invoker_clone(const mk_auth_invoker ctx){
|
||||
assert(ctx);
|
||||
Broadcast::AuthInvoker *invoker = (Broadcast::AuthInvoker *)ctx;
|
||||
return new Broadcast::AuthInvoker(*invoker);
|
||||
return (mk_auth_invoker)new Broadcast::AuthInvoker(*invoker);
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_auth_invoker_clone_release(const mk_auth_invoker ctx){
|
||||
|
@ -74,13 +74,13 @@ static mk_frame mk_frame_create_complex(int codec_id, uint64_t dts, uint64_t pts
|
||||
char *data, size_t size, on_mk_frame_data_release cb, std::shared_ptr<void> user_data) {
|
||||
switch (codec_id) {
|
||||
case CodecH264:
|
||||
return new Frame::Ptr(new H264FrameHelper<FrameFromPtrForC>(
|
||||
return (mk_frame)new Frame::Ptr(new H264FrameHelper<FrameFromPtrForC>(
|
||||
cb, frame_flags, cb, std::move(user_data), (CodecId)codec_id, data, size, dts, pts, prefix_size));
|
||||
case CodecH265:
|
||||
return new Frame::Ptr(new H265FrameHelper<FrameFromPtrForC>(
|
||||
return (mk_frame)new Frame::Ptr(new H265FrameHelper<FrameFromPtrForC>(
|
||||
cb, frame_flags, cb, std::move(user_data), (CodecId)codec_id, data, size, dts, pts, prefix_size));
|
||||
default:
|
||||
return new Frame::Ptr(new FrameFromPtrForC(
|
||||
return (mk_frame)new Frame::Ptr(new FrameFromPtrForC(
|
||||
cb, frame_flags, cb, std::move(user_data), (CodecId)codec_id, data, size, dts, pts, prefix_size));
|
||||
}
|
||||
}
|
||||
@ -117,7 +117,7 @@ API_EXPORT void API_CALL mk_frame_unref(mk_frame frame) {
|
||||
|
||||
API_EXPORT mk_frame API_CALL mk_frame_ref(mk_frame frame) {
|
||||
assert(frame);
|
||||
return new Frame::Ptr(Frame::getCacheAbleFrame(*((Frame::Ptr *) frame)));
|
||||
return (mk_frame)new Frame::Ptr(Frame::getCacheAbleFrame(*((Frame::Ptr *) frame)));
|
||||
}
|
||||
|
||||
API_EXPORT int API_CALL mk_frame_codec_id(mk_frame frame) {
|
||||
|
@ -48,7 +48,7 @@ API_EXPORT void API_CALL mk_http_downloader_start2(mk_http_downloader ctx, const
|
||||
///////////////////////////////////////////HttpRequester/////////////////////////////////////////////
|
||||
API_EXPORT mk_http_requester API_CALL mk_http_requester_create(){
|
||||
HttpRequester::Ptr *ret = new HttpRequester::Ptr(new HttpRequester);
|
||||
return ret;
|
||||
return (mk_http_requester)ret;
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_http_requester_clear(mk_http_requester ctx){
|
||||
|
@ -98,7 +98,7 @@ protected:
|
||||
|
||||
void onRegist(MediaSource &sender, bool regist) override{
|
||||
if (_on_regist) {
|
||||
_on_regist(_on_regist_data.get(), &sender, regist);
|
||||
_on_regist(_on_regist_data.get(), (mk_media_source)&sender, regist);
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,5 +319,5 @@ API_EXPORT void API_CALL mk_media_stop_send_rtp(mk_media ctx, const char *ssrc){
|
||||
|
||||
API_EXPORT mk_thread API_CALL mk_media_get_owner_thread(mk_media ctx) {
|
||||
MediaHelper::Ptr *obj = (MediaHelper::Ptr *)ctx;
|
||||
return (*obj)->getChannel()->getOwnerPoller(MediaSource::NullMediaSource()).get();
|
||||
return (mk_thread)(*obj)->getChannel()->getOwnerPoller(MediaSource::NullMediaSource()).get();
|
||||
}
|
@ -105,7 +105,7 @@ private:
|
||||
API_EXPORT mk_player API_CALL mk_player_create() {
|
||||
MediaPlayerForC::Ptr *obj = new MediaPlayerForC::Ptr(new MediaPlayerForC());
|
||||
(*obj)->setup();
|
||||
return obj;
|
||||
return (mk_player)obj;
|
||||
}
|
||||
API_EXPORT void API_CALL mk_player_release(mk_player ctx) {
|
||||
assert(ctx);
|
||||
|
@ -18,14 +18,14 @@ using namespace mediakit;
|
||||
API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vhost,const char *app, const char *stream){
|
||||
assert(schema && vhost && app && schema);
|
||||
MediaPusher::Ptr *obj = new MediaPusher::Ptr(new MediaPusher(schema,vhost,app,stream));
|
||||
return obj;
|
||||
return (mk_pusher)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;
|
||||
return (mk_pusher)obj;
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_pusher_release(mk_pusher ctx){
|
||||
|
@ -18,7 +18,7 @@ using namespace mediakit;
|
||||
|
||||
API_EXPORT mk_flv_recorder API_CALL mk_flv_recorder_create(){
|
||||
FlvRecorder::Ptr *ret = new FlvRecorder::Ptr(new FlvRecorder);
|
||||
return ret;
|
||||
return (mk_flv_recorder)ret;
|
||||
}
|
||||
API_EXPORT void API_CALL mk_flv_recorder_release(mk_flv_recorder ctx){
|
||||
assert(ctx);
|
||||
|
@ -19,7 +19,7 @@ using namespace mediakit;
|
||||
API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int tcp_mode, const char *stream_id) {
|
||||
RtpServer::Ptr *server = new RtpServer::Ptr(new RtpServer);
|
||||
(*server)->start(port, stream_id, (RtpServer::TcpMode)tcp_mode);
|
||||
return server;
|
||||
return (mk_rtp_server)server;
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_rtp_server_connect(mk_rtp_server ctx, const char *dst_url, uint16_t dst_port, on_mk_rtp_server_connected cb, void *user_data) {
|
||||
|
@ -65,12 +65,12 @@ API_EXPORT mk_buffer API_CALL mk_buffer_from_char(const char *data, size_t len,
|
||||
API_EXPORT mk_buffer API_CALL mk_buffer_from_char2(const char *data, size_t len, on_mk_buffer_free cb, void *user_data, on_user_data_free user_data_free) {
|
||||
assert(data);
|
||||
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
return new Buffer::Ptr(std::make_shared<BufferForC>(data, len, cb, std::move(ptr)));
|
||||
return (mk_buffer)new Buffer::Ptr(std::make_shared<BufferForC>(data, len, cb, std::move(ptr)));
|
||||
}
|
||||
|
||||
API_EXPORT mk_buffer API_CALL mk_buffer_ref(mk_buffer buffer) {
|
||||
assert(buffer);
|
||||
return new Buffer::Ptr(*((Buffer::Ptr *) buffer));
|
||||
return (mk_buffer)new Buffer::Ptr(*((Buffer::Ptr *) buffer));
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_buffer_unref(mk_buffer buffer) {
|
||||
@ -115,7 +115,7 @@ API_EXPORT uint16_t API_CALL mk_sock_info_local_port(const mk_sock_info ctx){
|
||||
API_EXPORT mk_sock_info API_CALL mk_tcp_session_get_sock_info(const mk_tcp_session ctx){
|
||||
assert(ctx);
|
||||
SessionForC *session = (SessionForC *)ctx;
|
||||
return (SockInfo *)session;
|
||||
return (mk_sock_info)session;
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_tcp_session_shutdown(const mk_tcp_session ctx,int err,const char *err_msg){
|
||||
@ -155,7 +155,7 @@ API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ct
|
||||
|
||||
API_EXPORT mk_tcp_session_ref API_CALL mk_tcp_session_ref_from(const mk_tcp_session ctx) {
|
||||
auto ref = ((SessionForC *) ctx)->shared_from_this();
|
||||
return new std::shared_ptr<SessionForC>(std::dynamic_pointer_cast<SessionForC>(ref));
|
||||
return (mk_tcp_session_ref)new std::shared_ptr<SessionForC>(std::dynamic_pointer_cast<SessionForC>(ref));
|
||||
}
|
||||
|
||||
API_EXPORT void mk_tcp_session_ref_release(const mk_tcp_session_ref ref) {
|
||||
@ -163,7 +163,7 @@ API_EXPORT void mk_tcp_session_ref_release(const mk_tcp_session_ref ref) {
|
||||
}
|
||||
|
||||
API_EXPORT mk_tcp_session mk_tcp_session_from_ref(const mk_tcp_session_ref ref) {
|
||||
return ((std::shared_ptr<SessionForC> *) ref)->get();
|
||||
return (mk_tcp_session)((std::shared_ptr<SessionForC> *) ref)->get();
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx, const char *data, size_t len) {
|
||||
@ -179,25 +179,25 @@ static mk_tcp_session_events s_events_server = {0};
|
||||
SessionForC::SessionForC(const Socket::Ptr &pSock) : Session(pSock) {
|
||||
_local_port = get_local_port();
|
||||
if (s_events_server.on_mk_tcp_session_create) {
|
||||
s_events_server.on_mk_tcp_session_create(_local_port,this);
|
||||
s_events_server.on_mk_tcp_session_create(_local_port, (mk_tcp_session) this);
|
||||
}
|
||||
}
|
||||
|
||||
void SessionForC::onRecv(const Buffer::Ptr &buffer) {
|
||||
if (s_events_server.on_mk_tcp_session_data) {
|
||||
s_events_server.on_mk_tcp_session_data(_local_port, this, (mk_buffer)&buffer);
|
||||
s_events_server.on_mk_tcp_session_data(_local_port, (mk_tcp_session)this, (mk_buffer)&buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void SessionForC::onError(const SockException &err) {
|
||||
if (s_events_server.on_mk_tcp_session_disconnect) {
|
||||
s_events_server.on_mk_tcp_session_disconnect(_local_port,this, err.getErrCode(), err.what());
|
||||
s_events_server.on_mk_tcp_session_disconnect(_local_port, (mk_tcp_session)this, err.getErrCode(), err.what());
|
||||
}
|
||||
}
|
||||
|
||||
void SessionForC::onManager() {
|
||||
if (s_events_server.on_mk_tcp_session_manager) {
|
||||
s_events_server.on_mk_tcp_session_manager(_local_port,this);
|
||||
s_events_server.on_mk_tcp_session_manager(_local_port, (mk_tcp_session)this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,13 +320,13 @@ TcpClientForC::Ptr *mk_tcp_client_create_l(mk_tcp_client_events *events, mk_tcp_
|
||||
API_EXPORT mk_sock_info API_CALL mk_tcp_client_get_sock_info(const mk_tcp_client ctx){
|
||||
assert(ctx);
|
||||
TcpClientForC::Ptr *client = (TcpClientForC::Ptr *)ctx;
|
||||
return (SockInfo *)client->get();
|
||||
return (mk_sock_info)(SockInfo *)client->get();
|
||||
}
|
||||
|
||||
API_EXPORT mk_tcp_client API_CALL mk_tcp_client_create(mk_tcp_client_events *events, mk_tcp_type type){
|
||||
auto ret = mk_tcp_client_create_l(events,type);
|
||||
(*ret)->setClient(ret);
|
||||
return ret;
|
||||
(*ret)->setClient((mk_tcp_client)ret);
|
||||
return (mk_tcp_client)ret;
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_tcp_client_release(mk_tcp_client ctx){
|
||||
|
@ -19,21 +19,21 @@ using namespace toolkit;
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_tcp_session(mk_tcp_session ctx){
|
||||
assert(ctx);
|
||||
SessionForC *obj = (SessionForC *)ctx;
|
||||
return obj->getPoller().get();
|
||||
return (mk_thread)(obj->getPoller().get());
|
||||
}
|
||||
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_tcp_client(mk_tcp_client ctx){
|
||||
assert(ctx);
|
||||
TcpClientForC::Ptr *client = (TcpClientForC::Ptr *)ctx;
|
||||
return (*client)->getPoller().get();
|
||||
return (mk_thread)((*client)->getPoller().get());
|
||||
}
|
||||
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_pool(){
|
||||
return EventPollerPool::Instance().getPoller().get();
|
||||
return (mk_thread)(EventPollerPool::Instance().getPoller().get());
|
||||
}
|
||||
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_pool_work(){
|
||||
return WorkThreadPool::Instance().getPoller().get();
|
||||
return (mk_thread)(WorkThreadPool::Instance().getPoller().get());
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_async_do(mk_thread ctx,on_mk_async cb, void *user_data){
|
||||
@ -123,7 +123,7 @@ API_EXPORT mk_timer API_CALL mk_timer_create2(mk_thread ctx, uint64_t delay_ms,
|
||||
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
|
||||
TimerForC::Ptr *ret = new TimerForC::Ptr(new TimerForC(cb, ptr));
|
||||
(*ret)->start(delay_ms,*poller);
|
||||
return ret;
|
||||
return (mk_timer)ret;
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_timer_release(mk_timer ctx){
|
||||
@ -148,7 +148,7 @@ public:
|
||||
};
|
||||
|
||||
API_EXPORT mk_thread_pool API_CALL mk_thread_pool_create(const char *name, size_t n_thread, int priority) {
|
||||
return new WorkThreadPoolForC(name, n_thread, priority);
|
||||
return (mk_thread_pool)new WorkThreadPoolForC(name, n_thread, priority);
|
||||
}
|
||||
|
||||
API_EXPORT int API_CALL mk_thread_pool_release(mk_thread_pool pool) {
|
||||
@ -159,11 +159,11 @@ API_EXPORT int API_CALL mk_thread_pool_release(mk_thread_pool pool) {
|
||||
|
||||
API_EXPORT mk_thread API_CALL mk_thread_from_thread_pool(mk_thread_pool pool) {
|
||||
assert(pool);
|
||||
return ((WorkThreadPoolForC *) pool)->getPoller().get();
|
||||
return (mk_thread)(((WorkThreadPoolForC *) pool)->getPoller().get());
|
||||
}
|
||||
|
||||
API_EXPORT mk_sem API_CALL mk_sem_create() {
|
||||
return new toolkit::semaphore;
|
||||
return (mk_sem)new toolkit::semaphore;
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_sem_release(mk_sem sem) {
|
||||
|
@ -82,8 +82,8 @@ public:
|
||||
|
||||
API_EXPORT mk_track API_CALL mk_track_create(int codec_id, codec_args *args) {
|
||||
switch (getTrackType((CodecId) codec_id)) {
|
||||
case TrackVideo: return new Track::Ptr(std::make_shared<VideoTrackForC>(codec_id, args));
|
||||
case TrackAudio: return new Track::Ptr(std::make_shared<AudioTrackForC>(codec_id, args));
|
||||
case TrackVideo: return (mk_track)new Track::Ptr(std::make_shared<VideoTrackForC>(codec_id, args));
|
||||
case TrackAudio: return (mk_track)new Track::Ptr(std::make_shared<AudioTrackForC>(codec_id, args));
|
||||
default: WarnL << "unrecognized codec:" << codec_id; return nullptr;
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,7 @@ API_EXPORT void API_CALL mk_track_unref(mk_track track) {
|
||||
|
||||
API_EXPORT mk_track API_CALL mk_track_ref(mk_track track) {
|
||||
assert(track);
|
||||
return new Track::Ptr(*( (Track::Ptr *)track));
|
||||
return (mk_track)new Track::Ptr(*( (Track::Ptr *)track));
|
||||
}
|
||||
|
||||
API_EXPORT int API_CALL mk_track_codec_id(mk_track track) {
|
||||
|
@ -29,12 +29,12 @@ std::vector<std::string> toCodecList(const char *codec_name_list[]) {
|
||||
|
||||
API_EXPORT mk_decoder API_CALL mk_decoder_create(mk_track track, int thread_num) {
|
||||
assert(track);
|
||||
return new FFmpegDecoder(*((Track::Ptr *) track), thread_num);
|
||||
return (mk_decoder)new FFmpegDecoder(*((Track::Ptr *) track), thread_num);
|
||||
}
|
||||
|
||||
API_EXPORT mk_decoder API_CALL mk_decoder_create2(mk_track track, int thread_num, const char *codec_name_list[]) {
|
||||
assert(track && codec_name_list);
|
||||
return new FFmpegDecoder(*((Track::Ptr *) track), thread_num, toCodecList(codec_name_list));
|
||||
return (mk_decoder)new FFmpegDecoder(*((Track::Ptr *) track), thread_num, toCodecList(codec_name_list));
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_decoder_release(mk_decoder ctx, int flush_frame) {
|
||||
@ -77,12 +77,12 @@ API_EXPORT const AVCodecContext *API_CALL mk_decoder_get_context(mk_decoder ctx)
|
||||
|
||||
API_EXPORT mk_frame_pix API_CALL mk_frame_pix_ref(mk_frame_pix frame) {
|
||||
assert(frame);
|
||||
return new FFmpegFrame::Ptr(*(FFmpegFrame::Ptr *) frame);
|
||||
return (mk_frame_pix)new FFmpegFrame::Ptr(*(FFmpegFrame::Ptr *) frame);
|
||||
}
|
||||
|
||||
API_EXPORT mk_frame_pix API_CALL mk_frame_pix_from_av_frame(AVFrame *frame) {
|
||||
assert(frame);
|
||||
return new FFmpegFrame::Ptr(std::make_shared<FFmpegFrame>(std::shared_ptr<AVFrame>(av_frame_clone(frame), [](AVFrame *frame){
|
||||
return (mk_frame_pix)new FFmpegFrame::Ptr(std::make_shared<FFmpegFrame>(std::shared_ptr<AVFrame>(av_frame_clone(frame), [](AVFrame *frame){
|
||||
av_frame_free(&frame);
|
||||
})));
|
||||
}
|
||||
@ -99,7 +99,7 @@ API_EXPORT mk_frame_pix API_CALL mk_frame_pix_from_buffer(mk_buffer plane_data[]
|
||||
frame->linesize[i] = line_size[i];
|
||||
buffer_array.emplace_back(buffer);
|
||||
}
|
||||
return new FFmpegFrame::Ptr(new FFmpegFrame(std::move(frame)), [buffer_array](FFmpegFrame *frame) {
|
||||
return (mk_frame_pix)new FFmpegFrame::Ptr(new FFmpegFrame(std::move(frame)), [buffer_array](FFmpegFrame *frame) {
|
||||
for (auto &buffer : buffer_array) {
|
||||
mk_buffer_unref(buffer);
|
||||
}
|
||||
@ -120,7 +120,7 @@ API_EXPORT AVFrame *API_CALL mk_frame_pix_get_av_frame(mk_frame_pix frame) {
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
API_EXPORT mk_swscale mk_swscale_create(int output, int width, int height) {
|
||||
return new FFmpegSws((AVPixelFormat) output, width, height);
|
||||
return (mk_swscale)new FFmpegSws((AVPixelFormat) output, width, height);
|
||||
}
|
||||
|
||||
API_EXPORT void mk_swscale_release(mk_swscale ctx) {
|
||||
@ -132,7 +132,7 @@ API_EXPORT int mk_swscale_input_frame(mk_swscale ctx, mk_frame_pix frame, uint8_
|
||||
}
|
||||
|
||||
API_EXPORT mk_frame_pix mk_swscale_input_frame2(mk_swscale ctx, mk_frame_pix frame){
|
||||
return new FFmpegFrame::Ptr(((FFmpegSws *) ctx)->inputFrame(*(FFmpegFrame::Ptr *) frame));
|
||||
return (mk_frame_pix)new FFmpegFrame::Ptr(((FFmpegSws *) ctx)->inputFrame(*(FFmpegFrame::Ptr *) frame));
|
||||
}
|
||||
|
||||
API_EXPORT uint8_t **API_CALL mk_get_av_frame_data(AVFrame *frame) {
|
||||
|
@ -55,11 +55,11 @@ API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len){
|
||||
}
|
||||
|
||||
API_EXPORT mk_ini API_CALL mk_ini_create() {
|
||||
return new mINI;
|
||||
return (mk_ini)new mINI;
|
||||
}
|
||||
|
||||
API_EXPORT mk_ini API_CALL mk_ini_default() {
|
||||
return &(mINI::Instance());
|
||||
return (mk_ini)&(mINI::Instance());
|
||||
}
|
||||
|
||||
static void emit_ini_file_reload(mk_ini ini) {
|
||||
|
@ -32,7 +32,7 @@ void release_player(mk_player *ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
void release_pusher(mk_media *ptr) {
|
||||
void release_pusher(mk_pusher *ptr) {
|
||||
if (ptr && *ptr) {
|
||||
mk_pusher_release(*ptr);
|
||||
*ptr = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user