Skip to content

Commit

Permalink
Merge pull request kaltura#394 from kaltura/dash-start-zero-pts
Browse files Browse the repository at this point in the history
start the pts from zero in dash
  • Loading branch information
erankor authored Aug 3, 2016
2 parents 198a52d + 4b586b9 commit c74715c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ngx_http_vod_dash.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static const ngx_http_vod_request_t dash_mp4_init_request = {

static const ngx_http_vod_request_t dash_mp4_fragment_request = {
REQUEST_FLAG_SINGLE_TRACK,
PARSE_FLAG_FRAMES_ALL,
PARSE_FLAG_FRAMES_ALL | PARSE_FLAG_INITIAL_PTS_DELAY,
REQUEST_CLASS_SEGMENT,
SUPPORTED_CODECS_MP4,
DASH_TIMESCALE,
Expand All @@ -421,7 +421,7 @@ static const ngx_http_vod_request_t dash_mp4_fragment_request = {

static const ngx_http_vod_request_t edash_mp4_fragment_request = {
REQUEST_FLAG_SINGLE_TRACK,
PARSE_FLAG_FRAMES_ALL | PARSE_FLAG_PARSED_EXTRA_DATA,
PARSE_FLAG_FRAMES_ALL | PARSE_FLAG_INITIAL_PTS_DELAY | PARSE_FLAG_PARSED_EXTRA_DATA,
REQUEST_CLASS_SEGMENT,
SUPPORTED_CODECS_MP4,
DASH_TIMESCALE,
Expand All @@ -441,7 +441,7 @@ static const ngx_http_vod_request_t dash_webm_init_request = {

static const ngx_http_vod_request_t dash_webm_fragment_request = {
REQUEST_FLAG_SINGLE_TRACK,
PARSE_FLAG_FRAMES_ALL,
PARSE_FLAG_FRAMES_ALL | PARSE_FLAG_INITIAL_PTS_DELAY,
REQUEST_CLASS_SEGMENT,
SUPPORTED_CODECS_WEBM,
DASH_TIMESCALE,
Expand Down
1 change: 1 addition & 0 deletions ngx_http_vod_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -4683,6 +4683,7 @@ ngx_http_vod_handler(ngx_http_request_t *r)
ctx->submodule_context.request_params = request_params;
ctx->submodule_context.media_set = media_set;
ctx->submodule_context.media_set.segmenter_conf = &conf->segmenter;
ctx->submodule_context.media_set.version = request_params.version;
ctx->request = request;
ctx->cur_source = media_set.sources_head;
ctx->submodule_context.request_context.pool = r->pool;
Expand Down
19 changes: 19 additions & 0 deletions ngx_http_vod_request_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ ngx_http_vod_parse_uri_file_name(
uint32_t clip_index;
uint32_t media_type;
uint32_t pts_delay;
uint32_t version;
language_id_t lang_id;

default_tracks_mask = (flags & PARSE_FILE_NAME_MULTI_STREAMS_PER_TYPE) ? 0xffffffff : 1;
Expand Down Expand Up @@ -460,6 +461,24 @@ ngx_http_vod_parse_uri_file_name(
}
}

// version
if (*start_pos == 'x')
{
start_pos++; // skip the x

start_pos = parse_utils_extract_uint32_token(start_pos, end_pos, &version);
if (version <= 0)
{
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"ngx_http_vod_parse_uri_file_name: failed to parse version");
return NGX_HTTP_BAD_REQUEST;
}

result->version = version - 1;

skip_dash(start_pos, end_pos);
}

ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"ngx_http_vod_parse_uri_file_name: did not consume the whole name");
return NGX_HTTP_BAD_REQUEST;
Expand Down
12 changes: 8 additions & 4 deletions vod/dash/dash_packager.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,7 @@ dash_packager_get_track_spec(
{
case MEDIA_TYPE_VIDEO:
p = vod_sprintf(p, "v%uD", track_index + 1);
if (pts_delay > 0)
{
p = vod_sprintf(p, "-p%uD", pts_delay);
}
p = vod_copy(p, "-x2", sizeof("-x2") - 1); // TODO: remove this after deployment
break;

case MEDIA_TYPE_AUDIO:
Expand Down Expand Up @@ -2054,6 +2051,13 @@ dash_packager_get_earliest_pres_time(media_set_t* media_set, media_track_t* trac
{
result += track->frames.first_frame[0].pts_delay;
}

if (track->media_info.media_type == MEDIA_TYPE_VIDEO &&
media_set->version == 1) // TODO: remove this after deployment
{
result -= track->media_info.u.video.initial_pts_delay;
}

return result;
}

Expand Down
2 changes: 2 additions & 0 deletions vod/media_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ typedef struct {
typedef struct {
// initialized during parsing
struct segmenter_conf_s* segmenter_conf;
uint32_t version;

uint32_t type;
media_clip_timing_t timing;
Expand Down Expand Up @@ -146,6 +147,7 @@ typedef struct {
uint32_t tracks_mask[MEDIA_TYPE_COUNT];
uint32_t* sequence_tracks_mask; // [MAX_SEQUENCES][MEDIA_TYPE_COUNT]
uint8_t* langs_mask; // [LANG_MASK_SIZE]
uint32_t version;
} request_params_t;

#endif //__MEDIA_SET_H__
1 change: 1 addition & 0 deletions vod/media_set_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,7 @@ media_set_parse_json(
result->segmenter_conf = segmenter;
result->uri = *uri;
result->timing.segment_base_time = SEGMENT_BASE_TIME_RELATIVE;
result->version = request_params->version;

if (params[MEDIA_SET_PARAM_DURATIONS] == NULL)
{
Expand Down

0 comments on commit c74715c

Please sign in to comment.