mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-02-14 20:30:53 +08:00
增加实用restful接口 (#1183)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user