Skip to content

Commit

Permalink
fix: Only request initialization segment when it's necessary (#6929)
Browse files Browse the repository at this point in the history
According to https://w3c.github.io/media-source/#dom-sourcebuffer-remove

Deleting a range from the source buffer does not delete the
initialization segment, so this change will prevent the initialization
segment from being requested when it is not needed.
  • Loading branch information
avelad committed Jul 1, 2024
1 parent df99f61 commit 190fa3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,6 @@ shaka.media.StreamingEngine = class {
mediaState.clearBufferSafeMargin = 0;
mediaState.clearingBuffer = true;
mediaState.lastSegmentReference = null;
mediaState.lastInitSegmentReference = null;
mediaState.segmentIterator = null;

shaka.log.debug(logPrefix, 'clearing buffer');
Expand Down
7 changes: 4 additions & 3 deletions test/media/streaming_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1179,12 +1179,13 @@ describe('StreamingEngine', () => {

const segmentType = shaka.net.NetworkingEngine.RequestType.SEGMENT;
const segmentContext = {
type: shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT,
type: shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT,
};

// Quickly switching back to text1, and text init segment should be
// Quickly switching back to text1, and text init segment shouldn't be
// fetched again.
netEngine.expectRequest('text-20-init', segmentType, segmentContext);
netEngine.expectRequest('text-20-0.mp4', segmentType, segmentContext);
netEngine.expectNoRequest('text-20-init', segmentType, segmentContext);
netEngine.expectNoRequest('text-21-init', segmentType, segmentContext);
// TODO: huh?
});
Expand Down

0 comments on commit 190fa3f

Please sign in to comment.