ZLMediaKit/api/include/mk_media.h

179 lines
6.1 KiB
C++
Raw Normal View History

2019-12-18 11:47:49 +08:00
/*
2019-12-17 18:45:31 +08:00
* MIT License
*
* Copyright (c) 2019 xiongziliang <771730766@qq.com>
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef MK_MEDIA_H_
#define MK_MEDIA_H_
#include "mk_common.h"
2019-12-17 18:45:31 +08:00
#ifdef __cplusplus
extern "C" {
#endif
typedef void *mk_media;
/**
*
2019-12-18 14:43:32 +08:00
* @param vhost __defaultVhost__
2019-12-17 18:45:31 +08:00
* @param app live
* @param stream idcamera
* @param duration ()0
* @param hls_enabled hls
* @param mp4_enabled mp4
* @return
*/
2019-12-18 14:43:32 +08:00
API_EXPORT mk_media API_CALL mk_media_create(const char *vhost, const char *app, const char *stream, float duration, int hls_enabled, int mp4_enabled);
2019-12-17 18:45:31 +08:00
/**
*
* @param ctx
*/
API_EXPORT void API_CALL mk_media_release(mk_media ctx);
/**
* h264视频轨道
* @param ctx
* @param width
* @param height
* @param fps fps
*/
API_EXPORT void API_CALL mk_media_init_h264(mk_media ctx, int width, int height, int fps);
/**
* h265视频轨道
* @param ctx
* @param width
* @param height
* @param fps fps
*/
API_EXPORT void API_CALL mk_media_init_h265(mk_media ctx, int width, int height, int fps);
/**
* aac音频轨道
* @param ctx
* @param channel
* @param sample_bit 16
* @param sample_rate
* @param profile aac编码profileadts头时用于生产adts头
*/
API_EXPORT void API_CALL mk_media_init_aac(mk_media ctx, int channel, int sample_bit, int sample_rate, int profile);
2020-02-27 11:40:38 +08:00
/**
* h264/h265/aac完毕后调用此函数
* track()ZLMediaKit不知道后续是否还要添加track3
* Track类型便(3)
* @param ctx
*/
API_EXPORT void API_CALL mk_media_init_complete(mk_media ctx);
2019-12-17 18:45:31 +08:00
/**
* H264视频00 00 01,00 00 00 01
* @param ctx
* @param data H264数据
* @param len H264数据字节数
* @param dts
2020-01-09 17:17:48 +08:00
* @param pts
2019-12-17 18:45:31 +08:00
*/
API_EXPORT void API_CALL mk_media_input_h264(mk_media ctx, void *data, int len, uint32_t dts, uint32_t pts);
/**
* H265视频00 00 01,00 00 00 01
* @param ctx
* @param data H265数据
* @param len H265数据字节数
* @param dts
2020-01-09 17:17:48 +08:00
* @param pts
2019-12-17 18:45:31 +08:00
*/
API_EXPORT void API_CALL mk_media_input_h265(mk_media ctx, void *data, int len, uint32_t dts, uint32_t pts);
/**
* AAC音频
* @param ctx
* @param data AAC数据
* @param len AAC数据字节数
* @param dts
* @param with_adts_header data中是否包含7个字节的adts头
*/
API_EXPORT void API_CALL mk_media_input_aac(mk_media ctx, void *data, int len, uint32_t dts, int with_adts_header);
/**
* AAC音频(adts头)
* @param ctx
* @param data adts头的单帧AAC数据
* @param len AAC数据字节数
* @param dts
* @param adts adts头
*/
API_EXPORT void API_CALL mk_media_input_aac1(mk_media ctx, void *data, int len, uint32_t dts, void *adts);
2020-02-28 17:53:21 +08:00
/**
2020-03-10 22:55:19 +08:00
* MediaSource.close()
* MediaSource时
* mk_media_release函数并且释放其他资源
* mk_media_release函数MediaSource.close()
2020-02-28 17:53:21 +08:00
* @param user_data mk_media_set_on_close函数设置
*/
2020-03-10 22:55:19 +08:00
typedef void(API_CALL *on_mk_media_close)(void *user_data);
2020-02-28 17:53:21 +08:00
/**
* MediaSource.close()
2020-03-10 22:55:19 +08:00
* MediaSource时
* mk_media_release函数并且释放其他资源
2020-02-28 17:53:21 +08:00
* @param ctx
* @param cb
* @param user_data
*/
API_EXPORT void API_CALL mk_media_set_on_close(mk_media ctx, on_mk_media_close cb, void *user_data);
2020-04-02 10:31:33 +08:00
/**
* seek请求时触发该回调
* @param user_data ,mk_media_set_on_seek设置
* @param stamp_ms seek至的时间轴位置
* @return 1seek请求0
*/
typedef int(API_CALL *on_mk_media_seek)(void *user_data,uint32_t stamp_ms);
/**
* seek请求事件
* @param ctx
* @param cb
* @param user_data
*/
API_EXPORT void API_CALL mk_media_set_on_seek(mk_media ctx, on_mk_media_seek cb, void *user_data);
2020-02-28 17:53:21 +08:00
/**
*
* @param ctx
* @return
*/
API_EXPORT int API_CALL mk_media_total_reader_count(mk_media ctx);
2019-12-17 18:45:31 +08:00
#ifdef __cplusplus
}
#endif
#endif /* MK_MEDIA_H_ */