Skip to content

Commit

Permalink
fix(CEA): reset PTS on new init segment (#6671)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed May 27, 2024
1 parent 2f973d1 commit af74719
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions lib/media/closed_caption_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ shaka.media.IClosedCaptionParser = class {
* Initialize the caption parser. This should be called whenever new init
* segment arrives.
* @param {BufferSource} initSegment
* @param {boolean=} adaptation True if we just automatically switched active
* variant(s).
*/
init(initSegment) {}
init(initSegment, adaptation = false) {}

/**
* Parses embedded CEA closed captions and interacts with the underlying
Expand Down Expand Up @@ -89,12 +91,16 @@ shaka.media.ClosedCaptionParser = class {
/**
* @override
*/
init(initSegment) {
init(initSegment, adaptation = false) {
shaka.log.debug('Passing new init segment to CEA parser');
// Reset underlying decoder when new init segment arrives
// to clear stored pts values.
this.reset();
this.ceaParser_.init(initSegment);
if (!adaptation) {
// Reset underlying decoder when new init segment arrives
// to clear stored pts values.
// This is necessary when a new Period comes in DASH or a discontinuity
// in HLS.
this.reset();
this.ceaParser_.init(initSegment);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ shaka.media.MediaSourceEngine = class {
// If it is the init segment for closed captions, initialize the closed
// caption parser.
if (!reference) {
this.captionParser_.init(data);
this.captionParser_.init(data, adaptation);
} else {
const closedCaptions = this.captionParser_.parseFrom(data);
if (closedCaptions.length) {
Expand Down

0 comments on commit af74719

Please sign in to comment.