From 80d7b1c905d0e43682c608e0f7a93a7d9f470cbc Mon Sep 17 00:00:00 2001 From: Peter Wright Date: Thu, 17 Jul 2014 13:07:49 +0000 Subject: [PATCH] Allow the filename on disk to use no suffix (or a different suffix from the format), as long as the format prefix is used (e.g. "mp4:test.mov") --- ngx_rtmp_play_module.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ngx_rtmp_play_module.c b/ngx_rtmp_play_module.c index acaa46c..1c06a92 100644 --- a/ngx_rtmp_play_module.c +++ b/ngx_rtmp_play_module.c @@ -860,9 +860,23 @@ ngx_rtmp_play_next_entry(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v) ctx->file.fd = ngx_open_file(path, NGX_FILE_RDONLY, NGX_FILE_OPEN, NGX_FILE_DEFAULT_ACCESS); + /* try unsuffixed file name as fallback if adding suffix didn't work */ if (ctx->file.fd == NGX_INVALID_FILE) { ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, ngx_errno, - "play: error opening file '%s'", path); + "play: error opening file '%s', trying without suffix", + path); + + p = ngx_snprintf(path, NGX_MAX_PATH, "%V/%s", + pe->root, v->name + ctx->pfx_size); + *p = 0; + + ctx->file.fd = ngx_open_file(path, NGX_FILE_RDONLY, NGX_FILE_OPEN, + NGX_FILE_DEFAULT_ACCESS); + } + + if (ctx->file.fd == NGX_INVALID_FILE) { + ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, ngx_errno, + "play: error opening fallback file '%s'", path); continue; }