Skip to content

Commit

Permalink
Merge branch 'main' into fix-llhls
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 authored May 25, 2023
2 parents 4abadab + f9a392f commit 6c7eeae
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docs/supported-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ not yet been implemented. VHS currently supports everything in the
* [EXT-X-DATERANGE]
* [EXT-X-SESSION-DATA]
* [EXT-X-SESSION-KEY]
* [EXT-X-INDEPENDENT-SEGMENTS]
* Alternate video via [EXT-X-MEDIA] of type video
* ASSOC-LANGUAGE in [EXT-X-MEDIA]
* CHANNELS in [EXT-X-MEDIA]
Expand Down Expand Up @@ -278,7 +277,6 @@ simply take on their default values (in the case where they have valid defaults)
[EXT-X-I-FRAMES-ONLY]: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.6
[EXT-X-I-FRAME-STREAM-INF]: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.3
[EXT-X-SESSION-KEY]: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.5
[EXT-X-INDEPENDENT-SEGMENTS]: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.5.1
[EXT-X-START]: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.5.2
[EXT-X-MEDIA]: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.1

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@videojs/vhs-utils": "4.0.0",
"aes-decrypter": "4.0.1",
"global": "^4.4.0",
"m3u8-parser": "^6.0.0",
"m3u8-parser": "^6.2.0",
"mpd-parser": "^1.1.1",
"mux.js": "6.3.0",
"video.js": "^7 || ^8"
Expand Down
8 changes: 7 additions & 1 deletion src/segment-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1480,11 +1480,17 @@ export default class SegmentLoader extends videojs.EventTarget {
nextPart = nextSegment.parts[0];
}

// independentSegments applies to every segment in a playlist. If independentSegments appears in a main playlist,
// it applies to each segment in each media playlist.
// https://datatracker.ietf.org/doc/html/draft-pantos-http-live-streaming-23#section-4.3.5.1
const hasIndependentSegments = (this.vhs_.playlists && this.vhs_.playlists.main && this.vhs_.playlists.main.independentSegments) ||
this.playlist_.independentSegments;

// if we have no buffered data then we need to make sure
// that the next part we append is "independent" if possible.
// So we check if the previous part is independent, and request
// it if it is.
if (!bufferedTime && nextPart && !nextPart.independent) {
if (!bufferedTime && nextPart && !hasIndependentSegments && !nextPart.independent) {

if (next.partIndex === 0) {
const lastSegment = segments[next.mediaIndex - 1];
Expand Down
46 changes: 46 additions & 0 deletions test/loader-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,52 @@ export const LoaderCommonFactory = ({
assert.equal(segmentInfo2.mediaIndex, 3, 'previous segment');
});

QUnit.test('chooses the correct next segment if independentSegments is true on the playlist', function(assert) {
loader.buffered_ = () => createTimeRanges();
const playlist = playlistWithDuration(50, {llhls: true});

playlist.independentSegments = true;

loader.hasPlayed_ = () => true;
loader.syncPoint_ = null;

loader.playlist(playlist);
loader.load();

loader.currentTime_ = () => 46;
// make the previous part indepenent, ensure we don't go back to that part.
playlist.segments[4].parts[1].independent = true;
const segmentInfo = loader.chooseNextRequest_();

assert.equal(segmentInfo.partIndex, 2, 'chooses part 2');
assert.equal(segmentInfo.mediaIndex, 4, 'same segment');
});

QUnit.test('chooses the correct next segment if independentSegments is true on the main playlist', function(assert) {
loader.buffered_ = () => createTimeRanges();
const playlist = playlistWithDuration(50, {llhls: true});

loader.vhs_.playlists = {
main: {
independentSegments: true
}
};

loader.hasPlayed_ = () => true;
loader.syncPoint_ = null;

loader.playlist(playlist);
loader.load();

loader.currentTime_ = () => 46;
// make the previous part indepenent, ensure we don't go back to that part.
playlist.segments[4].parts[1].independent = true;
const segmentInfo = loader.chooseNextRequest_();

assert.equal(segmentInfo.partIndex, 2, 'chooses part 2');
assert.equal(segmentInfo.mediaIndex, 4, 'same segment');
});

QUnit.test('processing segment reachable even after playlist update removes it', function(assert) {
const handleAppendsDone_ = loader.handleAppendsDone_.bind(loader);
let expectedURI = '0.ts';
Expand Down

0 comments on commit 6c7eeae

Please sign in to comment.