Permalink
Browse files

implemented sub-applications; recorders are now merged as sub-applica…

…tions
  • Loading branch information...
1 parent d8fbe51 commit 11cc6e6019d6bc0b6a446cb983a9c563c079a957 @arut committed Sep 13, 2012
Showing with 34 additions and 24 deletions.
  1. +9 −0 ngx_rtmp.c
  2. +1 −0 ngx_rtmp.h
  3. +7 −0 ngx_rtmp_core_module.c
  4. +17 −24 ngx_rtmp_record_module.c
View
@@ -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;
@@ -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;
View
@@ -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;
View
@@ -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;
}
View
@@ -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));
@@ -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;

0 comments on commit 11cc6e6

Please sign in to comment.