From 0bfbd6b39f5bc603bf58efb0f13595926b270ca6 Mon Sep 17 00:00:00 2001 From: Sergey Dryabzhinsky Date: Wed, 20 Apr 2016 09:27:34 +0300 Subject: [PATCH] Forgot to commit main redirect code --- ngx_rtmp_notify_module.c | 47 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/ngx_rtmp_notify_module.c b/ngx_rtmp_notify_module.c index d370bc1..e75c52c 100644 --- a/ngx_rtmp_notify_module.c +++ b/ngx_rtmp_notify_module.c @@ -1428,14 +1428,57 @@ ngx_rtmp_notify_play_handle(ngx_rtmp_session_t *s, if (ngx_strncasecmp(name, (u_char *) "rtmp://", 7)) { *ngx_cpymem(v->name, name, rc) = 0; ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, - "notify: play redirect to '%s'", v->name); + "notify: play internal redirect to '%s'", v->name); goto next; } /* pull */ nacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_notify_module); - if (nacf->relay_redirect) { + if (nacf->send_redirect) { + // Send 302 redirect and go next + + ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, + "notify: play send 302 redirect"); + ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, + "notify: -- for stream '%s' to new location '%*s'", v->name, rc, name); + + local_name.data = ngx_palloc(s->connection->pool, rc+1); + local_name.len = rc; + *ngx_cpymem(local_name.data, name, rc) = 0; + + /* MAGICK HERE */ + + if (!ngx_strncasecmp(s->flashver.data, (u_char *) "FMLE/", 5)) { + // Official method, by FMS SDK + send = ngx_rtmp_send_redirect_status(s, "onStatus", "Connect here", local_name); + send &= ngx_rtmp_send_redirect_status(s, "netStatus", "Connect here", local_name); + + ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, + "notify: play send(o) status = '%ui'", send == NGX_OK); + } else { + + // Something by rtmpdump lib + send = ngx_rtmp_send_redirect_status(s, "_error", "Connect here", local_name); + + ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, + "notify: play send(e) status = '%ui'", send == NGX_OK); + } + + ngx_pfree(s->connection->pool, local_name.data); + + ngx_rtmp_notify_clear_flag(s, NGX_RTMP_NOTIFY_PLAYING); + + // Something by rtmpdump lib + send = ngx_rtmp_send_close_method(s, "close"); + ngx_log_error(NGX_LOG_INFO, s->connection->log, 0, + "notify: play send(e) close method = '%ui'", send == NGX_OK); + + return send; + + } else if (nacf->relay_redirect) { + // Relay local streams, change name + ngx_rtmp_notify_set_name(v->name, NGX_RTMP_MAX_NAME, name, (size_t) rc); }