From 3b7ada66772f910ebecd671981b9a40e70bf6a4c Mon Sep 17 00:00:00 2001 From: jthomas Date: Mon, 17 Sep 2018 02:32:51 -0400 Subject: [PATCH] added multiple comma-separated push targets in on_publish http callback --- ngx_rtmp_notify_module.c | 47 ++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/ngx_rtmp_notify_module.c b/ngx_rtmp_notify_module.c index 04ee64a..8c112ac 100644 --- a/ngx_rtmp_notify_module.c +++ b/ngx_rtmp_notify_module.c @@ -1434,24 +1434,43 @@ ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s, local_name.data = v->name; local_name.len = ngx_strlen(v->name); - ngx_memzero(&target, sizeof(target)); + u_char *start = name; + u_char *next; - u = &target.url; - u->url = local_name; - u->url.data = name + 7; - u->url.len = rc - 7; - u->default_port = 1935; - u->uri_part = 1; - u->no_resolve = 1; /* want ip here */ + while (start != NULL) { + next = (u_char *) ngx_strchr(start, ','); - if (ngx_parse_url(s->connection->pool, u) != NGX_OK) { - ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, - "notify: push failed '%V'", &local_name); - return NGX_ERROR; + ngx_memzero(&target, sizeof(target)); + u = &target.url; + u->url = local_name; + + if (next) { + u->url.data = start + 7; + u->url.len = next - start - 7; + start = next + 1; + } else { + u->url.data = start + 7; + u->url.len = rc - (start - name) - 7; + start = NULL; + } + + + u->default_port = 1935; + u->uri_part = 1; + u->no_resolve = 1; /* want ip here */ + + ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, + "notify: processing push '%V'", &u->url); + + if (ngx_parse_url(s->connection->pool, u) != NGX_OK) { + ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, + "notify: push failed '%V'", &local_name); + return NGX_ERROR; + } + + ngx_rtmp_relay_push(s, &local_name, &target); } - ngx_rtmp_relay_push(s, &local_name, &target); - next: return next_publish(s, v);