From 40eab7fc886d550f24d4bd02d98bea65175c69b4 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 13 Apr 2015 11:45:08 +0800 Subject: [PATCH 1/3] for #381, refine the deviation for hls. --- trunk/src/app/srs_app_hls.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 9eccccda2..49e8762e2 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -60,9 +60,9 @@ using namespace std; #define SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS 100 // fragment plus the deviation percent. -#define SRS_HLS_FLOOR_REAP_PERCENT 0.2 +#define SRS_HLS_FLOOR_REAP_PERCENT 0.3 // reset the piece id when deviation overflow this. -#define SRS_JUMP_WHEN_PIECE_DEVIATION 10 +#define SRS_JUMP_WHEN_PIECE_DEVIATION 20 ISrsHlsHandler::ISrsHlsHandler() { @@ -441,7 +441,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream); if (hls_ts_floor) { // accept the floor ts for the first piece. - int64_t current_floor_ts = (int64_t)(srs_get_system_time_ms() / (1000 * hls_fragment)); + int64_t current_floor_ts = (int64_t)(srs_update_system_time_ms() / (1000 * hls_fragment)); if (!accept_floor_ts) { accept_floor_ts = current_floor_ts - 1; } else { @@ -459,7 +459,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) // dup/jmp detect for ts in floor mode. if (previous_floor_ts && previous_floor_ts != current_floor_ts - 1) { - srs_warn("hls: dup or jmp for floor ts, previous=%"PRId64", current=%"PRId64", accept=%"PRId64", deviation=%d", + srs_warn("hls: dup/jmp ts, previous=%"PRId64", current=%"PRId64", accept=%"PRId64", deviation=%d", previous_floor_ts, current_floor_ts, accept_floor_ts, deviation_ts); } previous_floor_ts = current_floor_ts; @@ -540,6 +540,8 @@ bool SrsHlsMuxer::is_segment_overflow() // use N% deviation, to smoother. double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0; + srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f", + current->duration, hls_fragment + deviation, deviation, deviation_ts, hls_fragment); return current->duration >= hls_fragment + deviation; } From a4216cc5828a84bc37d8f076c2f7e17767f9e57a Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 13 Apr 2015 16:40:31 +0800 Subject: [PATCH 2/3] add todo for ts parse. --- trunk/src/app/srs_app_mpegts_udp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_mpegts_udp.cpp b/trunk/src/app/srs_app_mpegts_udp.cpp index 94e2488b0..9691a74f5 100644 --- a/trunk/src/app/srs_app_mpegts_udp.cpp +++ b/trunk/src/app/srs_app_mpegts_udp.cpp @@ -419,7 +419,10 @@ int SrsMpegtsOverUdp::write_h264_sps_pps(u_int32_t dts, u_int32_t pts) { int ret = ERROR_SUCCESS; - // only send when both sps and pps changed. + // TODO: FIMXE: there exists bug, see following comments. + // when sps or pps changed, update the sequence header, + // for the pps maybe not changed while sps changed. + // so, we must check when each video ts message frame parsed. if (!h264_sps_changed || !h264_pps_changed) { return ret; } From 02a2cb7e1a3b9f2b049eabc4fa2b115091af563f Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 14 Apr 2015 11:36:58 +0800 Subject: [PATCH 3/3] for #381, refine the hls notify, report one by one. --- trunk/conf/full.conf | 1 + trunk/src/app/srs_app_hls.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index ed31509bd..b0c883939 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -794,6 +794,7 @@ vhost hooks.callback.srs.com { # [stream], replace with the stream. # [ts_url], replace with the ts url. # ignore any return data of server. + # @remark random select a url to report, not report all. on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream][ts_url]; } } diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 49e8762e2..2a2387b7c 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -240,13 +240,17 @@ int SrsDvrAsyncCallOnHlsNotify::call() return ret; } + std::string url; + if (true) { + static u_int32_t nb_call = 0; + int index = nb_call++ % on_hls->args.size(); + url = on_hls->args.at(index); + } + int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost); - for (int i = 0; i < (int)on_hls->args.size(); i++) { - std::string url = on_hls->args.at(i); - if ((ret = SrsHttpHooks::on_hls_notify(url, req, ts_url, nb_notify)) != ERROR_SUCCESS) { - srs_error("hook client on_hls_notify failed. url=%s, ts=%s, ret=%d", url.c_str(), ts_url.c_str(), ret); - return ret; - } + if ((ret = SrsHttpHooks::on_hls_notify(url, req, ts_url, nb_notify)) != ERROR_SUCCESS) { + srs_error("hook client on_hls_notify failed. url=%s, ts=%s, ret=%d", url.c_str(), ts_url.c_str(), ret); + return ret; } } #endif