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
6870292f
Commit
6870292f
authored
Oct 26, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善seek相关的逻辑
parent
52f0d89d
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
39 行增加
和
33 行删除
+39
-33
src/Common/MediaSource.h
+5
-14
src/Device/PlayerProxy.cpp
+1
-1
src/Device/PlayerProxy.h
+1
-1
src/MediaFile/MediaReader.cpp
+1
-4
src/MediaFile/MediaReader.h
+1
-2
src/Rtmp/RtmpMediaSource.h
+16
-3
src/Rtmp/RtmpSession.h
+1
-1
src/Rtsp/RtspMediaSource.h
+10
-4
src/Rtsp/RtspSession.cpp
+2
-2
src/Shell/ShellCMD.cpp
+1
-1
没有找到文件。
src/Common/MediaSource.h
查看文件 @
6870292f
...
...
@@ -54,11 +54,7 @@ public:
//拖动进度条
return
false
;
}
virtual
uint32_t
getStamp
()
{
//获取时间戳
return
0
;
}
virtual
bool
shutDown
()
{
virtual
bool
close
()
{
//通知其停止推流
return
false
;
}
...
...
@@ -143,19 +139,14 @@ public:
return
listener
->
seekTo
(
ui32Stamp
);
}
uint32_t
getStamp
()
{
auto
listener
=
_listener
.
lock
();
if
(
!
listener
){
return
0
;
}
return
listener
->
getStamp
();
}
bool
shutDown
()
{
virtual
uint32_t
getTimeStamp
(
TrackType
trackType
)
=
0
;
bool
close
()
{
auto
listener
=
_listener
.
lock
();
if
(
!
listener
){
return
false
;
}
return
listener
->
shutDown
();
return
listener
->
close
();
}
void
setListener
(
const
std
::
weak_ptr
<
MediaSourceEvent
>
&
listener
){
_listener
=
listener
;
...
...
src/Device/PlayerProxy.cpp
查看文件 @
6870292f
...
...
@@ -192,7 +192,7 @@ void PlayerProxy::initMedia() {
// _pChn->initAudio(info);
// }
}
bool
PlayerProxy
::
shutDown
()
{
bool
PlayerProxy
::
close
()
{
//通知其停止推流
weak_ptr
<
PlayerProxy
>
weakSlef
=
dynamic_pointer_cast
<
PlayerProxy
>
(
shared_from_this
());
auto
executor
=
getExecutor
();
...
...
src/Device/PlayerProxy.h
查看文件 @
6870292f
...
...
@@ -54,7 +54,7 @@ public:
virtual
~
PlayerProxy
();
void
play
(
const
char
*
strUrl
)
override
;
bool
shutDown
()
override
;
bool
close
()
override
;
private
:
void
initMedia
();
void
rePlay
(
const
string
&
strUrl
,
int
iFailedCnt
);
...
...
src/MediaFile/MediaReader.cpp
查看文件 @
6870292f
...
...
@@ -177,10 +177,7 @@ void MediaReader::startReadMP4() {
seek
(
ui32Stamp
);
return
true
;
}
uint32_t
MediaReader
::
getStamp
()
{
return
_iSeekTime
+
_ticker
.
elapsedTime
();
}
bool
MediaReader
::
shutDown
(){
bool
MediaReader
::
close
(){
AsyncTaskThread
::
Instance
().
CancelTask
(
reinterpret_cast
<
uint64_t
>
(
this
));
return
true
;
}
...
...
src/MediaFile/MediaReader.h
查看文件 @
6870292f
...
...
@@ -46,8 +46,7 @@ public:
static
MediaSource
::
Ptr
onMakeMediaSource
(
const
string
&
strSchema
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strId
);
public
:
bool
seekTo
(
uint32_t
ui32Stamp
)
override
;
uint32_t
getStamp
()
override
;
bool
shutDown
()
override
;
bool
close
()
override
;
private
:
#ifdef ENABLE_MP4V2
...
...
src/Rtmp/RtmpMediaSource.h
查看文件 @
6870292f
...
...
@@ -93,7 +93,7 @@ public:
void
onWrite
(
const
RtmpPacket
::
Ptr
&
pkt
,
bool
isKey
=
true
)
override
{
lock_guard
<
recursive_mutex
>
lock
(
_mtxMap
);
if
(
pkt
->
isCfgFrame
())
{
_mapCfgFrame
.
emplace
(
pkt
->
typeId
,
pkt
)
;
_mapCfgFrame
[
pkt
->
typeId
]
=
pkt
;
if
(
_bAsyncRegist
&&
!
_bRegisted
&&
_mapCfgFrame
.
size
()
==
_iCfgFrameSize
){
_bAsyncRegist
=
false
;
...
...
@@ -101,9 +101,21 @@ public:
_bRegisted
=
true
;
}
}
_mapStamp
[
pkt
->
typeId
]
=
pkt
->
timeStamp
;
_pRing
->
write
(
pkt
,
pkt
->
isVideoKeyFrame
());
}
uint32_t
getTimeStamp
(
TrackType
trackType
)
override
{
lock_guard
<
recursive_mutex
>
lock
(
_mtxMap
);
switch
(
trackType
){
case
TrackVideo
:
return
_mapStamp
[
MSG_VIDEO
];
case
TrackAudio
:
return
_mapStamp
[
MSG_AUDIO
];
default
:
return
MAX
(
_mapStamp
[
MSG_VIDEO
],
_mapStamp
[
MSG_AUDIO
]);
}
}
private
:
bool
ready
(){
lock_guard
<
recursive_mutex
>
lock
(
_mtxMap
);
...
...
@@ -111,7 +123,8 @@ private:
}
protected
:
AMFValue
_metadata
;
unordered_map
<
int
,
RtmpPacket
::
Ptr
>
_mapCfgFrame
;
map
<
int
,
RtmpPacket
::
Ptr
>
_mapCfgFrame
;
map
<
int
,
uint32_t
>
_mapStamp
;
mutable
recursive_mutex
_mtxMap
;
RingBuffer
<
RtmpPacket
::
Ptr
>::
Ptr
_pRing
;
//rtp环形缓冲
int
_iCfgFrameSize
=
-
1
;
...
...
src/Rtmp/RtmpSession.h
查看文件 @
6870292f
...
...
@@ -79,7 +79,7 @@ private:
sendResponse
(
MSG_CMD
,
invoke
.
data
());
}
bool
shutDown
()
override
{
bool
close
()
override
{
InfoL
<<
"kick out:"
<<
_mediaInfo
.
_vhost
<<
" "
<<
_mediaInfo
.
_app
<<
" "
<<
_mediaInfo
.
_streamid
;
safeShutdown
();
return
true
;
...
...
src/Rtsp/RtspMediaSource.h
查看文件 @
6870292f
...
...
@@ -84,13 +84,19 @@ public:
}
return
track
->
_seq
;
}
virtual
uint32_t
getTimeStamp
(
TrackType
trackType
)
{
uint32_t
getTimeStamp
(
TrackType
trackType
)
override
{
auto
track
=
_sdpAttr
.
getTrack
(
trackType
);
if
(
!
track
){
return
0
;
}
if
(
track
)
{
return
track
->
_time_stamp
;
}
auto
tracks
=
_sdpAttr
.
getAvailableTrack
();
switch
(
tracks
.
size
()){
case
0
:
return
0
;
case
1
:
return
tracks
[
0
]
->
_time_stamp
;
default
:
return
MAX
(
tracks
[
0
]
->
_time_stamp
,
tracks
[
1
]
->
_time_stamp
);
}
}
virtual
void
setTimeStamp
(
uint32_t
uiStamp
)
{
auto
tracks
=
_sdpAttr
.
getAvailableTrack
();
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
6870292f
...
...
@@ -723,13 +723,13 @@ bool RtspSession::handleReq_Play() {
auto
iStartTime
=
1000
*
atof
(
strStart
.
data
());
InfoL
<<
"rtsp seekTo(ms):"
<<
iStartTime
;
pMediaSrc
->
seekTo
(
iStartTime
);
iStamp
=
pMediaSrc
->
get
Stamp
(
);
iStamp
=
pMediaSrc
->
get
TimeStamp
(
TrackInvalid
);
}
else
if
(
pMediaSrc
->
getRing
()
->
readerCount
()
==
1
){
//第一个消费者
pMediaSrc
->
seekTo
(
0
);
iStamp
=
0
;
}
else
{
iStamp
=
pMediaSrc
->
get
Stamp
(
);
iStamp
=
pMediaSrc
->
get
TimeStamp
(
TrackInvalid
);
}
for
(
auto
&
track
:
_aTrackInfo
){
...
...
src/Shell/ShellCMD.cpp
查看文件 @
6870292f
...
...
@@ -51,7 +51,7 @@ public:
if
(
!
media
)
{
break
;
}
if
(
!
media
->
shutDown
())
{
if
(
!
media
->
close
())
{
break
;
}
(
*
stream
)
<<
"
\t
踢出成功:"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论