Skip to content

Commit

Permalink
basic implementation of first solution on issue kaltura#369
Browse files Browse the repository at this point in the history
  • Loading branch information
eminden committed Jul 30, 2016
1 parent f9c7048 commit 626351c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,13 @@ takes into account the key frame alignment, in case vod_align_segments_to_key_fr

Sets an nginx location that is used to read the MP4 file (remote mode) or mapping the request URI (mapped mode).

#### vod_remote_upstream_location
* **syntax**: `vod_remote_upstream_location location`
* **default**: `none`
* **context**: `http`, `server`, `location`

Sets an nginx location that is used to read the MP4 file on mapped mode, file will be read on local file system in the absence of this directive.

#### vod_max_upstream_headers_size
* **syntax**: `vod_max_upstream_headers_size size`
* **default**: `4k`
Expand Down
8 changes: 8 additions & 0 deletions ngx_http_vod_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ ngx_http_vod_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_memzero(&conf->submodule, sizeof(conf->submodule));
}
}
ngx_conf_merge_str_value(conf->remote_upstream_location, prev->remote_upstream_location, "");
ngx_conf_merge_ptr_value(conf->request_handler, prev->request_handler, ngx_http_vod_local_request_handler);
ngx_conf_merge_str_value(conf->multi_uri_suffix, prev->multi_uri_suffix, ".urlset");

Expand Down Expand Up @@ -1009,6 +1010,13 @@ ngx_command_t ngx_http_vod_commands[] = {
offsetof(ngx_http_vod_loc_conf_t, upstream_location),
NULL },

{ ngx_string("vod_remote_upstream_location"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_vod_loc_conf_t, remote_upstream_location),
NULL },

{ ngx_string("vod_upstream_extra_args"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
Expand Down
1 change: 1 addition & 0 deletions ngx_http_vod_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct ngx_http_vod_loc_conf_s {
// config fields
ngx_http_vod_submodule_t submodule;
ngx_str_t upstream_location;
ngx_str_t remote_upstream_location;
ngx_int_t(*request_handler)(ngx_http_request_t *r);
ngx_str_t multi_uri_suffix;
segmenter_conf_t segmenter;
Expand Down
25 changes: 19 additions & 6 deletions ngx_http_vod_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -3753,12 +3753,25 @@ ngx_http_vod_map_run_step(ngx_http_vod_ctx_t *ctx)
static ngx_int_t
ngx_http_vod_map_source_clip_done(ngx_http_vod_ctx_t *ctx)
{
// initialize for reading files
ctx->reader = &reader_file;
ctx->read = (ngx_http_vod_async_read_func_t)ngx_async_file_read;
ctx->alloc_params_index = READER_FILE;
ctx->alignment = ctx->alloc_params[READER_FILE].alignment;
ctx->perf_counter_async_read = PC_ASYNC_READ_FILE;
ngx_http_vod_loc_conf_t* conf;

conf = ctx->submodule_context.conf;

if (conf->remote_upstream_location.len == 0)
{
// initialize for reading files
ctx->reader = &reader_file;
ctx->read = (ngx_http_vod_async_read_func_t)ngx_async_file_read;
ctx->alloc_params_index = READER_FILE;
ctx->alignment = ctx->alloc_params[READER_FILE].alignment;
ctx->perf_counter_async_read = PC_ASYNC_READ_FILE;
} else {
// initialize for http read
ctx->reader = &reader_http;
ctx->read = (ngx_http_vod_async_read_func_t)ngx_http_vod_async_http_read;
ctx->alloc_params_index = READER_HTTP;
ctx->alignment = ctx->alloc_params[READER_HTTP].alignment;
}

// run the main state machine
return ngx_http_vod_start_processing_media_file(ctx);
Expand Down

0 comments on commit 626351c

Please sign in to comment.