Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-05-24 23:16:56 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a9dbaefb790f2e780e6d6dcf42f6745c8be5795
8a9dbaef
1 parent
0e1ac2b9
use cache for flv tag header.
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
18 行增加
和
12 行删除
trunk/src/kernel/srs_kernel_flv.cpp
trunk/src/kernel/srs_kernel_flv.hpp
trunk/src/kernel/srs_kernel_flv.cpp
查看文件 @
8a9dbae
...
...
@@ -38,9 +38,6 @@ using namespace std;
#include <srs_kernel_file.hpp>
#include <srs_kernel_codec.hpp>
#define SRS_FLV_TAG_HEADER_SIZE 11
#define SRS_FLV_PREVIOUS_TAG_SIZE 4
SrsFlvEncoder
::
SrsFlvEncoder
()
{
_fs
=
NULL
;
...
...
@@ -119,19 +116,22 @@ int SrsFlvEncoder::write_metadata(char type, char* data, int size)
srs_assert
(
data
);
// 11 bytes tag header
char
tag_header
[]
=
{
/*
char tag_header[] = {
(char)type, // TagType UB [5], 18 = script data
(char)0x00, (char)0x00, (char)0x00, // DataSize UI24 Length of the message.
(char)0x00, (char)0x00, (char)0x00, // Timestamp UI24 Time in milliseconds at which the data in this tag applies.
(char)0x00, // TimestampExtended UI8
(char)0x00, (char)0x00, (char)0x00, // StreamID UI24 Always 0.
};
};
*/
// write data size.
if
((
ret
=
tag_stream
->
initialize
(
tag_header
+
1
,
3
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
tag_stream
->
initialize
(
tag_header
,
8
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
tag_stream
->
write_1bytes
(
type
);
tag_stream
->
write_3bytes
(
size
);
tag_stream
->
write_3bytes
(
0x00
);
tag_stream
->
write_1bytes
(
0x00
);
if
((
ret
=
write_tag
(
tag_header
,
sizeof
(
tag_header
),
data
,
size
))
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
...
...
@@ -152,18 +152,19 @@ int SrsFlvEncoder::write_audio(int64_t timestamp, char* data, int size)
timestamp
&=
0x7fffffff
;
// 11bytes tag header
char
tag_header
[]
=
{
/*
char tag_header[] = {
(char)SrsCodecFlvTagAudio, // TagType UB [5], 8 = audio
(char)0x00, (char)0x00, (char)0x00, // DataSize UI24 Length of the message.
(char)0x00, (char)0x00, (char)0x00, // Timestamp UI24 Time in milliseconds at which the data in this tag applies.
(char)0x00, // TimestampExtended UI8
(char)0x00, (char)0x00, (char)0x00, // StreamID UI24 Always 0.
};
};
*/
// write data size.
if
((
ret
=
tag_stream
->
initialize
(
tag_header
+
1
,
7
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
tag_stream
->
initialize
(
tag_header
,
8
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
tag_stream
->
write_1bytes
(
SrsCodecFlvTagAudio
);
tag_stream
->
write_3bytes
(
size
);
tag_stream
->
write_3bytes
((
int32_t
)
timestamp
);
// default to little-endian
...
...
@@ -188,18 +189,19 @@ int SrsFlvEncoder::write_video(int64_t timestamp, char* data, int size)
timestamp
&=
0x7fffffff
;
// 11bytes tag header
char
tag_header
[]
=
{
/*
char tag_header[] = {
(char)SrsCodecFlvTagVideo, // TagType UB [5], 9 = video
(char)0x00, (char)0x00, (char)0x00, // DataSize UI24 Length of the message.
(char)0x00, (char)0x00, (char)0x00, // Timestamp UI24 Time in milliseconds at which the data in this tag applies.
(char)0x00, // TimestampExtended UI8
(char)0x00, (char)0x00, (char)0x00, // StreamID UI24 Always 0.
};
};
*/
// write data size.
if
((
ret
=
tag_stream
->
initialize
(
tag_header
+
1
,
7
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
tag_stream
->
initialize
(
tag_header
,
8
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
tag_stream
->
write_1bytes
(
SrsCodecFlvTagVideo
);
tag_stream
->
write_3bytes
(
size
);
tag_stream
->
write_3bytes
((
int32_t
)
timestamp
);
// default to little-endian
...
...
trunk/src/kernel/srs_kernel_flv.hpp
查看文件 @
8a9dbae
...
...
@@ -35,6 +35,9 @@ class SrsStream;
class
SrsFileWriter
;
class
SrsFileReader
;
#define SRS_FLV_TAG_HEADER_SIZE 11
#define SRS_FLV_PREVIOUS_TAG_SIZE 4
/**
* encode data to flv file.
*/
...
...
@@ -44,6 +47,7 @@ private:
SrsFileWriter
*
_fs
;
private
:
SrsStream
*
tag_stream
;
char
tag_header
[
SRS_FLV_TAG_HEADER_SIZE
];
public
:
SrsFlvEncoder
();
virtual
~
SrsFlvEncoder
();
...
...
请
注册
或
登录
后发表评论