正在显示
3 个修改的文件
包含
15 行增加
和
5 行删除
| @@ -253,7 +253,7 @@ class RESTDvrs(object): | @@ -253,7 +253,7 @@ class RESTDvrs(object): | ||
| 253 | return json.dumps(dvrs) | 253 | return json.dumps(dvrs) |
| 254 | 254 | ||
| 255 | ''' | 255 | ''' |
| 256 | - for SRS hook: on_dvr, on_dvr_reap_segment | 256 | + for SRS hook: on_dvr, |
| 257 | on_dvr: | 257 | on_dvr: |
| 258 | when srs reap a dvr file, call the hook, | 258 | when srs reap a dvr file, call the hook, |
| 259 | the request in the POST data string is a object encode by json: | 259 | the request in the POST data string is a object encode by json: |
| @@ -346,7 +346,7 @@ class RESTHls(object): | @@ -346,7 +346,7 @@ class RESTHls(object): | ||
| 346 | return json.dumps(hls) | 346 | return json.dumps(hls) |
| 347 | 347 | ||
| 348 | ''' | 348 | ''' |
| 349 | - for SRS hook: on_dvr, on_dvr_reap_segment | 349 | + for SRS hook: on, on_dvr_reap_segment |
| 350 | on_dvr: | 350 | on_dvr: |
| 351 | when srs reap a dvr file, call the hook, | 351 | when srs reap a dvr file, call the hook, |
| 352 | the request in the POST data string is a object encode by json: | 352 | the request in the POST data string is a object encode by json: |
| @@ -177,6 +177,7 @@ SrsHlsMuxer::SrsHlsMuxer() | @@ -177,6 +177,7 @@ SrsHlsMuxer::SrsHlsMuxer() | ||
| 177 | hls_aof_ratio = 1.0; | 177 | hls_aof_ratio = 1.0; |
| 178 | hls_fragment_deviation = 0; | 178 | hls_fragment_deviation = 0; |
| 179 | previous_floor_ts = 0; | 179 | previous_floor_ts = 0; |
| 180 | + accept_floor_ts = 0; | ||
| 180 | hls_ts_floor = false; | 181 | hls_ts_floor = false; |
| 181 | target_duration = 0; | 182 | target_duration = 0; |
| 182 | _sequence_no = 0; | 183 | _sequence_no = 0; |
| @@ -244,6 +245,7 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, | @@ -244,6 +245,7 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, | ||
| 244 | hls_aof_ratio = aof_ratio; | 245 | hls_aof_ratio = aof_ratio; |
| 245 | hls_ts_floor = ts_floor; | 246 | hls_ts_floor = ts_floor; |
| 246 | previous_floor_ts = 0; | 247 | previous_floor_ts = 0; |
| 248 | + accept_floor_ts = 0; | ||
| 247 | hls_window = window; | 249 | hls_window = window; |
| 248 | // for the first time, we set to -N% of fragment, | 250 | // for the first time, we set to -N% of fragment, |
| 249 | // that is, the first piece always smaller. | 251 | // that is, the first piece always smaller. |
| @@ -331,18 +333,25 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) | @@ -331,18 +333,25 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) | ||
| 331 | std::string ts_file = hls_ts_file; | 333 | std::string ts_file = hls_ts_file; |
| 332 | ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream); | 334 | ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream); |
| 333 | if (hls_ts_floor) { | 335 | if (hls_ts_floor) { |
| 336 | + // accept the floor ts for the first piece. | ||
| 337 | + int64_t floor_ts = (int64_t)(srs_get_system_time_ms() / (1000 * hls_fragment)); | ||
| 338 | + if (!accept_floor_ts) { | ||
| 339 | + accept_floor_ts = floor_ts - 1; | ||
| 340 | + } else { | ||
| 341 | + accept_floor_ts++; | ||
| 342 | + } | ||
| 343 | + | ||
| 334 | // we always ensure the piece is increase one by one. | 344 | // we always ensure the piece is increase one by one. |
| 335 | std::stringstream ts_floor; | 345 | std::stringstream ts_floor; |
| 336 | - ts_floor << (int64_t)(previous_floor_ts + 1); | 346 | + ts_floor << accept_floor_ts; |
| 337 | ts_file = srs_string_replace(ts_file, "[timestamp]", ts_floor.str()); | 347 | ts_file = srs_string_replace(ts_file, "[timestamp]", ts_floor.str()); |
| 338 | 348 | ||
| 339 | // dup/jmp detect for ts in floor mode. | 349 | // dup/jmp detect for ts in floor mode. |
| 340 | - int64_t floor_ts = (int64_t)(srs_get_system_time_ms() / (1000 * hls_fragment)); | ||
| 341 | if (previous_floor_ts && previous_floor_ts != floor_ts - 1) { | 350 | if (previous_floor_ts && previous_floor_ts != floor_ts - 1) { |
| 342 | srs_warn("hls: dup or jmp for floor ts, previous=%"PRId64", current=%"PRId64", ts=%s, deviation=%.2f", | 351 | srs_warn("hls: dup or jmp for floor ts, previous=%"PRId64", current=%"PRId64", ts=%s, deviation=%.2f", |
| 343 | previous_floor_ts, floor_ts, ts_file.c_str(), hls_fragment_deviation); | 352 | previous_floor_ts, floor_ts, ts_file.c_str(), hls_fragment_deviation); |
| 344 | } | 353 | } |
| 345 | - previous_floor_ts++; | 354 | + previous_floor_ts = floor_ts; |
| 346 | } | 355 | } |
| 347 | ts_file = srs_path_build_timestamp(ts_file); | 356 | ts_file = srs_path_build_timestamp(ts_file); |
| 348 | if (true) { | 357 | if (true) { |
| @@ -182,6 +182,7 @@ private: | @@ -182,6 +182,7 @@ private: | ||
| 182 | double hls_fragment_deviation; | 182 | double hls_fragment_deviation; |
| 183 | // the previous reap floor timestamp, | 183 | // the previous reap floor timestamp, |
| 184 | // used to detect the dup or jmp or ts. | 184 | // used to detect the dup or jmp or ts. |
| 185 | + int64_t accept_floor_ts; | ||
| 185 | int64_t previous_floor_ts; | 186 | int64_t previous_floor_ts; |
| 186 | private: | 187 | private: |
| 187 | int _sequence_no; | 188 | int _sequence_no; |
-
请 注册 或 登录 后发表评论