Skip to content

Commit

Permalink
fix(HLS): Expose tilesLayout properly for live (#7123)
Browse files Browse the repository at this point in the history
If any segment gets evicted in live scenario, `segmentIndex.get(0)` will return `null`. Due to that, image tracks have `tilesLayout` set to `null` if we call `player.getImageTracks()` after segments have been evicted.
Additionally to main fix, I've replaced all other appearances of `segmentIndex.get(0)` with `segmentIndex.earliestReference()` to prevent similar bugs.
  • Loading branch information
tykus160 authored Aug 3, 2024
1 parent 2c399e0 commit 388050c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,8 @@ shaka.hls.HlsParser = class {
if (streamInfo.type != 'audio' && streamInfo.type != 'video') {
continue;
}
const firstReference = streamInfo.stream.segmentIndex.get(0);
const firstReference =
streamInfo.stream.segmentIndex.earliestReference();
if (firstReference && firstReference.syncTime) {
const syncTime = firstReference.syncTime;
this.presentationTimeline_.setInitialProgramDateTime(syncTime);
Expand Down Expand Up @@ -2222,7 +2223,7 @@ shaka.hls.HlsParser = class {
// lazy-load in this situation.
await streamInfo.stream.createSegmentIndex();

const reference = streamInfo.stream.segmentIndex.get(0);
const reference = streamInfo.stream.segmentIndex.earliestReference();
const layout = reference.getTilesLayout();
if (layout) {
streamInfo.stream.width =
Expand Down Expand Up @@ -2536,7 +2537,7 @@ shaka.hls.HlsParser = class {
}

if (type == ContentType.TEXT) {
const firstSegment = realStream.segmentIndex.get(0);
const firstSegment = realStream.segmentIndex.earliestReference();
if (firstSegment && firstSegment.initSegmentReference) {
stream.mimeType = 'application/mp4';
this.setFullTypeForStream_(stream);
Expand Down
2 changes: 1 addition & 1 deletion lib/media/preload_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
if (!prefetchSegment) {
// If we can't get a segment at the desired spot, at least get a segment,
// so we can get the init segment.
prefetchSegment = stream.segmentIndex.get(0);
prefetchSegment = stream.segmentIndex.earliestReference();
}
if (prefetchSegment) {
if (isLive) {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/stream_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ shaka.util.StreamUtils = class {
// in DASH this information comes at the stream level and not at the
// segment level.
if (stream.segmentIndex) {
reference = stream.segmentIndex.get(0);
reference = stream.segmentIndex.earliestReference();
}
let layout = stream.tilesLayout;
if (reference) {
Expand Down

0 comments on commit 388050c

Please sign in to comment.