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
94ccd27f
Commit
94ccd27f
authored
May 28, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
等待流注册时间可配置化
parent
22e39dc2
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
17 行增加
和
10 行删除
+17
-10
src/Common/MediaSource.cpp
+7
-5
src/Common/MediaSource.h
+0
-1
src/Common/config.cpp
+2
-1
src/Common/config.h
+5
-0
src/Http/HttpSession.cpp
+1
-1
src/Rtmp/RtmpSession.cpp
+1
-1
src/Rtsp/RtspSession.cpp
+1
-1
没有找到文件。
src/Common/MediaSource.cpp
查看文件 @
94ccd27f
...
@@ -43,7 +43,6 @@ MediaSource::SchemaVhostAppStreamMap MediaSource::g_mapMediaSrc;
...
@@ -43,7 +43,6 @@ MediaSource::SchemaVhostAppStreamMap MediaSource::g_mapMediaSrc;
void
MediaSource
::
findAsync
(
const
MediaInfo
&
info
,
void
MediaSource
::
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
bool
retry
,
bool
retry
,
int
maxWaitMs
,
const
function
<
void
(
const
MediaSource
::
Ptr
&
src
)
>
&
cb
){
const
function
<
void
(
const
MediaSource
::
Ptr
&
src
)
>
&
cb
){
auto
src
=
MediaSource
::
find
(
info
.
_schema
,
auto
src
=
MediaSource
::
find
(
info
.
_schema
,
...
@@ -61,15 +60,18 @@ void MediaSource::findAsync(const MediaInfo &info,
...
@@ -61,15 +60,18 @@ void MediaSource::findAsync(const MediaInfo &info,
//广播未找到流,此时可以立即去拉流,这样还来得及
//广播未找到流,此时可以立即去拉流,这样还来得及
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastNotFoundStream
,
info
,
*
session
);
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastNotFoundStream
,
info
,
*
session
);
//最多等待一定时间,如果这个时间内,流未注册上,那么返回未找到流
GET_CONFIG_AND_REGISTER
(
int
,
maxWaitMS
,
Broadcast
::
kMaxStreamWaitTimeMS
);
//若干秒后执行等待媒体注册超时回调
//若干秒后执行等待媒体注册超时回调
auto
onRegistTimeout
=
session
->
getPoller
()
->
doDelayTask
(
maxWaitM
s
,[
cb
,
listener_tag
](){
auto
onRegistTimeout
=
session
->
getPoller
()
->
doDelayTask
(
maxWaitM
S
,[
cb
,
listener_tag
](){
//取消监听该事件
//取消监听该事件
NoticeCenter
::
Instance
().
delListener
(
listener_tag
,
Broadcast
::
kBroadcastMediaChanged
);
NoticeCenter
::
Instance
().
delListener
(
listener_tag
,
Broadcast
::
kBroadcastMediaChanged
);
cb
(
nullptr
);
cb
(
nullptr
);
return
0
;
return
0
;
});
});
auto
onRegist
=
[
listener_tag
,
weakSession
,
info
,
cb
,
maxWaitMs
,
onRegistTimeout
](
BroadcastMediaChangedArgs
)
{
auto
onRegist
=
[
listener_tag
,
weakSession
,
info
,
cb
,
onRegistTimeout
](
BroadcastMediaChangedArgs
)
{
if
(
!
bRegist
||
schema
!=
info
.
_schema
||
vhost
!=
info
.
_vhost
||
app
!=
info
.
_app
||
stream
!=
info
.
_streamid
){
if
(
!
bRegist
||
schema
!=
info
.
_schema
||
vhost
!=
info
.
_vhost
||
app
!=
info
.
_app
||
stream
!=
info
.
_streamid
){
//不是自己感兴趣的事件,忽略之
//不是自己感兴趣的事件,忽略之
return
;
return
;
...
@@ -85,14 +87,14 @@ void MediaSource::findAsync(const MediaInfo &info,
...
@@ -85,14 +87,14 @@ void MediaSource::findAsync(const MediaInfo &info,
}
}
//切换到自己的线程再回复
//切换到自己的线程再回复
strongSession
->
async
([
listener_tag
,
weakSession
,
info
,
cb
,
maxWaitMs
](){
strongSession
->
async
([
listener_tag
,
weakSession
,
info
,
cb
](){
auto
strongSession
=
weakSession
.
lock
();
auto
strongSession
=
weakSession
.
lock
();
if
(
!
strongSession
)
{
if
(
!
strongSession
)
{
return
;
return
;
}
}
DebugL
<<
"收到媒体注册事件,回复播放器:"
<<
info
.
_schema
<<
"/"
<<
info
.
_vhost
<<
"/"
<<
info
.
_app
<<
"/"
<<
info
.
_streamid
;
DebugL
<<
"收到媒体注册事件,回复播放器:"
<<
info
.
_schema
<<
"/"
<<
info
.
_vhost
<<
"/"
<<
info
.
_app
<<
"/"
<<
info
.
_streamid
;
//再找一遍媒体源,一般能找到
//再找一遍媒体源,一般能找到
findAsync
(
info
,
strongSession
,
false
,
maxWaitMs
,
cb
);
findAsync
(
info
,
strongSession
,
false
,
cb
);
//取消事件监听
//取消事件监听
NoticeCenter
::
Instance
().
delListener
(
listener_tag
,
Broadcast
::
kBroadcastMediaChanged
);
NoticeCenter
::
Instance
().
delListener
(
listener_tag
,
Broadcast
::
kBroadcastMediaChanged
);
},
false
);
},
false
);
...
...
src/Common/MediaSource.h
查看文件 @
94ccd27f
...
@@ -128,7 +128,6 @@ public:
...
@@ -128,7 +128,6 @@ public:
static
void
findAsync
(
const
MediaInfo
&
info
,
static
void
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
bool
retry
,
bool
retry
,
int
maxWaitMs
,
const
function
<
void
(
const
MediaSource
::
Ptr
&
src
)
>
&
cb
);
const
function
<
void
(
const
MediaSource
::
Ptr
&
src
)
>
&
cb
);
const
string
&
getSchema
()
const
{
const
string
&
getSchema
()
const
{
...
...
src/Common/config.cpp
查看文件 @
94ccd27f
...
@@ -69,11 +69,12 @@ const char kBroadcastStreamNoneReader[] = "kBroadcastStreamNoneReader";
...
@@ -69,11 +69,12 @@ const char kBroadcastStreamNoneReader[] = "kBroadcastStreamNoneReader";
const
char
kFlowThreshold
[]
=
"broadcast.flowThreshold"
;
const
char
kFlowThreshold
[]
=
"broadcast.flowThreshold"
;
const
char
kStreamNoneReaderDelayMS
[]
=
"broadcast.streamNoneReaderDelayMS"
;
const
char
kStreamNoneReaderDelayMS
[]
=
"broadcast.streamNoneReaderDelayMS"
;
const
char
kMaxStreamWaitTimeMS
[]
=
"kMaxStreamWaitTimeMS"
;
onceToken
token
([](){
onceToken
token
([](){
mINI
::
Instance
()[
kFlowThreshold
]
=
1024
;
mINI
::
Instance
()[
kFlowThreshold
]
=
1024
;
mINI
::
Instance
()[
kStreamNoneReaderDelayMS
]
=
5
*
1000
;
mINI
::
Instance
()[
kStreamNoneReaderDelayMS
]
=
5
*
1000
;
mINI
::
Instance
()[
kMaxStreamWaitTimeMS
]
=
5
*
1000
;
},
nullptr
);
},
nullptr
);
}
//namespace Broadcast
}
//namespace Broadcast
...
...
src/Common/config.h
查看文件 @
94ccd27f
...
@@ -127,9 +127,14 @@ extern const char kFlowThreshold[];
...
@@ -127,9 +127,14 @@ extern const char kFlowThreshold[];
//默认连续5秒无人观看然后触发kBroadcastStreamNoneReader事件
//默认连续5秒无人观看然后触发kBroadcastStreamNoneReader事件
extern
const
char
kStreamNoneReaderDelayMS
[];
extern
const
char
kStreamNoneReaderDelayMS
[];
//等待流注册超时时间,收到播放器后请求后,如果未找到相关流,服务器会等待一定时间,
//如果在这个时间内,相关流注册上了,那么服务器会立即响应播放器播放成功,
//否则会最多等待kMaxStreamWaitTimeMS毫秒,然后响应播放器播放失败
extern
const
char
kMaxStreamWaitTimeMS
[];
//更新配置文件事件广播,执行loadIniConfig函数加载配置文件成功后会触发该广播
//更新配置文件事件广播,执行loadIniConfig函数加载配置文件成功后会触发该广播
extern
const
char
kBroadcastReloadConfig
[];
extern
const
char
kBroadcastReloadConfig
[];
#define BroadcastReloadConfigArgs void
#define BroadcastReloadConfigArgs void
#define ReloadConfigTag ((void *)(0xFF))
#define ReloadConfigTag ((void *)(0xFF))
...
...
src/Http/HttpSession.cpp
查看文件 @
94ccd27f
...
@@ -222,7 +222,7 @@ inline bool HttpSession::checkLiveFlvStream(){
...
@@ -222,7 +222,7 @@ inline bool HttpSession::checkLiveFlvStream(){
bool
bClose
=
(
strcasecmp
(
_parser
[
"Connection"
].
data
(),
"close"
)
==
0
)
||
(
++
_iReqCnt
>
reqCnt
);
bool
bClose
=
(
strcasecmp
(
_parser
[
"Connection"
].
data
(),
"close"
)
==
0
)
||
(
++
_iReqCnt
>
reqCnt
);
weak_ptr
<
HttpSession
>
weakSelf
=
dynamic_pointer_cast
<
HttpSession
>
(
shared_from_this
());
weak_ptr
<
HttpSession
>
weakSelf
=
dynamic_pointer_cast
<
HttpSession
>
(
shared_from_this
());
MediaSource
::
findAsync
(
_mediaInfo
,
weakSelf
.
lock
(),
true
,
5000
,
[
weakSelf
,
bClose
,
this
](
const
MediaSource
::
Ptr
&
src
){
MediaSource
::
findAsync
(
_mediaInfo
,
weakSelf
.
lock
(),
true
,[
weakSelf
,
bClose
,
this
](
const
MediaSource
::
Ptr
&
src
){
auto
strongSelf
=
weakSelf
.
lock
();
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
){
if
(
!
strongSelf
){
//本对象已经销毁
//本对象已经销毁
...
...
src/Rtmp/RtmpSession.cpp
查看文件 @
94ccd27f
...
@@ -306,7 +306,7 @@ void RtmpSession::doPlayResponse(const string &err,const std::function<void(bool
...
@@ -306,7 +306,7 @@ void RtmpSession::doPlayResponse(const string &err,const std::function<void(bool
//鉴权成功,查找媒体源并回复
//鉴权成功,查找媒体源并回复
_mediaInfo
.
_schema
=
RTMP_SCHEMA
;
_mediaInfo
.
_schema
=
RTMP_SCHEMA
;
weak_ptr
<
RtmpSession
>
weakSelf
=
dynamic_pointer_cast
<
RtmpSession
>
(
shared_from_this
());
weak_ptr
<
RtmpSession
>
weakSelf
=
dynamic_pointer_cast
<
RtmpSession
>
(
shared_from_this
());
MediaSource
::
findAsync
(
_mediaInfo
,
weakSelf
.
lock
(),
true
,
5000
,
[
weakSelf
,
cb
](
const
MediaSource
::
Ptr
&
src
){
MediaSource
::
findAsync
(
_mediaInfo
,
weakSelf
.
lock
(),
true
,[
weakSelf
,
cb
](
const
MediaSource
::
Ptr
&
src
){
auto
rtmp_src
=
dynamic_pointer_cast
<
RtmpMediaSource
>
(
src
);
auto
rtmp_src
=
dynamic_pointer_cast
<
RtmpMediaSource
>
(
src
);
auto
strongSelf
=
weakSelf
.
lock
();
auto
strongSelf
=
weakSelf
.
lock
();
if
(
strongSelf
){
if
(
strongSelf
){
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
94ccd27f
...
@@ -304,7 +304,7 @@ bool RtspSession::handleReq_Describe(const Parser &parser) {
...
@@ -304,7 +304,7 @@ bool RtspSession::handleReq_Describe(const Parser &parser) {
_mediaInfo
.
_schema
=
RTSP_SCHEMA
;
_mediaInfo
.
_schema
=
RTSP_SCHEMA
;
auto
authorization
=
parser
[
"Authorization"
];
auto
authorization
=
parser
[
"Authorization"
];
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
MediaSource
::
findAsync
(
_mediaInfo
,
weakSelf
.
lock
(),
true
,
5000
,
[
weakSelf
,
authorization
](
const
MediaSource
::
Ptr
&
src
){
MediaSource
::
findAsync
(
_mediaInfo
,
weakSelf
.
lock
(),
true
,[
weakSelf
,
authorization
](
const
MediaSource
::
Ptr
&
src
){
auto
strongSelf
=
weakSelf
.
lock
();
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
){
if
(
!
strongSelf
){
return
;
return
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论