fixed on_record_done; fixed notification inheritance; fixed logging

This commit is contained in:
Roman Arutyunyan 2012-09-22 14:46:03 +04:00
parent 9aff59fc43
commit cdb084e375
3 changed files with 19 additions and 62 deletions

View file

@ -201,13 +201,18 @@ static ngx_rtmp_eval_t * ngx_rtmp_enotify_eval_p[] = {
static void *
ngx_rtmp_enotify_create_app_conf(ngx_conf_t *cf)
{
ngx_rtmp_enotify_app_conf_t *enacf;
ngx_rtmp_enotify_app_conf_t *enacf;
ngx_uint_t n;
enacf = ngx_pcalloc(cf->pool, sizeof(ngx_rtmp_enotify_app_conf_t));
if (enacf == NULL) {
return NULL;
}
for (n = 0; n < NGX_RTMP_ENOTIFY_MAX; ++n) {
enacf->event[n] = NGX_CONF_UNSET_PTR;
}
return enacf;
}
@ -220,7 +225,7 @@ ngx_rtmp_enotify_merge_app_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_uint_t n;
for (n = 0; n < NGX_RTMP_ENOTIFY_MAX; ++n) {
ngx_conf_merge_ptr_value(conf->event[n], prev->event[n], 0);
ngx_conf_merge_ptr_value(conf->event[n], prev->event[n], NULL);
if (conf->event[n]) {
conf->active = 1;
}

View file

@ -142,13 +142,18 @@ ngx_module_t ngx_rtmp_notify_module = {
static void *
ngx_rtmp_notify_create_app_conf(ngx_conf_t *cf)
{
ngx_rtmp_notify_app_conf_t *nacf;
ngx_rtmp_notify_app_conf_t *nacf;
ngx_uint_t n;
nacf = ngx_pcalloc(cf->pool, sizeof(ngx_rtmp_notify_app_conf_t));
if (nacf == NULL) {
return NULL;
}
for (n = 0; n < NGX_RTMP_NOTIFY_MAX; ++n) {
nacf->url[n] = NGX_CONF_UNSET_PTR;
}
return nacf;
}
@ -161,7 +166,7 @@ ngx_rtmp_notify_merge_app_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_uint_t n;
for (n = 0; n < NGX_RTMP_NOTIFY_MAX; ++n) {
ngx_conf_merge_ptr_value(conf->url[n], prev->url[n], 0);
ngx_conf_merge_ptr_value(conf->url[n], prev->url[n], NULL);
if (conf->url[n]) {
conf->active = 1;
}
@ -484,7 +489,8 @@ ngx_rtmp_notify_record_done_create(ngx_rtmp_session_t *s, void *arg,
}
/* HTTP header */
hl = ngx_rtmp_netcall_http_format_header(nacf->url[NGX_RTMP_NOTIFY_RECORD_DONE],
hl = ngx_rtmp_netcall_http_format_header(
nacf->url[NGX_RTMP_NOTIFY_RECORD_DONE],
pool, cl->buf->last - cl->buf->pos + (pl->buf->last - pl->buf->pos),
&ngx_rtmp_netcall_content_type_urlencoded);
@ -617,7 +623,7 @@ ngx_rtmp_notify_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: publish '%V'",
&nacf->url[NGX_RTMP_NOTIFY_PUBLISH]);
&nacf->url[NGX_RTMP_NOTIFY_PUBLISH]->url);
ngx_memzero(&ci, sizeof(ci));
@ -658,7 +664,7 @@ ngx_rtmp_notify_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: play '%V'",
&nacf->url[NGX_RTMP_NOTIFY_PLAY]);
&nacf->url[NGX_RTMP_NOTIFY_PLAY]->url);
ngx_memzero(&ci, sizeof(ci));
@ -741,7 +747,7 @@ ngx_rtmp_notify_record_done(ngx_rtmp_session_t *s, ngx_rtmp_record_done_t *v)
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: record_done recorder=%V path='%V' url='%V'",
&v->recorder, &v->path,
&nacf->url[NGX_RTMP_NOTIFY_RECORD_DONE]);
&nacf->url[NGX_RTMP_NOTIFY_RECORD_DONE]->url);
ngx_memzero(&ci, sizeof(ci));

View file

@ -21,8 +21,6 @@ static ngx_rtmp_delete_stream_pt next_delete_stream;
static char *ngx_rtmp_record_recorder(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char * ngx_rtmp_notify_on_record_done(ngx_conf_t *cf,
ngx_command_t *cmd, void *conf);
static ngx_int_t ngx_rtmp_record_postconfiguration(ngx_conf_t *cf);
static void * ngx_rtmp_record_create_app_conf(ngx_conf_t *cf);
static char * ngx_rtmp_record_merge_app_conf(ngx_conf_t *cf,
@ -113,14 +111,6 @@ static ngx_command_t ngx_rtmp_record_commands[] = {
offsetof(ngx_rtmp_record_app_conf_t, interval),
NULL },
{ ngx_string("on_record_done"),
NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|
NGX_RTMP_REC_CONF|NGX_CONF_TAKE1,
ngx_rtmp_notify_on_record_done,
NGX_RTMP_APP_CONF_OFFSET,
0,
NULL },
{ ngx_string("recorder"),
NGX_RTMP_APP_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE1,
ngx_rtmp_record_recorder,
@ -863,50 +853,6 @@ ngx_rtmp_record_done_init(ngx_rtmp_session_t *s, ngx_rtmp_record_done_t *v)
}
static char *
ngx_rtmp_notify_on_record_done(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_rtmp_record_app_conf_t *racf;
ngx_str_t *url;
ngx_url_t *u;
size_t add;
ngx_str_t *value;
value = cf->args->elts;
url = &value[1];
add = 0;
u = ngx_pcalloc(cf->pool, sizeof(ngx_url_t));
if (u == NULL) {
return NGX_CONF_ERROR;
}
if (ngx_strncasecmp(url->data, (u_char *) "http://", 7) == 0) {
add = 7;
}
u->url.len = url->len - add;
u->url.data = url->data + add;
u->default_port = 80;
u->uri_part = 1;
if (ngx_parse_url(cf->pool, u) != NGX_OK) {
if (u->err) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"%s in url \"%V\"", u->err, &u->url);
}
return NGX_CONF_ERROR;
}
racf = ngx_rtmp_conf_get_module_app_conf(cf, ngx_rtmp_record_module);
racf->url = u;
return NGX_CONF_OK;
}
static char *
ngx_rtmp_record_recorder(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{