diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 68072313..3e286441 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -944,6 +944,98 @@ }, "response": [] }, + { + "name": "设置录像速度(setRecordSpeed)", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{ZLMediaKit_URL}}/index/api/setRecordSpeed?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=live&stream=obs&speed=2.0", + "host": [ + "{{ZLMediaKit_URL}}" + ], + "path": [ + "index", + "api", + "setRecordSpeed" + ], + "query": [ + { + "key": "secret", + "value": "{{ZLMediaKit_secret}}", + "description": "api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数" + }, + { + "key": "vhost", + "value": "{{defaultVhost}}", + "description": "虚拟主机,例如__defaultVhost__" + }, + { + "key": "app", + "value": "live", + "description": "应用名,例如 live" + }, + { + "key": "stream", + "value": "obs", + "description": "流id,例如 obs" + }, + { + "key": "speed", + "value": 2.0, + "description": "要设置的录像倍速", + } + ] + } + }, + "response": [] + }, + { + "name": "设置录像流播放位置(seekRecordStamp)", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{ZLMediaKit_URL}}/index/api/startRecord?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=live&stream=obs&stamp=1000", + "host": [ + "{{ZLMediaKit_URL}}" + ], + "path": [ + "index", + "api", + "seekRecordStamp" + ], + "query": [ + { + "key": "secret", + "value": "{{ZLMediaKit_secret}}", + "description": "api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数" + }, + { + "key": "vhost", + "value": "{{defaultVhost}}", + "description": "虚拟主机,例如__defaultVhost__" + }, + { + "key": "app", + "value": "live", + "description": "应用名,例如 live" + }, + { + "key": "stream", + "value": "obs", + "description": "流id,例如 obs" + }, + { + "key": "stamp", + "value": 1000, + "description": "要设置的录像播放位置", + } + ] + } + }, + "response": [] + }, { "name": "停止录制(stopRecord)", "request": { diff --git a/server/WebApi.cpp b/server/WebApi.cpp index a6b916f8..5d9d0a05 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1037,6 +1037,45 @@ void installWebApi() { val["code"] = result ? API::Success : API::OtherFailed; val["msg"] = result ? "success" : "start record failed"; }); + + //设置录像流播放速度 + api_regist("/index/api/setRecordSpeed", [](API_ARGS_MAP) { + CHECK_SECRET(); + CHECK_ARGS("schema", "vhost", "app", "stream", "speed"); + auto src = MediaSource::find(allArgs["schema"], + allArgs["vhost"], + allArgs["app"], + allArgs["stream"]); + if (src) { + bool flag = src->speed(allArgs["speed"].as()); + val["result"] = flag ? 0 : -1; + val["msg"] = flag ? "success" : "set failed"; + val["code"] = flag ? API::Success : API::OtherFailed; + } else { + val["result"] = -2; + val["msg"] = "can not find the stream"; + val["code"] = API::OtherFailed; + } + }); + + api_regist("/index/api/seekRecordStamp", [](API_ARGS_MAP) { + CHECK_SECRET(); + CHECK_ARGS("schema", "vhost", "app", "stream", "stamp"); + auto src = MediaSource::find(allArgs["schema"], + allArgs["vhost"], + allArgs["app"], + allArgs["stream"]); + if (src) { + bool flag = src->seekTo(allArgs["stamp"].as()); + val["result"] = flag ? 0 : -1; + val["msg"] = flag ? "success" : "seek failed"; + val["code"] = flag ? API::Success : API::OtherFailed; + } else { + val["result"] = -2; + val["msg"] = "can not find the stream"; + val["code"] = API::OtherFailed; + } + }); // 停止录制hls或MP4 api_regist("/index/api/stopRecord",[](API_ARGS_MAP){ @@ -1399,4 +1438,4 @@ void unInstallWebApi(){ s_rtpServerMap.clear(); #endif } -} \ No newline at end of file +}