From 3ccb11a3a83f6cbd1ed6552bd6be8a7e83eebcc2 Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Thu, 1 Jul 2021 16:45:52 -0400 Subject: [PATCH 1/5] chore: use transmuxer debug/warn/error events to the debug log --- src/media-segment-request.js | 59 ++++++++++++++++++++++++++++++------ src/segment-loader.js | 11 ++++++- src/segment-transmuxer.js | 12 ++++++++ src/transmuxer-worker.js | 12 ++++++++ 4 files changed, 83 insertions(+), 11 deletions(-) diff --git a/src/media-segment-request.js b/src/media-segment-request.js index 1f7113215..f51eb3fed 100644 --- a/src/media-segment-request.js +++ b/src/media-segment-request.js @@ -289,7 +289,10 @@ const transmuxAndNotify = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerError, + onTransmuxerWarn, + onTransmuxerDebug }) => { const fmp4Tracks = segment.map && segment.map.tracks || {}; const isMuxed = Boolean(fmp4Tracks.audio && fmp4Tracks.video); @@ -358,6 +361,15 @@ const transmuxAndNotify = ({ onEndedTimeline: () => { endedTimelineFn(); }, + onError: ({message}) => { + onTransmuxerError(message); + }, + onWarn: ({message}) => { + onTransmuxerWarn(message); + }, + onDebug: ({message}) => { + onTransmuxerDebug(message); + }, onDone: (result) => { if (!doneFn) { return; @@ -415,7 +427,10 @@ const handleSegmentBytes = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerDebug, + onTransmuxerWarn, + onTransmuxerError }) => { let bytesAsUint8Array = new Uint8Array(bytes); @@ -547,7 +562,10 @@ const handleSegmentBytes = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerError, + onTransmuxerDebug, + onTransmuxerWarn }); }; @@ -623,7 +641,10 @@ const decryptSegment = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerDebug, + onTransmuxerWarn, + onTransmuxerError }) => { decrypt({ id: segment.requestId, @@ -645,7 +666,10 @@ const decryptSegment = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerError, + onTransmuxerWarn, + onTransmuxerDebug }); }); }; @@ -691,7 +715,10 @@ const waitForCompletion = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerDebug, + onTransmuxerWarn, + onTransmuxerError }) => { let count = 0; let didError = false; @@ -737,7 +764,10 @@ const waitForCompletion = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerError, + onTransmuxerWarn, + onTransmuxerDebug }); } // Otherwise, everything is ready just continue @@ -753,7 +783,10 @@ const waitForCompletion = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerError, + onTransmuxerWarn, + onTransmuxerDebug }); }; @@ -942,7 +975,10 @@ export const mediaSegmentRequest = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerDebug, + onTransmuxerWarn, + onTransmuxerError }) => { const activeXhrs = []; const finishProcessingFn = waitForCompletion({ @@ -957,7 +993,10 @@ export const mediaSegmentRequest = ({ isEndOfTimeline, endedTimelineFn, dataFn, - doneFn + doneFn, + onTransmuxerDebug, + onTransmuxerWarn, + onTransmuxerError }); // optionally, request the decryption key diff --git a/src/segment-loader.js b/src/segment-loader.js index b5c8c8caf..53df2c8b8 100644 --- a/src/segment-loader.js +++ b/src/segment-loader.js @@ -2427,7 +2427,16 @@ export default class SegmentLoader extends videojs.EventTarget { id3Fn: this.handleId3_.bind(this), dataFn: this.handleData_.bind(this), - doneFn: this.segmentRequestFinished_.bind(this) + doneFn: this.segmentRequestFinished_.bind(this), + onTransmuxerWarn: (message) => { + this.logger_(`${segmentInfoString(segmentInfo)} transmuxer warn: ${message}`); + }, + onTransmuxerDebug: (message) => { + this.logger_(`${segmentInfoString(segmentInfo)} transmuxer debug: ${message}`); + }, + onTransmuxerError: (message) => { + this.logger_(`${segmentInfoString(segmentInfo)} transmuxer error: ${message}`); + } }); } diff --git a/src/segment-transmuxer.js b/src/segment-transmuxer.js index d3511308f..65b33f52e 100644 --- a/src/segment-transmuxer.js +++ b/src/segment-transmuxer.js @@ -81,6 +81,9 @@ export const processTransmux = (options) => { onCaptions, onDone, onEndedTimeline, + onWarn, + onDebug, + onError, isEndOfTimeline } = options; const transmuxedData = { @@ -125,6 +128,15 @@ export const processTransmux = (options) => { waitForEndedTimelineEvent = false; onEndedTimeline(); } + if (event.data.action === 'warn') { + onWarn(event.data.message); + } + if (event.data.action === 'debug') { + onDebug(event.data.message); + } + if (event.data.action === 'error') { + onError(event.data.message); + } // wait for the transmuxed event since we may have audio and video if (event.data.type !== 'transmuxed') { diff --git a/src/transmuxer-worker.js b/src/transmuxer-worker.js index 7d8e5d764..d97ae1315 100644 --- a/src/transmuxer-worker.js +++ b/src/transmuxer-worker.js @@ -155,6 +155,18 @@ const wireTransmuxerEvents = function(self, transmuxer) { }); }); + transmuxer.on('debug', function(message) { + self.postMessage({action: 'debug', message}); + }); + + transmuxer.on('error', function(message) { + self.postMessage({action: 'error', message}); + }); + + transmuxer.on('warn', function(message) { + self.postMessage({action: 'warn', message}); + }); + }; /** From bc0236b22f9d2356db4622c35a81a4391ef91212 Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Fri, 2 Jul 2021 11:31:19 -0400 Subject: [PATCH 2/5] add test --- src/media-segment-request.js | 6 ++-- src/transmuxer-worker.js | 6 ++-- test/segment-loader.test.js | 64 ++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/src/media-segment-request.js b/src/media-segment-request.js index f51eb3fed..23322a775 100644 --- a/src/media-segment-request.js +++ b/src/media-segment-request.js @@ -361,13 +361,13 @@ const transmuxAndNotify = ({ onEndedTimeline: () => { endedTimelineFn(); }, - onError: ({message}) => { + onError: (message) => { onTransmuxerError(message); }, - onWarn: ({message}) => { + onWarn: (message) => { onTransmuxerWarn(message); }, - onDebug: ({message}) => { + onDebug: (message) => { onTransmuxerDebug(message); }, onDone: (result) => { diff --git a/src/transmuxer-worker.js b/src/transmuxer-worker.js index d97ae1315..e116a4dfe 100644 --- a/src/transmuxer-worker.js +++ b/src/transmuxer-worker.js @@ -155,15 +155,15 @@ const wireTransmuxerEvents = function(self, transmuxer) { }); }); - transmuxer.on('debug', function(message) { + transmuxer.on('debug', function({message}) { self.postMessage({action: 'debug', message}); }); - transmuxer.on('error', function(message) { + transmuxer.on('error', function({message}) { self.postMessage({action: 'error', message}); }); - transmuxer.on('warn', function(message) { + transmuxer.on('warn', function({message}) { self.postMessage({action: 'warn', message}); }); diff --git a/test/segment-loader.test.js b/test/segment-loader.test.js index d4f049d7e..29bbbfed9 100644 --- a/test/segment-loader.test.js +++ b/test/segment-loader.test.js @@ -902,6 +902,70 @@ QUnit.module('SegmentLoader', function(hooks) { }); }); + QUnit.test('logs warnings, debugs, and errors from the transmuxer', function(assert) { + const playlist = playlistWithDuration(10); + const ogPost = loader.transmuxer_.postMessage; + const messages = []; + + loader.logger_ = (message) => { + messages.push(message); + }; + + loader.transmuxer_.postMessage = (message) => { + if (message.action === 'flush') { + const debug = newEvent('message'); + const error = newEvent('message'); + const warn = newEvent('message'); + + debug.data = {action: 'debug', message: 'debug foo'}; + error.data = {action: 'error', message: 'error foo'}; + warn.data = {action: 'warn', message: 'warning foo'}; + + loader.transmuxer_.dispatchEvent(debug); + loader.transmuxer_.dispatchEvent(error); + loader.transmuxer_.dispatchEvent(warn); + return; + } + return ogPost.call(loader.transmuxer_, message); + }; + + return setupMediaSource(loader.mediaSource_, loader.sourceUpdater_, {isVideoOnly: true}).then(() => { + return new Promise((resolve, reject) => { + loader.one('appended', resolve); + loader.one('error', reject); + + loader.playlist(playlist); + loader.load(); + + this.clock.tick(100); + // segment + standardXHRResponse(this.requests.shift(), videoOneSecondSegment()); + }); + }).then(() => { + let debugFound = false; + let warnFound = false; + let errorFound = false; + + messages.forEach(function(message) { + if ((/debug foo/).test(message)) { + debugFound = true; + } + + if ((/warning foo/).test(message)) { + warnFound = true; + } + + if ((/error foo/).test(message)) { + errorFound = true; + } + }); + + assert.ok(debugFound, 'debug message was logged'); + assert.ok(warnFound, 'warn message was logged'); + assert.ok(errorFound, 'error message was logged'); + }); + }); + QUnit.test('segmentKey will cache new encrypted keys with cacheEncryptionKeys true', function(assert) { loader.cacheEncryptionKeys_ = true; From 7d38d47be024f2cd4abac8604d9f54fb2c109444 Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Fri, 2 Jul 2021 12:13:45 -0400 Subject: [PATCH 3/5] update worker-factory and test for sync --- package-lock.json | 6 +++--- package.json | 2 +- test/segment-loader.test.js | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index e7cf7003c..b87a4e77c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7715,9 +7715,9 @@ } }, "rollup-plugin-worker-factory": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/rollup-plugin-worker-factory/-/rollup-plugin-worker-factory-0.5.5.tgz", - "integrity": "sha512-kbsvueLjSntAFjBnnD7UOWTdc1zcufshG97M+Muu2s1mugtiviYpz/jR1WQyZK1u5ZA2tbSCCqRzHHe6FmpoIg==", + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/rollup-plugin-worker-factory/-/rollup-plugin-worker-factory-0.5.7.tgz", + "integrity": "sha512-DZ9HOy8FFVnx9in/x2DFrbH2Dj3iBMUm5zuisBnfQst2WcDbNicJLveiytgnoKqXQnBm7TPnlEklp4ce1eT1aw==", "dev": true, "requires": { "rollup": "^2.34.2" diff --git a/package.json b/package.json index 27db21353..fc1785796 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "lodash-compat": "^3.10.0", "nomnoml": "^0.3.0", "rollup": "^2.36.1", - "rollup-plugin-worker-factory": "0.5.5", + "rollup-plugin-worker-factory": "0.5.7", "shelljs": "^0.8.4", "sinon": "^8.1.1", "url-toolkit": "^2.2.1", diff --git a/test/segment-loader.test.js b/test/segment-loader.test.js index 29bbbfed9..781119424 100644 --- a/test/segment-loader.test.js +++ b/test/segment-loader.test.js @@ -912,7 +912,9 @@ QUnit.module('SegmentLoader', function(hooks) { }; loader.transmuxer_.postMessage = (message) => { - if (message.action === 'flush') { + const retval = ogPost.call(loader.transmuxer_, message); + + if (message.action === 'push') { const debug = newEvent('message'); const error = newEvent('message'); const warn = newEvent('message'); @@ -926,7 +928,8 @@ QUnit.module('SegmentLoader', function(hooks) { loader.transmuxer_.dispatchEvent(warn); return; } - return ogPost.call(loader.transmuxer_, message); + + return retval; }; return setupMediaSource(loader.mediaSource_, loader.sourceUpdater_, {isVideoOnly: true}).then(() => { From 7c9b4738acd867ac1d27128a2dc97894d3312c69 Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Fri, 2 Jul 2021 12:20:24 -0400 Subject: [PATCH 4/5] update mux.js --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index b87a4e77c..dfe4cfd50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6563,9 +6563,9 @@ "dev": true }, "mux.js": { - "version": "5.11.3", - "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-5.11.3.tgz", - "integrity": "sha512-wL7zb7CMthrTVhVFOKiU/HrWeNA9vbPNIIebhkFRz5g2nTDgBsQPsDoHYW8pk4sgHgY9wvuzrqlDvLkhdPPgrw==", + "version": "5.12.0", + "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-5.12.0.tgz", + "integrity": "sha512-xDvaPG3lkMvUgPqppJPQ4GYc9bx/vriU1rHoT+Y35QG2/t/vWDZ8395zJtu+FDuE0WC/KmsUnCN9S7smURIp5Q==", "requires": { "@babel/runtime": "^7.11.2" } diff --git a/package.json b/package.json index fc1785796..85ee17d4a 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "global": "^4.4.0", "m3u8-parser": "4.7.0", "mpd-parser": "0.17.0", - "mux.js": "5.11.3", + "mux.js": "5.12.0", "video.js": "^6 || ^7" }, "peerDependencies": { From 5497d00ab44a57d4a5b73d3dd7e25114b802ba6e Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Fri, 9 Jul 2021 12:09:12 -0400 Subject: [PATCH 5/5] switch from debug/warn/error to log --- package-lock.json | 6 ++-- package.json | 2 +- src/media-segment-request.js | 53 ++++++++---------------------- src/segment-loader.js | 10 ++---- src/segment-transmuxer.js | 14 ++------ src/transmuxer-worker.js | 13 ++------ test/media-segment-request.test.js | 9 +++-- test/segment-loader.test.js | 34 +++++-------------- test/transmuxer-worker.test.js | 1 + 9 files changed, 41 insertions(+), 101 deletions(-) diff --git a/package-lock.json b/package-lock.json index dfe4cfd50..d5f1677d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6563,9 +6563,9 @@ "dev": true }, "mux.js": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-5.12.0.tgz", - "integrity": "sha512-xDvaPG3lkMvUgPqppJPQ4GYc9bx/vriU1rHoT+Y35QG2/t/vWDZ8395zJtu+FDuE0WC/KmsUnCN9S7smURIp5Q==", + "version": "5.12.1", + "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-5.12.1.tgz", + "integrity": "sha512-bUZmpGr9fdyAsCc8UO761x8VKIxRuSIJ4yFX7F5bDer6bz5nCFcb3hbgFNc0bA3/v/Tp96Rftftexnx6BZAbVg==", "requires": { "@babel/runtime": "^7.11.2" } diff --git a/package.json b/package.json index 85ee17d4a..d1ede88f1 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "global": "^4.4.0", "m3u8-parser": "4.7.0", "mpd-parser": "0.17.0", - "mux.js": "5.12.0", + "mux.js": "5.12.1", "video.js": "^6 || ^7" }, "peerDependencies": { diff --git a/src/media-segment-request.js b/src/media-segment-request.js index 23322a775..d6c91051e 100644 --- a/src/media-segment-request.js +++ b/src/media-segment-request.js @@ -290,9 +290,7 @@ const transmuxAndNotify = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerError, - onTransmuxerWarn, - onTransmuxerDebug + onTransmuxerLog }) => { const fmp4Tracks = segment.map && segment.map.tracks || {}; const isMuxed = Boolean(fmp4Tracks.audio && fmp4Tracks.video); @@ -361,15 +359,7 @@ const transmuxAndNotify = ({ onEndedTimeline: () => { endedTimelineFn(); }, - onError: (message) => { - onTransmuxerError(message); - }, - onWarn: (message) => { - onTransmuxerWarn(message); - }, - onDebug: (message) => { - onTransmuxerDebug(message); - }, + onTransmuxerLog, onDone: (result) => { if (!doneFn) { return; @@ -428,9 +418,7 @@ const handleSegmentBytes = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerDebug, - onTransmuxerWarn, - onTransmuxerError + onTransmuxerLog }) => { let bytesAsUint8Array = new Uint8Array(bytes); @@ -525,6 +513,9 @@ const handleSegmentBytes = ({ // transfer bytes back to us bytes = message.data.buffer; segment.bytes = bytesAsUint8Array = message.data; + message.logs.forEach(function(log) { + onTransmuxerLog(videojs.mergeOptions(log, {stream: 'mp4CaptionParser'})); + }); finishLoading(message.captions); } }); @@ -563,9 +554,7 @@ const handleSegmentBytes = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerError, - onTransmuxerDebug, - onTransmuxerWarn + onTransmuxerLog }); }; @@ -642,9 +631,7 @@ const decryptSegment = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerDebug, - onTransmuxerWarn, - onTransmuxerError + onTransmuxerLog }) => { decrypt({ id: segment.requestId, @@ -667,9 +654,7 @@ const decryptSegment = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerError, - onTransmuxerWarn, - onTransmuxerDebug + onTransmuxerLog }); }); }; @@ -716,9 +701,7 @@ const waitForCompletion = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerDebug, - onTransmuxerWarn, - onTransmuxerError + onTransmuxerLog }) => { let count = 0; let didError = false; @@ -765,9 +748,7 @@ const waitForCompletion = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerError, - onTransmuxerWarn, - onTransmuxerDebug + onTransmuxerLog }); } // Otherwise, everything is ready just continue @@ -784,9 +765,7 @@ const waitForCompletion = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerError, - onTransmuxerWarn, - onTransmuxerDebug + onTransmuxerLog }); }; @@ -976,9 +955,7 @@ export const mediaSegmentRequest = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerDebug, - onTransmuxerWarn, - onTransmuxerError + onTransmuxerLog }) => { const activeXhrs = []; const finishProcessingFn = waitForCompletion({ @@ -994,9 +971,7 @@ export const mediaSegmentRequest = ({ endedTimelineFn, dataFn, doneFn, - onTransmuxerDebug, - onTransmuxerWarn, - onTransmuxerError + onTransmuxerLog }); // optionally, request the decryption key diff --git a/src/segment-loader.js b/src/segment-loader.js index 53df2c8b8..4b3598f15 100644 --- a/src/segment-loader.js +++ b/src/segment-loader.js @@ -2428,14 +2428,8 @@ export default class SegmentLoader extends videojs.EventTarget { dataFn: this.handleData_.bind(this), doneFn: this.segmentRequestFinished_.bind(this), - onTransmuxerWarn: (message) => { - this.logger_(`${segmentInfoString(segmentInfo)} transmuxer warn: ${message}`); - }, - onTransmuxerDebug: (message) => { - this.logger_(`${segmentInfoString(segmentInfo)} transmuxer debug: ${message}`); - }, - onTransmuxerError: (message) => { - this.logger_(`${segmentInfoString(segmentInfo)} transmuxer error: ${message}`); + onTransmuxerLog: ({message, level, stream}) => { + this.logger_(`${segmentInfoString(segmentInfo)} logged from transmuxer stream ${stream} as a ${level}: ${message}`); } }); } diff --git a/src/segment-transmuxer.js b/src/segment-transmuxer.js index 65b33f52e..6d1bb789e 100644 --- a/src/segment-transmuxer.js +++ b/src/segment-transmuxer.js @@ -81,9 +81,7 @@ export const processTransmux = (options) => { onCaptions, onDone, onEndedTimeline, - onWarn, - onDebug, - onError, + onTransmuxerLog, isEndOfTimeline } = options; const transmuxedData = { @@ -128,14 +126,8 @@ export const processTransmux = (options) => { waitForEndedTimelineEvent = false; onEndedTimeline(); } - if (event.data.action === 'warn') { - onWarn(event.data.message); - } - if (event.data.action === 'debug') { - onDebug(event.data.message); - } - if (event.data.action === 'error') { - onError(event.data.message); + if (event.data.action === 'log') { + onTransmuxerLog(event.data.log); } // wait for the transmuxed event since we may have audio and video diff --git a/src/transmuxer-worker.js b/src/transmuxer-worker.js index e116a4dfe..d8f9e7e3f 100644 --- a/src/transmuxer-worker.js +++ b/src/transmuxer-worker.js @@ -155,16 +155,8 @@ const wireTransmuxerEvents = function(self, transmuxer) { }); }); - transmuxer.on('debug', function({message}) { - self.postMessage({action: 'debug', message}); - }); - - transmuxer.on('error', function({message}) { - self.postMessage({action: 'error', message}); - }); - - transmuxer.on('warn', function({message}) { - self.postMessage({action: 'warn', message}); + transmuxer.on('log', function(log) { + self.postMessage({action: 'log', log}); }); }; @@ -210,6 +202,7 @@ class MessageHandlers { this.self.postMessage({ action: 'mp4Captions', captions: parsed && parsed.captions || [], + logs: parsed && parsed.logs || [], data: segment.buffer }, [segment.buffer]); } diff --git a/test/media-segment-request.test.js b/test/media-segment-request.test.js index 7a1c5164d..92f6344a7 100644 --- a/test/media-segment-request.test.js +++ b/test/media-segment-request.test.js @@ -89,7 +89,8 @@ QUnit.module('Media Segment Request - make it to transmuxer', { xhr: this.xhr, xhrOptions: this.xhrOptions, decryptionWorker: this.mockDecrypter, - segment: {} + segment: {}, + onTransmuxerLog: () => {} }; [ @@ -1335,7 +1336,8 @@ QUnit.test('non-TS segment will get parsed for captions', function(assert) { data: { action: 'mp4Captions', data: event.data, - captions + captions, + logs: [] } }); } @@ -1475,7 +1477,8 @@ QUnit.test('non-TS segment will get parsed for captions on next segment request data: { action: 'mp4Captions', data: event.data, - captions + captions, + logs: [] } }); } diff --git a/test/segment-loader.test.js b/test/segment-loader.test.js index 781119424..4f196f18c 100644 --- a/test/segment-loader.test.js +++ b/test/segment-loader.test.js @@ -902,7 +902,7 @@ QUnit.module('SegmentLoader', function(hooks) { }); }); - QUnit.test('logs warnings, debugs, and errors from the transmuxer', function(assert) { + QUnit.test('uses the log event from the transmuxer', function(assert) { const playlist = playlistWithDuration(10); const ogPost = loader.transmuxer_.postMessage; const messages = []; @@ -915,17 +915,11 @@ QUnit.module('SegmentLoader', function(hooks) { const retval = ogPost.call(loader.transmuxer_, message); if (message.action === 'push') { - const debug = newEvent('message'); - const error = newEvent('message'); - const warn = newEvent('message'); + const log = newEvent('message'); - debug.data = {action: 'debug', message: 'debug foo'}; - error.data = {action: 'error', message: 'error foo'}; - warn.data = {action: 'warn', message: 'warning foo'}; + log.data = {action: 'log', log: {message: 'debug foo', stream: 'something', level: 'warn'}}; - loader.transmuxer_.dispatchEvent(debug); - loader.transmuxer_.dispatchEvent(error); - loader.transmuxer_.dispatchEvent(warn); + loader.transmuxer_.dispatchEvent(log); return; } @@ -945,27 +939,15 @@ QUnit.module('SegmentLoader', function(hooks) { standardXHRResponse(this.requests.shift(), videoOneSecondSegment()); }); }).then(() => { - let debugFound = false; - let warnFound = false; - let errorFound = false; + let messageFound = false; messages.forEach(function(message) { - if ((/debug foo/).test(message)) { - debugFound = true; - } - - if ((/warning foo/).test(message)) { - warnFound = true; - } - - if ((/error foo/).test(message)) { - errorFound = true; + if ((/debug foo/).test(message) && (/warn/).test(message) && (/something/).test(message)) { + messageFound = true; } }); - assert.ok(debugFound, 'debug message was logged'); - assert.ok(warnFound, 'warn message was logged'); - assert.ok(errorFound, 'error message was logged'); + assert.ok(messageFound, 'message was logged'); }); }); diff --git a/test/transmuxer-worker.test.js b/test/transmuxer-worker.test.js index abad1c584..5730e11eb 100644 --- a/test/transmuxer-worker.test.js +++ b/test/transmuxer-worker.test.js @@ -328,6 +328,7 @@ QUnit.test('can parse mp4 captions', function(assert) { assert.equal(message.action, 'mp4Captions', 'returned mp4Captions event'); assert.deepEqual(message.captions.length, 2, 'two captions'); + assert.deepEqual(message.logs.length, 0, 'no logs returned'); assert.deepEqual( new Uint8Array(message.data), data,