mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-20 09:51:08 +02:00
Merge branch 'master' into control-redirect
This commit is contained in:
commit
ee55c21b4c
|
@ -741,7 +741,7 @@ ngx_rtmp_hls_get_fragment_id(ngx_rtmp_session_t *s, uint64_t ts)
|
|||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_hls_close_fragment(ngx_rtmp_session_t *s, ngx_int_t discont)
|
||||
ngx_rtmp_hls_close_fragment(ngx_rtmp_session_t *s)
|
||||
{
|
||||
ngx_rtmp_hls_ctx_t *ctx;
|
||||
|
||||
|
@ -750,9 +750,8 @@ ngx_rtmp_hls_close_fragment(ngx_rtmp_session_t *s, ngx_int_t discont)
|
|||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"hls: close fragment n=%uL, discont=%i",
|
||||
ctx->frag, discont);
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"hls: close fragment n=%uL", ctx->frag);
|
||||
|
||||
ngx_close_file(ctx->file.fd);
|
||||
|
||||
|
@ -1269,9 +1268,9 @@ 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: delete stream");
|
||||
"hls: close stream");
|
||||
|
||||
ngx_rtmp_hls_close_fragment(s, 1);
|
||||
ngx_rtmp_hls_close_fragment(s);
|
||||
|
||||
next:
|
||||
return next_close_stream(s, v);
|
||||
|
@ -1394,7 +1393,7 @@ ngx_rtmp_hls_update_fragment(ngx_rtmp_session_t *s, uint64_t ts,
|
|||
}
|
||||
|
||||
if (boundary) {
|
||||
ngx_rtmp_hls_close_fragment(s, 0);
|
||||
ngx_rtmp_hls_close_fragment(s);
|
||||
ngx_rtmp_hls_open_fragment(s, ts, !f);
|
||||
}
|
||||
|
||||
|
@ -1480,7 +1479,7 @@ ngx_rtmp_hls_audio(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
}
|
||||
|
||||
if (codec_ctx->audio_codec_id != NGX_RTMP_AUDIO_AAC ||
|
||||
codec_ctx->aac_header == NULL)
|
||||
codec_ctx->aac_header == NULL || ngx_rtmp_is_codec_header(in))
|
||||
{
|
||||
return NGX_OK;
|
||||
}
|
||||
|
@ -1797,11 +1796,12 @@ ngx_rtmp_hls_video(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
/*
|
||||
* start new fragment if
|
||||
* - we have video key frame AND
|
||||
* - we have audio buffered or have no audio at all
|
||||
* - we have audio buffered or have no audio at all or stream is closed
|
||||
*/
|
||||
|
||||
b = ctx->aframe;
|
||||
boundary = frame.key && (codec_ctx->aac_header == NULL || b->last > b->pos);
|
||||
boundary = frame.key && (codec_ctx->aac_header == NULL || !ctx->opened ||
|
||||
(b && b->last > b->pos));
|
||||
|
||||
ngx_rtmp_hls_update_fragment(s, frame.dts, boundary, 1);
|
||||
|
||||
|
@ -1823,30 +1823,9 @@ ngx_rtmp_hls_video(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_rtmp_hls_discontinue(ngx_rtmp_session_t *s)
|
||||
{
|
||||
ngx_rtmp_hls_ctx_t *ctx;
|
||||
|
||||
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_hls_module);
|
||||
|
||||
if (ctx == NULL || !ctx->opened) {
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"hld: discontinue");
|
||||
|
||||
ngx_close_file(ctx->file.fd);
|
||||
ctx->opened = 0;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_hls_stream_begin(ngx_rtmp_session_t *s, ngx_rtmp_stream_begin_t *v)
|
||||
{
|
||||
ngx_rtmp_hls_discontinue(s);
|
||||
|
||||
return next_stream_begin(s, v);
|
||||
}
|
||||
|
||||
|
@ -1854,7 +1833,9 @@ ngx_rtmp_hls_stream_begin(ngx_rtmp_session_t *s, ngx_rtmp_stream_begin_t *v)
|
|||
static ngx_int_t
|
||||
ngx_rtmp_hls_stream_eof(ngx_rtmp_session_t *s, ngx_rtmp_stream_eof_t *v)
|
||||
{
|
||||
ngx_rtmp_hls_discontinue(s);
|
||||
ngx_rtmp_hls_flush_audio(s);
|
||||
|
||||
ngx_rtmp_hls_close_fragment(s);
|
||||
|
||||
return next_stream_eof(s, v);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
|
|||
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||
ngx_rtmp_auto_push_conf_t *apcf;
|
||||
ngx_listening_t *ls, *lss;
|
||||
struct sockaddr_un *sun;
|
||||
struct sockaddr_un *saun;
|
||||
int reuseaddr;
|
||||
ngx_socket_t s;
|
||||
size_t n;
|
||||
|
@ -157,26 +157,26 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
|
|||
ls->addr_ntop = 0;
|
||||
|
||||
ls->socklen = sizeof(struct sockaddr_un);
|
||||
sun = ngx_pcalloc(cycle->pool, ls->socklen);
|
||||
ls->sockaddr = (struct sockaddr *) sun;
|
||||
saun = ngx_pcalloc(cycle->pool, ls->socklen);
|
||||
ls->sockaddr = (struct sockaddr *) saun;
|
||||
if (ls->sockaddr == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
sun->sun_family = AF_UNIX;
|
||||
*ngx_snprintf((u_char *) sun->sun_path, sizeof(sun->sun_path),
|
||||
saun->sun_family = AF_UNIX;
|
||||
*ngx_snprintf((u_char *) saun->sun_path, sizeof(saun->sun_path),
|
||||
"%V/" NGX_RTMP_AUTO_PUSH_SOCKNAME ".%i",
|
||||
&apcf->socket_dir, ngx_process_slot)
|
||||
= 0;
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, cycle->log, 0,
|
||||
"auto_push: create socket '%s'",
|
||||
sun->sun_path);
|
||||
saun->sun_path);
|
||||
|
||||
if (ngx_file_info(sun->sun_path, &fi) != ENOENT) {
|
||||
if (ngx_file_info(saun->sun_path, &fi) != ENOENT) {
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, cycle->log, 0,
|
||||
"auto_push: delete existing socket '%s'",
|
||||
sun->sun_path);
|
||||
ngx_delete_file(sun->sun_path);
|
||||
saun->sun_path);
|
||||
ngx_delete_file(saun->sun_path);
|
||||
}
|
||||
|
||||
ngx_str_set(&ls->addr_text, "worker_socket");
|
||||
|
@ -205,7 +205,7 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
|
|||
}
|
||||
}
|
||||
|
||||
if (bind(s, (struct sockaddr *) sun, sizeof(*sun)) == -1) {
|
||||
if (bind(s, (struct sockaddr *) saun, sizeof(*saun)) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
|
||||
ngx_nonblocking_n " worker_socket bind failed");
|
||||
goto sock_error;
|
||||
|
@ -228,7 +228,7 @@ sock_error:
|
|||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
|
||||
ngx_close_socket_n " worker_socket failed");
|
||||
}
|
||||
ngx_delete_file(sun->sun_path);
|
||||
ngx_delete_file(saun->sun_path);
|
||||
|
||||
return NGX_ERROR;
|
||||
|
||||
|
|
|
@ -1235,7 +1235,9 @@ ngx_rtmp_exec_close_stream(ngx_rtmp_session_t *s, ngx_rtmp_close_stream_t *v)
|
|||
if (ctx->flags & NGX_RTMP_EXEC_PUBLISHING) {
|
||||
ngx_rtmp_exec_unmanaged(s, &eacf->conf[NGX_RTMP_EXEC_PUBLISH_DONE],
|
||||
"publish_done");
|
||||
} else {
|
||||
}
|
||||
|
||||
if (ctx->flags & NGX_RTMP_EXEC_PLAYING) {
|
||||
ngx_rtmp_exec_unmanaged(s, &eacf->conf[NGX_RTMP_EXEC_PLAY_DONE],
|
||||
"play_done");
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_md5.h>
|
||||
#include "ngx_rtmp.h"
|
||||
#include "ngx_rtmp_cmd_module.h"
|
||||
#include "ngx_rtmp_netcall_module.h"
|
||||
|
@ -979,6 +980,22 @@ ngx_rtmp_notify_connect_handle(ngx_rtmp_session_t *s,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_rtmp_notify_set_name(u_char *dst, size_t dst_len, u_char *src,
|
||||
size_t src_len)
|
||||
{
|
||||
u_char result[16], *p;
|
||||
ngx_md5_t md5;
|
||||
|
||||
ngx_md5_init(&md5);
|
||||
ngx_md5_update(&md5, src, src_len);
|
||||
ngx_md5_final(result, &md5);
|
||||
|
||||
p = ngx_hex_dump(dst, result, ngx_min((dst_len - 1) / 2, 16));
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s,
|
||||
void *arg, ngx_chain_t *in)
|
||||
|
@ -1025,7 +1042,7 @@ ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s,
|
|||
|
||||
nacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_notify_module);
|
||||
if (nacf->relay_redirect) {
|
||||
*ngx_cpymem(v->name, name, rc) = 0;
|
||||
ngx_rtmp_notify_set_name(v->name, NGX_RTMP_MAX_NAME, name, (size_t) rc);
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
|
||||
|
@ -1104,7 +1121,7 @@ ngx_rtmp_notify_play_handle(ngx_rtmp_session_t *s,
|
|||
|
||||
nacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_notify_module);
|
||||
if (nacf->relay_redirect) {
|
||||
*ngx_cpymem(v->name, name, rc) = 0;
|
||||
ngx_rtmp_notify_set_name(v->name, NGX_RTMP_MAX_NAME, name, (size_t) rc);
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
|
|
|
@ -255,7 +255,7 @@ ngx_rtmp_stat_bw(ngx_http_request_t *r, ngx_chain_t ***lll,
|
|||
ngx_rtmp_bandwidth_t *bw, char *name,
|
||||
ngx_uint_t flags)
|
||||
{
|
||||
u_char buf[NGX_INT64_LEN + 1];
|
||||
u_char buf[NGX_INT64_LEN + 9];
|
||||
|
||||
ngx_rtmp_update_bandwidth(bw, 0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue