Skip to content

Commit

Permalink
chore(HLS): Retired unused error code (#4428)
Browse files Browse the repository at this point in the history
Now that #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 #1936
  • Loading branch information
theodab authored and Alvaro Velad committed Aug 31, 2022
1 parent d668790 commit 97303dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 62 deletions.
77 changes: 20 additions & 57 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 @@ -863,8 +862,6 @@ shaka.hls.HlsParser = class {
}
try {
const streamInfo = await this.createStreamInfoFromMediaTag_(tag);
goog.asserts.assert(
streamInfo, 'Should always have a streamInfo for text');
return streamInfo.stream;
} catch (e) {
if (this.config_.hls.ignoreTextStreamFailures) {
Expand Down Expand Up @@ -907,8 +904,6 @@ shaka.hls.HlsParser = class {
}
try {
const streamInfo = await this.createStreamInfoFromImageTag_(tag);
goog.asserts.assert(
streamInfo, 'Should always have a streamInfo for image');
return streamInfo.stream;
} catch (e) {
if (this.config_.hls.ignoreImageStreamFailures) {
Expand Down Expand Up @@ -960,22 +955,17 @@ shaka.hls.HlsParser = class {
const streamInfos = await this.createStreamInfosForVariantTag_(tag,
resolution, frameRate);

if (streamInfos) {
goog.asserts.assert(streamInfos.audio.length ||
streamInfos.video.length, 'We should have created a stream!');

return this.createVariants_(
streamInfos.audio,
streamInfos.video,
bandwidth,
width,
height,
frameRate,
videoRange);
}
// We do not support AES-128 encryption with HLS yet. If the streamInfos
// is null because of AES-128 encryption, do not create variants for that.
return [];
goog.asserts.assert(streamInfos.audio.length ||
streamInfos.video.length, 'We should have created a stream!');

return this.createVariants_(
streamInfos.audio,
streamInfos.video,
bandwidth,
width,
height,
frameRate,
videoRange);
});

const allVariants = await Promise.all(variantsPromises);
Expand All @@ -992,7 +982,7 @@ shaka.hls.HlsParser = class {
* @param {!shaka.hls.Tag} tag
* @param {?string} resolution
* @param {?string} frameRate
* @return {!Promise.<?shaka.hls.HlsParser.StreamInfos>}
* @return {!Promise.<!shaka.hls.HlsParser.StreamInfos>}
* @private
*/
async createStreamInfosForVariantTag_(tag, resolution, frameRate) {
Expand Down Expand Up @@ -1062,17 +1052,10 @@ shaka.hls.HlsParser = class {
type = ContentType.VIDEO;
}

let streamInfo;
if (!ignoreStream) {
streamInfo =
const 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 +1347,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 +1401,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 +1415,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 +1443,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 +1483,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 +1503,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 +1526,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 +1566,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 +1657,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 97303dd

Please sign in to comment.