Files
shaka-player/lib/hls/hls_utils.js
T
Joey Parrish 1372da934d Drop dead HLS code
This turned up as uncovered in a code coverage report, but it's
actually completely dead code.

Change-Id: I2ec6e83189d68aa3a43b136a20a0bb3e15eb41eb
2020-01-14 00:51:26 +00:00

78 lines
1.5 KiB
JavaScript

/** @license
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('shaka.hls.Utils');
goog.require('shaka.util.ManifestParserUtils');
shaka.hls.Utils = class {
/**
*
* @param {!Array.<!shaka.hls.Tag>} tags
* @param {string} name
* @return {!Array.<!shaka.hls.Tag>}
*/
static filterTagsByName(tags, name) {
return tags.filter((tag) => {
return tag.name == name;
});
}
/**
*
* @param {!Array.<!shaka.hls.Tag>} tags
* @param {string} type
* @return {!Array.<!shaka.hls.Tag>}
*/
static filterTagsByType(tags, type) {
return tags.filter((tag) => {
const tagType = tag.getRequiredAttrValue('TYPE');
return tagType == type;
});
}
/**
*
* @param {!Array.<!shaka.hls.Tag>} tags
* @param {string} name
* @return {?shaka.hls.Tag}
*/
static getFirstTagWithName(tags, name) {
const tagsWithName = shaka.hls.Utils.filterTagsByName(tags, name);
if (!tagsWithName.length) {
return null;
}
return tagsWithName[0];
}
/**
* @param {string} parentAbsoluteUri
* @param {string} uri
* @return {string}
*/
static constructAbsoluteUri(parentAbsoluteUri, uri) {
const uris = shaka.util.ManifestParserUtils.resolveUris(
[parentAbsoluteUri], [uri]);
return uris[0];
}
/**
* Matches a string to an HLS comment format and returns the result.
*
* @param {string} line
* @return {boolean}
*/
static isComment(line) {
return /^#(?!EXT)/m.test(line);
}
};