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
aa39680c
Commit
aa39680c
authored
Jun 17, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addStreamPusherProxy接口修改key唯一性规则,新增rtsp推流类型、超时参数
parent
eef0c31d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
8 行删除
+21
-8
server/WebApi.cpp
+21
-8
没有找到文件。
server/WebApi.cpp
查看文件 @
aa39680c
...
...
@@ -249,10 +249,15 @@ static unordered_map<string, RtpServer::Ptr> s_rtpServerMap;
static
recursive_mutex
s_rtpServerMapMtx
;
#endif
static
inline
string
getProxyKey
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
)
{
static
inline
string
getProxyKey
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
)
{
return
vhost
+
"/"
+
app
+
"/"
+
stream
;
}
static
inline
string
getPusherKey
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
,
const
string
&
dst_url
)
{
return
schema
+
"/"
+
vhost
+
"/"
+
app
+
"/"
+
stream
+
"/"
+
MD5
(
dst_url
).
hexdigest
();
}
Value
makeMediaSourceJson
(
MediaSource
&
media
){
Value
item
;
item
[
"schema"
]
=
media
.
getSchema
();
...
...
@@ -606,9 +611,11 @@ void installWebApi() {
const
string
&
app
,
const
string
&
stream
,
const
string
&
url
,
int
retryCount
,
int
retry_count
,
int
rtp_type
,
float
timeout_sec
,
const
function
<
void
(
const
SockException
&
ex
,
const
string
&
key
)
>
&
cb
)
{
auto
key
=
getP
roxyKey
(
vhost
,
app
,
stream
);
auto
key
=
getP
usherKey
(
schema
,
vhost
,
app
,
stream
,
url
);
lock_guard
<
recursive_mutex
>
lck
(
s_proxyPusherMapMtx
);
if
(
s_proxyPusherMap
.
find
(
key
)
!=
s_proxyPusherMap
.
end
())
{
//已经在推流了
...
...
@@ -616,14 +623,18 @@ void installWebApi() {
return
;
}
auto
poller
=
EventPollerPool
::
Instance
().
getPoller
();
int
retry_count
=
3
;
if
(
retryCount
!=
0
)
retry_count
=
retryCount
;
//添加推流代理
PusherProxy
::
Ptr
pusher
(
new
PusherProxy
(
schema
,
vhost
,
app
,
stream
,
retry_count
,
poller
));
PusherProxy
::
Ptr
pusher
(
new
PusherProxy
(
schema
,
vhost
,
app
,
stream
,
retry_count
?
retry_count
:
-
1
));
s_proxyPusherMap
[
key
]
=
pusher
;
//指定RTP over TCP(播放rtsp时有效)
(
*
pusher
)[
kRtpType
]
=
rtp_type
;
if
(
timeout_sec
>
0.1
)
{
//推流握手超时时间
(
*
pusher
)[
kTimeoutMS
]
=
timeout_sec
*
1000
;
}
//开始推流,如果推流失败或者推流中止,将会自动重试若干次,默认一直重试
pusher
->
setPushCallbackOnce
([
cb
,
key
,
url
](
const
SockException
&
ex
)
{
if
(
ex
)
{
...
...
@@ -671,6 +682,8 @@ void installWebApi() {
allArgs
[
"stream"
],
allArgs
[
"dst_url"
],
allArgs
[
"retry_count"
],
allArgs
[
"rtp_type"
],
allArgs
[
"timeout_sec"
],
[
invoker
,
val
,
headerOut
,
dst_url
](
const
SockException
&
ex
,
const
string
&
key
)
mutable
{
if
(
ex
)
{
val
[
"code"
]
=
API
::
OtherFailed
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论