static ngx_int_t ngx_rtmp_record_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v) { ngx_rtmp_record_app_conf_t *racf; ngx_rtmp_record_ctx_t *ctx; u_char *p; ngx_uint_t n; ngx_rtmp_record_node_ctx_t *rctx; if (s->auto_pushed) { goto next; } racf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_record_module); if (racf == NULL || racf->nodes.nelts == 0) { goto next; } if (ngx_rtmp_record_init(s) != NGX_OK) { return NGX_ERROR; } ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, "record: publish %ui nodes", racf->nodes.nelts); ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_record_module); ngx_memcpy(ctx->name, v->name, sizeof(ctx->name)); ngx_memcpy(ctx->args, v->args, sizeof(ctx->args)); /* terminate name on /../ */ for (p = ctx->name; *p; ++p) { if (ngx_path_separator(p[0]) && p[1] == '.' && p[2] == '.' && ngx_path_separator(p[3])) { *p = 0; break; } } rctx = ctx->nodes.elts; for (n = 0; n < ctx->nodes.nelts; ++n, ++rctx) { if (rctx->conf->flags & (NGX_RTMP_RECORD_OFF|NGX_RTMP_RECORD_MANUAL)) { continue; } ngx_rtmp_record_node_open(s, rctx); } next: return next_publish(s, v); }
static ngx_rtmp_record_rec_ctx_t * ngx_rtmp_record_get_node_ctx(ngx_rtmp_session_t *s, ngx_uint_t n) { ngx_rtmp_record_ctx_t *ctx; ngx_rtmp_record_rec_ctx_t *rctx; if (ngx_rtmp_record_init(s) != NGX_OK) { return NULL; } ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_record_module); if (n >= ctx->rec.nelts) { return NULL; } rctx = ctx->rec.elts; return &rctx[n]; }
static ngx_rtmp_record_node_ctx_t * ngx_rtmp_record_get_node_ctx(ngx_rtmp_session_t *s, ngx_uint_t n) { ngx_rtmp_record_ctx_t *ctx; ngx_rtmp_record_node_ctx_t *nodes; if (ngx_rtmp_record_init(s) != NGX_OK) { return NULL; } ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_record_module); if (n >= ctx->nodes.nelts) { return NULL; } nodes = ctx->nodes.elts; return &nodes[n]; }