| 1 |
- (function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.Wfs=e()}})(function(){var e,t,r;return function(){function l(o,a,s){function u(r,e){if(!a[r]){if(!o[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(f)return f(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=a[r]={exports:{}};o[r][0].call(i.exports,function(e){var t=o[r][1][e];return u(t||e)},i,i.exports,l,o,a,s)}return a[r].exports}for(var f="function"==typeof require&&require,e=0;e<s.length;e++)u(s[e]);return u}return l}()({1:[function(e,t,r){"use strict";var n=typeof Reflect==="object"?Reflect:null;var c=n&&typeof n.apply==="function"?n.apply:function e(t,r,n){return Function.prototype.apply.call(t,r,n)};var i;if(n&&typeof n.ownKeys==="function"){i=n.ownKeys}else if(Object.getOwnPropertySymbols){i=function e(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}}else{i=function e(t){return Object.getOwnPropertyNames(t)}}function u(e){if(console&&console.warn)console.warn(e)}var o=Number.isNaN||function e(t){return t!==t};function a(){a.init.call(this)}t.exports=a;t.exports.once=w;a.EventEmitter=a;a.prototype._events=undefined;a.prototype._eventsCount=0;a.prototype._maxListeners=undefined;var s=10;function f(e){if(typeof e!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:true,get:function(){return s},set:function(e){if(typeof e!=="number"||e<0||o(e)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".")}s=e}});a.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};a.prototype.setMaxListeners=function e(t){if(typeof t!=="number"||t<0||o(t)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".")}this._maxListeners=t;return this};function l(e){if(e._maxListeners===undefined)return a.defaultMaxListeners;return e._maxListeners}a.prototype.getMaxListeners=function e(){return l(this)};a.prototype.emit=function e(t){var r=[];for(var n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error";var o=this._events;if(o!==undefined)i=i&&o.error===undefined;else if(!i)return false;if(i){var a;if(r.length>0)a=r[0];if(a instanceof Error){throw a}var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));s.context=a;throw s}var u=o[t];if(u===undefined)return false;if(typeof u==="function"){c(u,this,r)}else{var f=u.length;var l=m(u,f);for(var n=0;n<f;++n)c(l[n],this,r)}return true};function d(e,t,r,n){var i;var o;var a;f(r);o=e._events;if(o===undefined){o=e._events=Object.create(null);e._eventsCount=0}else{if(o.newListener!==undefined){e.emit("newListener",t,r.listener?r.listener:r);o=e._events}a=o[t]}if(a===undefined){a=o[t]=r;++e._eventsCount}else{if(typeof a==="function"){a=o[t]=n?[r,a]:[a,r]}else if(n){a.unshift(r)}else{a.push(r)}i=l(e);if(i>0&&a.length>i&&!a.warned){a.warned=true;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");s.name="MaxListenersExceededWarning";s.emitter=e;s.type=t;s.count=a.length;u(s)}}return e}a.prototype.addListener=function e(t,r){return d(this,t,r,false)};a.prototype.on=a.prototype.addListener;a.prototype.prependListener=function e(t,r){return d(this,t,r,true)};function h(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function p(e,t,r){var n={fired:false,wrapFn:undefined,target:e,type:t,listener:r};var i=h.bind(n);i.listener=r;n.wrapFn=i;return i}a.prototype.once=function e(t,r){f(r);this.on(t,p(this,t,r));return this};a.prototype.prependOnceListener=function e(t,r){f(r);this.prependListener(t,p(this,t,r));return this};a.prototype.removeListener=function e(t,r){var n,i,o,a,s;f(r);i=this._events;if(i===undefined)return this;n=i[t];if(n===undefined)return this;if(n===r||n.listener===r){if(--this._eventsCount===0)this._events=Object.create(null);else{delete i[t];if(i.removeListener)this.emit("removeListener",t,n.listener||r)}}else if(typeof n!=="function"){o=-1;for(a=n.length-1;a>=0;a--){if(n[a]===r||n[a].listener===r){s=n[a].listener;o=a;break}}if(o<0)return this;if(o===0)n.shift();else{g(n,o)}if(n.length===1)i[t]=n[0];if(i.removeListener!==undefined)this.emit("removeListener",t,s||r)}return this};a.prototype.off=a.prototype.removeListener;a.prototype.removeAllListeners=function e(t){var r,n,i;n=this._events;if(n===undefined)return this;if(n.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(n[t]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete n[t]}return this}if(arguments.length===0){var o=Object.keys(n);var a;for(i=0;i<o.length;++i){a=o[i];if(a==="removeListener")continue;this.removeAllListeners(a)}this.removeAllListeners("removeListener");this._events=Object.create(null);this._eventsCount=0;return this}r=n[t];if(typeof r==="function"){this.removeListener(t,r)}else if(r!==undefined){for(i=r.length-1;i>=0;i--){this.removeListener(t,r[i])}}return this};function v(e,t,r){var n=e._events;if(n===undefined)return[];var i=n[t];if(i===undefined)return[];if(typeof i==="function")return r?[i.listener||i]:[i];return r?b(i):m(i,i.length)}a.prototype.listeners=function e(t){return v(this,t,true)};a.prototype.rawListeners=function e(t){return v(this,t,false)};a.listenerCount=function(e,t){if(typeof e.listenerCount==="function"){return e.listenerCount(t)}else{return y.call(e,t)}};a.prototype.listenerCount=y;function y(e){var t=this._events;if(t!==undefined){var r=t[e];if(typeof r==="function"){return 1}else if(r!==undefined){return r.length}}return 0}a.prototype.eventNames=function e(){return this._eventsCount>0?i(this._events):[]};function m(e,t){var r=new Array(t);for(var n=0;n<t;++n)r[n]=e[n];return r}function g(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function b(e){var t=new Array(e.length);for(var r=0;r<t.length;++r){t[r]=e[r].listener||e[r]}return t}function w(i,o){return new Promise(function(e,t){function r(e){i.removeListener(o,n);t(e)}function n(){if(typeof i.removeListener==="function"){i.removeListener("error",r)}e([].slice.call(arguments))}_(i,o,n,{once:true});if(o!=="error"){E(i,r,{once:true})}})}function E(e,t,r){if(typeof e.on==="function"){_(e,"error",t,r)}}function _(r,n,i,o){if(typeof r.on==="function"){if(o.once){r.once(n,i)}else{r.on(n,i)}}else if(typeof r.addEventListener==="function"){r.addEventListener(n,function e(t){if(o.once){r.removeEventListener(n,e)}i(t)})}else{throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}}},{}],2:[function(e,t,r){var n=t.exports={};var i;var o;function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){i=setTimeout}else{i=a}}catch(e){i=a}try{if(typeof clearTimeout==="function"){o=clearTimeout}else{o=s}}catch(e){o=s}})();function u(t){if(i===setTimeout){return setTimeout(t,0)}if((i===a||!i)&&setTimeout){i=setTimeout;return setTimeout(t,0)}try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}function f(t){if(o===clearTimeout){return clearTimeout(t)}if((o===s||!o)&&clearTimeout){o=clearTimeout;return clearTimeout(t)}try{return o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}var l=[];var c=false;var d;var h=-1;function p(){if(!c||!d){return}c=false;if(d.length){l=d.concat(l)}else{h=-1}if(l.length){v()}}function v(){if(c){return}var e=u(p);c=true;var t=l.length;while(t){d=l;l=[];while(++h<t){if(d){d[h].run()}}h=-1;t=l.length}d=null;c=false;f(e)}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}}l.push(new y(e,t));if(l.length===1&&!c){u(v)}};function y(e,t){this.fun=e;this.array=t}y.prototype.run=function(){this.fun.apply(null,this.array)};n.title="browser";n.browser=true;n.env={};n.argv=[];n.version="";n.versions={};function m(){}n.on=m;n.addListener=m;n.once=m;n.off=m;n.removeListener=m;n.removeAllListeners=m;n.emit=m;n.prependListener=m;n.prependOnceListener=m;n.listeners=function(e){return[]};n.binding=function(e){throw new Error("process.binding is not supported")};n.cwd=function(){return"/"};n.chdir=function(e){throw new Error("process.chdir is not supported")};n.umask=function(){return 0}},{}],3:[function(e,t,r){"use strict";function k(e){"@babel/helpers - typeof";return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var s=e("../errors");var u=o(e("../events"));var i=o(e("../event-handler"));var n=o(e("../utils/mp4-encoder"));function o(e){return e&&e.__esModule?e:{default:e}}function R(){"use strict";R=function e(){return a};var a={},e=Object.prototype,l=e.hasOwnProperty,t="function"==typeof Symbol?Symbol:{},i=t.iterator||"@@iterator",r=t.asyncIterator||"@@asyncIterator",n=t.toStringTag||"@@toStringTag";function o(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(e){o=function e(t,r,n){return t[r]=n}}function s(e,t,r,n){var i=t&&t.prototype instanceof u?t:u,o=Object.create(i.prototype),a=new A(n||[]);return o._invoke=function(o,a,s){var u="suspendedStart";return function(e,t){if("executing"===u)throw new Error("Generator is already running");if("completed"===u){if("throw"===e)throw t;return S()}for(s.method=e,s.arg=t;;){var r=s.delegate;if(r){var n=w(r,s);if(n){if(n===f)continue;return n}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if("suspendedStart"===u)throw u="completed",s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);u="executing";var i=c(o,a,s);if("normal"===i.type){if(u=s.done?"completed":"suspendedYield",i.arg===f)continue;return{value:i.arg,done:s.done}}"throw"===i.type&&(u="completed",s.method="throw",s.arg=i.arg)}}}(e,r,a),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}a.wrap=s;var f={};function u(){}function d(){}function h(){}var p={};o(p,i,function(){return this});var v=Object.getPrototypeOf,y=v&&v(v(T([])));y&&y!==e&&l.call(y,i)&&(p=y);var m=h.prototype=u.prototype=Object.create(p);function g(e){["next","throw","return"].forEach(function(t){o(e,t,function(e){return this._invoke(t,e)})})}function b(s,u){function f(e,t,r,n){var i=c(s[e],s,t);if("throw"!==i.type){var o=i.arg,a=o.value;return a&&"object"==k(a)&&l.call(a,"__await")?u.resolve(a.__await).then(function(e){f("next",e,r,n)},function(e){f("throw",e,r,n)}):u.resolve(a).then(function(e){o.value=e,r(o)},function(e){return f("throw",e,r,n)})}n(i.arg)}var t;this._invoke=function(r,n){function e(){return new u(function(e,t){f(r,n,e,t)})}return t=t?t.then(e,e):e()}}function w(e,t){var r=e.iterator[t.method];if(undefined===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=undefined,w(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=undefined),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function T(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;){if(l.call(t,r))return e.value=t[r],e.done=!1,e}return e.value=undefined,e.done=!0,e};return n.next=n}}return{next:S}}function S(){return{value:undefined,done:!0}}return d.prototype=h,o(m,"constructor",h),o(h,"constructor",d),d.displayName=o(h,n,"GeneratorFunction"),a.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,o(e,n,"GeneratorFunction")),e.prototype=Object.create(m),e},a.awrap=function(e){return{__await:e}},g(b.prototype),o(b.prototype,r,function(){return this}),a.AsyncIterator=b,a.async=function(e,t,r,n,i){void 0===i&&(i=Promise);var o=new b(s(e,t,r,n),i);return a.isGeneratorFunction(t)?o:o.next().then(function(e){return e.done?e.value:o.next()})},g(m),o(m,n,"Generator"),o(m,i,function(){return this}),o(m,"toString",function(){return"[object Generator]"}),a.keys=function(r){var n=[];for(var e in r){n.push(e)}return n.reverse(),function e(){for(;n.length;){var t=n.pop();if(t in r)return e.value=t,e.done=!1,e}return e.done=!0,e}},a.values=T,A.prototype={constructor:A,reset:function e(t){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(_),!t)for(var r in this){"t"===r.charAt(0)&&l.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=undefined)}},stop:function e(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function e(r){if(this.done)throw r;var n=this;function t(e,t){return a.type="throw",a.arg=r,n.next=e,t&&(n.method="next",n.arg=undefined),!!t}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var s=l.call(o,"catchLoc"),u=l.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function e(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&l.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function e(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f},finish:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),_(n),f}},catch:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var o=i.arg;_(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function e(t,r,n){return this.delegate={iterator:T(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=undefined),f}},a}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function l(e,t,r){if(t)f(e.prototype,t);if(r)f(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}function c(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)d(e,t)}function d(e,t){d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return d(e,t)}function h(i){var o=y();return function e(){var t=m(i),r;if(o){var n=m(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return p(this,r)}}function p(e,t){if(t&&(k(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return v(e)}function v(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function y(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function m(e){m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return m(e)}function g(e,t,r,n,i,o,a){try{var s=e[o](a);var u=s.value}catch(e){r(e);return}if(s.done){t(u)}else{Promise.resolve(u).then(n,i)}}function b(s){return function(){var e=this,a=arguments;return new Promise(function(t,r){var n=s.apply(e,a);function i(e){g(n,t,r,i,o,"next",e)}function o(e){g(n,t,r,i,o,"throw",e)}i(undefined)})}}var w=null;function E(){return _.apply(this,arguments)}function _(){_=b(R().mark(function e(){return R().wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return(0,n.default)().then(function(e){w=e});case 2:case"end":return t.stop()}}},e)}));return _.apply(this,arguments)}var A=function(e){c(n,e);var r=h(n);function n(e){var t;a(this,n);t=r.call(this,e,u.default.MEDIA_ATTACHING,u.default.BUFFER_APPENDING,u.default.BUFFER_RESET,u.default.RECORDING_START,u.default.RECORDING_STOP,u.default.H264_DATA_APPENDING,u.default.PLAYER_SEEK_NOW);t.rec_threshold_total=16*(1024*1024*1024);t.rec_threshold_single=1*(1024*1024*1024);t.rec_timer=undefined;t.rec_file="";t.rec_result_cb=undefined;t.rec_state_cb=undefined;t.mediaElement=null;t.mediaSource=null;t.mediaSize=0;t.sourceBuffers={};t.segments=[];t.h264Frames=[];t.appended=0;t.mediaErrorCount=0;t.count=0;t.recording=false;t.onsbue=t.onSBUpdateEnd.bind(v(t));t.browserType=0;if(navigator.userAgent.toLowerCase().indexOf("firefox")!==-1){t.browserType=1}t.mediaType="";t.websocketName=undefined;t.channelName=undefined;t._fs=null;t.track_info={width:0,height:0};E();t.mp4BlobBuffer=[];return t}l(n,[{key:"destroy",value:function e(){i.default.prototype.destroy.call(this)}},{key:"pad2",value:function e(t){return t<10?"0"+t:t}},{key:"onRecordingProc",value:function e(){var r=this;if(r._fs==null){if(r.rec_result_cb){r.rec_result_cb(false)}console.log("fs is not authorized");return}if(r.rec_timer){clearInterval(r.rec_timer);r.rec_timer=undefined}r.count=0;r.rec_timer=setInterval(function(){if(r.mediaType==""||r.mediaType=="H264Raw"&&r.appended>10){clearInterval(r.rec_timer);r.rec_timer=undefined;var e=new Date;var t=1900+e.getYear()+"-"+r.pad2(e.getMonth()+1)+"-"+r.pad2(e.getDate())+"_"+r.pad2(e.getHours())+"-"+r.pad2(e.getMinutes())+"-"+r.pad2(e.getSeconds());r.rec_file="ax_"+t+".mp4";console.log("MediaRecorder started: "+r.rec_file);r.mediaSize=0;r.recording=true;if(r.rec_result_cb){r.rec_result_cb(true)}}else{r.count++}if(r.count>=10){clearInterval(r.rec_timer);r.rec_timer=undefined;if(r.rec_result_cb){r.rec_result_cb(false)}}},1e3)}},{key:"onRecordingStart",value:function e(t){if(this.recording){console.log("recording is in progress");return}if(t!=undefined){this.rec_threshold_single=t.rec_file_threshold;this.rec_result_cb=t.result_cb;this.rec_state_cb=t.state_cb}var r=this;navigator.webkitPersistentStorage.queryUsageAndQuota(function(e,t){if(t==""){r.requestFs()}else{window.webkitRequestFileSystem(window.PERSISTENT,r.rec_threshold_total,function(e){r._fs=e;e.root.getDirectory("ax_video",{create:true},function(e){console.log("Directory: "+e.name+" fs requested");r.onRecordingProc()},r.errorHandler)})}},this.errorHandler)}},{key:"onRecordingStop",value:function e(){if(this.rec_timer){clearInterval(this.rec_timer);this.rec_timer=undefined;console.log("Media Recorder stopped2")}var t=this;t.recording=false;t.saveToMP4Blob(t.h264Frames,this.track_info);t.h264Frames=[]}},{key:"errorHandler",value:function e(t){var r="An error occured(errcd): ";console.log(r+t.code)}},{key:"requestFs",value:function e(){var t=this;navigator.webkitPersistentStorage.requestQuota(this.rec_threshold_total,function(e){console.log("grantedBytes: "+e);if(e>0){window.webkitRequestFileSystem(window.PERSISTENT,e,function(e){t._fs=e;e.root.getDirectory("ax_video",{create:true},function(e){console.log("Directory: "+e.name+" exists or just created.");t.onRecordingProc()},t.errorHandler)})}else{if(t.rec_result_cb){t.rec_result_cb(false)}}})}},{key:"onMediaAttaching",value:function e(t){var r=this.mediaElement=t.media;this.mediaType=t.mediaType;this.websocketName=t.websocketName;this.channelName=t.channelName;if(r){var n=this.mediaSource=new MediaSource;this.onmso=this.onMediaSourceOpen.bind(this);this.onmse=this.onMediaSourceEnded.bind(this);this.onmsc=this.onMediaSourceClose.bind(this);n.addEventListener("sourceopen",this.onmso);n.addEventListener("sourceended",this.onmse);n.addEventListener("sourceclose",this.onmsc);r.src=URL.createObjectURL(n)}}},{key:"onMediaDetaching",value:function e(){}},{key:"onH264DataAppending",value:function e(t){if(!this.recording||!t.data)return;var r=this;var n=t.data;r.h264Frames.push(t.data);r.mediaSize+=n.length;if(r.mediaSize>=r.rec_threshold_single){if(r.rec_state_cb){r.rec_state_cb(false)}r.onRecordingStop();r.onRecordingStart();if(r.rec_state_cb){r.rec_state_cb(true)}}}},{key:"saveToMP4Blob",value:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var n=this;var i=false;if(t.length>0){var o=r.width;var a=r.height;var s=w.createEncoder({width:o,height:a,hevc:i});t.forEach(function(e){s.addNalu(e)});var u=new Blob([s.end()]);n.writeMP4Data(u)}}},{key:"writeMP4Data",value:function e(t){var r=this;r._fs.root.getFile("ax_video/"+r.rec_file,{create:true},function(e){e.createWriter(function(e){e.onwriteend=function(e){};e.onerror=function(e){console.log("Write rec data failed: "+e.toString())};e.seek(e.length);e.write(t)},r.errorHandler)},r.errorHandler)}},{key:"onBufferAppending",value:function e(t){this.segments.push(t);this.doAppending()}},{key:"onMediaSourceClose",value:function e(){console.log("media source closed")}},{key:"onMediaSourceEnded",value:function e(){console.log("media source ended")}},{key:"onSBUpdateEnd",value:function e(t){if(this.browserType===1){this.mediaSource.endOfStream();this.media.play()}this.appending=false;this.doAppending()}},{key:"onMediaSourceOpen",value:function e(){console.log("media source open");var t=this.mediaSource;if(t){t.removeEventListener("sourceopen",this.onmso)}this.wfs.trigger(u.default.MEDIA_ATTACHED,{media:this.media,channelName:this.channelName,mediaType:this.mediaType,websocketName:this.websocketName})}},{key:"onBufferReset",value:function e(t){if(this.mediaType==="H264Raw"){this.createSourceBuffers({tracks:"video",mimeType:t.mimeType})}this.track_info.width=t.width;this.track_info.height=t.height}},{key:"createSourceBuffers",value:function e(t){var r=this.sourceBuffers;var n=this.mediaSource;var i;if(t.mimeType===""){i="video/mp4;codecs=avc1.420028"}else{i="video/mp4;codecs="+t.mimeType}try{var o=r["video"]=n.addSourceBuffer(i);o.addEventListener("updateend",this.onsbue)}catch(e){}this.wfs.trigger(u.default.BUFFER_CREATED,{tracks:t});this.mediaElement.play()}},{key:"onPlayerSeekNow",value:function e(){var t=this.mediaElement.buffered.end(0);this.mediaElement.currentTime=t}},{key:"doAppending",value:function e(){var t=this.wfs,r=this.sourceBuffers,n=this.segments;if(Object.keys(r).length){if(this.mediaElement.error){this.segments=[];this.mediaErrorCount++;if(this.mediaErrorCount<100){console.log("doAppending although a media error occured, error code:",this.media.error.code)}else{var i={type:s.ErrorTypes.MEDIA_ERROR};i.details=s.ErrorDetails.BUFFER_APPEND_ERROR;i.frag=this.fragCurrent;i.fatal=true;this.wfs.trigger(u.default.ERROR,i)}return}this.mediaErrorCount=0;if(this.appending){return}if(n&&n.length){var o=n.shift();try{if(r[o.type]){this.parent=o.parent;r[o.type].appendBuffer(o.data);this.appendError=0;this.appended++;this.appending=true}}catch(e){n.unshift(o);var a={type:s.ErrorTypes.MEDIA_ERROR};if(e.code!==22){if(this.appendError){this.appendError++}else{this.appendError=1}a.details=s.ErrorDetails.BUFFER_APPEND_ERROR;a.frag=this.fragCurrent;if(this.appendError>t.config.appendErrorMaxRetry){n=[];a.fatal=true}else{a.fatal=false}}else{this.segments=[];a.details=s.ErrorDetails.BUFFER_FULL_ERROR;a.fatal=true}this.wfs.trigger(u.default.ERROR,a)}}}}}]);return n}(i.default);var T=A;r.default=T},{"../errors":7,"../event-handler":8,"../events":9,"../utils/mp4-encoder":17}],4:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var a=o(e("../events"));var i=o(e("../event-handler"));function o(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function f(e,t,r){if(t)u(e.prototype,t);if(r)u(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}function l(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)c(e,t)}function c(e,t){c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return c(e,t)}function d(i){var o=v();return function e(){var t=y(i),r;if(o){var n=y(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return h(this,r)}}function h(e,t){if(t&&(n(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return p(e)}function p(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function v(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function y(e){y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return y(e)}var m=function(e){l(n,e);var r=d(n);function n(e){var t;s(this,n);t=r.call(this,e,a.default.MEDIA_ATTACHED,a.default.BUFFER_CREATED,a.default.FILE_PARSING_DATA,a.default.FILE_HEAD_LOADED,a.default.FILE_DATA_LOADED,a.default.WEBSOCKET_ATTACHED,a.default.FRAG_PARSING_DATA,a.default.FRAG_PARSING_INIT_SEGMENT);t.fileStart=0;t.fileEnd=0;t.pendingAppending=0;t.mediaType=undefined;e:t.channelName;return t}f(n,[{key:"destroy",value:function e(){i.default.prototype.destroy.call(this)}},{key:"onMediaAttached",value:function e(t){console.log("media attached");if(t.websocketName!=undefined){var r=t.websocketName;var n="binary";var i=new WebSocket(r,n);this.wfs.attachWebsocket(i,t.websocketName,t.channelName)}else{console.log("websocketName ERROE!!!")}}},{key:"onBufferCreated",value:function e(t){this.mediaType=t.mediaType}},{key:"onFileHeadLoaded",value:function e(t){}},{key:"onFileDataLoaded",value:function e(t){}},{key:"onFileParsingData",value:function e(t){}},{key:"onWebsocketAttached",value:function e(t){this.wfs.trigger(a.default.BUFFER_APPENDING,{type:"video",data:t.payload,parent:"main"})}},{key:"onFragParsingInitSegment",value:function e(t){var r=t.tracks,n;var i=r.video;if(i){i.id=t.id}for(n in r){i=r[n];var o=i.initSegment;if(o){this.pendingAppending++;this.wfs.trigger(a.default.BUFFER_APPENDING,{type:n,data:o,parent:"main"})}}}},{key:"onFragParsingData",value:function e(t){var r=this;[t.data1,t.data2].forEach(function(e){if(e){r.pendingAppending++;r.wfs.trigger(a.default.BUFFER_APPENDING,{type:t.type,data:e,parent:"main"})}})}}]);return n}(i.default);var g=m;r.default=g},{"../event-handler":8,"../events":9}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var i=e("../utils/logger");function n(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function a(e,t,r){if(t)o(e.prototype,t);if(r)o(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}var s=function(){function t(e){n(this,t);this.data=e;this.bytesAvailable=this.data.byteLength;this.word=0;this.bitsAvailable=0}a(t,[{key:"loadWord",value:function e(){var t=this.data.byteLength-this.bytesAvailable,r=new Uint8Array(4),n=Math.min(4,this.bytesAvailable);if(n===0){throw new Error("no bytes available")}r.set(this.data.subarray(t,t+n));this.word=new DataView(r.buffer).getUint32(0);this.bitsAvailable=n*8;this.bytesAvailable-=n}},{key:"skipBits",value:function e(t){var r;if(this.bitsAvailable>t){this.word<<=t;this.bitsAvailable-=t}else{t-=this.bitsAvailable;r=t>>3;t-=r>>3;this.bytesAvailable-=r;this.loadWord();this.word<<=t;this.bitsAvailable-=t}}},{key:"readBits",value:function e(t){var r=Math.min(this.bitsAvailable,t),n=this.word>>>32-r;if(t>32){i.logger.error("Cannot read more than 32 bits at a time")}this.bitsAvailable-=r;if(this.bitsAvailable>0){this.word<<=r}else if(this.bytesAvailable>0){this.loadWord()}r=t-r;if(r>0){return n<<r|this.readBits(r)}else{return n}}},{key:"skipLZ",value:function e(){var t;for(t=0;t<this.bitsAvailable;++t){if(0!==(this.word&2147483648>>>t)){this.word<<=t;this.bitsAvailable-=t;return t}}this.loadWord();return t+this.skipLZ()}},{key:"skipUEG",value:function e(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function e(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function e(){var t=this.skipLZ();return this.readBits(t+1)-1}},{key:"readEG",value:function e(){var t=this.readUEG();if(1&t){return 1+t>>>1}else{return-1*(t>>>1)}}},{key:"readBoolean",value:function e(){return 1===this.readBits(1)}},{key:"readUByte",value:function e(){return this.readBits(8)}},{key:"readUShort",value:function e(){return this.readBits(16)}},{key:"readUInt",value:function e(){return this.readBits(32)}},{key:"skipScalingList",value:function e(t){var r=8,n=8,i,o;for(i=0;i<t;i++){if(n!==0){o=this.readEG();n=(r+o+256)%256}r=n===0?r:n}}},{key:"readSPS",value:function e(){var t=0,r=0,n=0,i=0,o=1,a,s,u,f,l,c,d,h,p;this.readUByte();a=this.readUByte();s=this.readBits(5);this.skipBits(3);u=this.readUByte();this.skipUEG();if(a===100||a===110||a===122||a===244||a===44||a===83||a===86||a===118||a===128){var v=this.readUEG();if(v===3){this.skipBits(1)}this.skipUEG();this.skipUEG();this.skipBits(1);if(this.readBoolean()){h=v!==3?8:12;for(p=0;p<h;p++){if(this.readBoolean()){if(p<6){this.skipScalingList(16)}else{this.skipScalingList(64)}}}}}this.skipUEG();var y=this.readUEG();if(y===0){this.readUEG()}else if(y===1){this.skipBits(1);this.skipEG();this.skipEG();f=this.readUEG();for(p=0;p<f;p++){this.skipEG()}}this.skipUEG();this.skipBits(1);l=this.readUEG();c=this.readUEG();d=this.readBits(1);if(d===0){this.skipBits(1)}this.skipBits(1);if(this.readBoolean()){t=this.readUEG();r=this.readUEG();n=this.readUEG();i=this.readUEG()}if(this.readBoolean()){if(this.readBoolean()){var m;var g=this.readUByte();switch(g){case 1:m=[1,1];break;case 2:m=[12,11];break;case 3:m=[10,11];break;case 4:m=[16,11];break;case 5:m=[40,33];break;case 6:m=[24,11];break;case 7:m=[20,11];break;case 8:m=[32,11];break;case 9:m=[80,33];break;case 10:m=[18,11];break;case 11:m=[15,11];break;case 12:m=[64,33];break;case 13:m=[160,99];break;case 14:m=[4,3];break;case 15:m=[3,2];break;case 16:m=[2,1];break;case 255:{m=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()];break}}if(m){o=m[0]/m[1]}}}return{width:Math.ceil(((l+1)*16-t*2-r*2)*o),height:(2-d)*(c+1)*16-(d?2:4)*(n+i)}}},{key:"readSliceType",value:function e(){this.readUByte();this.readUEG();return this.readUEG()}}]);return t}();var u=s;r.default=u},{"../utils/logger":16}],6:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var i=e("../errors");var y=o(e("../events"));var m=o(e("./exp-golomb"));var a=o(e("../event-handler"));var s=o(e("../remux/mp4-remuxer"));function o(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function l(e,t,r){if(t)f(e.prototype,t);if(r)f(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}function c(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)d(e,t)}function d(e,t){d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return d(e,t)}function h(i){var o=g();return function e(){var t=b(i),r;if(o){var n=b(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return p(this,r)}}function p(e,t){if(t&&(n(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return v(e)}function v(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function g(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function b(e){b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return b(e)}var w=function(e){c(o,e);var i=h(o);function o(e){var t;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;u(this,o);t=i.call(this,e,y.default.H264_DATA_PARSING);t.config=t.wfs.config||r;t.wfs=e;t.id="main";var n={mp4:MediaSource.isTypeSupported("video/mp4")};t.remuxer=new s.default(t.wfs,t.id,t.config);t.contiguous=true;t.timeOffset=1;t.sn=0;t.TIMESCALE=9e4;t.timestamp=0;t.scaleFactor=t.TIMESCALE/1e3;t.H264_TIMEBASE=t.config.mp4Duration;t._avcTrack={container:"video/mp4",type:"video",id:1,sequenceNumber:0,samples:[],len:0,nbNalu:0,dropped:0,count:0};t.browserType=0;if(navigator.userAgent.toLowerCase().indexOf("firefox")!==-1){t.browserType=1}return t}l(o,[{key:"destroy",value:function e(){a.default.prototype.destroy.call(this)}},{key:"getTimestampM",value:function e(){this.timestamp+=this.H264_TIMEBASE;return this.timestamp}},{key:"onH264DataParsing",value:function e(t){this._parseAVCTrack(t.data);if(this.browserType===1){this.remuxer.pushVideo(0,this.sn,this._avcTrack,this.timeOffset,this.contiguous);this.sn+=1}else{this.remuxer.pushVideo(0,this.sn,this._avcTrack,this.timeOffset,this.contiguous);this.sn+=1}}},{key:"_parseAVCTrack",value:function e(t){var o=this;var a=this._avcTrack,r=a.samples,n=this._parseAVCNALu(t),s=[],u=false,f=false,l=0,c,i,d,h;var p="";var v=function(){if(s.length){if(!this.config.forceKeyFrameOnDiscontinuity||f===true||a.sps&&(r.length||this.contiguous)){var e=this.getTimestampM();i={units:{units:s,length:l},pts:e,dts:e,key:f};r.push(i);a.len+=l;a.nbNalu+=s.length}else{a.dropped++}s=[];l=0}}.bind(this);n.forEach(function(e){switch(e.type){case 1:d=true;if(u){p+="NDR "}break;case 5:d=true;if(u){p+="IDR "}f=true;break;case 6:e.data=o.discardEPB(e.data);c=new m.default(e.data);c.readUByte();break;case 7:d=false;if(u){p+="SPS "}if(!a.sps){c=new m.default(e.data);var t=c.readSPS();a.width=t.width;a.height=t.height;a.sps=[e.data];a.duration=0;var r=e.data.subarray(1,4);var n="avc1.";for(h=0;h<3;h++){var i=r[h].toString(16);if(i.length<2){i="0"+i}n+=i}a.codec=n;o.wfs.trigger(y.default.BUFFER_RESET,{mimeType:a.codec,width:a.width,height:a.height});d=true}break;case 8:d=false;if(u){p+="PPS "}if(!a.pps){a.pps=[e.data];d=true}break;case 9:d=false;if(u){p+="AUD "}v();break;default:d=false;p+="unknown NAL "+e.type+" ";break}if(d){s.push(e);l+=e.data.byteLength}});if(u||p.length){logger.log(p)}v()}},{key:"_parseAVCNALu",value:function e(t){var r=0,n=t.byteLength,i,o,a=0;var s=[],u,f,l,c;while(r<n){i=t[r++];switch(a){case 0:if(i===0){a=1}break;case 1:if(i===0){a=2}else{a=0}break;case 2:case 3:if(i===0){a=3}else if(i===1&&r<n){f=t[r]&31;if(l){u={data:t.subarray(l,r-a-1),type:c};s.push(u)}else{}l=r;c=f;a=0}else{a=0}break;default:break}}if(l){u={data:t.subarray(l,n),type:c,state:a};s.push(u)}return s}},{key:"discardEPB",value:function e(t){var r=t.byteLength,n=[],i=1,o,a;while(i<r-2){if(t[i]===0&&t[i+1]===0&&t[i+2]===3){n.push(i+2);i+=2}else{i++}}if(n.length===0){return t}o=r-n.length;a=new Uint8Array(o);var s=0;for(i=0;i<o;s++,i++){if(s===n[0]){s++;n.shift()}a[i]=t[s]}return a}}]);return o}(a.default);var E=w;r.default=E},{"../errors":7,"../event-handler":8,"../events":9,"../remux/mp4-remuxer":15,"./exp-golomb":5}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.ErrorTypes=r.ErrorDetails=void 0;var n={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",OTHER_ERROR:"otherError"};r.ErrorTypes=n;var i={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOOP_LOADING_ERROR:"fragLoopLoadingError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",INTERNAL_EXCEPTION:"internalException",NETWORK_RECV_DATA_TIMEOUT:"networkRecvDataTimeout"};r.ErrorDetails=i},{}],8:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var n=i(e("./events"));function i(e){return e&&e.__esModule?e:{default:e}}function o(e){"@babel/helpers - typeof";return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function u(e,t,r){if(t)s(e.prototype,t);if(r)s(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}var f=function(){function i(e){a(this,i);this.wfs=e;this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++){r[n-1]=arguments[n]}this.handledEvents=r;this.useGenericHandler=true;this.registerListeners()}u(i,[{key:"destroy",value:function e(){this.unregisterListeners()}},{key:"isEventHandler",value:function e(){return o(this.handledEvents)==="object"&&this.handledEvents.length&&typeof this.onEvent==="function"}},{key:"registerListeners",value:function e(){if(this.isEventHandler()){this.handledEvents.forEach(function(e){if(e==="wfsEventGeneric"){}this.wfs.on(e,this.onEvent)}.bind(this))}}},{key:"unregisterListeners",value:function e(){if(this.isEventHandler()){this.handledEvents.forEach(function(e){this.wfs.off(e,this.onEvent)}.bind(this))}}},{key:"onEvent",value:function e(t,r){this.onEventGeneric(t,r)}},{key:"onEventGeneric",value:function e(t,r){var n=function e(t,r){var n="on"+t.replace("wfs","");if(typeof this[n]!=="function"){}return this[n].bind(this,r)};try{n.call(this,t,r).call()}catch(e){console.log("internal error happened while processing ".concat(t,":").concat(e.message))}}}]);return i}();var l=f;r.default=l},{"./events":9}],9:[function(e,t,r){"use strict";t.exports={MEDIA_ATTACHING:"wfsMediaAttaching",MEDIA_ATTACHED:"wfsMediaAttached",FRAG_LOADING:"wfsFragLoading",BUFFER_CREATED:"wfsBufferCreated",BUFFER_APPENDING:"wfsBufferAppending",BUFFER_RESET:"wfsBufferReset",BUFFER_CLEAR:"wfsBufferClear",FRAG_PARSING_DATA:"wfsFragParsingData",FRAG_PARSING_INIT_SEGMENT:"wfsFragParsingInitSegment",H264_DATA_APPENDING:"wfsH264DataAppending",H264_DATA_PARSING:"wfsH264DataParsing",WEBSOCKET_ATTACHED:"wfsWebsocketAttached",WEBSOCKET_ATTACHING:"wfsWebsocketAttaching",WEBSOCKET_DATA_UPLOADING:"wfsWebsocketDataUploading",WEBSOCKET_MESSAGE_SENDING:"wfsWebsocketMessageSending",FILE_HEAD_LOADING:"wfsFileHeadLoading",FILE_HEAD_LOADED:"wfsFileHeadLoaded",FILE_DATA_LOADING:"wfsFileDataLoading",FILE_DATA_LOADED:"wfsFileDataLoaded",FILE_PARSING_DATA:"wfsFileParsingData",RECORDING_START:"wfsRecordingStart",PLAYER_SEEK_NOW:"wfsPlayerSeekNow",RECORDING_STOP:"wfsRecordingStop",ERROR:"wfsError"}},{}],10:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;function n(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function o(e,t,r){if(t)i(e.prototype,t);if(r)i(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}var a=function(){function e(){n(this,e)}o(e,null,[{key:"getSilentFrame",value:function e(t){if(t===1){return new Uint8Array([0,200,0,128,35,128])}else if(t===2){return new Uint8Array([33,0,73,144,2,25,0,35,128])}else if(t===3){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142])}else if(t===4){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56])}else if(t===5){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56])}else if(t===6){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}return null}}]);return e}();var s=a;r.default=s},{}],11:[function(e,t,r){"use strict";t.exports=e("./wfs.js").default},{"./wfs.js":20}],12:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var i=a(e("../events"));var o=a(e("../event-handler"));function a(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function f(e,t,r){if(t)u(e.prototype,t);if(r)u(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}function l(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)c(e,t)}function c(e,t){c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return c(e,t)}function d(i){var o=v();return function e(){var t=y(i),r;if(o){var n=y(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return h(this,r)}}function h(e,t){if(t&&(n(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return p(e)}function p(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function v(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function y(e){y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return y(e)}var m=function(e){l(n,e);var r=d(n);function n(e){var t;s(this,n);t=r.call(this,e,i.default.FRAG_LOADING,i.default.FILE_HEAD_LOADING,i.default.FILE_DATA_LOADING);t.loaders={};return t}f(n,[{key:"destroy",value:function e(){for(var t in this.loaders){var r=this.loaders[t];if(r){r.destroy()}}this.loaders={};o.default.prototype.destroy.call(this)}},{key:"onFileHeadLoading",value:function e(t){var r=this.wfs.config;var n=new r.loader(r);var i,o,a;i={url:r.fmp4FileUrl};o={maxRetry:0,retryDelay:0};a={onSuccess:this.fileloadheadsuccess.bind(this)};n.loadHead(i,o,a)}},{key:"fileloadheadsuccess",value:function e(t){this.wfs.trigger(i.default.FILE_HEAD_LOADED,{size:t})}},{key:"onFileDataLoading",value:function e(t){var r=this.wfs.config;var n=new r.loader(r);var i,o,a;i={url:r.fmp4FileUrl,responseType:"arraybuffer",progressData:false};var s=t.fileStart,u=t.fileEnd;if(!isNaN(s)&&!isNaN(u)){i.rangeStart=s;i.rangeEnd=u}o={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout};a={onSuccess:this.fileloaddatasuccess.bind(this)};n.load(i,o,a)}},{key:"fileloaddatasuccess",value:function e(t,r,n){this.wfs.trigger(i.default.FILE_DATA_LOADED,{payload:t.data,stats:r})}},{key:"loaderror",value:function e(t,r){var n=r.loader;if(n){n.abort()}this.loaders[r.type]=undefined}},{key:"loadtimeout",value:function e(t,r){var n=r.loader;if(n){n.abort()}this.loaders[r.type]=undefined}},{key:"loadprogress",value:function e(t,r,n){var i=r.frag;i.loaded=t.loaded}}]);return n}(o.default);var g=m;r.default=g},{"../event-handler":8,"../events":9}],13:[function(e,t,r){"use strict";function n(e){"@babel/helpers - typeof";return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var i=e("../errors");var a=u(e("../events"));var o=u(e("../event-handler"));var s=u(e("../demux/h264-demuxer"));function u(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function c(e,t,r){if(t)l(e.prototype,t);if(r)l(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}function d(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)h(e,t)}function h(e,t){h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function e(t,r){t.__proto__=r;return t};return h(e,t)}function p(i){var o=m();return function e(){var t=g(i),r;if(o){var n=g(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return v(this,r)}}function v(e,t){if(t&&(n(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return y(e)}function y(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function m(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function g(e){g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function e(t){return t.__proto__||Object.getPrototypeOf(t)};return g(e)}var b=function(e){d(n,e);var r=p(n);function n(e){var t;f(this,n);t=r.call(this,e,a.default.WEBSOCKET_ATTACHING,a.default.WEBSOCKET_DATA_UPLOADING,a.default.WEBSOCKET_MESSAGE_SENDING);t.buf=null;t.ctx=null;t.h264Demuxer=new s.default(e);t.websocketName=undefined;t.media=undefined;t.mediaType=undefined;t.mediaCode=0;t.channelName=undefined;t.isForceClosed=false;t.timer=undefined;t.lastRecvDataTime=0;t.extraData=undefined;t.isLoaded=false;return t}c(n,[{key:"create_timer",value:function e(){var n=this;this.lastRecvDataTime=performance.now();console.log("Websocket: create_timer");this.timer=setInterval(function(){if(n.lastRecvDataTime>0){var e=performance.now();var t=e-n.lastRecvDataTime;if(t>n.wfs.config.wsMinPacketInterval){console.log("Websocket: did not recv data over "+t+" ms")}if(t>n.wfs.config.wsMaxPacketInterval&&!n.isForceClosed){n.unload();console.log("Websocket data not received in "+n.wfs.config.wsMaxPacketInterval/1e3+"s, open again...");var r={type:i.ErrorTypes.NETWORK_ERROR};r.details=i.ErrorDetails.NETWORK_RECV_DATA_TIMEOUT;r.fatal=true;n.wfs.trigger(a.default.ERROR,r)}}else{n.lastRecvDataTime=performance.now()}},this.wfs.config.wsMinPacketInterval)}},{key:"kill_timer",value:function e(){if(this.timer){console.log("Websocket close: clear timer");clearInterval(this.timer);this.timer=undefined}}},{key:"destroy",value:function e(){this.kill_timer();this.isForceClosed=true;!!this.client&&this.client.close();o.default.prototype.destroy.call(this)}},{key:"onWebsocketAttaching",value:function e(t){this.kill_timer();this.create_timer();switch(t.mediaType){case"MJPEG":this.mediaCode=1;this.ctx=t.media.getContext("2d");break;case"H264Raw":default:this.mediaCode=0;break}this.websocketName=t.websocketName;this.media=t.media;this.mediaType=t.mediaType;this.channelName=t.channelName;this.extraData=t.extraData;if(t.websocket instanceof WebSocket){this.client=t.websocket;this.client.onopen=this.initSocketClient.bind(this);this.client.onclose=this.closeSocketClient.bind(this);this.client.onerror=this.errorSocketClient.bind(this)}}},{key:"errorSocketClient",value:function e(t){this.unload();console.log("WebSocket error: ",t)}},{key:"closeSocketClient",value:function e(t){this.unload();console.log("Websocket closed: ",t)}},{key:"initSocketClient",value:function e(t){this.load();}},{key:"receiveSocketMessage",value:function e(t){var r=this;if(!this.isLoaded)return;this.lastRecvDataTime=performance.now();if(this.mediaCode===0){this.buf=new Uint8Array(t.data);var n=new Uint8Array(this.buf);var i=new Uint8Array(this.buf);this.wfs.trigger(a.default.H264_DATA_PARSING,{data:n});this.wfs.trigger(a.default.H264_DATA_APPENDING,{data:i})}else if(this.mediaCode===1){if(this.extraData){if(!this.extraData.isDrawImg)return;if(this.media==undefined||!this.media)return;var o=new FileReader;o.onload=function(e){if(e.target.readyState===FileReader.DONE){var f=r.ctx;var l=new Image;var c=r.extraData.mjpeg_w;var d=r.extraData.mjpeg_h;var h=r.extraData.sizeOptionInd;var p=r.extraData.getObjectFitSize;l.onload=function(){f.clearRect(0,0,c,d);if(h===1){var e=p(h,c,d,this.width,this.height),t=e.sx,r=e.sy,n=e.swidth,i=e.sheight,o=e.x,a=e.y,s=e.width,u=e.height;f.drawImage(l,t,r,n,i,o,a,s,u)}else{f.drawImage(l,0,0,c,d)}};l.src=e.target.result}};o.readAsDataURL(t.data)}else{console.log("extraData is undefined");this.extraData=this.wfs.extraData}}}},{key:"onWebsocketDataUploading",value:function e(t){this.client.send(t.data)}},{key:"onWebsocketMessageSending",value:function e(t){this.client.send(JSON.stringify({t:t.commandType,c:t.channelName,v:t.commandValue}))}},{key:"load",value:function e(){if(this.mediaCode===0){this.client.binaryType="arraybuffer"}this.client.onmessage=this.receiveSocketMessage.bind(this);this.wfs.trigger(a.default.WEBSOCKET_MESSAGE_SENDING,{commandType:"open",channelName:this.channelName,commandValue:"NA"});this.isLoaded=true}},{key:"unload",value:function e(){this.isLoaded=false;if(this.mediaCode===1){this.ctx.clearRect(0,0,this.extraData.mjpeg_w,this.extraData.mjpeg_h)}}}]);return n}(o.default);var w=b;r.default=w},{"../demux/h264-demuxer":6,"../errors":7,"../event-handler":8,"../events":9}],14:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;function n(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function o(e,t,r){if(t)i(e.prototype,t);if(r)i(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}var a=function(){function h(){n(this,h)}o(h,null,[{key:"init",value:function e(){h.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var t;for(t in h.types){if(h.types.hasOwnProperty(t)){h.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]}}var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]);var n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);h.HDLR_TYPES={video:r,audio:n};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);var o=new Uint8Array([0,0,0,0,0,0,0,0]);h.STTS=h.STSC=h.STCO=o;h.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);h.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]);h.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]);h.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]);var s=new Uint8Array([97,118,99,49]);var u=new Uint8Array([0,0,0,1]);h.FTYP=h.box(h.types.ftyp,a,u,a,s);h.DINF=h.box(h.types.dinf,h.box(h.types.dref,i))}},{key:"box",value:function e(t){var r=Array.prototype.slice.call(arguments,1),n=8,i=r.length,o=i,a;while(i--){n+=r[i].byteLength}a=new Uint8Array(n);a[0]=n>>24&255;a[1]=n>>16&255;a[2]=n>>8&255;a[3]=n&255;a.set(t,4);for(i=0,n=8;i<o;i++){a.set(r[i],n);n+=r[i].byteLength}return a}},{key:"hdlr",value:function e(t){return h.box(h.types.hdlr,h.HDLR_TYPES[t])}},{key:"mdat",value:function e(t){return h.box(h.types.mdat,t)}},{key:"mdhd",value:function e(t,r){r*=t;return h.box(h.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}},{key:"mdia",value:function e(t){return h.box(h.types.mdia,h.mdhd(t.timescale,t.duration),h.hdlr(t.type),h.minf(t))}},{key:"mfhd",value:function e(t){return h.box(h.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}},{key:"minf",value:function e(t){if(t.type==="audio"){return h.box(h.types.minf,h.box(h.types.smhd,h.SMHD),h.DINF,h.stbl(t))}else{return h.box(h.types.minf,h.box(h.types.vmhd,h.VMHD),h.DINF,h.stbl(t))}}},{key:"moof",value:function e(t,r,n){return h.box(h.types.moof,h.mfhd(t),h.traf(n,r))}},{key:"moov",value:function e(t){var r=t.length,n=[];while(r--){n[r]=h.trak(t[r])}return h.box.apply(null,[h.types.moov,h.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(h.mvex(t)))}},{key:"mvex",value:function e(t){var r=t.length,n=[];while(r--){n[r]=h.trex(t[r])}return h.box.apply(null,[h.types.mvex].concat(n))}},{key:"mvhd",value:function e(t,r){r=0;var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return h.box(h.types.mvhd,n)}},{key:"sdtp",value:function e(t){var r=t.samples||[],n=new Uint8Array(4+r.length),i,o;for(o=0;o<r.length;o++){i=r[o].flags;n[o+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy}return h.box(h.types.sdtp,n)}},{key:"stbl",value:function e(t){return h.box(h.types.stbl,h.stsd(t),h.box(h.types.stts,h.STTS),h.box(h.types.stsc,h.STSC),h.box(h.types.stsz,h.STSZ),h.box(h.types.stco,h.STCO))}},{key:"avc1",value:function e(t){var r=[],n=[],i,o,a;for(i=0;i<t.sps.length;i++){o=t.sps[i];a=o.byteLength;r.push(a>>>8&255);r.push(a&255);r=r.concat(Array.prototype.slice.call(o))}for(i=0;i<t.pps.length;i++){o=t.pps[i];a=o.byteLength;n.push(a>>>8&255);n.push(a&255);n=n.concat(Array.prototype.slice.call(o))}var s=h.box(h.types.avcC,new Uint8Array([1,r[3],r[4],r[5],252|3,224|t.sps.length].concat(r).concat([t.pps.length]).concat(n))),u=t.width,f=t.height;return h.box(h.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u>>8&255,u&255,f>>8&255,f&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,106,101,102,102,45,121,97,110,47,47,47,103,119,102,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,h.box(h.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))}},{key:"esds",value:function e(t){var r=t.config.length;return new Uint8Array([0,0,0,0,3,23+r,0,1,0,4,15+r,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([r]).concat(t.config).concat([6,1,2]))}},{key:"mp4a",value:function e(t){var r=t.audiosamplerate;return h.box(h.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,r&255,0,0]),h.box(h.types.esds,h.esds(t)))}},{key:"stsd",value:function e(t){if(t.type==="audio"){return h.box(h.types.stsd,h.STSD,h.mp4a(t))}else{return h.box(h.types.stsd,h.STSD,h.avc1(t))}}},{key:"tkhd",value:function e(t){var r=t.id,n=t.duration*t.timescale,i=t.width,o=t.height;return h.box(h.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,r&255,0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,i&255,0,0,o>>8&255,o&255,0,0]))}},{key:"traf",value:function e(t,r){var n=h.sdtp(t),i=t.id;return h.box(h.types.traf,h.box(h.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255])),h.box(h.types.tfdt,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),h.trun(t,n.length+16+16+8+16+8+8),n)}},{key:"trak",value:function e(t){t.duration=t.duration||4294967295;return h.box(h.types.trak,h.tkhd(t),h.mdia(t))}},{key:"trex",value:function e(t){var r=t.id;return h.box(h.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function e(t,r){var n=t.samples||[],i=n.length,o=12+16*i,a=new Uint8Array(o),s,u,f,l,c,d;r+=8+o;a.set([0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,i&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255],0);for(s=0;s<i;s++){u=n[s];f=u.duration;l=u.size;c=u.flags;d=u.cts;a.set([f>>>24&255,f>>>16&255,f>>>8&255,f&255,l>>>24&255,l>>>16&255,l>>>8&255,l&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&240<<8,c.degradPrio&15,d>>>24&255,d>>>16&255,d>>>8&255,d&255],12+16*s)}return h.box(h.types.trun,a)}},{key:"initSegment",value:function e(t){if(!h.types){h.init()}var r=h.moov(t),n;n=new Uint8Array(h.FTYP.byteLength+r.byteLength);n.set(h.FTYP);n.set(r,h.FTYP.byteLength);return n}}]);return h}();var s=a;r.default=s},{}],15:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var G=n(e("../helper/aac"));var B=n(e("../events"));var H=e("../utils/logger");var W=n(e("../remux/mp4-generator"));var p=e("../errors");e("../utils/polyfill");function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function a(e,t,r){if(t)o(e.prototype,t);if(r)o(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}var s=function(){function n(e,t,r){i(this,n);this.observer=e;this.id=t;this.config=r;this.ISGenerated=false;this.PES2MP4SCALEFACTOR=4;this.PES_TIMESCALE=9e4;this.MP4_TIMESCALE=this.PES_TIMESCALE/this.PES2MP4SCALEFACTOR;this.nextAvcDts=90300;this.H264_TIMEBASE=this.config.mp4Duration;this.genISFailCount=0}a(n,[{key:"passthrough",get:function e(){return false}},{key:"destroy",value:function e(){}},{key:"insertDiscontinuity",value:function e(){this._initPTS=this._initDTS=undefined}},{key:"switchLevel",value:function e(){this.ISGenerated=false;this.genISFailCount=0}},{key:"pushVideo",value:function e(t,r,n,i,o){this.level=t;this.sn=r;var a;if(!this.ISGenerated){this.generateVideoIS(n,i)}if(this.ISGenerated){this.remuxVideo_2(n,i,o)}}},{key:"remuxVideo_2",value:function e(t,r,n,i){var o=8,a,s,u=t.samples,f=[];a=new Uint8Array(t.len+4*t.nbNalu+8);var l=new DataView(a.buffer);l.setUint32(0,a.byteLength);a.set(W.default.types.mdat,4);var c=0;var d,h,p,v;for(var y=0;y<u.length;y++){var m=u[y],g=0;while(m.units.units.length){var b=m.units.units.shift();l.setUint32(o,b.data.byteLength);o+=4;a.set(b.data,o);o+=b.data.byteLength;g+=4+b.data.byteLength}var w=m.pts-this._initPTS;var E=m.dts-this._initDTS;E=Math.min(w,E);if(v!==undefined){d=this._PTSNormalize(w,v);h=this._PTSNormalize(E,v);c=h-v;if(c<=0){H.logger.log("invalid sample duration at PTS/DTS: ".concat(m.pts,"/").concat(m.dts,"|dts norm: ").concat(h,"|lastDTS: ").concat(v,":").concat(c));c=1}}else{var _=this.nextAvcDts,A;d=this._PTSNormalize(w,_);h=this._PTSNormalize(E,_);if(_){A=Math.round(h-_);if(Math.abs(A)<600){if(A){if(A>1){H.logger.log("AVC:".concat(A," ms hole between fragments detected,filling it"))}else if(A<-1){H.logger.log("AVC:".concat(-A," ms overlapping between fragments detected"))}h=_;d=Math.max(d-A,h);H.logger.log("Video/PTS/DTS adjusted: ".concat(d,"/").concat(h,",delta:").concat(A))}}}this.firstPTS=Math.max(0,d);this.firstDTS=Math.max(0,h);c=.03}f.push({size:g,duration:this.H264_TIMEBASE,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:m.key?2:1,isNonSync:m.key?0:1}});v=h}var T=0;if(f.length>=2){T=f[f.length-2].duration;f[0].duration=T}this.nextAvcDts=h+T;t.len=0;t.nbNalu=0;t.dropped=0;if(f.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var S=f[0].flags;S.dependsOn=2;S.isNonSync=0}t.samples=f;s=W.default.moof(t.sequenceNumber++,h,t);t.samples=[];var k={data1:s,data2:a,type:"video"};this.observer.trigger(B.default.FRAG_PARSING_DATA,k);return k}},{key:"generateVideoIS",value:function e(t,r){var n=this.observer,i=t.samples,o=this.PES_TIMESCALE,a={},s={id:this.id,level:this.level,sn:this.sn,tracks:a,unique:false},u=this._initPTS===undefined,f,l;if(u){f=l=Infinity}if(t.sps&&t.pps&&i.length){t.timescale=9e4;a.video={container:"video/mp4",codec:t.codec,initSegment:W.default.initSegment([t]),metadata:{width:t.width,height:t.height}};if(u){f=Math.min(f,i[0].pts-this.H264_TIMEBASE);l=Math.min(l,i[0].dts-this.H264_TIMEBASE)}}if(Object.keys(a).length){n.trigger(B.default.FRAG_PARSING_INIT_SEGMENT,s);this.ISGenerated=true;this.genISFailCount=0;if(u){this._initPTS=f;this._initDTS=l}}else{this.genISFailCount++;if(this.genISFailCount>60){console.log("generateVideoIS ERROR: ",p.ErrorTypes.MEDIA_ERROR)}}}},{key:"remux",value:function e(t,r,n,i,o,a,s,u){this.level=t;this.sn=r;if(!this.ISGenerated){this.generateIS(n,i,s)}if(this.ISGenerated){if(n.samples.length){var f=this.remuxAudio(n,s,u);if(i.samples.length){var l;if(f){l=f.endPTS-f.startPTS}this.remuxVideo(i,s,u,l)}}else{var c;if(i.samples.length){c=this.remuxVideo(i,s,u)}if(c&&n.codec){this.remuxEmptyAudio(n,s,u,c)}}}if(o.samples.length){this.remuxID3(o,s)}if(a.samples.length){this.remuxText(a,s)}this.observer.trigger(B.default.FRAG_PARSED,{id:this.id,level:this.level,sn:this.sn})}},{key:"generateIS",value:function e(t,r,n){var i=this.observer,o=t.samples,a=r.samples,s=this.PES_TIMESCALE,u={},f={id:this.id,level:this.level,sn:this.sn,tracks:u,unique:false},l=this._initPTS===undefined,c,d;if(l){c=d=Infinity}if(t.config&&o.length){t.timescale=t.audiosamplerate;if(t.timescale*t.duration>Math.pow(2,32)){var h=function e(t,r){if(!r){return t}return e(r,t%r)};t.timescale=t.audiosamplerate/h(t.audiosamplerate,1024)}H.logger.log("audio mp4 timescale :"+t.timescale);u.audio={container:"audio/mp4",codec:t.codec,initSegment:W.default.initSegment([t]),metadata:{channelCount:t.channelCount}};if(l){c=d=o[0].pts-s*n}}if(r.sps&&r.pps&&a.length){r.timescale=this.MP4_TIMESCALE;u.video={container:"video/mp4",codec:r.codec,initSegment:W.default.initSegment([r]),metadata:{width:r.width,height:r.height}};if(l){c=Math.min(c,a[0].pts-s*n);d=Math.min(d,a[0].dts-s*n)}}if(Object.keys(u).length){i.trigger(B.default.FRAG_PARSING_INIT_SEGMENT,f);this.ISGenerated=true;if(l){this._initPTS=c;this._initDTS=d}}else{i.trigger(B.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,id:this.id,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:false,reason:"no audio/video samples found"})}}},{key:"remuxAudio",value:function F(e,t,r){var n=this.PES_TIMESCALE,M=e.timescale,i=n/M,U=e.timescale*1024/e.audiosamplerate;var o,a=8,s,u,f,l,c,d,h,p,v,y,m,g,b=[],w=[];e.samples.sort(function(e,t){return e.pts-t.pts});w=e.samples;var E=r?this.nextAacPts:t*n;var j=this._PTSNormalize(w[0].pts-this._initPTS,E),_=U*i;var A=j+_;for(var T=1;T<w.length;){var S=w[T],k=this._PTSNormalize(S.pts-this._initPTS,E),R=k-A;if(R<-.5*_){H.logger.log("Dropping frame due to ".concat(Math.abs(R/90)," ms overlap."));w.splice(T,1);e.len-=S.unit.length}else if(R>.5*_){var O=Math.round(R/_);H.logger.log("Injecting ".concat(O," frame").concat(O>1?"s":""," of missing audio due to ").concat(Math.round(R/90)," ms gap."));for(var P=0;P<O;P++){var D=w[T-1].pts+_,L=G.default.getSilentFrame(e.channelCount);if(!L){H.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead.");L=S.unit.slice(0)}w.splice(T,0,{unit:L,pts:D,dts:D});e.len+=L.length;T+=1}A+=(O+1)*_;S.pts=w[T-1].pts+_;T+=1}else{if(Math.abs(R)>.1*_){H.logger.log("Invalid frame delta ".concat(k-A+_," at PTS ").concat(Math.round(k/90)," (should be ").concat(_,")."))}A+=_;S.pts=w[T-1].pts+_;T+=1}}while(w.length){s=w.shift();f=s.unit;v=s.pts-this._initDTS;y=s.dts-this._initDTS;if(p!==undefined){m=this._PTSNormalize(v,p);g=this._PTSNormalize(y,p);u.duration=(g-p)/i}else{m=this._PTSNormalize(v,E);g=this._PTSNormalize(y,E);var x=Math.round(1e3*(m-E)/n);if(r){if(x){if(x>0){H.logger.log("".concat(x," ms hole between AAC samples detected,filling it"))}else if(x<-12){H.logger.log("".concat(-x," ms overlapping between AAC samples detected, drop frame"));e.len-=f.byteLength;continue}m=g=E}}d=Math.max(0,m);h=Math.max(0,g);if(e.len>0){l=new Uint8Array(e.len+8);o=new DataView(l.buffer);o.setUint32(0,l.byteLength);l.set(W.default.types.mdat,4)}else{return}}l.set(f,a);a+=f.byteLength;u={size:f.byteLength,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}};b.push(u);p=g}var C=0;var I=b.length;if(I>=2){C=b[I-2].duration;u.duration=C}if(I){this.nextAacPts=m+i*C;e.len=0;e.samples=b;c=W.default.moof(e.sequenceNumber++,h/i,e);e.samples=[];var N={id:this.id,level:this.level,sn:this.sn,data1:c,data2:l,startPTS:d/n,endPTS:this.nextAacPts/n,startDTS:h/n,endDTS:(g+i*C)/n,type:"audio",nb:I};this.observer.trigger(B.default.FRAG_PARSING_DATA,N);return N}return null}},{key:"remuxEmptyAudio",value:function e(t,r,n,i){var o=this.PES_TIMESCALE,a=t.timescale?t.timescale:t.audiosamplerate,s=o/a,u=i.startDTS*o+this._initDTS,f=i.endDTS*o+this._initDTS,l=1024,c=s*l,d=Math.ceil((f-u)/c),h=G.default.getSilentFrame(t.channelCount);if(!h){H.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");return}var p=[];for(var v=0;v<d;v++){var y=u+v*c;p.push({unit:h.slice(0),pts:y,dts:y});t.len+=h.length}t.samples=p;this.remuxAudio(t,r,n)}},{key:"remuxID3",value:function e(t,r){var n=t.samples.length,i;if(n){for(var o=0;o<n;o++){i=t.samples[o];i.pts=(i.pts-this._initPTS)/this.PES_TIMESCALE;i.dts=(i.dts-this._initDTS)/this.PES_TIMESCALE}this.observer.trigger(B.default.FRAG_PARSING_METADATA,{id:this.id,level:this.level,sn:this.sn,samples:t.samples})}t.samples=[];r=r}},{key:"remuxText",value:function e(t,r){t.samples.sort(function(e,t){return e.pts-t.pts});var n=t.samples.length,i;if(n){for(var o=0;o<n;o++){i=t.samples[o];i.pts=(i.pts-this._initPTS)/this.PES_TIMESCALE}this.observer.trigger(B.default.FRAG_PARSING_USERDATA,{id:this.id,level:this.level,sn:this.sn,samples:t.samples})}t.samples=[];r=r}},{key:"_PTSNormalize",value:function e(t,r){var n;if(r===undefined){return t}if(r<t){n=-8589934592}else{n=8589934592}while(Math.abs(t-r)>4294967296){t+=n}return t}}]);return n}();var u=s;r.default=u},{"../errors":7,"../events":9,"../helper/aac":10,"../remux/mp4-generator":14,"../utils/logger":16,"../utils/polyfill":18}],16:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.logger=r.enableLogs=void 0;function n(e){"@babel/helpers - typeof";return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(){}var i={trace:o,debug:o,log:o,warn:o,info:o,error:o};var a=i;function s(e,t){t="["+e+"] > "+t;return t}function u(n){var i=window.console[n];if(i){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++){t[r]=arguments[r]}if(t[0]){t[0]=s(n,t[0])}i.apply(window.console,t)}}return o}function f(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}r.forEach(function(e){a[e]=t[e]?t[e].bind(t):u(e)})}var l=function e(t){if(t===true||n(t)==="object"){f(t,"debug","log","info","warn","error");try{a.log()}catch(e){a=i}}else{a=i}};r.enableLogs=l;var c=a;r.logger=c},{}],17:[function(e,t,r){(function(Kt){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.createEncoderWithModule=zt;r.createFile=v;r.default=void 0;function qt(e){"@babel/helpers - typeof";return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qt(e)}var e=function(){var Vt=typeof document!=="undefined"&&document.currentScript?document.currentScript.src:undefined;return function(a){a=a||{};var a=typeof a!="undefined"?a:{};var F,s;a["ready"]=new Promise(function(e,t){F=e;s=t});a["createEncoder"]=function e(t){return zt(a,t)};var M=Object.assign({},a);var U=[];var j="./this.program";var G=function e(t,r){throw r};var B=(typeof window==="undefined"?"undefined":qt(window))=="object";var e=typeof importScripts=="function";var H=(typeof Kt==="undefined"?"undefined":qt(Kt))=="object"&&qt(Kt.versions)=="object"&&typeof Kt.versions.node=="string";var t="";function W(e){if(a["locateFile"]){return a["locateFile"](e,t)}return t+e}var V,q,r,z;if(B||e){if(e){t=self.location.href}else if(typeof document!="undefined"&&document.currentScript){t=document.currentScript.src}if(Vt){t=Vt}if(t.indexOf("blob:")!==0){t=t.substr(0,t.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{t=""}{V=function e(t){var r=new XMLHttpRequest;r.open("GET",t,false);r.send(null);return r.responseText};if(e){r=function e(t){var r=new XMLHttpRequest;r.open("GET",t,false);r.responseType="arraybuffer";r.send(null);return new Uint8Array(r.response)}}q=function e(t,r,n){var i=new XMLHttpRequest;i.open("GET",t,true);i.responseType="arraybuffer";i.onload=function(){if(i.status==200||i.status==0&&i.response){r(i.response);return}n()};i.onerror=n;i.send(null)}}z=function e(t){return document.title=t}}else{}var K=a["print"]||console.log.bind(console);var u=a["printErr"]||console.warn.bind(console);Object.assign(a,M);M=null;if(a["arguments"])U=a["arguments"];if(a["thisProgram"])j=a["thisProgram"];if(a["quit"])G=a["quit"];var Y=4;var f;if(a["wasmBinary"])f=a["wasmBinary"];var X=a["noExitRuntime"]||true;if((typeof WebAssembly==="undefined"?"undefined":qt(WebAssembly))!="object"){b("no native wasm support detected")}var l;var Z=false;var J;function Q(e,t,r){var n=t+r;var i="";while(!(t>=n)){var o=e[t++];if(!o)return i;if(!(o&128)){i+=String.fromCharCode(o);continue}var a=e[t++]&63;if((o&224)==192){i+=String.fromCharCode((o&31)<<6|a);continue}var s=e[t++]&63;if((o&240)==224){o=(o&15)<<12|a<<6|s}else{o=(o&7)<<18|a<<12|s<<6|e[t++]&63}if(o<65536){i+=String.fromCharCode(o)}else{var u=o-65536;i+=String.fromCharCode(55296|u>>10,56320|u&1023)}}return i}function d(e,t){return e?Q(p,e,t):""}function $(e,t,r,n){if(!(n>0))return 0;var i=r;var o=r+n-1;for(var a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343){var u=e.charCodeAt(++a);s=65536+((s&1023)<<10)|u&1023}if(s<=127){if(r>=o)break;t[r++]=s}else if(s<=2047){if(r+1>=o)break;t[r++]=192|s>>6;t[r++]=128|s&63}else if(s<=65535){if(r+2>=o)break;t[r++]=224|s>>12;t[r++]=128|s>>6&63;t[r++]=128|s&63}else{if(r+3>=o)break;t[r++]=240|s>>18;t[r++]=128|s>>12&63;t[r++]=128|s>>6&63;t[r++]=128|s&63}}t[r]=0;return r-i}function ee(e,t,r){return $(e,p,t,r)}function te(e){var t=0;for(var r=0;r<e.length;++r){var n=e.charCodeAt(r);if(n<=127){t++}else if(n<=2047){t+=2}else if(n>=55296&&n<=57343){t+=4;++r}else{t+=3}}return t}var c,h,p,v,n,y,m,re,ne;function ie(e){c=e;a["HEAP8"]=h=new Int8Array(e);a["HEAP16"]=v=new Int16Array(e);a["HEAP32"]=y=new Int32Array(e);a["HEAPU8"]=p=new Uint8Array(e);a["HEAPU16"]=n=new Uint16Array(e);a["HEAPU32"]=m=new Uint32Array(e);a["HEAPF32"]=re=new Float32Array(e);a["HEAPF64"]=ne=new Float64Array(e)}var oe=a["INITIAL_MEMORY"]||16777216;var ae;var se=[];var ue=[];var fe=[];var le=false;function ce(){if(a["preRun"]){if(typeof a["preRun"]=="function")a["preRun"]=[a["preRun"]];while(a["preRun"].length){pe(a["preRun"].shift())}}E(se)}function de(){le=true;E(ue)}function he(){if(a["postRun"]){if(typeof a["postRun"]=="function")a["postRun"]=[a["postRun"]];while(a["postRun"].length){ye(a["postRun"].shift())}}E(fe)}function pe(e){se.unshift(e)}function ve(e){ue.unshift(e)}function ye(e){fe.unshift(e)}var i=0;var o=null;var g=null;function me(e){i++;if(a["monitorRunDependencies"]){a["monitorRunDependencies"](i)}}function ge(e){i--;if(a["monitorRunDependencies"]){a["monitorRunDependencies"](i)}if(i==0){if(o!==null){clearInterval(o);o=null}if(g){var t=g;g=null;t()}}}function b(e){{if(a["onAbort"]){a["onAbort"](e)}}e="Aborted("+e+")";u(e);Z=true;J=1;e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);s(t);throw t}var be="data:application/octet-stream;base64,";function we(e){return e.startsWith(be)}var w;w="mp4-encoder.wasm";if(!we(w)){w=W(w)}function Ee(e){try{if(e==w&&f){return new Uint8Array(f)}if(r){return r(e)}throw"both async and sync fetching of the wasm failed"}catch(e){b(e)}}function _e(){if(!f&&(B||e)){if(typeof fetch=="function"){return fetch(w,{credentials:"same-origin"}).then(function(e){if(!e["ok"]){throw"failed to load wasm binary file at '"+w+"'"}return e["arrayBuffer"]()}).catch(function(){return Ee(w)})}}return Promise.resolve().then(function(){return Ee(w)})}function Ae(){var r={a:Ft};function t(e,t){var r=e.exports;a["asm"]=r;l=a["asm"]["x"];ie(l.buffer);ae=a["asm"]["B"];ve(a["asm"]["y"]);ge("wasm-instantiate")}me("wasm-instantiate");function n(e){t(e["instance"])}function i(e){return _e().then(function(e){return WebAssembly.instantiate(e,r)}).then(function(e){return e}).then(e,function(e){u("failed to asynchronously prepare wasm: "+e);b(e)})}function e(){if(!f&&typeof WebAssembly.instantiateStreaming=="function"&&!we(w)&&typeof fetch=="function"){return fetch(w,{credentials:"same-origin"}).then(function(e){var t=WebAssembly.instantiateStreaming(e,r);return t.then(n,function(e){u("wasm streaming compile failed: "+e);u("falling back to ArrayBuffer instantiation");return i(n)})})}else{return i(n)}}if(a["instantiateWasm"]){try{var o=a["instantiateWasm"](r,t);return o}catch(e){u("Module.instantiateWasm callback failed with error: "+e);s(e)}}e().catch(s);return{}}function E(e){while(e.length>0){e.shift()(a)}}function Te(e,t,r,n){b("Assertion failed: "+d(e)+", at: "+[t?d(t):"unknown filename",r,n?d(n):"unknown function"])}function Se(e,t,r,n,i){}function _(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}function ke(){var e=new Array(256);for(var t=0;t<256;++t){e[t]=String.fromCharCode(t)}Re=e}var Re=undefined;function A(e){var t="";var r=e;while(p[r]){t+=Re[p[r++]]}return t}var T={};var S={};var k={};var Oe=48;var Pe=57;function De(e){if(undefined===e){return"_unknown"}e=e.replace(/[^a-zA-Z0-9_]/g,"$");var t=e.charCodeAt(0);if(t>=Oe&&t<=Pe){return"_"+e}return e}function Le(e,t){e=De(e);return new Function("body","return function "+e+"() {\n"+' "use strict";'+" return body.apply(this, arguments);\n"+"};\n")(t)}function R(e,r){var t=Le(r,function(e){this.name=r;this.message=e;var t=new Error(e).stack;if(t!==undefined){this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,"")}});t.prototype=Object.create(e.prototype);t.prototype.constructor=t;t.prototype.toString=function(){if(this.message===undefined){return this.name}else{return this.name+": "+this.message}};return t}var xe=undefined;function O(e){throw new xe(e)}var Ce=undefined;function Ie(e){throw new Ce(e)}function Ne(n,t,i){n.forEach(function(e){k[e]=t});function r(e){var t=i(e);if(t.length!==n.length){Ie("Mismatched type converter count")}for(var r=0;r<n.length;++r){P(n[r],t[r])}}var o=new Array(t.length);var a=[];var s=0;t.forEach(function(e,t){if(S.hasOwnProperty(e)){o[t]=S[e]}else{a.push(e);if(!T.hasOwnProperty(e)){T[e]=[]}T[e].push(function(){o[t]=S[e];++s;if(s===a.length){r(o)}})}});if(0===a.length){r(o)}}function P(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(!("argPackAdvance"in t)){throw new TypeError("registerType registeredInstance requires argPackAdvance")}var n=t.name;if(!e){O('type "'+n+'" must have a positive integer typeid pointer')}if(S.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations){return}else{O("Cannot register type '"+n+"' twice")}}S[e]=t;delete k[e];if(T.hasOwnProperty(e)){var i=T[e];delete T[e];i.forEach(function(e){return e()})}}function Fe(e,n,i,o,a){var s=_(i);n=A(n);P(e,{name:n,fromWireType:function e(t){return!!t},toWireType:function e(t,r){return r?o:a},argPackAdvance:8,readValueFromPointer:function e(t){var r;if(i===1){r=h}else if(i===2){r=v}else if(i===4){r=y}else{throw new TypeError("Unknown boolean type size: "+n)}return this["fromWireType"](r[t>>s])},destructorFunction:null})}var D=[];var L=[{},{value:undefined},{value:null},{value:true},{value:false}];function Me(e){if(e>4&&0===--L[e].refcount){L[e]=undefined;D.push(e)}}function Ue(){var e=0;for(var t=5;t<L.length;++t){if(L[t]!==undefined){++e}}return e}function je(){for(var e=5;e<L.length;++e){if(L[e]!==undefined){return L[e]}}return null}function Ge(){a["count_emval_handles"]=Ue;a["get_first_emval"]=je}var x={toValue:function e(t){if(!t){O("Cannot use deleted val. handle = "+t)}return L[t].value},toHandle:function e(t){switch(t){case undefined:return 1;case null:return 2;case true:return 3;case false:return 4;default:{var r=D.length?D.pop():L.length;L[r]={refcount:1,value:t};return r}}}};function Be(e){return this["fromWireType"](y[e>>2])}function He(e,t){t=A(t);P(e,{name:t,fromWireType:function e(t){var r=x.toValue(t);Me(t);return r},toWireType:function e(t,r){return x.toHandle(r)},argPackAdvance:8,readValueFromPointer:Be,destructorFunction:null})}function We(e,t){switch(t){case 2:return function(e){return this["fromWireType"](re[e>>2])};case 3:return function(e){return this["fromWireType"](ne[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ve(e,t,r){var n=_(r);t=A(t);P(e,{name:t,fromWireType:function e(t){return t},toWireType:function e(t,r){return r},argPackAdvance:8,readValueFromPointer:We(t,n),destructorFunction:null})}function qe(e,t){if(!(e instanceof Function)){throw new TypeError("new_ called with constructor type "+qt(e)+" which is not a function")}var r=Le(e.name||"unknownFunctionName",function(){});r.prototype=e.prototype;var n=new r;var i=e.apply(n,t);return i instanceof Object?i:n}function ze(e){while(e.length){var t=e.pop();var r=e.pop();r(t)}}function Ke(e,t,r,n,i){var o=t.length;if(o<2){O("argTypes array size mismatch! Must at least get return value and 'this' types!")}var a=t[1]!==null&&r!==null;var s=false;for(var u=1;u<t.length;++u){if(t[u]!==null&&t[u].destructorFunction===undefined){s=true;break}}var f=t[0].name!=="void";var l="";var c="";for(var u=0;u<o-2;++u){l+=(u!==0?", ":"")+"arg"+u;c+=(u!==0?", ":"")+"arg"+u+"Wired"}var d="return function "+De(e)+"("+l+") {\n"+"if (arguments.length !== "+(o-2)+") {\n"+"throwBindingError('function "+e+" called with ' + arguments.length + ' arguments, expected "+(o-2)+" args!');\n"+"}\n";if(s){d+="var destructors = [];\n"}var h=s?"destructors":"null";var p=["throwBindingError","invoker","fn","runDestructors","retType","classParam"];var v=[O,n,i,ze,t[0],t[1]];if(a){d+="var thisWired = classParam.toWireType("+h+", this);\n"}for(var u=0;u<o-2;++u){d+="var arg"+u+"Wired = argType"+u+".toWireType("+h+", arg"+u+"); // "+t[u+2].name+"\n";p.push("argType"+u);v.push(t[u+2])}if(a){c="thisWired"+(c.length>0?", ":"")+c}d+=(f?"var rv = ":"")+"invoker(fn"+(c.length>0?", ":"")+c+");\n";if(s){d+="runDestructors(destructors);\n"}else{for(var u=a?1:2;u<t.length;++u){var y=u===1?"thisWired":"arg"+(u-2)+"Wired";if(t[u].destructorFunction!==null){d+=y+"_dtor("+y+"); // "+t[u].name+"\n";p.push(y+"_dtor");v.push(t[u].destructorFunction)}}}if(f){d+="var ret = retType.fromWireType(rv);\n"+"return ret;\n"}else{}d+="}\n";p.push(d);var m=qe(Function,p).apply(null,v);return m}function Ye(e,t,r){if(undefined===e[t].overloadTable){var n=e[t];e[t]=function(){if(!e[t].overloadTable.hasOwnProperty(arguments.length)){O("Function '"+r+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].overloadTable+")!")}return e[t].overloadTable[arguments.length].apply(this,arguments)};e[t].overloadTable=[];e[t].overloadTable[n.argCount]=n}}function Xe(e,t,r){if(a.hasOwnProperty(e)){if(undefined===r||undefined!==a[e].overloadTable&&undefined!==a[e].overloadTable[r]){O("Cannot register public name '"+e+"' twice")}Ye(a,e,e);if(a.hasOwnProperty(r)){O("Cannot register multiple overloads of a function with the same number of arguments ("+r+")!")}a[e].overloadTable[r]=t}else{a[e]=t;if(undefined!==r){a[e].numArguments=r}}}function Ze(e,t){var r=[];for(var n=0;n<e;n++){r.push(m[t+n*4>>2])}return r}function Je(e,t,r){if(!a.hasOwnProperty(e)){Ie("Replacing nonexistant public symbol")}if(undefined!==a[e].overloadTable&&undefined!==r){a[e].overloadTable[r]=t}else{a[e]=t;a[e].argCount=r}}function Qe(e,t,r){var n=a["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)}var C=[];function $e(e){var t=C[e];if(!t){if(e>=C.length)C.length=e+1;C[e]=t=ae.get(e)}return t}function et(e,t,r){if(e.includes("j")){return Qe(e,t,r)}var n=$e(t).apply(null,r);return n}function tt(e,t){var r=[];return function(){r.length=0;Object.assign(r,arguments);return et(e,t,r)}}function rt(e,t){e=A(e);function r(){if(e.includes("j")){return tt(e,t)}return $e(t)}var n=r();if(typeof n!="function"){O("unknown function pointer with signature "+e+": "+t)}return n}var nt=undefined;function it(e){var t=Gt(e);var r=A(t);I(t);return r}function ot(e,t){var r=[];var n={};function i(e){if(n[e]){return}if(S[e]){return}if(k[e]){k[e].forEach(i);return}r.push(e);n[e]=true}t.forEach(i);throw new nt(e+": "+r.map(it).join([", "]))}function at(r,n,e,t,i,o){var a=Ze(n,e);r=A(r);i=rt(t,i);Xe(r,function(){ot("Cannot call "+r+" due to unbound types",a)},n-1);Ne([],a,function(e){var t=[e[0],null].concat(e.slice(1));Je(r,Ke(r,t,null,i,o),n-1);return[]})}function st(e,t,r){switch(t){case 0:return r?function e(t){return h[t]}:function e(t){return p[t]};case 1:return r?function e(t){return v[t>>1]}:function e(t){return n[t>>1]};case 2:return r?function e(t){return y[t>>2]}:function e(t){return m[t>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function ut(e,t,r,n,i){t=A(t);if(i===-1){i=4294967295}var o=_(r);var a=function e(t){return t};if(n===0){var s=32-8*r;a=function e(t){return t<<s>>>s}}var u=t.includes("unsigned");var f=function e(t,r){};var l;if(u){l=function e(t,r){f(r,this.name);return r>>>0}}else{l=function e(t,r){f(r,this.name);return r}}P(e,{name:t,fromWireType:a,toWireType:l,argPackAdvance:8,readValueFromPointer:st(t,o,n!==0),destructorFunction:null})}function ft(e,t,r){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var i=n[t];function o(e){e=e>>2;var t=m;var r=t[e];var n=t[e+1];return new i(c,n,r)}r=A(r);P(e,{name:r,fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:true})}function lt(e,t){t=A(t);var c=t==="std::string";P(e,{name:t,fromWireType:function e(t){var r=m[t>>2];var n=t+4;var i;if(c){var o=n;for(var a=0;a<=r;++a){var s=n+a;if(a==r||p[s]==0){var u=s-o;var f=d(o,u);if(i===undefined){i=f}else{i+=String.fromCharCode(0);i+=f}o=s+1}}}else{var l=new Array(r);for(var a=0;a<r;++a){l[a]=String.fromCharCode(p[n+a])}i=l.join("")}I(t);return i},toWireType:function e(t,r){if(r instanceof ArrayBuffer){r=new Uint8Array(r)}var n;var i=typeof r=="string";if(!(i||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int8Array)){O("Cannot pass non-string to std::string")}if(c&&i){n=te(r)}else{n=r.length}var o=jt(4+n+1);var a=o+4;m[o>>2]=n;if(c&&i){ee(r,a,n+1)}else{if(i){for(var s=0;s<n;++s){var u=r.charCodeAt(s);if(u>255){I(a);O("String has UTF-16 code units that do not fit in 8 bits")}p[a+s]=u}}else{for(var s=0;s<n;++s){p[a+s]=r[s]}}}if(t!==null){t.push(I,o)}return o},argPackAdvance:8,readValueFromPointer:Be,destructorFunction:function e(t){I(t)}})}function ct(e,t){var r="";for(var n=0;!(n>=t/2);++n){var i=v[e+n*2>>1];if(i==0)break;r+=String.fromCharCode(i)}return r}function dt(e,t,r){if(r===undefined){r=2147483647}if(r<2)return 0;r-=2;var n=t;var i=r<e.length*2?r/2:e.length;for(var o=0;o<i;++o){var a=e.charCodeAt(o);v[t>>1]=a;t+=2}v[t>>1]=0;return t-n}function ht(e){return e.length*2}function pt(e,t){var r=0;var n="";while(!(r>=t/4)){var i=y[e+r*4>>2];if(i==0)break;++r;if(i>=65536){var o=i-65536;n+=String.fromCharCode(55296|o>>10,56320|o&1023)}else{n+=String.fromCharCode(i)}}return n}function vt(e,t,r){if(r===undefined){r=2147483647}if(r<4)return 0;var n=t;var i=n+r-4;for(var o=0;o<e.length;++o){var a=e.charCodeAt(o);if(a>=55296&&a<=57343){var s=e.charCodeAt(++o);a=65536+((a&1023)<<10)|s&1023}y[t>>2]=a;t+=4;if(t+4>i)break}y[t>>2]=0;return t-n}function yt(e){var t=0;for(var r=0;r<e.length;++r){var n=e.charCodeAt(r);if(n>=55296&&n<=57343)++r;t+=4}return t}function mt(e,l,o){o=A(o);var c,a,d,s,h;if(l===2){c=ct;a=dt;s=ht;d=function e(){return n};h=1}else if(l===4){c=pt;a=vt;s=yt;d=function e(){return m};h=2}P(e,{name:o,fromWireType:function e(t){var r=m[t>>2];var n=d();var i;var o=t+4;for(var a=0;a<=r;++a){var s=t+4+a*l;if(a==r||n[s>>h]==0){var u=s-o;var f=c(o,u);if(i===undefined){i=f}else{i+=String.fromCharCode(0);i+=f}o=s+l}}I(t);return i},toWireType:function e(t,r){if(!(typeof r=="string")){O("Cannot pass non-string to C++ string type "+o)}var n=s(r);var i=jt(4+n+l);m[i>>2]=n>>h;a(r,i+4,n+l);if(t!==null){t.push(I,i)}return i},argPackAdvance:8,readValueFromPointer:Be,destructorFunction:function e(t){I(t)}})}function gt(e,t){t=A(t);P(e,{isVoid:true,name:t,argPackAdvance:0,fromWireType:function e(){return undefined},toWireType:function e(t,r){return undefined}})}function bt(e,t){var r=S[e];if(undefined===r){O(t+" has unknown type "+it(e))}return r}function wt(e,t,r){e=x.toValue(e);t=bt(t,"emval::as");var n=[];var i=x.toHandle(n);m[r>>2]=i;return t["toWireType"](n,e)}function Et(e,t){var r=new Array(e);for(var n=0;n<e;++n){r[n]=bt(m[t+n*Y>>2],"parameter "+n)}return r}function _t(e,t,r,n){e=x.toValue(e);var i=Et(t,r);var o=new Array(t);for(var a=0;a<t;++a){var s=i[a];o[a]=s["readValueFromPointer"](n);n+=s["argPackAdvance"]}var u=e.apply(undefined,o);return x.toHandle(u)}function At(e,t){e=x.toValue(e);t=x.toValue(t);return x.toHandle(e[t])}function Tt(e){if(e>4){L[e].refcount+=1}}function St(e){e=x.toValue(e);return typeof e=="number"}var kt={};function Rt(e){var t=kt[e];if(t===undefined){return A(e)}return t}function Ot(e){return x.toHandle(Rt(e))}function Pt(e){var t=x.toValue(e);ze(t);Me(e)}function Dt(e,t){e=bt(e,"_emval_take_value");var r=e["readValueFromPointer"](t);return x.toHandle(r)}function Lt(){b("")}function xt(e,t,r){p.copyWithin(e,t,t+r)}function Ct(){return 2147483648}function It(e){try{l.grow(e-c.byteLength+65535>>>16);ie(l.buffer);return 1}catch(e){}}function Nt(e){var t=p.length;e=e>>>0;var r=Ct();if(e>r){return false}var n=function e(t,r){return t+(r-t%r)%r};for(var i=1;i<=4;i*=2){var o=t*(1+.2/i);o=Math.min(o,e+100663296);var a=Math.min(r,n(Math.max(e,o),65536));var s=It(a);if(s){return true}}return false}ke();xe=a["BindingError"]=R(Error,"BindingError");Ce=a["InternalError"]=R(Error,"InternalError");Ge();nt=a["UnboundTypeError"]=R(Error,"UnboundTypeError");var Ft={a:Te,q:Se,u:Fe,t:He,o:Ve,h:at,d:ut,c:ft,n:lt,l:mt,v:gt,k:wt,w:_t,b:Me,e:At,g:Tt,p:St,f:Ot,j:Pt,i:Dt,m:Lt,s:xt,r:Nt};var Mt=Ae();var Ut=a["___wasm_call_ctors"]=function(){return(Ut=a["___wasm_call_ctors"]=a["asm"]["y"]).apply(null,arguments)};var jt=a["_malloc"]=function(){return(jt=a["_malloc"]=a["asm"]["z"]).apply(null,arguments)};var I=a["_free"]=function(){return(I=a["_free"]=a["asm"]["A"]).apply(null,arguments)};var Gt=a["___getTypeName"]=function(){return(Gt=a["___getTypeName"]=a["asm"]["C"]).apply(null,arguments)};var Bt=a["__embind_initialize_bindings"]=function(){return(Bt=a["__embind_initialize_bindings"]=a["asm"]["D"]).apply(null,arguments)};var Ht=a["dynCall_ijiii"]=function(){return(Ht=a["dynCall_ijiii"]=a["asm"]["E"]).apply(null,arguments)};var N;g=function e(){if(!N)Wt();if(!N)g=e};function Wt(e){e=e||U;if(i>0){return}ce();if(i>0){return}function t(){if(N)return;N=true;a["calledRun"]=true;if(Z)return;de();F(a);if(a["onRuntimeInitialized"])a["onRuntimeInitialized"]();he()}if(a["setStatus"]){a["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){a["setStatus"]("")},1);t()},1)}else{t()}}if(a["preInit"]){if(typeof a["preInit"]=="function")a["preInit"]=[a["preInit"]];while(a["preInit"].length>0){a["preInit"].pop()()}}Wt();return a.ready}}();var t=e;r.default=t;e.createFile=v;function v(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:256;var n=0;var i=0;var o=new Uint8Array(e);return{contents:function e(){return o.slice(0,i)},seek:function e(t){n=t},write:function e(t){var r=t.byteLength;a(n+r);o.set(t,n);n+=r;i=Math.max(i,n);return r}};function a(e){var t=o.length;if(t>=e)return;var r=1024*1024;e=Math.max(e,t*(t<r?2:1.125)>>>0);if(t!=0)e=Math.max(e,256);var n=o;o=new Uint8Array(e);if(i>0)o.set(n.subarray(0,i),0)}}function zt(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var t=e.width,r=e.height,n=e.fps,o=n===void 0?30:n,a=e.fragmentation,s=a===void 0?false:a,u=e.sequential,f=u===void 0?false:u,l=e.hevc,c=l===void 0?false:l;if(typeof t!=="number"||typeof r!=="number"){throw new Error("Must specify { width, height } options")}if(!isFinite(t)||t<0||!isFinite(r)||r<0){throw new Error("{ width, height } options must be positive integers")}var d=v();var h=i.create_muxer({width:t,height:r,fps:o,fragmentation:s,sequential:f,hevc:c},p);return{end:function e(){i.finalize_muxer(h);return d.contents()},addNalu:function e(t){var r=i._malloc(t.byteLength);i.HEAPU8.set(t,r);i.mux_nal(h,r,t.byteLength);i._free(r)}};function p(e,t,r){d.seek(r);var n=i.HEAPU8.subarray(e,e+t);return d.write(n)!==n.byteLength}}}).call(this)}).call(this,e("_process"))},{_process:2}],18:[function(e,t,r){"use strict";if(typeof ArrayBuffer!=="undefined"&&!ArrayBuffer.prototype.slice){ArrayBuffer.prototype.slice=function(e,t){var r=new Uint8Array(this);if(t===undefined){t=r.length}var n=new ArrayBuffer(t-e);var i=new Uint8Array(n);for(var o=0;o<i.length;o++){i[o]=r[o+e]}return n}}},{}],19:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;function n(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function o(e,t,r){if(t)i(e.prototype,t);if(r)i(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}var a=function(){function t(e){n(this,t);if(e&&e.xhrSetup){this.xhrSetup=e.xhrSetup}}o(t,[{key:"destroy",value:function e(){this.abort();this.loader=null}},{key:"abort",value:function e(){var t=this.loader;if(t&&t.readyState!==4){this.stats.aborted=true;t.abort()}window.clearTimeout(this.requestTimeout);this.requestTimeout=null;window.clearTimeout(this.retryTimeout);this.retryTimeout=null}},{key:"loadHead",value:function e(t,r,n){this.context=t;this.config=r;this.callbacks=n;this.stats={trequest:performance.now(),retry:0};this.retryDelay=r.retryDelay;var i=new XMLHttpRequest;i.open("head",t.url);i.onload=function(){n.onSuccess(i.getResponseHeader("content-length"))};i.send()}},{key:"load",value:function e(t,r,n){this.context=t;this.config=r;this.callbacks=n;this.stats={trequest:performance.now(),retry:0};this.retryDelay=r.retryDelay;this.loadInternal()}},{key:"loadInternal",value:function e(){var t,r=this.context;if(typeof XDomainRequest!=="undefined"){t=this.loader=new XDomainRequest}else{t=this.loader=new XMLHttpRequest}t.onloadend=this.loadend.bind(this);t.onprogress=this.loadprogress.bind(this);t.open("GET",r.url,true);if(r.rangeEnd){t.setRequestHeader("Range","bytes="+r.rangeStart+"-"+(r.rangeEnd-1))}t.responseType=r.responseType;var n=this.stats;n.tfirst=0;n.loaded=0;if(this.xhrSetup){this.xhrSetup(t,r.url)}this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout);t.send()}},{key:"loadend",value:function e(t){var r=t.currentTarget,n=r.status,i=this.stats,o=this.context,a=this.config;if(i.aborted){return}window.clearTimeout(this.requestTimeout);if(n>=200&&n<300){i.tload=Math.max(i.tfirst,performance.now());var s,u;if(o.responseType==="arraybuffer"){s=r.response;u=s.byteLength}else{s=r.responseText;u=s.length}i.loaded=i.total=u;var f={url:r.responseURL,data:s};this.callbacks.onSuccess(f,i,o)}else{if(i.retry>=a.maxRetry||n>=400&&n<499){this.callbacks.onError({code:n,text:r.statusText},o)}else{this.destroy();this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay);this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay);i.retry++}}}},{key:"loadtimeout",value:function e(){this.callbacks.onTimeout(this.stats,this.context)}},{key:"loadprogress",value:function e(t){var r=this.stats;if(r.tfirst===0){r.tfirst=Math.max(performance.now(),r.trequest)}r.loaded=t.loaded;if(t.lengthComputable){r.total=t.total}var n=this.callbacks.onProgress;if(n){n(r,this.context,null)}}}]);return t}();var s=a;r.default=s},{}],20:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.default=void 0;var i=e("./errors");var s=c(e("./events"));var a=c(e("./controller/flow-controller"));var u=c(e("./controller/buffer-controller"));var f=c(e("events"));var o=c(e("./utils/xhr-loader"));var n=c(e("./loader/file-loader"));var l=c(e("./loader/websocket-loader"));function c(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function p(e,t,r){if(t)h(e.prototype,t);if(r)h(e,r);Object.defineProperty(e,"prototype",{writable:false});return e}var v=function(){function n(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};d(this,n);var t=n.DefaultConfig;for(var r in t){if(r in e){continue}e[r]=t[r]}this.config=e;var o=this.observer=new f.default;o.trigger=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++){n[i-1]=arguments[i]}o.emit.apply(o,[t,t].concat(n))};o.off=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++){n[i-1]=arguments[i]}o.removeListener.apply(o,[t].concat(n))};this.on=o.on.bind(o);this.off=o.off.bind(o);this.trigger=o.trigger.bind(o);this.flowController=new a.default(this);this.bufferController=new u.default(this);this.websocketLoader=new l.default(this);this.mediaType=undefined;this.extraData=undefined}p(n,[{key:"destroy",value:function e(){console.log("wfs destroy +++");this.flowController.destroy();this.bufferController.destroy();this.websocketLoader.destroy();console.log("wfs destroy ---")}},{key:"attachMedia",value:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"chX";var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"H264Raw";var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:"play2";var o=arguments.length>4&&arguments[4]!==undefined?arguments[4]:undefined;this.mediaType=n;this.media=t;this.extraData=o;var a=undefined;switch(n){case"MJPEG":a=s.default.MEDIA_ATTACHED;break;case"H264Raw":default:a=s.default.MEDIA_ATTACHING;break}this.trigger(a,{media:t,channelName:r,mediaType:n,websocketName:i,extraData:this.extraData})}},{key:"attachWebsocket",value:function e(t,r,n){this.trigger(s.default.WEBSOCKET_ATTACHING,{websocket:t,websocketName:r,media:this.media,mediaType:this.mediaType,channelName:n,extraData:this.extraData})}},{key:"start_recording",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1*(1024*1024*1024);var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:undefined;var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:undefined;this.trigger(s.default.RECORDING_START,{rec_file_threshold:t,result_cb:r,state_cb:n})}},{key:"playerSeekNow",value:function e(){this.trigger(s.default.PLAYER_SEEK_NOW)}},{key:"stop_recording",value:function e(){this.trigger(s.default.RECORDING_STOP)}}],[{key:"version",get:function e(){return""+"v.0.0.0.1"}},{key:"isSupported",value:function e(){return window.MediaSource&&typeof window.MediaSource.isTypeSupported==="function"&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42c01f,mp4a.40.2"')}},{key:"Events",get:function e(){return s.default}},{key:"ErrorTypes",get:function e(){return i.ErrorTypes}},{key:"ErrorDetails",get:function e(){return i.ErrorDetails}},{key:"DefaultConfig",get:function e(){if(!n.defaultConfig){n.defaultConfig={autoStartLoad:true,startPosition:-1,debug:false,fLoader:undefined,loader:o.default,fmp4FileUrl:"xxxx.mp4",fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,fragLoadingLoopThreshold:3,forceKeyFrameOnDiscontinuity:true,appendErrorMaxRetry:3,wsMinPacketInterval:3e3,wsMaxPacketInterval:3e4,mp4Duration:1e3}}return n.defaultConfig},set:function e(t){n.defaultConfig=t}}]);return n}();var y=v;r.default=y},{"./controller/buffer-controller":3,"./controller/flow-controller":4,"./errors":7,"./events":9,"./loader/file-loader":12,"./loader/websocket-loader":13,"./utils/xhr-loader":19,events:1}]},{},[11])(11)});
|