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
afdc5e42
Commit
afdc5e42
authored
Nov 19, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine: 优化tcp/udp服务器异常管理断开机制
parent
7e646761
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
26 行增加
和
56 行删除
+26
-56
3rdpart/ZLToolKit
+1
-1
src/Http/HttpSession.cpp
+1
-6
src/Rtmp/RtmpSession.cpp
+0
-4
src/Rtp/RtpSession.cpp
+0
-6
src/Rtsp/RtspSession.cpp
+24
-28
webrtc/WebRtcSession.cpp
+0
-8
webrtc/WebRtcSession.h
+0
-3
没有找到文件。
ZLToolKit
@
f4cae4bb
Subproject commit
60eb96ded0493fb368dd907997211b6beffb6777
Subproject commit
f4cae4bbffe1e58392a0c7201f6d501a48141289
src/Http/HttpSession.cpp
查看文件 @
afdc5e42
...
...
@@ -75,12 +75,7 @@ ssize_t HttpSession::onRecvHeader(const char *header,size_t len) {
//默认后面数据不是content而是header
ssize_t
content_len
=
0
;
auto
&
fun
=
it
->
second
;
try
{
(
this
->*
fun
)(
content_len
);
}
catch
(
exception
&
ex
){
shutdown
(
SockException
(
Err_shutdown
,
ex
.
what
()));
}
(
this
->*
(
it
->
second
))(
content_len
);
//清空解析器节省内存
_parser
.
Clear
();
...
...
src/Rtmp/RtmpSession.cpp
查看文件 @
afdc5e42
...
...
@@ -60,12 +60,8 @@ void RtmpSession::onManager() {
void
RtmpSession
::
onRecv
(
const
Buffer
::
Ptr
&
buf
)
{
_ticker
.
resetTime
();
try
{
_total_bytes
+=
buf
->
size
();
onParseRtmp
(
buf
->
data
(),
buf
->
size
());
}
catch
(
exception
&
ex
)
{
shutdown
(
SockException
(
Err_shutdown
,
ex
.
what
()));
}
}
void
RtmpSession
::
onCmd_connect
(
AMFDecoder
&
dec
)
{
...
...
src/Rtp/RtpSession.cpp
查看文件 @
afdc5e42
...
...
@@ -45,17 +45,11 @@ RtpSession::~RtpSession() {
}
void
RtpSession
::
onRecv
(
const
Buffer
::
Ptr
&
data
)
{
try
{
if
(
_is_udp
)
{
onRtpPacket
(
data
->
data
(),
data
->
size
());
return
;
}
RtpSplitter
::
input
(
data
->
data
(),
data
->
size
());
}
catch
(
SockException
&
ex
)
{
shutdown
(
ex
);
}
catch
(
std
::
exception
&
ex
)
{
shutdown
(
SockException
(
Err_other
,
ex
.
what
()));
}
}
void
RtpSession
::
onError
(
const
SockException
&
err
)
{
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
afdc5e42
...
...
@@ -125,46 +125,36 @@ void RtspSession::onRecv(const Buffer::Ptr &buf) {
void
RtspSession
::
onWholeRtspPacket
(
Parser
&
parser
)
{
string
method
=
parser
.
Method
();
//提取出请求命令字
_cseq
=
atoi
(
parser
[
"CSeq"
].
data
());
if
(
_content_base
.
empty
()
&&
method
!=
"GET"
)
{
if
(
_content_base
.
empty
()
&&
method
!=
"GET"
)
{
_content_base
=
parser
.
Url
();
_media_info
.
parse
(
parser
.
FullUrl
());
_media_info
.
_schema
=
RTSP_SCHEMA
;
}
typedef
void
(
RtspSession
::*
rtsp_request_handler
)(
const
Parser
&
parser
);
using
rtsp_request_handler
=
void
(
RtspSession
::*
)(
const
Parser
&
parser
);
static
unordered_map
<
string
,
rtsp_request_handler
>
s_cmd_functions
;
static
onceToken
token
(
[]()
{
s_cmd_functions
.
emplace
(
"OPTIONS"
,
&
RtspSession
::
handleReq_Options
);
s_cmd_functions
.
emplace
(
"DESCRIBE"
,
&
RtspSession
::
handleReq_Describe
);
s_cmd_functions
.
emplace
(
"ANNOUNCE"
,
&
RtspSession
::
handleReq_ANNOUNCE
);
s_cmd_functions
.
emplace
(
"RECORD"
,
&
RtspSession
::
handleReq_RECORD
);
s_cmd_functions
.
emplace
(
"SETUP"
,
&
RtspSession
::
handleReq_Setup
);
s_cmd_functions
.
emplace
(
"PLAY"
,
&
RtspSession
::
handleReq_Play
);
s_cmd_functions
.
emplace
(
"PAUSE"
,
&
RtspSession
::
handleReq_Pause
);
s_cmd_functions
.
emplace
(
"TEARDOWN"
,
&
RtspSession
::
handleReq_Teardown
);
s_cmd_functions
.
emplace
(
"GET"
,
&
RtspSession
::
handleReq_Get
);
s_cmd_functions
.
emplace
(
"POST"
,
&
RtspSession
::
handleReq_Post
);
s_cmd_functions
.
emplace
(
"SET_PARAMETER"
,
&
RtspSession
::
handleReq_SET_PARAMETER
);
s_cmd_functions
.
emplace
(
"GET_PARAMETER"
,
&
RtspSession
::
handleReq_SET_PARAMETER
);
}
,
[]()
{}
);
static
onceToken
token
([]()
{
s_cmd_functions
.
emplace
(
"OPTIONS"
,
&
RtspSession
::
handleReq_Options
);
s_cmd_functions
.
emplace
(
"DESCRIBE"
,
&
RtspSession
::
handleReq_Describe
);
s_cmd_functions
.
emplace
(
"ANNOUNCE"
,
&
RtspSession
::
handleReq_ANNOUNCE
);
s_cmd_functions
.
emplace
(
"RECORD"
,
&
RtspSession
::
handleReq_RECORD
);
s_cmd_functions
.
emplace
(
"SETUP"
,
&
RtspSession
::
handleReq_Setup
);
s_cmd_functions
.
emplace
(
"PLAY"
,
&
RtspSession
::
handleReq_Play
);
s_cmd_functions
.
emplace
(
"PAUSE"
,
&
RtspSession
::
handleReq_Pause
);
s_cmd_functions
.
emplace
(
"TEARDOWN"
,
&
RtspSession
::
handleReq_Teardown
);
s_cmd_functions
.
emplace
(
"GET"
,
&
RtspSession
::
handleReq_Get
);
s_cmd_functions
.
emplace
(
"POST"
,
&
RtspSession
::
handleReq_Post
);
s_cmd_functions
.
emplace
(
"SET_PARAMETER"
,
&
RtspSession
::
handleReq_SET_PARAMETER
);
s_cmd_functions
.
emplace
(
"GET_PARAMETER"
,
&
RtspSession
::
handleReq_SET_PARAMETER
);
});
auto
it
=
s_cmd_functions
.
find
(
method
);
if
(
it
==
s_cmd_functions
.
end
())
{
sendRtspResponse
(
"403 Forbidden"
);
shutdown
(
SockException
(
Err_shutdown
,
StrPrinter
<<
"403 Forbidden:"
<<
method
));
return
;
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"403 Forbidden:"
<<
method
);
}
auto
&
fun
=
it
->
second
;
try
{
(
this
->*
fun
)(
parser
);
}
catch
(
SockException
&
ex
){
if
(
ex
){
shutdown
(
ex
);
}
}
catch
(
exception
&
ex
){
shutdown
(
SockException
(
Err_shutdown
,
ex
.
what
()));
}
(
this
->*
(
it
->
second
))(
parser
);
parser
.
Clear
();
}
...
...
@@ -979,7 +969,13 @@ void RtspSession::startListenPeerUdpData(int track_idx) {
if
(
!
strongSelf
)
{
return
;
}
try
{
strongSelf
->
onRcvPeerUdpData
(
interleaved
,
buf
,
addr
);
}
catch
(
SockException
&
ex
)
{
strongSelf
->
shutdown
(
ex
);
}
catch
(
std
::
exception
&
ex
)
{
strongSelf
->
shutdown
(
SockException
(
Err_other
,
ex
.
what
()));
}
});
return
true
;
};
...
...
webrtc/WebRtcSession.cpp
查看文件 @
afdc5e42
...
...
@@ -51,14 +51,6 @@ WebRtcSession::~WebRtcSession() {
}
void
WebRtcSession
::
onRecv
(
const
Buffer
::
Ptr
&
buffer
)
{
try
{
onRecv_l
(
buffer
);
}
catch
(
std
::
exception
&
ex
)
{
shutdown
(
SockException
(
Err_shutdown
,
ex
.
what
()));
}
}
void
WebRtcSession
::
onRecv_l
(
const
Buffer
::
Ptr
&
buffer
)
{
if
(
_find_transport
)
{
//只允许寻找一次transport
_find_transport
=
false
;
...
...
webrtc/WebRtcSession.h
查看文件 @
afdc5e42
...
...
@@ -31,9 +31,6 @@ public:
static
EventPoller
::
Ptr
queryPoller
(
const
Buffer
::
Ptr
&
buffer
);
private
:
void
onRecv_l
(
const
Buffer
::
Ptr
&
);
private
:
std
::
string
_identifier
;
bool
_find_transport
=
true
;
Ticker
_ticker
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论