From 80c01eae0de48deb4493a3ca0c6b395cf2c7dba6 Mon Sep 17 00:00:00 2001 From: dreamer Date: Fri, 11 Mar 2022 02:28:31 +0100 Subject: [PATCH] added multiple comma-separated push targets in on_publish http callback --- ngx_rtmp_notify_module.c | 46 ++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/ngx_rtmp_notify_module.c b/ngx_rtmp_notify_module.c index dd65e4991..b877a1b18 100644 --- a/ngx_rtmp_notify_module.c +++ b/ngx_rtmp_notify_module.c @@ -1057,23 +1057,41 @@ 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; + + while (start != NULL) { + next = (u_char *) ngx_strchr(start, ','); + + 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 = &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 */ + u->default_port = 1935; + u->uri_part = 1; + u->no_resolve = 1; /* want ip here */ - 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_log_error(NGX_LOG_ERR, s->connection->log, 0, + "notify: processing push '%V'", &u->url); - ngx_rtmp_relay_push(s, &local_name, &target); + 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); + } next: