Skip to content

Commit

Permalink
chore(HLS): Retired unused error code
Browse files Browse the repository at this point in the history
Now that shaka-project#2337 has been implemented, the error code HLS_INTERNAL_SKIP_STREAM
is no longer used anywhere in the code.
This retires that error, and also cleans up the code that previously
was responsible for handling that error being fired.

Pre-work for shaka-project#1936
  • Loading branch information
theodab committed Aug 19, 2022
1 parent 8376410 commit 264dd68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 49 deletions.
55 changes: 11 additions & 44 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ shaka.hls.HlsParser = class {
playlist, uri, uri, codecs, type, language, primary, name,
channelsCount, closedCaptions, characteristics, forced, spatialAudio,
mimeType);
goog.asserts.assert(streamInfo != null, 'StreamInfo is null!');
this.uriToStreamInfosMap_.set(uri, streamInfo);

// Wrap the stream from that stream info with a variant.
Expand Down Expand Up @@ -856,16 +855,13 @@ shaka.hls.HlsParser = class {
// Create text stream for each Subtitle media tag.
const subtitleTags =
shaka.hls.Utils.filterTagsByType(mediaTags, 'SUBTITLES');
const textStreamPromises = subtitleTags.map(async (tag) => {
const textStreamPromises = subtitleTags.map((tag) => {
const disableText = this.config_.disableText;
if (disableText) {
return null;
}
try {
const streamInfo = await this.createStreamInfoFromMediaTag_(tag);
goog.asserts.assert(
streamInfo, 'Should always have a streamInfo for text');
return streamInfo.stream;
return this.createStreamInfoFromMediaTag_(tag);
} catch (e) {
if (this.config_.hls.ignoreTextStreamFailures) {
return null;
Expand Down Expand Up @@ -900,16 +896,13 @@ shaka.hls.HlsParser = class {
*/
async parseImages_(imageTags) {
// Create image stream for each image tag.
const imageStreamPromises = imageTags.map(async (tag) => {
const imageStreamPromises = imageTags.map((tag) => {
const disableThumbnails = this.config_.disableThumbnails;
if (disableThumbnails) {
return null;
}
try {
const streamInfo = await this.createStreamInfoFromImageTag_(tag);
goog.asserts.assert(
streamInfo, 'Should always have a streamInfo for image');
return streamInfo.stream;
return this.createStreamInfoFromImageTag_(tag);
} catch (e) {
if (this.config_.hls.ignoreImageStreamFailures) {
return null;
Expand Down Expand Up @@ -1066,13 +1059,7 @@ shaka.hls.HlsParser = class {
if (!ignoreStream) {
streamInfo =
await this.createStreamInfoFromVariantTag_(tag, allCodecs, type);
}
if (streamInfo) {
res[streamInfo.stream.type] = [streamInfo];
} else if (streamInfo === null) {
// Triple-equals for undefined.
shaka.log.debug('streamInfo is null');
return null;
}
this.filterLegacyCodecs_(res);
return res;
Expand Down Expand Up @@ -1364,7 +1351,7 @@ shaka.hls.HlsParser = class {
* Parse EXT-X-MEDIA media tag into a Stream object.
*
* @param {shaka.hls.Tag} tag
* @return {!Promise.<?shaka.hls.HlsParser.StreamInfo>}
* @return {!Promise.<!shaka.hls.HlsParser.StreamInfo>}
* @private
*/
async createStreamInfoFromMediaTag_(tag) {
Expand Down Expand Up @@ -1418,9 +1405,6 @@ shaka.hls.HlsParser = class {
} else {
this.groupIdToStreamInfosMap_.set(groupId, [streamInfo]);
}
if (streamInfo == null) {
return null;
}

// TODO: This check is necessary because of the possibility of multiple
// calls to createStreamInfoFromMediaTag_ before either has resolved.
Expand All @@ -1435,7 +1419,7 @@ shaka.hls.HlsParser = class {
* Parse EXT-X-MEDIA media tag into a Stream object.
*
* @param {shaka.hls.Tag} tag
* @return {!Promise.<?shaka.hls.HlsParser.StreamInfo>}
* @return {!Promise.<!shaka.hls.HlsParser.StreamInfo>}
* @private
*/
async createStreamInfoFromImageTag_(tag) {
Expand Down Expand Up @@ -1463,9 +1447,6 @@ shaka.hls.HlsParser = class {
verbatimImagePlaylistUri, codecs, type, language, /* primary= */ false,
name, /* channelsCount= */ null, /* closedCaptions= */ null,
characteristics, /* forced= */ false, /* spatialAudio= */ false);
if (streamInfo == null) {
return null;
}

// TODO: This check is necessary because of the possibility of multiple
// calls to createStreamInfoFromImageTag_ before either has resolved.
Expand Down Expand Up @@ -1506,7 +1487,7 @@ shaka.hls.HlsParser = class {
* @param {!shaka.hls.Tag} tag
* @param {!Array.<string>} allCodecs
* @param {string} type
* @return {!Promise.<?shaka.hls.HlsParser.StreamInfo>}
* @return {!Promise.<!shaka.hls.HlsParser.StreamInfo>}
* @private
*/
async createStreamInfoFromVariantTag_(tag, allCodecs, type) {
Expand All @@ -1526,9 +1507,6 @@ shaka.hls.HlsParser = class {
/* name= */ null, /* channelcount= */ null, closedCaptions,
/* characteristics= */ null, /* forced= */ false,
/* spatialAudio= */ false);
if (streamInfo == null) {
return null;
}
// TODO: This check is necessary because of the possibility of multiple
// calls to createStreamInfoFromVariantTag_ before either has resolved.
if (this.uriToStreamInfosMap_.has(verbatimMediaPlaylistUri)) {
Expand All @@ -1552,7 +1530,7 @@ shaka.hls.HlsParser = class {
* @param {?string} characteristics
* @param {boolean} forced
* @param {boolean} spatialAudio
* @return {!Promise.<?shaka.hls.HlsParser.StreamInfo>}
* @return {!Promise.<!shaka.hls.HlsParser.StreamInfo>}
* @private
*/
async createStreamInfo_(verbatimMediaPlaylistUri, codecs, type, language,
Expand Down Expand Up @@ -1592,7 +1570,7 @@ shaka.hls.HlsParser = class {
* @param {boolean} forced
* @param {boolean} spatialAudio
* @param {(string|undefined)} mimeType
* @return {!Promise.<?shaka.hls.HlsParser.StreamInfo>}
* @return {!Promise.<!shaka.hls.HlsParser.StreamInfo>}
* @private
*/
async convertParsedPlaylistIntoStreamInfo_(playlist, verbatimMediaPlaylistUri,
Expand Down Expand Up @@ -1683,19 +1661,8 @@ shaka.hls.HlsParser = class {
/** @type {!Map.<number, number>} */
const mediaSequenceToStartTime = new Map();

let segments;
try {
segments = this.createSegments_(verbatimMediaPlaylistUri, playlist, type,
mimeType, mediaSequenceToStartTime, mediaVariables, codecs);
} catch (error) {
if (error.code == shaka.util.Error.Code.HLS_INTERNAL_SKIP_STREAM) {
shaka.log.alwaysWarn('Skipping unsupported HLS stream',
mimeType, verbatimMediaPlaylistUri);
return null;
}

throw error;
}
const segments = this.createSegments_(verbatimMediaPlaylistUri, playlist,
type, mimeType, mediaSequenceToStartTime, mediaVariables, codecs);

const lastEndTime = segments[segments.length - 1].endTime;
/** @type {!shaka.media.SegmentIndex} */
Expand Down
6 changes: 1 addition & 5 deletions lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,7 @@ shaka.util.Error.Code = {
*/
'HLS_AES_128_ENCRYPTION_NOT_SUPPORTED': 4034,

/**
* An internal error code that should never be seen by applications, thrown
* to force the HLS parser to skip an unsupported stream.
*/
'HLS_INTERNAL_SKIP_STREAM': 4035,
// RETIRED: 'HLS_INTERNAL_SKIP_STREAM': 4035,

/** The Manifest contained no Variants. */
'NO_VARIANTS': 4036,
Expand Down

0 comments on commit 264dd68

Please sign in to comment.