Skip to content

Commit

Permalink
hls+ keep alive
Browse files Browse the repository at this point in the history
  • Loading branch information
im-pingo committed Oct 20, 2019
1 parent d2476b6 commit 483fd1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions mpegts/ngx_hls_http_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ ngx_hls_http_send_header(ngx_http_request_t *r, ngx_uint_t status, ngx_keyval_t
ngx_int_t rc;

r->headers_out.status = status;
r->keepalive = 0; /* set Connection to closed */
// r->keepalive = 0; /* set Connection to closed */

//set eTag
if (ngx_http_set_etag(r) != NGX_OK) {
Expand Down Expand Up @@ -342,7 +342,8 @@ ngx_hls_http_master_m3u8_handler(ngx_http_request_t *r,

m3u8->last = ngx_snprintf(m3u8->pos, m3u8->end - m3u8->start,
"#EXTM3U\n"
"#EXT-X-STREAM-INF:BANDWIDTH=1280000,AVERAGE-BANDWIDTH=1000000\n"
"#EXT-X-STREAM-INF:BANDWIDTH=1,AVERAGE-BANDWIDTH=1\n"
//"#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1\n"
"%V\n", &m3u8_url);

r->headers_out.content_length_n = m3u8->last - m3u8->pos;
Expand Down Expand Up @@ -955,6 +956,8 @@ ngx_hls_http_write_handler(ngx_http_request_t *r)
if (wev->active) {
ngx_del_event(wev, NGX_WRITE_EVENT, 0);
}

ngx_http_finalize_request(r, NGX_HTTP_OK);
}

static ngx_int_t
Expand Down Expand Up @@ -1143,6 +1146,8 @@ ngx_hls_http_m3u8(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, ngx_chain_t *in)
return rc;
}

ngx_http_finalize_request(r, NGX_HTTP_OK);

return NGX_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions mpegts/ngx_hls_live_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ ngx_hls_live_update_playlist(ngx_rtmp_session_t *s)

p = ngx_slprintf(p, end,
"#EXTINF:%.3f,\n"
"%V%V-%uL.ts?session=%V\n",
"%V%V-%uL.ts?session=%V&slot=%d\n",
frag->duration, &hacf->base_url,
&name_part, frag->id, &ctx->sid);
&name_part, frag->id, &ctx->sid, ngx_process_slot);

ngx_log_debug5(NGX_LOG_DEBUG_RTMP, s->log, 0,
"hls: fragment nfrag=%uL, n=%ui/%ui, duration=%.3f, "
Expand Down

0 comments on commit 483fd1c

Please sign in to comment.