ZLMediaKit/api/include/mk_track.h

136 lines
3.1 KiB
C++
Raw Normal View History

/*
2023-12-09 16:23:51 +08:00
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
2022-05-25 15:38:32 +08:00
*
2023-12-09 16:23:51 +08:00
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
2022-05-25 15:38:32 +08:00
*
2023-12-09 16:23:51 +08:00
* Use of this source code is governed by MIT-like license that can be found in the
2022-05-25 15:38:32 +08:00
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ZLMEDIAKIT_MK_TRACK_H
#define ZLMEDIAKIT_MK_TRACK_H
#include "mk_common.h"
#include "mk_frame.h"
#ifdef __cplusplus
extern "C" {
#endif
//音视频轨道
typedef struct mk_track_t *mk_track;
2022-05-25 15:38:32 +08:00
//输出frame回调
typedef void(API_CALL *on_mk_frame_out)(void *user_data, mk_frame frame);
//track创建参数
typedef union {
struct {
int width;
int height;
int fps;
} video;
struct {
int channels;
int sample_rate;
} audio;
} codec_args;
/**
* track对象引用
* @param codec_id MKCodecXXX
* @param args
* @return track对象引用
*/
API_EXPORT mk_track API_CALL mk_track_create(int codec_id, codec_args *args);
/**
* track对象
* @param track track对象
*/
API_EXPORT void API_CALL mk_track_unref(mk_track track);
/**
* track对象
* @param track track对象
* @return track引用对象
*/
API_EXPORT mk_track API_CALL mk_track_ref(mk_track track);
/**
* track codec类型MKCodecXXX定义
*/
API_EXPORT int API_CALL mk_track_codec_id(mk_track track);
/**
* codec名称
*/
API_EXPORT const char* API_CALL mk_track_codec_name(mk_track track);
/**
*
*/
API_EXPORT int API_CALL mk_track_bit_rate(mk_track track);
/**
* frame输出事件
* @param track track对象
* @param cb frame输出回调
* @param user_data frame输出回调用户指针参数
*/
API_EXPORT void *API_CALL mk_track_add_delegate(mk_track track, on_mk_frame_out cb, void *user_data);
API_EXPORT void *API_CALL mk_track_add_delegate2(mk_track track, on_mk_frame_out cb, void *user_data, on_user_data_free user_data_free);
2022-05-25 15:38:32 +08:00
/**
* frame输出事件监听
* @param track track对象
* @param tag mk_track_add_delegate返回值
*/
API_EXPORT void API_CALL mk_track_del_delegate(mk_track track, void *tag);
/**
* frame到trackapi
*/
API_EXPORT void API_CALL mk_track_input_frame(mk_track track, mk_frame frame);
/**
* track是否为视频
*/
API_EXPORT int API_CALL mk_track_is_video(mk_track track);
/**
*
*/
API_EXPORT int API_CALL mk_track_video_width(mk_track track);
/**
*
*/
API_EXPORT int API_CALL mk_track_video_height(mk_track track);
/**
*
*/
API_EXPORT int API_CALL mk_track_video_fps(mk_track track);
/**
*
*/
API_EXPORT int API_CALL mk_track_audio_sample_rate(mk_track track);
/**
*
*/
API_EXPORT int API_CALL mk_track_audio_channel(mk_track track);
/**
* 16bit
*/
API_EXPORT int API_CALL mk_track_audio_sample_bit(mk_track track);
#ifdef __cplusplus
}
#endif
#endif //ZLMEDIAKIT_MK_TRACK_H