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
ba3b4708
Commit
ba3b4708
authored
Oct 29, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决gcc4.8编译失败的问题
解决部分rtsp服务器seek异常的问题
parent
1faeda2f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
49 行删除
+39
-49
ZLToolKit
+1
-1
src/Rtsp/RtspSession.cpp
+37
-45
src/Rtsp/RtspSession.h
+1
-3
没有找到文件。
ZLToolKit
@
109c994d
Subproject commit
3a9c916454897ad02c6ee4cba89f5e370718cd91
Subproject commit
109c994dc84f1c9ce9caf7199dd905086f54881d
src/Rtsp/RtspSession.cpp
查看文件 @
ba3b4708
...
...
@@ -541,13 +541,6 @@ bool RtspSession::handleReq_Setup() {
}
trackRef
->
_inited
=
true
;
//现在初始化
auto
strongRing
=
_pWeakRing
.
lock
();
if
(
!
strongRing
)
{
//the media source is released!
send_NotAcceptable
();
return
false
;
}
if
(
!
_bSetUped
){
_bSetUped
=
true
;
auto
strTransport
=
_parser
[
"Transport"
];
...
...
@@ -560,18 +553,6 @@ bool RtspSession::handleReq_Setup() {
}
}
if
(
!
_pRtpReader
&&
_rtpType
!=
PlayerBase
::
RTP_MULTICAST
)
{
_pRtpReader
=
strongRing
->
attach
();
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
_pRtpReader
->
setDetachCB
([
weakSelf
]()
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
strongSelf
->
safeShutdown
();
});
}
switch
(
_rtpType
)
{
case
PlayerBase
:
:
RTP_TCP
:
{
int
iLen
=
sprintf
(
_pcBuf
,
...
...
@@ -723,6 +704,9 @@ bool RtspSession::handleReq_Play() {
return
;
}
bool
useBuf
=
true
;
_enableSendRtp
=
false
;
if
(
strRange
.
size
()
&&
!
_bFirstPlay
)
{
//这个是seek操作
auto
strStart
=
FindField
(
strRange
.
data
(),
"npt="
,
"-"
);
...
...
@@ -731,8 +715,8 @@ bool RtspSession::handleReq_Play() {
}
auto
iStartTime
=
1000
*
atof
(
strStart
.
data
());
InfoL
<<
"rtsp seekTo(ms):"
<<
iStartTime
;
pMediaSrc
->
seekTo
(
iStartTime
);
}
else
if
(
pMediaSrc
->
getRing
()
->
readerCount
()
==
1
){
useBuf
=
!
pMediaSrc
->
seekTo
(
iStartTime
);
}
else
if
(
pMediaSrc
->
getRing
()
->
readerCount
()
==
0
){
//第一个消费者
pMediaSrc
->
seekTo
(
0
);
}
...
...
@@ -769,28 +753,41 @@ bool RtspSession::handleReq_Play() {
iLen
+=
sprintf
(
_pcBuf
+
iLen
,
"
\r\n\r\n
"
);
SocketHelper
::
send
(
_pcBuf
,
iLen
);
_enableSendRtp
=
true
;
//提高发送性能
(
*
this
)
<<
SocketFlags
(
kSockFlags
);
SockUtil
::
setNoDelay
(
_pSender
->
rawFD
(),
false
);
if
(
_pRtpReader
){
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
SockUtil
::
setNoDelay
(
_pSender
->
rawFD
(),
false
);
_pRtpReader
->
setReadCB
([
weakSelf
](
const
RtpPacket
::
Ptr
&
pack
)
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
strongSelf
->
async
([
weakSelf
,
pack
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
strongSelf
->
sendRtpPacket
(
pack
);
});
});
}
if
(
!
_pRtpReader
&&
_rtpType
!=
PlayerBase
::
RTP_MULTICAST
)
{
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
_pRtpReader
=
pMediaSrc
->
getRing
()
->
attach
(
useBuf
);
_pRtpReader
->
setDetachCB
([
weakSelf
]()
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
strongSelf
->
safeShutdown
();
});
_pRtpReader
->
setReadCB
([
weakSelf
](
const
RtpPacket
::
Ptr
&
pack
)
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
if
(
!
strongSelf
->
_enableSendRtp
)
{
return
;
}
strongSelf
->
async
([
weakSelf
,
pack
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
if
(
strongSelf
->
_enableSendRtp
)
{
strongSelf
->
sendRtpPacket
(
pack
);
}
});
});
}
};
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
...
...
@@ -834,11 +831,8 @@ bool RtspSession::handleReq_Pause() {
"Session: %s
\r\n\r\n
"
,
_iCseq
,
SERVER_NAME
,
RTSP_VERSION
,
RTSP_BUILDTIME
,
dateHeader
().
data
(),
_strSession
.
data
());
SocketHelper
::
send
(
_pcBuf
,
n
);
if
(
_pRtpReader
)
{
_pRtpReader
->
setReadCB
(
nullptr
);
}
_enableSendRtp
=
false
;
return
true
;
}
bool
RtspSession
::
handleReq_Teardown
()
{
...
...
@@ -992,8 +986,6 @@ inline bool RtspSession::findStream() {
return
false
;
}
_strSdp
=
pMediaSrc
->
getSdp
();
_pWeakRing
=
pMediaSrc
->
getRing
();
_sdpAttr
.
load
(
_strSdp
);
_aTrackInfo
=
_sdpAttr
.
getAvailableTrack
();
...
...
src/Rtsp/RtspSession.h
查看文件 @
ba3b4708
...
...
@@ -156,9 +156,6 @@ private:
bool
_bFirstPlay
=
true
;
MediaInfo
_mediaInfo
;
std
::
weak_ptr
<
RtspMediaSource
>
_pMediaSrc
;
//RTP缓冲
weak_ptr
<
RingBuffer
<
RtpPacket
::
Ptr
>
>
_pWeakRing
;
RingBuffer
<
RtpPacket
::
Ptr
>::
RingReader
::
Ptr
_pRtpReader
;
PlayerBase
::
eRtpType
_rtpType
=
PlayerBase
::
RTP_UDP
;
...
...
@@ -204,6 +201,7 @@ private:
std
::
function
<
void
()
>
_delayTask
;
uint32_t
_iTaskTimeLine
=
0
;
atomic
<
bool
>
_enableSendRtp
;
};
}
/* namespace mediakit */
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论