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
787af510
Commit
787af510
authored
Apr 23, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api返回音视频相关信息
parent
1c03acbd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
24 行删除
+40
-24
server/WebApi.cpp
+40
-24
没有找到文件。
server/WebApi.cpp
查看文件 @
787af510
...
@@ -372,6 +372,43 @@ void installWebApi() {
...
@@ -372,6 +372,43 @@ void installWebApi() {
#endif//#if !defined(_WIN32)
#endif//#if !defined(_WIN32)
static
auto
makeMediaSourceJson
=
[](
const
MediaSource
::
Ptr
&
media
){
Value
item
;
item
[
"schema"
]
=
media
->
getSchema
();
item
[
"vhost"
]
=
media
->
getVhost
();
item
[
"app"
]
=
media
->
getApp
();
item
[
"stream"
]
=
media
->
getId
();
item
[
"readerCount"
]
=
media
->
readerCount
();
item
[
"totalReaderCount"
]
=
media
->
totalReaderCount
();
for
(
auto
&
track
:
media
->
getTracks
()){
Value
obj
;
auto
codec_type
=
track
->
getTrackType
();
obj
[
"codec_id"
]
=
track
->
getCodecId
();
obj
[
"ready"
]
=
track
->
ready
();
obj
[
"codec_type"
]
=
codec_type
;
switch
(
codec_type
){
case
TrackAudio
:
{
auto
audio_track
=
dynamic_pointer_cast
<
AudioTrack
>
(
track
);
obj
[
"sample_rate"
]
=
audio_track
->
getAudioSampleRate
();
obj
[
"channels"
]
=
audio_track
->
getAudioChannel
();
obj
[
"sample_bit"
]
=
audio_track
->
getAudioSampleBit
();
break
;
}
case
TrackVideo
:
{
auto
video_track
=
dynamic_pointer_cast
<
VideoTrack
>
(
track
);
obj
[
"width"
]
=
video_track
->
getVideoWidth
();
obj
[
"height"
]
=
video_track
->
getVideoHeight
();
obj
[
"fps"
]
=
(
int
)
video_track
->
getVideoFps
();
break
;
}
default:
break
;
}
item
[
"tracks"
].
append
(
obj
);
}
return
item
;
};
//获取流列表,可选筛选参数
//获取流列表,可选筛选参数
//测试url0(获取所有流) http://127.0.0.1/index/api/getMediaList
//测试url0(获取所有流) http://127.0.0.1/index/api/getMediaList
//测试url1(获取虚拟主机为"__defaultVost__"的流) http://127.0.0.1/index/api/getMediaList?vhost=__defaultVost__
//测试url1(获取虚拟主机为"__defaultVost__"的流) http://127.0.0.1/index/api/getMediaList?vhost=__defaultVost__
...
@@ -389,21 +426,7 @@ void installWebApi() {
...
@@ -389,21 +426,7 @@ void installWebApi() {
if
(
!
allArgs
[
"app"
].
empty
()
&&
allArgs
[
"app"
]
!=
media
->
getApp
()){
if
(
!
allArgs
[
"app"
].
empty
()
&&
allArgs
[
"app"
]
!=
media
->
getApp
()){
return
;
return
;
}
}
Value
item
;
val
[
"data"
].
append
(
makeMediaSourceJson
(
media
));
item
[
"schema"
]
=
media
->
getSchema
();
item
[
"vhost"
]
=
media
->
getVhost
();
item
[
"app"
]
=
media
->
getApp
();
item
[
"stream"
]
=
media
->
getId
();
item
[
"readerCount"
]
=
media
->
readerCount
();
item
[
"totalReaderCount"
]
=
media
->
totalReaderCount
();
for
(
auto
&
track
:
media
->
getTracks
()){
Value
obj
;
obj
[
"codec_id"
]
=
track
->
getCodecId
();
obj
[
"codec_type"
]
=
track
->
getTrackType
();
obj
[
"ready"
]
=
track
->
ready
();
item
[
"tracks"
].
append
(
obj
);
}
val
[
"data"
].
append
(
item
);
});
});
});
});
...
@@ -423,16 +446,9 @@ void installWebApi() {
...
@@ -423,16 +446,9 @@ void installWebApi() {
val
[
"online"
]
=
false
;
val
[
"online"
]
=
false
;
return
;
return
;
}
}
val
=
makeMediaSourceJson
(
src
);
val
[
"online"
]
=
true
;
val
[
"online"
]
=
true
;
val
[
"readerCount"
]
=
src
->
readerCount
();
val
[
"code"
]
=
API
::
Success
;
val
[
"totalReaderCount"
]
=
src
->
totalReaderCount
();
for
(
auto
&
track
:
src
->
getTracks
()){
Value
obj
;
obj
[
"codec_id"
]
=
track
->
getCodecId
();
obj
[
"codec_type"
]
=
track
->
getTrackType
();
obj
[
"ready"
]
=
track
->
ready
();
val
[
"tracks"
].
append
(
obj
);
}
});
});
//主动关断流,包括关断拉流、推流
//主动关断流,包括关断拉流、推流
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论