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
dce6b27f
Commit
dce6b27f
authored
Dec 28, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Http-FLV: http-flv直播采用绝对时间戳并支持las
parent
30b63ad6
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
16 行增加
和
14 行删除
+16
-14
src/Http/HttpSession.cpp
+3
-2
src/Rtmp/FlvMuxer.cpp
+12
-9
src/Rtmp/FlvMuxer.h
+1
-3
没有找到文件。
src/Http/HttpSession.cpp
查看文件 @
dce6b27f
...
@@ -332,7 +332,8 @@ bool HttpSession::checkLiveStreamTS(const function<void()> &cb){
...
@@ -332,7 +332,8 @@ bool HttpSession::checkLiveStreamTS(const function<void()> &cb){
//http-flv 链接格式:http://vhost-url:port/app/streamid.flv?key1=value1&key2=value2
//http-flv 链接格式:http://vhost-url:port/app/streamid.flv?key1=value1&key2=value2
bool
HttpSession
::
checkLiveStreamFlv
(
const
function
<
void
()
>
&
cb
){
bool
HttpSession
::
checkLiveStreamFlv
(
const
function
<
void
()
>
&
cb
){
return
checkLiveStream
(
RTMP_SCHEMA
,
".flv"
,
[
this
,
cb
](
const
MediaSource
::
Ptr
&
src
)
{
auto
start_pts
=
atoll
(
_parser
.
getUrlArgs
()[
"starPts"
].
data
());
return
checkLiveStream
(
RTMP_SCHEMA
,
".flv"
,
[
this
,
cb
,
start_pts
](
const
MediaSource
::
Ptr
&
src
)
{
auto
rtmp_src
=
dynamic_pointer_cast
<
RtmpMediaSource
>
(
src
);
auto
rtmp_src
=
dynamic_pointer_cast
<
RtmpMediaSource
>
(
src
);
assert
(
rtmp_src
);
assert
(
rtmp_src
);
if
(
!
cb
)
{
if
(
!
cb
)
{
...
@@ -359,7 +360,7 @@ bool HttpSession::checkLiveStreamFlv(const function<void()> &cb){
...
@@ -359,7 +360,7 @@ bool HttpSession::checkLiveStreamFlv(const function<void()> &cb){
}
}
}
}
start
(
getPoller
(),
rtmp_src
);
start
(
getPoller
(),
rtmp_src
,
start_pts
);
});
});
}
}
...
...
src/Rtmp/FlvMuxer.cpp
查看文件 @
dce6b27f
...
@@ -20,17 +20,17 @@ FlvMuxer::FlvMuxer(){
...
@@ -20,17 +20,17 @@ FlvMuxer::FlvMuxer(){
_packet_pool
.
setSize
(
64
);
_packet_pool
.
setSize
(
64
);
}
}
void
FlvMuxer
::
start
(
const
EventPoller
::
Ptr
&
poller
,
const
RtmpMediaSource
::
Ptr
&
media
)
{
void
FlvMuxer
::
start
(
const
EventPoller
::
Ptr
&
poller
,
const
RtmpMediaSource
::
Ptr
&
media
,
uint32_t
start_pts
)
{
if
(
!
media
)
{
if
(
!
media
)
{
throw
std
::
runtime_error
(
"RtmpMediaSource 无效"
);
throw
std
::
runtime_error
(
"RtmpMediaSource 无效"
);
}
}
if
(
!
poller
->
isCurrentThread
())
{
if
(
!
poller
->
isCurrentThread
())
{
weak_ptr
<
FlvMuxer
>
weakSelf
=
getSharedPtr
();
weak_ptr
<
FlvMuxer
>
weakSelf
=
getSharedPtr
();
//延时两秒启动录制,目的是为了等待config帧收集完毕
//延时两秒启动录制,目的是为了等待config帧收集完毕
poller
->
doDelayTask
(
2000
,
[
weakSelf
,
poller
,
media
]()
{
poller
->
doDelayTask
(
2000
,
[
weakSelf
,
poller
,
media
,
start_pts
]()
{
auto
strongSelf
=
weakSelf
.
lock
();
auto
strongSelf
=
weakSelf
.
lock
();
if
(
strongSelf
)
{
if
(
strongSelf
)
{
strongSelf
->
start
(
poller
,
media
);
strongSelf
->
start
(
poller
,
media
,
start_pts
);
}
}
return
0
;
return
0
;
});
});
...
@@ -50,9 +50,8 @@ void FlvMuxer::start(const EventPoller::Ptr &poller, const RtmpMediaSource::Ptr
...
@@ -50,9 +50,8 @@ void FlvMuxer::start(const EventPoller::Ptr &poller, const RtmpMediaSource::Ptr
strongSelf
->
onDetach
();
strongSelf
->
onDetach
();
});
});
//音频同步于视频
bool
check
=
start_pts
>
0
;
_stamp
[
0
].
syncTo
(
_stamp
[
1
]);
_ring_reader
->
setReadCB
([
weakSelf
,
start_pts
,
check
](
const
RtmpMediaSource
::
RingDataType
&
pkt
)
mutable
{
_ring_reader
->
setReadCB
([
weakSelf
](
const
RtmpMediaSource
::
RingDataType
&
pkt
)
{
auto
strongSelf
=
weakSelf
.
lock
();
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
if
(
!
strongSelf
)
{
return
;
return
;
...
@@ -61,6 +60,12 @@ void FlvMuxer::start(const EventPoller::Ptr &poller, const RtmpMediaSource::Ptr
...
@@ -61,6 +60,12 @@ void FlvMuxer::start(const EventPoller::Ptr &poller, const RtmpMediaSource::Ptr
size_t
i
=
0
;
size_t
i
=
0
;
auto
size
=
pkt
->
size
();
auto
size
=
pkt
->
size
();
pkt
->
for_each
([
&
](
const
RtmpPacket
::
Ptr
&
rtmp
)
{
pkt
->
for_each
([
&
](
const
RtmpPacket
::
Ptr
&
rtmp
)
{
if
(
check
)
{
if
(
rtmp
->
time_stamp
<
start_pts
)
{
return
;
}
check
=
false
;
}
strongSelf
->
onWriteRtmp
(
rtmp
,
++
i
==
size
);
strongSelf
->
onWriteRtmp
(
rtmp
,
++
i
==
size
);
});
});
});
});
...
@@ -137,9 +142,7 @@ void FlvMuxer::onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t t
...
@@ -137,9 +142,7 @@ void FlvMuxer::onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t t
}
}
void
FlvMuxer
::
onWriteRtmp
(
const
RtmpPacket
::
Ptr
&
pkt
,
bool
flush
)
{
void
FlvMuxer
::
onWriteRtmp
(
const
RtmpPacket
::
Ptr
&
pkt
,
bool
flush
)
{
int64_t
dts_out
;
onWriteFlvTag
(
pkt
,
pkt
->
time_stamp
,
flush
);
_stamp
[
pkt
->
type_id
%
2
].
revise
(
pkt
->
time_stamp
,
0
,
dts_out
,
dts_out
);
onWriteFlvTag
(
pkt
,
(
uint32_t
)
dts_out
,
flush
);
}
}
void
FlvMuxer
::
stop
()
{
void
FlvMuxer
::
stop
()
{
...
...
src/Rtmp/FlvMuxer.h
查看文件 @
dce6b27f
...
@@ -28,7 +28,7 @@ public:
...
@@ -28,7 +28,7 @@ public:
void
stop
();
void
stop
();
protected
:
protected
:
void
start
(
const
EventPoller
::
Ptr
&
poller
,
const
RtmpMediaSource
::
Ptr
&
media
);
void
start
(
const
EventPoller
::
Ptr
&
poller
,
const
RtmpMediaSource
::
Ptr
&
media
,
uint32_t
start_pts
=
0
);
virtual
void
onWrite
(
const
Buffer
::
Ptr
&
data
,
bool
flush
)
=
0
;
virtual
void
onWrite
(
const
Buffer
::
Ptr
&
data
,
bool
flush
)
=
0
;
virtual
void
onDetach
()
=
0
;
virtual
void
onDetach
()
=
0
;
virtual
std
::
shared_ptr
<
FlvMuxer
>
getSharedPtr
()
=
0
;
virtual
std
::
shared_ptr
<
FlvMuxer
>
getSharedPtr
()
=
0
;
...
@@ -43,8 +43,6 @@ private:
...
@@ -43,8 +43,6 @@ private:
private
:
private
:
ResourcePool
<
BufferRaw
>
_packet_pool
;
ResourcePool
<
BufferRaw
>
_packet_pool
;
//时间戳修整器
Stamp
_stamp
[
2
];
RtmpMediaSource
::
RingType
::
RingReader
::
Ptr
_ring_reader
;
RtmpMediaSource
::
RingType
::
RingReader
::
Ptr
_ring_reader
;
};
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论