Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clip id var #1502

Merged
merged 5 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion ngx_http_vod_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ 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 && ctx->submodule_context.media_set.clip_count == 1)
{
cur_clip = (media_clip_t*) ctx->submodule_context.media_set.sources_head;
}
if (cur_clip == NULL)
{
goto not_found;
Expand All @@ -475,7 +479,11 @@ ngx_http_vod_set_clip_id_var(ngx_http_request_t *r, ngx_http_variable_value_t *v
switch (cur_clip->type)
{
case MEDIA_CLIP_SOURCE:
value = &((media_clip_source_t*)cur_clip)->mapped_uri;
if (((media_clip_source_t*)cur_clip)->id.len != 0) {
value = &((media_clip_source_t*)cur_clip)->id;
} else {
value = &((media_clip_source_t*)cur_clip)->mapped_uri;
}
break;

case MEDIA_CLIP_DYNAMIC:
Expand Down
1 change: 1 addition & 0 deletions vod/media_clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions vod/media_set_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Loading