Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Processing segment reachable even after playlist update removes it #939

Merged
merged 5 commits into from
Jan 24, 2017

Conversation

gesinger
Copy link
Contributor

Description

In live scenarios, a refresh may render a processing segment unreachable. This attaches the segment to the segmentInfo object so the segment will always be around.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

@imbcmdth
Copy link
Member

imbcmdth commented Jan 6, 2017

When a playlist is refreshed, the segments in the new playlist are copies of the old segments. That means that if playlist is refreshed between segment request and xhr completing, we will annotate the old segment object at:

https://github.com/gesinger/videojs-contrib-hls/blob/b426cc22fe27de3d96a53d5586c0ab3a451d3ad1/src/sync-controller.js#L310-L314

@gesinger
Copy link
Contributor Author

Good call @imbcmdth . Here are a couple approaches (I think (1) is better, but there are definitely alternatives from these as well):

  1. When we update segment loader's playlist with a refresh and change the media index of segmentInfo, we also change the segment reference. We'd have to check that the segment exists on the new playlist (media index did not turn negative). If it doesn't exist, we simply leave the old segment reference (it'll save info onto a segment that is missing from the playlist, but no harm will be done). This is the simplest change from the current code.

  2. Instead of saving the segment reference on segmentInfo, we continue to use mediaIndex and the playlist reference but save old segments that are not officially part of the playlist anymore for the case where they fell off. This may lead to misleading playlist objects, as we will save information that technically no longer exists in the playlist.

mediaSource.sourceBuffers[0].trigger('updateend');

assert.equal(loader.state, 'WAITING', 'in waiting state');
assert.equal(loader.pendingSegment_.uri, '1.ts', 'second segment pending');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to also check loader.pendingSegment_.segment.uri is what you expect whenver checking loader.pendingSegment_.uri to to make sure the new segment object we are attaching to segmentInfo is the correct reference

@@ -279,6 +279,13 @@ export default class SegmentLoader extends videojs.EventTarget {

if (segmentInfo && !segmentInfo.isSyncRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we only do these adjustments for non-sync requests. It probably doesn't matter if we don't save the info on an outdated segment object when its a sync-request because we don't append it and if we do need to append it in the future, we are going to have to re-request/probe/sync it anyway. However, I think it probably doesn't hurt to make sure the timing info we get from the probe of the sync request to be put onto the segment object. It might help make other calculations that fallback to target duration when start and end times are unavailable be more accurate

@gesinger gesinger force-pushed the unreachable-segment-playlist-update branch from 279f6e4 to c4a3f26 Compare January 24, 2017 20:33
@imbcmdth imbcmdth merged commit d38dc44 into videojs:master Jan 24, 2017
@imbcmdth
Copy link
Member

LFGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants