Skip to content

Commit

Permalink
Merge pull request #1502 from kaltura/hls-clip-id
Browse files Browse the repository at this point in the history
Add clip id var
  • Loading branch information
shamamayair authored Jan 1, 2024
2 parents 3f618d0 + b44ca18 commit 1750eb0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
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
22 changes: 20 additions & 2 deletions ngx_http_vod_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
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

0 comments on commit 1750eb0

Please sign in to comment.