Skip to content

Commit

Permalink
feat(HLS) Add support to blocking playlist reload by adding the CAN-B…
Browse files Browse the repository at this point in the history
…LOCK-RELOAD=YES
  • Loading branch information
avelad committed Jun 12, 2023
1 parent 70823f9 commit f9dd6e3
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,18 @@ shaka.hls.HlsParser = class {
// 'EXT-X-SKIP' tag in the media playlist.
queryData.add('_HLS_skip', 'YES');
}
if (streamInfo.nextMediaSequence >= 0) {
// Indicates that the server must hold the request until a Playlist
// contains a Media Segment with Media Sequence
queryData.add('_HLS_msn', String(streamInfo.nextMediaSequence));
}
if (streamInfo.nextPart >= 0) {
// Indicates, in combination with _HLS_msn, that the server must hold
// the request until a Playlist contains Partial Segment N of Media
// Sequence Number M or later.
queryData.add('_HLS_part', String(streamInfo.nextPart));
if (streamInfo.canBlockReload) {
if (streamInfo.nextMediaSequence >= 0) {
// Indicates that the server must hold the request until a Playlist
// contains a Media Segment with Media Sequence
queryData.add('_HLS_msn', String(streamInfo.nextMediaSequence));
}
if (streamInfo.nextPart >= 0) {
// Indicates, in combination with _HLS_msn, that the server must hold
// the request until a Playlist contains Partial Segment N of Media
// Sequence Number M or later.
queryData.add('_HLS_part', String(streamInfo.nextPart));
}
}
if (queryData.getCount()) {
uriObj.setQueryData(queryData);
Expand Down Expand Up @@ -1960,6 +1962,7 @@ shaka.hls.HlsParser = class {
maxTimestamp: 0,
mediaSequenceToStartTime: new Map(),
canSkipSegments: false,
canBlockReload: false,
hasEndList: false,
firstSequenceNumber: -1,
nextMediaSequence: -1,
Expand Down Expand Up @@ -2007,6 +2010,7 @@ shaka.hls.HlsParser = class {
streamInfo.minTimestamp = realStreamInfo.minTimestamp;
streamInfo.maxTimestamp = realStreamInfo.maxTimestamp;
streamInfo.canSkipSegments = realStreamInfo.canSkipSegments;
streamInfo.canBlockReload = realStreamInfo.canBlockReload;
streamInfo.hasEndList = realStreamInfo.hasEndList;
streamInfo.mediaSequenceToStartTime =
realStreamInfo.mediaSequenceToStartTime;
Expand Down Expand Up @@ -2297,6 +2301,8 @@ shaka.hls.HlsParser = class {
playlist.tags, 'EXT-X-SERVER-CONTROL');
const canSkipSegments = serverControlTag ?
serverControlTag.getAttribute('CAN-SKIP-UNTIL') != null : false;
const canBlockReload = serverControlTag ?
serverControlTag.getAttribute('CAN-BLOCK-RELOAD') == 'YES' : false;

const mediaSequenceNumber = shaka.hls.Utils.getFirstTagWithNameAsNumber(
playlist.tags, 'EXT-X-MEDIA-SEQUENCE', 0);
Expand All @@ -2320,6 +2326,7 @@ shaka.hls.HlsParser = class {
minTimestamp: firstStartTime,
maxTimestamp: lastEndTime,
canSkipSegments,
canBlockReload,
hasEndList: false,
firstSequenceNumber: -1,
nextMediaSequence,
Expand Down Expand Up @@ -3687,6 +3694,7 @@ shaka.hls.HlsParser = class {
* maxTimestamp: number,
* mediaSequenceToStartTime: !Map.<number, number>,
* canSkipSegments: boolean,
* canBlockReload: boolean,
* hasEndList: boolean,
* firstSequenceNumber: number,
* nextMediaSequence: number,
Expand Down Expand Up @@ -3719,6 +3727,10 @@ shaka.hls.HlsParser = class {
* @property {boolean} canSkipSegments
* True if the server supports delta playlist updates, and we can send a
* request for a playlist that can skip older media segments.
* @property {boolean} canBlockReload
* True if the server supports blocking playlist reload, and we can send a
* request for a playlist that can block reload until some segments are
* present.
* @property {boolean} hasEndList
* True if the stream has an EXT-X-ENDLIST tag.
* @property {number} firstSequenceNumber
Expand Down

0 comments on commit f9dd6e3

Please sign in to comment.