mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-06-01 06:09:32 +02:00
Fixes:
- fix first fragment search - fix log output for discontinuety flag
This commit is contained in:
parent
998de2937a
commit
a88bc39141
|
@ -39,8 +39,8 @@ typedef struct {
|
||||||
uint64_t key_id;
|
uint64_t key_id;
|
||||||
ngx_str_t *datetime;
|
ngx_str_t *datetime;
|
||||||
double duration;
|
double duration;
|
||||||
unsigned active:1;
|
u_char active; /* small int, 0/1 */
|
||||||
unsigned discont:1; /* before */
|
u_char discont; /* small int, 0/1 */
|
||||||
} ngx_rtmp_hls_frag_t;
|
} ngx_rtmp_hls_frag_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ typedef struct {
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned opened:1;
|
u_char opened; /* small int, 0/1 */
|
||||||
|
|
||||||
ngx_rtmp_mpegts_file_t file;
|
ngx_rtmp_mpegts_file_t file;
|
||||||
|
|
||||||
|
@ -534,7 +534,8 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
ngx_rtmp_hls_app_conf_t *hacf;
|
ngx_rtmp_hls_app_conf_t *hacf;
|
||||||
ngx_rtmp_hls_frag_t *f;
|
ngx_rtmp_hls_frag_t *f;
|
||||||
ngx_uint_t i, start_i, max_frag;
|
ngx_int_t i, start_i;
|
||||||
|
ngx_uint_t max_frag;
|
||||||
double fragments_length;
|
double fragments_length;
|
||||||
ngx_str_t name_part, key_name_part;
|
ngx_str_t name_part, key_name_part;
|
||||||
uint64_t prev_key_id;
|
uint64_t prev_key_id;
|
||||||
|
@ -558,6 +559,8 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
max_frag = hacf->fraglen / 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to check fragments length sum and playlist max length
|
* Need to check fragments length sum and playlist max length
|
||||||
* Do backward search
|
* Do backward search
|
||||||
|
@ -569,7 +572,12 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
|
||||||
if (f->duration) {
|
if (f->duration) {
|
||||||
fragments_length += f->duration;
|
fragments_length += f->duration;
|
||||||
}
|
}
|
||||||
if (fragments_length >= hacf->playlen/1000.) {
|
/**
|
||||||
|
* Think that sum of frag length is more than playlist disired length - half minimal frag length
|
||||||
|
* XXX: sometimes sum of frag lengths are almost playlist length
|
||||||
|
* but key-frames come at random rate...
|
||||||
|
*/
|
||||||
|
if (fragments_length >= hacf->playlen/1000. - max_frag/2) {
|
||||||
start_i = i;
|
start_i = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -578,8 +586,6 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||||
"hls: found starting fragment=%i", start_i);
|
"hls: found starting fragment=%i", start_i);
|
||||||
|
|
||||||
max_frag = hacf->fraglen / 1000;
|
|
||||||
|
|
||||||
for (i = start_i; i < ctx->nfrags; i++) {
|
for (i = start_i; i < ctx->nfrags; i++) {
|
||||||
f = ngx_rtmp_hls_get_frag(s, i);
|
f = ngx_rtmp_hls_get_frag(s, i);
|
||||||
if (f->duration > max_frag) {
|
if (f->duration > max_frag) {
|
||||||
|
@ -669,7 +675,7 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
|
||||||
ngx_log_debug5(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
ngx_log_debug5(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||||
"hls: fragment frag=%uL, n=%ui/%ui, duration=%.3f, "
|
"hls: fragment frag=%uL, n=%ui/%ui, duration=%.3f, "
|
||||||
"discont=%i",
|
"discont=%i",
|
||||||
ctx->frag, i + 1, ctx->nfrags, f->duration, f->discont);
|
ctx->frag, i + 1, ctx->nfrags, f->duration, (ngx_int_t)f->discont);
|
||||||
|
|
||||||
n = ngx_write_fd(fd, buffer, p - buffer);
|
n = ngx_write_fd(fd, buffer, p - buffer);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
|
|
Loading…
Reference in a new issue