mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
refine hls m3u8, use LR(0x0a, \n) as new line char
This commit is contained in:
parent
81ea6d34ce
commit
693c7a5349
3 changed files with 25 additions and 14 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -201,6 +201,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define SRS_CONSTS_RTMP_SET_DATAFRAME "@setDataFrame"
|
||||
#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
|
||||
///////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in a new issue