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
b0a64d1e
Commit
b0a64d1e
authored
Feb 09, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
广播添加sender参数
parent
4cf09bda
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
35 行增加
和
24 行删除
+35
-24
src/Common/MediaSource.cpp
+4
-2
src/Common/config.h
+9
-9
src/Http/HttpSession.cpp
+3
-3
src/MediaFile/Mp4Maker.cpp
+1
-1
src/Rtmp/RtmpSession.cpp
+4
-3
src/Rtsp/RtspSession.cpp
+13
-5
src/Shell/ShellSession.cpp
+1
-1
没有找到文件。
src/Common/MediaSource.cpp
查看文件 @
b0a64d1e
...
...
@@ -85,7 +85,8 @@ bool MediaSource::regist() {
m_strSchema
,
m_strVhost
,
m_strApp
,
m_strId
);
m_strId
,
*
this
);
}
return
success
;
}
...
...
@@ -114,7 +115,8 @@ void MediaSource::unregisted(){
m_strSchema
,
m_strVhost
,
m_strApp
,
m_strId
);
m_strId
,
*
this
);
}
void
MediaInfo
::
parse
(
const
string
&
url
){
...
...
src/Common/config.h
查看文件 @
b0a64d1e
...
...
@@ -73,24 +73,24 @@ namespace Broadcast {
//注册或反注册MediaSource事件广播
extern
const
char
kBroadcastMediaChanged
[];
#define BroadcastMediaChangedArgs const bool &bRegist, const string &schema,const string &vhost,const string &app,const string &stream
#define BroadcastMediaChangedArgs const bool &bRegist, const string &schema,const string &vhost,const string &app,const string &stream
,MediaSource &sender
//录制mp4文件成功后广播
extern
const
char
kBroadcastRecordMP4
[];
#define BroadcastRecordMP4Args const Mp4Info &info
#define BroadcastRecordMP4Args const Mp4Info &info
,Mp4Maker &sender
//收到http api请求广播
extern
const
char
kBroadcastHttpRequest
[];
#define BroadcastHttpRequestArgs const Parser &parser,const HttpSession::HttpResponseInvoker &invoker,bool &consumed
#define BroadcastHttpRequestArgs const Parser &parser,const HttpSession::HttpResponseInvoker &invoker,bool &consumed
,TcpSession &sender
//该流是否需要认证?是的话调用invoker并传入realm,否则传入空的realm.如果该事件不监听则不认证
extern
const
char
kBroadcastOnGetRtspRealm
[];
#define BroadcastOnGetRtspRealmArgs const string &app,const string &stream,const RtspSession::onGetRealm &invoker
#define BroadcastOnGetRtspRealmArgs const string &app,const string &stream,const RtspSession::onGetRealm &invoker
,TcpSession &sender
//请求认证用户密码事件,user_name为用户名,must_no_encrypt如果为true,则必须提供明文密码(因为此时是base64认证方式),否则会导致认证失败
//获取到密码后请调用invoker并输入对应类型的密码和密码类型,invoker执行时会匹配密码
extern
const
char
kBroadcastOnRtspAuth
[];
#define BroadcastOnRtspAuthArgs const string &user_name,const bool &must_no_encrypt,const RtspSession::onAuth &invoker
#define BroadcastOnRtspAuthArgs const string &user_name,const bool &must_no_encrypt,const RtspSession::onAuth &invoker
,TcpSession &sender
//鉴权结果回调对象
//如果errMessage为空则代表鉴权成功
...
...
@@ -98,19 +98,19 @@ typedef std::function<void(const string &errMessage)> AuthInvoker;
//收到rtmp推流事件广播,通过该事件控制推流鉴权
extern
const
char
kBroadcastRtmpPublish
[];
#define BroadcastRtmpPublishArgs const MediaInfo &args,const Broadcast::AuthInvoker &invoker
#define BroadcastRtmpPublishArgs const MediaInfo &args,const Broadcast::AuthInvoker &invoker
,TcpSession &sender
//播放rtsp/rtmp/http-flv事件广播,通过该事件控制播放鉴权
extern
const
char
kBroadcastMediaPlayed
[];
#define BroadcastMediaPlayedArgs const MediaInfo &args,const Broadcast::AuthInvoker &invoker
#define BroadcastMediaPlayedArgs const MediaInfo &args,const Broadcast::AuthInvoker &invoker
,TcpSession &sender
//shell登录鉴权
extern
const
char
kBroadcastShellLogin
[];
#define BroadcastShellLoginArgs const string &user_name,const string &passwd,const Broadcast::AuthInvoker &invoker
#define BroadcastShellLoginArgs const string &user_name,const string &passwd,const Broadcast::AuthInvoker &invoker
,TcpSession &sender
//停止rtsp/rtmp/http-flv会话后流量汇报事件广播
extern
const
char
kBroadcastFlowReport
[];
#define BroadcastFlowReportArgs const MediaInfo &args,const uint64_t &totalBytes
#define BroadcastFlowReportArgs const MediaInfo &args,const uint64_t &totalBytes
,TcpSession &sender
//流量汇报事件流量阈值,单位KB,默认1MB
extern
const
char
kFlowThreshold
[];
...
...
src/Http/HttpSession.cpp
查看文件 @
b0a64d1e
...
...
@@ -169,7 +169,7 @@ void HttpSession::onError(const SockException& err) {
if
(
m_previousTagSize
>
iFlowThreshold
*
1024
){
uint64_t
totalBytes
=
m_previousTagSize
;
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
totalBytes
);
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
totalBytes
,
*
this
);
}
}
...
...
@@ -300,7 +300,7 @@ inline bool HttpSession::checkLiveFlvStream(){
onRes
(
err
);
});
};
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
m_mediaInfo
,
invoker
);
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
m_mediaInfo
,
invoker
,
*
this
);
if
(
!
flag
){
//该事件无人监听,默认不鉴权
onRes
(
""
);
...
...
@@ -616,7 +616,7 @@ inline bool HttpSession::emitHttpEvent(bool doInvoke){
};
///////////////////广播HTTP事件///////////////////////////
bool
consumed
=
false
;
//该事件是否被消费
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastHttpRequest
,
m_parser
,
invoker
,
consumed
);
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastHttpRequest
,
m_parser
,
invoker
,
consumed
,
*
this
);
if
(
!
consumed
&&
doInvoke
){
//该事件无人消费,所以返回404
invoker
(
"404 Not Found"
,
KeyValue
(),
""
);
...
...
src/MediaFile/Mp4Maker.cpp
查看文件 @
b0a64d1e
...
...
@@ -223,7 +223,7 @@ void Mp4Maker::closeFile() {
stat
(
m_strFile
.
data
(),
&
fileData
);
m_info
.
ui64FileSize
=
fileData
.
st_size
;
//----record 业务逻辑----//
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastRecordMP4
,
m_info
);
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastRecordMP4
,
m_info
,
*
this
);
}
}
...
...
src/Rtmp/RtmpSession.cpp
查看文件 @
b0a64d1e
...
...
@@ -57,7 +57,7 @@ void RtmpSession::onError(const SockException& err) {
GET_CONFIG_AND_REGISTER
(
uint32_t
,
iFlowThreshold
,
Broadcast
::
kFlowThreshold
);
if
(
m_ui64TotalBytes
>
iFlowThreshold
*
1024
){
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
m_ui64TotalBytes
);
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
m_ui64TotalBytes
,
*
this
);
}
}
...
...
@@ -179,7 +179,8 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
};
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Config
::
Broadcast
::
kBroadcastRtmpPublish
,
m_mediaInfo
,
invoker
);
invoker
,
*
this
);
if
(
!
flag
){
//该事件无人监听,默认鉴权成功
onRes
(
""
);
...
...
@@ -313,7 +314,7 @@ void RtmpSession::doPlay(AMFDecoder &dec){
onRes
(
err
);
});
};
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
m_mediaInfo
,
invoker
);
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
m_mediaInfo
,
invoker
,
*
this
);
if
(
!
flag
){
//该事件无人监听,默认不鉴权
onRes
(
""
);
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
b0a64d1e
...
...
@@ -129,7 +129,7 @@ void RtspSession::onError(const SockException& err) {
//流量统计事件广播
GET_CONFIG_AND_REGISTER
(
uint32_t
,
iFlowThreshold
,
Broadcast
::
kFlowThreshold
);
if
(
m_ui64TotalBytes
>
iFlowThreshold
*
1024
){
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
m_ui64TotalBytes
);
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
m_mediaInfo
,
m_ui64TotalBytes
,
*
this
);
}
}
...
...
@@ -227,7 +227,8 @@ bool RtspSession::handleReq_Describe() {
if
(
!
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnGetRtspRealm
,
m_mediaInfo
.
m_app
,
m_mediaInfo
.
m_streamid
,
invoker
)){
invoker
,
*
this
)){
//无人监听此事件,说明无需认证
invoker
(
""
);
}
...
...
@@ -328,9 +329,16 @@ void RtspSession::onAuthBasic(const weak_ptr<RtspSession> &weakSelf,const string
onAuthFailed
(
weakSelf
,
realm
);
}
};
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
){
//本对象已销毁
return
;
}
//此时必须提供明文密码
bool
must_no_encrypt
=
true
;
if
(
!
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnRtspAuth
,
user
,
must_no_encrypt
,
invoker
)){
if
(
!
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnRtspAuth
,
user
,
must_no_encrypt
,
invoker
,
*
strongSelf
)){
//表明该流需要认证却没监听请求密码事件,这一般是大意的程序所为,警告之
WarnL
<<
"请监听kBroadcastOnRtspAuth事件!"
;
//但是我们还是忽略认证以便完成播放
...
...
@@ -412,7 +420,7 @@ void RtspSession::onAuthDigest(const weak_ptr<RtspSession> &weakSelf,const strin
//此时可以提供明文或md5加密的密码
bool
must_no_encrypt
=
false
;
if
(
!
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnRtspAuth
,
username
,
must_no_encrypt
,
invoker
)){
if
(
!
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastOnRtspAuth
,
username
,
must_no_encrypt
,
invoker
,
*
strongSelf
)){
//表明该流需要认证却没监听请求密码事件,这一般是大意的程序所为,警告之
WarnL
<<
"请监听kBroadcastOnRtspAuth事件!"
;
//但是我们还是忽略认证以便完成播放
...
...
@@ -756,7 +764,7 @@ bool RtspSession::handleReq_Play() {
onRes
(
err
);
});
};
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
m_mediaInfo
,
invoker
);
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastMediaPlayed
,
m_mediaInfo
,
invoker
,
*
this
);
if
(
!
flag
){
//该事件无人监听,默认不鉴权
onRes
(
""
);
...
...
src/Shell/ShellSession.cpp
查看文件 @
b0a64d1e
...
...
@@ -148,7 +148,7 @@ inline void ShellSession::pleaseInputPasswd() {
});
};
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastShellLogin
,
m_strUserName
,
passwd
,
invoker
);
auto
flag
=
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastShellLogin
,
m_strUserName
,
passwd
,
invoker
,
*
this
);
if
(
!
flag
){
//如果无人监听shell登录事件,那么默认shell无法登录
onAuth
(
"please listen kBroadcastShellLogin event"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论