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
8937d9ea
Commit
8937d9ea
authored
Jan 17, 2022
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加递归溢出检测代码: #1363
parent
0c4410c5
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
37 行增加
和
1 行删除
+37
-1
src/Common/MediaSource.cpp
+36
-1
src/Common/MediaSource.h
+1
-0
没有找到文件。
src/Common/MediaSource.cpp
查看文件 @
8937d9ea
...
@@ -609,7 +609,28 @@ string MediaSourceEvent::getOriginUrl(MediaSource &sender) const {
...
@@ -609,7 +609,28 @@ string MediaSourceEvent::getOriginUrl(MediaSource &sender) const {
return
getOriginUrl_l
(
&
sender
);
return
getOriginUrl_l
(
&
sender
);
}
}
class
InvokeDepthHelper
{
public
:
InvokeDepthHelper
(
const
int
&
depth
,
int
max_depth
,
const
LogContextCapture
&
log
)
:
_depth
(
const_cast
<
int
&>
(
depth
))
{
if
(
++
_depth
>
max_depth
)
{
throw
std
::
runtime_error
(
"invalid call depth: "
+
to_string
(
_depth
));
}
else
{
const_cast
<
LogContextCapture
&>
(
log
).
clear
();
}
}
~
InvokeDepthHelper
()
{
--
_depth
;
}
private
:
int
&
_depth
;
};
#define CHECK_CALL_DEPTH() \
InvokeDepthHelper \
heler(_invoke_depth, 5, ErrorL << "invalid call depth[" << _invoke_depth + 1 << "] on object: " << this)
MediaOriginType
MediaSourceEventInterceptor
::
getOriginType
(
MediaSource
&
sender
)
const
{
MediaOriginType
MediaSourceEventInterceptor
::
getOriginType
(
MediaSource
&
sender
)
const
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
MediaOriginType
::
unknown
;
return
MediaOriginType
::
unknown
;
...
@@ -618,6 +639,7 @@ MediaOriginType MediaSourceEventInterceptor::getOriginType(MediaSource &sender)
...
@@ -618,6 +639,7 @@ MediaOriginType MediaSourceEventInterceptor::getOriginType(MediaSource &sender)
}
}
string
MediaSourceEventInterceptor
::
getOriginUrl
(
MediaSource
&
sender
)
const
{
string
MediaSourceEventInterceptor
::
getOriginUrl
(
MediaSource
&
sender
)
const
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
MediaSourceEvent
::
getOriginUrl
(
sender
);
return
MediaSourceEvent
::
getOriginUrl
(
sender
);
...
@@ -630,6 +652,7 @@ string MediaSourceEventInterceptor::getOriginUrl(MediaSource &sender) const {
...
@@ -630,6 +652,7 @@ string MediaSourceEventInterceptor::getOriginUrl(MediaSource &sender) const {
}
}
std
::
shared_ptr
<
SockInfo
>
MediaSourceEventInterceptor
::
getOriginSock
(
MediaSource
&
sender
)
const
{
std
::
shared_ptr
<
SockInfo
>
MediaSourceEventInterceptor
::
getOriginSock
(
MediaSource
&
sender
)
const
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
nullptr
;
return
nullptr
;
...
@@ -638,6 +661,7 @@ std::shared_ptr<SockInfo> MediaSourceEventInterceptor::getOriginSock(MediaSource
...
@@ -638,6 +661,7 @@ std::shared_ptr<SockInfo> MediaSourceEventInterceptor::getOriginSock(MediaSource
}
}
bool
MediaSourceEventInterceptor
::
seekTo
(
MediaSource
&
sender
,
uint32_t
stamp
)
{
bool
MediaSourceEventInterceptor
::
seekTo
(
MediaSource
&
sender
,
uint32_t
stamp
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
false
;
return
false
;
...
@@ -646,6 +670,7 @@ bool MediaSourceEventInterceptor::seekTo(MediaSource &sender, uint32_t stamp) {
...
@@ -646,6 +670,7 @@ bool MediaSourceEventInterceptor::seekTo(MediaSource &sender, uint32_t stamp) {
}
}
bool
MediaSourceEventInterceptor
::
pause
(
MediaSource
&
sender
,
bool
pause
)
{
bool
MediaSourceEventInterceptor
::
pause
(
MediaSource
&
sender
,
bool
pause
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
false
;
return
false
;
...
@@ -654,6 +679,7 @@ bool MediaSourceEventInterceptor::pause(MediaSource &sender, bool pause) {
...
@@ -654,6 +679,7 @@ bool MediaSourceEventInterceptor::pause(MediaSource &sender, bool pause) {
}
}
bool
MediaSourceEventInterceptor
::
speed
(
MediaSource
&
sender
,
float
speed
)
{
bool
MediaSourceEventInterceptor
::
speed
(
MediaSource
&
sender
,
float
speed
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
false
;
return
false
;
...
@@ -662,6 +688,7 @@ bool MediaSourceEventInterceptor::speed(MediaSource &sender, float speed) {
...
@@ -662,6 +688,7 @@ bool MediaSourceEventInterceptor::speed(MediaSource &sender, float speed) {
}
}
bool
MediaSourceEventInterceptor
::
close
(
MediaSource
&
sender
,
bool
force
)
{
bool
MediaSourceEventInterceptor
::
close
(
MediaSource
&
sender
,
bool
force
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
false
;
return
false
;
...
@@ -670,6 +697,7 @@ bool MediaSourceEventInterceptor::close(MediaSource &sender, bool force) {
...
@@ -670,6 +697,7 @@ bool MediaSourceEventInterceptor::close(MediaSource &sender, bool force) {
}
}
int
MediaSourceEventInterceptor
::
totalReaderCount
(
MediaSource
&
sender
)
{
int
MediaSourceEventInterceptor
::
totalReaderCount
(
MediaSource
&
sender
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
sender
.
readerCount
();
return
sender
.
readerCount
();
...
@@ -678,6 +706,7 @@ int MediaSourceEventInterceptor::totalReaderCount(MediaSource &sender) {
...
@@ -678,6 +706,7 @@ int MediaSourceEventInterceptor::totalReaderCount(MediaSource &sender) {
}
}
void
MediaSourceEventInterceptor
::
onReaderChanged
(
MediaSource
&
sender
,
int
size
)
{
void
MediaSourceEventInterceptor
::
onReaderChanged
(
MediaSource
&
sender
,
int
size
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
MediaSourceEvent
::
onReaderChanged
(
sender
,
size
);
MediaSourceEvent
::
onReaderChanged
(
sender
,
size
);
...
@@ -687,6 +716,7 @@ void MediaSourceEventInterceptor::onReaderChanged(MediaSource &sender, int size)
...
@@ -687,6 +716,7 @@ void MediaSourceEventInterceptor::onReaderChanged(MediaSource &sender, int size)
}
}
void
MediaSourceEventInterceptor
::
onRegist
(
MediaSource
&
sender
,
bool
regist
)
{
void
MediaSourceEventInterceptor
::
onRegist
(
MediaSource
&
sender
,
bool
regist
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
listener
)
{
if
(
listener
)
{
listener
->
onRegist
(
sender
,
regist
);
listener
->
onRegist
(
sender
,
regist
);
...
@@ -694,6 +724,7 @@ void MediaSourceEventInterceptor::onRegist(MediaSource &sender, bool regist) {
...
@@ -694,6 +724,7 @@ void MediaSourceEventInterceptor::onRegist(MediaSource &sender, bool regist) {
}
}
bool
MediaSourceEventInterceptor
::
setupRecord
(
MediaSource
&
sender
,
Recorder
::
type
type
,
bool
start
,
const
string
&
custom_path
,
size_t
max_second
)
{
bool
MediaSourceEventInterceptor
::
setupRecord
(
MediaSource
&
sender
,
Recorder
::
type
type
,
bool
start
,
const
string
&
custom_path
,
size_t
max_second
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
false
;
return
false
;
...
@@ -702,6 +733,7 @@ bool MediaSourceEventInterceptor::setupRecord(MediaSource &sender, Recorder::typ
...
@@ -702,6 +733,7 @@ bool MediaSourceEventInterceptor::setupRecord(MediaSource &sender, Recorder::typ
}
}
bool
MediaSourceEventInterceptor
::
isRecording
(
MediaSource
&
sender
,
Recorder
::
type
type
)
{
bool
MediaSourceEventInterceptor
::
isRecording
(
MediaSource
&
sender
,
Recorder
::
type
type
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
false
;
return
false
;
...
@@ -710,6 +742,7 @@ bool MediaSourceEventInterceptor::isRecording(MediaSource &sender, Recorder::typ
...
@@ -710,6 +742,7 @@ bool MediaSourceEventInterceptor::isRecording(MediaSource &sender, Recorder::typ
}
}
vector
<
Track
::
Ptr
>
MediaSourceEventInterceptor
::
getMediaTracks
(
MediaSource
&
sender
,
bool
trackReady
)
const
{
vector
<
Track
::
Ptr
>
MediaSourceEventInterceptor
::
getMediaTracks
(
MediaSource
&
sender
,
bool
trackReady
)
const
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
if
(
!
listener
)
{
return
vector
<
Track
::
Ptr
>
();
return
vector
<
Track
::
Ptr
>
();
...
@@ -718,6 +751,7 @@ vector<Track::Ptr> MediaSourceEventInterceptor::getMediaTracks(MediaSource &send
...
@@ -718,6 +751,7 @@ vector<Track::Ptr> MediaSourceEventInterceptor::getMediaTracks(MediaSource &send
}
}
void
MediaSourceEventInterceptor
::
startSendRtp
(
MediaSource
&
sender
,
const
string
&
dst_url
,
uint16_t
dst_port
,
const
string
&
ssrc
,
bool
is_udp
,
uint16_t
src_port
,
const
function
<
void
(
uint16_t
local_port
,
const
SockException
&
ex
)
>
&
cb
){
void
MediaSourceEventInterceptor
::
startSendRtp
(
MediaSource
&
sender
,
const
string
&
dst_url
,
uint16_t
dst_port
,
const
string
&
ssrc
,
bool
is_udp
,
uint16_t
src_port
,
const
function
<
void
(
uint16_t
local_port
,
const
SockException
&
ex
)
>
&
cb
){
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
listener
)
{
if
(
listener
)
{
listener
->
startSendRtp
(
sender
,
dst_url
,
dst_port
,
ssrc
,
is_udp
,
src_port
,
cb
);
listener
->
startSendRtp
(
sender
,
dst_url
,
dst_port
,
ssrc
,
is_udp
,
src_port
,
cb
);
...
@@ -726,7 +760,8 @@ void MediaSourceEventInterceptor::startSendRtp(MediaSource &sender, const string
...
@@ -726,7 +760,8 @@ void MediaSourceEventInterceptor::startSendRtp(MediaSource &sender, const string
}
}
}
}
bool
MediaSourceEventInterceptor
::
stopSendRtp
(
MediaSource
&
sender
,
const
string
&
ssrc
){
bool
MediaSourceEventInterceptor
::
stopSendRtp
(
MediaSource
&
sender
,
const
string
&
ssrc
)
{
CHECK_CALL_DEPTH
();
auto
listener
=
_listener
.
lock
();
auto
listener
=
_listener
.
lock
();
if
(
listener
)
{
if
(
listener
)
{
return
listener
->
stopSendRtp
(
sender
,
ssrc
);
return
listener
->
stopSendRtp
(
sender
,
ssrc
);
...
...
src/Common/MediaSource.h
查看文件 @
8937d9ea
...
@@ -124,6 +124,7 @@ public:
...
@@ -124,6 +124,7 @@ public:
bool
stopSendRtp
(
MediaSource
&
sender
,
const
string
&
ssrc
)
override
;
bool
stopSendRtp
(
MediaSource
&
sender
,
const
string
&
ssrc
)
override
;
private
:
private
:
int
_invoke_depth
=
0
;
std
::
weak_ptr
<
MediaSourceEvent
>
_listener
;
std
::
weak_ptr
<
MediaSourceEvent
>
_listener
;
};
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论