diff --git a/README.md b/README.md index 93f6fcc3..9b165ac3 100644 --- a/README.md +++ b/README.md @@ -571,6 +571,7 @@ Mandatory fields: an empty captions file (useful in case only some videos in a playlist have captions) Optional fields: +* `id` - a string that identifies the source clip * `sourceType` - sets the interface that should be used to read the MP4 file, allowed values are: `file` and `http`. By default, the module uses `http` if `vod_remote_upstream_location` is set, and `file` otherwise. diff --git a/ngx_http_vod_module.c b/ngx_http_vod_module.c index d9304c67..57fceedf 100644 --- a/ngx_http_vod_module.c +++ b/ngx_http_vod_module.c @@ -456,8 +456,10 @@ ngx_http_vod_set_sequence_id_var(ngx_http_request_t *r, ngx_http_variable_value_ static ngx_int_t ngx_http_vod_set_clip_id_var(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { + media_clip_source_t* clip_source; ngx_http_vod_ctx_t *ctx; media_clip_t* cur_clip; + media_set_t* media_set; ngx_str_t* value; ctx = ngx_http_get_module_ctx(r, ngx_http_vod_module); @@ -469,13 +471,29 @@ ngx_http_vod_set_clip_id_var(ngx_http_request_t *r, ngx_http_variable_value_t *v cur_clip = ctx->cur_clip; if (cur_clip == NULL) { - goto not_found; + media_set = &ctx->submodule_context.media_set; + if (media_set->sequence_count == 1 && media_set->clip_count == 1) + { + cur_clip = media_set->sequences->clips[0]; + } + else + { + goto not_found; + } } switch (cur_clip->type) { case MEDIA_CLIP_SOURCE: - value = &((media_clip_source_t*)cur_clip)->mapped_uri; + clip_source = (media_clip_source_t*)cur_clip; + if (clip_source->id.len != 0) + { + value = &clip_source->id; + } + else + { + value = &clip_source->mapped_uri; + } break; case MEDIA_CLIP_DYNAMIC: diff --git a/vod/media_clip.h b/vod/media_clip.h index 6fe34886..2a9e8f30 100644 --- a/vod/media_clip.h +++ b/vod/media_clip.h @@ -74,6 +74,7 @@ struct media_clip_source_s { // TODO: the fields below are not required for generators, consider adding another struct // input params + vod_str_t id; media_clip_source_type_t source_type; vod_str_t uri; // original uri uint64_t clip_from; diff --git a/vod/media_set_parser.c b/vod/media_set_parser.c index a1a0e7ff..81e33b6f 100644 --- a/vod/media_set_parser.c +++ b/vod/media_set_parser.c @@ -119,6 +119,7 @@ static json_parser_union_type_def_t media_clip_union_params[] = { }; static json_object_value_def_t media_clip_source_params[] = { + { vod_string("id"), VOD_JSON_STRING, offsetof(media_clip_source_t, id), media_set_parse_null_term_string }, { vod_string("path"), VOD_JSON_STRING, offsetof(media_clip_source_t, mapped_uri), media_set_parse_null_term_string }, { vod_string("tracks"), VOD_JSON_STRING, offsetof(media_clip_source_t, tracks_mask), media_set_parse_tracks_spec }, { vod_string("clipFrom"), VOD_JSON_INT, offsetof(media_clip_source_t, clip_from), media_set_parse_int64 },