UNPKG

bitmovin-player

Version:

The Bitmovin HTML5 Adaptive Streaming Player for MPEG-DASH and HLS

13 lines (12 loc) 4.1 kB
/**************************************************************************** * Copyright (C) 2019, Bitmovin, Inc., All Rights Reserved * * This source code and its use and distribution, is subject to the terms * and conditions of the applicable license agreement. * * Bitmovin Player Version 8.16.2 * ****************************************************************************/ (function() { !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["subtitles-cea608"]=t():(e.bitmovin=e.bitmovin||{},e.bitmovin.player=e.bitmovin.player||{},e.bitmovin.player["subtitles-cea608"]=t())}(this,function(){return webpackJsonpbitmovin_player__name_([26],{186:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=s(112),a=s(395),r=function(){function e(e){this.MPEG_TS_TIMESCALE=9e4,this.timeScale=1,this.mp4Parser=e}return e.prototype.extract=function(e){var t=this;return new Promise(function(s,a){var r,i=[],n=e.getParsedData().get("moov.trak.mdia.mdhd");n&&(t.timeScale=n.timescale);var u=e.getParsedData().get("moov.mvex.trex");u&&(t.defaultSampleDuration=u.default_sample_duration);var c=e.getParsedData().get("moof.traf.tfdt");c&&(r=c.baseMediaDecodeTime/t.timeScale*t.MPEG_TS_TIMESCALE);var p=t.mp4Parser.getAvcSamples(e,[o.NalUnitType.SEI]),l=r||0;p.forEach(function(e){e.nalus.forEach(function(s){i.push({nalUnitType:"sei_rbsp",escapedRBSP:new Uint8Array(s.data.buffer,s.data.byteOffset,s.data.byteLength),pts:l+e.compositionTimeOffset/t.timeScale*t.MPEG_TS_TIMESCALE})}),l+=Math.floor((e.duration||t.defaultSampleDuration)/t.timeScale*t.MPEG_TS_TIMESCALE)}),t.parseCaptions(i).then(s)})},e.prototype.parseCaptions=function(e){return 0===e.length?Promise.resolve([]):(this.cea608Processor||(this.cea608Processor=new a.WebWorkerCea608Processor),this.cea608Processor.getCaptions(e)["catch"](function(){return Promise.resolve([])}))},e.prototype.reset=function(){this.cea608Processor&&this.cea608Processor.reset()},e.prototype.dispose=function(){this.cea608Processor&&this.cea608Processor.dispose(),this.mp4Parser=null},e}();t.Cea608Extractor=r},394:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=s(0),a=s(186);t.CeaSubtitlesModuleDefinition={name:o.ModuleName.SubtitlesCEA608,module:function(){return{Cea608Extractor:a.Cea608Extractor}},dependencies:[o.ModuleName.Subtitles]},t["default"]=t.CeaSubtitlesModuleDefinition},395:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=s(2),a=s(0),r=function(){function e(){var e=this;this.handleTransmuxerEvent=function(t){if("caption"===t.data.action){var s=t.data.caption;s.startTime=s.startTime||s.startPts/9e4,s.endTime=s.endTime||s.endPts/9e4,e.captions.push(t.data.caption)}else if("done"===t.data.action&&"captions"===t.data.what)if(e.onCaptionsAvailable(e.captions),e.captions=[],e.jobQueue.length>0){var o=e.jobQueue[0];e.process(o.message)}else e.isProcessing=!1};var t=o.ModuleManager.get(a.ModuleName.ContainerTS).TransmuxerWorker;this.transmuxer=new t,this.transmuxer.onmessage=this.handleTransmuxerEvent,this.captions=[],this.jobQueue=[],this.isProcessing=!1,this.transmuxer.postMessage({action:"initCaptionParser"})}return e.prototype.getCaptions=function(e){var t=this;return new Promise(function(s,o){(!e||!Array.isArray(e)||e.length<1)&&o();var a={action:"pushCaptions",data:e};t.jobQueue.push({message:a,resolve:s,reject:o}),t.isProcessing||(t.isProcessing=!0,t.process(a))})},e.prototype.dispose=function(){this.transmuxer&&(this.transmuxer.postMessage({action:"dispose"}),this.transmuxer.terminate(),this.transmuxer=null)},e.prototype.process=function(e){this.transmuxer.postMessage(e),this.flush()},e.prototype.flush=function(){this.transmuxer.postMessage({action:"flushCaptions"})},e.prototype.reset=function(){this.transmuxer.postMessage({action:"resetCaptions"})},e.prototype.onCaptionsAvailable=function(e){var t=this.jobQueue.shift();t.resolve(e)},e}();t.WebWorkerCea608Processor=r}},[394])}); })();