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-02-10 11:38:14 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
693c7a5349612a0ae12c16b085c95454e43d6fca
693c7a53
1 parent
81ea6d34
refine hls m3u8, use LR(0x0a, \n) as new line char
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
25 行增加
和
14 行删除
trunk/src/app/srs_app_hls.cpp
trunk/src/app/srs_app_http.hpp
trunk/src/kernel/srs_kernel_consts.hpp
trunk/src/app/srs_app_hls.cpp
查看文件 @
693c7a5
...
...
@@ -506,13 +506,13 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
// #EXTM3U\n#EXT-X-VERSION:3\n
char
header
[]
=
{
// #EXTM3U\n
0x23
,
0x45
,
0x58
,
0x54
,
0x4d
,
0x33
,
0x55
,
0xa
,
0x23
,
0x45
,
0x58
,
0x54
,
0x4d
,
0x33
,
0x55
,
SRS_CONSTS_LF
,
// #EXT-X-VERSION:3\n
0x23
,
0x45
,
0x58
,
0x54
,
0x2d
,
0x58
,
0x2d
,
0x56
,
0x45
,
0x52
,
0x53
,
0x49
,
0x4f
,
0x4e
,
0x3a
,
0x33
,
0xa
,
// #EXT-X-ALLOW-CACHE:NO
0x53
,
0x49
,
0x4f
,
0x4e
,
0x3a
,
0x33
,
SRS_CONSTS_LF
,
// #EXT-X-ALLOW-CACHE:NO\n
0x23
,
0x45
,
0x58
,
0x54
,
0x2d
,
0x58
,
0x2d
,
0x41
,
0x4c
,
0x4c
,
0x4f
,
0x57
,
0x2d
,
0x43
,
0x41
,
0x43
,
0x48
,
0x45
,
0x3a
,
0x4e
,
0x4f
,
0x0a
0x4f
,
0x57
,
0x2d
,
0x43
,
0x41
,
0x43
,
0x48
,
0x45
,
0x3a
,
0x4e
,
0x4f
,
SRS_CONSTS_LF
};
if
((
ret
=
writer
.
write
(
header
,
sizeof
(
header
),
NULL
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"write m3u8 header failed. ret=%d"
,
ret
);
...
...
@@ -523,7 +523,7 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
// #EXT-X-MEDIA-SEQUENCE:4294967295\n
SrsHlsSegment
*
first
=
*
segments
.
begin
();
char
sequence
[
34
]
=
{};
int
len
=
snprintf
(
sequence
,
sizeof
(
sequence
),
"#EXT-X-MEDIA-SEQUENCE:%d
\n
"
,
first
->
sequence_no
);
int
len
=
snprintf
(
sequence
,
sizeof
(
sequence
),
"#EXT-X-MEDIA-SEQUENCE:%d
%c"
,
first
->
sequence_no
,
SRS_CONSTS_LF
);
if
((
ret
=
writer
.
write
(
sequence
,
len
,
NULL
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"write m3u8 sequence failed. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -540,7 +540,7 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
// TODO: maybe need to take an around value
target_duration
+=
1
;
char
duration
[
34
];
// 23+10+1
len
=
snprintf
(
duration
,
sizeof
(
duration
),
"#EXT-X-TARGETDURATION:%d
\n
"
,
target_duration
);
len
=
snprintf
(
duration
,
sizeof
(
duration
),
"#EXT-X-TARGETDURATION:%d
%c"
,
target_duration
,
SRS_CONSTS_LF
);
if
((
ret
=
writer
.
write
(
duration
,
len
,
NULL
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"write m3u8 duration failed. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -554,7 +554,7 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
if
(
segment
->
is_sequence_header
)
{
// #EXT-X-DISCONTINUITY\n
char
ext_discon
[
22
];
// 21+1
len
=
snprintf
(
ext_discon
,
sizeof
(
ext_discon
),
"#EXT-X-DISCONTINUITY
\n
"
);
len
=
snprintf
(
ext_discon
,
sizeof
(
ext_discon
),
"#EXT-X-DISCONTINUITY
%c"
,
SRS_CONSTS_LF
);
if
((
ret
=
writer
.
write
(
ext_discon
,
len
,
NULL
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"write m3u8 segment discontinuity failed. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -564,16 +564,16 @@ int SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
// "#EXTINF:4294967295.208,\n"
char
ext_info
[
25
];
// 14+10+1
len
=
snprintf
(
ext_info
,
sizeof
(
ext_info
),
"#EXTINF:%.3f,
\n
"
,
segment
->
duration
);
len
=
snprintf
(
ext_info
,
sizeof
(
ext_info
),
"#EXTINF:%.3f,
%c"
,
segment
->
duration
,
SRS_CONSTS_LF
);
if
((
ret
=
writer
.
write
(
ext_info
,
len
,
NULL
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"write m3u8 segment info failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"write m3u8 segment info success."
);
//
file name
//
{file name}\n
std
::
string
filename
=
segment
->
uri
;
filename
+=
"
\n
"
;
filename
+=
SRS_CONSTS_LF
;
if
((
ret
=
writer
.
write
((
char
*
)
filename
.
c_str
(),
(
int
)
filename
.
length
(),
NULL
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"write m3u8 segment uri failed. ret=%d"
,
ret
);
return
ret
;
...
...
trunk/src/app/srs_app_http.hpp
查看文件 @
693c7a5
...
...
@@ -51,13 +51,13 @@ class ISrsGoHttpResponseWriter;
// http specification
// CR = <US-ASCII CR, carriage return (13)>
#define __SRS_CR
"\r"
// 0x0D
#define __SRS_CR
SRS_CONSTS_CR
// 0x0D
// LF = <US-ASCII LF, linefeed (10)>
#define __SRS_LF
"\n"
// 0x0A
#define __SRS_LF
SRS_CONSTS_LF
// 0x0A
// SP = <US-ASCII SP, space (32)>
#define __SRS_SP
" "
// 0x20
#define __SRS_SP
' '
// 0x20
// HT = <US-ASCII HT, horizontal-tab (9)>
#define __SRS_HT
"\x09"
// 0x09
#define __SRS_HT
'\x09'
// 0x09
// HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all
// protocol elements except the entity-body (see appendix 19.3 for
...
...
trunk/src/kernel/srs_kernel_consts.hpp
查看文件 @
693c7a5
...
...
@@ -202,6 +202,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONSTS_RTMP_ON_METADATA "onMetaData"
///////////////////////////////////////////////////////////
// HTTP/HLS consts values
///////////////////////////////////////////////////////////
// @see hls-m3u8-draft-pantos-http-live-streaming-12.pdf, page 4
// Lines are terminated by either a single LF character or a CR
// character followed by an LF character.
// CR = <US-ASCII CR, carriage return (13)>
#define SRS_CONSTS_CR '\r' // 0x0D
// LF = <US-ASCII LF, linefeed (10)>
#define SRS_CONSTS_LF '\n' // 0x0A
///////////////////////////////////////////////////////////
// HTTP consts values
///////////////////////////////////////////////////////////
// linux path seprator
...
...
请
注册
或
登录
后发表评论