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
458a9252
Commit
458a9252
authored
May 28, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善服务器日志打印
parent
69624f84
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
73 行增加
和
64 行删除
+73
-64
src/Http/HttpSession.cpp
+3
-6
src/Rtmp/RtmpSession.cpp
+26
-20
src/Rtmp/RtmpSession.h
+1
-1
src/Rtsp/RtspSession.cpp
+43
-37
没有找到文件。
src/Http/HttpSession.cpp
查看文件 @
458a9252
...
...
@@ -124,7 +124,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) {
string
cmd
=
_parser
.
Method
();
auto
it
=
g_mapCmdIndex
.
find
(
cmd
);
if
(
it
==
g_mapCmdIndex
.
end
())
{
Warn
L
<<
cmd
;
Warn
P
(
this
)
<<
cmd
;
sendResponse
(
"403 Forbidden"
,
makeHttpHeader
(
true
),
""
);
shutdown
();
return
0
;
...
...
@@ -156,7 +156,7 @@ void HttpSession::onRecv(const Buffer::Ptr &pBuf) {
}
void
HttpSession
::
onError
(
const
SockException
&
err
)
{
//WarnL
<< err.what();
// WarnP(this)
<< err.what();
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_ui64TotalBytes
>
iFlowThreshold
*
1024
){
...
...
@@ -174,7 +174,7 @@ void HttpSession::onManager() {
if
(
_ticker
.
elapsedTime
()
>
keepAliveSec
*
1000
){
//1分钟超时
WarnL
<<
"HttpSession timeouted!"
;
// WarnP(this)
<<"HttpSession timeouted!";
shutdown
();
}
}
...
...
@@ -441,7 +441,6 @@ inline bool HttpSession::Handle_Req_GET(int64_t &content_len) {
if
(
iRead
<
iReq
||
!*
piLeft
)
{
//文件读完
//InfoL << "send complete!" << iRead << " " << iReq << " " << *piLeft;
if
(
iRead
>
0
)
{
sendBuf
->
setSize
(
iRead
);
strongSelf
->
send
(
sendBuf
);
...
...
@@ -456,7 +455,6 @@ inline bool HttpSession::Handle_Req_GET(int64_t &content_len) {
int
iSent
=
strongSelf
->
send
(
sendBuf
);
if
(
iSent
==
-
1
)
{
//套机制销毁
//InfoL << "send error";
return
false
;
}
if
(
strongSelf
->
isSocketBusy
()){
...
...
@@ -583,7 +581,6 @@ inline void HttpSession::sendResponse(const char* pcStatus, const KeyValue& head
}
printer
<<
"
\r\n
"
<<
strContent
;
auto
strSend
=
printer
<<
endl
;
//DebugL << strSend;
send
(
strSend
);
_ticker
.
resetTime
();
}
...
...
src/Rtmp/RtmpSession.cpp
查看文件 @
458a9252
...
...
@@ -34,7 +34,7 @@ namespace mediakit {
static
int
kSockFlags
=
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
;
RtmpSession
::
RtmpSession
(
const
Socket
::
Ptr
&
pSock
)
:
TcpSession
(
pSock
)
{
Debug
L
<<
get_peer_ip
(
);
Debug
P
(
this
);
//设置15秒发送超时时间
pSock
->
setSendTimeOutSecond
(
15
);
//起始接收buffer缓存设置为4K,节省内存
...
...
@@ -42,11 +42,11 @@ RtmpSession::RtmpSession(const Socket::Ptr &pSock) : TcpSession(pSock) {
}
RtmpSession
::~
RtmpSession
()
{
Debug
L
<<
get_peer_ip
(
);
Debug
P
(
this
);
}
void
RtmpSession
::
onError
(
const
SockException
&
err
)
{
Debug
L
<<
err
.
what
();
Debug
P
(
this
)
<<
err
.
what
();
//流量统计事件广播
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
...
...
@@ -65,14 +65,14 @@ void RtmpSession::onError(const SockException& err) {
void
RtmpSession
::
onManager
()
{
if
(
_ticker
.
createdTime
()
>
15
*
1000
)
{
if
(
!
_pRingReader
&&
!
_pPublisherSrc
)
{
Warn
L
<<
"非法链接:"
<<
get_peer_ip
()
;
Warn
P
(
this
)
<<
"非法链接"
;
shutdown
();
}
}
if
(
_pPublisherSrc
)
{
//publisher
if
(
_ticker
.
elapsedTime
()
>
15
*
1000
)
{
Warn
L
<<
"数据接收超时:"
<<
get_peer_ip
()
;
Warn
P
(
this
)
<<
"数据接收超时"
;
shutdown
();
}
}
...
...
@@ -84,7 +84,7 @@ void RtmpSession::onRecv(const Buffer::Ptr &pBuf) {
_ui64TotalBytes
+=
pBuf
->
size
();
onParseRtmp
(
pBuf
->
data
(),
pBuf
->
size
());
}
catch
(
exception
&
e
)
{
Warn
L
<<
e
.
what
();
Warn
P
(
this
)
<<
e
.
what
();
shutdown
();
}
}
...
...
@@ -134,8 +134,12 @@ void RtmpSession::onCmd_createStream(AMFDecoder &dec) {
void
RtmpSession
::
onCmd_publish
(
AMFDecoder
&
dec
)
{
std
::
shared_ptr
<
Ticker
>
pTicker
(
new
Ticker
);
std
::
shared_ptr
<
onceToken
>
pToken
(
new
onceToken
(
nullptr
,[
pTicker
](){
DebugL
<<
"publish 回复时间:"
<<
pTicker
->
elapsedTime
()
<<
"ms"
;
weak_ptr
<
RtmpSession
>
weakSelf
=
dynamic_pointer_cast
<
RtmpSession
>
(
shared_from_this
());
std
::
shared_ptr
<
onceToken
>
pToken
(
new
onceToken
(
nullptr
,[
pTicker
,
weakSelf
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
strongSelf
){
DebugP
(
strongSelf
.
get
())
<<
"publish 回复时间:"
<<
pTicker
->
elapsedTime
()
<<
"ms"
;
}
}));
dec
.
load
<
AMFValue
>
();
/* NULL */
_mediaInfo
.
parse
(
_strTcUrl
+
"/"
+
dec
.
load
<
std
::
string
>
());
...
...
@@ -155,7 +159,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
status
.
set
(
"clientid"
,
"0"
);
sendReply
(
"onStatus"
,
nullptr
,
status
);
if
(
!
ok
)
{
Warn
L
<<
"onPublish:"
Warn
P
(
this
)
<<
"onPublish:"
<<
(
authSuccess
?
"Already publishing:"
:
err
.
data
())
<<
" "
<<
_mediaInfo
.
_vhost
<<
" "
<<
_mediaInfo
.
_app
<<
" "
...
...
@@ -169,7 +173,6 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
_sock
->
setReadBuffer
(
std
::
make_shared
<
BufferRaw
>
(
256
*
1024
));
};
weak_ptr
<
RtmpSession
>
weakSelf
=
dynamic_pointer_cast
<
RtmpSession
>
(
shared_from_this
());
Broadcast
::
AuthInvoker
invoker
=
[
weakSelf
,
onRes
,
pToken
](
const
string
&
err
){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
){
...
...
@@ -219,7 +222,7 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
status
.
set
(
"clientid"
,
"0"
);
sendReply
(
"onStatus"
,
nullptr
,
status
);
if
(
!
ok
)
{
Warn
L
<<
(
authSuccess
?
"No such stream:"
:
err
.
data
())
<<
" "
Warn
P
(
this
)
<<
(
authSuccess
?
"No such stream:"
:
err
.
data
())
<<
" "
<<
_mediaInfo
.
_vhost
<<
" "
<<
_mediaInfo
.
_app
<<
" "
<<
_mediaInfo
.
_streamid
...
...
@@ -264,7 +267,7 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
sendResponse
(
MSG_DATA
,
invoke
.
data
());
src
->
getConfigFrame
([
&
](
const
RtmpPacket
::
Ptr
&
pkt
)
{
//Debug
L
<<"send initial frame";
//Debug
P(this)
<<"send initial frame";
onSendMedia
(
pkt
);
});
...
...
@@ -318,10 +321,13 @@ void RtmpSession::doPlayResponse(const string &err,const std::function<void(bool
void
RtmpSession
::
doPlay
(
AMFDecoder
&
dec
){
std
::
shared_ptr
<
Ticker
>
pTicker
(
new
Ticker
);
std
::
shared_ptr
<
onceToken
>
pToken
(
new
onceToken
(
nullptr
,[
pTicker
](){
DebugL
<<
"play 回复时间:"
<<
pTicker
->
elapsedTime
()
<<
"ms"
;
}));
weak_ptr
<
RtmpSession
>
weakSelf
=
dynamic_pointer_cast
<
RtmpSession
>
(
shared_from_this
());
std
::
shared_ptr
<
onceToken
>
pToken
(
new
onceToken
(
nullptr
,[
pTicker
,
weakSelf
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
strongSelf
)
{
DebugP
(
strongSelf
.
get
())
<<
"play 回复时间:"
<<
pTicker
->
elapsedTime
()
<<
"ms"
;
}
}));
Broadcast
::
AuthInvoker
invoker
=
[
weakSelf
,
pToken
](
const
string
&
err
){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
){
...
...
@@ -353,7 +359,7 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
void
RtmpSession
::
onCmd_pause
(
AMFDecoder
&
dec
)
{
dec
.
load
<
AMFValue
>
();
/* NULL */
bool
paused
=
dec
.
load
<
bool
>
();
Trace
L
<<
paused
;
Trace
P
(
this
)
<<
paused
;
AMFValue
status
(
AMF_OBJECT
);
status
.
set
(
"level"
,
"status"
);
status
.
set
(
"code"
,
paused
?
"NetStream.Pause.Notify"
:
"NetStream.Unpause.Notify"
);
...
...
@@ -406,7 +412,7 @@ void RtmpSession::onProcessCmd(AMFDecoder &dec) {
std
::
string
method
=
dec
.
load
<
std
::
string
>
();
auto
it
=
g_mapCmd
.
find
(
method
);
if
(
it
==
g_mapCmd
.
end
())
{
Trace
L
<<
"can not support cmd:"
<<
method
;
Trace
P
(
this
)
<<
"can not support cmd:"
<<
method
;
return
;
}
_dNowReqID
=
dec
.
load
<
double
>
();
...
...
@@ -427,7 +433,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
case
MSG_DATA3
:
{
AMFDecoder
dec
(
chunkData
.
strBuf
,
chunkData
.
typeId
==
MSG_CMD3
?
1
:
0
);
std
::
string
type
=
dec
.
load
<
std
::
string
>
();
Trace
L
<<
"notify:"
<<
type
;
Trace
P
(
this
)
<<
"notify:"
<<
type
;
if
(
type
==
"@setDataFrame"
)
{
setMetaData
(
dec
);
}
...
...
@@ -446,7 +452,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
}
break
;
default
:
Warn
L
<<
"unhandled message:"
<<
(
int
)
chunkData
.
typeId
<<
hexdump
(
chunkData
.
strBuf
.
data
(),
chunkData
.
strBuf
.
size
());
Warn
P
(
this
)
<<
"unhandled message:"
<<
(
int
)
chunkData
.
typeId
<<
hexdump
(
chunkData
.
strBuf
.
data
(),
chunkData
.
strBuf
.
size
());
break
;
}
}
...
...
@@ -454,7 +460,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
void
RtmpSession
::
onCmd_seek
(
AMFDecoder
&
dec
)
{
dec
.
load
<
AMFValue
>
();
/* NULL */
auto
milliSeconds
=
dec
.
load
<
AMFValue
>
().
as_number
();
Info
L
<<
"rtmp seekTo(ms):"
<<
milliSeconds
;
Info
P
(
this
)
<<
"rtmp seekTo(ms):"
<<
milliSeconds
;
auto
stongSrc
=
_pPlayerSrc
.
lock
();
if
(
stongSrc
)
{
stongSrc
->
seekTo
(
milliSeconds
);
...
...
src/Rtmp/RtmpSession.h
查看文件 @
458a9252
...
...
@@ -85,7 +85,7 @@ private:
if
(
!
force
&&
_pPublisherSrc
->
readerCount
()
!=
0
){
return
false
;
}
Info
L
<<
"kick out:"
<<
_mediaInfo
.
_vhost
<<
" "
<<
_mediaInfo
.
_app
<<
" "
<<
_mediaInfo
.
_streamid
;
Info
P
(
this
)
<<
"kick out:"
<<
_mediaInfo
.
_vhost
<<
" "
<<
_mediaInfo
.
_app
<<
" "
<<
_mediaInfo
.
_streamid
;
safeShutdown
();
return
true
;
}
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
458a9252
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论