From 6d6ac8321bf4e72ff7ec4e81fc250f3f547773fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Tue, 14 May 2024 11:19:26 +0200 Subject: [PATCH] fix(CEA): reset PTS on new init segment (#6606) 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. --- lib/cea/cea_decoder.js | 3 +++ lib/media/closed_caption_parser.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/cea/cea_decoder.js b/lib/cea/cea_decoder.js index dc4bbe6749..959b42dc0d 100644 --- a/lib/cea/cea_decoder.js +++ b/lib/cea/cea_decoder.js @@ -97,6 +97,7 @@ shaka.cea.CeaDecoder = class { * @override */ clear() { + shaka.log.debug('Clearing CEA decoder'); this.badFrames_ = 0; this.cea608DataArray_ = []; this.cea708DataArray_ = []; @@ -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()) { @@ -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); } diff --git a/lib/media/closed_caption_parser.js b/lib/media/closed_caption_parser.js index b85385d912..71a1240e60 100644 --- a/lib/media/closed_caption_parser.js +++ b/lib/media/closed_caption_parser.js @@ -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'); @@ -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) {} @@ -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); }