diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 9a4ba731fc..476992a817 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -1164,8 +1164,8 @@ shaka.hls.HlsParser = class { if (shaka.util.TsParser.probe( shaka.util.BufferUtils.toUint8(data))) { - const basicInfo = - shaka.media.SegmentUtils.getBasicInfoFromTs(data); + const basicInfo = shaka.media.SegmentUtils.getBasicInfoFromTs( + data, this.config_.disableAudio, this.config_.disableVideo); if (basicInfo) { return basicInfo; } diff --git a/lib/media/segment_utils.js b/lib/media/segment_utils.js index 3cdb4319ed..8fbcb248f0 100644 --- a/lib/media/segment_utils.js +++ b/lib/media/segment_utils.js @@ -48,9 +48,11 @@ shaka.media.SegmentUtils = class { /** * @param {!BufferSource} data + * @param {boolean=} disableAudio + * @param {boolean=} disableVideo * @return {?shaka.media.SegmentUtils.BasicInfo} */ - static getBasicInfoFromTs(data) { + static getBasicInfoFromTs(data, disableAudio = false, disableVideo = false) { const uint8ArrayData = shaka.util.BufferUtils.toUint8(data); const tsParser = new shaka.util.TsParser().parse(uint8ArrayData); const tsCodecs = tsParser.getCodecs(); @@ -58,50 +60,54 @@ shaka.media.SegmentUtils = class { const codecs = []; let hasAudio = false; let hasVideo = false; - switch (tsCodecs.audio) { - case 'aac': - case 'aac-loas': - codecs.push('mp4a.40.2'); - hasAudio = true; - break; - case 'mp3': - codecs.push('mp4a.40.34'); - hasAudio = true; - break; - case 'ac3': - codecs.push('ac-3'); - hasAudio = true; - break; - case 'ec3': - codecs.push('ec-3'); - hasAudio = true; - break; - case 'opus': - codecs.push('opus'); - hasAudio = true; - break; + if (!disableAudio) { + switch (tsCodecs.audio) { + case 'aac': + case 'aac-loas': + codecs.push('mp4a.40.2'); + hasAudio = true; + break; + case 'mp3': + codecs.push('mp4a.40.34'); + hasAudio = true; + break; + case 'ac3': + codecs.push('ac-3'); + hasAudio = true; + break; + case 'ec3': + codecs.push('ec-3'); + hasAudio = true; + break; + case 'opus': + codecs.push('opus'); + hasAudio = true; + break; + } } - switch (tsCodecs.video) { - case 'avc': - if (videoInfo.codec) { - codecs.push(videoInfo.codec); - } else { - codecs.push('avc1.42E01E'); - } - hasVideo = true; - break; - case 'hvc': - if (videoInfo.codec) { - codecs.push(videoInfo.codec); - } else { - codecs.push('hvc1.1.6.L93.90'); - } - hasVideo = true; - break; - case 'av1': - codecs.push('av01.0.01M.08'); - hasVideo = true; - break; + if (!disableVideo) { + switch (tsCodecs.video) { + case 'avc': + if (videoInfo.codec) { + codecs.push(videoInfo.codec); + } else { + codecs.push('avc1.42E01E'); + } + hasVideo = true; + break; + case 'hvc': + if (videoInfo.codec) { + codecs.push(videoInfo.codec); + } else { + codecs.push('hvc1.1.6.L93.90'); + } + hasVideo = true; + break; + case 'av1': + codecs.push('av01.0.01M.08'); + hasVideo = true; + break; + } } if (!codecs.length) { return null;