Skip to content

Commit

Permalink
Update segment_template.js
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish authored Jan 26, 2023
1 parent 1916749 commit 1f5c296
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/dash/segment_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,23 @@ shaka.dash.SegmentTemplate = class {
context.periodInfo.start + context.periodInfo.duration : Infinity;
const isLastPeriod = context.periodInfo.isLastPeriod;

// Don't fit live content, since it might receive more segments.
// Unless that live content is multi-period; it's safe to fit every period
// but the last one, since only the last period might receive new
// segments.
const shouldFit =
periodEnd != Infinity && (!isLastPeriod || !context.dynamic);
/* When to fit segments. All refactors should honor/update this table:
*
* | dynamic | infinite | last | should | notes |
* | | period | period | fit | |
* | ------- | -------- | ------ | ------ | ------------------------- |
* | F | F | X | T | typical VOD |
* | F | T | X | X | impossible: infinite VOD |
* | T | F | F | T | typical live, old period |
* | T | F | T | F | typical IPR |
* | T | T | F | X | impossible: old, infinite |
* | T | T | T | F | typical live, new period |
*/

// We never fit the final period of dynamic content, which could be
// infinite live (with no limit to fit to) or IPR (which would expand the
// most recent segment to the end of the presentation).
const shouldFit = !(context.dynamic && context.periodInfo.isLastPeriod);

if (segmentIndex) {
if (shouldFit) {
Expand Down

0 comments on commit 1f5c296

Please sign in to comment.