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

Improvement of segment timeline $Time$ accuracy #706

Merged
Show file tree
Hide file tree
Changes from all 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 CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Andy Hochhaus <ahochhaus@samegoal.com>
Chad Assareh <assareh@google.com>
Costel Madalin Grecu <madalin.grecu@adswizz.com>
Donato Borrello <donato@jwplayer.com>
Duc Pham <duc.pham@edgeware.tv>
Esteban Dosztal <edosztal@gmail.com>
Itay Kinnrot <itay.kinnrot@kaltura.com>
Jacob Trimble <modmaker@google.com>
Expand Down
15 changes: 13 additions & 2 deletions lib/dash/mpd_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ shaka.dash.MpdUtils.GAP_OVERLAP_TOLERANCE_SECONDS = 1 / 15;
/**
* @typedef {{
* start: number,
* unscaledStart: number,
* end: number
* }}
*
Expand All @@ -52,6 +53,8 @@ shaka.dash.MpdUtils.GAP_OVERLAP_TOLERANCE_SECONDS = 1 / 15;
*
* @property {number} start
* The start time of the range.
* @property {number} unscaledStart
* The start time of the range in representation timescale units.
* @property {number} end
* The end time (exclusive) of the range.
*/
Expand All @@ -64,6 +67,7 @@ shaka.dash.MpdUtils.TimeRange;
* segmentDuration: ?number,
* startNumber: number,
* presentationTimeOffset: number,
* unscaledPresentationTimeOffset: number,
* timeline: Array.<shaka.dash.MpdUtils.TimeRange>
* }}
*
Expand All @@ -78,6 +82,8 @@ shaka.dash.MpdUtils.TimeRange;
* The start number of the segments; 1 or greater.
* @property {number} presentationTimeOffset
* The presentationTimeOffset of the representation, in seconds.
* @property {number} unscaledPresentationTimeOffset
* The presentationTimeOffset of the representation, in timescale units.
* @property {Array.<shaka.dash.MpdUtils.TimeRange>} timeline
* The timeline of the representation, if given. Times in seconds.
*/
Expand Down Expand Up @@ -269,8 +275,12 @@ shaka.dash.MpdUtils.createTimeline = function(

for (var j = 0; j <= repeat; ++j) {
var endTime = startTime + d;
timeline.push(
{start: (startTime / timescale), end: (endTime / timescale)});
var item = {
start: startTime / timescale,
end: endTime / timescale,
unscaledStart: startTime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this field to the shaka.dash.MpdUtils.TimeRange definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Missed that. Will fix. Thanks.

};
timeline.push(item);

startTime = endTime;
lastEndTime = endTime;
Expand Down Expand Up @@ -398,6 +408,7 @@ shaka.dash.MpdUtils.parseSegmentInfo = function(context, callback) {
segmentDuration: segmentDuration,
startNumber: startNumber,
presentationTimeOffset: pto,
unscaledPresentationTimeOffset: Number(presentationTimeOffset),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this field to the shaka.dash.MpdUtils.SegmentInfo definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix.

timeline: timeline
};
};
Expand Down
10 changes: 7 additions & 3 deletions lib/dash/segment_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ shaka.dash.SegmentTemplate.createStream = function(
* segmentDuration: ?number,
* startNumber: number,
* presentationTimeOffset: number,
* unscaledPresentationTimeOffset: number,
* timeline: Array.<shaka.dash.MpdUtils.TimeRange>,
* mediaTemplate: ?string,
* indexTemplate: ?string
Expand All @@ -131,6 +132,8 @@ shaka.dash.SegmentTemplate.createStream = function(
* The start number of the segments; 1 or greater.
* @property {number} presentationTimeOffset
* The presentationTimeOffset of the representation, in seconds.
* @property {number} unscaledPresentationTimeOffset
* The presentationTimeOffset of the representation, in timescale units.
* @property {Array.<shaka.dash.MpdUtils.TimeRange>} timeline
* The timeline of the representation, if given. Times in seconds.
* @property {?string} mediaTemplate
Expand Down Expand Up @@ -174,6 +177,7 @@ shaka.dash.SegmentTemplate.parseSegmentTemplateInfo_ = function(context) {
timescale: segmentInfo.timescale,
startNumber: segmentInfo.startNumber,
presentationTimeOffset: segmentInfo.presentationTimeOffset,
unscaledPresentationTimeOffset: segmentInfo.unscaledPresentationTimeOffset,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this field to the shaka.dash.SegmentTemplate.SegmentTemplateInfo definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix.

timeline: segmentInfo.timeline,
mediaTemplate: media,
indexTemplate: index
Expand Down Expand Up @@ -357,16 +361,16 @@ shaka.dash.SegmentTemplate.createFromTimeline_ = function(context, info) {
var references = [];
for (var i = 0; i < info.timeline.length; i++) {
var start = info.timeline[i].start;
var unscaledStart = info.timeline[i].unscaledStart;
var end = info.timeline[i].end;

// Note: i = k - 1, where k indicates the k'th segment listed in the MPD.
// (See section 5.3.9.5.3 of the DASH spec.)
var segmentReplacement = i + info.startNumber;

// Consider the presentation time offset in segment uri computation
var timeReplacement = (start + info.presentationTimeOffset) *
info.timescale;

var timeReplacement = unscaledStart +
info.unscaledPresentationTimeOffset;
var createUris = (function(
template, repId, bandwidth, baseUris, segmentId, time) {
var mediaUri = MpdUtils.fillUriTemplate(
Expand Down