mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-19 17:41:08 +02:00
skipped on_publish/access/record for auto-pushed connections
This commit is contained in:
parent
b960e68a0b
commit
dd19680ed9
|
@ -205,6 +205,9 @@ typedef struct {
|
||||||
unsigned ping_active:1;
|
unsigned ping_active:1;
|
||||||
unsigned ping_reset:1;
|
unsigned ping_reset:1;
|
||||||
|
|
||||||
|
/* auto-pushed? */
|
||||||
|
unsigned auto_pushed:1;
|
||||||
|
|
||||||
/* input stream 0 (reserved by RTMP spec)
|
/* input stream 0 (reserved by RTMP spec)
|
||||||
* is used as free chain link */
|
* is used as free chain link */
|
||||||
|
|
||||||
|
|
|
@ -400,10 +400,15 @@ ngx_rtmp_access_rule(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_rtmp_access_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
ngx_rtmp_access_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
||||||
{
|
{
|
||||||
|
if (s->auto_pushed) {
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
|
||||||
if (ngx_rtmp_access(s, NGX_RTMP_ACCESS_PUBLISH) != NGX_OK) {
|
if (ngx_rtmp_access(s, NGX_RTMP_ACCESS_PUBLISH) != NGX_OK) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next:
|
||||||
return next_publish(s, v);
|
return next_publish(s, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ typedef struct ngx_rtmp_auto_push_ctx_s ngx_rtmp_auto_push_ctx_t;
|
||||||
struct ngx_rtmp_auto_push_ctx_s {
|
struct ngx_rtmp_auto_push_ctx_s {
|
||||||
ngx_int_t *slots; /* NGX_MAX_PROCESSES */
|
ngx_int_t *slots; /* NGX_MAX_PROCESSES */
|
||||||
ngx_str_t name;
|
ngx_str_t name;
|
||||||
|
ngx_str_t args;
|
||||||
ngx_event_t push_evt;
|
ngx_event_t push_evt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,7 +89,6 @@ ngx_module_t ngx_rtmp_auto_push_module = {
|
||||||
|
|
||||||
|
|
||||||
#define NGX_RTMP_AUTO_PUSH_SOCKNAME "nginx-rtmp"
|
#define NGX_RTMP_AUTO_PUSH_SOCKNAME "nginx-rtmp"
|
||||||
#define NGX_RTMP_AUTO_PUSH_PAGEURL "nginx-auto-push"
|
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
|
@ -296,8 +296,9 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
|
||||||
ngx_int_t n;
|
ngx_int_t n;
|
||||||
ngx_rtmp_relay_target_t at;
|
ngx_rtmp_relay_target_t at;
|
||||||
u_char path[sizeof("unix:") + NGX_MAX_PATH];
|
u_char path[sizeof("unix:") + NGX_MAX_PATH];
|
||||||
u_char flash_ver[sizeof("APSH.") + 2
|
u_char flash_ver[sizeof("APSH ,") +
|
||||||
+ NGX_OFF_T_LEN * 2];
|
NGX_OFF_T_LEN * 2];
|
||||||
|
u_char play_path[NGX_RTMP_MAX_NAME];
|
||||||
u_char *p;
|
u_char *p;
|
||||||
ngx_str_t *u;
|
ngx_str_t *u;
|
||||||
ngx_pid_t pid;
|
ngx_pid_t pid;
|
||||||
|
@ -313,9 +314,16 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_memzero(&at, sizeof(at));
|
ngx_memzero(&at, sizeof(at));
|
||||||
ngx_str_set(&at.page_url, NGX_RTMP_AUTO_PUSH_PAGEURL);
|
ngx_str_set(&at.page_url, "nginx-auto-push");
|
||||||
at.tag = &ngx_rtmp_auto_push_module;
|
at.tag = &ngx_rtmp_auto_push_module;
|
||||||
|
|
||||||
|
if (ctx->args.len) {
|
||||||
|
at.play_path.data = play_path;
|
||||||
|
at.play_path.len = ngx_snprintf(play_path, sizeof(play_path),
|
||||||
|
"%V?%V", &ctx->name, &ctx->args) -
|
||||||
|
play_path;
|
||||||
|
}
|
||||||
|
|
||||||
slot = ctx->slots;
|
slot = ctx->slots;
|
||||||
|
|
||||||
for (n = 0; n < NGX_MAX_PROCESSES; ++n, ++slot) {
|
for (n = 0; n < NGX_MAX_PROCESSES; ++n, ++slot) {
|
||||||
|
@ -350,7 +358,7 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ngx_snprintf(flash_ver, sizeof(flash_ver) - 1, "APSH,%i,%i",
|
p = ngx_snprintf(flash_ver, sizeof(flash_ver) - 1, "APSH %i,%i",
|
||||||
(ngx_int_t) ngx_process_slot, (ngx_int_t) ngx_pid);
|
(ngx_int_t) ngx_process_slot, (ngx_int_t) ngx_pid);
|
||||||
at.flash_ver.data = flash_ver;
|
at.flash_ver.data = flash_ver;
|
||||||
at.flash_ver.len = p - flash_ver;
|
at.flash_ver.len = p - flash_ver;
|
||||||
|
@ -383,17 +391,13 @@ ngx_rtmp_auto_push_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
||||||
ngx_rtmp_auto_push_conf_t *apcf;
|
ngx_rtmp_auto_push_conf_t *apcf;
|
||||||
ngx_rtmp_auto_push_ctx_t *ctx;
|
ngx_rtmp_auto_push_ctx_t *ctx;
|
||||||
|
|
||||||
apcf = (ngx_rtmp_auto_push_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx,
|
if (s->auto_pushed) {
|
||||||
ngx_rtmp_auto_push_module);
|
|
||||||
if (apcf->auto_push == 0) {
|
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* auto-push from another worker? */
|
apcf = (ngx_rtmp_auto_push_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx,
|
||||||
if (s->page_url.len == sizeof(NGX_RTMP_AUTO_PUSH_PAGEURL) - 1 &&
|
ngx_rtmp_auto_push_module);
|
||||||
ngx_memcmp(s->page_url.data, NGX_RTMP_AUTO_PUSH_PAGEURL,
|
if (apcf->auto_push == 0) {
|
||||||
s->page_url.len) == 0)
|
|
||||||
{
|
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,6 +430,13 @@ ngx_rtmp_auto_push_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
||||||
}
|
}
|
||||||
ngx_memcpy(ctx->name.data, v->name, ctx->name.len);
|
ngx_memcpy(ctx->name.data, v->name, ctx->name.len);
|
||||||
|
|
||||||
|
ctx->args.len = ngx_strlen(v->args);
|
||||||
|
ctx->args.data = ngx_palloc(s->connection->pool, ctx->args.len);
|
||||||
|
if (ctx->args.data == NULL) {
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
ngx_memcpy(ctx->args.data, v->args, ctx->args.len);
|
||||||
|
|
||||||
ngx_rtmp_auto_push_reconnect(&ctx->push_evt);
|
ngx_rtmp_auto_push_reconnect(&ctx->push_evt);
|
||||||
|
|
||||||
next:
|
next:
|
||||||
|
|
|
@ -20,6 +20,7 @@ ngx_rtmp_init_connection(ngx_connection_t *c)
|
||||||
ngx_rtmp_in_addr_t *addr;
|
ngx_rtmp_in_addr_t *addr;
|
||||||
ngx_rtmp_session_t *s;
|
ngx_rtmp_session_t *s;
|
||||||
ngx_rtmp_addr_conf_t *addr_conf;
|
ngx_rtmp_addr_conf_t *addr_conf;
|
||||||
|
ngx_int_t unix_socket;
|
||||||
#if (NGX_HAVE_INET6)
|
#if (NGX_HAVE_INET6)
|
||||||
struct sockaddr_in6 *sin6;
|
struct sockaddr_in6 *sin6;
|
||||||
ngx_rtmp_in6_addr_t *addr6;
|
ngx_rtmp_in6_addr_t *addr6;
|
||||||
|
@ -31,6 +32,7 @@ ngx_rtmp_init_connection(ngx_connection_t *c)
|
||||||
/* AF_INET only */
|
/* AF_INET only */
|
||||||
|
|
||||||
port = c->listening->servers;
|
port = c->listening->servers;
|
||||||
|
unix_socket = 0;
|
||||||
|
|
||||||
if (port->naddrs > 1) {
|
if (port->naddrs > 1) {
|
||||||
|
|
||||||
|
@ -70,6 +72,9 @@ ngx_rtmp_init_connection(ngx_connection_t *c)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
case AF_UNIX:
|
||||||
|
unix_socket = 1;
|
||||||
|
|
||||||
default: /* AF_INET */
|
default: /* AF_INET */
|
||||||
sin = (struct sockaddr_in *) sa;
|
sin = (struct sockaddr_in *) sa;
|
||||||
|
|
||||||
|
@ -98,6 +103,9 @@ ngx_rtmp_init_connection(ngx_connection_t *c)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
case AF_UNIX:
|
||||||
|
unix_socket = 1;
|
||||||
|
|
||||||
default: /* AF_INET */
|
default: /* AF_INET */
|
||||||
addr = port->addrs;
|
addr = port->addrs;
|
||||||
addr_conf = &addr[0].conf;
|
addr_conf = &addr[0].conf;
|
||||||
|
@ -105,11 +113,15 @@ ngx_rtmp_init_connection(ngx_connection_t *c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, 0, "*%ui client connected",
|
/*ngx_log_error(NGX_LOG_INFO, c->log, 0, "*%ui client connected",
|
||||||
c->number, &c->addr_text);
|
c->number, &c->addr_text);*/
|
||||||
|
|
||||||
s = ngx_rtmp_init_session(c, addr_conf);
|
s = ngx_rtmp_init_session(c, addr_conf);
|
||||||
|
|
||||||
|
/* only auto-pushed connections are
|
||||||
|
* done through unix socket */
|
||||||
|
s->auto_pushed = unix_socket;
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
ngx_rtmp_handshake(s);
|
ngx_rtmp_handshake(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,6 +442,10 @@ ngx_rtmp_notify_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
||||||
ngx_rtmp_notify_app_conf_t *nacf;
|
ngx_rtmp_notify_app_conf_t *nacf;
|
||||||
ngx_rtmp_netcall_init_t ci;
|
ngx_rtmp_netcall_init_t ci;
|
||||||
|
|
||||||
|
if (s->auto_pushed) {
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
|
||||||
nacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_notify_module);
|
nacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_notify_module);
|
||||||
if (nacf == NULL) {
|
if (nacf == NULL) {
|
||||||
goto next;
|
goto next;
|
||||||
|
|
|
@ -302,6 +302,10 @@ ngx_rtmp_record_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
||||||
ngx_rtmp_record_app_conf_t *racf;
|
ngx_rtmp_record_app_conf_t *racf;
|
||||||
ngx_rtmp_record_ctx_t *ctx;
|
ngx_rtmp_record_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (s->auto_pushed) {
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
|
||||||
racf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_record_module);
|
racf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_record_module);
|
||||||
|
|
||||||
if (racf == NULL || racf->flags & NGX_RTMP_RECORD_OFF) {
|
if (racf == NULL || racf->flags & NGX_RTMP_RECORD_OFF) {
|
||||||
|
|
Loading…
Reference in a new issue