trtc-sdk-v5 5.15.0-beta.2 → 5.15.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).LEBPlayer=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function r(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function c(e){t(a,o,i,c,s,"next",e)}function s(e){t(a,o,i,c,s,"throw",e)}c(void 0)}))}}function n(e,t,r){return t=s(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,r||[],s(e).constructor):t.apply(e,r))}function o(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||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,v(n.key),n)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=m(e))||t){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function f(){f=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:_(e,r,c)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var p="suspendedStart",h="suspendedYield",v="executing",y="completed",m={};function g(){}function w(){}function b(){}var S={};u(S,a,(function(){return this}));var k=Object.getPrototypeOf,P=k&&k(k(L([])));P&&P!==r&&n.call(P,a)&&(S=P);var E=b.prototype=g.prototype=Object.create(S);function R(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function r(o,i,a,c){var s=d(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function _(t,r,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=T(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=d(t,r,n);if("normal"===u.type){if(o=n.done?y:h,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function T(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,T(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=d(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function D(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 O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return w.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},R(x.prototype),u(x.prototype,c,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t);else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function y(e){return y="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},y(e)}function m(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}function g(e){var t="function"==typeof Map?new Map:void 0;return g=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(l())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&d(o,r.prototype),o}(e,arguments,s(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},g(e)}var w,b,S=Object.create,k=Object.defineProperty,P=Object.getOwnPropertyDescriptor,E=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,x=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,D=function(e,t,r){return t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},O=function(e,t){for(var r in t||(t={}))_.call(t,r)&&D(e,r,t[r]);if(R){var n,o=c(R(t));try{for(o.s();!(n=o.n()).done;){r=n.value;T.call(t,r)&&D(e,r,t[r])}}catch(e){o.e(e)}finally{o.f()}}return e},I=function(e,t,r,n){for(var o,i=P(t,r),a=e.length-1;a>=0;a--)(o=e[a])&&(i=o(t,r,i)||i);return i&&k(t,r,i),i},L=function(e,t,r){return D(e,"symbol"!==y(t)?t+"":t,r)},A=(w={"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js":function(e,t){var r=Object.prototype.hasOwnProperty,n="~";function o(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new i(r,o||e,a),s=n?n+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],c]:e._events[s].push(c):(e._events[s]=c,e._eventsCount++),e}function c(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function s(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,i,a){var c=n?n+e:e;if(!this._events[c])return!1;var s,u,l=this._events[c],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,i),!0;case 6:return l.fn.call(l.context,t,r,o,i,a),!0}for(u=1,s=new Array(f-1);u<f;u++)s[u-1]=arguments[u];l.fn.apply(l.context,s)}else{var d,p=l.length;for(u=0;u<p;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),f){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,o);break;default:if(!s)for(d=1,s=new Array(f-1);d<f;d++)s[d-1]=arguments[d];l[u].fn.apply(l[u].context,s)}}return!0},s.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return c(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||c(this,i);else{for(var s=0,u=[],l=a.length;s<l;s++)(a[s].fn!==t||o&&!a[s].once||r&&a[s].context!==r)&&u.push(a[s]);u.length?this._events[i]=1===u.length?u[0]:u:c(this,i)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&c(this,t)):(this._events=new o,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,void 0!==t&&(t.exports=s)}},function(){return b||(0,w[E(w)[0]])((b={exports:{}}).exports,b),b.exports}),j={name:"option",required:!0,properties:{view:{type:["string",HTMLElement],required:!0},url:{type:"string",required:!0},muted:{type:"boolean",required:!1},volume:{type:"number",required:!1},fillMode:{type:"string",required:!1,values:["contain","cover","fill"]},loggerConfig:{type:"object",required:!0,properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0}}}}},C=function(e){var t=e.split("\r\n"),r=[];t.forEach((function(e){var t=e.toLowerCase();t.includes("a=rtpmap")&&t.includes("h264")&&r.push(e)}));var n=r.map((function(e){var t=/a=rtpmap:(\d+)\s/.exec(e);return t&&t.length>1?t[1]:null})).filter((function(e){return null!==e})),o=[];return t.forEach((function(e){var t=e;if(e.includes("a=fmtp:111")&&(t="".concat(e,";stereo=1")),e.includes("a=fmtp")){var r=/a=fmtp:(\d+)\s/.exec(e);r&&r.length>1&&n.includes(r[1])&&(t="".concat(e,";sps-pps-idr-in-keyframe=1"))}o.push(t)})),function(e){if(!navigator.userAgent.includes("Firefox"))return e;var t=e.split("\r\n"),r=[],n=[];t.forEach((function(e){var t=e.toLowerCase();t.includes("a=rtpmap")&&t.includes("h264")&&r.push(e)})),r.length>1&&n.push.apply(n,h(r.slice(1)));var o=n.map((function(e){var t=/a=rtpmap:(\d+)\s/.exec(e);return t&&t.length>1?t[1]:null})).filter((function(e){return null!==e})),i=[];return t.forEach((function(e){var t=e;if(e.includes("a=setup")&&(t="a=setup:passive"),(e.includes("m=audio")||e.includes("m=video"))&&(t=e.split(" ").filter((function(e,t){return t<3||!o.includes(e)})).join(" ")),e.includes("a=fmtp")||e.includes("a=rtcp-fb")||e.includes("a=rtpmap")){var r=/a=(?:fmtp|rtcp-fb|rtpmap):(\d+)\s/.exec(e);if(r&&r.length>1&&o.includes(r[1]))return}i.push(t)})),i.join("\r\n")}(o.join("\r\n"))},M=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,t="",r=crypto.getRandomValues(new Uint8Array(e|=0));e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&r[e]];return t},N=function(e){return"function"==typeof e};var F=function(e){var t=e.retryFunction,n=e.settings,o=e.onError,i=e.onRetrying,a=e.onRetryFailed,c=e.onRetrySuccess,s=e.context;return function(){for(var e=this,u=arguments.length,l=new Array(u),d=0;d<u;d++)l[d]=arguments[d];var p=n.retries,h=void 0===p?5:p,v=n.timeout,y=void 0===v?1e3:v,m=0,g=-1,w=0,b=function(){var n=r(f().mark((function r(n,u){var d,p,v,S;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return d=s||e,r.prev=1,r.next=4,t.apply(d,l);case 4:p=r.sent,m>0&&c&&c.call(e,m),m=0,n(p),r.next=15;break;case 10:r.prev=10,r.t0=r.catch(1),v=function(){clearTimeout(g),m=0,w=2,u(r.t0)},S=function(){2!==w&&m<(N(h)?h():h)?(m++,w=1,N(i)&&i.call(e,m,v),g=window.setTimeout((function(){g=-1,b(n,u)}),N(y)?y(m):y)):(v(),N(a)&&a.call(e,r.t0))},N(o)?o.call(e,{error:r.t0,retry:S,reject:u,retryFuncArgs:l,retriedCount:m}):S();case 15:case"end":return r.stop()}}),r,null,[[1,10]])})));return function(e,t){return n.apply(this,arguments)}}();return new Promise(b)}},B=new WeakMap;var U=function(){return a((function e(t,r){o(this,e),this.core=r,L(this,"peerConnection"),L(this,"audioTransceiver",null),L(this,"videoTransceiver",null),L(this,"timerId",null),L(this,"callback",null),L(this,"previousRawStats",null),L(this,"_prevReportTime",0),L(this,"_prevDecoderImplementation",""),L(this,"_decodeMap",new Map),this.peerConnection=t,this.findTransceivers()}),[{key:"statInterval",get:function(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}},{key:"findTransceivers",value:function(){var e,t=c(this.peerConnection.getTransceivers());try{for(t.s();!(e=t.n()).done;){var r=e.value;if(r.receiver&&r.receiver.track){var n=r.receiver.track;"audio"===n.kind?this.audioTransceiver=r:"video"===n.kind&&(this.videoTransceiver=r)}}}catch(e){t.e(e)}finally{t.f()}}},{key:"start",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3;this.stop(),this.callback=e,this.collectStats(),this.timerId=window.setInterval((function(){t.collectStats()}),r)}},{key:"stop",value:function(){null!==this.timerId&&(clearInterval(this.timerId),this.timerId=null),this.callback=null,this.previousRawStats=null,this._prevReportTime=0}},{key:"collectStats",value:(e=r(f().mark((function e(){var t,r,n,o,i,a,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callback){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.peerConnection.getStats();case 5:t=e.sent,r=new Set(["inbound-rtp","track","candidate-pair","media-source","codec"]),n=[],t.forEach((function(e){return r.has(e.type)&&n.push(e)})),o=Date.now(),i=this.parseAudioStats(n),a=this.parseVideoStats(n),c=this.parseNetworkStats(n),this._prevReportTime=o,this.callback({audio:i,video:a,network:c}),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(2),this.core.log.error("Failed to collect WebRTC stats:",e.t0);case 20:case"end":return e.stop()}}),e,this,[[2,17]])}))),function(){return e.apply(this,arguments)})},{key:"getDifferenceValue",value:function(e,t){if(this.core.utils.isUndefined(e))return t;var r=(t||0)-e;return r<0?0:r}},{key:"parseAudioStats",value:function(e){var t,r,n,o,i,a={bitrate:0,volume:0,packetLossRate:0,jitterBufferDelay:0,bytesReceived:0,packetsReceived:0,packetsLost:0},s=c(e);try{for(s.s();!(i=s.n()).done;){var u=i.value;if("inbound-rtp"===u.type&&("audio"===u.mediaType||"audio"===u.kind)){if(a.bytesReceived=u.bytesReceived||0,a.packetsReceived=u.packetsReceived||0,a.packetsLost=u.packetsLost||0,this.previousRawStats&&this.previousRawStats.audio){var l=this.getDifferenceValue(this.previousRawStats.audio.bytesReceived,a.bytesReceived);a.bitrate=Math.round(8*l/this.statInterval/1e3)}var f=this.getDifferenceValue(null==(t=this.previousRawStats)?void 0:t.audio.packetsLost,a.packetsLost),d=this.getDifferenceValue(null==(r=this.previousRawStats)?void 0:r.audio.packetsReceived,a.packetsReceived)+f;if(d>0&&(a.packetLossRate=Math.round(f/d*100)),this.core.utils.isUndefined(u.audioLevel)||(a.volume=u.audioLevel||0),u.jitterBufferDelay&&u.jitterBufferEmittedCount){var p=u.jitterBufferEmittedCount,h=u.jitterBufferDelay;(null==(n=this.previousRawStats)?void 0:n.audio)&&(p=this.getDifferenceValue(this.previousRawStats.audio.jitterBufferEmittedCount,u.jitterBufferEmittedCount),h=this.getDifferenceValue(this.previousRawStats.audio.jitterBufferDelay,u.jitterBufferDelay)),p>0&&(a.jitterBufferDelay=Math.floor(h/p*1e3)),this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.audio.jitterBufferDelay=u.jitterBufferDelay,this.previousRawStats.audio.jitterBufferEmittedCount=u.jitterBufferEmittedCount}this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.audio.bytesReceived=a.bytesReceived,this.previousRawStats.audio.packetsReceived=a.packetsReceived,this.previousRawStats.audio.packetsLost=a.packetsLost}!this.core.utils.isUndefined(u.audioLevel)&&(null==(o=this.audioTransceiver)?void 0:o.receiver.track)&&u.trackIdentifier===this.audioTransceiver.receiver.track.id&&(a.volume=u.audioLevel||0)}}catch(e){s.e(e)}finally{s.f()}return a}},{key:"parseVideoStats",value:function(e){var t,r,n,o,i,a,s={bitrate:0,frameRate:0,width:0,height:0,packetLossRate:0,jitterBufferDelay:0,bytesReceived:0,packetsReceived:0,packetsLost:0,framesDecoded:0},u=c(e);try{for(u.s();!(a=u.n()).done;){var l=a.value;if("codec"===l.type&&this._decodeMap.set(l.id,l),"inbound-rtp"===l.type&&("video"===l.mediaType||"video"===l.kind)){if(s.bytesReceived=l.bytesReceived||0,s.packetsReceived=l.packetsReceived||0,s.packetsLost=l.packetsLost||0,s.framesDecoded=l.framesDecoded||0,this.core.utils.isUndefined(l.framesPerSecond)||(s.frameRate=Math.round(l.framesPerSecond)),l.decoderImplementation&&this._prevDecoderImplementation!==l.decoderImplementation){var f=this._decodeMap.get(l.codecId),d=(null==(t=null==f?void 0:f.mimeType)?void 0:t.split("/")[1])||"unknown",p=l.powerEfficientDecoder;this.core.log.info("decoderImplementation change to ".concat(l.decoderImplementation,"(").concat(d,") HWDecoder: ").concat(p)),this._prevDecoderImplementation=l.decoderImplementation}if(this.previousRawStats&&this.previousRawStats.video){var h=this.getDifferenceValue(this.previousRawStats.video.bytesReceived,s.bytesReceived);s.bitrate=Math.round(8*h/this.statInterval/1e3)}var v=this.getDifferenceValue(null==(r=this.previousRawStats)?void 0:r.video.packetsLost,s.packetsLost),y=this.getDifferenceValue(null==(n=this.previousRawStats)?void 0:n.video.packetsReceived,s.packetsReceived)+v;if(y>0&&(s.packetLossRate=Math.round(v/y*100)),l.jitterBufferDelay&&l.jitterBufferEmittedCount){var m=l.jitterBufferEmittedCount,g=l.jitterBufferDelay;(null==(o=this.previousRawStats)?void 0:o.video)&&(m=this.getDifferenceValue(this.previousRawStats.video.jitterBufferEmittedCount,l.jitterBufferEmittedCount),g=this.getDifferenceValue(this.previousRawStats.video.jitterBufferDelay,l.jitterBufferDelay)),m>0&&(s.jitterBufferDelay=Math.floor(g/m*1e3)),this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.video.jitterBufferDelay=l.jitterBufferDelay,this.previousRawStats.video.jitterBufferEmittedCount=l.jitterBufferEmittedCount}this.previousRawStats||this.initPreviousRawStats(),this.previousRawStats.video.bytesReceived=s.bytesReceived,this.previousRawStats.video.packetsReceived=s.packetsReceived,this.previousRawStats.video.packetsLost=s.packetsLost}!this.core.utils.isUndefined(l.frameWidth)&&(null==(i=this.videoTransceiver)?void 0:i.receiver.track)&&l.trackIdentifier===this.videoTransceiver.receiver.track.id&&(s.width=l.frameWidth,s.height=l.frameHeight)}}catch(e){u.e(e)}finally{u.f()}return s}},{key:"parseNetworkStats",value:function(e){var t,r={rtt:0},n=c(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;if("candidate-pair"===o.type)if((o.selected||"succeeded"===o.state)&&this.core.utils.isNumber(o.currentRoundTripTime)){r.rtt=Math.floor(1e3*o.currentRoundTripTime);break}}}catch(e){n.e(e)}finally{n.f()}return r}},{key:"initPreviousRawStats",value:function(){this.previousRawStats={timestamp:Date.now(),audio:{bytesReceived:0,packetsReceived:0,packetsLost:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0}}}}]);var e}(),V=function(e,t,r){return r=null!=e?S(x(e)):{},function(e,t,r,n){if(t&&"object"===y(t)||"function"==typeof t){var o,i=c(E(t));try{var a=function(){var i=o.value;_.call(e,i)||i===r||k(e,i,{get:function(){return t[i]},enumerable:!(n=P(t,i))||n.enumerable})};for(i.s();!(o=i.n()).done;)a()}catch(e){i.e(e)}finally{i.f()}}return e}(k(r,"default",{value:e,enumerable:!0}),e)}(A()),W=Symbol("instance"),q=Symbol("cacheResult"),G=function(){return a((function e(t,r,n){o(this,e),this.oldState=t,this.newState=r,this.action=n,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,Q.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),H=function(e){function t(e,r,i){var a;return o(this,t),(a=n(this,t,[r])).state=e,a.message=r,a.cause=i,a}return u(t,e),a(t)}(g(Error));var Y=new Map;function J(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n,o,i){var a=r.action||o;if(!r.context){var c=Y.get(n)||[];Y.has(n)||Y.set(n,c),c.push({from:e,to:t,action:a})}var s=i.value;i.value=function(){for(var n,o=this,i=this,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];r.context&&(i=X.get("function"==typeof r.context?(n=r.context).call.apply(n,[this].concat(u)):r.context));if(i.state===t)return r.sync?i[q]:Promise.resolve(i[q]);i.state instanceof G&&i.state.action==r.abortAction&&i.state.abort(i);var f=null;Array.isArray(e)?0==e.length?i.state instanceof G&&i.state.abort(i):"string"==typeof i.state&&e.includes(i.state)||(f=new H(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(f=new H(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));var d=function(e){if(r.fail&&r.fail.call(o,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(f)return d(f);var p=i.state,h=new G(p,t,a);Q.call(i,h);var v,m=function(e){var n;return i[q]=e,h.aborted||(Q.call(i,t),null===(n=r.success)||void 0===n||n.call(o,i[q])),e},g=function(e){return Q.call(i,p,e),d(e)};try{var w=s.apply(this,u);return"object"===y(v=w)&&v&&"then"in v?w.then(m).catch(g):r.sync?m(w):Promise.resolve(m(w))}catch(r){return g(new H(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(r),r instanceof Error?r:new Error(String(r))))}}}}var z,K,Z=(z="undefined"!=typeof window&&window.__AFSM__,K="undefined"!=typeof importScripts,z?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:K?function(e,t){postMessage({type:e,payload:t})}:function(){});function Q(e,t){var r=this._state;this._state=e;var n=e.toString();e&&this.emit(n,r),this.emit(X.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var X=function(e){function t(e,r,i){var a;o(this,t),(a=n(this,t)).name=e,a.groupName=r,a._state=t.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(a,i):i=Object.getPrototypeOf(a),r||(a.groupName=a.constructor.name);var c=i[W];return c?a.name=c.name+"-"+c.count++:i[W]={name:a.name,count:0},a.updateDevTools({diagram:a.stateDiagram}),a}return u(t,e),a(t,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=Y.get(e)||[],r=new Set,n=[],o=[],i=new Set,a=Object.getPrototypeOf(e);Y.has(a)&&(a.stateDiagram.forEach((function(e){return r.add(e)})),a.allStates.forEach((function(e){return i.add(e)}))),t.forEach((function(e){var t=e.from,r=e.to,i=e.action;"string"==typeof t?n.push({from:t,to:r,action:i}):t.length?t.forEach((function(e){n.push({from:e,to:r,action:i})})):o.push({to:r,action:i})})),n.forEach((function(e){var t=e.from,n=e.to,o=e.action;i.add(t),i.add(n),i.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(n," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((function(e){var t=e.to,n=e.action;r.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🟢")),i.forEach((function(e){e!==t&&r.add("".concat(e," --\x3e ").concat(n,"ing : ").concat(n))}))}));var c=h(r);return Object.defineProperties(e,{stateDiagram:{value:c},allStates:{value:i}}),c}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Z(t.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){Q.call(this,e)}}],[{key:"get",value:function(e){var r;return"string"==typeof e?(r=t.instances.get(e))||t.instances.set(e,r=new t(e,void 0,Object.create(t.prototype))):(r=t.instances2.get(e))||t.instances2.set(e,r=new t(e.constructor.name,void 0,Object.create(t.prototype))),r}},{key:"getState",value:function(e){var r;return null===(r=t.get(e))||void 0===r?void 0:r.state}}])}(V.default);X.STATECHANGED="stateChanged",X.UPDATEAFSM="updateAFSM",X.INIT="[*]",X.ON="on",X.OFF="off",X.instances=new Map,X.instances2=new WeakMap;var $=function(e){function t(e,r){var i;return o(this,t),(i=n(this,t)).core=e,L(i,"audioPlayer"),L(i,"videoPlayer"),L(i,"callback"),L(i,"_log"),L(i,"lastPausedReason"),L(i,"muted",!1),i._log=r,i.videoPlayer=new e.VideoPlayer({id:"vp",log:i._log.createChild({id:"vp"}),track:null,muted:!1,container:null,enableLogTrackState:!0}),i.audioPlayer=new e.RemoteAudioPlayer({id:"ap",log:i._log.createChild({id:"ap"}),track:null,muted:!1,container:null,enableVolumeControlInIOS:!0,enableLogTrackState:!0}),i.videoPlayer.on("loadstart",(function(){return i.handleLoadStart("video")})),i.audioPlayer.on("loadstart",(function(){return i.handleLoadStart("audio")})),i.videoPlayer.on("player-state-changed",i.handlePlayerStateChanged,i),i.audioPlayer.on("player-state-changed",i.handlePlayerStateChanged,i),i}return u(t,e),a(t,[{key:"isPlaying",get:function(){return this.videoPlayer.isPlaying&&this.audioPlayer.isPlaying}},{key:"isPaused",get:function(){return this.videoPlayer.isPaused&&this.audioPlayer.isPaused}},{key:"isStopped",get:function(){return this.videoPlayer.isStopped&&this.audioPlayer.isStopped}},{key:"setCallback",value:function(e){this.callback=e}},{key:"handleLoadStart",value:function(e){this.onLoadStart()}},{key:"handlePlayerStateChanged",value:function(e){"PLAYING"===e.state&&this.isPlaying&&this.onPlaying(),"PAUSED"===e.state&&this.isPaused&&this.onPaused(e.reason),"STOPPED"===e.state&&this.isStopped&&this.onStopped()}},{key:"onLoadStart",value:function(){}},{key:"onPlaying",value:function(){}},{key:"onPaused",value:function(e){this.lastPausedReason=e}},{key:"onStopped",value:function(){}},{key:"setVideoContainer",value:function(e){if(this.core.utils.isString(e)){var t=document.getElementById(e);t&&this.videoPlayer.setContainer(t)}else this.videoPlayer.setContainer(e)}},{key:"setVolume",value:function(e){this.core.utils.isUndefined(e)||this.audioPlayer.setVolume(e/100)}},{key:"setMuted",value:function(e){this.core.utils.isUndefined(e)||(this.muted=e,this.audioPlayer.setMuted(e))}},{key:"setFillMode",value:function(e){e&&this.videoPlayer.setObjectFit(e)}},{key:"setAudioTrack",value:function(e){this.audioPlayer.setTrack(e)}},{key:"setVideoTrack",value:function(e){this.videoPlayer.setTrack(e)}},{key:"play",value:(d=r(f().mark((function e(){var t,r,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.videoPlayer.play().catch((function(e){var t,r;n.handleAutoPlayFailed(n.videoPlayer,e),null==(r=null==(t=n.callback)?void 0:t.onAutoPlayFailed)||r.call(t,{type:"video",resume:function(){return n.videoPlayer.resume()}})})),r=this.audioPlayer.play().catch((function(e){var t,r;n.handleAutoPlayFailed(n.audioPlayer,e),null==(r=null==(t=n.callback)?void 0:t.onAutoPlayFailed)||r.call(t,{type:"audio",resume:function(){return n.audioPlayer.resume()}})})),e.next=4,Promise.all([t,r]);case 4:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"handleAutoPlayFailed",value:function(e,t){var r=this;this._log.warn("handleAutoPlayFailed",t);var n=function(){r.audioPlayer.resume().then((function(){document.removeEventListener("click",n,!0)}))};document.addEventListener("click",n,!0)}},{key:"pause",value:function(){this.videoPlayer.pause(!1),this.audioPlayer.setMuted(!0),this.audioPlayer.pause()}},{key:"resume",value:function(){this.videoPlayer.resume(!0),this.audioPlayer.setMuted(this.muted),this.audioPlayer.resume()}},{key:"enterFullscreen",value:(l=r(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.videoPlayer.enterFullscreen();case 2:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"exitFullscreen",value:(s=r(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.videoPlayer.exitFullscreen();case 2:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"enterPictureInPicture",value:(c=r(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.videoPlayer.enterPictureInPicture();case 2:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"exitPictureInPicture",value:(i=r(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.videoPlayer.exitPictureInPicture();case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"stop",value:function(){this.videoPlayer&&this.videoPlayer.stop(),this.audioPlayer&&this.audioPlayer.stop()}}]);var i,c,s,l,d}(X);I([J([X.INIT,"PAUSED"],"LOADSTART",{ignoreError:!0,sync:!0,success:function(){var e,t;null==(t=null==(e=this.callback)?void 0:e.onLoadStart)||t.call(e)},fail:function(e){this._log.warn("onLoadStart",e)}})],$.prototype,"onLoadStart"),I([J(["LOADSTART","PAUSED"],"PLAYING",{ignoreError:!0,sync:!0,success:function(){var e,t;null==(t=null==(e=this.callback)?void 0:e.onPlaying)||t.call(e)},fail:function(e){this._log.warn("onPlaying",e)}})],$.prototype,"onPlaying"),I([J("PLAYING","PAUSED",{ignoreError:!0,sync:!0,success:function(){var e,t;null==(t=null==(e=this.callback)?void 0:e.onPaused)||t.call(e,{reason:this.lastPausedReason})},fail:function(e){this._log.warn("onPaused",e)}})],$.prototype,"onPaused"),I([J([],X.INIT,{ignoreError:!0,sync:!0,success:function(){var e,t;null==(t=null==(e=this.callback)?void 0:e.onStopped)||t.call(e)},fail:function(e){this._log.warn("onStopped",e)}})],$.prototype,"onStopped");var ee,te,re,ne,oe,ie,ae,ce,se,ue,le,fe=$,de=["overseas-webrtc.tlivewebrtc.com","oswebrtc-lint.tliveplay.com"],pe=function(){function e(t){o(this,e),this.core=t,L(this,"connectedRoomIdSet",new Set),L(this,"updateSeq",0),L(this,"_log"),L(this,"player"),L(this,"peerConnection"),L(this,"svrSig"),L(this,"streamURL"),L(this,"signalURL"),L(this,"insertableStreamsAbortMap",new Map),L(this,"scriptTransformWorker"),L(this,"connectionState","disconnected"),L(this,"isStarted",!1),L(this,"isStopped",!0),L(this,"isReconnecting",!1),L(this,"callback"),L(this,"isFireWallErrorEmitted",!1),L(this,"stat"),L(this,"isH264DecodeSupported"),L(this,"connectionTimeoutId"),t.loggerManager.startUpload(),this._log=this.core.log.createChild({id:"".concat(this.getAlias())}),this.player=new fe(t,this._log),t.innerEmitter.on(t.INNER_EVENT.SEI_MESSAGE,this.onSEIMessage,this)}return a(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"LEB"}},{key:"getGroup",value:function(){return""}},{key:"getValidateRule",value:function(e){switch(e){case"start":return j;case"update":case"stop":return{}}}},{key:"enableSEI",get:function(){return this.core.room.enableSEI&&(this.core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED||this.core.rtcDectection.IS_SCRIPT_TRANSFORM_SUPPORTED)}},{key:"start",value:(v=r(f().mark((function e(t){var r,n,o,i,a,c,s,u,l,d,p,h,v,y,m,g=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isStopped=!1,n=t.view,o=t.url,i=t.volume,a=t.muted,c=t.fillMode,s=t.loggerConfig,u=t.callback,this.callback=u,this.player.setCallback(u),l=this.core,d=l.errorModule,p=d.RtcError,h=d.ErrorCode,v=d.ErrorCodeDictionary,y=l.loggerManager,m=l.rtcDectection,this._log.setSdkAppId(s.sdkAppId),this._log.setUserId(s.userId),y.addJoinedUser(s),m.isWebRTCSupported()&&m.isAddTransceiverSupported()){e.next=10;break}throw new p({code:h.ENV_NOT_SUPPORTED,extraCode:v.NOT_SUPPORTED_WEBRTC,message:"webrtc not supported"});case 10:return e.next=12,m.decodeSupportStatus();case 12:if(e.t0=!e.sent.isH264DecodeSupported,e.t0){e.next=15;break}e.t0=!1===this.isH264DecodeSupported;case 15:if(!e.t0){e.next=18;break}throw this.isH264DecodeSupported=!1,new p({code:h.ENV_NOT_SUPPORTED,extraCode:v.NOT_SUPPORTED_H264_DECODE,message:"h264 not supported"});case 18:return!m.IS_SEI_SUPPORTED&&(null==u?void 0:u.onSEIMessage)&&(null==(r=u.onError)||r.call(u,new p({code:h.ENV_NOT_SUPPORTED,extraCode:v.NOT_SUPPORTED_SEI,message:"sei not supported"}))),this.player.setVideoContainer(n),this.player.setMuted(a),this.player.setVolume(i),this.player.setFillMode(c),e.next=25,this.connect(o);case 25:return this.stat=new U(this.peerConnection,this.core),this.stat.start((function(e){var t,r;return null==(r=null==(t=g.callback)?void 0:t.onStats)?void 0:r.call(t,e)})),e.next=29,this.player.play();case 29:this.isStarted=!0;case 30:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"connect",value:function(e){var t=this;return new Promise((function(r,n){try{t.initScriptTransformWorker();var o={encodedInsertableStreams:t.enableSEI,iceServers:[],sdpSemantics:"unified-plan",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"},i=new RTCPeerConnection(o);t.peerConnection=i,i.onconnectionstatechange=function(){t.connectionState=i.connectionState,t._log.info("connectionState",i.connectionState),"failed"!==i.connectionState&&"closed"!==i.connectionState||(t.isStarted?t.reconnect(e):n(new Error("connection is ".concat(i.connectionState)))),"connected"===i.connectionState&&(t.logSelectedCandidate(),r())},i.ontrack=function(e){return t.onTrack(e)},i.addTransceiver("audio",{direction:"recvonly"}),i.addTransceiver("video",{direction:"recvonly"}),t._log.info("createOffer"),i.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1}).then((function(e){return e.sdp=C(e.sdp),t._log.info("setOffer"),i.setLocalDescription(e)})).then((function(){var r={sessionId:M(),streamurl:e,clientinfo:t.core.environment.getOSString(),localsdp:i.localDescription};return t.exchangeSDP(e,r)})).then((function(e){return t._log.info("setAnswer"),i.setRemoteDescription(e)})).catch(n)}catch(e){n(e)}t.connectionTimeoutId=setTimeout((function(){return n(new Error("connection timeout"))}),1e4)}))}},{key:"exchangeSDP",value:(h=r(f().mark((function e(t,r){var n,o,i,a,c,s,u,l,d,p=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this._log.info("exchangeSDP"),a=ge(t)){e.next=5;break}throw new Error("streamDomain is empty");case 5:return e.next=7,this.fetchSignalDomain(a);case 7:if(c=e.sent,s=c.signalDomain,u=c.cached,!s){e.next=20;break}return this._log.info("try exchangeSDP signalDomain:",s,u),e.next=14,this.doExchangeSDP("https://".concat(s),r,3);case 14:l=e.sent,n=l.url,o=l.remoteSdp,i=l.svrSig,e.next=21;break;case 20:throw new Error("signalDomain is empty");case 21:e.next=32;break;case 23:return e.prev=23,e.t0=e.catch(0),this._log.warn("exchangeSDP failed, fallback",e.t0),e.next=28,this.core.utils.promiseAny(de.map((function(e){return p.doExchangeSDP("https://".concat(e),r,3)})));case 28:d=e.sent,n=d.url,o=d.remoteSdp,i=d.svrSig;case 32:return this.streamURL=t,this.signalURL=n,this.svrSig=i,e.abrupt("return",o);case 36:case"end":return e.stop()}}),e,this,[[0,23]])}))),function(e,t){return h.apply(this,arguments)})},{key:"reconnect",value:(d=r(f().mark((function e(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isReconnecting){e.next=2;break}return e.abrupt("return");case 2:return this.isReconnecting=!0,e.prev=3,this._log.warn("start reconnect"),e.next=7,this.connect(t);case 7:this._log.warn("reconnect success"),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(3),this._log.error("reconnect error",e.t0);case 13:return e.prev=13,this.isReconnecting=!1,e.finish(13);case 16:case"end":return e.stop()}}),e,this,[[3,10,13,16]])}))),function(e){return d.apply(this,arguments)})},{key:"logSelectedCandidate",value:(l=r(f().mark((function e(){var t,r,n,o,i,a,s;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.peerConnection){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.peerConnection.getStats();case 4:t=e.sent,r=c(t),e.prev=6,r.s();case 8:if((n=r.n()).done){e.next=18;break}if((o=p(n.value,2))[0],i=o[1],!this.core.rtcDectection.isSelectedCandidatePair(i)){e.next=16;break}return a=t.get(i.localCandidateId),s=t.get(i.remoteCandidateId),a&&this._log.info("local candidate: ".concat(a.candidateType," ").concat(a.protocol,":").concat(a.ip||a.address,":").concat(a.port," ").concat(a.networkType||""," ").concat(a.relayProtocol?"relayProtocol:".concat(a.relayProtocol," url: ").concat(a.url):"")),s&&this._log.info("remote candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port)),e.abrupt("break",18);case 16:e.next=8;break;case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(6),r.e(e.t0);case 23:return e.prev=23,r.f(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[6,20,23,26]])}))),function(){return l.apply(this,arguments)})},{key:"doExchangeSDP",value:(u=r(f().mark((function e(t,r,n){var o,i,a,c,s,u,l;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o="".concat(t,"/webrtc/v1/pullstream"),e.next=3,ve(o,r,{timeout:n});case 3:if(i=e.sent,a=i.errcode,c=i.errmsg,s=i.remotesdp,u=i.svrsig,0===a){e.next=9;break}throw(l=new Error("errCode:".concat(a,", errMsg:").concat(c))).name="RequestSignalError",l;case 9:return e.abrupt("return",{url:t,remoteSdp:s,svrSig:u});case 10:case"end":return e.stop()}}),e)}))),function(e,t,r){return u.apply(this,arguments)})},{key:"createEncodedStreams",value:function(e){var t,r=this;if(this.enableSEI&&this.core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED)try{if(this._log.warn("enableSEI",this.enableSEI),!this.insertableStreamsAbortMap.has(e)){var n=e.createEncodedStreams(),o=new AbortController,i={abortController:o,enqueue:function(t){return"audio"===e.track.kind?t:r.decodeVideoFrame(t)}};n.readable.pipeThrough(new TransformStream({transform:function(e,t){var r=i.enqueue(e);r&&t.enqueue(r)}})).pipeTo(n.writable,o).catch((function(e){"destroy"!==e&&r._log.warn(e)})),null==(t=this.insertableStreamsAbortMap.get(e))||t.abort("destroy"),this.insertableStreamsAbortMap.set(e,o)}}catch(t){this._log.warn("createEncodedStreams ".concat(e.track.kind," failed"),t)}}},{key:"initReceiverTransform",value:function(e,t){this.peerConnection&&this.enableSEI&&this.scriptTransformWorker&&!e.transform&&(e.transform=new RTCRtpScriptTransform(this.scriptTransformWorker,{isReceiver:!0,isAudio:t,userId:"",streamType:this.core.enums.RemoteStreamType.Main}))}},{key:"initScriptTransformWorker",value:function(){var e=this,t=this.core,r=t.room,n=t.rtcDectection,o=t.createScriptTransformWorker;t.trtc,t.TRTC,!this.enableSEI||n.IS_INSERTABLE_STREAM_SUPPORTED||this.scriptTransformWorker||n.IS_SCRIPT_TRANSFORM_SUPPORTED&&(this._log.info("initScriptTransformWorker"),this.scriptTransformWorker=o({videoEncodePipeline:r.videoManager.encodePipeline,videoDecodePipeline:r.videoManager.decodePipeline,audioEncodePipeline:r.audioManager.encodePipeline,audioDecodePipeline:r.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=function(t){var r,n;"sei"===t.data.type&&(null==(n=null==(r=e.callback)?void 0:r.onSEIMessage)||n.call(r,{data:t.data.data,seiPayloadType:t.data.seiPayloadType}))},this.scriptTransformWorker.onerror=function(t){e._log.error("scriptTransformWorker error: ",t.message)})}},{key:"decodeVideoFrame",value:function(e){if(!this.core.room.videoManager)return e;var t,r=c(this.core.room.videoManager.decodePipeline);try{for(r.s();!(t=r.n()).done;){var n=t.value;if(n&&!(e=n({frame:e})))return}}catch(e){r.e(e)}finally{r.f()}return e}},{key:"fetchStopStream",value:(s=r(f().mark((function e(){var t,r,n,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.streamURL&&this.svrSig&&this.signalURL){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,t="".concat(this.signalURL,"/webrtc/v1/stopstream"),e.next=6,ve(t,{streamurl:this.streamURL,svrsig:this.svrSig},{timeout:3});case 6:if(r=e.sent,n=r.errcode,o=r.errmsg,0===n){e.next=10;break}throw new Error("errCode:".concat(n,", errmsg:").concat(o));case 10:return e.abrupt("return",r);case 13:e.prev=13,e.t0=e.catch(2),this._log.error("fetchStopStream error",e.t0);case 16:case"end":return e.stop()}}),e,this,[[2,13]])}))),function(){return s.apply(this,arguments)})},{key:"onTrack",value:function(e){var t=e.track;this.createEncodedStreams(e.receiver),this.initReceiverTransform(e.receiver,"audio"===t.kind),"audio"===t.kind?this.player.setAudioTrack(t):this.player.setVideoTrack(t)}},{key:"update",value:(i=r(f().mark((function e(t){var r,n,o,i,a,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.volume,n=t.muted,o=t.fillMode,i=t.action,a=t.fullScreen,c=t.pictureInPicture,this.player.setMuted(n),this.player.setVolume(r),this.player.setFillMode(o),"pause"===i?this.player.pause():"resume"===i&&this.player.resume(),!this.core.utils.isBoolean(a)){e.next=13;break}if(!a){e.next=11;break}return e.next=9,this.player.enterFullscreen();case 9:e.next=13;break;case 11:return e.next=13,this.player.exitFullscreen();case 13:if(!this.core.utils.isBoolean(c)){e.next=21;break}if(!c){e.next=19;break}return e.next=17,this.player.enterPictureInPicture();case 17:e.next=21;break;case 19:return e.next=21,this.player.exitPictureInPicture();case 21:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"stop",value:(n=r(f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isStopped=!0,this.player.stop(),!this.peerConnection){e.next=12;break}return clearTimeout(this.connectionTimeoutId),this.peerConnection.close(),this.peerConnection.getReceivers().forEach((function(e){return t.insertableStreamsAbortMap.delete(e)})),delete this.peerConnection,e.next=9,this.fetchStopStream();case 9:delete this.streamURL,delete this.signalURL,delete this.svrSig;case 12:this.stat&&(this.stat.stop(),delete this.stat);case 13:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"destroy",value:function(){this.stop(),this.core.innerEmitter.off(this.core.INNER_EVENT.SEI_MESSAGE,this.onSEIMessage,this)}},{key:"onSEIMessage",value:function(e){var t,r,n=e.room,o=e.nalu;n===this.core.room&&(null==(r=null==(t=this.callback)?void 0:t.onSEIMessage)||r.call(t,{data:o.seiPayload.buffer,seiPayloadType:o.seiPayloadType}))}},{key:"fetchSignalDomain",value:(t=r(f().mark((function e(t){var r,n,o,i,a,c,s,u,l,d,p,h=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=h.length>1&&void 0!==h[1]?h[1]:ye[0],n="https://".concat(r,"/signal_query"),e.prev=2,!(o=window.localStorage.getItem(me))){e.next=8;break}if(!((i=JSON.parse(o))[t].expire-(new Date).getTime()>0)){e.next=8;break}return e.abrupt("return",{signalDomain:i[t].signal,cached:!0});case 8:return e.next=10,ve(n,{domain:t,requestid:M(16),client_type:"Web",client_info:window.navigator.userAgent});case 10:if(a=e.sent,c=a.errcode,s=a.data,0!==c){e.next=20;break}u=s.signal_domain,l=s.cache_time,d={},(p=window.localStorage.getItem(me))&&(d=JSON.parse(p)),d[t]={signal:u,expire:(new Date).getTime()+1e3*l};try{window.localStorage.setItem(me,JSON.stringify(d))}catch(e){}return e.abrupt("return",{signalDomain:u,cached:!1});case 20:throw new Error("errCode:".concat(c));case 23:if(e.prev=23,e.t0=e.catch(2),this._log.error("fetchSignalDomain error",e.t0),r===ye[1]){e.next=28;break}return e.abrupt("return",this.fetchSignalDomain(t,ye[1]));case 28:return e.abrupt("return",{signalDomain:"",cached:!1});case 29:case"end":return e.stop()}}),e,this,[[2,23]])}))),function(e){return t.apply(this,arguments)})}]);var t,n,i,s,u,l,d,h,v}();L(pe,"Name","LEBPlayer"),I([(ee={settings:{retries:1/0,timeout:2e3},onRetrying:function(e){var t;if(this._log.warn("retry connect ".concat(e)),e>=3&&(null==(t=this.callback)?void 0:t.onError)&&!this.isFireWallErrorEmitted){var r=this.core.errorModule,n=r.RtcError,o=r.ErrorCode,i=r.ErrorCodeDictionary;this.isFireWallErrorEmitted=!0,this.callback.onError(new n({code:o.OPERATION_FAILED,extraCode:i.FIREWALL_RESTRICTION,message:"firewall restriction"}))}},onError:function(e,t,r,n){var o;if(this._log.warn("connect failed",e),this.peerConnection&&(this.peerConnection.close(),delete this.peerConnection),!this.isStopped&&(null==(o=e.message||e)?void 0:o.includes("connection")))t();else{var i=this.core.errorModule;r(new(0,i.RtcError)({code:i.ErrorCode.UNKNOWN_ERROR,message:e.message}))}}},te=ee.settings,re=void 0===te?{retries:5,timeout:2e3}:te,ne=ee.onError,oe=ee.onRetrying,ie=ee.onRetryFailed,function(e,t,r){var n=F({retryFunction:r.value,settings:re,onError:function(r){var n,o=r.error,i=r.retry,a=r.reject,c=r.retryFuncArgs;ne?ne.call(this,o,(function(){var r;(null==(r=B.get(e))?void 0:r.has(t))?i():a(o)}),a,c):(null==(n=B.get(e))?void 0:n.has(t))?i():a(o)},onRetrying:function(r,n){var o;N(oe)&&oe.call(this,r,n),(null==(o=B.get(e))?void 0:o.has(t))&&(B.get(e).get(t).stopRetry=n)},onRetryFailed:ie});return r.value=function(){for(var r=B.get(e),o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return r?r.set(t,{args:i}):B.set(e,new Map([[t,{args:i}]])),n.apply(this,i).finally((function(){var r;return null==(r=B.get(e))?void 0:r.delete(t)}))},r})],pe.prototype,"connect"),I([(ae={fnName:"connect"},ce=ae.fnName,se=ae.callback,ue=ae.validateArgs,le=void 0===ue||ue,function(e,t,r){var n=r.value;return r.value=function(){for(var t,r,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];if(null==(t=B.get(e))?void 0:t.has(ce)){var s=B.get(e).get(ce),u=s.stopRetry,l=s.args,f=!0;if(le){var d,p=c(l);try{var h=function(){var e=d.value;if(!i.find((function(t){return t===e})))return f=!1,1};for(p.s();!(d=p.n()).done&&!h(););}catch(e){p.e(e)}finally{p.f()}}f&&(se&&se.apply(this,i),u&&u(),null==(r=B.get(e))||r.delete(ce))}return n.apply(this,i)},r})],pe.prototype,"stop");var he=pe,ve=function(){var e=r(f().mark((function e(t,r){var n,o,i,a,c,s,u=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(u.length>2&&void 0!==u[2]?u[2]:{}).timeout,o=void 0===n?10:n,a=0,c={},window.AbortController&&(i=new window.AbortController,c={signal:i.signal},a=window.setTimeout((function(){return i.abort()}),1e3*o)),e.next=7,fetch(t,O({body:JSON.stringify(r),cache:"no-cache",credentials:"same-origin",headers:{"content-type":"text/plain;charset=utf-8"},method:"POST",mode:"cors"},c));case 7:if(s=e.sent,a&&window.clearTimeout(a),200===s.status){e.next=11;break}throw new Error("Network Error, status code:".concat(s.status));case 11:return e.abrupt("return",s.json());case 12:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),ye=["webrtc-signal-scheduler.tlivesource.com","bak-webrtc-signal-scheduler.tlivesource.com"],me="LEB_PLAYER_STORAGE_KEY",ge=function(e){var t=/^(?:webrtc:\/\/)([0-9.\-A-Za-z_]+)(?:\/)(?:[0-9.\-A-Za-z_=]+)(?:\/)(?:[^?#]*)(?:\?*)(?:[^?#]*)/.exec(e);return t?t[1]:""};return he}));
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@rtc-plugin/lebplayer",
3
+ "version": "5.15.0-beta.3",
4
+ "description": "TRTC Web SDK 5.x LEBPlayer plugin",
5
+ "main": "./lebplayer.esm.js",
6
+ "module": "./lebplayer.esm.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git@github.com:LiteAVSDK/TRTC_Web.git"
10
+ },
11
+ "homepage": "https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/tutorial-30-advanced-lebplayer-link.html",
12
+ "keywords": [
13
+ "webrtc",
14
+ "TRTC",
15
+ "rtc",
16
+ "call",
17
+ "video call",
18
+ "audio call",
19
+ "javascript",
20
+ "video",
21
+ "audio",
22
+ "camera",
23
+ "microphone",
24
+ "live streaming",
25
+ "real-time communication",
26
+ "lebplayer"
27
+ ],
28
+ "types": "./lebplayer.esm.d.ts"
29
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/small-stream-auto-switcher",
3
- "version": "5.15.0-beta.2",
3
+ "version": "5.15.0-beta.3",
4
4
  "description": "",
5
5
  "main": "./small-stream-auto-switcher.esm.js",
6
6
  "keywords": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-decoder",
3
- "version": "5.15.0-beta.2",
3
+ "version": "5.15.0-beta.3",
4
4
  "description": "Video decoder plugin for TRTC",
5
5
  "main": "./video-decoder.esm.js",
6
6
  "module": "./video-decoder.esm.js",