增加实用restful接口 (#1183)

This commit is contained in:
rqb500
2021-10-25 15:13:21 +08:00
committed by GitHub
parent 573dc2e67a
commit 5a04575cb9
2 changed files with 132 additions and 1 deletions

View File

@@ -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<float>());
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<size_t>());
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
}
}
}