Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
5a04575c
Unverified
Commit
5a04575c
authored
Oct 25, 2021
by
rqb500
Committed by
GitHub
Oct 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加实用restful接口 (#1183)
parent
573dc2e6
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
131 行增加
和
0 行删除
+131
-0
postman/ZLMediaKit.postman_collection.json
+92
-0
server/WebApi.cpp
+39
-0
没有找到文件。
postman/ZLMediaKit.postman_collection.json
查看文件 @
5a04575c
...
@@ -945,6 +945,98 @@
...
@@ -945,6 +945,98 @@
"response"
:
[]
"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)"
,
"name"
:
"停止录制(stopRecord)"
,
"request"
:
{
"request"
:
{
"method"
:
"GET"
,
"method"
:
"GET"
,
...
...
server/WebApi.cpp
查看文件 @
5a04575c
...
@@ -1038,6 +1038,45 @@ void installWebApi() {
...
@@ -1038,6 +1038,45 @@ void installWebApi() {
val
[
"msg"
]
=
result
?
"success"
:
"start record failed"
;
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
// 停止录制hls或MP4
api_regist
(
"/index/api/stopRecord"
,[](
API_ARGS_MAP
){
api_regist
(
"/index/api/stopRecord"
,[](
API_ARGS_MAP
){
CHECK_SECRET
();
CHECK_SECRET
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论