Skip to content

Commit

Permalink
fix(HLS): Disable text correctly when loading a media playlist (#7840)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jan 7, 2025
1 parent e6ca059 commit 0fa17f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1165,15 +1165,16 @@ shaka.hls.HlsParser = class {
if (shaka.util.TsParser.probe(
shaka.util.BufferUtils.toUint8(data))) {
const basicInfo = shaka.media.SegmentUtils.getBasicInfoFromTs(
data, this.config_.disableAudio, this.config_.disableVideo);
data, this.config_.disableAudio, this.config_.disableVideo,
this.config_.disableText);
if (basicInfo) {
return basicInfo;
}
} else if (validMp4Extensions.includes(extension) ||
validMp4MimeType.includes(contentMimeType) ||
(initMimeType && validMp4MimeType.includes(initMimeType))) {
const basicInfo = shaka.media.SegmentUtils.getBasicInfoFromMp4(
initData, data);
initData, data, this.config_.disableText);
if (basicInfo) {
return basicInfo;
}
Expand Down
14 changes: 8 additions & 6 deletions lib/media/segment_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ shaka.media.SegmentUtils = class {

/**
* @param {!BufferSource} data
* @param {boolean=} disableAudio
* @param {boolean=} disableVideo
* @param {boolean} disableAudio
* @param {boolean} disableVideo
* @param {boolean} disableText
* @return {?shaka.media.SegmentUtils.BasicInfo}
*/
static getBasicInfoFromTs(data, disableAudio = false, disableVideo = false) {
static getBasicInfoFromTs(data, disableAudio, disableVideo, disableText) {
const uint8ArrayData = shaka.util.BufferUtils.toUint8(data);
const tsParser = new shaka.util.TsParser().parse(uint8ArrayData);
const tsCodecs = tsParser.getCodecs();
Expand Down Expand Up @@ -124,7 +125,7 @@ shaka.media.SegmentUtils = class {
}
const onlyAudio = hasAudio && !hasVideo;
const closedCaptions = new Map();
if (hasVideo) {
if (hasVideo && !disableText) {
const captionParser = new shaka.media.ClosedCaptionParser('video/mp2t');
captionParser.parseFrom(data);
for (const stream of captionParser.getStreams()) {
Expand All @@ -151,9 +152,10 @@ shaka.media.SegmentUtils = class {
/**
* @param {?BufferSource} initData
* @param {!BufferSource} data
* @param {boolean} disableText
* @return {?shaka.media.SegmentUtils.BasicInfo}
*/
static getBasicInfoFromMp4(initData, data) {
static getBasicInfoFromMp4(initData, data, disableText) {
const Mp4Parser = shaka.util.Mp4Parser;
const SegmentUtils = shaka.media.SegmentUtils;

Expand Down Expand Up @@ -428,7 +430,7 @@ shaka.media.SegmentUtils = class {
}
const onlyAudio = hasAudio && !hasVideo;
const closedCaptions = new Map();
if (hasVideo) {
if (hasVideo && !disableText) {
const captionParser = new shaka.media.ClosedCaptionParser('video/mp4');
if (initData) {
captionParser.init(initData);
Expand Down

0 comments on commit 0fa17f6

Please sign in to comment.