define(["exports","../utils/logging-control.js","./transmuxing-controller.js","./transmuxing-events.js"],function(_exports,_loggingControl,_transmuxingController,_transmuxingEvents){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;_exports.default=function(self){var controller=null,logcatListener=function(type,str){self.postMessage({msg:"logcat_callback",data:{type:type,logcat:str}})}.bind(this);self.addEventListener("message",function(e){switch(e.data.cmd){case"init":(controller=new _transmuxingController.default(e.data.param[0],e.data.param[1])).on(_transmuxingEvents.default.IO_ERROR,function(type,info){self.postMessage({msg:_transmuxingEvents.default.IO_ERROR,data:{type:type,info:info}})}.bind(this)),controller.on(_transmuxingEvents.default.DEMUX_ERROR,function(type,info){self.postMessage({msg:_transmuxingEvents.default.DEMUX_ERROR,data:{type:type,info:info}})}.bind(this)),controller.on(_transmuxingEvents.default.INIT_SEGMENT,function(type,initSegment){type={msg:_transmuxingEvents.default.INIT_SEGMENT,data:{type:type,data:initSegment}};self.postMessage(type,[initSegment.data])}.bind(this)),controller.on(_transmuxingEvents.default.MEDIA_SEGMENT,function(type,mediaSegment){type={msg:_transmuxingEvents.default.MEDIA_SEGMENT,data:{type:type,data:mediaSegment}};self.postMessage(type,[mediaSegment.data])}.bind(this)),controller.on(_transmuxingEvents.default.LOADING_COMPLETE,function(){var obj={msg:_transmuxingEvents.default.LOADING_COMPLETE};self.postMessage(obj)}.bind(this)),controller.on(_transmuxingEvents.default.RECOVERED_EARLY_EOF,function(){var obj={msg:_transmuxingEvents.default.RECOVERED_EARLY_EOF};self.postMessage(obj)}.bind(this)),controller.on(_transmuxingEvents.default.MEDIA_INFO,function(mediaInfo){mediaInfo={msg:_transmuxingEvents.default.MEDIA_INFO,data:mediaInfo};self.postMessage(mediaInfo)}.bind(this)),controller.on(_transmuxingEvents.default.METADATA_ARRIVED,function(metadata){metadata={msg:_transmuxingEvents.default.METADATA_ARRIVED,data:metadata};self.postMessage(metadata)}.bind(this)),controller.on(_transmuxingEvents.default.SCRIPTDATA_ARRIVED,function(data){data={msg:_transmuxingEvents.default.SCRIPTDATA_ARRIVED,data:data};self.postMessage(data)}.bind(this)),controller.on(_transmuxingEvents.default.STATISTICS_INFO,function(statInfo){statInfo={msg:_transmuxingEvents.default.STATISTICS_INFO,data:statInfo};self.postMessage(statInfo)}.bind(this)),controller.on(_transmuxingEvents.default.RECOMMEND_SEEKPOINT,function(milliseconds){self.postMessage({msg:_transmuxingEvents.default.RECOMMEND_SEEKPOINT,data:milliseconds})}.bind(this));break;case"destroy":controller&&(controller.destroy(),controller=null),self.postMessage({msg:"destroyed"});break;case"start":controller.start();break;case"stop":controller.stop();break;case"seek":controller.seek(e.data.param);break;case"pause":controller.pause();break;case"resume":controller.resume();break;case"logging_config":var config=e.data.param;_loggingControl.default.applyConfig(config),!0===config.enableCallback?_loggingControl.default.addLogListener(logcatListener):_loggingControl.default.removeLogListener(logcatListener)}})}});