1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 11:21:52 +00:00

HLS: Refine sequence no.

This commit is contained in:
chundonglinlin 2023-04-28 10:41:15 +08:00
parent 1668ba705c
commit 635bb139a2

View file

@ -407,16 +407,13 @@ srs_error_t SrsHlsMuxer::restore_stream()
if ((err = fr.read(fbuf, nb_fbuf, NULL)) != srs_success) {
return srs_error_wrap(err, "read data");
}
fr.close();
std::string body(fbuf, nb_fbuf);
// parse
std::string body(fbuf, nb_fbuf);
if (body.empty()) {
return srs_error_wrap(err, "read empty m3u8");
}
int sequence_num = 0;
srs_utime_t max_target_duration = 0;
bool discon = false;
@ -455,7 +452,7 @@ srs_error_t SrsHlsMuxer::restore_stream()
// #EXT-X-MEDIA-SEQUENCE:4294967295
// the media sequence no.
if (srs_string_starts_with(line, "#EXT-X-MEDIA-SEQUENCE:")) {
sequence_num = ::atof(line.substr(string("#EXT-X-MEDIA-SEQUENCE:").length()).c_str());
_sequence_no = ::atof(line.substr(string("#EXT-X-MEDIA-SEQUENCE:").length()).c_str());
}
// #EXT-X-TARGETDURATION:12
@ -531,7 +528,7 @@ srs_error_t SrsHlsMuxer::restore_stream()
// new segment.
SrsHlsSegment* seg = new SrsHlsSegment(context, default_acodec, default_vcodec, writer);
seg->sequence_no = sequence_num++;
seg->sequence_no = _sequence_no++;
seg->set_path(hls_path + "/" + req->app + "/" + ts_url);
seg->uri = ts_url;
seg->set_sequence_header(discon);