trtc-sdk-v5 5.11.1-ktv.2 → 5.11.1-wasm.2
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/assets/av_processing.wasm +0 -0
- package/assets/debug-dialog.js +2 -2
- package/assets/worker.js +17 -0
- package/index.d.ts +1 -3
- package/package.json +4 -6
- package/plugins/cdn-streaming/cdn-streaming.esm.js +1 -1
- package/plugins/cdn-streaming/cdn-streaming.umd.js +1 -3
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/cross-room.esm.js +1 -1
- package/plugins/cross-room/cross-room.umd.js +1 -3
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/custom-encryption.esm.js +1 -1
- package/plugins/custom-encryption/custom-encryption.umd.js +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/device-detector.esm.d.ts +1 -2
- package/plugins/device-detector/device-detector.esm.js +31 -19
- package/plugins/device-detector/device-detector.umd.js +14 -4
- package/plugins/device-detector/package.json +1 -1
- package/plugins/small-stream-auto-switcher/package.json +1 -1
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.esm.js +1 -1
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.umd.js +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-decoder/video-decoder.esm.js +1 -1
- package/plugins/video-decoder/video-decoder.umd.js +1 -3
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +1 -3
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/beauty.esm.js +1 -1
- package/plugins/video-effect/beauty/beauty.umd.js +1 -3
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/video-mixer/package.json +1 -1
- package/plugins/video-effect/video-mixer/video-mixer.umd.js +1 -1
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.esm.js +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.umd.js +1 -3
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/video-effect/watermark/watermark.umd.js +1 -3
- package/plugins/voice-changer/package.json +1 -1
- package/plugins/voice-changer/voice-changer.esm.js +1 -1
- package/plugins/voice-changer/voice-changer.umd.js +1 -3
- package/trtc.esm.js +64 -43
- package/trtc.js +1 -1
- package/plugins/chorus/chorus.esm.d.ts +0 -13
- package/plugins/chorus/chorus.esm.js +0 -1
- package/plugins/chorus/chorus.umd.js +0 -3
- package/plugins/chorus/package.json +0 -29
|
@@ -1,3 +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).CDNStreaming=e()}(this,function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,o=Array(e);r<e;r++)o[r]=t[r];return o}function e(t,e,r,o,n,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(o,n)}function r(t){return function(){var r=this,o=arguments;return new Promise(function(n,i){var a=t.apply(r,o);function s(t){e(a,n,i,s,u,"next",t)}function u(t){e(a,n,i,s,u,"throw",t)}s(void 0)})}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,u(o.key),o)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(e,r){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,r){if(e){if("string"==typeof e)return t(e,r);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,r):void 0}}(e))||r){o&&(e=o);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(t){throw t},f:i}}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 a,s=!0,u=!1;return{s:function(){o=o.call(e)},n:function(){var t=o.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==o.return||o.return()}finally{if(u)throw a}}}}function a(){
|
|
2
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var t,e,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",n=r.toStringTag||"@@toStringTag";function i(r,o,n,i){var a=o&&o.prototype instanceof c?o:c,d=Object.create(a.prototype);return s(d,"_invoke",function(r,o,n){var i,a,s,c=0,d=n||[],h=!1,l={p:0,n:0,v:t,a:m,f:m.bind(t,4),d:function(e,r){return i=e,a=0,s=t,l.n=r,u}};function m(r,o){for(a=r,s=o,e=0;!h&&c&&!n&&e<d.length;e++){var n,i=d[e],m=l.p,p=i[2];r>3?(n=p===o)&&(s=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=m&&((n=r<2&&m<i[1])?(a=0,l.v=o,l.n=i[1]):m<p&&(n=r<3||i[0]>o||o>p)&&(i[4]=r,i[5]=o,l.n=p,a=0))}if(n||r>1)return u;throw h=!0,o}return function(n,d,p){if(c>1)throw TypeError("Generator is already running");for(h&&1===d&&m(d,p),a=d,s=p;(e=a<2?t:s)||!h;){i||(a?a<3?(a>1&&(l.n=-1),m(a,s)):l.n=s:l.v=s);try{if(c=2,i){if(a||(n="next"),e=i[n]){if(!(e=e.call(i,s)))throw TypeError("iterator result is not an object");if(!e.done)return e;s=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(s=TypeError("The iterator does not provide a '"+n+"' method"),a=1);i=t}else if((e=(h=l.n<0)?s:r.call(o,l))!==u)break}catch(e){i=t,a=1,s=e}finally{c=1}}return{value:e,done:h}}}(r,n,i),!0),d}var u={};function c(){}function d(){}function h(){}e=Object.getPrototypeOf;var l=[][o]?e(e([][o]())):(s(e={},o,function(){return this}),e),m=h.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,s(t,n,"GeneratorFunction")),t.prototype=Object.create(m),t}return d.prototype=h,s(m,"constructor",h),s(h,"constructor",d),d.displayName="GeneratorFunction",s(h,n,"GeneratorFunction"),s(m),s(m,n,"Generator"),s(m,o,function(){return this}),s(m,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:p}})()}function s(t,e,r,o){var n=Object.defineProperty;try{n({},"",{})}catch(t){n=0}s=function(t,e,r,o){if(e)n?n(t,e,{value:r,enumerable:!o,configurable:!o,writable:!o}):t[e]=r;else{function i(e,r){s(t,e,function(t){return this._invoke(e,r,t)})}i("next",0),i("throw",1),i("return",2)}},s(t,e,r,o)}function u(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e);if("object"!=typeof o)return o;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)}var d,h,l,m=Object.create,p=Object.defineProperty,f=Object.defineProperties,g=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols,y=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,C=function(t,e,r){return e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},D=function(t,e){for(var r in e||(e={}))S.call(e,r)&&C(t,r,e[r]);if(_){var o,n=i(_(e));try{for(n.s();!(o=n.n()).done;){r=o.value;I.call(e,r)&&C(t,r,e[r])}}catch(t){n.e(t)}finally{n.f()}}return t},N=function(t,e){return f(t,v(e))},P=function(t,e,r){return r=null!=t?m(y(t)):{},function(t,e,r,o){if(e&&"object"===c(e)||"function"==typeof e){var n,a=i(b(e));try{var s=function(){var i=n.value;S.call(t,i)||i===r||p(t,i,{get:function(){return e[i]},enumerable:!(o=g(e,i))||o.enumerable})};for(a.s();!(n=a.n()).done;)s()}catch(t){a.e(t)}finally{a.f()}}return t}(p(r,"default",{value:t,enumerable:!0}),t)},T=function(t,e,r){return C(t,"symbol"!==c(e)?e+"":e,r)},w=(d={"../node_modules/.pnpm/blueimp-md5@2.19.0/node_modules/blueimp-md5/js/md5.js":function(t,e){!function(t){function r(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function o(t,e,o,n,i,a){return r((s=r(r(e,t),r(n,a)))<<(u=i)|s>>>32-u,o);var s,u}function n(t,e,r,n,i,a,s){return o(e&r|~e&n,t,e,i,a,s)}function i(t,e,r,n,i,a,s){return o(e&n|r&~n,t,e,i,a,s)}function a(t,e,r,n,i,a,s){return o(e^r^n,t,e,i,a,s)}function s(t,e,r,n,i,a,s){return o(r^(e|~n),t,e,i,a,s)}function u(t,e){var o,u,c,d,h;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var l=1732584193,m=-271733879,p=-1732584194,f=271733878;for(o=0;o<t.length;o+=16)u=l,c=m,d=p,h=f,l=n(l,m,p,f,t[o],7,-680876936),f=n(f,l,m,p,t[o+1],12,-389564586),p=n(p,f,l,m,t[o+2],17,606105819),m=n(m,p,f,l,t[o+3],22,-1044525330),l=n(l,m,p,f,t[o+4],7,-176418897),f=n(f,l,m,p,t[o+5],12,1200080426),p=n(p,f,l,m,t[o+6],17,-1473231341),m=n(m,p,f,l,t[o+7],22,-45705983),l=n(l,m,p,f,t[o+8],7,1770035416),f=n(f,l,m,p,t[o+9],12,-1958414417),p=n(p,f,l,m,t[o+10],17,-42063),m=n(m,p,f,l,t[o+11],22,-1990404162),l=n(l,m,p,f,t[o+12],7,1804603682),f=n(f,l,m,p,t[o+13],12,-40341101),p=n(p,f,l,m,t[o+14],17,-1502002290),l=i(l,m=n(m,p,f,l,t[o+15],22,1236535329),p,f,t[o+1],5,-165796510),f=i(f,l,m,p,t[o+6],9,-1069501632),p=i(p,f,l,m,t[o+11],14,643717713),m=i(m,p,f,l,t[o],20,-373897302),l=i(l,m,p,f,t[o+5],5,-701558691),f=i(f,l,m,p,t[o+10],9,38016083),p=i(p,f,l,m,t[o+15],14,-660478335),m=i(m,p,f,l,t[o+4],20,-405537848),l=i(l,m,p,f,t[o+9],5,568446438),f=i(f,l,m,p,t[o+14],9,-1019803690),p=i(p,f,l,m,t[o+3],14,-187363961),m=i(m,p,f,l,t[o+8],20,1163531501),l=i(l,m,p,f,t[o+13],5,-1444681467),f=i(f,l,m,p,t[o+2],9,-51403784),p=i(p,f,l,m,t[o+7],14,1735328473),l=a(l,m=i(m,p,f,l,t[o+12],20,-1926607734),p,f,t[o+5],4,-378558),f=a(f,l,m,p,t[o+8],11,-2022574463),p=a(p,f,l,m,t[o+11],16,1839030562),m=a(m,p,f,l,t[o+14],23,-35309556),l=a(l,m,p,f,t[o+1],4,-1530992060),f=a(f,l,m,p,t[o+4],11,1272893353),p=a(p,f,l,m,t[o+7],16,-155497632),m=a(m,p,f,l,t[o+10],23,-1094730640),l=a(l,m,p,f,t[o+13],4,681279174),f=a(f,l,m,p,t[o],11,-358537222),p=a(p,f,l,m,t[o+3],16,-722521979),m=a(m,p,f,l,t[o+6],23,76029189),l=a(l,m,p,f,t[o+9],4,-640364487),f=a(f,l,m,p,t[o+12],11,-421815835),p=a(p,f,l,m,t[o+15],16,530742520),l=s(l,m=a(m,p,f,l,t[o+2],23,-995338651),p,f,t[o],6,-198630844),f=s(f,l,m,p,t[o+7],10,1126891415),p=s(p,f,l,m,t[o+14],15,-1416354905),m=s(m,p,f,l,t[o+5],21,-57434055),l=s(l,m,p,f,t[o+12],6,1700485571),f=s(f,l,m,p,t[o+3],10,-1894986606),p=s(p,f,l,m,t[o+10],15,-1051523),m=s(m,p,f,l,t[o+1],21,-2054922799),l=s(l,m,p,f,t[o+8],6,1873313359),f=s(f,l,m,p,t[o+15],10,-30611744),p=s(p,f,l,m,t[o+6],15,-1560198380),m=s(m,p,f,l,t[o+13],21,1309151649),l=s(l,m,p,f,t[o+4],6,-145523070),f=s(f,l,m,p,t[o+11],10,-1120210379),p=s(p,f,l,m,t[o+2],15,718787259),m=s(m,p,f,l,t[o+9],21,-343485551),l=r(l,u),m=r(m,c),p=r(p,d),f=r(f,h);return[l,m,p,f]}function d(t){var e,r="",o=32*t.length;for(e=0;e<o;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function h(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var o=8*t.length;for(e=0;e<o;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function l(t){var e,r,o="0123456789abcdef",n="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),n+=o.charAt(e>>>4&15)+o.charAt(15&e);return n}function m(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return d(u(h(t),8*t.length))}(m(t))}function f(t,e){return function(t,e){var r,o,n=h(t),i=[],a=[];for(i[15]=a[15]=void 0,n.length>16&&(n=u(n,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^n[r],a[r]=1549556828^n[r];return o=u(i.concat(h(e)),512+8*e.length),d(u(a.concat(o),640))}(m(t),m(e))}function g(t,e,r){return e?r?f(e,t):l(f(e,t)):r?p(t):l(p(t))}"function"==typeof define&&define.amd?define(function(){return g}):"object"===c(e)&&e.exports?e.exports=g:t.md5=g}(t)}},function(){return h||(0,d[b(d)[0]])((h={exports:{}}).exports,h),h.exports}),M=P(w()),k=0,R=4,E=5,x=function(){return n(function t(e,r){o(this,t),T(this,"_core"),T(this,"_room"),T(this,"_log"),T(this,"_params"),T(this,"_publishGivenCDNData",null),this._core=e,this._room=e.room,this._log=r},[{key:"isPublishingGivenCDN",get:function(){return!!this._params}},{key:"startPublishGivenCDN",value:(e=r(a().m(function t(e){var r,o,n,i,s,u,c,d,h;return a().w(function(t){for(;;)switch(t.n){case 0:if(this._log.info("[CDNStreaming] startPublishGivenCDN() current: ".concat(JSON.stringify(this._params),", params: ").concat(JSON.stringify(e))),!this.isPublishingGivenCDN){t.n=2;break}if(r=this._params||{},o=r.appId,n=r.bizId,i=r.url,o!==e.appId||n!==e.bizId||i!==e.url){t.n=1;break}return t.a(2);case 1:return t.n=2,this.stopPublishGivenCDN();case 2:return this._params=e,this._publishGivenCDNData={pushRequestTime:Date.now(),pushAppId:e.appId,pushBizId:e.bizId,pushCdnUrl:e.url,pushStreamType:this.convertStreamType(null==e?void 0:e.publishMode),pushStreamId:e.streamId},t.p=3,t.n=4,this._room.sendStartPublishCDN(this._publishGivenCDNData,!1);case 4:if(s=t.v,u=s.data,c=u.code,d=u.message,0!==c){t.n=5;break}this._log.info("[CDNStreaming] server success: start given cdn."),t.n=6;break;case 5:throw this.resetGivenCDN(),this._log.error("[CDNStreaming] server failed: start given cdn errCode: ".concat(c," errMsg: ").concat(d," options: ").concat(JSON.stringify(e))),new Error("[CDNStreaming] server failed: start given cdn errCode: ".concat(c," errMsg: ").concat(d));case 6:t.n=8;break;case 7:throw t.p=7,h=t.v,this.resetGivenCDN(),h;case 8:return t.a(2)}},t,this,[[3,7]])})),function(t){return e.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=r(a().m(function t(){var e,r,o,n,i,s,u,c,d,h,l;return a().w(function(t){for(;;)switch(t.n){case 0:if(this._log.info("[CDNStreaming] stopPublishGivenCDN"),this.isPublishingGivenCDN&&this._publishGivenCDNData){t.n=1;break}return this.resetGivenCDN(),t.a(2);case 1:return e=this._publishGivenCDNData,r=e.pushAppId,o=e.pushBizId,n=e.pushCdnUrl,i=e.pushStreamType,s=e.pushStreamId,u={pushRequestTime:Date.now(),pushAppId:r,pushBizId:o,pushCdnUrl:n,pushStreamType:i,pushStreamId:s},t.n=2,this._room.sendStopPublishCDN(u,!1);case 2:if(c=t.v,d=c.data,h=d.code,l=d.message,0!==h){t.n=3;break}this._log.info("[CDNStreaming] server success: stop given cdn."),this.resetGivenCDN(),t.n=4;break;case 3:throw this._log.error("[CDNStreaming] server failed: stop given cdn errCode: ".concat(h," errMsg: ").concat(l," data: ").concat(JSON.stringify(u))),new Error("[CDNStreaming] server failed: stop given cdn errCode: ".concat(h," errMsg: ").concat(l));case 4:return t.a(2)}},t,this)})),function(){return t.apply(this,arguments)})},{key:"resetGivenCDN",value:function(){this._publishGivenCDNData=null,this._params=void 0}},{key:"convertStreamType",value:function(t){return"publish-sub-stream-to-cdn"===t?"aux":"main"}}]);var t,e}(),O=function(){return n(function t(e,r){o(this,t),T(this,"_core"),T(this,"_room"),T(this,"_log"),T(this,"_config",null),T(this,"_data",null),T(this,"_givenCDNManager"),this._core=e,this._room=e.room,this._log=r,this.reset()},[{key:"isMixing",get:function(){return!!this._data}},{key:"isStarted",get:function(){return!!this._config}},{key:"hasCustomCDN",get:function(){var t,e,r;return(null==(t=this._config)?void 0:t.target.appId)&&(null==(e=this._config)?void 0:e.target.bizId)&&(null==(r=this._config)?void 0:r.target.url)}},{key:"startMixTranscode",value:(c=r(a().m(function t(e){var r,o,n,i,s,u,c,d,h,l;return a().w(function(t){for(;;)switch(t.n){case 0:if(this._log.info("startMixTranscode: ".concat(JSON.stringify(e))),this._config=e,this.installEvents(),this._core.room.isJoined){t.n=1;break}return t.a(2);case 1:if(t.p=1,r=this.getInputParam(e),o=this.getOutputParam(e),n=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId}),!this.isMixing||!this._data||n===this._data.outputSessionId){t.n=2;break}return this._log.info("[CDNStreaming] streamId changed, auto stop mixing before start"),t.n=2,this.doStopMixTranscode();case 2:return t.n=3,this.doStartMixTranscode({outputSessionId:n,inputParam:r,outputParam:o});case 3:if(i=e.target,s=i.appId,u=i.bizId,c=i.url,d=i.streamId,h=void 0===d?"":d,!(s&&u&&c)){t.n=4;break}return this._givenCDNManager||(this._givenCDNManager=new x(this._core,this._log)),t.n=4,this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:s,bizId:u,url:c,streamId:h});case 4:t.n=6;break;case 5:throw t.p=5,l=t.v,this.reset(),l;case 6:return t.a(2)}},t,this,[[1,5]])})),function(t){return c.apply(this,arguments)})},{key:"doStartMixTranscode",value:(u=r(a().m(function t(e){var r,o,n,i,s,u,c;return a().w(function(t){for(;;)switch(t.n){case 0:return r=e.outputSessionId,o=e.inputParam,n=e.outputParam,i={roomId:String(this._room.roomId),mcuRequestTime:Date.now(),outputSessionId:r,inputParam:o,outputParam:n},this._log.info("[CDNStreaming] doStartMixTranscode: ".concat(JSON.stringify(i))),t.n=1,this._room.sendStartMixTranscode(i);case 1:if(s=t.v,u=s.data.code,c=s.data.message,0!==u){t.n=2;break}this._log.info("[CDNStreaming] server success: start mix"),this._data=i,t.n=3;break;case 2:throw-102083===u&&(c="Please enable relayed-push in ".concat(this._core.constants.CLOUD_CONSOLE_URL," and try later, refer to ").concat(this._core.constants.DOC_URL,"tutorial-26-advanced-publish-cdn-stream.html")),this._log.error("[CDNStreaming] server failed: start mix errCode: ".concat(u," errMsg: ").concat(c)),new Error("[CDNStreaming] server failed: start mix errCode: ".concat(u," errMsg: ").concat(c));case 3:return t.a(2)}},t,this)})),function(t){return u.apply(this,arguments)})},{key:"stopMixTranscode",value:(s=r(a().m(function t(){return a().w(function(t){for(;;)switch(t.n){case 0:if(this._log.info("[CDNStreaming] stopMixTranscode"),t.p=1,!this.isStarted||!this.isMixing){t.n=3;break}return t.n=2,this.doStopMixTranscode();case 2:if(!(this._config&&this.hasCustomCDN&&this._givenCDNManager)){t.n=3;break}return t.n=3,this._givenCDNManager.stopPublishGivenCDN();case 3:t.n=5;break;case 4:throw t.p=4,t.v;case 5:this.reset();case 6:return t.a(2)}},t,this,[[1,4]])})),function(){return s.apply(this,arguments)})},{key:"doStopMixTranscode",value:(i=r(a().m(function t(){var e,r,o,n,i;return a().w(function(t){for(;;)switch(t.n){case 0:return e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType},this._log.info("[CDNStreaming] doStopMixTranscode: ".concat(JSON.stringify(e))),t.n=1,this._room.sendStopMixTranscode(e);case 1:if(r=t.v,o=r.data,n=o.code,i=o.message,0!==n){t.n=2;break}this._log.info("[CDNStreaming] server success: stop mix"),this.reset(),t.n=3;break;case 2:throw this._log.error("[CDNStreaming] server failed: stop mix errCode: ".concat(n," errMsg: ").concat(i)),new Error("[CDNStreaming] server failed: stop mix errCode: ".concat(n," errMsg: ").concat(i));case 3:return t.a(2)}},t,this)})),function(){return i.apply(this,arguments)})},{key:"reset",value:function(){this._config=null,this._data=null,this.uninstallEvents()}},{key:"installEvents",value:function(){this._core.room.on("joined",this.handleRoomJoined,this),this._core.room.on("left",this.handleRoomLeft,this)}},{key:"uninstallEvents",value:function(){this._core.room.off("joined",this.handleRoomJoined,this),this._core.room.off("left",this.handleRoomLeft,this)}},{key:"handleRoomJoined",value:(e=r(a().m(function t(){return a().w(function(t){for(;;)switch(t.n){case 0:if(this._log.info("[CDNStreaming] handleJoined: ".concat(JSON.stringify(this._config))),!this.isStarted||!this._config){t.n=1;break}return t.n=1,this.startMixTranscode(this._config);case 1:return t.a(2)}},t,this)})),function(){return e.apply(this,arguments)})},{key:"handleRoomLeft",value:(t=r(a().m(function t(){return a().w(function(t){for(;;)switch(t.n){case 0:this._log.info("[CDNStreaming] handleRoomLeft: ".concat(JSON.stringify(this._config))),this._data=null;case 1:return t.a(2)}},t,this)})),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(t){var e=t.config,r=t.userId,o=t.roomId;return this._core.utils.isString(e.target.streamId)&&e.target.streamId.length>0?e.target.streamId:(0,M.default)("".concat(o,"_").concat(r,"_main"))}},{key:"getStringRoomId",value:function(t,e){return t?String(t):e}},{key:"getInputParam",value:function(t){var e=this,r=t.mix,o=void 0===r?{}:r,n=o.audioMixUserList,i=void 0===n?[]:n,a=o.videoLayoutList,s=(void 0===a?[]:a).map(function(t){return{userId:t.fixedVideoUser.userId,roomId:e.getStringRoomId(t.fixedVideoUser.roomId,t.fixedVideoUser.strRoomId)||e._core.room.roomId,width:t.width||0,height:t.height||0,locationX:t.locationX||0,locationY:t.locationY||0,zOrder:t.zOrder||1,streamType:"sub"===t.fixedVideoStreamType?1:0,inputType:E,renderMode:t.fillMode||0}});return i.forEach(function(t){var r=e._core.room.roomId;(t.roomId||t.strRoomId)&&(r=e.getStringRoomId(t.roomId,t.strRoomId));var o=s.findIndex(function(e){return e.userId===t.userId&&e.roomId===r});-1!==o?s[o].inputType=k:s.push({userId:t.userId,roomId:t.roomId||t.strRoomId||e._core.room.roomId,inputType:R})}),s}},{key:"getOutputParam",value:function(t){var e=t.target.streamId||"",r=t.encoding,o=void 0===r?{}:r,n=t.mix,i=void 0===n?{}:n;return{streamId:e,streamType:e.length>0?1:0,width:this._core.utils.isUndefined(o.videoWidth)?640:o.videoWidth,height:this._core.utils.isUndefined(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:i.backgroundColor||0,backgroundImg:i.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}}]);var t,e,i,s,u,c}(),A=P(w()),L=function(){return n(function t(e,r){o(this,t),T(this,"_room"),T(this,"_core"),T(this,"_log"),T(this,"_paramsForTencentCDN"),T(this,"_initParamsForTencentCDN",{isPublished:!1,isStarted:!1}),this._core=e,this._room=e.room,this._log=r,this._paramsForTencentCDN=new Map([["publish-main-stream-to-cdn",this._initParamsForTencentCDN],["publish-sub-stream-to-cdn",this._initParamsForTencentCDN]])},[{key:"installEvents",value:function(){this._core.innerEmitter.on("104",this.handlePublished,this),this._core.room.on("left",this.handleRoomLeft,this)}},{key:"uninstallEvents",value:function(){this._core.innerEmitter.off("104",this.handlePublished,this),this._core.room.off("left",this.handleRoomLeft,this)}},{key:"handlePublished",value:(c=r(a().m(function t(e){var r,o,n,i;return a().w(function(t){for(;;)switch(t.n){case 0:if((r=e.track).room===this._room){t.n=1;break}return t.a(2);case 1:if(this._log.info("[CDNStreaming] handlePublished: mediaType ".concat(r.mediaType,", roomID ").concat(null==(o=null==r?void 0:r.room)?void 0:o.roomId)),1!==r.mediaType){t.n=2;break}return t.a(2);case 2:if(n=4===r.mediaType?"publish-main-stream-to-cdn":"publish-sub-stream-to-cdn",!(null==(i=this._paramsForTencentCDN.get(n)||null)?void 0:i.target)||!i.isStarted){t.n=3;break}return t.n=3,this.startPublishTencentCDN(i.target);case 3:return t.a(2)}},t,this)})),function(t){return c.apply(this,arguments)})},{key:"handleRoomLeft",value:(u=r(a().m(function t(){return a().w(function(t){for(;;)switch(t.n){case 0:this._log.info("[CDNStreaming] handleRoomLeft"),this.changeDataStatus("publish-main-stream-to-cdn",{isPublished:!1}),this.changeDataStatus("publish-sub-stream-to-cdn",{isPublished:!1});case 1:return t.a(2)}},t,this)})),function(){return u.apply(this,arguments)})},{key:"isStreamPublished",value:function(t){return"publish-main-stream-to-cdn"!==t||this._room.isMainStreamPublished?!("publish-sub-stream-to-cdn"===t&&!this._room.isAuxStreamPublished)||(this._log.info("[CDNStreaming] Sub has not already published, will auto reStart after published."),!1):(this._log.info("[CDNStreaming] Main stream has not already published, will auto reStart after published."),!1)}},{key:"changeDataStatus",value:function(t,e){var r=this._paramsForTencentCDN.get(t),o=D(D({},r),e);this._paramsForTencentCDN.set(t,o)}},{key:"startPublishTencentCDN",value:(s=r(a().m(function t(e){var r,o,n,i,s,u,c,d,h;return a().w(function(t){for(;;)switch(t.n){case 0:if(this._log.info("[CDNStreaming] startPublishTencentCDN ".concat(JSON.stringify(e))),this.installEvents(),this.changeDataStatus(e.publishMode,{target:e,isStarted:!0}),this.isStreamPublished(e.publishMode)){t.n=1;break}return t.a(2);case 1:return r=e.streamId||"",o=this.generatePublishCDNStreamId(r,e.publishMode),n=this.generatePublishCDNSessionId(e.publishMode),i="publish-sub-stream-to-cdn"===e.publishMode?1:0,s={requestTime:Date.now(),sessionId:n,streamId:o,streamType:i},t.n=2,this.doStartPublishTencentCDN(s,e.publishMode);case 2:if(u=e.appId,c=e.bizId,d=e.url,!(u&&c&&d)){t.n=3;break}return(null==(h=this._paramsForTencentCDN.get(e.publishMode)||this._initParamsForTencentCDN)?void 0:h.givenCDNManager)||(h.givenCDNManager=new x(this._core,this._log),this._paramsForTencentCDN.set(e.publishMode,h)),t.n=3,h.givenCDNManager.startPublishGivenCDN({publishMode:e.publishMode,appId:u,bizId:c,url:d,streamId:o});case 3:return t.a(2)}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(i=r(a().m(function t(e,r){var o,n,i,s,u,c;return a().w(function(t){for(;;)switch(t.n){case 0:this._log.info("[CDNStreaming] doStartPublishTencentCDN: ".concat(JSON.stringify(e))),o=6,n=500,i=0;case 1:return t.n=2,this._room.sendStartPublishCDN(e,!0);case 2:if(s=t.v,u=s.data.code,c=s.data.message,0!==u){t.n=3;break}return this._log.info("[CDNStreaming] server success: start tencent cdn"),this.changeDataStatus(r,{isPublished:!0}),t.a(3,7);case 3:if(!(-10006===u&&i<o)){t.n=5;break}return this._log.warn("[CDNStreaming] doStartPublishTencentCDN: retry...".concat(i+1,"/6, reason: ").concat(c)),i+=1,t.n=4,new Promise(function(t){return setTimeout(t,n)});case 4:t.n=6;break;case 5:throw this.changeDataStatus(r,{isPublished:!1}),-102083===u&&(c="Please enable relayed-push in ".concat(this._core.constants.CLOUD_CONSOLE_URL," and try later, refer to ").concat(this._core.constants.DOC_URL,"tutorial-26-advanced-publish-cdn-stream.html")),this._log.error("[CDNStreaming] server failed: start tencent cdn errCode: ".concat(u," errMsg: ").concat(c)),new Error("[CDNStreaming] server failed: start tencent cdn errCode: ".concat(u," errMsg: ").concat(c));case 6:t.n=1;break;case 7:return t.a(2)}},t,this)})),function(t,e){return i.apply(this,arguments)})},{key:"stopPublishTencentCDN",value:(e=r(a().m(function t(e){var r,o;return a().w(function(t){for(;;)switch(t.n){case 0:if(this._log.info("[CDNStreaming] doStartPublishTencentCDN: ".concat(JSON.stringify(e))),!(r=this._paramsForTencentCDN.get(e)||this._initParamsForTencentCDN).isPublished){t.n=2;break}if(!((null==(o=r.target)?void 0:o.bizId)&&o.appId&&o.url&&(null==r?void 0:r.givenCDNManager))){t.n=1;break}return t.n=1,null==r?void 0:r.givenCDNManager.stopPublishGivenCDN();case 1:return t.n=2,this.doStopPublishTencentCDN(e);case 2:this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN);case 3:return t.a(2)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(t=r(a().m(function t(e){var r,o,n,i;return a().w(function(t){for(;;)switch(t.n){case 0:return r={requestTime:Date.now(),sessionId:(0,A.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(e)))},this._log.info("[CDNStreaming] doStopPublishTencentCDN: ".concat(JSON.stringify(r))),t.n=1,this._room.sendStopPublishCDN(r,!0);case 1:if(o=t.v,n=o.data.code,i=o.data.message,0!==n){t.n=2;break}this._log.info("[CDNStreaming] server success: stop tencent cdn"),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),this.reset(e),t.n=3;break;case 2:throw-102069===n&&(this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),i="can not stop in auto relayed-push mode ".concat(i)),this._log.error("[CDNStreaming] server failed: stop tencent cdn errCode: ".concat(n," errMsg: ").concat(i)),new Error("[CDNStreaming] server failed: stop tencent cdn errCode: ".concat(n," errMsg: ").concat(i));case 3:return t.a(2)}},t,this)})),function(e){return t.apply(this,arguments)})},{key:"reset",value:function(t){this.uninstallEvents(),this._paramsForTencentCDN.set(t,this._initParamsForTencentCDN)}},{key:"generatePublishCDNStreamId",value:function(t,e){if(""===t){var r="".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(e));return/^[A-Za-z\d_-]*$/.test(r)||(r=(0,A.default)(r)),"".concat(this._room.sdkAppId,"_").concat(r)}return t}},{key:"convertPublishModeToStreamType",value:function(t){return"publish-main-stream-to-cdn"===t?"main":"aux"}},{key:"generatePublishCDNSessionId",value:function(t){return(0,A.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(t)))}}]);var t,e,i,s,u,c}(),j=P(w()),G=function(){return n(function t(e,r){o(this,t),T(this,"_core"),T(this,"_room"),T(this,"_log"),T(this,"_seq"),T(this,"_taskId",null),T(this,"_startData",null),T(this,"_updateData",null),T(this,"_stopData",null),this._core=e,this._room=e.room,this._log=r,this._seq=0},[{key:"startPushStreamToRoom",value:(i=r(a().m(function t(e){var r,o,n,i,s,u;return a().w(function(t){for(;;)switch(t.n){case 0:return this._seq+=1,this._startData=D({roomid:String(this._room.roomId),roomType:this._room.useStringRoomId?1:0,sessionId:(0,j.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_start")),agentParam:{cdnRobotUserid:"mcu_robot_".concat(this._room.roomId,"_").concat(this._room.userId)}},this.getCommonParams(e)),this._log.info("startPushStreamToRoom: ".concat(JSON.stringify(this._startData))),t.n=1,this._room.sendStartPushStreamToRoom(this._startData);case 1:n=t.v,i=n.data,s=i.code,u=i.message,0===s?(this._taskId=null==(o=null==(r=n.data)?void 0:r.data)?void 0:o.taskId,this._taskId||this.reportServerError("startPushStreamToRoom",s,"can't resolve task id: ".concat(JSON.stringify(n.data))),this._log.info("[CDNStreaming] server success: taskId",this._taskId)):this.reportServerError("startPushStreamToRoom",s,u);case 2:return t.a(2)}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"updatePushStreamToRoom",value:(e=r(a().m(function t(e){var r,o,n,i;return a().w(function(t){for(;;)switch(t.n){case 0:return this._seq+=1,this._updateData=N(D({taskid:this._taskId},this.getCommonParams(e)),{enableNtpSync:!0}),this._log.info("updatePushStreamToRoom: ".concat(JSON.stringify(this._updateData))),t.n=1,this._room.sendUpdatePushStreamToRoom(this._updateData);case 1:r=t.v,o=r.data,n=o.code,i=o.message,0===n?this._log.info("server success: updatePushStreamToRoom"):this.reportServerError("updatePushStreamToRoom",n,i);case 2:return t.a(2)}},t,this)})),function(t){return e.apply(this,arguments)})},{key:"stopPushStreamToRoom",value:(t=r(a().m(function t(){var e,r,o,n;return a().w(function(t){for(;;)switch(t.n){case 0:return this._seq+=1,this._stopData={sdkappid:this._room.sdkAppId,taskid:this._taskId},this._log.info("stopPushStreamToRoom: ".concat(JSON.stringify(this._stopData))),t.n=1,this._room.sendStopPushStreamToRoom(this._stopData);case 1:e=t.v,r=e.data,o=r.code,n=r.message,0===o?this._log.info("server success: start mix"):this.reportServerError("stopPushStreamToRoom",o,n);case 2:return t.a(2)}},t,this)})),function(){return t.apply(this,arguments)})},{key:"reportServerError",value:function(t,e,r){var o="server failed: ".concat(t," errCode: ").concat(e," errMsg: ").concat(r);throw this._log.error(o),new Error(o)}},{key:"getPushRtcRoomParams",value:function(t){var e=t.target.robotUser;return e?[{roomid:String((null==e?void 0:e.roomId)||(null==e?void 0:e.strRoomId))||this._room.roomId,roomType:(null==e?void 0:e.roomId)?0:1,pushRobotUserid:null==e?void 0:e.userId}]:[]}},{key:"getCommonParams",value:function(t){return{sdkappid:this._room.sdkAppId,transcode:!0,audioParam:this.getAudioParam(t),videoParam:this.getVideoParam(t),pushRtcRoomParams:this.getPushRtcRoomParams(t),sequenceNumber:this._seq}}},{key:"getAudioParam",value:function(t){var e=this,r=t.mix,o=void 0===r?{}:r,n=t.encoding,i=void 0===n?{}:n,a={audioSamplerate:i.audioSampleRate||48e3,audioBitrateKbps:i.audioBitrate||64,audioChannels:i.audioChannels||1},s=o.audioMixUserList;return{audioEncodeParam:a,mixAudioUsers:(null==s?void 0:s.map(function(t){return{roomid:String(t.roomId||t.strRoomId)||e._room.roomId,userid:t.userId,roomType:t.roomId?0:1}}))||[]}}},{key:"getVideoParam",value:function(t){var e=this,r=t.mix,o=void 0===r?{}:r,n=t.encoding,i=void 0===n?{}:n,a={videoCodec:2,videoWidth:i.videoWidth||640,videoHeight:i.videoHeight||480,videoFramerate:i.videoFramerate||15,videoGop:i.videoGOP||2,videoBitrateKbps:i.videoBitrate||800},s=o.videoLayoutList;return{videoEncodeParam:a,layoutParams:(null==s?void 0:s.map(function(t){return{userMediaStream:{userInfo:{roomid:String(t.fixedVideoUser.roomId||t.fixedVideoUser.strRoomId)||e._room.roomId,userid:t.fixedVideoUser.userId,roomType:t.fixedVideoUser.roomId?0:1},streamType:"sub"===t.fixedVideoStreamType?1:0},imageWidth:t.width||0,imageHeight:t.height||0,locationX:t.locationX||0,locationY:t.locationY||0,imageZorder:t.zOrder||1,renderMode:t.fillMode||0}}))||[],backgroundColor:o.backgroundColor||0,backgroundImageUrl:o.backgroundImage||""}}}]);var t,e,i}();var U={type:"number",notLessThanZero:!0},V={type:"object",properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:function(t,e,r,o){var n=l,i=n.RtcError,a=n.ErrorCode,s=n.ErrorCodeDictionary;if("string"==typeof t)throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER_STRING,fnName:r,messageParams:{key:"roomId"}});if(void 0!==t&&!(/^[1-9]\d*$/.test(String(t))&&t<4294967295))throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER,fnName:r,messageParams:{key:"roomId"}})}},strRoomId:{type:"string",validate:function(t,e,r,o){var n=l,i=n.RtcError,a=n.ErrorCode,s=n.ErrorCodeDictionary;if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(t))throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_STRING,fnName:r,messageParams:{key:"strRoomId"}})}}}},q={required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]},streamId:{required:!1,type:"string",validate:function(t,e,r,o){if(!/^[A-Za-z\d_-]*$/.test(t)){var n=l,i=n.RtcError,a=n.ErrorCode,s=n.ErrorCodeDictionary;throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_STREAM_ID,messageParams:{key:"streamId"}})}}},appId:{type:"number",allowEmpty:!1},bizId:{type:"number",allowEmpty:!1},url:{type:"string",allowEmpty:!1},robotUser:D({},V)},validate:function(t,e,r,o){var n=t.publishMode,i=t.robotUser;if("publish-mix-stream-to-room"===n&&!i){var a=l;throw new(0,a.RtcError)({code:a.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter target, the value of publishMode is PublishMixStreamToRoom, robotUser is required."})}}},F={required:!1,type:"object",properties:{videoWidth:U,videoHeight:U,videoBitrate:N(D({},U),{allowEmpty:!1}),videoFramerate:{type:"number",validate:function(t,e,r,o){if(t<=0||t>30){var n=l;throw new(0,n.RtcError)({code:n.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoFramerate, the value must be between (0, 30]."})}}},videoGOP:{type:"number",validate:function(t,e,r,o){if(t<1||t>8){var n=l;throw new(0,n.RtcError)({code:n.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:U,audioBitrate:{type:"number",validate:function(t,e,r,o){if(t<32||t>192){var n=l;throw new(0,n.RtcError)({code:n.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> audioBitrate, the value must be between [32, 192]."})}}},audioChannels:{type:"number",values:[1,2]}}},J={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:D({},V)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:D({},V),fixedVideoStreamType:{type:"string",required:!0,values:["main","sub"]},fillMode:{type:"number",values:[0,1,2,4]},zOrder:{type:"number",required:!0,validate:function(t,e,r,o){if(t<1||t>15){var n=l;throw new(0,n.RtcError)({code:n.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:U,height:U,locationX:U,locationY:U}}}}};var z=0,B=function(){function t(e){o(this,t),this.core=e,T(this,"_mixTranscodeManager"),T(this,"_publishCDNManager"),T(this,"_pushStreamToRoomManager"),T(this,"_core"),T(this,"_modeOptions"),T(this,"seq"),T(this,"_log"),z+=1,this.seq=z,this._log=e.log.createChild({id:"".concat(this.getAlias()).concat(z)}),this._log.info("[CDNStreaming] created id=".concat(this.getAlias()).concat(z)),this._core=e,this._modeOptions=new Map,this._mixTranscodeManager=new O(e,this._log),this._publishCDNManager=new L(e,this._log),this._pushStreamToRoomManager=new G(e,this._log)}return n(t,[{key:"getName",value:function(){return t.Name}},{key:"getAlias",value:function(){return"cdn"}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e=this._core,l=e.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:D({},q),encoding:D({},F),mix:D({},J)},validate:function(t,r,o,n){var i,a,s=t.target.publishMode,u=t.encoding,c=t.mix;if("publish-mix-stream-to-cdn"===s){var d=e.errorModule,h=d.RtcError,l=d.ErrorCode,m=d.ErrorCodeDictionary;if(!u)throw new h({code:l.INVALID_PARAMETER,extraCode:m.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"encoding"}});if(!c)throw new h({code:l.INVALID_PARAMETER,extraCode:m.INVALID_PARAMETER_REQUIRED,fnName:o,messageParams:{key:"mix"}});if(c&&c.videoLayoutList){var p=0,f=0,g=[];if(c.videoLayoutList.forEach(function(t,e){g.push(t.fixedVideoUser.userId),t.width+t.locationX>p&&(p=t.width+t.locationX),t.height+t.locationY>f&&(f=t.height+t.locationY)}),g.indexOf(e.room.userId)<0)throw new h({code:l.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList, the value must be include self."});var v=null!=(i=null==u?void 0:u.videoWidth)?i:640,b=null!=(a=null==u?void 0:u.videoHeight)?a:480;if(v<p||b<f)throw new h({code:l.INVALID_PARAMETER,message:"Invalid parameter encoding, the width and height of the mixed video must encompass all the mixed-in video streams."})}}}};case"update":return function(t){return l=t.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:D({},q),encoding:D({},F),mix:D({},J)}}}(this._core);case"stop":return function(t){return l=t.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:{required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]}}}}}}(this._core)}var e}},{key:"getGroup",value:function(t){return t.target.publishMode}},{key:"start",value:(u=r(a().m(function t(e){return a().w(function(t){for(;;)switch(t.n){case 0:if(this._modeOptions.set(e.target.publishMode,e),"publish-mix-stream-to-room"!==e.target.publishMode){t.n=1;break}return t.a(2,this._pushStreamToRoomManager.startPushStreamToRoom(e));case 1:return t.n=2,this.doStart(e);case 2:return t.a(2,t.v)}},t,this)})),function(t){return u.apply(this,arguments)})},{key:"update",value:(s=r(a().m(function t(e){var r;return a().w(function(t){for(;;)switch(t.n){case 0:if(r=this._modeOptions.get(e.target.publishMode),this._core.utils.deepMerge(r,e),"publish-mix-stream-to-room"!==e.target.publishMode){t.n=1;break}return t.a(2,this._pushStreamToRoomManager.updatePushStreamToRoom(r));case 1:return t.n=2,this.doStart(r);case 2:return t.a(2,t.v)}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"stop",value:(i=r(a().m(function t(e){var r;return a().w(function(t){for(;;)switch(t.n){case 0:r=e.target.publishMode,t.n="publish-mix-stream-to-cdn"===r?1:"publish-main-stream-to-cdn"===r||"publish-sub-stream-to-cdn"===r?3:"publish-mix-stream-to-room"===r?5:7;break;case 1:return t.n=2,this._mixTranscodeManager.stopMixTranscode();case 2:return t.a(3,7);case 3:return t.n=4,this._publishCDNManager.stopPublishTencentCDN(e.target.publishMode);case 4:return t.a(3,7);case 5:return t.n=6,this._pushStreamToRoomManager.stopPushStreamToRoom();case 6:return t.a(3,7);case 7:this._modeOptions.delete(e.target.publishMode);case 8:return t.a(2)}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"doStart",value:(e=r(a().m(function t(e){var r;return a().w(function(t){for(;;)switch(t.n){case 0:this._log.info("[CDNStreaming] doStart: ".concat(JSON.stringify(e))),r=e.target.publishMode,t.n="publish-mix-stream-to-cdn"===r?1:"publish-main-stream-to-cdn"===r||"publish-sub-stream-to-cdn"===r?3:5;break;case 1:return t.n=2,this._mixTranscodeManager.startMixTranscode(e);case 2:case 4:return t.a(3,5);case 3:return t.n=4,this._publishCDNManager.startPublishTencentCDN(e.target);case 5:return t.a(2)}},t,this)})),function(t){return e.apply(this,arguments)})}]);var e,i,s,u}();return T(B,"TYPE",{PublishMode:{PublishMainStreamToCDN:"publish-main-stream-to-cdn",PublishSubStreamToCDN:"publish-sub-stream-to-cdn",PublishMixStreamToCDN:"publish-mix-stream-to-cdn",PublishMixStreamToRoom:"publish-mix-stream-to-room"}}),T(B,"Name","CDNStreaming"),B});
|
|
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).CDNStreaming=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 s=t[i](a),u=s.value}catch(t){return void r(t)}s.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 s(t){e(a,o,i,s,u,"next",t)}function u(t){e(a,o,i,s,u,"throw",t)}s(void 0)}))}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(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,s(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(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}}(e))||r){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(t){throw t},f:i}}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 a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var t=n.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function a(){a=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),s=new M(n||[]);return o(a,"_invoke",{value:w(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var m="suspendedStart",p="suspendedYield",f="executing",g="completed",v={};function b(){}function y(){}function _(){}var I={};h(I,s,(function(){return this}));var S=Object.getPrototypeOf,x=S&&S(S(E([])));x&&x!==r&&n.call(x,s)&&(I=x);var C=_.prototype=b.prototype=Object.create(I);function D(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function N(t,e){function r(o,i,a,s){var u=l(t[o],t,i);if("throw"!==u.type){var c=u.arg,h=c.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(h).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function w(e,r,n){var o=m;return function(i,a){if(o===f)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var u=P(s,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===m)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=f;var c=l(e,r,n);if("normal"===c.type){if(o=n.done?g:p,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=g,n.method="throw",n.arg=c.arg)}}}function P(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,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=l(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;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,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function E(e){if(e||""===e){var r=e[s];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 y.prototype=_,o(C,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:y,configurable:!0}),y.displayName=h(_,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,h(t,c,"GeneratorFunction")),t.prototype=Object.create(C),t},e.awrap=function(t){return{__await:t}},D(N.prototype),h(N.prototype,u,(function(){return this})),e.AsyncIterator=N,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new N(d(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},D(C),h(C,c,"Generator"),h(C,s,(function(){return this})),h(C,"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=E,M.prototype={constructor:M,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(T),!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 s.type="throw",s.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],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){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(!c)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,v):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),v},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),T(r),v}},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;T(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:E(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function s(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 u(t){return u="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},u(t)}var c,h,d,l=Object.create,m=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols,y=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,S=function(t,e,r){return e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},x=function(t,e){for(var r in e||(e={}))_.call(e,r)&&S(t,r,e[r]);if(b){var n,o=i(b(e));try{for(o.s();!(n=o.n()).done;){r=n.value;I.call(e,r)&&S(t,r,e[r])}}catch(t){o.e(t)}finally{o.f()}}return t},C=function(t,e){return p(t,g(e))},D=function(t,e,r){return r=null!=t?l(y(t)):{},function(t,e,r,n){if(e&&"object"===u(e)||"function"==typeof e){var o,a=i(v(e));try{var s=function(){var i=o.value;_.call(t,i)||i===r||m(t,i,{get:function(){return e[i]},enumerable:!(n=f(e,i))||n.enumerable})};for(a.s();!(o=a.n()).done;)s()}catch(t){a.e(t)}finally{a.f()}}return t}(m(r,"default",{value:t,enumerable:!0}),t)},N=function(t,e,r){return S(t,"symbol"!==u(e)?e+"":e,r)},w=(c={"../node_modules/.pnpm/blueimp-md5@2.19.0/node_modules/blueimp-md5/js/md5.js":function(t,e){!function(t){function r(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function n(t,e,n,o,i,a){return r((s=r(r(e,t),r(o,a)))<<(u=i)|s>>>32-u,n);var s,u}function o(t,e,r,o,i,a,s){return n(e&r|~e&o,t,e,i,a,s)}function i(t,e,r,o,i,a,s){return n(e&o|r&~o,t,e,i,a,s)}function a(t,e,r,o,i,a,s){return n(e^r^o,t,e,i,a,s)}function s(t,e,r,o,i,a,s){return n(r^(e|~o),t,e,i,a,s)}function c(t,e){var n,u,c,h,d;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var l=1732584193,m=-271733879,p=-1732584194,f=271733878;for(n=0;n<t.length;n+=16)u=l,c=m,h=p,d=f,l=o(l,m,p,f,t[n],7,-680876936),f=o(f,l,m,p,t[n+1],12,-389564586),p=o(p,f,l,m,t[n+2],17,606105819),m=o(m,p,f,l,t[n+3],22,-1044525330),l=o(l,m,p,f,t[n+4],7,-176418897),f=o(f,l,m,p,t[n+5],12,1200080426),p=o(p,f,l,m,t[n+6],17,-1473231341),m=o(m,p,f,l,t[n+7],22,-45705983),l=o(l,m,p,f,t[n+8],7,1770035416),f=o(f,l,m,p,t[n+9],12,-1958414417),p=o(p,f,l,m,t[n+10],17,-42063),m=o(m,p,f,l,t[n+11],22,-1990404162),l=o(l,m,p,f,t[n+12],7,1804603682),f=o(f,l,m,p,t[n+13],12,-40341101),p=o(p,f,l,m,t[n+14],17,-1502002290),l=i(l,m=o(m,p,f,l,t[n+15],22,1236535329),p,f,t[n+1],5,-165796510),f=i(f,l,m,p,t[n+6],9,-1069501632),p=i(p,f,l,m,t[n+11],14,643717713),m=i(m,p,f,l,t[n],20,-373897302),l=i(l,m,p,f,t[n+5],5,-701558691),f=i(f,l,m,p,t[n+10],9,38016083),p=i(p,f,l,m,t[n+15],14,-660478335),m=i(m,p,f,l,t[n+4],20,-405537848),l=i(l,m,p,f,t[n+9],5,568446438),f=i(f,l,m,p,t[n+14],9,-1019803690),p=i(p,f,l,m,t[n+3],14,-187363961),m=i(m,p,f,l,t[n+8],20,1163531501),l=i(l,m,p,f,t[n+13],5,-1444681467),f=i(f,l,m,p,t[n+2],9,-51403784),p=i(p,f,l,m,t[n+7],14,1735328473),l=a(l,m=i(m,p,f,l,t[n+12],20,-1926607734),p,f,t[n+5],4,-378558),f=a(f,l,m,p,t[n+8],11,-2022574463),p=a(p,f,l,m,t[n+11],16,1839030562),m=a(m,p,f,l,t[n+14],23,-35309556),l=a(l,m,p,f,t[n+1],4,-1530992060),f=a(f,l,m,p,t[n+4],11,1272893353),p=a(p,f,l,m,t[n+7],16,-155497632),m=a(m,p,f,l,t[n+10],23,-1094730640),l=a(l,m,p,f,t[n+13],4,681279174),f=a(f,l,m,p,t[n],11,-358537222),p=a(p,f,l,m,t[n+3],16,-722521979),m=a(m,p,f,l,t[n+6],23,76029189),l=a(l,m,p,f,t[n+9],4,-640364487),f=a(f,l,m,p,t[n+12],11,-421815835),p=a(p,f,l,m,t[n+15],16,530742520),l=s(l,m=a(m,p,f,l,t[n+2],23,-995338651),p,f,t[n],6,-198630844),f=s(f,l,m,p,t[n+7],10,1126891415),p=s(p,f,l,m,t[n+14],15,-1416354905),m=s(m,p,f,l,t[n+5],21,-57434055),l=s(l,m,p,f,t[n+12],6,1700485571),f=s(f,l,m,p,t[n+3],10,-1894986606),p=s(p,f,l,m,t[n+10],15,-1051523),m=s(m,p,f,l,t[n+1],21,-2054922799),l=s(l,m,p,f,t[n+8],6,1873313359),f=s(f,l,m,p,t[n+15],10,-30611744),p=s(p,f,l,m,t[n+6],15,-1560198380),m=s(m,p,f,l,t[n+13],21,1309151649),l=s(l,m,p,f,t[n+4],6,-145523070),f=s(f,l,m,p,t[n+11],10,-1120210379),p=s(p,f,l,m,t[n+2],15,718787259),m=s(m,p,f,l,t[n+9],21,-343485551),l=r(l,u),m=r(m,c),p=r(p,h),f=r(f,d);return[l,m,p,f]}function h(t){var e,r="",n=32*t.length;for(e=0;e<n;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function d(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function l(t){var e,r,n="0123456789abcdef",o="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),o+=n.charAt(e>>>4&15)+n.charAt(15&e);return o}function m(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return h(c(d(t),8*t.length))}(m(t))}function f(t,e){return function(t,e){var r,n,o=d(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=c(o,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^o[r],a[r]=1549556828^o[r];return n=c(i.concat(d(e)),512+8*e.length),h(c(a.concat(n),640))}(m(t),m(e))}function g(t,e,r){return e?r?f(e,t):l(f(e,t)):r?p(t):l(p(t))}"function"==typeof define&&define.amd?define((function(){return g})):"object"===u(e)&&e.exports?e.exports=g:t.md5=g}(t)}},function(){return h||(0,c[v(c)[0]])((h={exports:{}}).exports,h),h.exports}),P=D(w()),k=0,T=4,M=5,E=function(){return o((function t(e,r){n(this,t),N(this,"_core"),N(this,"_room"),N(this,"_log"),N(this,"_params"),N(this,"_publishGivenCDNData",null),this._core=e,this._room=e.room,this._log=r}),[{key:"isPublishingGivenCDN",get:function(){return!!this._params}},{key:"startPublishGivenCDN",value:(e=r(a().mark((function t(e){var r,n,o,i,s,u,c,h;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("[CDNStreaming] startPublishGivenCDN() current: ".concat(JSON.stringify(this._params),", params: ").concat(JSON.stringify(e))),!this.isPublishingGivenCDN){t.next=7;break}if(r=this._params||{},n=r.appId,o=r.bizId,i=r.url,n!==e.appId||o!==e.bizId||i!==e.url){t.next=5;break}return t.abrupt("return");case 5:return t.next=7,this.stopPublishGivenCDN();case 7:return this._params=e,this._publishGivenCDNData={pushRequestTime:Date.now(),pushAppId:e.appId,pushBizId:e.bizId,pushCdnUrl:e.url,pushStreamType:this.convertStreamType(null==e?void 0:e.publishMode),pushStreamId:e.streamId},t.prev=9,t.next=12,this._room.sendStartPublishCDN(this._publishGivenCDNData,!1);case 12:if(s=t.sent,u=s.data,c=u.code,h=u.message,0!==c){t.next=18;break}this._log.info("[CDNStreaming] server success: start given cdn."),t.next=21;break;case 18:throw this.resetGivenCDN(),this._log.error("[CDNStreaming] server failed: start given cdn errCode: ".concat(c," errMsg: ").concat(h," options: ").concat(JSON.stringify(e))),new Error("[CDNStreaming] server failed: start given cdn errCode: ".concat(c," errMsg: ").concat(h));case 21:t.next=27;break;case 23:throw t.prev=23,t.t0=t.catch(9),this.resetGivenCDN(),t.t0;case 27:case"end":return t.stop()}}),t,this,[[9,23]])}))),function(t){return e.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=r(a().mark((function t(){var e,r,n,o,i,s,u,c,h,d,l;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("[CDNStreaming] stopPublishGivenCDN"),this.isPublishingGivenCDN&&this._publishGivenCDNData){t.next=4;break}return this.resetGivenCDN(),t.abrupt("return");case 4:return e=this._publishGivenCDNData,r=e.pushAppId,n=e.pushBizId,o=e.pushCdnUrl,i=e.pushStreamType,s=e.pushStreamId,u={pushRequestTime:Date.now(),pushAppId:r,pushBizId:n,pushCdnUrl:o,pushStreamType:i,pushStreamId:s},t.next=8,this._room.sendStopPublishCDN(u,!1);case 8:if(c=t.sent,h=c.data,d=h.code,l=h.message,0!==d){t.next=15;break}this._log.info("[CDNStreaming] server success: stop given cdn."),this.resetGivenCDN(),t.next=17;break;case 15:throw this._log.error("[CDNStreaming] server failed: stop given cdn errCode: ".concat(d," errMsg: ").concat(l," data: ").concat(JSON.stringify(u))),new Error("[CDNStreaming] server failed: stop given cdn errCode: ".concat(d," errMsg: ").concat(l));case 17:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"resetGivenCDN",value:function(){this._publishGivenCDNData=null,this._params=void 0}},{key:"convertStreamType",value:function(t){return"publish-sub-stream-to-cdn"===t?"aux":"main"}}]);var t,e}(),R=function(){return o((function t(e,r){n(this,t),N(this,"_core"),N(this,"_room"),N(this,"_log"),N(this,"_config",null),N(this,"_data",null),N(this,"_givenCDNManager"),this._core=e,this._room=e.room,this._log=r,this.reset()}),[{key:"isMixing",get:function(){return!!this._data}},{key:"isStarted",get:function(){return!!this._config}},{key:"hasCustomCDN",get:function(){var t,e,r;return(null==(t=this._config)?void 0:t.target.appId)&&(null==(e=this._config)?void 0:e.target.bizId)&&(null==(r=this._config)?void 0:r.target.url)}},{key:"startMixTranscode",value:(c=r(a().mark((function t(e){var r,n,o,i,s,u,c,h,d;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("startMixTranscode: ".concat(JSON.stringify(e))),this._config=e,this.installEvents(),this._core.room.isJoined){t.next=5;break}return t.abrupt("return");case 5:if(t.prev=5,r=this.getInputParam(e),n=this.getOutputParam(e),o=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId}),!this.isMixing||!this._data||o===this._data.outputSessionId){t.next=13;break}return this._log.info("[CDNStreaming] streamId changed, auto stop mixing before start"),t.next=13,this.doStopMixTranscode();case 13:return t.next=15,this.doStartMixTranscode({outputSessionId:o,inputParam:r,outputParam:n});case 15:if(i=e.target,s=i.appId,u=i.bizId,c=i.url,h=i.streamId,d=void 0===h?"":h,!(s&&u&&c)){t.next=20;break}return this._givenCDNManager||(this._givenCDNManager=new E(this._core,this._log)),t.next=20,this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:s,bizId:u,url:c,streamId:d});case 20:t.next=26;break;case 22:throw t.prev=22,t.t0=t.catch(5),this.reset(),t.t0;case 26:case"end":return t.stop()}}),t,this,[[5,22]])}))),function(t){return c.apply(this,arguments)})},{key:"doStartMixTranscode",value:(u=r(a().mark((function t(e){var r,n,o,i,s,u,c;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.outputSessionId,n=e.inputParam,o=e.outputParam,i={roomId:String(this._room.roomId),mcuRequestTime:Date.now(),outputSessionId:r,inputParam:n,outputParam:o},this._log.info("[CDNStreaming] doStartMixTranscode: ".concat(JSON.stringify(i))),t.next=5,this._room.sendStartMixTranscode(i);case 5:if(s=t.sent,u=s.data.code,c=s.data.message,0!==u){t.next=13;break}this._log.info("[CDNStreaming] server success: start mix"),this._data=i,t.next=16;break;case 13:throw-102083===u&&(c="Please enable relayed-push in ".concat(this._core.constants.CLOUD_CONSOLE_URL," and try later, refer to ").concat(this._core.constants.DOC_URL,"tutorial-26-advanced-publish-cdn-stream.html")),this._log.error("[CDNStreaming] server failed: start mix errCode: ".concat(u," errMsg: ").concat(c)),new Error("[CDNStreaming] server failed: start mix errCode: ".concat(u," errMsg: ").concat(c));case 16:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"stopMixTranscode",value:(s=r(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("[CDNStreaming] stopMixTranscode"),t.prev=1,!this.isStarted||!this.isMixing){t.next=8;break}return t.next=5,this.doStopMixTranscode();case 5:if(!(this._config&&this.hasCustomCDN&&this._givenCDNManager)){t.next=8;break}return t.next=8,this._givenCDNManager.stopPublishGivenCDN();case 8:t.next=13;break;case 10:throw t.prev=10,t.t0=t.catch(1),t.t0;case 13:this.reset();case 14:case"end":return t.stop()}}),t,this,[[1,10]])}))),function(){return s.apply(this,arguments)})},{key:"doStopMixTranscode",value:(i=r(a().mark((function t(){var e,r,n,o,i;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType},this._log.info("[CDNStreaming] doStopMixTranscode: ".concat(JSON.stringify(e))),t.next=4,this._room.sendStopMixTranscode(e);case 4:if(r=t.sent,n=r.data,o=n.code,i=n.message,0!==o){t.next=11;break}this._log.info("[CDNStreaming] server success: stop mix"),this.reset(),t.next=13;break;case 11:throw this._log.error("[CDNStreaming] server failed: stop mix errCode: ".concat(o," errMsg: ").concat(i)),new Error("[CDNStreaming] server failed: stop mix errCode: ".concat(o," errMsg: ").concat(i));case 13:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"reset",value:function(){this._config=null,this._data=null,this.uninstallEvents()}},{key:"installEvents",value:function(){this._core.room.on("joined",this.handleRoomJoined,this),this._core.room.on("left",this.handleRoomLeft,this)}},{key:"uninstallEvents",value:function(){this._core.room.off("joined",this.handleRoomJoined,this),this._core.room.off("left",this.handleRoomLeft,this)}},{key:"handleRoomJoined",value:(e=r(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("[CDNStreaming] handleJoined: ".concat(JSON.stringify(this._config))),!this.isStarted||!this._config){t.next=4;break}return t.next=4,this.startMixTranscode(this._config);case 4:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"handleRoomLeft",value:(t=r(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._log.info("[CDNStreaming] handleRoomLeft: ".concat(JSON.stringify(this._config))),this._data=null;case 2:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(t){var e=t.config,r=t.userId,n=t.roomId;return this._core.utils.isString(e.target.streamId)&&e.target.streamId.length>0?e.target.streamId:(0,P.default)("".concat(n,"_").concat(r,"_main"))}},{key:"getStringRoomId",value:function(t,e){return t?String(t):e}},{key:"getInputParam",value:function(t){var e=this,r=t.mix,n=void 0===r?{}:r,o=n.audioMixUserList,i=void 0===o?[]:o,a=n.videoLayoutList,s=(void 0===a?[]:a).map((function(t){return{userId:t.fixedVideoUser.userId,roomId:e.getStringRoomId(t.fixedVideoUser.roomId,t.fixedVideoUser.strRoomId)||e._core.room.roomId,width:t.width||0,height:t.height||0,locationX:t.locationX||0,locationY:t.locationY||0,zOrder:t.zOrder||1,streamType:"sub"===t.fixedVideoStreamType?1:0,inputType:M,renderMode:t.fillMode||0}}));return i.forEach((function(t){var r=e._core.room.roomId;(t.roomId||t.strRoomId)&&(r=e.getStringRoomId(t.roomId,t.strRoomId));var n=s.findIndex((function(e){return e.userId===t.userId&&e.roomId===r}));-1!==n?s[n].inputType=k:s.push({userId:t.userId,roomId:t.roomId||t.strRoomId||e._core.room.roomId,inputType:T})})),s}},{key:"getOutputParam",value:function(t){var e=t.target.streamId||"",r=t.encoding,n=void 0===r?{}:r,o=t.mix,i=void 0===o?{}:o;return{streamId:e,streamType:e.length>0?1:0,width:this._core.utils.isUndefined(n.videoWidth)?640:n.videoWidth,height:this._core.utils.isUndefined(n.videoHeight)?480:n.videoHeight,videoBps:n.videoBitrate||0,fps:n.videoFramerate||15,gop:n.videoGOP||2,audioSampleRate:n.audioSampleRate||48e3,audioBps:n.audioBitrate||64,audioChannels:n.audioChannels||1,backgroundColor:i.backgroundColor||0,backgroundImg:i.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}}]);var t,e,i,s,u,c}(),O=D(w()),L=function(){return o((function t(e,r){n(this,t),N(this,"_room"),N(this,"_core"),N(this,"_log"),N(this,"_paramsForTencentCDN"),N(this,"_initParamsForTencentCDN",{isPublished:!1,isStarted:!1}),this._core=e,this._room=e.room,this._log=r,this._paramsForTencentCDN=new Map([["publish-main-stream-to-cdn",this._initParamsForTencentCDN],["publish-sub-stream-to-cdn",this._initParamsForTencentCDN]])}),[{key:"installEvents",value:function(){this._core.innerEmitter.on("104",this.handlePublished,this),this._core.room.on("left",this.handleRoomLeft,this)}},{key:"uninstallEvents",value:function(){this._core.innerEmitter.off("104",this.handlePublished,this),this._core.room.off("left",this.handleRoomLeft,this)}},{key:"handlePublished",value:(c=r(a().mark((function t(e){var r,n,o,i;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((r=e.track).room===this._room){t.next=3;break}return t.abrupt("return");case 3:if(this._log.info("[CDNStreaming] handlePublished: mediaType ".concat(r.mediaType,", roomID ").concat(null==(n=null==r?void 0:r.room)?void 0:n.roomId)),1!==r.mediaType){t.next=6;break}return t.abrupt("return");case 6:if(o=4===r.mediaType?"publish-main-stream-to-cdn":"publish-sub-stream-to-cdn",!(null==(i=this._paramsForTencentCDN.get(o)||null)?void 0:i.target)||!i.isStarted){t.next=11;break}return t.next=11,this.startPublishTencentCDN(i.target);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"handleRoomLeft",value:(u=r(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._log.info("[CDNStreaming] handleRoomLeft"),this.changeDataStatus("publish-main-stream-to-cdn",{isPublished:!1}),this.changeDataStatus("publish-sub-stream-to-cdn",{isPublished:!1});case 3:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"isStreamPublished",value:function(t){return"publish-main-stream-to-cdn"!==t||this._room.isMainStreamPublished?!("publish-sub-stream-to-cdn"===t&&!this._room.isAuxStreamPublished)||(this._log.info("[CDNStreaming] Sub has not already published, will auto reStart after published."),!1):(this._log.info("[CDNStreaming] Main stream has not already published, will auto reStart after published."),!1)}},{key:"changeDataStatus",value:function(t,e){var r=this._paramsForTencentCDN.get(t),n=x(x({},r),e);this._paramsForTencentCDN.set(t,n)}},{key:"startPublishTencentCDN",value:(s=r(a().mark((function t(e){var r,n,o,i,s,u,c,h,d;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("[CDNStreaming] startPublishTencentCDN ".concat(JSON.stringify(e))),this.installEvents(),this.changeDataStatus(e.publishMode,{target:e,isStarted:!0}),this.isStreamPublished(e.publishMode)){t.next=5;break}return t.abrupt("return");case 5:return r=e.streamId||"",n=this.generatePublishCDNStreamId(r,e.publishMode),o=this.generatePublishCDNSessionId(e.publishMode),i="publish-sub-stream-to-cdn"===e.publishMode?1:0,s={requestTime:Date.now(),sessionId:o,streamId:n,streamType:i},t.next=12,this.doStartPublishTencentCDN(s,e.publishMode);case 12:if(u=e.appId,c=e.bizId,h=e.url,!(u&&c&&h)){t.next=18;break}return(null==(d=this._paramsForTencentCDN.get(e.publishMode)||this._initParamsForTencentCDN)?void 0:d.givenCDNManager)||(d.givenCDNManager=new E(this._core,this._log),this._paramsForTencentCDN.set(e.publishMode,d)),t.next=18,d.givenCDNManager.startPublishGivenCDN({publishMode:e.publishMode,appId:u,bizId:c,url:h,streamId:n});case 18:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(i=r(a().mark((function t(e,r){var n,o,i,s,u,c;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._log.info("[CDNStreaming] doStartPublishTencentCDN: ".concat(JSON.stringify(e))),n=6,o=500,i=0;case 4:return t.next=7,this._room.sendStartPublishCDN(e,!0);case 7:if(s=t.sent,u=s.data.code,c=s.data.message,0!==u){t.next=16;break}return this._log.info("[CDNStreaming] server success: start tencent cdn"),this.changeDataStatus(r,{isPublished:!0}),t.abrupt("break",29);case 16:if(!(-10006===u&&i<n)){t.next=23;break}return this._log.warn("[CDNStreaming] doStartPublishTencentCDN: retry...".concat(i+1,"/6, reason: ").concat(c)),i+=1,t.next=21,new Promise((function(t){return setTimeout(t,o)}));case 21:t.next=27;break;case 23:throw this.changeDataStatus(r,{isPublished:!1}),-102083===u&&(c="Please enable relayed-push in ".concat(this._core.constants.CLOUD_CONSOLE_URL," and try later, refer to ").concat(this._core.constants.DOC_URL,"tutorial-26-advanced-publish-cdn-stream.html")),this._log.error("[CDNStreaming] server failed: start tencent cdn errCode: ".concat(u," errMsg: ").concat(c)),new Error("[CDNStreaming] server failed: start tencent cdn errCode: ".concat(u," errMsg: ").concat(c));case 27:t.next=4;break;case 29:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"stopPublishTencentCDN",value:(e=r(a().mark((function t(e){var r,n;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("[CDNStreaming] doStartPublishTencentCDN: ".concat(JSON.stringify(e))),!(r=this._paramsForTencentCDN.get(e)||this._initParamsForTencentCDN).isPublished){t.next=9;break}if(!((null==(n=r.target)?void 0:n.bizId)&&n.appId&&n.url&&(null==r?void 0:r.givenCDNManager))){t.next=7;break}return t.next=7,null==r?void 0:r.givenCDNManager.stopPublishGivenCDN();case 7:return t.next=9,this.doStopPublishTencentCDN(e);case 9:this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN);case 10:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(t=r(a().mark((function t(e){var r,n,o,i;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={requestTime:Date.now(),sessionId:(0,O.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(e)))},this._log.info("[CDNStreaming] doStopPublishTencentCDN: ".concat(JSON.stringify(r))),t.next=4,this._room.sendStopPublishCDN(r,!0);case 4:if(n=t.sent,o=n.data.code,i=n.data.message,0!==o){t.next=13;break}this._log.info("[CDNStreaming] server success: stop tencent cdn"),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),this.reset(e),t.next=16;break;case 13:throw-102069===o&&(this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),i="can not stop in auto relayed-push mode ".concat(i)),this._log.error("[CDNStreaming] server failed: stop tencent cdn errCode: ".concat(o," errMsg: ").concat(i)),new Error("[CDNStreaming] server failed: stop tencent cdn errCode: ".concat(o," errMsg: ").concat(i));case 16:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})},{key:"reset",value:function(t){this.uninstallEvents(),this._paramsForTencentCDN.set(t,this._initParamsForTencentCDN)}},{key:"generatePublishCDNStreamId",value:function(t,e){if(""===t){var r="".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(e));return/^[A-Za-z\d_-]*$/.test(r)||(r=(0,O.default)(r)),"".concat(this._room.sdkAppId,"_").concat(r)}return t}},{key:"convertPublishModeToStreamType",value:function(t){return"publish-main-stream-to-cdn"===t?"main":"aux"}},{key:"generatePublishCDNSessionId",value:function(t){return(0,O.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(t)))}}]);var t,e,i,s,u,c}(),A=D(w()),j=function(){return o((function t(e,r){n(this,t),N(this,"_core"),N(this,"_room"),N(this,"_log"),N(this,"_seq"),N(this,"_taskId",null),N(this,"_startData",null),N(this,"_updateData",null),N(this,"_stopData",null),this._core=e,this._room=e.room,this._log=r,this._seq=0}),[{key:"startPushStreamToRoom",value:(i=r(a().mark((function t(e){var r,n,o,i,s,u;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._seq+=1,this._startData=x({roomid:String(this._room.roomId),roomType:this._room.useStringRoomId?1:0,sessionId:(0,A.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_start")),agentParam:{cdnRobotUserid:"mcu_robot_".concat(this._room.roomId,"_").concat(this._room.userId)}},this.getCommonParams(e)),this._log.info("startPushStreamToRoom: ".concat(JSON.stringify(this._startData))),t.next=5,this._room.sendStartPushStreamToRoom(this._startData);case 5:o=t.sent,i=o.data,s=i.code,u=i.message,0===s?(this._taskId=null==(n=null==(r=o.data)?void 0:r.data)?void 0:n.taskId,this._taskId||this.reportServerError("startPushStreamToRoom",s,"can't resolve task id: ".concat(JSON.stringify(o.data))),this._log.info("[CDNStreaming] server success: taskId",this._taskId)):this.reportServerError("startPushStreamToRoom",s,u);case 8:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"updatePushStreamToRoom",value:(e=r(a().mark((function t(e){var r,n,o,i;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._seq+=1,this._updateData=C(x({taskid:this._taskId},this.getCommonParams(e)),{enableNtpSync:!0}),this._log.info("updatePushStreamToRoom: ".concat(JSON.stringify(this._updateData))),t.next=5,this._room.sendUpdatePushStreamToRoom(this._updateData);case 5:r=t.sent,n=r.data,o=n.code,i=n.message,0===o?this._log.info("server success: updatePushStreamToRoom"):this.reportServerError("updatePushStreamToRoom",o,i);case 8:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"stopPushStreamToRoom",value:(t=r(a().mark((function t(){var e,r,n,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._seq+=1,this._stopData={sdkappid:this._room.sdkAppId,taskid:this._taskId},this._log.info("stopPushStreamToRoom: ".concat(JSON.stringify(this._stopData))),t.next=5,this._room.sendStopPushStreamToRoom(this._stopData);case 5:e=t.sent,r=e.data,n=r.code,o=r.message,0===n?this._log.info("server success: start mix"):this.reportServerError("stopPushStreamToRoom",n,o);case 8:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"reportServerError",value:function(t,e,r){var n="server failed: ".concat(t," errCode: ").concat(e," errMsg: ").concat(r);throw this._log.error(n),new Error(n)}},{key:"getPushRtcRoomParams",value:function(t){var e=t.target.robotUser;return e?[{roomid:String((null==e?void 0:e.roomId)||(null==e?void 0:e.strRoomId))||this._room.roomId,roomType:(null==e?void 0:e.roomId)?0:1,pushRobotUserid:null==e?void 0:e.userId}]:[]}},{key:"getCommonParams",value:function(t){return{sdkappid:this._room.sdkAppId,transcode:!0,audioParam:this.getAudioParam(t),videoParam:this.getVideoParam(t),pushRtcRoomParams:this.getPushRtcRoomParams(t),sequenceNumber:this._seq}}},{key:"getAudioParam",value:function(t){var e=this,r=t.mix,n=void 0===r?{}:r,o=t.encoding,i=void 0===o?{}:o,a={audioSamplerate:i.audioSampleRate||48e3,audioBitrateKbps:i.audioBitrate||64,audioChannels:i.audioChannels||1},s=n.audioMixUserList;return{audioEncodeParam:a,mixAudioUsers:(null==s?void 0:s.map((function(t){return{roomid:String(t.roomId||t.strRoomId)||e._room.roomId,userid:t.userId,roomType:t.roomId?0:1}})))||[]}}},{key:"getVideoParam",value:function(t){var e=this,r=t.mix,n=void 0===r?{}:r,o=t.encoding,i=void 0===o?{}:o,a={videoCodec:2,videoWidth:i.videoWidth||640,videoHeight:i.videoHeight||480,videoFramerate:i.videoFramerate||15,videoGop:i.videoGOP||2,videoBitrateKbps:i.videoBitrate||800},s=n.videoLayoutList;return{videoEncodeParam:a,layoutParams:(null==s?void 0:s.map((function(t){return{userMediaStream:{userInfo:{roomid:String(t.fixedVideoUser.roomId||t.fixedVideoUser.strRoomId)||e._room.roomId,userid:t.fixedVideoUser.userId,roomType:t.fixedVideoUser.roomId?0:1},streamType:"sub"===t.fixedVideoStreamType?1:0},imageWidth:t.width||0,imageHeight:t.height||0,locationX:t.locationX||0,locationY:t.locationY||0,imageZorder:t.zOrder||1,renderMode:t.fillMode||0}})))||[],backgroundColor:n.backgroundColor||0,backgroundImageUrl:n.backgroundImage||""}}}]);var t,e,i}();var G={type:"number",notLessThanZero:!0},U={type:"object",properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:function(t,e,r,n){var o=d,i=o.RtcError,a=o.ErrorCode,s=o.ErrorCodeDictionary;if("string"==typeof t)throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER_STRING,fnName:r,messageParams:{key:"roomId"}});if(void 0!==t&&!(/^[1-9]\d*$/.test(String(t))&&t<4294967295))throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_INTEGER,fnName:r,messageParams:{key:"roomId"}})}},strRoomId:{type:"string",validate:function(t,e,r,n){var o=d,i=o.RtcError,a=o.ErrorCode,s=o.ErrorCodeDictionary;if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(t))throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_ROOM_ID_STRING,fnName:r,messageParams:{key:"strRoomId"}})}}}},V={required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]},streamId:{required:!1,type:"string",validate:function(t,e,r,n){if(!/^[A-Za-z\d_-]*$/.test(t)){var o=d,i=o.RtcError,a=o.ErrorCode,s=o.ErrorCodeDictionary;throw new i({code:a.INVALID_PARAMETER,extraCode:s.INVALID_STREAM_ID,messageParams:{key:"streamId"}})}}},appId:{type:"number",allowEmpty:!1},bizId:{type:"number",allowEmpty:!1},url:{type:"string",allowEmpty:!1},robotUser:x({},U)},validate:function(t,e,r,n){var o=t.publishMode,i=t.robotUser;if("publish-mix-stream-to-room"===o&&!i){var a=d;throw new(0,a.RtcError)({code:a.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter target, the value of publishMode is PublishMixStreamToRoom, robotUser is required."})}}},F={required:!1,type:"object",properties:{videoWidth:G,videoHeight:G,videoBitrate:C(x({},G),{allowEmpty:!1}),videoFramerate:{type:"number",validate:function(t,e,r,n){if(t<=0||t>30){var o=d;throw new(0,o.RtcError)({code:o.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoFramerate, the value must be between (0, 30]."})}}},videoGOP:{type:"number",validate:function(t,e,r,n){if(t<1||t>8){var o=d;throw new(0,o.RtcError)({code:o.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:G,audioBitrate:{type:"number",validate:function(t,e,r,n){if(t<32||t>192){var o=d;throw new(0,o.RtcError)({code:o.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> audioBitrate, the value must be between [32, 192]."})}}},audioChannels:{type:"number",values:[1,2]}}},q={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:x({},U)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:x({},U),fixedVideoStreamType:{type:"string",required:!0,values:["main","sub"]},fillMode:{type:"number",values:[0,1,2,4]},zOrder:{type:"number",required:!0,validate:function(t,e,r,n){if(t<1||t>15){var o=d;throw new(0,o.RtcError)({code:o.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:G,height:G,locationX:G,locationY:G}}}}};var J=0,z=function(){function t(e){n(this,t),this.core=e,N(this,"_mixTranscodeManager"),N(this,"_publishCDNManager"),N(this,"_pushStreamToRoomManager"),N(this,"_core"),N(this,"_modeOptions"),N(this,"seq"),N(this,"_log"),J+=1,this.seq=J,this._log=e.log.createChild({id:"".concat(this.getAlias()).concat(J)}),this._log.info("[CDNStreaming] created id=".concat(this.getAlias()).concat(J)),this._core=e,this._modeOptions=new Map,this._mixTranscodeManager=new R(e,this._log),this._publishCDNManager=new L(e,this._log),this._pushStreamToRoomManager=new j(e,this._log)}return o(t,[{key:"getName",value:function(){return t.Name}},{key:"getAlias",value:function(){return"cdn"}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e=this._core,d=e.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:x({},V),encoding:x({},F),mix:x({},q)},validate:function(t,r,n,o){var i,a,s=t.target.publishMode,u=t.encoding,c=t.mix;if("publish-mix-stream-to-cdn"===s){var h=e.errorModule,d=h.RtcError,l=h.ErrorCode,m=h.ErrorCodeDictionary;if(!u)throw new d({code:l.INVALID_PARAMETER,extraCode:m.INVALID_PARAMETER_REQUIRED,fnName:n,messageParams:{key:"encoding"}});if(!c)throw new d({code:l.INVALID_PARAMETER,extraCode:m.INVALID_PARAMETER_REQUIRED,fnName:n,messageParams:{key:"mix"}});if(c&&c.videoLayoutList){var p=0,f=0,g=[];if(c.videoLayoutList.forEach((function(t,e){g.push(t.fixedVideoUser.userId),t.width+t.locationX>p&&(p=t.width+t.locationX),t.height+t.locationY>f&&(f=t.height+t.locationY)})),g.indexOf(e.room.userId)<0)throw new d({code:l.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList, the value must be include self."});var v=null!=(i=null==u?void 0:u.videoWidth)?i:640,b=null!=(a=null==u?void 0:u.videoHeight)?a:480;if(v<p||b<f)throw new d({code:l.INVALID_PARAMETER,message:"Invalid parameter encoding, the width and height of the mixed video must encompass all the mixed-in video streams."})}}}};case"update":return function(t){return d=t.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:x({},V),encoding:x({},F),mix:x({},q)}}}(this._core);case"stop":return function(t){return d=t.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:{required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn","publish-mix-stream-to-room"]}}}}}}(this._core)}var e}},{key:"getGroup",value:function(t){return t.target.publishMode}},{key:"start",value:(u=r(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._modeOptions.set(e.target.publishMode,e),"publish-mix-stream-to-room"!==e.target.publishMode){t.next=3;break}return t.abrupt("return",this._pushStreamToRoomManager.startPushStreamToRoom(e));case 3:return t.next=5,this.doStart(e);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"update",value:(s=r(a().mark((function t(e){var r;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this._modeOptions.get(e.target.publishMode),this._core.utils.deepMerge(r,e),"publish-mix-stream-to-room"!==e.target.publishMode){t.next=4;break}return t.abrupt("return",this._pushStreamToRoomManager.updatePushStreamToRoom(r));case 4:return t.next=6,this.doStart(r);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"stop",value:(i=r(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.target.publishMode,t.next="publish-mix-stream-to-cdn"===t.t0?3:"publish-main-stream-to-cdn"===t.t0||"publish-sub-stream-to-cdn"===t.t0?6:"publish-mix-stream-to-room"===t.t0?9:11;break;case 3:return t.next=5,this._mixTranscodeManager.stopMixTranscode();case 5:return t.abrupt("break",11);case 6:return t.next=8,this._publishCDNManager.stopPublishTencentCDN(e.target.publishMode);case 8:return t.abrupt("break",11);case 9:return this._pushStreamToRoomManager.stopPushStreamToRoom(),t.abrupt("break",11);case 11:this._modeOptions.delete(e.target.publishMode);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"doStart",value:(e=r(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._log.info("[CDNStreaming] doStart: ".concat(JSON.stringify(e))),t.t0=e.target.publishMode,t.next="publish-mix-stream-to-cdn"===t.t0?4:"publish-main-stream-to-cdn"===t.t0||"publish-sub-stream-to-cdn"===t.t0?7:10;break;case 4:return t.next=6,this._mixTranscodeManager.startMixTranscode(e);case 6:case 9:return t.abrupt("break",10);case 7:return t.next=9,this._publishCDNManager.startPublishTencentCDN(e.target);case 10:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}]);var e,i,s,u}();return N(z,"TYPE",{PublishMode:{PublishMainStreamToCDN:"publish-main-stream-to-cdn",PublishSubStreamToCDN:"publish-sub-stream-to-cdn",PublishMixStreamToCDN:"publish-mix-stream-to-cdn",PublishMixStreamToRoom:"publish-mix-stream-to-room"}}),N(z,"Name","CDNStreaming"),z}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__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},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__decorateClass=(e,t,r,o)=>{for(var s,a=o>1?void 0:o?__getOwnPropDesc(t,r):t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=(o?s(t,r,a):s(a))||a);return o&&a&&__defProp(t,r,a),a},__publicField=(e,t,r)=>__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),roomIValidate={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},StartValidateRule={name:"option",required:!0,properties:__spreadProps(__spreadValues({},roomIValidate.properties),{userId:{type:"string"}})},UpdateValidateRule={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:__spreadProps(__spreadValues({},StartValidateRule.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},StopValidateRule={name:"option",properties:__spreadValues({},roomIValidate.properties)},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:o,onRetryFailed:s,onRetrySuccess:a,context:i}){return function(...n){const{retries:d=5,timeout:p=1e3}=t;let c=0,l=-1,u=RETRY_STATE_NOT_START;const _=async(t,m)=>{const R=i||this;try{const r=await e.apply(R,n);c>0&&a&&a.call(this,c),c=0,t(r)}catch(e){const a=()=>{clearTimeout(l),c=0,u=RETRY_STATE_STOPPED,m(e)},i=()=>{u!==RETRY_STATE_STOPPED&&c<(isFunction(d)?d():d)?(c++,u=RETRY_STATE_STARTED,isFunction(o)&&o.call(this,c,a),l=window.setTimeout(()=>{l=-1,_(t,m)},isFunction(p)?p(c):p)):(a(),isFunction(s)&&s.call(this,e))};isFunction(r)?r.call(this,{error:e,retry:i,reject:m,retryFuncArgs:n,retriedCount:c}):i()}};return new Promise(_)}}var retry_default=promiseRetry,retryingMap=new WeakMap;function addPromiseRetry({settings:e={retries:5,timeout:2e3},onError:t,onRetrying:r,onRetryFailed:o}){return function(s,a,i){const n=retry_default({retryFunction:i.value,settings:e,onError({error:e,retry:r,reject:o,retryFuncArgs:i}){var n;t?t.call(this,e,()=>{var t;(null==(t=retryingMap.get(s))?void 0:t.has(a))?r():o(e)},o,i):(null==(n=retryingMap.get(s))?void 0:n.has(a))?r():o(e)},onRetrying(e,t){var o;isFunction(r)&&r.call(this,e,t),(null==(o=retryingMap.get(s))?void 0:o.has(a))&&(retryingMap.get(s).get(a).stopRetry=t)},onRetryFailed:o});return i.value=function(...e){const t=retryingMap.get(s);return t?t.set(a,{args:e}):retryingMap.set(s,new Map([[a,{args:e}]])),n.apply(this,e).finally(()=>{var e;return null==(e=retryingMap.get(s))?void 0:e.delete(a)})},i}}var _CrossRoom=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"crs-r"}getGroup(e){var t;const r=(null==e?void 0:e.userId)||(null==(t=null==e?void 0:e.updateList)?void 0:t[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return StartValidateRule;case"update":return UpdateValidateRule;case"stop":return StopValidateRule}}async start({roomId:e,strRoomId:t,userId:r}){const{RtcError:o,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new o({code:s.ENV_NOT_SUPPORTED});const a=e||t,i=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:a,userId:r,localRoomId:r?void 0:this.core.room.roomId},retries:3});if(0!==i.data.code)throw new o({code:s.SERVER_ERROR,extraCode:i.data.code,message:i.data.message});r||this.connectedRoomIdSet.add(a)}async update({updateList:e}){var t;const{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});const s=e.find(e=>e.userId)?0:1,a=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:s,updateList:e.map(({roomId:e,strRoomId:t,userId:r,muteAudio:o,muteVideo:s,muteSubStream:a})=>({roomId:e||t,userId:r,muteAudio:o,muteVideo:s,muteSubStream:a}))},retries:3});if(a.data.data.expectSeq)return this.updateSeq=a.data.data.expectSeq,this.update({updateList:e});if(0!==a.data.code)throw new r({code:o.SERVER_ERROR,extraCode:a.data.code,message:a.data.message});if((null==(t=a.data.data.errorList)?void 0:t.length)>0)throw new r({code:o.UNKNOWN_ERROR,message:a.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:t}={}){const r=e||t;if(r)await this.doStop(r);else if(this.connectedRoomIdSet.size>0)for(const e of[...this.connectedRoomIdSet.values()])await this.doStop(e);else await this.doStop()}async doStop(e){const{RtcError:t,ErrorCode:r}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:r.ENV_NOT_SUPPORTED});const o=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(0!==o.data.code)throw new t({code:r.SERVER_ERROR,extraCode:o.data.code,message:o.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};__publicField(_CrossRoom,"Name","CrossRoom"),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],_CrossRoom.prototype,"start",1),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],_CrossRoom.prototype,"update",1);var CrossRoom=_CrossRoom,index_default=CrossRoom;export{index_default as default};export{CrossRoom};
|
|
1
|
+
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__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},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__decorateClass=(e,t,r,o)=>{for(var s,a=o>1?void 0:o?__getOwnPropDesc(t,r):t,i=e.length-1;i>=0;i--)(s=e[i])&&(a=(o?s(t,r,a):s(a))||a);return o&&a&&__defProp(t,r,a),a},__publicField=(e,t,r)=>__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),roomIValidate={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},StartValidateRule={name:"option",required:!0,properties:__spreadProps(__spreadValues({},roomIValidate.properties),{userId:{type:"string"}})},UpdateValidateRule={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:__spreadProps(__spreadValues({},StartValidateRule.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},StopValidateRule={name:"option",properties:__spreadValues({},roomIValidate.properties)},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:o,onRetryFailed:s,onRetrySuccess:a,context:i}){return function(...n){const{retries:d=5,timeout:p=1e3}=t;let c=0,l=-1,u=RETRY_STATE_NOT_START;const _=async(t,m)=>{const R=i||this;try{const r=await e.apply(R,n);c>0&&a&&a.call(this,c),c=0,t(r)}catch(e){const a=()=>{clearTimeout(l),c=0,u=RETRY_STATE_STOPPED,m(e)},i=()=>{u!==RETRY_STATE_STOPPED&&c<(isFunction(d)?d():d)?(c++,u=RETRY_STATE_STARTED,isFunction(o)&&o.call(this,c,a),l=window.setTimeout((()=>{l=-1,_(t,m)}),isFunction(p)?p(c):p)):(a(),isFunction(s)&&s.call(this,e))};isFunction(r)?r.call(this,{error:e,retry:i,reject:m,retryFuncArgs:n,retriedCount:c}):i()}};return new Promise(_)}}var retry_default=promiseRetry,retryingMap=new WeakMap;function addPromiseRetry({settings:e={retries:5,timeout:2e3},onError:t,onRetrying:r,onRetryFailed:o}){return function(s,a,i){const n=retry_default({retryFunction:i.value,settings:e,onError({error:e,retry:r,reject:o,retryFuncArgs:i}){var n;t?t.call(this,e,(()=>{var t;(null==(t=retryingMap.get(s))?void 0:t.has(a))?r():o(e)}),o,i):(null==(n=retryingMap.get(s))?void 0:n.has(a))?r():o(e)},onRetrying(e,t){var o;isFunction(r)&&r.call(this,e,t),(null==(o=retryingMap.get(s))?void 0:o.has(a))&&(retryingMap.get(s).get(a).stopRetry=t)},onRetryFailed:o});return i.value=function(...e){const t=retryingMap.get(s);return t?t.set(a,{args:e}):retryingMap.set(s,new Map([[a,{args:e}]])),n.apply(this,e).finally((()=>{var e;return null==(e=retryingMap.get(s))?void 0:e.delete(a)}))},i}}var _CrossRoom=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"crs-r"}getGroup(e){var t;const r=(null==e?void 0:e.userId)||(null==(t=null==e?void 0:e.updateList)?void 0:t[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return StartValidateRule;case"update":return UpdateValidateRule;case"stop":return StopValidateRule}}async start({roomId:e,strRoomId:t,userId:r}){const{RtcError:o,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new o({code:s.ENV_NOT_SUPPORTED});const a=e||t,i=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:a,userId:r,localRoomId:r?void 0:this.core.room.roomId},retries:3});if(0!==i.data.code)throw new o({code:s.SERVER_ERROR,extraCode:i.data.code,message:i.data.message});r||this.connectedRoomIdSet.add(a)}async update({updateList:e}){var t;const{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});const s=e.find((e=>e.userId))?0:1,a=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:s,updateList:e.map((({roomId:e,strRoomId:t,userId:r,muteAudio:o,muteVideo:s,muteSubStream:a})=>({roomId:e||t,userId:r,muteAudio:o,muteVideo:s,muteSubStream:a})))},retries:3});if(a.data.data.expectSeq)return this.updateSeq=a.data.data.expectSeq,this.update({updateList:e});if(0!==a.data.code)throw new r({code:o.SERVER_ERROR,extraCode:a.data.code,message:a.data.message});if((null==(t=a.data.data.errorList)?void 0:t.length)>0)throw new r({code:o.UNKNOWN_ERROR,message:a.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:t}={}){const r=e||t;if(r)await this.doStop(r);else if(this.connectedRoomIdSet.size>0)for(const e of[...this.connectedRoomIdSet.values()])await this.doStop(e);else await this.doStop()}async doStop(e){const{RtcError:t,ErrorCode:r}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:r.ENV_NOT_SUPPORTED});const o=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(0!==o.data.code)throw new t({code:r.SERVER_ERROR,extraCode:o.data.code,message:o.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};__publicField(_CrossRoom,"Name","CrossRoom"),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],_CrossRoom.prototype,"start",1),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],_CrossRoom.prototype,"update",1);var CrossRoom=_CrossRoom,index_default=CrossRoom;export{index_default as default};export{CrossRoom};
|
|
@@ -1,3 +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).CrossRoom=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,a,i){try{var u=e[a](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function r(e){return function(){var r=this,n=arguments;return new Promise(function(o,a){var i=e.apply(r,n);function u(e){t(i,o,a,u,c,"next",e)}function c(e){t(i,o,a,u,c,"throw",e)}u(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,u(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(){
|
|
2
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function u(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,d=Object.create(u.prototype);return a(d,"_invoke",function(r,n,o){var a,i,u,s=0,d=o||[],f=!1,l={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return a=t,i=0,u=e,l.n=r,c}};function p(r,n){for(i=r,u=n,t=0;!f&&s&&!o&&t<d.length;t++){var o,a=d[t],p=l.p,y=a[2];r>3?(o=y===n)&&(u=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=r<2&&p<a[1])?(i=0,l.v=n,l.n=a[1]):p<y&&(o=r<3||a[0]>n||n>y)&&(a[4]=r,a[5]=n,l.n=y,i=0))}if(o||r>1)return c;throw f=!0,n}return function(o,d,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===d&&p(d,y),i=d,u=y;(t=i<2?e:u)||!f;){a||(i?i<3?(i>1&&(l.n=-1),p(i,u)):l.n=u:l.v=u);try{if(s=2,a){if(i||(o="next"),t=a[o]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,i<2&&(i=0)}else 1===i&&(t=a.return)&&t.call(a),i<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=e}else if((t=(f=l.n<0)?u:r.call(n,l))!==c)break}catch(t){a=e,i=1,u=t}finally{s=1}}return{value:t,done:f}}}(r,o,i),!0),d}var c={};function s(){}function d(){}function f(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(a(t={},n,function(){return this}),t),p=f.prototype=s.prototype=Object.create(l);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,a(e,i,"GeneratorFunction")),e.prototype=Object.create(p),e}return d.prototype=f,a(p,"constructor",f),a(f,"constructor",d),d.displayName="GeneratorFunction",a(f,i,"GeneratorFunction"),a(p),a(p,i,"Generator"),a(p,n,function(){return this}),a(p,"toString",function(){return"[object Generator]"}),(o=function(){return{w:u,m:y}})()}function a(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}a=function(e,t,r,n){if(t)o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r;else{function i(t,r){a(e,t,function(e){return this._invoke(t,r,e)})}i("next",0),i("throw",1),i("return",2)}},a(e,t,r,n)}function i(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)||s(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 u(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 c(e){return c="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},c(e)}function s(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 d=Object.defineProperty,f=Object.defineProperties,l=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,v=function(e,t,r){return t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},g=function(e,t){for(var r in t||(t={}))m.call(t,r)&&v(e,r,t[r]);if(y){var n,o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=s(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 a,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}(y(t));try{for(o.s();!(n=o.n()).done;){r=n.value;h.call(t,r)&&v(e,r,t[r])}}catch(e){o.e(e)}finally{o.f()}}return e},b=function(e,t){return f(e,p(t))},w=function(e,t,r,n){for(var o,a=l(t,r),i=e.length-1;i>=0;i--)(o=e[i])&&(a=o(t,r,a)||a);return a&&d(t,r,a),a},S=function(e,t,r){return v(e,"symbol"!==c(t)?t+"":t,r)},R={roomId:{type:"number"},strRoomId:{type:"string"}},I={name:"option",required:!0,properties:b(g({},R),{userId:{type:"string"}})},O={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:b(g({},I.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},E={name:"option",properties:g({},R)},k=function(e){return"function"==typeof e};var _=function(e){var t=e.retryFunction,n=e.settings,a=e.onError,i=e.onRetrying,u=e.onRetryFailed,c=e.onRetrySuccess,s=e.context;return function(){for(var e=this,d=arguments.length,f=new Array(d),l=0;l<d;l++)f[l]=arguments[l];var p=n.retries,y=void 0===p?5:p,m=n.timeout,h=void 0===m?1e3:m,v=0,g=-1,b=0,w=function(){var n=r(o().m(function r(n,d){var l,p,m,S,R;return o().w(function(r){for(;;)switch(r.n){case 0:return l=s||e,r.p=1,r.n=2,t.apply(l,f);case 2:p=r.v,v>0&&c&&c.call(e,v),v=0,n(p),r.n=4;break;case 3:r.p=3,R=r.v,m=function(){clearTimeout(g),v=0,b=2,d(R)},S=function(){2!==b&&v<(k(y)?y():y)?(v++,b=1,k(i)&&i.call(e,v,m),g=window.setTimeout(function(){g=-1,w(n,d)},k(h)?h(v):h)):(m(),k(u)&&u.call(e,R))},k(a)?a.call(e,{error:R,retry:S,reject:d,retryFuncArgs:f,retriedCount:v}):S();case 4:return r.a(2)}},r,null,[[1,3]])}));return function(e,t){return n.apply(this,arguments)}}();return new Promise(w)}},j=new WeakMap;function P(e){var t=e.settings,r=void 0===t?{retries:5,timeout:2e3}:t,n=e.onError,o=e.onRetrying,a=e.onRetryFailed;return function(e,t,i){var u=_({retryFunction:i.value,settings:r,onError:function(r){var o,a=r.error,i=r.retry,u=r.reject,c=r.retryFuncArgs;n?n.call(this,a,function(){var r;(null==(r=j.get(e))?void 0:r.has(t))?i():u(a)},u,c):(null==(o=j.get(e))?void 0:o.has(t))?i():u(a)},onRetrying:function(r,n){var a;k(o)&&o.call(this,r,n),(null==(a=j.get(e))?void 0:a.has(t))&&(j.get(e).get(t).stopRetry=n)},onRetryFailed:a});return i.value=function(){for(var r=j.get(e),n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return r?r.set(t,{args:o}):j.set(e,new Map([[t,{args:o}]])),u.apply(this,o).finally(function(){var r;return null==(r=j.get(e))?void 0:r.delete(t)})},i}}var T=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=t,S(this,"disableRandomCall",!0),S(this,"connectedRoomIdSet",new Set),S(this,"updateSeq",0),S(this,"_log"),this._log=this.core.log.createChild({id:"".concat(this.getAlias())})}return n(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"crs-r"}},{key:"getGroup",value:function(e){var t,r=(null==e?void 0:e.userId)||(null==(t=null==e?void 0:e.updateList)?void 0:t[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}},{key:"getValidateRule",value:function(e){switch(e){case"start":return I;case"update":return O;case"stop":return E}}},{key:"start",value:(c=r(o().m(function e(t){var r,n,a,i,u,c,s,d;return o().w(function(e){for(;;)switch(e.n){case 0:if(r=t.roomId,n=t.strRoomId,a=t.userId,i=this.core.errorModule,u=i.RtcError,c=i.ErrorCode,this.core.room.sendSignalMessage){e.n=1;break}throw new u({code:c.ENV_NOT_SUPPORTED});case 1:return s=r||n,e.n=2,this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:s,userId:a,localRoomId:a?void 0:this.core.room.roomId},retries:3});case 2:if(0===(d=e.v).data.code){e.n=3;break}throw new u({code:c.SERVER_ERROR,extraCode:d.data.code,message:d.data.message});case 3:a||this.connectedRoomIdSet.add(s);case 4:return e.a(2)}},e,this)})),function(e){return c.apply(this,arguments)})},{key:"update",value:(u=r(o().m(function e(t){var r,n,a,i,u,c,s;return o().w(function(e){for(;;)switch(e.n){case 0:if(r=t.updateList,a=this.core.errorModule,i=a.RtcError,u=a.ErrorCode,this.core.room.sendSignalMessage){e.n=1;break}throw new i({code:u.ENV_NOT_SUPPORTED});case 1:return c=r.find(function(e){return e.userId})?0:1,e.n=2,this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:c,updateList:r.map(function(e){var t=e.roomId,r=e.strRoomId;return{roomId:t||r,userId:e.userId,muteAudio:e.muteAudio,muteVideo:e.muteVideo,muteSubStream:e.muteSubStream}})},retries:3});case 2:if(!(s=e.v).data.data.expectSeq){e.n=3;break}return this.updateSeq=s.data.data.expectSeq,e.a(2,this.update({updateList:r}));case 3:if(0===s.data.code){e.n=4;break}throw new i({code:u.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});case 4:if(!((null==(n=s.data.data.errorList)?void 0:n.length)>0)){e.n=5;break}throw new i({code:u.UNKNOWN_ERROR,message:s.data.data.errorList[0].message});case 5:return e.a(2)}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"stop",value:(a=r(o().m(function e(){var t,r,n,a,u,c,s,d=arguments;return o().w(function(e){for(;;)switch(e.n){case 0:if(r=(t=d.length>0&&void 0!==d[0]?d[0]:{}).roomId,n=t.strRoomId,!(a=r||n)){e.n=2;break}return e.n=1,this.doStop(a);case 1:e.n=7;break;case 2:if(!(this.connectedRoomIdSet.size>0)){e.n=6;break}u=0,c=i(this.connectedRoomIdSet.values());case 3:if(!(u<c.length)){e.n=5;break}return s=c[u],e.n=4,this.doStop(s);case 4:u++,e.n=3;break;case 5:e.n=7;break;case 6:return e.n=7,this.doStop();case 7:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"doStop",value:(t=r(o().m(function e(t){var r,n,a,i;return o().w(function(e){for(;;)switch(e.n){case 0:if(r=this.core.errorModule,n=r.RtcError,a=r.ErrorCode,this.core.room.sendSignalMessage){e.n=1;break}throw new n({code:a.ENV_NOT_SUPPORTED});case 1:return e.n=2,this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:t,localRoomId:this.core.room.roomId},retries:3});case 2:if(0===(i=e.v).data.code){e.n=3;break}throw new n({code:a.SERVER_ERROR,extraCode:i.data.code,message:i.data.message});case 3:this.connectedRoomIdSet.delete(t);case 4:return e.a(2)}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){}}]);var t,a,u,c}();return S(T,"Name","CrossRoom"),w([P({settings:{retries:3,timeout:1e3},onRetrying:function(e){this._log.warn("retry start: ".concat(e))}})],T.prototype,"start"),w([P({settings:{retries:3,timeout:1e3},onRetrying:function(e){this._log.warn("retry update: ".concat(e))}})],T.prototype,"update"),T});
|
|
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).CrossRoom=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 u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).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 u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(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:{},u=a.iterator||"@@iterator",c=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),u=new P(n||[]);return i(a,"_invoke",{value:O(t,r,u)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",h="suspendedYield",y="executing",m="completed",v={};function g(){}function b(){}function w(){}var x={};l(x,u,(function(){return this}));var S=Object.getPrototypeOf,E=S&&S(S(T([])));E&&E!==r&&n.call(E,u)&&(x=E);var R=w.prototype=g.prototype=Object.create(x);function I(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,u){var c=d(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.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=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=L(u,n);if(c){if(c===v)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=d(e,r,n);if("normal"===s.type){if(o=n.done?m:h,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function L(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,L(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;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,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function _(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[u];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 b.prototype=w,i(R,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(R),t},e.awrap=function(t){return{__await:t}},I(k.prototype),l(k.prototype,c,(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()}))},I(R),l(R,s,"Generator"),l(R,u,(function(){return this})),l(R,"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=T,P.prototype={constructor:P,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(j),!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 u.type="throw",u.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],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){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,v):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),v},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),j(r),v}},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;j(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},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)||c(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 u(t){return u="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},u(t)}function c(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.defineProperties,f=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,m=function(t,e,r){return e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},v=function(t,e){for(var r in e||(e={}))h.call(e,r)&&m(t,r,e[r]);if(p){var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=c(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(p(e));try{for(o.s();!(n=o.n()).done;){r=n.value;y.call(e,r)&&m(t,r,e[r])}}catch(t){o.e(t)}finally{o.f()}}return t},g=function(t,e){return l(t,d(e))},b=function(t,e,r,n){for(var o,i=f(e,r),a=t.length-1;a>=0;a--)(o=t[a])&&(i=o(e,r,i)||i);return i&&s(e,r,i),i},w=function(t,e,r){return m(t,"symbol"!==u(e)?e+"":e,r)},x={roomId:{type:"number"},strRoomId:{type:"string"}},S={name:"option",required:!0,properties:g(v({},x),{userId:{type:"string"}})},E={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:g(v({},S.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},R={name:"option",properties:v({},x)},I=function(t){return"function"==typeof t};var k=function(t){var e=t.retryFunction,n=t.settings,i=t.onError,a=t.onRetrying,u=t.onRetryFailed,c=t.onRetrySuccess,s=t.context;return function(){for(var t=this,l=arguments.length,f=new Array(l),d=0;d<l;d++)f[d]=arguments[d];var p=n.retries,h=void 0===p?5:p,y=n.timeout,m=void 0===y?1e3:y,v=0,g=-1,b=0,w=function(){var n=r(o().mark((function r(n,l){var d,p,y,x;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return d=s||t,r.prev=1,r.next=4,e.apply(d,f);case 4:p=r.sent,v>0&&c&&c.call(t,v),v=0,n(p),r.next=15;break;case 10:r.prev=10,r.t0=r.catch(1),y=function(){clearTimeout(g),v=0,b=2,l(r.t0)},x=function(){2!==b&&v<(I(h)?h():h)?(v++,b=1,I(a)&&a.call(t,v,y),g=window.setTimeout((function(){g=-1,w(n,l)}),I(m)?m(v):m)):(y(),I(u)&&u.call(t,r.t0))},I(i)?i.call(t,{error:r.t0,retry:x,reject:l,retryFuncArgs:f,retriedCount:v}):x();case 15:case"end":return r.stop()}}),r,null,[[1,10]])})));return function(t,e){return n.apply(this,arguments)}}();return new Promise(w)}},O=new WeakMap;function L(t){var e=t.settings,r=void 0===e?{retries:5,timeout:2e3}:e,n=t.onError,o=t.onRetrying,i=t.onRetryFailed;return function(t,e,a){var u=k({retryFunction:a.value,settings:r,onError:function(r){var o,i=r.error,a=r.retry,u=r.reject,c=r.retryFuncArgs;n?n.call(this,i,(function(){var r;(null==(r=O.get(t))?void 0:r.has(e))?a():u(i)}),u,c):(null==(o=O.get(t))?void 0:o.has(e))?a():u(i)},onRetrying:function(r,n){var i;I(o)&&o.call(this,r,n),(null==(i=O.get(t))?void 0:i.has(e))&&(O.get(t).get(e).stopRetry=n)},onRetryFailed:i});return a.value=function(){for(var r=O.get(t),n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return r?r.set(e,{args:o}):O.set(t,new Map([[e,{args:o}]])),u.apply(this,o).finally((function(){var r;return null==(r=O.get(t))?void 0:r.delete(e)}))},a}}var _=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,w(this,"disableRandomCall",!0),w(this,"connectedRoomIdSet",new Set),w(this,"updateSeq",0),w(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"crs-r"}},{key:"getGroup",value:function(t){var e,r=(null==t?void 0:t.userId)||(null==(e=null==t?void 0:t.updateList)?void 0:e[0].userId)||"";return r||(t?t.updateList?String(t.updateList[0].roomId)||t.updateList[0].strRoomId||"":String(t.roomId)||t.strRoomId||"":"*")}},{key:"getValidateRule",value:function(t){switch(t){case"start":return S;case"update":return E;case"stop":return R}}},{key:"start",value:(c=r(o().mark((function t(e){var r,n,i,a,u,c,s,l;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.roomId,n=e.strRoomId,i=e.userId,a=this.core.errorModule,u=a.RtcError,c=a.ErrorCode,this.core.room.sendSignalMessage){t.next=4;break}throw new u({code:c.ENV_NOT_SUPPORTED});case 4:return s=r||n,t.next=7,this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:s,userId:i,localRoomId:i?void 0:this.core.room.roomId},retries:3});case 7:if(0===(l=t.sent).data.code){t.next=10;break}throw new u({code:c.SERVER_ERROR,extraCode:l.data.code,message:l.data.message});case 10:i||this.connectedRoomIdSet.add(s);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"update",value:(u=r(o().mark((function t(e){var r,n,i,a,u,c,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.updateList,i=this.core.errorModule,a=i.RtcError,u=i.ErrorCode,this.core.room.sendSignalMessage){t.next=4;break}throw new a({code:u.ENV_NOT_SUPPORTED});case 4:return c=r.find((function(t){return t.userId}))?0:1,t.next=7,this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:c,updateList:r.map((function(t){var e=t.roomId,r=t.strRoomId;return{roomId:e||r,userId:t.userId,muteAudio:t.muteAudio,muteVideo:t.muteVideo,muteSubStream:t.muteSubStream}}))},retries:3});case 7:if(!(s=t.sent).data.data.expectSeq){t.next=11;break}return this.updateSeq=s.data.data.expectSeq,t.abrupt("return",this.update({updateList:r}));case 11:if(0===s.data.code){t.next=15;break}throw new a({code:u.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});case 15:if(!((null==(n=s.data.data.errorList)?void 0:n.length)>0)){t.next=17;break}throw new a({code:u.UNKNOWN_ERROR,message:s.data.data.errorList[0].message});case 17:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"stop",value:(a=r(o().mark((function t(){var e,r,n,a,u,c,s,l=arguments;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=(e=l.length>0&&void 0!==l[0]?l[0]:{}).roomId,n=e.strRoomId,!(a=r||n)){t.next=7;break}return t.next=5,this.doStop(a);case 5:t.next=20;break;case 7:if(!(this.connectedRoomIdSet.size>0)){t.next=18;break}u=0,c=i(this.connectedRoomIdSet.values());case 9:if(!(u<c.length)){t.next=16;break}return s=c[u],t.next=13,this.doStop(s);case 13:u++,t.next=9;break;case 16:t.next=20;break;case 18:return t.next=20,this.doStop();case 20:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"doStop",value:(e=r(o().mark((function t(e){var r,n,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.core.errorModule,n=r.RtcError,i=r.ErrorCode,this.core.room.sendSignalMessage){t.next=3;break}throw new n({code:i.ENV_NOT_SUPPORTED});case 3:return t.next=5,this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});case 5:if(0===(a=t.sent).data.code){t.next=8;break}throw new n({code:i.SERVER_ERROR,extraCode:a.data.code,message:a.data.message});case 8:this.connectedRoomIdSet.delete(e);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"destroy",value:function(){}}]);var e,a,u,c}();return w(_,"Name","CrossRoom"),b([L({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry start: ".concat(t))}})],_.prototype,"start"),b([L({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry update: ".concat(t))}})],_.prototype,"update"),_}));
|