mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-17 00:51:09 +02:00
Upsate:
- fix memory allocation for URL string - fix code pass in AMF
This commit is contained in:
parent
139c8c2773
commit
3497601b6b
|
@ -1059,10 +1059,22 @@ ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s,
|
|||
if (nacf->send_redirect) {
|
||||
// Send 302 redirect and go next
|
||||
|
||||
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"notify: send 302 redirect for stream '%s' to new location '%*s'", v->name, rc, name);
|
||||
|
||||
ngx_rtmp_send_redirect_status("Publish here", name);
|
||||
local_name.data = ngx_palloc(s->connection->pool, rc);
|
||||
local_name.len = rc;
|
||||
*ngx_cpymem(local_name.data, name, rc) = 0;
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"notify: check redirect to location: '%s'", local_name.data);
|
||||
|
||||
ngx_rtmp_send_redirect_status(s, "Publish here", local_name);
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"notify: release location memory");
|
||||
|
||||
ngx_pfree(s->connection->pool, local_name.data);
|
||||
|
||||
goto next;
|
||||
|
||||
|
@ -1072,7 +1084,7 @@ ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s,
|
|||
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,
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"notify: push '%s' to '%*s'", v->name, rc, name);
|
||||
|
||||
local_name.data = v->name;
|
||||
|
|
|
@ -491,7 +491,7 @@ ngx_rtmp_create_status(ngx_rtmp_session_t *s, char *code, char* level,
|
|||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
ngx_null_string,
|
||||
ngx_string("info"),
|
||||
out_inf,
|
||||
sizeof(out_inf) },
|
||||
};
|
||||
|
@ -597,16 +597,24 @@ ngx_rtmp_send_play_status(ngx_rtmp_session_t *s, char *code, char* level,
|
|||
// ----------- Based on Adobe FMS 3 application.redirectConnection description --------- //
|
||||
|
||||
ngx_chain_t *
|
||||
ngx_rtmp_create_redirect_status(ngx_rtmp_session_t *s, char *desc, char *to_url)
|
||||
ngx_rtmp_create_redirect_status(ngx_rtmp_session_t *s, char *desc, ngx_str_t to_url)
|
||||
{
|
||||
ngx_rtmp_header_t h;
|
||||
static double trans;
|
||||
static double dcode;
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_inf_ex[] = {
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"create redirect status: got data");
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"create redirect status: status code='%s' level='%s' "
|
||||
"ex.code=%ui ex.redirect='%s'",
|
||||
"NetConnection.Connect.Rejected", "Error", 302, to_url.data);
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
static ngx_rtmp_amf_elt_t out_inf_ex_data[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_string("code"),
|
||||
NULL, 0 },
|
||||
&dcode, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_string("redirect"),
|
||||
|
@ -629,8 +637,8 @@ ngx_rtmp_create_redirect_status(ngx_rtmp_session_t *s, char *desc, char *to_url)
|
|||
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
ngx_string("ex"),
|
||||
out_inf_ex,
|
||||
sizeof(out_inf_ex) },
|
||||
out_inf_ex_data,
|
||||
sizeof(out_inf_ex_data) },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
@ -648,21 +656,19 @@ ngx_rtmp_create_redirect_status(ngx_rtmp_session_t *s, char *desc, char *to_url)
|
|||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
ngx_null_string,
|
||||
ngx_string("info"),
|
||||
out_inf,
|
||||
sizeof(out_inf) },
|
||||
};
|
||||
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"create: status code='%s' level='%s' "
|
||||
"ex.code='%s' ex.redirect='%s'",
|
||||
"NetConnection.Connect.Rejected", "Error", "302", to_url);
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"create redirect status: set structure data");
|
||||
|
||||
out_inf[0].data = "NetConnection.Connect.Rejected";
|
||||
out_inf[1].data = "Error";
|
||||
out_inf[2].data = desc;
|
||||
out_inf_ex[0].data = "302";
|
||||
out_inf_ex[1].data = to_url;
|
||||
dcode = 302;
|
||||
out_inf_ex_data[1].data = to_url.data;
|
||||
|
||||
memset(&h, 0, sizeof(h));
|
||||
|
||||
|
@ -677,7 +683,7 @@ ngx_rtmp_create_redirect_status(ngx_rtmp_session_t *s, char *desc, char *to_url)
|
|||
|
||||
ngx_int_t
|
||||
ngx_rtmp_send_redirect_status(ngx_rtmp_session_t *s,
|
||||
char *desc, char *to_url)
|
||||
char *desc, ngx_str_t to_url)
|
||||
{
|
||||
return ngx_rtmp_send_shared_packet(s,
|
||||
ngx_rtmp_create_redirect_status(s, desc, to_url));
|
||||
|
|
Loading…
Reference in a new issue