winlin

Merge branch '2.0release' into develop

@@ -794,6 +794,7 @@ vhost hooks.callback.srs.com { @@ -794,6 +794,7 @@ vhost hooks.callback.srs.com {
794 # [stream], replace with the stream. 794 # [stream], replace with the stream.
795 # [ts_url], replace with the ts url. 795 # [ts_url], replace with the ts url.
796 # ignore any return data of server. 796 # ignore any return data of server.
  797 + # @remark random select a url to report, not report all.
797 on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream][ts_url]; 798 on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream][ts_url];
798 } 799 }
799 } 800 }
@@ -60,9 +60,9 @@ using namespace std; @@ -60,9 +60,9 @@ using namespace std;
60 #define SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS 100 60 #define SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS 100
61 61
62 // fragment plus the deviation percent. 62 // fragment plus the deviation percent.
63 -#define SRS_HLS_FLOOR_REAP_PERCENT 0.2 63 +#define SRS_HLS_FLOOR_REAP_PERCENT 0.3
64 // reset the piece id when deviation overflow this. 64 // reset the piece id when deviation overflow this.
65 -#define SRS_JUMP_WHEN_PIECE_DEVIATION 10 65 +#define SRS_JUMP_WHEN_PIECE_DEVIATION 20
66 66
67 ISrsHlsHandler::ISrsHlsHandler() 67 ISrsHlsHandler::ISrsHlsHandler()
68 { 68 {
@@ -240,15 +240,19 @@ int SrsDvrAsyncCallOnHlsNotify::call() @@ -240,15 +240,19 @@ int SrsDvrAsyncCallOnHlsNotify::call()
240 return ret; 240 return ret;
241 } 241 }
242 242
  243 + std::string url;
  244 + if (true) {
  245 + static u_int32_t nb_call = 0;
  246 + int index = nb_call++ % on_hls->args.size();
  247 + url = on_hls->args.at(index);
  248 + }
  249 +
243 int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost); 250 int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost);
244 - for (int i = 0; i < (int)on_hls->args.size(); i++) {  
245 - std::string url = on_hls->args.at(i);  
246 if ((ret = SrsHttpHooks::on_hls_notify(url, req, ts_url, nb_notify)) != ERROR_SUCCESS) { 251 if ((ret = SrsHttpHooks::on_hls_notify(url, req, ts_url, nb_notify)) != ERROR_SUCCESS) {
247 srs_error("hook client on_hls_notify failed. url=%s, ts=%s, ret=%d", url.c_str(), ts_url.c_str(), ret); 252 srs_error("hook client on_hls_notify failed. url=%s, ts=%s, ret=%d", url.c_str(), ts_url.c_str(), ret);
248 return ret; 253 return ret;
249 } 254 }
250 } 255 }
251 - }  
252 #endif 256 #endif
253 257
254 return ret; 258 return ret;
@@ -441,7 +445,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) @@ -441,7 +445,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
441 ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream); 445 ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream);
442 if (hls_ts_floor) { 446 if (hls_ts_floor) {
443 // accept the floor ts for the first piece. 447 // accept the floor ts for the first piece.
444 - int64_t current_floor_ts = (int64_t)(srs_get_system_time_ms() / (1000 * hls_fragment)); 448 + int64_t current_floor_ts = (int64_t)(srs_update_system_time_ms() / (1000 * hls_fragment));
445 if (!accept_floor_ts) { 449 if (!accept_floor_ts) {
446 accept_floor_ts = current_floor_ts - 1; 450 accept_floor_ts = current_floor_ts - 1;
447 } else { 451 } else {
@@ -459,7 +463,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) @@ -459,7 +463,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
459 463
460 // dup/jmp detect for ts in floor mode. 464 // dup/jmp detect for ts in floor mode.
461 if (previous_floor_ts && previous_floor_ts != current_floor_ts - 1) { 465 if (previous_floor_ts && previous_floor_ts != current_floor_ts - 1) {
462 - srs_warn("hls: dup or jmp for floor ts, previous=%"PRId64", current=%"PRId64", accept=%"PRId64", deviation=%d", 466 + srs_warn("hls: dup/jmp ts, previous=%"PRId64", current=%"PRId64", accept=%"PRId64", deviation=%d",
463 previous_floor_ts, current_floor_ts, accept_floor_ts, deviation_ts); 467 previous_floor_ts, current_floor_ts, accept_floor_ts, deviation_ts);
464 } 468 }
465 previous_floor_ts = current_floor_ts; 469 previous_floor_ts = current_floor_ts;
@@ -540,6 +544,8 @@ bool SrsHlsMuxer::is_segment_overflow() @@ -540,6 +544,8 @@ bool SrsHlsMuxer::is_segment_overflow()
540 544
541 // use N% deviation, to smoother. 545 // use N% deviation, to smoother.
542 double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0; 546 double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
  547 + srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f",
  548 + current->duration, hls_fragment + deviation, deviation, deviation_ts, hls_fragment);
543 549
544 return current->duration >= hls_fragment + deviation; 550 return current->duration >= hls_fragment + deviation;
545 } 551 }
@@ -419,7 +419,10 @@ int SrsMpegtsOverUdp::write_h264_sps_pps(u_int32_t dts, u_int32_t pts) @@ -419,7 +419,10 @@ int SrsMpegtsOverUdp::write_h264_sps_pps(u_int32_t dts, u_int32_t pts)
419 { 419 {
420 int ret = ERROR_SUCCESS; 420 int ret = ERROR_SUCCESS;
421 421
422 - // only send when both sps and pps changed. 422 + // TODO: FIMXE: there exists bug, see following comments.
  423 + // when sps or pps changed, update the sequence header,
  424 + // for the pps maybe not changed while sps changed.
  425 + // so, we must check when each video ts message frame parsed.
423 if (!h264_sps_changed || !h264_pps_changed) { 426 if (!h264_sps_changed || !h264_pps_changed) {
424 return ret; 427 return ret;
425 } 428 }