From 414cccf662a451879a8fef286c40ee1f2a1f112f Mon Sep 17 00:00:00 2001 From: Alvaro Velad Galvan Date: Tue, 28 Feb 2023 13:13:29 +0100 Subject: [PATCH 1/3] fix: Allow the playback of TS without mux.js --- lib/transmuxer/muxjs_transmuxer.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/transmuxer/muxjs_transmuxer.js b/lib/transmuxer/muxjs_transmuxer.js index ebb56b4722..b5ce7e189f 100644 --- a/lib/transmuxer/muxjs_transmuxer.js +++ b/lib/transmuxer/muxjs_transmuxer.js @@ -33,9 +33,7 @@ shaka.transmuxer.MuxjsTransmuxer = class { this.muxjs_ = shaka.dependencies.muxjs(); /** @private {muxjs.mp4.Transmuxer} */ - this.muxTransmuxer_ = new this.muxjs_.mp4.Transmuxer({ - 'keepOriginalTimestamps': true, - }); + this.muxTransmuxer_ = null; /** @private {shaka.util.PublicPromise} */ this.transmuxPromise_ = null; @@ -46,9 +44,13 @@ shaka.transmuxer.MuxjsTransmuxer = class { /** @private {boolean} */ this.isTransmuxing_ = false; - this.muxTransmuxer_.on('data', (segment) => this.onTransmuxed_(segment)); - - this.muxTransmuxer_.on('done', () => this.onTransmuxDone_()); + if (this.muxjs_) { + this.muxTransmuxer_ = new this.muxjs_.mp4.Transmuxer({ + 'keepOriginalTimestamps': true, + }); + this.muxTransmuxer_.on('data', (segment) => this.onTransmuxed_(segment)); + this.muxTransmuxer_.on('done', () => this.onTransmuxDone_()); + } } @@ -57,7 +59,9 @@ shaka.transmuxer.MuxjsTransmuxer = class { * @export */ destroy() { - this.muxTransmuxer_.dispose(); + if (this.muxTransmuxer_) { + this.muxTransmuxer_.dispose(); + } this.muxTransmuxer_ = null; } From bd7acb2b17c82cc9885d9d75455bcb3eefc08594 Mon Sep 17 00:00:00 2001 From: Alvaro Velad Galvan Date: Tue, 28 Feb 2023 13:59:08 +0100 Subject: [PATCH 2/3] Add assert --- lib/transmuxer/muxjs_transmuxer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/transmuxer/muxjs_transmuxer.js b/lib/transmuxer/muxjs_transmuxer.js index b5ce7e189f..9e7c319499 100644 --- a/lib/transmuxer/muxjs_transmuxer.js +++ b/lib/transmuxer/muxjs_transmuxer.js @@ -211,6 +211,8 @@ shaka.transmuxer.MuxjsTransmuxer = class { * @export */ transmux(data) { + goog.asserts.assert(!this.muxTransmuxer_, + 'mux.js should be available.'); goog.asserts.assert(!this.isTransmuxing_, 'No transmuxing should be in progress.'); this.isTransmuxing_ = true; From 01e1f7e5a8d685a6d13539d708b5ce333666bd7b Mon Sep 17 00:00:00 2001 From: Alvaro Velad Galvan Date: Tue, 28 Feb 2023 14:01:08 +0100 Subject: [PATCH 3/3] Fix typo --- lib/transmuxer/muxjs_transmuxer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transmuxer/muxjs_transmuxer.js b/lib/transmuxer/muxjs_transmuxer.js index 9e7c319499..1feee6f695 100644 --- a/lib/transmuxer/muxjs_transmuxer.js +++ b/lib/transmuxer/muxjs_transmuxer.js @@ -211,7 +211,7 @@ shaka.transmuxer.MuxjsTransmuxer = class { * @export */ transmux(data) { - goog.asserts.assert(!this.muxTransmuxer_, + goog.asserts.assert(this.muxTransmuxer_, 'mux.js should be available.'); goog.asserts.assert(!this.isTransmuxing_, 'No transmuxing should be in progress.');