Skip to content

Commit

Permalink
fix(CEA): reset PTS on new init segment (#6606)
Browse files Browse the repository at this point in the history
Fixes #6605
Resets cache (including last used presentation timestamp) of CEA Decoder
on every init segment append.
Adds few debug logs to easify investigations in the future.
  • Loading branch information
tykus160 authored and avelad committed May 14, 2024
1 parent 270d342 commit 6d6ac83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/cea/cea_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ shaka.cea.CeaDecoder = class {
* @override
*/
clear() {
shaka.log.debug('Clearing CEA decoder');
this.badFrames_ = 0;
this.cea608DataArray_ = [];
this.cea708DataArray_ = [];
Expand All @@ -113,6 +114,7 @@ shaka.cea.CeaDecoder = class {
* Resets the decoder.
*/
reset() {
shaka.log.debug('Resetting CEA decoder');
this.currentField1Channel_ = 0;
this.currentField2Channel_ = 0;
for (const stream of this.cea608ModeToStream_.values()) {
Expand All @@ -128,6 +130,7 @@ shaka.cea.CeaDecoder = class {
*/
extract(userDataSeiMessage, pts) {
if (this.waitingForFirstPacket_) {
shaka.log.debug('Setting first pts value to', pts);
for (const stream of this.cea608ModeToStream_.values()) {
stream.firstPts(pts);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/media/closed_caption_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ goog.provide('shaka.media.IClosedCaptionParser');

goog.require('shaka.cea.DummyCaptionDecoder');
goog.require('shaka.cea.DummyCeaParser');
goog.require('shaka.log');
goog.require('shaka.util.BufferUtils');


Expand All @@ -22,7 +23,8 @@ goog.require('shaka.util.BufferUtils');
*/
shaka.media.IClosedCaptionParser = class {
/**
* Initialize the caption parser. This should be called only once.
* Initialize the caption parser. This should be called whenever new init
* segment arrives.
* @param {BufferSource} initSegment
*/
init(initSegment) {}
Expand Down Expand Up @@ -88,6 +90,10 @@ shaka.media.ClosedCaptionParser = class {
* @override
*/
init(initSegment) {
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);
}

Expand Down

0 comments on commit 6d6ac83

Please sign in to comment.