diff --git a/api/include/mk_events.h b/api/include/mk_events.h index 8f433a2a..d765a8fa 100644 --- a/api/include/mk_events.h +++ b/api/include/mk_events.h @@ -132,7 +132,12 @@ typedef struct { /** * 录制mp4分片文件成功后广播 */ - void (API_CALL *on_mk_record_mp4)(const mk_mp4_info mp4); + void (API_CALL *on_mk_record_mp4)(const mk_record_info mp4); + + /** + * 录制ts分片文件成功后广播 + */ + void (API_CALL *on_mk_record_ts)(const mk_record_info ts); /** * shell登录鉴权 @@ -175,16 +180,16 @@ typedef struct { * @param err 错误代码 * @param msg 错误提示 */ - void(API_CALL *on_mk_media_send_rtp_stop)(const char *vhost, const char *app, const char *stream, const char *ssrc, int err, const char *msg); + void (API_CALL *on_mk_media_send_rtp_stop)(const char *vhost, const char *app, const char *stream, const char *ssrc, int err, const char *msg); /** * rtc sctp连接中/完成/失败/关闭回调 * @param rtc_transport 数据通道对象 */ - void(API_CALL *on_mk_rtc_sctp_connecting)(mk_rtc_transport rtc_transport); - void(API_CALL *on_mk_rtc_sctp_connected)(mk_rtc_transport rtc_transport); - void(API_CALL *on_mk_rtc_sctp_failed)(mk_rtc_transport rtc_transport); - void(API_CALL *on_mk_rtc_sctp_closed)(mk_rtc_transport rtc_transport); + void (API_CALL *on_mk_rtc_sctp_connecting)(mk_rtc_transport rtc_transport); + void (API_CALL *on_mk_rtc_sctp_connected)(mk_rtc_transport rtc_transport); + void (API_CALL *on_mk_rtc_sctp_failed)(mk_rtc_transport rtc_transport); + void (API_CALL *on_mk_rtc_sctp_closed)(mk_rtc_transport rtc_transport); /** * rtc数据通道发送数据回调 @@ -192,7 +197,7 @@ typedef struct { * @param msg 数据 * @param len 数据长度 */ - void(API_CALL *on_mk_rtc_sctp_send)(mk_rtc_transport rtc_transport, const uint8_t *msg, size_t len); + void (API_CALL *on_mk_rtc_sctp_send)(mk_rtc_transport rtc_transport, const uint8_t *msg, size_t len); /** * rtc数据通道接收数据回调 @@ -202,7 +207,7 @@ typedef struct { * @param msg 数据 * @param len 数据长度 */ - void(API_CALL *on_mk_rtc_sctp_received)(mk_rtc_transport rtc_transport, uint16_t streamId, uint32_t ppid, const uint8_t *msg, size_t len); + void (API_CALL *on_mk_rtc_sctp_received)(mk_rtc_transport rtc_transport, uint16_t streamId, uint32_t ppid, const uint8_t *msg, size_t len); } mk_events; diff --git a/api/include/mk_events_objects.h b/api/include/mk_events_objects.h index 428f9dc6..d28dbc62 100644 --- a/api/include/mk_events_objects.h +++ b/api/include/mk_events_objects.h @@ -18,29 +18,42 @@ extern "C" { #endif -///////////////////////////////////////////MP4Info///////////////////////////////////////////// -//MP4Info对象的C映射 -typedef struct mk_mp4_info_t *mk_mp4_info; +///////////////////////////////////////////RecordInfo///////////////////////////////////////////// +//RecordInfo对象的C映射 +typedef struct mk_record_info_t *mk_record_info; // GMT 标准时间,单位秒 -API_EXPORT uint64_t API_CALL mk_mp4_info_get_start_time(const mk_mp4_info ctx); +API_EXPORT uint64_t API_CALL mk_record_info_get_start_time(const mk_record_info ctx); // 录像长度,单位秒 -API_EXPORT float API_CALL mk_mp4_info_get_time_len(const mk_mp4_info ctx); +API_EXPORT float API_CALL mk_record_info_get_time_len(const mk_record_info ctx); // 文件大小,单位 BYTE -API_EXPORT size_t API_CALL mk_mp4_info_get_file_size(const mk_mp4_info ctx); +API_EXPORT size_t API_CALL mk_record_info_get_file_size(const mk_record_info ctx); // 文件路径 -API_EXPORT const char* API_CALL mk_mp4_info_get_file_path(const mk_mp4_info ctx); +API_EXPORT const char *API_CALL mk_record_info_get_file_path(const mk_record_info ctx); // 文件名称 -API_EXPORT const char* API_CALL mk_mp4_info_get_file_name(const mk_mp4_info ctx); +API_EXPORT const char *API_CALL mk_record_info_get_file_name(const mk_record_info ctx); // 文件夹路径 -API_EXPORT const char* API_CALL mk_mp4_info_get_folder(const mk_mp4_info ctx); +API_EXPORT const char *API_CALL mk_record_info_get_folder(const mk_record_info ctx); // 播放路径 -API_EXPORT const char* API_CALL mk_mp4_info_get_url(const mk_mp4_info ctx); +API_EXPORT const char *API_CALL mk_record_info_get_url(const mk_record_info ctx); // 应用名称 -API_EXPORT const char* API_CALL mk_mp4_info_get_vhost(const mk_mp4_info ctx); +API_EXPORT const char *API_CALL mk_record_info_get_vhost(const mk_record_info ctx); // 流 ID -API_EXPORT const char* API_CALL mk_mp4_info_get_app(const mk_mp4_info ctx); +API_EXPORT const char *API_CALL mk_record_info_get_app(const mk_record_info ctx); // 虚拟主机 -API_EXPORT const char* API_CALL mk_mp4_info_get_stream(const mk_mp4_info ctx); +API_EXPORT const char *API_CALL mk_record_info_get_stream(const mk_record_info ctx); + +//// 下面宏保障用户代码兼容性, 二进制abi不兼容,用户需要重新编译链接 ///// +#define mk_mp4_info mk_record_info +#define mk_mp4_info_get_start_time mk_record_info_get_start_time +#define mk_mp4_info_get_time_len mk_record_info_get_time_len +#define mk_mp4_info_get_file_size mk_record_info_get_file_size +#define mk_mp4_info_get_file_path mk_record_info_get_file_path +#define mk_mp4_info_get_file_name mk_record_info_get_file_name +#define mk_mp4_info_get_folder mk_record_info_get_folder +#define mk_mp4_info_get_url mk_record_info_get_url +#define mk_mp4_info_get_vhost mk_record_info_get_vhost +#define mk_mp4_info_get_app mk_record_info_get_app +#define mk_mp4_info_get_stream mk_record_info_get_stream ///////////////////////////////////////////Parser///////////////////////////////////////////// //Parser对象的C映射 diff --git a/api/source/mk_events.cpp b/api/source/mk_events.cpp index 7f5ed661..a835a7c9 100644 --- a/api/source/mk_events.cpp +++ b/api/source/mk_events.cpp @@ -42,7 +42,13 @@ API_EXPORT void API_CALL mk_events_listen(const mk_events *events){ NoticeCenter::Instance().addListener(&s_tag,Broadcast::kBroadcastRecordMP4,[](BroadcastRecordMP4Args){ if(s_events.on_mk_record_mp4){ - s_events.on_mk_record_mp4((mk_mp4_info)&info); + s_events.on_mk_record_mp4((mk_record_info)&info); + } + }); + + NoticeCenter::Instance().addListener(&s_tag, Broadcast::kBroadcastRecordTs, [](BroadcastRecordTsArgs) { + if (s_events.on_mk_record_ts) { + s_events.on_mk_record_ts((mk_record_info)&info); } }); diff --git a/api/source/mk_events_objects.cpp b/api/source/mk_events_objects.cpp index 8fdb38af..3615bbcd 100644 --- a/api/source/mk_events_objects.cpp +++ b/api/source/mk_events_objects.cpp @@ -26,61 +26,61 @@ using namespace toolkit; using namespace mediakit; ///////////////////////////////////////////RecordInfo///////////////////////////////////////////// -API_EXPORT uint64_t API_CALL mk_mp4_info_get_start_time(const mk_mp4_info ctx){ +API_EXPORT uint64_t API_CALL mk_record_info_get_start_time(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->start_time; } -API_EXPORT float API_CALL mk_mp4_info_get_time_len(const mk_mp4_info ctx){ +API_EXPORT float API_CALL mk_record_info_get_time_len(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->time_len; } -API_EXPORT size_t API_CALL mk_mp4_info_get_file_size(const mk_mp4_info ctx){ +API_EXPORT size_t API_CALL mk_record_info_get_file_size(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->file_size; } -API_EXPORT const char* API_CALL mk_mp4_info_get_file_path(const mk_mp4_info ctx){ +API_EXPORT const char *API_CALL mk_record_info_get_file_path(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->file_path.c_str(); } -API_EXPORT const char* API_CALL mk_mp4_info_get_file_name(const mk_mp4_info ctx){ +API_EXPORT const char *API_CALL mk_record_info_get_file_name(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->file_name.c_str(); } -API_EXPORT const char* API_CALL mk_mp4_info_get_folder(const mk_mp4_info ctx){ +API_EXPORT const char *API_CALL mk_record_info_get_folder(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->folder.c_str(); } -API_EXPORT const char* API_CALL mk_mp4_info_get_url(const mk_mp4_info ctx){ +API_EXPORT const char *API_CALL mk_record_info_get_url(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->url.c_str(); } -API_EXPORT const char* API_CALL mk_mp4_info_get_vhost(const mk_mp4_info ctx){ +API_EXPORT const char *API_CALL mk_record_info_get_vhost(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->vhost.c_str(); } -API_EXPORT const char* API_CALL mk_mp4_info_get_app(const mk_mp4_info ctx){ +API_EXPORT const char *API_CALL mk_record_info_get_app(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->app.c_str(); } -API_EXPORT const char* API_CALL mk_mp4_info_get_stream(const mk_mp4_info ctx){ +API_EXPORT const char *API_CALL mk_record_info_get_stream(const mk_record_info ctx) { assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->stream.c_str(); diff --git a/api/tests/server.c b/api/tests/server.c index 4f76fe60..28f44ada 100644 --- a/api/tests/server.c +++ b/api/tests/server.c @@ -387,7 +387,7 @@ void API_CALL on_mk_rtsp_auth(const mk_media_info url_info, /** * 录制mp4分片文件成功后广播 */ -void API_CALL on_mk_record_mp4(const mk_mp4_info mp4) { +void API_CALL on_mk_record_mp4(const mk_record_info mp4) { log_printf(LOG_LEV, "\nstart_time: %d\n" "time_len: %d\n" @@ -399,16 +399,16 @@ void API_CALL on_mk_record_mp4(const mk_mp4_info mp4) { "vhost: %s\n" "app: %s\n" "stream: %s\n", - mk_mp4_info_get_start_time(mp4), - mk_mp4_info_get_time_len(mp4), - mk_mp4_info_get_file_size(mp4), - mk_mp4_info_get_file_path(mp4), - mk_mp4_info_get_file_name(mp4), - mk_mp4_info_get_folder(mp4), - mk_mp4_info_get_url(mp4), - mk_mp4_info_get_vhost(mp4), - mk_mp4_info_get_app(mp4), - mk_mp4_info_get_stream(mp4)); + mk_record_info_get_start_time(mp4), + mk_record_info_get_time_len(mp4), + mk_record_info_get_file_size(mp4), + mk_record_info_get_file_path(mp4), + mk_record_info_get_file_name(mp4), + mk_record_info_get_folder(mp4), + mk_record_info_get_url(mp4), + mk_record_info_get_vhost(mp4), + mk_record_info_get_app(mp4), + mk_record_info_get_stream(mp4)); } /**