mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Merge branch '2.0release' into develop
This commit is contained in:
commit
70c1d3cc7e
3 changed files with 21 additions and 11 deletions
|
@ -794,6 +794,7 @@ vhost hooks.callback.srs.com {
|
||||||
# [stream], replace with the stream.
|
# [stream], replace with the stream.
|
||||||
# [ts_url], replace with the ts url.
|
# [ts_url], replace with the ts url.
|
||||||
# ignore any return data of server.
|
# 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];
|
on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream][ts_url];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,9 @@ using namespace std;
|
||||||
#define SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS 100
|
#define SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS 100
|
||||||
|
|
||||||
// fragment plus the deviation percent.
|
// 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.
|
// reset the piece id when deviation overflow this.
|
||||||
#define SRS_JUMP_WHEN_PIECE_DEVIATION 10
|
#define SRS_JUMP_WHEN_PIECE_DEVIATION 20
|
||||||
|
|
||||||
ISrsHlsHandler::ISrsHlsHandler()
|
ISrsHlsHandler::ISrsHlsHandler()
|
||||||
{
|
{
|
||||||
|
@ -240,13 +240,17 @@ int SrsDvrAsyncCallOnHlsNotify::call()
|
||||||
return ret;
|
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);
|
int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost);
|
||||||
for (int i = 0; i < (int)on_hls->args.size(); i++) {
|
if ((ret = SrsHttpHooks::on_hls_notify(url, req, ts_url, nb_notify)) != ERROR_SUCCESS) {
|
||||||
std::string url = on_hls->args.at(i);
|
srs_error("hook client on_hls_notify failed. url=%s, ts=%s, ret=%d", url.c_str(), ts_url.c_str(), ret);
|
||||||
if ((ret = SrsHttpHooks::on_hls_notify(url, req, ts_url, nb_notify)) != ERROR_SUCCESS) {
|
return ret;
|
||||||
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
|
#endif
|
||||||
|
@ -441,7 +445,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
|
||||||
ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream);
|
ts_file = srs_path_build_stream(ts_file, req->vhost, req->app, req->stream);
|
||||||
if (hls_ts_floor) {
|
if (hls_ts_floor) {
|
||||||
// accept the floor ts for the first piece.
|
// 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) {
|
if (!accept_floor_ts) {
|
||||||
accept_floor_ts = current_floor_ts - 1;
|
accept_floor_ts = current_floor_ts - 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -459,7 +463,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
|
||||||
|
|
||||||
// dup/jmp detect for ts in floor mode.
|
// dup/jmp detect for ts in floor mode.
|
||||||
if (previous_floor_ts && previous_floor_ts != current_floor_ts - 1) {
|
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, accept_floor_ts, deviation_ts);
|
||||||
}
|
}
|
||||||
previous_floor_ts = current_floor_ts;
|
previous_floor_ts = current_floor_ts;
|
||||||
|
@ -540,6 +544,8 @@ bool SrsHlsMuxer::is_segment_overflow()
|
||||||
|
|
||||||
// use N% deviation, to smoother.
|
// use N% deviation, to smoother.
|
||||||
double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
|
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;
|
return current->duration >= hls_fragment + deviation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,7 +419,10 @@ int SrsMpegtsOverUdp::write_h264_sps_pps(u_int32_t dts, u_int32_t pts)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
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) {
|
if (!h264_sps_changed || !h264_pps_changed) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue