trtc-sdk-v5 5.14.2-beta.6 → 5.14.2-beta.8

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.
package/index.d.ts CHANGED
@@ -338,6 +338,7 @@ export declare type PluginWithAssets = {
338
338
  export declare interface TRTCOptions {
339
339
  plugins?: Array<TRTCPlugin>;
340
340
  enableSEI?: boolean;
341
+ enableAutoPlayDialog?: boolean;
341
342
  assetsPath?: string;
342
343
  volumeType?: number;
343
344
  enableAutoSwitchWhenRecapturing?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
5
  "main": "trtc.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cdn-streaming",
3
- "version": "5.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
4
4
  "description": "TRTC Web SDK 5.x CDN streaming plugin",
5
5
  "main": "./cdn-streaming.esm.js",
6
6
  "module": "./cdn-streaming.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/chorus",
3
- "version": "5.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
4
4
  "description": "TRTC Web SDK 5.x Chorus plugin",
5
5
  "main": "./chorus.esm.js",
6
6
  "module": "./chorus.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cross-room",
3
- "version": "5.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
4
4
  "description": "TRTC Web SDK 5.x Cross Room plugin",
5
5
  "main": "./cross-room.esm.js",
6
6
  "module": "./cross-room.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/custom-encryption",
3
- "version": "5.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
4
4
  "main": "./custom-encryption.esm.js",
5
5
  "module": "./custom-encryption.esm.js",
6
6
  "types": "./custom-encryption.esm.d.ts"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/device-detector",
3
- "version": "5.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
4
4
  "description": "TRTC Web SDK 5.x device detector plugin",
5
5
  "main": "./device-detector.esm.js",
6
6
  "module": "./device-detector.esm.js",
@@ -0,0 +1,27 @@
1
+ export interface StartCrossRoomOption {
2
+ roomId?: number,
3
+ strRoomId?: string,
4
+ userId?: string
5
+ }
6
+
7
+ interface UpdateCrossRoomOptionItem extends StartCrossRoomOption {
8
+ muteAudio: boolean,
9
+ muteVideo: boolean,
10
+ muteSubStream: boolean,
11
+ }
12
+
13
+ export interface UpdateCrossRoomOption {
14
+ updateList: UpdateCrossRoomOptionItem[]
15
+ }
16
+
17
+ export interface StopCrossRoomOption {
18
+ roomId?: number,
19
+ strRoomId?: string,
20
+ }
21
+
22
+
23
+ export declare class CrossRoom {
24
+ start(option: StartCrossRoomOption): Promise<void>;
25
+ update(option: UpdateCrossRoomOption): Promise<void>;
26
+ stop(option?: StopCrossRoomOption): Promise<void>;
27
+ }
@@ -0,0 +1 @@
1
+ var __defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__publicField=(e,t,r)=>__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),StartValidateRule={name:"option",required:!0,properties:{view:{type:["string",HTMLElement],required:!0},url:{type:"string",required:!0},licenseConfig:{type:"object",required:!0,properties:{secretKey:{type:"string",required:!0},encrypted:{type:"string",required:!0},signature:{type:"string",required:!0}}}}},updateSdpForFirefox=e=>{if(!navigator.userAgent.includes("Firefox"))return e;const t=e.split("\r\n"),r=[],o=[];t.forEach((e=>{const t=e.toLowerCase();t.includes("a=rtpmap")&&t.includes("h264")&&r.push(e)})),r.length>1&&o.push(...r.slice(1));const s=o.map((e=>{const t=/a=rtpmap:(\d+)\s/.exec(e);return t&&t.length>1?t[1]:null})).filter((e=>null!==e)),i=[];return t.forEach((e=>{let t=e;if(e.includes("a=setup")&&(t="a=setup:passive"),(e.includes("m=audio")||e.includes("m=video"))&&(t=e.split(" ").filter(((e,t)=>t<3||!s.includes(e))).join(" ")),e.includes("a=fmtp")||e.includes("a=rtcp-fb")||e.includes("a=rtpmap")){const t=/a=(?:fmtp|rtcp-fb|rtpmap):(\d+)\s/.exec(e);if(t&&t.length>1&&s.includes(t[1]))return}i.push(t)})),i.join("\r\n")},updateSdpRestriction=e=>{const t=e.split("\r\n"),r=[];t.forEach((e=>{const t=e.toLowerCase();t.includes("a=rtpmap")&&t.includes("h264")&&r.push(e)}));const o=r.map((e=>{const t=/a=rtpmap:(\d+)\s/.exec(e);return t&&t.length>1?t[1]:null})).filter((e=>null!==e)),s=[];t.forEach((e=>{let t=e;if(e.includes("a=fmtp:111")&&(t=`${e};stereo=1`),e.includes("a=fmtp")){const r=/a=fmtp:(\d+)\s/.exec(e);r&&r.length>1&&o.includes(r[1])&&(t=`${e};sps-pps-idr-in-keyframe=1`)}s.push(t)}));const i=s.join("\r\n");return updateSdpForFirefox(i)},urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",nanoid=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=urlAlphabet[63&r[e]];return t},SIGNAL_DOMAIN_NAME_LIST=["overseas-webrtc.tlivewebrtc.com","oswebrtc-lint.tliveplay.com"],_FastWebRTC=class e{constructor(e){this.core=e,__publicField(this,"disableRandomCall",!0),__publicField(this,"connectedRoomIdSet",new Set),__publicField(this,"updateSeq",0),__publicField(this,"_log"),this._log=this.core.log.createChild({id:`${this.getAlias()}`})}getName(){return e.Name}getAlias(){return"fwrtc"}getGroup(){return""}getValidateRule(e){switch(e){case"start":return StartValidateRule;case"update":case"stop":return{}}}async start(e){const{view:t,url:r,licenseConfig:o}=e}async connect(e){const t=new RTCPeerConnection({iceServers:[],sdpSemantics:"unified-plan",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"});t.addTransceiver("audio",{direction:"recvonly"}),t.addTransceiver("video",{direction:"recvonly"});const r=await t.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1});r.sdp=updateSdpRestriction(r.sdp),await t.setLocalDescription(r);const o={sessionId:nanoid(),streamurl:e,clientinfo:"macos chrome115",localsdp:t.localDescription},{remoteSdp:s,svrSig:i}=await this.core.utils.promiseAny(SIGNAL_DOMAIN_NAME_LIST.map((e=>this.exchangeSDP(e,o,3))));await t.setRemoteDescription(s)}async exchangeSDP(e,t,r){const o=`${e}/webrtc/v1/pullstream`,s=await fetchPost(o,t,{timeout:r}),{errcode:i,errmsg:n,remotesdp:a,svrsig:c}=s;if(0!==i){const e=new Error(`errCode:${i}, errMsg:${n}`);throw e.name="RequestSignalError",e}return{url:e,remoteSdp:a,svrSig:c}}async update(e){}async stop(){}destroy(){}};__publicField(_FastWebRTC,"Name","FastWebRTC");var FastWebRTC=_FastWebRTC,fetchPost=async(e,t,r={})=>{const{timeout:o=10}=r;let s,i=0,n={};window.AbortController&&(s=new window.AbortController,n={signal:s.signal},i=window.setTimeout((()=>s.abort()),1e3*o));const a=await fetch(e,__spreadValues({body:JSON.stringify(t),cache:"no-cache",credentials:"same-origin",headers:{"content-type":"text/plain;charset=utf-8"},method:"POST",mode:"cors"},n));if(i&&window.clearTimeout(i),200!==a.status)throw new Error(`Network Error, status code:${a.status}`);return a.json()},index_default=FastWebRTC;export{index_default as default};export{FastWebRTC};
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).FastWebRTC=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function e(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))}}function n(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,a(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(){o=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),c=new _(n||[]);return i(a,"_invoke",{value:O(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",y="suspendedYield",d="executing",v="completed",m={};function g(){}function w(){}function b(){}var x={};l(x,c,(function(){return this}));var E=Object.getPrototypeOf,S=E&&E(E(C([])));S&&S!==r&&n.call(S,c)&&(x=S);var L=b.prototype=g.prototype=Object.create(x);function j(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,i,a,c){var u=p(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var o=h;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=T(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=p(e,r,n);if("normal"===s.type){if(o=n.done?v:y,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function T(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,T(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=p(o,e.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[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function C(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return w.prototype=b,i(L,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:w,configurable:!0}),w.displayName=l(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,s,"GeneratorFunction")),t.prototype=Object.create(L),t},e.awrap=function(t){return{__await:t}},j(k.prototype),l(k.prototype,u,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(L),l(L,s,"Generator"),l(L,c,(function(){return this})),l(L,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=C,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!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 u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){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"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){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&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:C(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function i(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||u(e)||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 a(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function u(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}var s=Object.defineProperty,l=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,h=function(t,e,r){return e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},y=function(t,e){for(var r in e||(e={}))f.call(e,r)&&h(t,r,e[r]);if(l){var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=u(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},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(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(l(e));try{for(o.s();!(n=o.n()).done;){r=n.value;p.call(e,r)&&h(t,r,e[r])}}catch(t){o.e(t)}finally{o.f()}}return t},d=function(t,e,r){return h(t,"symbol"!==c(e)?e+"":e,r)},v={name:"option",required:!0,properties:{view:{type:["string",HTMLElement],required:!0},url:{type:"string",required:!0},licenseConfig:{type:"object",required:!0,properties:{secretKey:{type:"string",required:!0},encrypted:{type:"string",required:!0},signature:{type:"string",required:!0}}}}},m=function(t){var e=t.split("\r\n"),r=[];e.forEach((function(t){var e=t.toLowerCase();e.includes("a=rtpmap")&&e.includes("h264")&&r.push(t)}));var n=r.map((function(t){var e=/a=rtpmap:(\d+)\s/.exec(t);return e&&e.length>1?e[1]:null})).filter((function(t){return null!==t})),o=[];return e.forEach((function(t){var e=t;if(t.includes("a=fmtp:111")&&(e="".concat(t,";stereo=1")),t.includes("a=fmtp")){var r=/a=fmtp:(\d+)\s/.exec(t);r&&r.length>1&&n.includes(r[1])&&(e="".concat(t,";sps-pps-idr-in-keyframe=1"))}o.push(e)})),function(t){if(!navigator.userAgent.includes("Firefox"))return t;var e=t.split("\r\n"),r=[],n=[];e.forEach((function(t){var e=t.toLowerCase();e.includes("a=rtpmap")&&e.includes("h264")&&r.push(t)})),r.length>1&&n.push.apply(n,i(r.slice(1)));var o=n.map((function(t){var e=/a=rtpmap:(\d+)\s/.exec(t);return e&&e.length>1?e[1]:null})).filter((function(t){return null!==t})),a=[];return e.forEach((function(t){var e=t;if(t.includes("a=setup")&&(e="a=setup:passive"),(t.includes("m=audio")||t.includes("m=video"))&&(e=t.split(" ").filter((function(t,e){return e<3||!o.includes(t)})).join(" ")),t.includes("a=fmtp")||t.includes("a=rtcp-fb")||t.includes("a=rtpmap")){var r=/a=(?:fmtp|rtcp-fb|rtpmap):(\d+)\s/.exec(t);if(r&&r.length>1&&o.includes(r[1]))return}a.push(e)})),a.join("\r\n")}(o.join("\r\n"))},g=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,e="",r=crypto.getRandomValues(new Uint8Array(t|=0));t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&r[t]];return e},w=["overseas-webrtc.tlivewebrtc.com","oswebrtc-lint.tliveplay.com"],b=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.core=e,d(this,"disableRandomCall",!0),d(this,"connectedRoomIdSet",new Set),d(this,"updateSeq",0),d(this,"_log"),this._log=this.core.log.createChild({id:"".concat(this.getAlias())})}return n(t,[{key:"getName",value:function(){return t.Name}},{key:"getAlias",value:function(){return"fwrtc"}},{key:"getGroup",value:function(){return""}},{key:"getValidateRule",value:function(t){switch(t){case"start":return v;case"update":case"stop":return{}}}},{key:"start",value:(u=r(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.view,e.url,e.licenseConfig;case 1:case"end":return t.stop()}}),t)}))),function(t){return u.apply(this,arguments)})},{key:"connect",value:(c=r(o().mark((function t(e){var r,n,i,a,c,u,s=this;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(r=new RTCPeerConnection({iceServers:[],sdpSemantics:"unified-plan",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"})).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t.next=5,r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1});case 5:return(n=t.sent).sdp=m(n.sdp),t.next=9,r.setLocalDescription(n);case 9:return i=g(),a={sessionId:i,streamurl:e,clientinfo:"macos chrome115",localsdp:r.localDescription},t.next=13,this.core.utils.promiseAny(w.map((function(t){return s.exchangeSDP(t,a,3)})));case 13:return c=t.sent,u=c.remoteSdp,c.svrSig,t.next=18,r.setRemoteDescription(u);case 18:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"exchangeSDP",value:(a=r(o().mark((function t(e,r,n){var i,a,c,u,s,l,f;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i="".concat(e,"/webrtc/v1/pullstream"),t.next=3,E(i,r,{timeout:n});case 3:if(a=t.sent,c=a.errcode,u=a.errmsg,s=a.remotesdp,l=a.svrsig,0===c){t.next=9;break}throw(f=new Error("errCode:".concat(c,", errMsg:").concat(u))).name="RequestSignalError",f;case 9:return t.abrupt("return",{url:e,remoteSdp:s,svrSig:l});case 10:case"end":return t.stop()}}),t)}))),function(t,e,r){return a.apply(this,arguments)})},{key:"update",value:(i=r(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(t){return i.apply(this,arguments)})},{key:"stop",value:(e=r(o().mark((function t(){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(){return e.apply(this,arguments)})},{key:"destroy",value:function(){}}]);var e,i,a,c,u}();d(b,"Name","FastWebRTC");var x=b,E=function(){var t=r(o().mark((function t(e,r){var n,i,a,c,u,s,l=arguments;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=(l.length>2&&void 0!==l[2]?l[2]:{}).timeout,i=void 0===n?10:n,c=0,u={},window.AbortController&&(a=new window.AbortController,u={signal:a.signal},c=window.setTimeout((function(){return a.abort()}),1e3*i)),t.next=7,fetch(e,y({body:JSON.stringify(r),cache:"no-cache",credentials:"same-origin",headers:{"content-type":"text/plain;charset=utf-8"},method:"POST",mode:"cors"},u));case 7:if(s=t.sent,c&&window.clearTimeout(c),200===s.status){t.next=11;break}throw new Error("Network Error, status code:".concat(s.status));case 11:return t.abrupt("return",s.json());case 12:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}();return x}));
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@rtc-plugin/lebplayer",
3
+ "version": "5.14.1",
4
+ "description": "TRTC Web SDK 5.x Cross Room 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
+ }
@@ -0,0 +1,27 @@
1
+ export interface StartCrossRoomOption {
2
+ roomId?: number,
3
+ strRoomId?: string,
4
+ userId?: string
5
+ }
6
+
7
+ interface UpdateCrossRoomOptionItem extends StartCrossRoomOption {
8
+ muteAudio: boolean,
9
+ muteVideo: boolean,
10
+ muteSubStream: boolean,
11
+ }
12
+
13
+ export interface UpdateCrossRoomOption {
14
+ updateList: UpdateCrossRoomOptionItem[]
15
+ }
16
+
17
+ export interface StopCrossRoomOption {
18
+ roomId?: number,
19
+ strRoomId?: string,
20
+ }
21
+
22
+
23
+ export declare class CrossRoom {
24
+ start(option: StartCrossRoomOption): Promise<void>;
25
+ update(option: UpdateCrossRoomOption): Promise<void>;
26
+ stop(option?: StopCrossRoomOption): Promise<void>;
27
+ }
@@ -0,0 +1 @@
1
+ var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__decorateClass=(e,t,r,i)=>{for(var o,n=i>1?void 0:i?__getOwnPropDesc(t,r):t,s=e.length-1;s>=0;s--)(o=e[s])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&__defProp(t,r,n),n},__publicField=(e,t,r)=>__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),StartValidateRule={name:"option",required:!0,properties:{view:{type:["string",HTMLElement],required:!0},url:{type:"string",required:!0},licenseConfig:{type:"object",required:!1,properties:{secretKey:{type:"string",required:!0},encrypted:{type:"string",required:!0},signature:{type:"string",required:!0}}}}},updateSdpForFirefox=e=>{if(!navigator.userAgent.includes("Firefox"))return e;const t=e.split("\r\n"),r=[],i=[];t.forEach((e=>{const t=e.toLowerCase();t.includes("a=rtpmap")&&t.includes("h264")&&r.push(e)})),r.length>1&&i.push(...r.slice(1));const o=i.map((e=>{const t=/a=rtpmap:(\d+)\s/.exec(e);return t&&t.length>1?t[1]:null})).filter((e=>null!==e)),n=[];return t.forEach((e=>{let t=e;if(e.includes("a=setup")&&(t="a=setup:passive"),(e.includes("m=audio")||e.includes("m=video"))&&(t=e.split(" ").filter(((e,t)=>t<3||!o.includes(e))).join(" ")),e.includes("a=fmtp")||e.includes("a=rtcp-fb")||e.includes("a=rtpmap")){const t=/a=(?:fmtp|rtcp-fb|rtpmap):(\d+)\s/.exec(e);if(t&&t.length>1&&o.includes(t[1]))return}n.push(t)})),n.join("\r\n")},updateSdpRestriction=e=>{const t=e.split("\r\n"),r=[];t.forEach((e=>{const t=e.toLowerCase();t.includes("a=rtpmap")&&t.includes("h264")&&r.push(e)}));const i=r.map((e=>{const t=/a=rtpmap:(\d+)\s/.exec(e);return t&&t.length>1?t[1]:null})).filter((e=>null!==e)),o=[];t.forEach((e=>{let t=e;if(e.includes("a=fmtp:111")&&(t=`${e};stereo=1`),e.includes("a=fmtp")){const r=/a=fmtp:(\d+)\s/.exec(e);r&&r.length>1&&i.includes(r[1])&&(t=`${e};sps-pps-idr-in-keyframe=1`)}o.push(t)}));const n=o.join("\r\n");return updateSdpForFirefox(n)},urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",nanoid=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=urlAlphabet[63&r[e]];return t},isFunction=e=>"function"==typeof e,RETRY_STATE_NOT_START=0,RETRY_STATE_STARTED=1,RETRY_STATE_STOPPED=2;function promiseRetry({retryFunction:e,settings:t,onError:r,onRetrying:i,onRetryFailed:o,onRetrySuccess:n,context:s}){return function(...a){const{retries:l=5,timeout:c=1e3}=t;let d=0,u=-1,p=RETRY_STATE_NOT_START;const h=async(t,y)=>{const m=s||this;try{const r=await e.apply(m,a);d>0&&n&&n.call(this,d),d=0,t(r)}catch(e){const n=()=>{clearTimeout(u),d=0,p=RETRY_STATE_STOPPED,y(e)},s=()=>{p!==RETRY_STATE_STOPPED&&d<(isFunction(l)?l():l)?(d++,p=RETRY_STATE_STARTED,isFunction(i)&&i.call(this,d,n),u=window.setTimeout((()=>{u=-1,h(t,y)}),isFunction(c)?c(d):c)):(n(),isFunction(o)&&o.call(this,e))};isFunction(r)?r.call(this,{error:e,retry:s,reject:y,retryFuncArgs:a,retriedCount:d}):s()}};return new Promise(h)}}var retry_default=promiseRetry,retryingMap=new WeakMap;function addPromiseRetry({settings:e={retries:5,timeout:2e3},onError:t,onRetrying:r,onRetryFailed:i}){return function(o,n,s){const a=retry_default({retryFunction:s.value,settings:e,onError({error:e,retry:r,reject:i,retryFuncArgs:s}){var a;t?t.call(this,e,(()=>{var t;(null==(t=retryingMap.get(o))?void 0:t.has(n))?r():i(e)}),i,s):(null==(a=retryingMap.get(o))?void 0:a.has(n))?r():i(e)},onRetrying(e,t){var i;isFunction(r)&&r.call(this,e,t),(null==(i=retryingMap.get(o))?void 0:i.has(n))&&(retryingMap.get(o).get(n).stopRetry=t)},onRetryFailed:i});return s.value=function(...e){const t=retryingMap.get(o);return t?t.set(n,{args:e}):retryingMap.set(o,new Map([[n,{args:e}]])),a.apply(this,e).finally((()=>{var e;return null==(e=retryingMap.get(o))?void 0:e.delete(n)}))},s}}function removePromiseRetry({fnName:e,callback:t,validateArgs:r=!0}){return function(i,o,n){const s=n.value;return n.value=function(...o){var n,a;if(null==(n=retryingMap.get(i))?void 0:n.has(e)){const{stopRetry:n,args:s}=retryingMap.get(i).get(e);let l=!0;if(r)for(const e of s)if(!o.find((t=>t===e))){l=!1;break}l&&(t&&t.apply(this,o),n&&n(),null==(a=retryingMap.get(i))||a.delete(e))}return s.apply(this,o)},n}}var SIGNAL_DOMAIN_NAME_LIST=["overseas-webrtc.tlivewebrtc.com","oswebrtc-lint.tliveplay.com"],_LEBPlayer=class e{constructor(e){this.core=e,__publicField(this,"connectedRoomIdSet",new Set),__publicField(this,"updateSeq",0),__publicField(this,"_log"),__publicField(this,"audioPlayer"),__publicField(this,"videoPlayer"),__publicField(this,"peerConnection"),__publicField(this,"svrSig"),__publicField(this,"streamURL"),__publicField(this,"signalURL"),__publicField(this,"insertableStreamsAbortMap",new Map),__publicField(this,"scriptTransformWorker"),__publicField(this,"connectionState","disconnected"),__publicField(this,"isStarted",!1),__publicField(this,"isStopped",!0),__publicField(this,"isReconnecting",!1),__publicField(this,"callback"),e.loggerManager.startUpload(),this._log=this.core.log.createChild({id:`${this.getAlias()}`}),this.videoPlayer=new e.VideoPlayer({id:"vp",log:this._log.createChild({id:"vp"}),track:null,muted:!1,container:null}),this.audioPlayer=new e.RemoteAudioPlayer({id:"ap",log:this._log.createChild({id:"ap"}),track:null,muted:!1,container:null,enableVolumeControlInIOS:!0}),this.videoPlayer.on("loadstart",(()=>{var e,t;return null==(t=null==(e=this.callback)?void 0:e.onLoadStart)?void 0:t.call(e,"video")})),this.audioPlayer.on("loadstart",(()=>{var e,t;return null==(t=null==(e=this.callback)?void 0:e.onLoadStart)?void 0:t.call(e,"audio")})),this.videoPlayer.on("player-state-changed",(e=>{var t,r;null==(r=null==(t=this.callback)?void 0:t.onVideoPlayStateChanged)||r.call(t,{state:e.state,reason:e.reason})})),this.audioPlayer.on("player-state-changed",(e=>{var t,r;null==(r=null==(t=this.callback)?void 0:t.onAudioPlayStateChanged)||r.call(t,{state:e.state,reason:e.reason})})),e.innerEmitter.on(e.INNER_EVENT.SEI_MESSAGE,this.onSEIMessage,this)}getName(){return e.Name}getAlias(){return"LEB"}getGroup(){return""}getValidateRule(e){switch(e){case"start":return StartValidateRule;case"update":case"stop":return{}}}get enableSEI(){return this.core.room.enableSEI&&(this.core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED||this.core.rtcDectection.IS_SCRIPT_TRANSFORM_SUPPORTED)}async start(e){this.isStopped=!1;const{view:t,url:r,volume:i,muted:o,fillMode:n,loggerConfig:s,callback:a}=e;if(this.callback=a,this.core.loggerManager.addJoinedUser(s),this.core.utils.isString(t)){const e=document.getElementById(t);e&&this.videoPlayer.setContainer(e)}this.setMuted(o),this.setVolume(i),n&&this.videoPlayer.setObjectFit(n),await this.connect(r),this.videoPlayer.play().catch((e=>{var t,r;this.handleAutoPlayFailed(this.audioPlayer,e),null==(r=null==(t=this.callback)?void 0:t.onAutoPlayFailed)||r.call(t,{type:"video",resume:()=>this.videoPlayer.resume()})})),this.audioPlayer.play().catch((e=>{var t,r;this.handleAutoPlayFailed(this.audioPlayer,e),null==(r=null==(t=this.callback)?void 0:t.onAutoPlayFailed)||r.call(t,{type:"audio",resume:()=>this.audioPlayer.resume()})})),this.isStarted=!0}handleAutoPlayFailed(e,t){this._log.warn("handleAutoPlayFailed",t);const r=()=>{this.audioPlayer.resume().then((()=>{document.removeEventListener("click",r,!0)}))};document.addEventListener("click",r,!0)}async connect(e){return new Promise((async(t,r)=>{this.initScriptTransformWorker();const i=new RTCPeerConnection({iceServers:[],sdpSemantics:"unified-plan",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost",enableInsertableStreams:this.enableSEI});this.peerConnection=i,i.onconnectionstatechange=()=>{this.connectionState=i.connectionState,this._log.info("connectionState",i.connectionState),"failed"!==i.connectionState&&"closed"!==i.connectionState||(this.isStarted?this.reconnect(e):r(`connection is ${i.connectionState}`)),"connected"===i.connectionState&&(this.logSelectedCandidate(),t())},i.ontrack=this.onTrack.bind(this);const o=i.addTransceiver("audio",{direction:"recvonly"}),n=i.addTransceiver("video",{direction:"recvonly"});this.createEncodedStreams(o.receiver),this.createEncodedStreams(n.receiver),this.initReceiverTransform(o.receiver,!0),this.initReceiverTransform(n.receiver,!1),this._log.info("createOffer");const s=await i.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1});s.sdp=updateSdpRestriction(s.sdp),this._log.info("setOffer"),await i.setLocalDescription(s);const a={sessionId:nanoid(),streamurl:e,clientinfo:this.core.environment.getOSString(),localsdp:i.localDescription},{url:l,remoteSdp:c,svrSig:d}=await this.core.utils.promiseAny(SIGNAL_DOMAIN_NAME_LIST.map((e=>this.exchangeSDP(`https://${e}`,a,3))));this.streamURL=e,this.signalURL=l,this.svrSig=d,this._log.info("setAnswer"),await i.setRemoteDescription(c),setTimeout((()=>r("connection timeout")),1e4)}))}async reconnect(e){if(!this.isReconnecting){this.isReconnecting=!0;try{this._log.warn("start reconnect"),await this.connect(e),this._log.warn("reconnect success")}catch(e){this._log.error("reconnect error",e)}finally{this.isReconnecting=!1}}}async logSelectedCandidate(){if(!this.peerConnection)return;const e=await this.peerConnection.getStats();for(const[t,r]of e)if(this.core.rtcDectection.isSelectedCandidatePair(r)){const t=e.get(r.localCandidateId),i=e.get(r.remoteCandidateId);t&&this._log.info(`local candidate: ${t.candidateType} ${t.protocol}:${t.ip||t.address}:${t.port} ${t.networkType||""} ${t.relayProtocol?`relayProtocol:${t.relayProtocol} url: ${t.url}`:""}`),i&&this._log.info(`remote candidate: ${i.candidateType} ${i.protocol}:${i.ip||i.address}:${i.port}`);break}}async exchangeSDP(e,t,r){const i=`${e}/webrtc/v1/pullstream`,o=await fetchPost(i,t,{timeout:r}),{errcode:n,errmsg:s,remotesdp:a,svrsig:l}=o;if(0!==n){const e=new Error(`errCode:${n}, errMsg:${s}`);throw e.name="RequestSignalError",e}return{url:e,remoteSdp:a,svrSig:l}}createEncodedStreams(e){var t;if(this.core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED&&!this.insertableStreamsAbortMap.has(e)){const r=e.createEncodedStreams(),i=new AbortController,o={abortController:i,enqueue:t=>"audio"===e.track.kind?t:this.decodeVideoFrame(t)};r.readable.pipeThrough(new TransformStream({transform:(e,t)=>{const r=o.enqueue(e);r&&t.enqueue(r)}})).pipeTo(r.writable,i).catch((e=>{"destroy"!==e&&this._log.warn(e)})),null==(t=this.insertableStreamsAbortMap.get(e))||t.abort("destroy"),this.insertableStreamsAbortMap.set(e,i)}}initReceiverTransform(e,t){this.peerConnection&&this.scriptTransformWorker&&!e.transform&&(e.transform=new RTCRtpScriptTransform(this.scriptTransformWorker,{isReceiver:!0,isAudio:t,userId:"",streamType:this.core.enums.RemoteStreamType.Main}))}initScriptTransformWorker(){const{room:e,rtcDectection:t,createScriptTransformWorker:r,trtc:i,TRTC:o}=this.core;!this.enableSEI||t.IS_INSERTABLE_STREAM_SUPPORTED||this.scriptTransformWorker||t.IS_SCRIPT_TRANSFORM_SUPPORTED&&(this.scriptTransformWorker=r({videoEncodePipeline:e.videoManager.encodePipeline,videoDecodePipeline:e.videoManager.decodePipeline,audioEncodePipeline:e.audioManager.encodePipeline,audioDecodePipeline:e.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=e=>{"sei"===e.data.type&&i.emit(o.EVENT.SEI_MESSAGE,e.data)},this.scriptTransformWorker.onerror=e=>{this._log.error("scriptTransformWorker error: ",e.message)})}decodeVideoFrame(e){if(!this.core.room.videoManager)return e;for(const t of this.core.room.videoManager.decodePipeline)if(t&&!(e=t({frame:e})))return;return e}async fetchStopStream(){if(!this.streamURL||!this.svrSig||!this.signalURL)return;const e=`${this.signalURL}/webrtc/v1/stopstream`,t=await fetchPost(e,{streamurl:this.streamURL,svrsig:this.svrSig},{timeout:3}),{errcode:r,errmsg:i}=t;if(0!==r)throw new Error(`errCode:${r}, errmsg:${i}`);return t}onTrack(e){const{track:t}=e;"audio"===t.kind?this.audioPlayer.setTrack(t):this.videoPlayer.setTrack(t)}async update(e){const{volume:t,muted:r,fillMode:i,action:o,fullScreen:n,pictureInPicture:s}=e;this.setMuted(r),this.setVolume(t),i&&this.videoPlayer.setObjectFit(i),"pause"===o?(this.videoPlayer.pause(),this.audioPlayer.pause()):"resume"===o&&(this.videoPlayer.resume(),this.audioPlayer.resume()),this.core.utils.isBoolean(n)&&(n?await this.videoPlayer.enterFullscreen():await this.videoPlayer.exitFullscreen()),this.core.utils.isBoolean(s)&&(s?await this.videoPlayer.enterPictureInPicture():await this.videoPlayer.exitPictureInPicture())}async stop(){this.isStopped=!0,this.videoPlayer&&this.videoPlayer.stop(),this.audioPlayer&&this.audioPlayer.stop(),this.peerConnection&&(this.peerConnection.close(),delete this.peerConnection,await this.fetchStopStream(),delete this.streamURL,delete this.signalURL,delete this.svrSig)}setVolume(e){this.core.utils.isUndefined(e)||this.audioPlayer.setVolume(e/100)}setMuted(e){this.core.utils.isUndefined(e)||this.audioPlayer.setMuted(e)}destroy(){this.stop(),this.core.innerEmitter.off(this.core.INNER_EVENT.SEI_MESSAGE,this.onSEIMessage,this)}onSEIMessage({room:e,nalu:t}){var r,i;e===this.core.room&&(null==(i=null==(r=this.callback)?void 0:r.onSEIMessage)||i.call(r,{data:t.seiPayload.buffer,seiPayloadType:t.seiPayloadType}))}};__publicField(_LEBPlayer,"Name","LEBPlayer"),__decorateClass([addPromiseRetry({settings:{retries:1/0,timeout:2e3},onRetrying(e){this._log.warn(`retry connect ${e}`)},onError(e,t,r,i){this._log.warn("connect failed",e),this.peerConnection&&(this.peerConnection.close(),delete this.peerConnection),this.isStopped||t()}})],_LEBPlayer.prototype,"connect",1),__decorateClass([removePromiseRetry({fnName:"connect"})],_LEBPlayer.prototype,"stop",1);var LEBPlayer=_LEBPlayer,fetchPost=async(e,t,r={})=>{const{timeout:i=10}=r;let o,n=0,s={};window.AbortController&&(o=new window.AbortController,s={signal:o.signal},n=window.setTimeout((()=>o.abort()),1e3*i));const a=await fetch(e,__spreadValues({body:JSON.stringify(t),cache:"no-cache",credentials:"same-origin",headers:{"content-type":"text/plain;charset=utf-8"},method:"POST",mode:"cors"},s));if(n&&window.clearTimeout(n),200!==a.status)throw new Error(`Network Error, status code:${a.status}`);return a.json()},index_default=LEBPlayer;export{index_default as default};export{LEBPlayer};
@@ -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&&function(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,s(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=l(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 i(){i=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(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:R(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=f;var h="suspendedStart",p="suspendedYield",y="executing",v="completed",m={};function g(){}function b(){}function w(){}var S={};l(S,c,(function(){return this}));var P=Object.getPrototypeOf,k=P&&P(P(C([])));k&&k!==r&&n.call(k,c)&&(S=k);var E=w.prototype=g.prototype=Object.create(S);function x(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function T(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 R(t,r,n){var o=h;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){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=A(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===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var u=d(t,r,n);if("normal"===u.type){if(o=n.done?v:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=v,n.method="throw",n.arg=u.arg)}}}function A(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,A(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 _(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 L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function C(t){if(t||""===t){var r=t[c];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 b.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,u,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},x(T.prototype),l(T.prototype,s,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new T(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},x(E),l(E,u,"Generator"),l(E,c,(function(){return this})),l(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=C,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(L),!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),L(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;L(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:C(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function a(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)||l(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 c(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)||l(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 s(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 u(e){return u="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},u(e)}function l(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}}var f=Object.defineProperty,d=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,v=function(e,t,r){return t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},m=function(e,t){for(var r in t||(t={}))p.call(t,r)&&v(e,r,t[r]);if(h){var n,i=o(h(t));try{for(i.s();!(n=i.n()).done;){r=n.value;y.call(t,r)&&v(e,r,t[r])}}catch(e){i.e(e)}finally{i.f()}}return e},g=function(e,t,r,n){for(var o,i=d(t,r),a=e.length-1;a>=0;a--)(o=e[a])&&(i=o(t,r,i)||i);return i&&f(t,r,i),i},b=function(e,t,r){return v(e,"symbol"!==u(t)?t+"":t,r)},w={name:"option",required:!0,properties:{view:{type:["string",HTMLElement],required:!0},url:{type:"string",required:!0},licenseConfig:{type:"object",required:!1,properties:{secretKey:{type:"string",required:!0},encrypted:{type:"string",required:!0},signature:{type:"string",required:!0}}}}},S=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,c(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"))},P=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},k=function(e){return"function"==typeof e};var E=function(e){var t=e.retryFunction,n=e.settings,o=e.onError,a=e.onRetrying,c=e.onRetryFailed,s=e.onRetrySuccess,u=e.context;return function(){for(var e=this,l=arguments.length,f=new Array(l),d=0;d<l;d++)f[d]=arguments[d];var h=n.retries,p=void 0===h?5:h,y=n.timeout,v=void 0===y?1e3:y,m=0,g=-1,b=0,w=function(){var n=r(i().mark((function r(n,l){var d,h,y,S;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return d=u||e,r.prev=1,r.next=4,t.apply(d,f);case 4:h=r.sent,m>0&&s&&s.call(e,m),m=0,n(h),r.next=15;break;case 10:r.prev=10,r.t0=r.catch(1),y=function(){clearTimeout(g),m=0,b=2,l(r.t0)},S=function(){2!==b&&m<(k(p)?p():p)?(m++,b=1,k(a)&&a.call(e,m,y),g=window.setTimeout((function(){g=-1,w(n,l)}),k(v)?v(m):v)):(y(),k(c)&&c.call(e,r.t0))},k(o)?o.call(e,{error:r.t0,retry:S,reject:l,retryFuncArgs:f,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(w)}},x=new WeakMap;var T,R,A,_,L,I,C,O,M,j,F,N=["overseas-webrtc.tlivewebrtc.com","oswebrtc-lint.tliveplay.com"],U=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=t,b(this,"connectedRoomIdSet",new Set),b(this,"updateSeq",0),b(this,"_log"),b(this,"audioPlayer"),b(this,"videoPlayer"),b(this,"peerConnection"),b(this,"svrSig"),b(this,"streamURL"),b(this,"signalURL"),b(this,"insertableStreamsAbortMap",new Map),b(this,"scriptTransformWorker"),b(this,"connectionState","disconnected"),b(this,"isStarted",!1),b(this,"isStopped",!0),b(this,"isReconnecting",!1),b(this,"callback"),t.loggerManager.startUpload(),this._log=this.core.log.createChild({id:"".concat(this.getAlias())}),this.videoPlayer=new t.VideoPlayer({id:"vp",log:this._log.createChild({id:"vp"}),track:null,muted:!1,container:null}),this.audioPlayer=new t.RemoteAudioPlayer({id:"ap",log:this._log.createChild({id:"ap"}),track:null,muted:!1,container:null,enableVolumeControlInIOS:!0}),this.videoPlayer.on("loadstart",(function(){var e,t;return null==(t=null==(e=r.callback)?void 0:e.onLoadStart)?void 0:t.call(e,"video")})),this.audioPlayer.on("loadstart",(function(){var e,t;return null==(t=null==(e=r.callback)?void 0:e.onLoadStart)?void 0:t.call(e,"audio")})),this.videoPlayer.on("player-state-changed",(function(e){var t,n;null==(n=null==(t=r.callback)?void 0:t.onVideoPlayStateChanged)||n.call(t,{state:e.state,reason:e.reason})})),this.audioPlayer.on("player-state-changed",(function(e){var t,n;null==(n=null==(t=r.callback)?void 0:t.onAudioPlayStateChanged)||n.call(t,{state:e.state,reason:e.reason})})),t.innerEmitter.on(t.INNER_EVENT.SEI_MESSAGE,this.onSEIMessage,this)}return n(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 w;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:(h=r(i().mark((function e(t){var r,n,o,a,c,s,u,l,f=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isStopped=!1,r=t.view,n=t.url,o=t.volume,a=t.muted,c=t.fillMode,s=t.loggerConfig,u=t.callback,this.callback=u,this.core.loggerManager.addJoinedUser(s),this.core.utils.isString(r)&&(l=document.getElementById(r))&&this.videoPlayer.setContainer(l),this.setMuted(a),this.setVolume(o),c&&this.videoPlayer.setObjectFit(c),e.next=10,this.connect(n);case 10:this.videoPlayer.play().catch((function(e){var t,r;f.handleAutoPlayFailed(f.audioPlayer,e),null==(r=null==(t=f.callback)?void 0:t.onAutoPlayFailed)||r.call(t,{type:"video",resume:function(){return f.videoPlayer.resume()}})})),this.audioPlayer.play().catch((function(e){var t,r;f.handleAutoPlayFailed(f.audioPlayer,e),null==(r=null==(t=f.callback)?void 0:t.onAutoPlayFailed)||r.call(t,{type:"audio",resume:function(){return f.audioPlayer.resume()}})})),this.isStarted=!0;case 13:case"end":return e.stop()}}),e,this)}))),function(e){return h.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:"connect",value:(d=r(i().mark((function e(t){var n=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=r(i().mark((function e(r,o){var a,c,s,u,l,f,d,h,p,y;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.initScriptTransformWorker(),a=new RTCPeerConnection({iceServers:[],sdpSemantics:"unified-plan",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost",enableInsertableStreams:n.enableSEI}),n.peerConnection=a,a.onconnectionstatechange=function(){n.connectionState=a.connectionState,n._log.info("connectionState",a.connectionState),"failed"!==a.connectionState&&"closed"!==a.connectionState||(n.isStarted?n.reconnect(t):o("connection is ".concat(a.connectionState))),"connected"===a.connectionState&&(n.logSelectedCandidate(),r())},a.ontrack=n.onTrack.bind(n),c=a.addTransceiver("audio",{direction:"recvonly"}),s=a.addTransceiver("video",{direction:"recvonly"}),n.createEncodedStreams(c.receiver),n.createEncodedStreams(s.receiver),n.initReceiverTransform(c.receiver,!0),n.initReceiverTransform(s.receiver,!1),n._log.info("createOffer"),e.next=14,a.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1});case 14:return(u=e.sent).sdp=S(u.sdp),n._log.info("setOffer"),e.next=19,a.setLocalDescription(u);case 19:return l=P(),f={sessionId:l,streamurl:t,clientinfo:n.core.environment.getOSString(),localsdp:a.localDescription},e.next=23,n.core.utils.promiseAny(N.map((function(e){return n.exchangeSDP("https://".concat(e),f,3)})));case 23:return d=e.sent,h=d.url,p=d.remoteSdp,y=d.svrSig,n.streamURL=t,n.signalURL=h,n.svrSig=y,n._log.info("setAnswer"),e.next=33,a.setRemoteDescription(p);case 33:setTimeout((function(){return o("connection timeout")}),1e4);case 34:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e){return d.apply(this,arguments)})},{key:"reconnect",value:(f=r(i().mark((function e(t){return i().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 f.apply(this,arguments)})},{key:"logSelectedCandidate",value:(l=r(i().mark((function e(){var t,r,n,c,s,u,l;return i().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=o(t),e.prev=6,r.s();case 8:if((n=r.n()).done){e.next=18;break}if((c=a(n.value,2))[0],s=c[1],!this.core.rtcDectection.isSelectedCandidatePair(s)){e.next=16;break}return u=t.get(s.localCandidateId),l=t.get(s.remoteCandidateId),u&&this._log.info("local candidate: ".concat(u.candidateType," ").concat(u.protocol,":").concat(u.ip||u.address,":").concat(u.port," ").concat(u.networkType||""," ").concat(u.relayProtocol?"relayProtocol:".concat(u.relayProtocol," url: ").concat(u.url):"")),l&&this._log.info("remote candidate: ".concat(l.candidateType," ").concat(l.protocol,":").concat(l.ip||l.address,":").concat(l.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:"exchangeSDP",value:(u=r(i().mark((function e(t,r,n){var o,a,c,s,u,l,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o="".concat(t,"/webrtc/v1/pullstream"),e.next=3,V(o,r,{timeout:n});case 3:if(a=e.sent,c=a.errcode,s=a.errmsg,u=a.remotesdp,l=a.svrsig,0===c){e.next=9;break}throw(f=new Error("errCode:".concat(c,", errMsg:").concat(s))).name="RequestSignalError",f;case 9:return e.abrupt("return",{url:t,remoteSdp:u,svrSig:l});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.core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED&&!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)}}},{key:"initReceiverTransform",value:function(e,t){this.peerConnection&&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,i=t.trtc,a=t.TRTC;!this.enableSEI||n.IS_INSERTABLE_STREAM_SUPPORTED||this.scriptTransformWorker||n.IS_SCRIPT_TRANSFORM_SUPPORTED&&(this.scriptTransformWorker=o({videoEncodePipeline:r.videoManager.encodePipeline,videoDecodePipeline:r.videoManager.decodePipeline,audioEncodePipeline:r.audioManager.encodePipeline,audioDecodePipeline:r.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=function(e){"sei"===e.data.type&&i.emit(a.EVENT.SEI_MESSAGE,e.data)},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=o(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(i().mark((function e(){var t,r,n,o;return i().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 t="".concat(this.signalURL,"/webrtc/v1/stopstream"),e.next=5,V(t,{streamurl:this.streamURL,svrsig:this.svrSig},{timeout:3});case 5:if(r=e.sent,n=r.errcode,o=r.errmsg,0===n){e.next=9;break}throw new Error("errCode:".concat(n,", errmsg:").concat(o));case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"onTrack",value:function(e){var t=e.track;"audio"===t.kind?this.audioPlayer.setTrack(t):this.videoPlayer.setTrack(t)}},{key:"update",value:(c=r(i().mark((function e(t){var r,n,o,a,c,s;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.volume,n=t.muted,o=t.fillMode,a=t.action,c=t.fullScreen,s=t.pictureInPicture,this.setMuted(n),this.setVolume(r),o&&this.videoPlayer.setObjectFit(o),"pause"===a?(this.videoPlayer.pause(),this.audioPlayer.pause()):"resume"===a&&(this.videoPlayer.resume(),this.audioPlayer.resume()),!this.core.utils.isBoolean(c)){e.next=13;break}if(!c){e.next=11;break}return e.next=9,this.videoPlayer.enterFullscreen();case 9:e.next=13;break;case 11:return e.next=13,this.videoPlayer.exitFullscreen();case 13:if(!this.core.utils.isBoolean(s)){e.next=21;break}if(!s){e.next=19;break}return e.next=17,this.videoPlayer.enterPictureInPicture();case 17:e.next=21;break;case 19:return e.next=21,this.videoPlayer.exitPictureInPicture();case 21:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"stop",value:(t=r(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isStopped=!0,this.videoPlayer&&this.videoPlayer.stop(),this.audioPlayer&&this.audioPlayer.stop(),!this.peerConnection){e.next=11;break}return this.peerConnection.close(),delete this.peerConnection,e.next=8,this.fetchStopStream();case 8:delete this.streamURL,delete this.signalURL,delete this.svrSig;case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{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.audioPlayer.setMuted(e)}},{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}))}}]);var t,c,s,u,l,f,d,h}();b(U,"Name","LEBPlayer"),g([(T={settings:{retries:1/0,timeout:2e3},onRetrying:function(e){this._log.warn("retry connect ".concat(e))},onError:function(e,t,r,n){this._log.warn("connect failed",e),this.peerConnection&&(this.peerConnection.close(),delete this.peerConnection),this.isStopped||t()}},R=T.settings,A=void 0===R?{retries:5,timeout:2e3}:R,_=T.onError,L=T.onRetrying,I=T.onRetryFailed,function(e,t,r){var n=E({retryFunction:r.value,settings:A,onError:function(r){var n,o=r.error,i=r.retry,a=r.reject,c=r.retryFuncArgs;_?_.call(this,o,(function(){var r;(null==(r=x.get(e))?void 0:r.has(t))?i():a(o)}),a,c):(null==(n=x.get(e))?void 0:n.has(t))?i():a(o)},onRetrying:function(r,n){var o;k(L)&&L.call(this,r,n),(null==(o=x.get(e))?void 0:o.has(t))&&(x.get(e).get(t).stopRetry=n)},onRetryFailed:I});return r.value=function(){for(var r=x.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}):x.set(e,new Map([[t,{args:i}]])),n.apply(this,i).finally((function(){var r;return null==(r=x.get(e))?void 0:r.delete(t)}))},r})],U.prototype,"connect"),g([(C={fnName:"connect"},O=C.fnName,M=C.callback,j=C.validateArgs,F=void 0===j||j,function(e,t,r){var n=r.value;return r.value=function(){for(var t,r,i=arguments.length,a=new Array(i),c=0;c<i;c++)a[c]=arguments[c];if(null==(t=x.get(e))?void 0:t.has(O)){var s=x.get(e).get(O),u=s.stopRetry,l=s.args,f=!0;if(F){var d,h=o(l);try{var p=function(){var e=d.value;if(!a.find((function(t){return t===e})))return f=!1,1};for(h.s();!(d=h.n()).done&&!p(););}catch(e){h.e(e)}finally{h.f()}}f&&(M&&M.apply(this,a),u&&u(),null==(r=x.get(e))||r.delete(O))}return n.apply(this,a)},r})],U.prototype,"stop");var D=U,V=function(){var e=r(i().mark((function e(t,r){var n,o,a,c,s,u,l=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(l.length>2&&void 0!==l[2]?l[2]:{}).timeout,o=void 0===n?10:n,c=0,s={},window.AbortController&&(a=new window.AbortController,s={signal:a.signal},c=window.setTimeout((function(){return a.abort()}),1e3*o)),e.next=7,fetch(t,m({body:JSON.stringify(r),cache:"no-cache",credentials:"same-origin",headers:{"content-type":"text/plain;charset=utf-8"},method:"POST",mode:"cors"},s));case 7:if(u=e.sent,c&&window.clearTimeout(c),200===u.status){e.next=11;break}throw new Error("Network Error, status code:".concat(u.status));case 11:return e.abrupt("return",u.json());case 12:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();return D}));
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@rtc-plugin/lebplayer",
3
+ "version": "5.14.2-beta.8",
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.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
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.14.2-beta.6",
3
+ "version": "5.14.2-beta.8",
4
4
  "description": "Video decoder plugin for TRTC",
5
5
  "main": "./video-decoder.esm.js",
6
6
  "module": "./video-decoder.esm.js",