diff --git a/api/include/mediakit.h b/api/include/mediakit.h index 3d38b9e8..a6f42496 100755 --- a/api/include/mediakit.h +++ b/api/include/mediakit.h @@ -31,7 +31,7 @@ #include "httpdownloader.h" #include "media.h" #include "proxyplayer.h" -#include "flvrecorder.h" +#include "recorder.h" #include "player.h" #include "pusher.h" #include "events.h" diff --git a/api/include/flvrecorder.h b/api/include/recorder.h similarity index 56% rename from api/include/flvrecorder.h rename to api/include/recorder.h index 323d33a6..de697872 100644 --- a/api/include/flvrecorder.h +++ b/api/include/recorder.h @@ -24,8 +24,8 @@ * SOFTWARE. */ -#ifndef MK_FLV_RECORDER_API_H_ -#define MK_FLV_RECORDER_API_H_ +#ifndef MK_RECORDER_API_H_ +#define MK_RECORDER_API_H_ #include "common.h" @@ -33,6 +33,8 @@ extern "C" { #endif +///////////////////////////////////////////flv录制///////////////////////////////////////////// + typedef void* mk_flv_recorder; /** @@ -57,8 +59,48 @@ API_EXPORT void API_CALL mk_flv_recorder_release(mk_flv_recorder ctx); */ API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *app, const char *stream, const char *file_path); + +///////////////////////////////////////////hls/mp4录制///////////////////////////////////////////// + +/** + * 获取录制状态 + * @param type 0:hls,1:MP4 + * @param vhost 虚拟主机 + * @param app 应用名 + * @param stream 流id + * @return 录制状态,0:未录制,1:等待MediaSource注册,注册成功后立即开始录制,2:MediaSource已注册,并且正在录制 + */ +API_EXPORT int mk_recorder_status(int type, const char *vhost, const char *app, const char *stream); + +/** + * 开始录制 + * @param type 0:hls,1:MP4 + * @param vhost 虚拟主机 + * @param app 应用名 + * @param stream 流id + * @param wait_for_record 是否等待流注册后再录制,未注册时,置false将返回失败 + * @param continue_record 流注销时是否继续等待录制还是立即停止录制 + * @return 0代表成功,负数代表失败 + */ +API_EXPORT int mk_recorder_start(int type, const char *vhost, const char *app, const char *stream,bool wait_for_record, bool continue_record); + +/** + * 停止录制 + * @param type 0:hls,1:MP4 + * @param vhost 虚拟主机 + * @param app 应用名 + * @param stream 流id + * @return 1:成功,0:失败 + */ +API_EXPORT int mk_recorder_stop(int type, const char *vhost, const char *app, const char *stream); + +/** + * 停止所有录制,一般程序退出时调用 + */ +API_EXPORT void mk_recorder_stop_all(); + #ifdef __cplusplus } #endif -#endif /* MK_FLV_RECORDER_API_H_ */ +#endif /* MK_RECORDER_API_H_ */ diff --git a/api/source/flvrecorder.cpp b/api/source/recorder.cpp similarity index 69% rename from api/source/flvrecorder.cpp rename to api/source/recorder.cpp index 93882320..04030d37 100644 --- a/api/source/flvrecorder.cpp +++ b/api/source/recorder.cpp @@ -24,8 +24,9 @@ * SOFTWARE. */ -#include "flvrecorder.h" +#include "recorder.h" #include "Rtmp/FlvMuxer.h" +#include "Record/Recorder.h" using namespace toolkit; using namespace mediakit; @@ -48,4 +49,24 @@ API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *a WarnL << ex.what(); return -1; } +} + +///////////////////////////////////////////hls/mp4录制///////////////////////////////////////////// +API_EXPORT int mk_recorder_status(int type, const char *vhost, const char *app, const char *stream){ + assert(vhost && app && stream); + return Recorder::getRecordStatus((Recorder::type)type,vhost,app,stream); +} + +API_EXPORT int mk_recorder_start(int type, const char *vhost, const char *app, const char *stream,bool wait_for_record, bool continue_record){ + assert(vhost && app && stream); + return Recorder::startRecord((Recorder::type)type,vhost,app,stream,wait_for_record,continue_record); +} + +API_EXPORT int mk_recorder_stop(int type, const char *vhost, const char *app, const char *stream){ + assert(vhost && app && stream); + return Recorder::stopRecord((Recorder::type)type,vhost,app,stream); +} + +API_EXPORT void mk_recorder_stop_all(){ + Recorder::stopAll(); } \ No newline at end of file