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
d286ac1d
Commit
d286ac1d
authored
Sep 02, 2023
by
xia-chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NoticeCenter支持安全类型转换,解决监听者参数类型不一致导致的bug
parent
c35b5e92
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
43 行增加
和
46 行删除
+43
-46
3rdpart/ZLToolKit
+1
-1
api/source/mk_common.cpp
+1
-1
api/source/mk_util.cpp
+1
-1
server/WebApi.cpp
+1
-1
src/Common/MediaSource.cpp
+3
-3
src/Common/MultiMediaSourceMuxer.cpp
+1
-1
src/Common/config.cpp
+1
-1
src/Http/HttpFileManager.cpp
+3
-3
src/Http/HttpRequester.cpp
+1
-1
src/Http/HttpSession.cpp
+3
-3
src/Record/HlsMakerImp.cpp
+1
-1
src/Record/HlsMediaSource.cpp
+1
-1
src/Record/MP4Recorder.cpp
+1
-1
src/Rtmp/RtmpSession.cpp
+3
-3
src/Rtp/RtpProcess.cpp
+3
-3
src/Rtp/RtpServer.cpp
+2
-2
src/Rtsp/RtspSession.cpp
+6
-6
src/Shell/ShellSession.cpp
+3
-3
srt/SrtTransportImp.cpp
+3
-6
webrtc/WebRtcPlayer.cpp
+1
-1
webrtc/WebRtcPusher.cpp
+1
-1
webrtc/WebRtcTransport.cpp
+2
-2
没有找到文件。
ZLToolKit
@
d7dd07dd
Subproject commit
a4b8b5e00aac6251254a513c7759605c0ba35f90
Subproject commit
d7dd07ddd968ad8f927da2c655e13956be116cef
api/source/mk_common.cpp
查看文件 @
d286ac1d
...
@@ -159,7 +159,7 @@ API_EXPORT void API_CALL mk_set_option(const char *key, const char *val) {
...
@@ -159,7 +159,7 @@ API_EXPORT void API_CALL mk_set_option(const char *key, const char *val) {
}
}
mINI
::
Instance
()[
key
]
=
val
;
mINI
::
Instance
()[
key
]
=
val
;
//广播配置文件热加载
//广播配置文件热加载
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastReloadConfig
);
N
OTICE_EMIT
(
BroadcastReloadConfigArgs
,
Broadcast
::
kBroadcastReloadConfig
);
}
}
API_EXPORT
const
char
*
API_CALL
mk_get_option
(
const
char
*
key
)
API_EXPORT
const
char
*
API_CALL
mk_get_option
(
const
char
*
key
)
...
...
api/source/mk_util.cpp
查看文件 @
d286ac1d
...
@@ -65,7 +65,7 @@ API_EXPORT mk_ini API_CALL mk_ini_default() {
...
@@ -65,7 +65,7 @@ API_EXPORT mk_ini API_CALL mk_ini_default() {
static
void
emit_ini_file_reload
(
mk_ini
ini
)
{
static
void
emit_ini_file_reload
(
mk_ini
ini
)
{
if
(
ini
==
mk_ini_default
())
{
if
(
ini
==
mk_ini_default
())
{
// 广播配置文件热加载
// 广播配置文件热加载
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastReloadConfig
);
N
OTICE_EMIT
(
BroadcastReloadConfigArgs
,
Broadcast
::
kBroadcastReloadConfig
);
}
}
}
}
...
...
server/WebApi.cpp
查看文件 @
d286ac1d
...
@@ -666,7 +666,7 @@ void installWebApi() {
...
@@ -666,7 +666,7 @@ void installWebApi() {
++
changed
;
++
changed
;
}
}
if
(
changed
>
0
)
{
if
(
changed
>
0
)
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastReloadConfig
);
N
OTICE_EMIT
(
BroadcastReloadConfigArgs
,
Broadcast
::
kBroadcastReloadConfig
);
ini
.
dumpFile
(
g_ini_file
);
ini
.
dumpFile
(
g_ini_file
);
}
}
val
[
"changed"
]
=
changed
;
val
[
"changed"
]
=
changed
;
...
...
src/Common/MediaSource.cpp
查看文件 @
d286ac1d
...
@@ -469,7 +469,7 @@ static void findAsync_l(const MediaInfo &info, const std::shared_ptr<Session> &s
...
@@ -469,7 +469,7 @@ static void findAsync_l(const MediaInfo &info, const std::shared_ptr<Session> &s
});
});
};
};
//广播未找到流,此时可以立即去拉流,这样还来得及
//广播未找到流,此时可以立即去拉流,这样还来得及
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastNotFoundStream
,
info
,
static_cast
<
SockInfo
&>
(
*
session
)
,
close_player
);
N
OTICE_EMIT
(
BroadcastNotFoundStreamArgs
,
Broadcast
::
kBroadcastNotFoundStream
,
info
,
*
session
,
close_player
);
}
}
void
MediaSource
::
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
Session
>
&
session
,
const
function
<
void
(
const
Ptr
&
)
>
&
cb
)
{
void
MediaSource
::
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
Session
>
&
session
,
const
function
<
void
(
const
Ptr
&
)
>
&
cb
)
{
...
@@ -499,7 +499,7 @@ void MediaSource::emitEvent(bool regist){
...
@@ -499,7 +499,7 @@ void MediaSource::emitEvent(bool regist){
listener
->
onRegist
(
*
this
,
regist
);
listener
->
onRegist
(
*
this
,
regist
);
}
}
//触发广播
//触发广播
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaChanged
,
regist
,
*
this
);
N
OTICE_EMIT
(
BroadcastMediaChangedArgs
,
Broadcast
::
kBroadcastMediaChanged
,
regist
,
*
this
);
InfoL
<<
(
regist
?
"媒体注册:"
:
"媒体注销:"
)
<<
getUrl
();
InfoL
<<
(
regist
?
"媒体注册:"
:
"媒体注销:"
)
<<
getUrl
();
}
}
...
@@ -669,7 +669,7 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
...
@@ -669,7 +669,7 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
strong_sender
->
close
(
false
);
strong_sender
->
close
(
false
);
}
else
{
}
else
{
// 直播时触发无人观看事件,让开发者自行选择是否关闭
// 直播时触发无人观看事件,让开发者自行选择是否关闭
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastStreamNoneReader
,
*
strong_sender
);
N
OTICE_EMIT
(
BroadcastStreamNoneReaderArgs
,
Broadcast
::
kBroadcastStreamNoneReader
,
*
strong_sender
);
}
}
}
else
{
}
else
{
//这个是mp4点播,我们自动关闭
//这个是mp4点播,我们自动关闭
...
...
src/Common/MultiMediaSourceMuxer.cpp
查看文件 @
d286ac1d
...
@@ -312,7 +312,7 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE
...
@@ -312,7 +312,7 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE
strong_self
->
getOwnerPoller
(
MediaSource
::
NullMediaSource
())
->
async
([
=
]()
{
strong_self
->
getOwnerPoller
(
MediaSource
::
NullMediaSource
())
->
async
([
=
]()
{
WarnL
<<
"stream:"
<<
strong_self
->
shortUrl
()
<<
" stop send rtp:"
<<
ssrc
<<
", reason:"
<<
ex
;
WarnL
<<
"stream:"
<<
strong_self
->
shortUrl
()
<<
" stop send rtp:"
<<
ssrc
<<
", reason:"
<<
ex
;
strong_self
->
_rtp_sender
.
erase
(
ssrc
);
strong_self
->
_rtp_sender
.
erase
(
ssrc
);
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastSendRtpStopped
,
*
strong_self
,
ssrc
,
ex
);
N
OTICE_EMIT
(
BroadcastSendRtpStoppedArgs
,
Broadcast
::
kBroadcastSendRtpStopped
,
*
strong_self
,
ssrc
,
ex
);
});
});
}
}
});
});
...
...
src/Common/config.cpp
查看文件 @
d286ac1d
...
@@ -31,7 +31,7 @@ bool loadIniConfig(const char *ini_path) {
...
@@ -31,7 +31,7 @@ bool loadIniConfig(const char *ini_path) {
}
}
try
{
try
{
mINI
::
Instance
().
parseFile
(
ini
);
mINI
::
Instance
().
parseFile
(
ini
);
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastReloadConfig
);
N
OTICE_EMIT
(
BroadcastReloadConfigArgs
,
Broadcast
::
kBroadcastReloadConfig
);
return
true
;
return
true
;
}
catch
(
std
::
exception
&
)
{
}
catch
(
std
::
exception
&
)
{
InfoL
<<
"dump ini file to:"
<<
ini
;
InfoL
<<
"dump ini file to:"
<<
ini
;
...
...
src/Http/HttpFileManager.cpp
查看文件 @
d286ac1d
...
@@ -250,7 +250,7 @@ static bool emitHlsPlayed(const Parser &parser, const MediaInfo &media_info, con
...
@@ -250,7 +250,7 @@ static bool emitHlsPlayed(const Parser &parser, const MediaInfo &media_info, con
//cookie有效期为kHlsCookieSecond
//cookie有效期为kHlsCookieSecond
invoker
(
err
,
""
,
kHlsCookieSecond
);
invoker
(
err
,
""
,
kHlsCookieSecond
);
};
};
bool
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
media_info
,
auth_invoker
,
static_cast
<
SockInfo
&>
(
sender
)
);
bool
flag
=
N
OTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
media_info
,
auth_invoker
,
sender
);
if
(
!
flag
)
{
if
(
!
flag
)
{
//未开启鉴权,那么允许播放
//未开启鉴权,那么允许播放
auth_invoker
(
""
);
auth_invoker
(
""
);
...
@@ -383,7 +383,7 @@ static void canAccessPath(Session &sender, const Parser &parser, const MediaInfo
...
@@ -383,7 +383,7 @@ static void canAccessPath(Session &sender, const Parser &parser, const MediaInfo
}
}
// 事件未被拦截,则认为是http下载请求
// 事件未被拦截,则认为是http下载请求
bool
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastHttpAccess
,
parser
,
path
,
is_dir
,
accessPathInvoker
,
static_cast
<
SockInfo
&>
(
sender
)
);
bool
flag
=
N
OTICE_EMIT
(
BroadcastHttpAccessArgs
,
Broadcast
::
kBroadcastHttpAccess
,
parser
,
path
,
is_dir
,
accessPathInvoker
,
sender
);
if
(
!
flag
)
{
if
(
!
flag
)
{
// 此事件无人监听,我们默认都有权限访问
// 此事件无人监听,我们默认都有权限访问
callback
(
""
,
nullptr
);
callback
(
""
,
nullptr
);
...
@@ -556,7 +556,7 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, Sess
...
@@ -556,7 +556,7 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, Sess
}
}
// 替换url,防止返回的目录索引网页被注入非法内容
// 替换url,防止返回的目录索引网页被注入非法内容
const_cast
<
Parser
&>
(
parser
).
setUrl
(
"/"
+
ret
.
substr
(
http_root
.
size
()));
const_cast
<
Parser
&>
(
parser
).
setUrl
(
"/"
+
ret
.
substr
(
http_root
.
size
()));
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastHttpBeforeAccess
,
parser
,
ret
,
static_cast
<
SockInfo
&>
(
sender
)
);
N
OTICE_EMIT
(
BroadcastHttpBeforeAccessArgs
,
Broadcast
::
kBroadcastHttpBeforeAccess
,
parser
,
ret
,
sender
);
return
ret
;
return
ret
;
}
}
...
...
src/Http/HttpRequester.cpp
查看文件 @
d286ac1d
...
@@ -271,7 +271,7 @@ static void sendReport() {
...
@@ -271,7 +271,7 @@ static void sendReport() {
}
}
static
toolkit
::
onceToken
s_token
([]()
{
static
toolkit
::
onceToken
s_token
([]()
{
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
"kBroadcastEventPollerPoolStarted"
,
[](
EventPollerPool
&
pool
,
size_t
&
size
)
{
NoticeCenter
::
Instance
().
addListener
(
nullptr
,
"kBroadcastEventPollerPoolStarted"
,
[](
EventPollerPool
OnStartedArgs
)
{
// 第一次汇报在程序启动后5分钟
// 第一次汇报在程序启动后5分钟
pool
.
getPoller
()
->
doDelayTask
(
5
*
60
*
1000
,
[]()
{
pool
.
getPoller
()
->
doDelayTask
(
5
*
60
*
1000
,
[]()
{
sendReport
();
sendReport
();
...
...
src/Http/HttpSession.cpp
查看文件 @
d286ac1d
...
@@ -170,7 +170,7 @@ void HttpSession::onError(const SockException &err) {
...
@@ -170,7 +170,7 @@ void HttpSession::onError(const SockException &err) {
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_total_bytes_usage
>=
iFlowThreshold
*
1024
)
{
if
(
_total_bytes_usage
>=
iFlowThreshold
*
1024
)
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_mediaInfo
,
_total_bytes_usage
,
duration
,
true
,
static_cast
<
SockInfo
&>
(
*
this
)
);
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_mediaInfo
,
_total_bytes_usage
,
duration
,
true
,
*
this
);
}
}
return
;
return
;
}
}
...
@@ -311,7 +311,7 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
...
@@ -311,7 +311,7 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix
}
}
};
};
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
_mediaInfo
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
_mediaInfo
,
invoker
,
*
this
);
if
(
!
flag
)
{
if
(
!
flag
)
{
// 该事件无人监听,默认不鉴权
// 该事件无人监听,默认不鉴权
onRes
(
""
);
onRes
(
""
);
...
@@ -711,7 +711,7 @@ bool HttpSession::emitHttpEvent(bool doInvoke) {
...
@@ -711,7 +711,7 @@ bool HttpSession::emitHttpEvent(bool doInvoke) {
};
};
///////////////////广播HTTP事件///////////////////////////
///////////////////广播HTTP事件///////////////////////////
bool
consumed
=
false
;
// 该事件是否被消费
bool
consumed
=
false
;
// 该事件是否被消费
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastHttpRequest
,
_parser
,
invoker
,
consumed
,
static_cast
<
SockInfo
&>
(
*
this
)
);
N
OTICE_EMIT
(
BroadcastHttpRequestArgs
,
Broadcast
::
kBroadcastHttpRequest
,
_parser
,
invoker
,
consumed
,
*
this
);
if
(
!
consumed
&&
doInvoke
)
{
if
(
!
consumed
&&
doInvoke
)
{
// 该事件无人消费,所以返回404
// 该事件无人消费,所以返回404
invoker
(
404
,
KeyValue
(),
HttpBody
::
Ptr
());
invoker
(
404
,
KeyValue
(),
HttpBody
::
Ptr
());
...
...
src/Record/HlsMakerImp.cpp
查看文件 @
d286ac1d
...
@@ -149,7 +149,7 @@ void HlsMakerImp::onFlushLastSegment(uint64_t duration_ms) {
...
@@ -149,7 +149,7 @@ void HlsMakerImp::onFlushLastSegment(uint64_t duration_ms) {
if
(
broadcastRecordTs
)
{
if
(
broadcastRecordTs
)
{
_info
.
time_len
=
duration_ms
/
1000.0
f
;
_info
.
time_len
=
duration_ms
/
1000.0
f
;
_info
.
file_size
=
File
::
fileSize
(
_info
.
file_path
.
data
());
_info
.
file_size
=
File
::
fileSize
(
_info
.
file_path
.
data
());
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastRecordTs
,
_info
);
N
OTICE_EMIT
(
BroadcastRecordTsArgs
,
Broadcast
::
kBroadcastRecordTs
,
_info
);
}
}
}
}
...
...
src/Record/HlsMediaSource.cpp
查看文件 @
d286ac1d
...
@@ -47,7 +47,7 @@ HlsCookieData::~HlsCookieData() {
...
@@ -47,7 +47,7 @@ HlsCookieData::~HlsCookieData() {
uint64_t
bytes
=
_bytes
.
load
();
uint64_t
bytes
=
_bytes
.
load
();
if
(
bytes
>=
iFlowThreshold
*
1024
)
{
if
(
bytes
>=
iFlowThreshold
*
1024
)
{
try
{
try
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_info
,
bytes
,
duration
,
true
,
static_cast
<
SockInfo
&>
(
*
_sock_info
)
);
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_info
,
bytes
,
duration
,
true
,
*
_sock_info
);
}
catch
(
std
::
exception
&
ex
)
{
}
catch
(
std
::
exception
&
ex
)
{
WarnL
<<
"Exception occurred: "
<<
ex
.
what
();
WarnL
<<
"Exception occurred: "
<<
ex
.
what
();
}
}
...
...
src/Record/MP4Recorder.cpp
查看文件 @
d286ac1d
...
@@ -92,7 +92,7 @@ void MP4Recorder::asyncClose() {
...
@@ -92,7 +92,7 @@ void MP4Recorder::asyncClose() {
}
}
TraceL
<<
"Emit mp4 record event: "
<<
full_path
;
TraceL
<<
"Emit mp4 record event: "
<<
full_path
;
//触发mp4录制切片生成事件
//触发mp4录制切片生成事件
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastRecordMP4
,
info
);
N
OTICE_EMIT
(
BroadcastRecordMP4Args
,
Broadcast
::
kBroadcastRecordMP4
,
info
);
});
});
}
}
...
...
src/Rtmp/RtmpSession.cpp
查看文件 @
d286ac1d
...
@@ -36,7 +36,7 @@ void RtmpSession::onError(const SockException& err) {
...
@@ -36,7 +36,7 @@ void RtmpSession::onError(const SockException& err) {
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_total_bytes
>=
iFlowThreshold
*
1024
)
{
if
(
_total_bytes
>=
iFlowThreshold
*
1024
)
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_total_bytes
,
duration
,
is_player
,
static_cast
<
SockInfo
&>
(
*
this
)
);
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_total_bytes
,
duration
,
is_player
,
*
this
);
}
}
//如果是主动关闭的,那么不延迟注销
//如果是主动关闭的,那么不延迟注销
...
@@ -215,7 +215,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
...
@@ -215,7 +215,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
on_res
(
err
,
option
);
on_res
(
err
,
option
);
});
});
};
};
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtmp_push
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastMediaPublishArgs
,
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtmp_push
,
_media_info
,
invoker
,
*
this
);
if
(
!
flag
){
if
(
!
flag
){
//该事件无人监听,默认鉴权成功
//该事件无人监听,默认鉴权成功
on_res
(
""
,
ProtocolOption
());
on_res
(
""
,
ProtocolOption
());
...
@@ -381,7 +381,7 @@ void RtmpSession::doPlay(AMFDecoder &dec){
...
@@ -381,7 +381,7 @@ void RtmpSession::doPlay(AMFDecoder &dec){
});
});
};
};
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
_media_info
,
invoker
,
*
this
);
if
(
!
flag
)
{
if
(
!
flag
)
{
// 该事件无人监听,默认不鉴权
// 该事件无人监听,默认不鉴权
doPlayResponse
(
""
,
[
token
](
bool
)
{});
doPlayResponse
(
""
,
[
token
](
bool
)
{});
...
...
src/Rtp/RtpProcess.cpp
查看文件 @
d286ac1d
...
@@ -67,7 +67,7 @@ RtpProcess::~RtpProcess() {
...
@@ -67,7 +67,7 @@ RtpProcess::~RtpProcess() {
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_total_bytes
>=
iFlowThreshold
*
1024
)
{
if
(
_total_bytes
>=
iFlowThreshold
*
1024
)
{
try
{
try
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_total_bytes
,
duration
,
false
,
static_cast
<
SockInfo
&>
(
*
this
)
);
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_total_bytes
,
duration
,
false
,
*
this
);
}
catch
(
std
::
exception
&
ex
)
{
}
catch
(
std
::
exception
&
ex
)
{
WarnL
<<
"Exception occurred: "
<<
ex
.
what
();
WarnL
<<
"Exception occurred: "
<<
ex
.
what
();
}
}
...
@@ -266,9 +266,9 @@ void RtpProcess::emitOnPublish() {
...
@@ -266,9 +266,9 @@ void RtpProcess::emitOnPublish() {
};
};
//触发推流鉴权事件
//触发推流鉴权事件
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtp_push
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastMediaPublishArgs
,
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtp_push
,
_media_info
,
invoker
,
*
this
);
if
(
!
flag
)
{
if
(
!
flag
)
{
//该事件无人监听,默认不鉴权
//
该事件无人监听,默认不鉴权
invoker
(
""
,
ProtocolOption
());
invoker
(
""
,
ProtocolOption
());
}
}
}
}
...
...
src/Rtp/RtpServer.cpp
查看文件 @
d286ac1d
...
@@ -102,8 +102,8 @@ public:
...
@@ -102,8 +102,8 @@ public:
process
->
setOnDetach
(
std
::
move
(
strong_self
->
_on_detach
));
process
->
setOnDetach
(
std
::
move
(
strong_self
->
_on_detach
));
}
}
if
(
!
process
)
{
// process 未创建,触发rtp server 超时事件
if
(
!
process
)
{
// process 未创建,触发rtp server 超时事件
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
KBroadcastRtpServerTimeout
,
strong_self
->
_local_port
,
strong_self
->
_stream_id
,
N
OTICE_EMIT
(
BroadcastRtpServerTimeoutArgs
,
Broadcast
::
KBroadcastRtpServerTimeout
,
strong_self
->
_local_port
,
strong_self
->
_stream_id
,
(
int
)
strong_self
->
_tcp_mode
,
strong_self
->
_re_use_port
,
strong_self
->
_ssrc
);
(
int
)
strong_self
->
_tcp_mode
,
strong_self
->
_re_use_port
,
strong_self
->
_ssrc
);
}
}
}
}
return
0
;
return
0
;
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
d286ac1d
...
@@ -80,7 +80,7 @@ void RtspSession::onError(const SockException &err) {
...
@@ -80,7 +80,7 @@ void RtspSession::onError(const SockException &err) {
//流量统计事件广播
//流量统计事件广播
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_bytes_usage
>=
iFlowThreshold
*
1024
)
{
if
(
_bytes_usage
>=
iFlowThreshold
*
1024
)
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_bytes_usage
,
duration
,
is_player
,
static_cast
<
SockInfo
&>
(
*
this
)
);
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_bytes_usage
,
duration
,
is_player
,
*
this
);
}
}
//如果是主动关闭的,那么不延迟注销
//如果是主动关闭的,那么不延迟注销
...
@@ -294,7 +294,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
...
@@ -294,7 +294,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
};
};
//rtsp推流需要鉴权
//rtsp推流需要鉴权
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtsp_push
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastMediaPublishArgs
,
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtsp_push
,
_media_info
,
invoker
,
*
this
);
if
(
!
flag
)
{
if
(
!
flag
)
{
//该事件无人监听,默认不鉴权
//该事件无人监听,默认不鉴权
onRes
(
""
,
ProtocolOption
());
onRes
(
""
,
ProtocolOption
());
...
@@ -352,7 +352,7 @@ void RtspSession::emitOnPlay(){
...
@@ -352,7 +352,7 @@ void RtspSession::emitOnPlay(){
};
};
//广播通用播放url鉴权事件
//广播通用播放url鉴权事件
auto
flag
=
_emit_on_play
?
false
:
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
);
auto
flag
=
_emit_on_play
?
false
:
N
OTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
_media_info
,
invoker
,
*
this
);
if
(
!
flag
)
{
if
(
!
flag
)
{
//该事件无人监听,默认不鉴权
//该事件无人监听,默认不鉴权
onRes
(
""
);
onRes
(
""
);
...
@@ -392,7 +392,7 @@ void RtspSession::handleReq_Describe(const Parser &parser) {
...
@@ -392,7 +392,7 @@ void RtspSession::handleReq_Describe(const Parser &parser) {
if
(
_rtsp_realm
.
empty
()){
if
(
_rtsp_realm
.
empty
()){
//广播是否需要rtsp专属认证事件
//广播是否需要rtsp专属认证事件
if
(
!
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnGetRtspRealm
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
))
{
if
(
!
N
OTICE_EMIT
(
BroadcastOnGetRtspRealmArgs
,
Broadcast
::
kBroadcastOnGetRtspRealm
,
_media_info
,
invoker
,
*
this
))
{
//无人监听此事件,说明无需认证
//无人监听此事件,说明无需认证
invoker
(
""
);
invoker
(
""
);
}
}
...
@@ -497,7 +497,7 @@ void RtspSession::onAuthBasic(const string &realm, const string &auth_base64) {
...
@@ -497,7 +497,7 @@ void RtspSession::onAuthBasic(const string &realm, const string &auth_base64) {
};
};
//此时必须提供明文密码
//此时必须提供明文密码
if
(
!
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnRtspAuth
,
_media_info
,
realm
,
user
,
true
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
))
{
if
(
!
N
OTICE_EMIT
(
BroadcastOnRtspAuthArgs
,
Broadcast
::
kBroadcastOnRtspAuth
,
_media_info
,
realm
,
user
,
true
,
invoker
,
*
this
))
{
//表明该流需要认证却没监听请求密码事件,这一般是大意的程序所为,警告之
//表明该流需要认证却没监听请求密码事件,这一般是大意的程序所为,警告之
WarnP
(
this
)
<<
"请监听kBroadcastOnRtspAuth事件!"
;
WarnP
(
this
)
<<
"请监听kBroadcastOnRtspAuth事件!"
;
//但是我们还是忽略认证以便完成播放
//但是我们还是忽略认证以便完成播放
...
@@ -581,7 +581,7 @@ void RtspSession::onAuthDigest(const string &realm,const string &auth_md5){
...
@@ -581,7 +581,7 @@ void RtspSession::onAuthDigest(const string &realm,const string &auth_md5){
};
};
//此时可以提供明文或md5加密的密码
//此时可以提供明文或md5加密的密码
if
(
!
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnRtspAuth
,
_media_info
,
realm
,
username
,
false
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
)){
if
(
!
N
OTICE_EMIT
(
BroadcastOnRtspAuthArgs
,
Broadcast
::
kBroadcastOnRtspAuth
,
_media_info
,
realm
,
username
,
false
,
invoker
,
*
this
)){
//表明该流需要认证却没监听请求密码事件,这一般是大意的程序所为,警告之
//表明该流需要认证却没监听请求密码事件,这一般是大意的程序所为,警告之
WarnP
(
this
)
<<
"请监听kBroadcastOnRtspAuth事件!"
;
WarnP
(
this
)
<<
"请监听kBroadcastOnRtspAuth事件!"
;
//但是我们还是忽略认证以便完成播放
//但是我们还是忽略认证以便完成播放
...
...
src/Shell/ShellSession.cpp
查看文件 @
d286ac1d
...
@@ -135,9 +135,9 @@ inline void ShellSession::pleaseInputPasswd() {
...
@@ -135,9 +135,9 @@ inline void ShellSession::pleaseInputPasswd() {
});
});
};
};
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastShellLogin
,
_strUserName
,
passwd
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastShellLoginArgs
,
Broadcast
::
kBroadcastShellLogin
,
_strUserName
,
passwd
,
invoker
,
*
this
);
if
(
!
flag
)
{
if
(
!
flag
)
{
//如果无人监听shell登录事件,那么默认shell无法登录
//
如果无人监听shell登录事件,那么默认shell无法登录
onAuth
(
"please listen kBroadcastShellLogin event"
);
onAuth
(
"please listen kBroadcastShellLogin event"
);
}
}
return
true
;
return
true
;
...
...
srt/SrtTransportImp.cpp
查看文件 @
d286ac1d
...
@@ -17,7 +17,7 @@ SrtTransportImp::~SrtTransportImp() {
...
@@ -17,7 +17,7 @@ SrtTransportImp::~SrtTransportImp() {
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_total_bytes
>=
iFlowThreshold
*
1024
)
{
if
(
_total_bytes
>=
iFlowThreshold
*
1024
)
{
try
{
try
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_total_bytes
,
duration
,
!
_is_pusher
,
static_cast
<
SockInfo
&>
(
*
this
)
);
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_total_bytes
,
duration
,
!
_is_pusher
,
*
this
);
}
catch
(
std
::
exception
&
ex
)
{
}
catch
(
std
::
exception
&
ex
)
{
WarnL
<<
"Exception occurred: "
<<
ex
.
what
();
WarnL
<<
"Exception occurred: "
<<
ex
.
what
();
}
}
...
@@ -172,9 +172,7 @@ void SrtTransportImp::emitOnPublish() {
...
@@ -172,9 +172,7 @@ void SrtTransportImp::emitOnPublish() {
};
};
// 触发推流鉴权事件
// 触发推流鉴权事件
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
auto
flag
=
NOTICE_EMIT
(
BroadcastMediaPublishArgs
,
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
srt_push
,
_media_info
,
invoker
,
*
this
);
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
srt_push
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
));
if
(
!
flag
)
{
if
(
!
flag
)
{
// 该事件无人监听,默认不鉴权
// 该事件无人监听,默认不鉴权
invoker
(
""
,
ProtocolOption
());
invoker
(
""
,
ProtocolOption
());
...
@@ -197,8 +195,7 @@ void SrtTransportImp::emitOnPlay() {
...
@@ -197,8 +195,7 @@ void SrtTransportImp::emitOnPlay() {
});
});
};
};
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
auto
flag
=
NOTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
_media_info
,
invoker
,
*
this
);
Broadcast
::
kBroadcastMediaPlayed
,
_media_info
,
invoker
,
static_cast
<
SockInfo
&>
(
*
this
));
if
(
!
flag
)
{
if
(
!
flag
)
{
doPlay
();
doPlay
();
}
}
...
...
webrtc/WebRtcPlayer.cpp
查看文件 @
d286ac1d
...
@@ -77,7 +77,7 @@ void WebRtcPlayer::onDestory() {
...
@@ -77,7 +77,7 @@ void WebRtcPlayer::onDestory() {
if
(
_reader
&&
getSession
())
{
if
(
_reader
&&
getSession
())
{
WarnL
<<
"RTC播放器("
<<
_media_info
.
shortUrl
()
<<
")结束播放,耗时(s):"
<<
duration
;
WarnL
<<
"RTC播放器("
<<
_media_info
.
shortUrl
()
<<
")结束播放,耗时(s):"
<<
duration
;
if
(
bytes_usage
>=
iFlowThreshold
*
1024
)
{
if
(
bytes_usage
>=
iFlowThreshold
*
1024
)
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
bytes_usage
,
duration
,
true
,
static_cast
<
SockInfo
&>
(
*
getSession
()
));
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
bytes_usage
,
duration
,
true
,
*
getSession
(
));
}
}
}
}
WebRtcTransportImp
::
onDestory
();
WebRtcTransportImp
::
onDestory
();
...
...
webrtc/WebRtcPusher.cpp
查看文件 @
d286ac1d
...
@@ -129,7 +129,7 @@ void WebRtcPusher::onDestory() {
...
@@ -129,7 +129,7 @@ void WebRtcPusher::onDestory() {
if
(
getSession
())
{
if
(
getSession
())
{
WarnL
<<
"RTC推流器("
<<
_media_info
.
shortUrl
()
<<
")结束推流,耗时(s):"
<<
duration
;
WarnL
<<
"RTC推流器("
<<
_media_info
.
shortUrl
()
<<
")结束推流,耗时(s):"
<<
duration
;
if
(
bytes_usage
>=
iFlowThreshold
*
1024
)
{
if
(
bytes_usage
>=
iFlowThreshold
*
1024
)
{
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
bytes_usage
,
duration
,
false
,
static_cast
<
SockInfo
&>
(
*
getSession
()
));
N
OTICE_EMIT
(
BroadcastFlowReportArgs
,
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
bytes_usage
,
duration
,
false
,
*
getSession
(
));
}
}
}
}
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
d286ac1d
...
@@ -1218,7 +1218,7 @@ void push_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginMana
...
@@ -1218,7 +1218,7 @@ void push_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginMana
};
};
// rtsp推流需要鉴权
// rtsp推流需要鉴权
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtc_push
,
info
,
invoker
,
static_cast
<
SockInfo
&>
(
sender
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastMediaPublishArgs
,
Broadcast
::
kBroadcastMediaPublish
,
MediaOriginType
::
rtc_push
,
info
,
invoker
,
sender
);
if
(
!
flag
)
{
if
(
!
flag
)
{
// 该事件无人监听,默认不鉴权
// 该事件无人监听,默认不鉴权
invoker
(
""
,
ProtocolOption
());
invoker
(
""
,
ProtocolOption
());
...
@@ -1252,7 +1252,7 @@ void play_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginMana
...
@@ -1252,7 +1252,7 @@ void play_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginMana
};
};
// 广播通用播放url鉴权事件
// 广播通用播放url鉴权事件
auto
flag
=
N
oticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
info
,
invoker
,
static_cast
<
SockInfo
&>
(
sender
)
);
auto
flag
=
N
OTICE_EMIT
(
BroadcastMediaPlayedArgs
,
Broadcast
::
kBroadcastMediaPlayed
,
info
,
invoker
,
sender
);
if
(
!
flag
)
{
if
(
!
flag
)
{
// 该事件无人监听,默认不鉴权
// 该事件无人监听,默认不鉴权
invoker
(
""
);
invoker
(
""
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论