trtc-sdk-v5 5.8.0 → 5.8.1-beta.1
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/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/cross-room.esm.js +1 -1
- package/plugins/cross-room/cross-room.iife.js +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/debug/package.json +1 -1
- package/plugins/device-detector/package.json +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +2 -2
- package/plugins/video-effect/basic-beauty/basic-beauty.iife.js +2 -2
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.esm.js +14 -14
- package/plugins/video-effect/virtual-background/virtual-background.iife.js +14 -14
- package/plugins/video-effect/watermark/package.json +1 -1
- package/trtc.esm.js +21 -21
- package/trtc.js +1 -1
- package/plugins/cdn-streaming/cdn-streaming.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var global,factory;global=this,factory=function(e){var t,r,i,o,s,a=Object.create,n=Object.defineProperty,d=Object.defineProperties,c=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,m=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,b=(e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f=(e,t)=>{for(var r in t||(t={}))p.call(t,r)&&b(e,r,t[r]);if(u)for(var r of u(t))g.call(t,r)&&b(e,r,t[r]);return e},_=(e,t,r)=>(r=null!=e?a(m(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of l(t))!p.call(e,o)&&o!==r&&n(e,o,{get:()=>t[o],enumerable:!(i=c(t,o))||i.enumerable});return e})(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),C=(e,t,r)=>(b(e,"symbol"!=typeof t?t+"":t,r),r),D=(t=(e,t)=>{!function(e){function r(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function i(e,t,i,o,s,a){return r(function(e,t){return e<<t|e>>>32-t}(r(r(t,e),r(o,a)),s),i)}function o(e,t,r,o,s,a,n){return i(t&r|~t&o,e,t,s,a,n)}function s(e,t,r,o,s,a,n){return i(t&o|r&~o,e,t,s,a,n)}function a(e,t,r,o,s,a,n){return i(t^r^o,e,t,s,a,n)}function n(e,t,r,o,s,a,n){return i(r^(t|~o),e,t,s,a,n)}function d(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var i,d,c,h,l,u=1732584193,m=-271733879,p=-1732584194,g=271733878;for(i=0;i<e.length;i+=16)d=u,c=m,h=p,l=g,u=o(u,m,p,g,e[i],7,-680876936),g=o(g,u,m,p,e[i+1],12,-389564586),p=o(p,g,u,m,e[i+2],17,606105819),m=o(m,p,g,u,e[i+3],22,-1044525330),u=o(u,m,p,g,e[i+4],7,-176418897),g=o(g,u,m,p,e[i+5],12,1200080426),p=o(p,g,u,m,e[i+6],17,-1473231341),m=o(m,p,g,u,e[i+7],22,-45705983),u=o(u,m,p,g,e[i+8],7,1770035416),g=o(g,u,m,p,e[i+9],12,-1958414417),p=o(p,g,u,m,e[i+10],17,-42063),m=o(m,p,g,u,e[i+11],22,-1990404162),u=o(u,m,p,g,e[i+12],7,1804603682),g=o(g,u,m,p,e[i+13],12,-40341101),p=o(p,g,u,m,e[i+14],17,-1502002290),u=s(u,m=o(m,p,g,u,e[i+15],22,1236535329),p,g,e[i+1],5,-165796510),g=s(g,u,m,p,e[i+6],9,-1069501632),p=s(p,g,u,m,e[i+11],14,643717713),m=s(m,p,g,u,e[i],20,-373897302),u=s(u,m,p,g,e[i+5],5,-701558691),g=s(g,u,m,p,e[i+10],9,38016083),p=s(p,g,u,m,e[i+15],14,-660478335),m=s(m,p,g,u,e[i+4],20,-405537848),u=s(u,m,p,g,e[i+9],5,568446438),g=s(g,u,m,p,e[i+14],9,-1019803690),p=s(p,g,u,m,e[i+3],14,-187363961),m=s(m,p,g,u,e[i+8],20,1163531501),u=s(u,m,p,g,e[i+13],5,-1444681467),g=s(g,u,m,p,e[i+2],9,-51403784),p=s(p,g,u,m,e[i+7],14,1735328473),u=a(u,m=s(m,p,g,u,e[i+12],20,-1926607734),p,g,e[i+5],4,-378558),g=a(g,u,m,p,e[i+8],11,-2022574463),p=a(p,g,u,m,e[i+11],16,1839030562),m=a(m,p,g,u,e[i+14],23,-35309556),u=a(u,m,p,g,e[i+1],4,-1530992060),g=a(g,u,m,p,e[i+4],11,1272893353),p=a(p,g,u,m,e[i+7],16,-155497632),m=a(m,p,g,u,e[i+10],23,-1094730640),u=a(u,m,p,g,e[i+13],4,681279174),g=a(g,u,m,p,e[i],11,-358537222),p=a(p,g,u,m,e[i+3],16,-722521979),m=a(m,p,g,u,e[i+6],23,76029189),u=a(u,m,p,g,e[i+9],4,-640364487),g=a(g,u,m,p,e[i+12],11,-421815835),p=a(p,g,u,m,e[i+15],16,530742520),u=n(u,m=a(m,p,g,u,e[i+2],23,-995338651),p,g,e[i],6,-198630844),g=n(g,u,m,p,e[i+7],10,1126891415),p=n(p,g,u,m,e[i+14],15,-1416354905),m=n(m,p,g,u,e[i+5],21,-57434055),u=n(u,m,p,g,e[i+12],6,1700485571),g=n(g,u,m,p,e[i+3],10,-1894986606),p=n(p,g,u,m,e[i+10],15,-1051523),m=n(m,p,g,u,e[i+1],21,-2054922799),u=n(u,m,p,g,e[i+8],6,1873313359),g=n(g,u,m,p,e[i+15],10,-30611744),p=n(p,g,u,m,e[i+6],15,-1560198380),m=n(m,p,g,u,e[i+13],21,1309151649),u=n(u,m,p,g,e[i+4],6,-145523070),g=n(g,u,m,p,e[i+11],10,-1120210379),p=n(p,g,u,m,e[i+2],15,718787259),m=n(m,p,g,u,e[i+9],21,-343485551),u=r(u,d),m=r(m,c),p=r(p,h),g=r(g,l);return[u,m,p,g]}function c(e){var t,r="",i=32*e.length;for(t=0;t<i;t+=8)r+=String.fromCharCode(e[t>>5]>>>t%32&255);return r}function h(e){var t,r=[];for(r[(e.length>>2)-1]=void 0,t=0;t<r.length;t+=1)r[t]=0;var i=8*e.length;for(t=0;t<i;t+=8)r[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return r}function l(e){var t,r,i="0123456789abcdef",o="";for(r=0;r<e.length;r+=1)t=e.charCodeAt(r),o+=i.charAt(t>>>4&15)+i.charAt(15&t);return o}function u(e){return unescape(encodeURIComponent(e))}function m(e){return function(e){return c(d(h(e),8*e.length))}(u(e))}function p(e,t){return function(e,t){var r,i,o=h(e),s=[],a=[];for(s[15]=a[15]=void 0,o.length>16&&(o=d(o,8*e.length)),r=0;r<16;r+=1)s[r]=909522486^o[r],a[r]=1549556828^o[r];return i=d(s.concat(h(t)),512+8*t.length),c(d(a.concat(i),640))}(u(e),u(t))}function g(e,t,r){return t?r?p(t,e):function(e,t){return l(p(e,t))}(t,e):r?m(e):function(e){return l(m(e))}(e)}"function"==typeof define&&define.amd?define((function(){return g})):"object"==typeof t&&t.exports?t.exports=g:e.md5=g}(e)},()=>(r||t((r={exports:{}}).exports,r),r.exports)),N=_(D(),1),I=((o=I||{}).PublishMainStreamToCDN="publish-main-stream-to-cdn",o.PublishSubStreamToCDN="publish-sub-stream-to-cdn",o.PublishMixStreamToCDN="publish-mix-stream-to-cdn",o),v=((i=v||{}).Main="main",i.Sub="sub",i),S=0,y=4,T=5,M=class{constructor(e,t){C(this,"_core"),C(this,"_room"),C(this,"_log"),C(this,"_params"),C(this,"_publishGivenCDNData",null),this._core=e,this._room=e.room,this._log=t}get isPublishingGivenCDN(){return!!this._params}async startPublishGivenCDN(e){if(this._log.info("[CDNStreaming] startPublishGivenCDN() current: ".concat(JSON.stringify(this._params),", params: ").concat(JSON.stringify(e))),this.isPublishingGivenCDN){let{appId:t,bizId:r,url:i}=this._params||{};if(t===e.appId&&r===e.bizId&&i===e.url)return;await this.stopPublishGivenCDN()}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};try{let t=await this._room.sendStartPublishCDN(this._publishGivenCDNData,!1),{code:r,message:i}=t.data;if(0!==r)throw this.resetGivenCDN(),this._log.error("[CDNStreaming] server failed: start given cdn errCode: ".concat(r," errMsg: ").concat(i," options: ").concat(JSON.stringify(e))),new Error("[CDNStreaming] server failed: start given cdn errCode: ".concat(r," errMsg: ").concat(i));this._log.info("[CDNStreaming] server success: start given cdn.")}catch(i){throw this.resetGivenCDN(),i}}async stopPublishGivenCDN(){if(this._log.info("[CDNStreaming] stopPublishGivenCDN"),!this.isPublishingGivenCDN||!this._publishGivenCDNData)return void this.resetGivenCDN();let{pushAppId:e,pushBizId:t,pushCdnUrl:r,pushStreamType:i,pushStreamId:o}=this._publishGivenCDNData,s={pushRequestTime:Date.now(),pushAppId:e,pushBizId:t,pushCdnUrl:r,pushStreamType:i,pushStreamId:o},a=await this._room.sendStopPublishCDN(s,!1),{code:n,message:d}=a.data;if(0!==n)throw this._log.error("[CDNStreaming] server failed: stop given cdn errCode: ".concat(n," errMsg: ").concat(d," data: ").concat(JSON.stringify(s))),new Error("[CDNStreaming] server failed: stop given cdn errCode: ".concat(n," errMsg: ").concat(d));this._log.info("[CDNStreaming] server success: stop given cdn."),this.resetGivenCDN()}resetGivenCDN(){this._publishGivenCDNData=null,this._params=void 0}convertStreamType(e){return"publish-main-stream-to-cdn"===e?"main":"aux"}},P=class{constructor(e,t){C(this,"_core"),C(this,"_room"),C(this,"_log"),C(this,"_config",null),C(this,"_data",null),C(this,"_givenCDNManager"),this._core=e,this._room=e.room,this._log=t,this.reset()}get isMixing(){return!!this._data}get isStarted(){return!!this._config}get hasCustomCDN(){var e,t,r;return(null==(e=this._config)?void 0:e.target.appId)&&(null==(t=this._config)?void 0:t.target.bizId)&&(null==(r=this._config)?void 0:r.target.url)}async startMixTranscode(e){if(this._log.info("startMixTranscode: ".concat(JSON.stringify(e))),this._config=e,this.installEvents(),this._core.room.isJoined)try{let t=this.getInputParam(e),r=this.getOutputParam(e),i=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId});this.isMixing&&this._data&&i!==this._data.outputSessionId&&(this._log.info("[CDNStreaming] streamId changed, auto stop mixing before start"),await this.doStopMixTranscode()),await this.doStartMixTranscode({outputSessionId:i,inputParam:t,outputParam:r});let{appId:o,bizId:s,url:a,streamId:n=""}=e.target;o&&s&&a&&(this._givenCDNManager||(this._givenCDNManager=new M(this._core,this._log)),await this._givenCDNManager.startPublishGivenCDN({publishMode:e.target.publishMode,appId:o,bizId:s,url:a,streamId:n}))}catch(i){throw this.reset(),i}}async doStartMixTranscode(e){let{outputSessionId:t,inputParam:r,outputParam:i}=e,o={roomId:String(this._room.roomId),mcuRequestTime:Date.now(),outputSessionId:t,inputParam:r,outputParam:i};this._log.info("[CDNStreaming] doStartMixTranscode: ".concat(JSON.stringify(o)));let s=await this._room.sendStartMixTranscode(o),{code:a}=s.data,{message:n}=s.data;if(0!==a)throw-102083===a&&(n="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(a," errMsg: ").concat(n)),new Error("[CDNStreaming] server failed: start mix errCode: ".concat(a," errMsg: ").concat(n));this._log.info("[CDNStreaming] server success: start mix"),this._data=o}async stopMixTranscode(){this._log.info("[CDNStreaming] stopMixTranscode");try{this.isStarted&&this.isMixing&&(await this.doStopMixTranscode(),this._config&&this.hasCustomCDN&&this._givenCDNManager&&await this._givenCDNManager.stopPublishGivenCDN())}catch(r){throw r}this.reset()}async doStopMixTranscode(){let e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType};this._log.info("[CDNStreaming] doStopMixTranscode: ".concat(JSON.stringify(e)));let t=await this._room.sendStopMixTranscode(e),{code:r,message:i}=t.data;if(0!==r)throw this._log.error("[CDNStreaming] server failed: start mix errCode: ".concat(r," errMsg: ").concat(i)),new Error("[CDNStreaming] server failed: start mix errCode: ".concat(r," errMsg: ").concat(i));this._log.info("[CDNStreaming] server success: stop mix"),this.reset()}reset(){this._config=null,this._data=null,this.uninstallEvents()}installEvents(){this._core.room.on("joined",this.handleRoomJoined,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.room.off("joined",this.handleRoomJoined,this),this._core.room.off("left",this.handleRoomLeft,this)}async handleRoomJoined(){this._log.info("[CDNStreaming] handleJoined: ".concat(JSON.stringify(this._config))),this.isStarted&&this._config&&await this.startMixTranscode(this._config)}async handleRoomLeft(){this._log.info("[CDNStreaming] handleRoomLeft: ".concat(JSON.stringify(this._config))),this._data=null}getOutputSessionId(e){let{config:t,userId:r,roomId:i}=e;return this._core.utils.isString(t.target.streamId)&&t.target.streamId.length>0?t.target.streamId:(0,N.default)("".concat(i,"_").concat(r,"_main"))}getStringRoomId(e,t){return e?String(e):t}getInputParam(e){let{mix:t={}}=e,{audioMixUserList:r=[],videoLayoutList:i=[]}=t,o=i.map((e=>({userId:e.fixedVideoUser.userId,roomId:this.getStringRoomId(e.fixedVideoUser.roomId,e.fixedVideoUser.strRoomId)||this._core.room.roomId,width:e.width||0,height:e.height||0,locationX:e.locationX||0,locationY:e.locationY||0,zOrder:e.zOrder||1,streamType:"sub"===e.fixedVideoStreamType?1:0,inputType:T,renderMode:e.fillMode||0})));return r.forEach((e=>{let t=o.findIndex((t=>t.userId===e.userId&&t.roomId===this.getStringRoomId(e.roomId,e.strRoomId)));-1!==t?o[t].inputType=S:o.push({userId:e.userId,roomId:e.roomId||e.strRoomId,inputType:y})})),o}getOutputParam(e){let t=e.target.streamId||"",{encoding:r={},mix:i={}}=e;return{streamId:t,streamType:t.length>0?1:0,width:this._core.utils.isUndefined(r.videoWidth)?640:r.videoWidth,height:this._core.utils.isUndefined(r.videoHeight)?480:r.videoHeight,videoBps:r.videoBitrate||0,fps:r.videoFramerate||15,gop:r.videoGOP||2,audioSampleRate:r.audioSampleRate||48e3,audioBps:r.audioBitrate||64,audioChannels:r.audioChannels||1,backgroundColor:i.backgroundColor||0,backgroundImg:i.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}},w=_(D(),1),E=class{constructor(e,t){C(this,"_room"),C(this,"_core"),C(this,"_log"),C(this,"_paramsForTencentCDN"),C(this,"_initParamsForTencentCDN",{isPublished:!1,isStarted:!1}),this._core=e,this._room=e.room,this._log=t,this._paramsForTencentCDN=new Map([["publish-main-stream-to-cdn",this._initParamsForTencentCDN],["publish-sub-stream-to-cdn",this._initParamsForTencentCDN]])}installEvents(){this._core.innerEmitter.on("104",this.handlePublished,this),this._core.room.on("left",this.handleRoomLeft,this)}uninstallEvents(){this._core.innerEmitter.off("104",this.handlePublished,this),this._core.room.off("left",this.handleRoomLeft,this)}async handlePublished(e){let{track:t}=e;var r;if(t.room!==this._room||(this._log.info("[CDNStreaming] handlePublished: mediaType ".concat(t.mediaType,", roomID ").concat(null==(r=null==t?void 0:t.room)?void 0:r.roomId,", ").concat(this._room.isMainStreamPublished)),1===t.mediaType))return;let i=4===t.mediaType?"publish-main-stream-to-cdn":"publish-sub-stream-to-cdn",o=this._paramsForTencentCDN.get(i)||null;null!=o&&o.target&&o.isStarted&&await this.startPublishTencentCDN(o.target)}async handleRoomLeft(){this._log.info("[CDNStreaming] handleRoomLeft"),this.changeDataStatus("publish-main-stream-to-cdn",{isPublished:!1}),this.changeDataStatus("publish-sub-stream-to-cdn",{isPublished:!1})}isStreamPublished(e){return"publish-main-stream-to-cdn"!==e||this._room.isMainStreamPublished?!("publish-sub-stream-to-cdn"===e&&!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)}changeDataStatus(e,t){let r=this._paramsForTencentCDN.get(e),i=f(f({},r),t);this._paramsForTencentCDN.set(e,i)}async startPublishTencentCDN(e){if(this._log.info("[CDNStreaming] startPublishTencentCDN ".concat(JSON.stringify(e))),this.installEvents(),this.changeDataStatus(e.publishMode,{target:e,isStarted:!0}),!this.isStreamPublished(e.publishMode))return;let t=e.streamId||"",r=this.generatePublishCDNStreamId(t,e.publishMode),i=this.generatePublishCDNSessionId(e.publishMode),o="publish-sub-stream-to-cdn"===e.publishMode?1:0,s={requestTime:Date.now(),sessionId:i,streamId:r,streamType:o};await this.doStartPublishTencentCDN(s,e.publishMode);let{appId:a,bizId:n,url:d}=e;if(a&&n&&d){let t=this._paramsForTencentCDN.get(e.publishMode)||this._initParamsForTencentCDN;null!=t&&t.givenCDNManager||(t.givenCDNManager=new M(this._core,this._log),this._paramsForTencentCDN.set(e.publishMode,t)),await t.givenCDNManager.startPublishGivenCDN({publishMode:e.publishMode,appId:a,bizId:n,url:d,streamId:r})}}async doStartPublishTencentCDN(e,t){this._log.info("[CDNStreaming] doStartPublishTencentCDN: ".concat(JSON.stringify(e)));let r=0;for(;;){let i=await this._room.sendStartPublishCDN(e,!0),{code:o}=i.data,{message:s}=i.data;if(0===o){this._log.info("[CDNStreaming] server success: start tencent cdn"),this.changeDataStatus(t,{isPublished:!0});break}if(!(-10006===o&&r<6))throw this.changeDataStatus(t,{isPublished:!1}),-102083===o&&(s="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(o," errMsg: ").concat(s)),new Error("[CDNStreaming] server failed: start tencent cdn errCode: ".concat(o," errMsg: ").concat(s));this._log.warn("[CDNStreaming] doStartPublishTencentCDN: retry...".concat(r+1,"/6, reason: ").concat(s)),r+=1,await new Promise((e=>setTimeout(e,500)))}}async stopPublishTencentCDN(e){this._log.info("[CDNStreaming] doStartPublishTencentCDN: ".concat(JSON.stringify(e)));let t=this._paramsForTencentCDN.get(e)||this._initParamsForTencentCDN;if(t.isPublished){let{target:r}=t;null!=r&&r.bizId&&r.appId&&r.url&&null!=t&&t.givenCDNManager&&await(null==t?void 0:t.givenCDNManager.stopPublishGivenCDN()),await this.doStopPublishTencentCDN(e)}this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}async doStopPublishTencentCDN(e){let t={requestTime:Date.now(),sessionId:(0,w.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(e)))};this._log.info("[CDNStreaming] doStopPublishTencentCDN: ".concat(JSON.stringify(t)));let r=await this._room.sendStopPublishCDN(t,!0),{code:i}=r.data,{message:o}=r.data;if(0!==i)throw-102069===i&&(this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),o="can not stop in auto relayed-push mode ".concat(o)),this._log.error("[CDNStreaming] server failed: stop tencent cdn errCode: ".concat(i," errMsg: ").concat(o)),new Error("[CDNStreaming] server failed: stop tencent cdn errCode: ".concat(i," errMsg: ").concat(o));this._log.info("[CDNStreaming] server success: stop tencent cdn"),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN),this.reset(e)}reset(e){this.uninstallEvents(),this._paramsForTencentCDN.set(e,this._initParamsForTencentCDN)}generatePublishCDNStreamId(e,t){if(""===e){let e="".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(t));return/^[A-Za-z\d_-]*$/.test(e)||(e=(0,w.default)(e)),"".concat(this._room.sdkAppId,"_").concat(e)}return e}convertPublishModeToStreamType(e){return"publish-main-stream-to-cdn"===e?"main":"aux"}generatePublishCDNSessionId(e){return(0,w.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertPublishModeToStreamType(e)))}},x={type:"number",notLessThanZero:!0},R={type:"object",required:!0,properties:{userId:{required:!0,type:"string"},roomId:{type:["string","number"],validate:function(e,t,r,i){let{RtcError:o,ErrorCode:a,ErrorCodeDictionary:n}=s;if((e=>"string"==typeof e)(e))throw new o({code:a.INVALID_PARAMETER,extraCode:n.INVALID_ROOM_ID_INTEGER_STRING,fnName:r,messageParams:{key:"roomId"}});if(void 0!==e&&!(/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new o({code:a.INVALID_PARAMETER,extraCode:n.INVALID_ROOM_ID_INTEGER,fnName:r,messageParams:{key:"roomId"}})}},strRoomId:{type:"string",validate:function(e,t,r,i){let{RtcError:o,ErrorCode:a,ErrorCodeDictionary:n}=s;if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e))throw new o({code:a.INVALID_PARAMETER,extraCode:n.INVALID_ROOM_ID_STRING,fnName:r,messageParams:{key:"strRoomId"}})}}}},O={required:!0,properties:{publishMode:{required:!0,values:["publish-main-stream-to-cdn","publish-mix-stream-to-cdn","publish-sub-stream-to-cdn"]},streamId:{required:!1,type:"string",validate:function(e,t,r,i){if(!/^[A-Za-z\d_-]*$/.test(e)){let{RtcError:e,ErrorCode:t,ErrorCodeDictionary:r}=s;throw new e({code:t.INVALID_PARAMETER,extraCode:r.INVALID_STREAM_ID,messageParams:{key:"streamId"}})}}},appId:{type:"number",allowEmpty:!1},bizId:{type:"number",allowEmpty:!1},url:{type:"string",allowEmpty:!1}}},A={required:!1,type:"object",properties:{videoWidth:x,videoHeight:x,videoBitrate:((e,t)=>d(e,h(t)))(f({},x),{allowEmpty:!1}),videoFramerate:{type:"number",validate(e,t,r,i){if(e<=0||e>30){let{RtcError:e,ErrorCode:t}=s;throw new e({code:t.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoFramerate, the value must be between (0, 30]."})}}},videoGOP:{type:"number",validate(e,t,r,i){if(e<1||e>8){let{RtcError:e,ErrorCode:t}=s;throw new e({code:t.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> videoGOP, the value must be between [1, 8]."})}}},audioSampleRate:x,audioBitrate:{type:"number",validate(e,t,r,i){if(e<32||e>192){let{RtcError:e,ErrorCode:t}=s;throw new e({code:t.INVALID_PARAMETER,message:"Invalid parameter mixConfig -> audioBitrate, the value must be between [32, 192]."})}}},audioChannels:{type:"number",values:[1,2]}}},L={required:!1,type:"object",properties:{backgroundColor:{type:"number"},backgroundImage:{type:"string"},audioMixUserList:{type:"array",arrayItem:f({},R)},videoLayoutList:{type:"array",required:!0,arrayItem:{type:"object",properties:{fixedVideoUser:f({},R),fixedVideoStreamType:{type:"string",required:!0,values:["main","sub"]},fillMode:{type:"number",values:[0,1,2,4]},zOrder:{type:"number",required:!0,validate(e,t,r,i){if(e<1||e>15){let{RtcError:e,ErrorCode:t}=s;throw new e({code:t.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList -> zOrder, the value must be between [1, 15]."})}}},width:x,height:x,locationX:x,locationY:x}}}}},j=0,G=class{constructor(e){this.core=e,C(this,"_mixTranscodeManager"),C(this,"_publishCDNManager"),C(this,"_core"),C(this,"_modeOptions"),C(this,"seq"),C(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 P(e,this._log),this._publishCDNManager=new E(e,this._log)}getName(){return"CDNStreaming"}getAlias(){return"cdn"}getValidateRule(e){switch(e){case"start":return function(e){return s=e.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:f({},O),encoding:f({},A),mix:f({},L)},validate(t,r,i,o){var s,a;let{publishMode:n}=t.target,{encoding:d,mix:c}=t;if("publish-mix-stream-to-cdn"===n){let{RtcError:t,ErrorCode:r,ErrorCodeDictionary:o}=e.errorModule;if(!d)throw new t({code:r.INVALID_PARAMETER,extraCode:o.INVALID_PARAMETER_REQUIRED,fnName:i,messageParams:{key:"encoding"}});if(!c)throw new t({code:r.INVALID_PARAMETER,extraCode:o.INVALID_PARAMETER_REQUIRED,fnName:i,messageParams:{key:"mix"}});if(c&&c.videoLayoutList){let i=0,o=0,n=[];if(c.videoLayoutList.forEach(((e,t)=>{n.push(e.fixedVideoUser.userId),e.width+e.locationX>i&&(i=e.width+e.locationX),e.height+e.locationY>o&&(o=e.height+e.locationY)})),n.indexOf(e.room.userId)<0)throw new t({code:r.INVALID_PARAMETER,message:"Invalid parameter mix -> videoLayoutList, the value must be include self."});let h=null!=(s=null==d?void 0:d.videoWidth)?s:640,l=null!=(a=null==d?void 0:d.videoHeight)?a:480;if(h<i||l<o)throw new t({code:r.INVALID_PARAMETER,message:"Invalid parameter encoding, the width and height of the mixed video must encompass all the mixed-in video streams."})}}}}}(this._core);case"update":return function(e){return s=e.errorModule,{name:"CDNStreamingOptions",type:"object",required:!0,allowEmpty:!1,properties:{target:f({},O),encoding:f({},A),mix:f({},L)}}}(this._core);case"stop":return function(e){return s=e.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"]}}}}}}(this._core)}}getGroup(e){return e.target.publishMode}async start(e){return this._modeOptions.set(e.target.publishMode,e),await this.doStart(e)}async update(e){let t=this._modeOptions.get(e.target.publishMode);return this._core.utils.deepMerge(t,e),await this.doStart(t)}async stop(e){switch(e.target.publishMode){case"publish-mix-stream-to-cdn":await this._mixTranscodeManager.stopMixTranscode();break;case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":await this._publishCDNManager.stopPublishTencentCDN(e.target.publishMode)}this._modeOptions.delete(e.target.publishMode)}async doStart(e){switch(this._log.info("[CDNStreaming] doStart: ".concat(JSON.stringify(e))),e.target.publishMode){case"publish-mix-stream-to-cdn":await this._mixTranscodeManager.startMixTranscode(e);break;case"publish-main-stream-to-cdn":case"publish-sub-stream-to-cdn":await this._publishCDNManager.startPublishTencentCDN(e.target)}}};C(G,"TYPE",{PublishMode:{PublishMainStreamToCDN:"publish-main-stream-to-cdn",PublishSubStreamToCDN:"publish-sub-stream-to-cdn",PublishMixStreamToCDN:"publish-mix-stream-to-cdn"}});var q=G;e.CDNStreaming=G,e.PublishMode=I,e.TRTCStreamType=v,e.default=q,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("core-js/modules/es.array.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.regexp.exec.js")):"function"==typeof define&&define.amd?define(["exports","core-js/modules/es.array.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/es.promise.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.regexp.exec.js"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).CDNStreaming={});
|