mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 02:34:26 +08:00
添加C API on_record_ts 回调ts录像信息 (#3520)
用时合并on_record_mp4相关接口 Co-authored-by: 李道甫 <lidf@ahtelit.com>
This commit is contained in:
parent
2eed284e61
commit
18c5bb3670
@ -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;
|
||||
|
||||
|
@ -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映射
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user