添加C API on_record_ts 回调ts录像信息 (#3520)

用时合并on_record_mp4相关接口

Co-authored-by: 李道甫 <lidf@ahtelit.com>
This commit is contained in:
Lidaofu 2024-05-10 14:27:23 +08:00 committed by GitHub
parent 2eed284e61
commit 18c5bb3670
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 67 additions and 43 deletions

View File

@ -132,7 +132,12 @@ typedef struct {
/** /**
* mp4分片文件成功后广播 * 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登录鉴权 * shell登录鉴权

View File

@ -18,29 +18,42 @@
extern "C" { extern "C" {
#endif #endif
///////////////////////////////////////////MP4Info///////////////////////////////////////////// ///////////////////////////////////////////RecordInfo/////////////////////////////////////////////
//MP4Info对象的C映射 //RecordInfo对象的C映射
typedef struct mk_mp4_info_t *mk_mp4_info; typedef struct mk_record_info_t *mk_record_info;
// GMT 标准时间,单位秒 // 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 // 文件大小,单位 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 // 流 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/////////////////////////////////////////////
//Parser对象的C映射 //Parser对象的C映射

View File

@ -42,7 +42,13 @@ API_EXPORT void API_CALL mk_events_listen(const mk_events *events){
NoticeCenter::Instance().addListener(&s_tag,Broadcast::kBroadcastRecordMP4,[](BroadcastRecordMP4Args){ NoticeCenter::Instance().addListener(&s_tag,Broadcast::kBroadcastRecordMP4,[](BroadcastRecordMP4Args){
if(s_events.on_mk_record_mp4){ 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);
} }
}); });

View File

@ -26,61 +26,61 @@ using namespace toolkit;
using namespace mediakit; using namespace mediakit;
///////////////////////////////////////////RecordInfo///////////////////////////////////////////// ///////////////////////////////////////////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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->start_time; 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->time_len; 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->file_size; 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->file_path.c_str(); 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->file_name.c_str(); 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->folder.c_str(); 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->url.c_str(); 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->vhost.c_str(); 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->app.c_str(); 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->stream.c_str(); return info->stream.c_str();

View File

@ -387,7 +387,7 @@ void API_CALL on_mk_rtsp_auth(const mk_media_info url_info,
/** /**
* mp4分片文件成功后广播 * 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, log_printf(LOG_LEV,
"\nstart_time: %d\n" "\nstart_time: %d\n"
"time_len: %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" "vhost: %s\n"
"app: %s\n" "app: %s\n"
"stream: %s\n", "stream: %s\n",
mk_mp4_info_get_start_time(mp4), mk_record_info_get_start_time(mp4),
mk_mp4_info_get_time_len(mp4), mk_record_info_get_time_len(mp4),
mk_mp4_info_get_file_size(mp4), mk_record_info_get_file_size(mp4),
mk_mp4_info_get_file_path(mp4), mk_record_info_get_file_path(mp4),
mk_mp4_info_get_file_name(mp4), mk_record_info_get_file_name(mp4),
mk_mp4_info_get_folder(mp4), mk_record_info_get_folder(mp4),
mk_mp4_info_get_url(mp4), mk_record_info_get_url(mp4),
mk_mp4_info_get_vhost(mp4), mk_record_info_get_vhost(mp4),
mk_mp4_info_get_app(mp4), mk_record_info_get_app(mp4),
mk_mp4_info_get_stream(mp4)); mk_record_info_get_stream(mp4));
} }
/** /**