UNPKG

trtc-sdk-v5

Version:
4 lines (3 loc) 39.9 kB
!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(){ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ 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){function i(e,r){s(t,e,function(t){return this._invoke(e,r,t)})}e?n?n(t,e,{value:r,enumerable:!o,configurable:!o,writable:!o}):t[e]=r:(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=Object.create,m=Object.defineProperty,p=Object.defineProperties,f=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols,_=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,I=function(t,e,r){return e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},D=function(t,e){for(var r in e||(e={}))y.call(e,r)&&I(t,r,e[r]);if(b){var o,n=i(b(e));try{for(n.s();!(o=n.n()).done;){r=o.value;S.call(e,r)&&I(t,r,e[r])}}catch(t){n.e(t)}finally{n.f()}}return t},C=function(t,e,r){return r=null!=t?l(_(t)):{},function(t,e,r,o){if(e&&"object"===c(e)||"function"==typeof e){var n,a=i(v(e));try{var s=function(){var i=n.value;y.call(t,i)||i===r||m(t,i,{get:function(){return e[i]},enumerable:!(o=f(e,i))||o.enumerable})};for(a.s();!(n=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 I(t,"symbol"!==c(e)?e+"":e,r)},P=(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[v(d)[0]])((h={exports:{}}).exports,h),h.exports}),T=C(P()),w=0,k=4,M=5,R=function(){return n(function t(e,r){o(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().m(function t(e){var r,o,n,i,s,u,c,d,h;return a().w(function(t){for(;;)switch(t.p=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}(),E=function(){return n(function t(e,r){o(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().m(function t(e){var r,o,n,i,s,u,c,d,h,l,m,p;return a().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this._log.info("startMixTranscode: ".concat(JSON.stringify(e))),r=this._config,o=this._data,this._config=e,this.installEvents(),this._core.room.isJoined){t.n=1;break}return t.a(2);case 1:if(t.p=1,n=this.getInputParam(e),i=this.getOutputParam(e),s=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId}),!this.isMixing||!this._data||s===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:s,inputParam:n,outputParam:i});case 3:if(u=e.target,c=u.appId,d=u.bizId,h=u.url,l=u.streamId,m=void 0===l?"":l,!(c&&d&&h)){t.n=4;break}return this._givenCDNManager||(this._givenCDNManager=new R(this._core,this._log)),t.n=4,this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:c,bizId:d,url:h,streamId:m});case 4:t.n=6;break;case 5:throw t.p=5,p=t.v,o?(this._log.warn("[CDNStreaming] update failed, restore previous state"),this._config=r,this._data=o):this.reset(),p;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.p=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,T.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: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 o=s.findIndex(function(e){return e.userId===t.userId&&e.roomId===r});-1!==o?s[o].inputType=w:s.push({userId:t.userId,roomId:t.roomId||t.strRoomId||e._core.room.roomId,inputType:k})}),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}(),x=C(P()),O=function(){return n(function t(e,r){o(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().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)),n="main"===r.streamType?"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=2;break}return t.n=2,this.startPublishTencentCDN(i.target);case 2: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 R(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,x.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,x.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,x.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(t)))}}]);var t,e,i,s,u,c}(),A=C(P()),L=function(){function t(e,r){o(this,t),N(this,"_core"),N(this,"_room"),N(this,"_log"),N(this,"_seq"),N(this,"_taskId"),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;var n=localStorage.getItem(t.TASK_ID_KEY);n&&(this._taskId=n)}return n(t,[{key:"startPushStreamToRoom",value:(s=r(a().m(function e(r){var o,n,i,s,u,c,d;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,!this._taskId){e.n=1;break}return e.n=1,this.stopPushStreamToRoom();case 1:e.n=3;break;case 2:e.p=2,d=e.v,this._log.warn("stopPushStreamToRoom prev taskId failed",d);case 3:return this._seq+=1,this._startData=D({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(r)),this._log.info("startPushStreamToRoom: ".concat(JSON.stringify(this._startData))),e.n=4,this._room.sendStartPushStreamToRoom(this._startData);case 4:i=e.v,s=i.data,u=s.code,c=s.message,0===u?(this._taskId=null==(n=null==(o=i.data)?void 0:o.data)?void 0:n.taskId,this._taskId?localStorage.setItem(t.TASK_ID_KEY,this._taskId):this.reportServerError("startPushStreamToRoom",u,"can't resolve task id: ".concat(JSON.stringify(i.data))),this._log.info("[CDNStreaming] server success: taskId",this._taskId)):this.reportServerError("startPushStreamToRoom",u,c);case 5:return e.a(2)}},e,this,[[0,2]])})),function(t){return s.apply(this,arguments)})},{key:"updatePushStreamToRoom",value:(i=r(a().m(function t(e){var r,o,n,i,s;return a().w(function(t){for(;;)switch(t.n){case 0:return this._seq+=1,this._updateData=D({taskid:this._taskId},this.getCommonParams(e)),this._core.utils.isBoolean(null==(r=e.mix)?void 0:r.enableNtpSync)&&(this._updateData.enableNtpSync=e.mix.enableNtpSync),this._log.info("updatePushStreamToRoom: ".concat(JSON.stringify(this._updateData))),t.n=1,this._room.sendUpdatePushStreamToRoom(this._updateData);case 1:o=t.v,n=o.data,i=n.code,s=n.message,0===i?this._log.info("server success: updatePushStreamToRoom"):this.reportServerError("updatePushStreamToRoom",i,s);case 2:return t.a(2)}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"stopPushStreamToRoom",value:(e=r(a().m(function e(){var r,o,n,i;return a().w(function(e){for(;;)switch(e.n){case 0:if(this._taskId){e.n=1;break}return e.a(2);case 1:return this._seq+=1,this._stopData={sdkappid:this._room.sdkAppId,taskid:this._taskId},this._log.info("stopPushStreamToRoom: ".concat(JSON.stringify(this._stopData))),e.n=2,this._room.sendStopPushStreamToRoom(this._stopData);case 2:r=e.v,o=r.data,n=o.code,i=o.message,0===n?(delete this._taskId,localStorage.removeItem(t.TASK_ID_KEY),this._log.info("server success: start mix")):this.reportServerError("stopPushStreamToRoom",n,i);case 3:return e.a(2)}},e,this)})),function(){return e.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){var e;return{sdkappid:this._room.sdkAppId,transcode:!0,audioParam:this.getAudioParam(t),videoParam:this.getVideoParam(t),pushRtcRoomParams:this.getPushRtcRoomParams(t),sequenceNumber:this._seq,enableNtpSync:(null==(e=t.mix)?void 0:e.enableNtpSync)||!1}}},{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 e,i,s}();N(L,"TASK_ID_KEY","trtc_mix_to_room_taskId");var j,G=L;var U,V,q={type:"number",notLessThanZero:!0},F={type:"object",properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:function(t,e,r,o){var n=j,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=j,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"}})}}}},J={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=j,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({},F)},validate:function(t,e,r,o){var n=t.publishMode,i=t.robotUser;if("publish-mix-stream-to-room"===n&&!i){var a=j;throw new(0,a.RtcError)({code:a.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter target, the value of publishMode is PublishMixStreamToRoom, robotUser is required."})}}},z={required:!1,type:"object",properties:{videoWidth:q,videoHeight:q,videoBitrate:(U=D({},q),V={allowEmpty:!1},p(U,g(V))),videoFramerate:{type:"number",validate:function(t,e,r,o){if(t<=0||t>30){var n=j;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=j;throw new(0,n.RtcError)({code:n.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:q,audioBitrate:{type:"number",validate:function(t,e,r,o){if(t<32||t>192){var n=j;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]}}},B={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:D({},F)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:D({},F),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=j;throw new(0,n.RtcError)({code:n.ErrorCode.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:q,height:q,locationX:q,locationY:q}}}}};var Y=0,K=function(){function t(e){o(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"),Y+=1,this.seq=Y,this._log=e.log.createChild({id:"".concat(this.getAlias()).concat(Y)}),this._log.info("[CDNStreaming] created id=".concat(this.getAlias()).concat(Y)),this._core=e,this._modeOptions=new Map,this._mixTranscodeManager=new E(e,this._log),this._publishCDNManager=new O(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,j=e.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:D({},J),encoding:D({},z),mix:D({},B)},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 j=t.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:D({},J),encoding:D({},z),mix:D({},B)}}}(this._core);case"stop":return function(t){return j=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 N(K,"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(K,"Name","CDNStreaming"),K});