added global record on/off feature

This commit is contained in:
Roman Arutyunyan 2012-09-03 19:54:05 +04:00
parent 4a775d6f0b
commit 8c5b864339

View file

@ -584,13 +584,21 @@ ngx_rtmp_record_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
racf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_record_module);
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_record_module);
if (racf == NULL || ctx == NULL || racf->flags & NGX_RTMP_RECORD_OFF) {
if (racf == NULL || ctx == NULL) {
return NGX_OK;
}
if (racf->flags & NGX_RTMP_RECORD_OFF) {
if (ctx->file.fd != NGX_INVALID_FILE) {
ngx_rtmp_record_close(s);
}
return NGX_OK;
}
keyframe = (ngx_rtmp_get_video_frame_type(in) == NGX_RTMP_VIDEO_KEY_FRAME);
if (keyframe && racf->interval != (ngx_msec_t)NGX_CONF_UNSET) {
if (keyframe) {
if (racf->interval != (ngx_msec_t)NGX_CONF_UNSET) {
next = ctx->last;
next.msec += racf->interval;
next.sec += (next.msec / 1000);
@ -605,6 +613,9 @@ ngx_rtmp_record_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
"record: failed");
}
}
} else if (ctx->file.fd == NGX_INVALID_FILE) {
ngx_rtmp_record_open(s);
}
}
if (ctx->file.fd == NGX_INVALID_FILE) {