Write ENDLIST tag on stream end

This commit is contained in:
Laura Hausmann 2022-02-06 02:24:36 +01:00
parent 8e344d7994
commit e73d44f0fb
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -529,7 +529,7 @@ ngx_rtmp_hls_write_variant_playlist(ngx_rtmp_session_t *s)
static ngx_int_t
ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s, int final)
{
static u_char buffer[1024];
ngx_fd_t fd;
@ -687,6 +687,15 @@ ngx_rtmp_hls_write_playlist(ngx_rtmp_session_t *s)
}
}
if (final)
{
p = ngx_slprintf(p, end, "#EXT-X-ENDLIST\n");
n = ngx_write_fd(fd, buffer, p - buffer);
if (n < 0) {
goto write_err;
}
}
ngx_close_file(fd);
if (ngx_rtmp_hls_rename_file(ctx->playlist_bak.data, ctx->playlist.data)
@ -967,7 +976,7 @@ ngx_rtmp_hls_get_fragment_datetime(ngx_rtmp_session_t *s, uint64_t ts)
static ngx_int_t
ngx_rtmp_hls_close_fragment(ngx_rtmp_session_t *s)
ngx_rtmp_hls_close_final_fragment(ngx_rtmp_session_t *s, int final)
{
ngx_rtmp_hls_ctx_t *ctx;
@ -985,12 +994,19 @@ ngx_rtmp_hls_close_fragment(ngx_rtmp_session_t *s)
ngx_rtmp_hls_next_frag(s);
ngx_rtmp_hls_write_playlist(s);
ngx_rtmp_hls_write_playlist(s, final);
return NGX_OK;
}
static ngx_int_t
ngx_rtmp_hls_close_fragment(ngx_rtmp_session_t *s)
{
return ngx_rtmp_hls_close_final_fragment(s, 0);
}
static ngx_int_t
ngx_rtmp_hls_open_fragment(ngx_rtmp_session_t *s, uint64_t ts,
ngx_int_t discont)
@ -1651,7 +1667,7 @@ ngx_rtmp_hls_close_stream(ngx_rtmp_session_t *s, ngx_rtmp_close_stream_t *v)
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"hls: close stream");
ngx_rtmp_hls_close_fragment(s);
ngx_rtmp_hls_close_final_fragment(s, 1);
next:
return next_close_stream(s, v);