mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
enhanced hls, warning when ts dup or jmp.
This commit is contained in:
parent
9be7fbba7d
commit
b9c21b1e8f
2 changed files with 14 additions and 1 deletions
|
@ -176,6 +176,7 @@ SrsHlsMuxer::SrsHlsMuxer()
|
|||
hls_fragment = hls_window = 0;
|
||||
hls_aof_ratio = 1.0;
|
||||
hls_fragment_deviation = 0;
|
||||
previous_floor_ts = 0;
|
||||
hls_ts_floor = false;
|
||||
target_duration = 0;
|
||||
_sequence_no = 0;
|
||||
|
@ -242,6 +243,7 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix,
|
|||
hls_fragment = fragment;
|
||||
hls_aof_ratio = aof_ratio;
|
||||
hls_ts_floor = ts_floor;
|
||||
previous_floor_ts = 0;
|
||||
hls_window = window;
|
||||
// for the first time, we set to -N% of fragment,
|
||||
// that is, the first piece always smaller.
|
||||
|
@ -329,9 +331,17 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
|
|||
std::string ts_file = hls_ts_file;
|
||||
ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream);
|
||||
if (hls_ts_floor) {
|
||||
int64_t floor_ts = (int64_t)(srs_get_system_time_ms() / (1000 * hls_fragment));
|
||||
std::stringstream ts_floor;
|
||||
ts_floor << (int64_t)(srs_get_system_time_ms() / (1000 * hls_fragment));
|
||||
ts_floor << floor_ts;
|
||||
ts_file = srs_string_replace(ts_file, "[timestamp]", ts_floor.str());
|
||||
|
||||
// dup/jmp detect for ts in floor mode.
|
||||
if (previous_floor_ts && previous_floor_ts != floor_ts - 1) {
|
||||
srs_warn("hls: dup or jmp for floor ts, previous=%"PRId64", current=%"PRId64", ts=%s, deviation=%.2f",
|
||||
previous_floor_ts, floor_ts, ts_file.c_str(), hls_fragment_deviation);
|
||||
}
|
||||
previous_floor_ts = floor_ts;
|
||||
}
|
||||
ts_file = srs_path_build_timestamp(ts_file);
|
||||
if (true) {
|
||||
|
|
|
@ -180,6 +180,9 @@ private:
|
|||
// the deviation in seconds to adjust the fragment to be more
|
||||
// bigger or smaller.
|
||||
double hls_fragment_deviation;
|
||||
// the previous reap floor timestamp,
|
||||
// used to detect the dup or jmp or ts.
|
||||
int64_t previous_floor_ts;
|
||||
private:
|
||||
int _sequence_no;
|
||||
int target_duration;
|
||||
|
|
Loading…
Reference in a new issue