1 /* 2 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. 3 * 4 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). 5 * 6 * Use of this source code is governed by MIT license that can be found in the 7 * LICENSE file in the root of the source tree. All contributing project authors 8 * may be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MK_RECORDER_API_H_ 12 #define MK_RECORDER_API_H_ 13 14 #include "mk_common.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 ///////////////////////////////////////////flv录制///////////////////////////////////////////// 21 22 typedef void* mk_flv_recorder; 23 24 /** 25 * 创建flv录制器 26 * @return 27 */ 28 API_EXPORT mk_flv_recorder API_CALL mk_flv_recorder_create(); 29 30 /** 31 * 释放flv录制器 32 * @param ctx 33 */ 34 API_EXPORT void API_CALL mk_flv_recorder_release(mk_flv_recorder ctx); 35 36 /** 37 * 开始录制flv 38 * @param ctx flv录制器 39 * @param vhost 虚拟主机 40 * @param app 绑定的RtmpMediaSource的 app名 41 * @param stream 绑定的RtmpMediaSource的 stream名 42 * @param file_path 文件存放地址 43 * @return 0:开始超过,-1:失败,打开文件失败或该RtmpMediaSource不存在 44 */ 45 API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *vhost, const char *app, const char *stream, const char *file_path); 46 47 ///////////////////////////////////////////hls/mp4录制///////////////////////////////////////////// 48 49 /** 50 * 获取录制状态 51 * @param type 0:hls,1:MP4 52 * @param vhost 虚拟主机 53 * @param app 应用名 54 * @param stream 流id 55 * @return 录制状态,0:未录制, 1:正在录制 56 */ 57 API_EXPORT int API_CALL mk_recorder_is_recording(int type, const char *vhost, const char *app, const char *stream); 58 59 /** 60 * 开始录制 61 * @param type 0:hls,1:MP4 62 * @param vhost 虚拟主机 63 * @param app 应用名 64 * @param stream 流id 65 * @param customized_path 录像文件保存自定义目录,默认为空或null则自动生成 66 * @param max_second mp4录制最大切片时间,单位秒,置0则采用配置文件配置 67 * @return 1代表成功,0代表失败 68 */ 69 API_EXPORT int API_CALL mk_recorder_start(int type, const char *vhost, const char *app, const char *stream, const char *customized_path, size_t max_second); 70 71 /** 72 * 停止录制 73 * @param type 0:hls,1:MP4 74 * @param vhost 虚拟主机 75 * @param app 应用名 76 * @param stream 流id 77 * @return 1:成功,0:失败 78 */ 79 API_EXPORT int API_CALL mk_recorder_stop(int type, const char *vhost, const char *app, const char *stream); 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif /* MK_RECORDER_API_H_ */ 86