Skip to content

Commit

Permalink
Move the time-offset in th erequest context
Browse files Browse the repository at this point in the history
  • Loading branch information
david-winder-kaltura committed May 5, 2024
1 parent 41a700c commit ec76921
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ngx_http_vod_hls.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ ngx_http_vod_hls_get_default_id3_data(ngx_http_vod_submodule_context_t* submodul
data_size = sizeof(ID3_TEXT_JSON_FORMAT) + VOD_INT64_LEN;
}

timestamp = media_set_get_segment_time_millis(media_set);
timestamp = media_set_get_segment_time_millis(media_set, &submodule_context->request_context);

p = ngx_pnalloc(submodule_context->request_context.pool, data_size);
if (p == NULL)
Expand Down
2 changes: 1 addition & 1 deletion ngx_http_vod_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ ngx_http_vod_set_segment_time_var(ngx_http_request_t *r, ngx_http_variable_value
return NGX_ERROR;
}

value = media_set_get_segment_time_millis(media_set);
value = media_set_get_segment_time_millis(media_set, &ctx->submodule_context.request_context);

v->data = p;
v->len = ngx_sprintf(p, "%L", value) - p;
Expand Down
7 changes: 5 additions & 2 deletions vod/media_set.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "media_set.h"

int64_t
media_set_get_segment_time_millis(media_set_t* media_set)
media_set_get_segment_time_millis(media_set_t* media_set, request_context_t* request_context )
{
media_track_t* cur_track;
int64_t time_offset;

time_offset = request_context->time_offset * 1000;

// try to find a track that has frames, if no track is found, fallback to the first track
for (cur_track = media_set->filtered_tracks; ; cur_track += media_set->total_track_count)
Expand All @@ -20,6 +23,6 @@ media_set_get_segment_time_millis(media_set_t* media_set)
}
}

return cur_track->original_clip_time - media_set->time_offset +
return cur_track->original_clip_time - time_offset +
rescale_time(cur_track->first_frame_time_offset, cur_track->media_info.timescale, 1000);
}
4 changes: 1 addition & 3 deletions vod/media_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ typedef struct {
bool_t use_discontinuity;
bool_t presentation_end;
bool_t cache_mapping;
int64_t time_offset;

uint32_t clip_count; // number of clips relevant to serve the current request
uint32_t sequence_count;
Expand Down Expand Up @@ -188,7 +187,6 @@ typedef struct {
uint32_t height;
} request_params_t;


int64_t media_set_get_segment_time_millis(media_set_t* media_set);
int64_t media_set_get_segment_time_millis(media_set_t* media_set, request_context_t* request_context);

#endif //__MEDIA_SET_H__
1 change: 0 additions & 1 deletion vod/media_set_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,6 @@ media_set_parse_live_params(
if (params[MEDIA_SET_PARAM_TIME_OFFSET] != NULL)
{
request_context->time_offset = params[MEDIA_SET_PARAM_TIME_OFFSET]->v.num.num;
media_set->time_offset = params[MEDIA_SET_PARAM_TIME_OFFSET]->v.num.num * 1000;
}

// clip times
Expand Down

0 comments on commit ec76921

Please sign in to comment.