Skip to content

Commit

Permalink
implemented sub-applications; recorders are now merged as sub-applica…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
arut committed Sep 13, 2012
1 parent d8fbe51 commit 11cc6e6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
9 changes: 9 additions & 0 deletions ngx_rtmp.c
Expand Up @@ -317,6 +317,7 @@ ngx_rtmp_merge_applications(ngx_conf_t *cf, ngx_array_t *applications,
ngx_rtmp_conf_ctx_t *ctx, saved;
ngx_rtmp_core_app_conf_t **cacfp;
ngx_uint_t n;
ngx_rtmp_core_app_conf_t *cacf;

if (applications == NULL) {
return NGX_CONF_OK;
Expand All @@ -335,6 +336,14 @@ ngx_rtmp_merge_applications(ngx_conf_t *cf, ngx_array_t *applications,
if (rv != NGX_CONF_OK) {
return rv;
}

cacf = (*cacfp)->app_conf[ngx_rtmp_core_module.ctx_index];
rv = ngx_rtmp_merge_applications(cf, &cacf->applications,
(*cacfp)->app_conf,
module, ctx_index);
if (rv != NGX_CONF_OK) {
return rv;
}
}

*ctx = saved;
Expand Down
1 change: 1 addition & 0 deletions ngx_rtmp.h
Expand Up @@ -294,6 +294,7 @@ typedef struct ngx_rtmp_core_srv_conf_s {


typedef struct {
ngx_array_t applications; /* ngx_rtmp_core_app_conf_t */
ngx_str_t name;
void **app_conf;
} ngx_rtmp_core_app_conf_t;
Expand Down
7 changes: 7 additions & 0 deletions ngx_rtmp_core_module.c
Expand Up @@ -282,6 +282,13 @@ ngx_rtmp_core_create_app_conf(ngx_conf_t *cf)
return NULL;
}

if (ngx_array_init(&conf->applications, cf->pool, 1,
sizeof(ngx_rtmp_core_app_conf_t *))
!= NGX_OK)
{
return NULL;
}

return conf;
}

Expand Down
41 changes: 17 additions & 24 deletions ngx_rtmp_record_module.c
Expand Up @@ -904,16 +904,19 @@ ngx_rtmp_notify_on_record_done(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
static char *
ngx_rtmp_record_recorder(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *rv, *rvm;
char *rv;
ngx_int_t i;
ngx_str_t *value;
ngx_conf_t save;
ngx_rtmp_module_t *module;
ngx_rtmp_core_app_conf_t *cacf, **pcacf, *rcacf;
ngx_rtmp_record_app_conf_t *racf, **pracf, *rracf;
ngx_rtmp_conf_ctx_t *ctx, *pctx;

value = cf->args->elts;

cacf = ngx_rtmp_conf_get_module_app_conf(cf, ngx_rtmp_core_module);

racf = ngx_rtmp_conf_get_module_app_conf(cf, ngx_rtmp_record_module);

ctx = ngx_pcalloc(cf->pool, sizeof(ngx_rtmp_conf_ctx_t));
Expand Down Expand Up @@ -947,42 +950,32 @@ ngx_rtmp_record_recorder(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
}

/* add to sub-applications */
rcacf = ctx->app_conf[ngx_rtmp_core_module.ctx_index];
rcacf->app_conf = ctx->app_conf;
pcacf = ngx_array_push(&cacf->applications);
if (pcacf == NULL) {
return NGX_CONF_ERROR;
}
*pcacf = rcacf;

/* add to recorders */
rracf = ctx->app_conf[ngx_rtmp_record_module.ctx_index];
rracf->rec_conf = ctx->app_conf;
rracf->id = value[1];

pracf = ngx_array_push(&racf->rec);

if (pracf == NULL) {
return NGX_CONF_ERROR;
}

*pracf = rracf;

rracf->id = value[1];


save = *cf;
cf->ctx = ctx;
cf->cmd_type = NGX_RTMP_REC_CONF;

rv = ngx_conf_parse(cf, NULL);

for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->type != NGX_RTMP_MODULE) {
continue;
}

module = ngx_modules[i]->ctx;

if (module->merge_app_conf) {
rvm = module->merge_app_conf(cf,
pctx->app_conf[ngx_modules[i]->ctx_index],
ctx->app_conf[ngx_modules[i]->ctx_index]);

if (rvm != NGX_CONF_OK) {
return NGX_CONF_ERROR;
}
}
}

*cf= save;

return rv;
Expand Down

0 comments on commit 11cc6e6

Please sign in to comment.