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
c4d14ec4
Commit
c4d14ec4
authored
Apr 08, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复flv PreviousTagSize相关问题
parent
a638c029
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
19 行增加
和
40 行删除
+19
-40
src/Http/HttpSession.cpp
+0
-8
src/Http/HttpSession.h
+0
-1
src/RtmpMuxer/FlvMuxer.cpp
+18
-27
src/RtmpMuxer/FlvMuxer.h
+1
-4
没有找到文件。
src/Http/HttpSession.cpp
查看文件 @
c4d14ec4
...
...
@@ -691,14 +691,6 @@ void HttpSession::onWrite(const Buffer::Ptr &buffer) {
send
(
buffer
);
}
void
HttpSession
::
onWrite
(
const
char
*
data
,
int
len
)
{
BufferRaw
::
Ptr
buffer
(
new
BufferRaw
);
buffer
->
assign
(
data
,
len
);
_ticker
.
resetTime
();
_ui64TotalBytes
+=
buffer
->
size
();
send
(
buffer
);
}
void
HttpSession
::
onDetach
()
{
shutdown
();
}
...
...
src/Http/HttpSession.h
查看文件 @
c4d14ec4
...
...
@@ -62,7 +62,6 @@ public:
protected
:
//FlvMuxer override
void
onWrite
(
const
Buffer
::
Ptr
&
data
)
override
;
void
onWrite
(
const
char
*
data
,
int
len
)
override
;
void
onDetach
()
override
;
std
::
shared_ptr
<
FlvMuxer
>
getSharedPtr
()
override
;
//HttpRequestSplitter override
...
...
src/RtmpMuxer/FlvMuxer.cpp
查看文件 @
c4d14ec4
...
...
@@ -74,7 +74,6 @@ void FlvMuxer::start(const EventPoller::Ptr &poller,const RtmpMediaSource::Ptr &
}
void
FlvMuxer
::
onWriteFlvHeader
(
const
RtmpMediaSource
::
Ptr
&
mediaSrc
)
{
_previousTagSize
=
0
;
CLEAR_ARR
(
_aui32FirstStamp
);
//发送flv文件头
...
...
@@ -101,11 +100,17 @@ void FlvMuxer::onWriteFlvHeader(const RtmpMediaSource::Ptr &mediaSrc) {
}
//flv header
onWrite
(
flv_file_header
,
sizeof
(
flv_file_header
)
-
1
);
onWrite
(
std
::
make_shared
<
BufferRaw
>
(
flv_file_header
,
sizeof
(
flv_file_header
)
-
1
));
auto
size
=
htonl
(
0
);
//PreviousTagSize0 Always 0
onWrite
(
std
::
make_shared
<
BufferRaw
>
((
char
*
)
&
size
,
4
));
//metadata
AMFEncoder
invoke
;
invoke
<<
"onMetaData"
<<
mediaSrc
->
getMetaData
();
onWriteFlvTag
(
MSG_DATA
,
invoke
.
data
(),
0
);
onWriteFlvTag
(
MSG_DATA
,
std
::
make_shared
<
BufferString
>
(
invoke
.
data
()),
0
);
//config frame
mediaSrc
->
getConfigFrame
([
&
](
const
RtmpPacket
::
Ptr
&
pkt
){
onWriteRtmp
(
pkt
);
...
...
@@ -132,29 +137,22 @@ public:
#endif // defined(_WIN32)
void
FlvMuxer
::
onWriteFlvTag
(
const
RtmpPacket
::
Ptr
&
pkt
,
uint32_t
ui32TimeStamp
)
{
auto
size
=
htonl
(
_previousTagSize
);
onWrite
((
char
*
)
&
size
,
4
);
//onWrite PreviousTagSize
RtmpTagHeader
header
;
header
.
type
=
pkt
->
typeId
;
set_be24
(
header
.
data_size
,
pkt
->
strBuf
.
size
());
header
.
timestamp_ex
=
(
uint8_t
)
((
ui32TimeStamp
>>
24
)
&
0xff
);
set_be24
(
header
.
timestamp
,
ui32TimeStamp
&
0xFFFFFF
);
onWrite
((
char
*
)
&
header
,
sizeof
(
header
));
//onWrite tag header
onWrite
(
pkt
);
//onWrite tag data
_previousTagSize
+=
(
pkt
->
strBuf
.
size
()
+
sizeof
(
header
));
onWriteFlvTag
(
pkt
->
typeId
,
pkt
,
ui32TimeStamp
);
}
void
FlvMuxer
::
onWriteFlvTag
(
uint8_t
ui8Type
,
const
std
::
string
&
strBuf
,
uint32_t
ui32TimeStamp
)
{
auto
size
=
htonl
(
_previousTagSize
);
onWrite
((
char
*
)
&
size
,
4
);
//onWrite PreviousTagSize
void
FlvMuxer
::
onWriteFlvTag
(
uint8_t
ui8Type
,
const
Buffer
::
Ptr
&
buffer
,
uint32_t
ui32TimeStamp
)
{
RtmpTagHeader
header
;
header
.
type
=
ui8Type
;
set_be24
(
header
.
data_size
,
strBuf
.
size
());
set_be24
(
header
.
data_size
,
buffer
->
size
());
header
.
timestamp_ex
=
(
uint8_t
)
((
ui32TimeStamp
>>
24
)
&
0xff
);
set_be24
(
header
.
timestamp
,
ui32TimeStamp
&
0xFFFFFF
);
onWrite
((
char
*
)
&
header
,
sizeof
(
header
));
//onWrite tag header
onWrite
(
std
::
make_shared
<
BufferString
>
(
strBuf
));
//onWrite tag data
_previousTagSize
+=
(
strBuf
.
size
()
+
sizeof
(
header
));
//tag header
onWrite
(
std
::
make_shared
<
BufferRaw
>
((
char
*
)
&
header
,
sizeof
(
header
)));
//tag data
onWrite
(
buffer
);
auto
size
=
htonl
((
buffer
->
size
()
+
sizeof
(
header
)));
//PreviousTagSize
onWrite
(
std
::
make_shared
<
BufferRaw
>
((
char
*
)
&
size
,
4
));
}
void
FlvMuxer
::
onWriteRtmp
(
const
RtmpPacket
::
Ptr
&
pkt
)
{
...
...
@@ -218,13 +216,6 @@ void FlvRecorder::onWrite(const Buffer::Ptr &data) {
}
}
void
FlvRecorder
::
onWrite
(
const
char
*
data
,
int
len
)
{
lock_guard
<
recursive_mutex
>
lck
(
_file_mtx
);
if
(
_file
){
fwrite
(
data
,
len
,
1
,
_file
.
get
());
}
}
void
FlvRecorder
::
onDetach
()
{
lock_guard
<
recursive_mutex
>
lck
(
_file_mtx
);
_file
.
reset
();
...
...
src/RtmpMuxer/FlvMuxer.h
查看文件 @
c4d14ec4
...
...
@@ -43,18 +43,16 @@ public:
protected
:
void
start
(
const
EventPoller
::
Ptr
&
poller
,
const
RtmpMediaSource
::
Ptr
&
media
);
virtual
void
onWrite
(
const
Buffer
::
Ptr
&
data
)
=
0
;
virtual
void
onWrite
(
const
char
*
data
,
int
len
)
=
0
;
virtual
void
onDetach
()
=
0
;
virtual
std
::
shared_ptr
<
FlvMuxer
>
getSharedPtr
()
=
0
;
private
:
void
onWriteFlvHeader
(
const
RtmpMediaSource
::
Ptr
&
media
);
void
onWriteRtmp
(
const
RtmpPacket
::
Ptr
&
pkt
);
void
onWriteFlvTag
(
const
RtmpPacket
::
Ptr
&
pkt
,
uint32_t
ui32TimeStamp
);
void
onWriteFlvTag
(
uint8_t
ui8Type
,
const
std
::
string
&
strBuf
,
uint32_t
ui32TimeStamp
);
void
onWriteFlvTag
(
uint8_t
ui8Type
,
const
Buffer
::
Ptr
&
buffer
,
uint32_t
ui32TimeStamp
);
private
:
RtmpMediaSource
::
RingType
::
RingReader
::
Ptr
_ring_reader
;
uint32_t
_aui32FirstStamp
[
2
]
=
{
0
};
uint32_t
_previousTagSize
=
0
;
};
...
...
@@ -67,7 +65,6 @@ public:
void
startRecord
(
const
EventPoller
::
Ptr
&
poller
,
const
RtmpMediaSource
::
Ptr
&
media
,
const
string
&
file_path
);
private
:
virtual
void
onWrite
(
const
Buffer
::
Ptr
&
data
)
override
;
virtual
void
onWrite
(
const
char
*
data
,
int
len
)
override
;
virtual
void
onDetach
()
override
;
virtual
std
::
shared_ptr
<
FlvMuxer
>
getSharedPtr
()
override
;
private
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论