Skip to content

Commit

Permalink
feat(HLS): Add support to variable substitution in EXT-X-DATERANGE (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jun 4, 2024
1 parent 2e4ace5 commit 3b2477f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ shaka.hls.HlsParser = class {

this.determineLastTargetDuration_(playlist);

this.processDateRangeTags_(playlist.tags, stream.type);
this.processDateRangeTags_(playlist.tags, stream.type, mediaVariables);
}


Expand Down Expand Up @@ -769,6 +769,9 @@ shaka.hls.HlsParser = class {
/** @type {?string} */
let mediaPlaylistType = null;

/** @type {!Map.<string, string>} */
let mediaVariables = new Map();

// Parsing a media playlist results in a single-variant stream.
if (playlist.type == shaka.hls.PlaylistType.MEDIA) {
this.needsClosedCaptionsDetection_ = false;
Expand All @@ -777,8 +780,8 @@ shaka.hls.HlsParser = class {
const variablesTags = shaka.hls.Utils.filterTagsByName(playlist.tags,
'EXT-X-DEFINE');

const mediaVariables =
this.parseMediaVariables_(variablesTags, this.masterPlaylistUri_);
mediaVariables = this.parseMediaVariables_(
variablesTags, this.masterPlaylistUri_);

// Get necessary info for this stream. These are things we would normally
// find from the master playlist (e.g. from values on EXT-X-MEDIA tags).
Expand Down Expand Up @@ -893,7 +896,8 @@ shaka.hls.HlsParser = class {

goog.asserts.assert(mediaPlaylistType,
'mediaPlaylistType should be non-null');
this.processDateRangeTags_(playlist.tags, mediaPlaylistType);
this.processDateRangeTags_(
playlist.tags, mediaPlaylistType, mediaVariables);
}

this.manifest_ = {
Expand Down Expand Up @@ -2451,7 +2455,7 @@ shaka.hls.HlsParser = class {
}
}

this.processDateRangeTags_(playlist.tags, stream.type);
this.processDateRangeTags_(playlist.tags, stream.type, mediaVariables);
};

/** @type {Promise} */
Expand Down Expand Up @@ -3635,9 +3639,11 @@ shaka.hls.HlsParser = class {
/**
* @param {!Array.<!shaka.hls.Tag>} tags
* @param {string} contentType
* @param {!Map.<string, string>} variables
* @private
*/
processDateRangeTags_(tags, contentType) {
processDateRangeTags_(tags, contentType, variables) {
const Utils = shaka.hls.Utils;
const initialProgramDateTime =
this.presentationTimeline_.getInitialProgramDateTime();
if (!initialProgramDateTime ||
Expand Down Expand Up @@ -3742,7 +3748,7 @@ shaka.hls.HlsParser = class {
const metadataFrame = {
key: attribute.name,
description: '',
data: attribute.value,
data: Utils.variableSubstitution(attribute.value, variables),
mimeType: null,
pictureType: null,
};
Expand Down

0 comments on commit 3b2477f

Please sign in to comment.