From 69c0c3e237d4c15174675e4172bd7bc1212e1d51 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 5 Dec 2019 12:04:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=95=E5=88=B6=E7=9B=B8?= =?UTF-8?q?=E5=85=B3http=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 34 ++++++++++++++++++++++++++++++++++ src/Record/Recorder.h | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 580e34c8..4e2e14d7 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -692,6 +692,40 @@ void installWebApi() { invoker.responseFile(headerIn,StrCaseMap(),exePath()); }); + // 开始录制hls或MP4 + API_REGIST_INVOKER(api,startRecord,{ + CHECK_SECRET(); + CHECK_ARGS("type","vhost","app","stream","wait_for_record","continue_record"); + int result = Recorder::startRecord((Recorder::type)allArgs["type"].as(), + allArgs["vhost"], + allArgs["app"], + allArgs["stream"], + allArgs["wait_for_record"], + allArgs["continue_record"]); + val["result"] = result; + }); + + // 停止录制hls或MP4 + API_REGIST_INVOKER(api,stopRecord,{ + CHECK_SECRET(); + CHECK_ARGS("type","vhost","app","stream"); + Recorder::stopRecord((Recorder::type)allArgs["type"].as(), + allArgs["vhost"], + allArgs["app"], + allArgs["stream"]); + }); + + // 获取hls或MP4录制状态 + API_REGIST_INVOKER(api,stopRecord,{ + CHECK_SECRET(); + CHECK_ARGS("type","vhost","app","stream"); + auto status = Recorder::getRecordStatus((Recorder::type)allArgs["type"].as(), + allArgs["vhost"], + allArgs["app"], + allArgs["stream"]); + val["status"] = (int)status; + }); + ////////////以下是注册的Hook API//////////// API_REGIST(hook,on_publish,{ //开始推流事件 diff --git a/src/Record/Recorder.h b/src/Record/Recorder.h index 64d3af9a..ffb8017c 100644 --- a/src/Record/Recorder.h +++ b/src/Record/Recorder.h @@ -70,7 +70,7 @@ public: * @param app 应用名 * @param stream_id 流id * @param waitForRecord 是否等待流注册后再录制,未注册时,置false将返回失败 - * @param continueRecord 流注销时是否继续等待录制还是立即停止注册 + * @param continueRecord 流注销时是否继续等待录制还是立即停止录制 * @return 0代表成功,负数代表失败 */ static int startRecord(type type, const string &vhost, const string &app, const string &stream_id,bool waitForRecord, bool continueRecord);