UNPKG

zego-express-engine-webrtc

Version:

zego webrtc express sdk

1 lines 23.1 kB
!function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n(require("long"));else if("function"==typeof define&&define.amd)define(["long"],n);else{var i="object"==typeof exports?n(require("long")):n(t.long);for(var r in i)("object"==typeof exports?exports:t)[r]=i[r]}}("undefined"!=typeof self?self:this,(function(t){return function(){"use strict";var n={6994:function(n){n.exports=t}},i={};function r(t){var o=i[t];if(void 0!==o)return o.exports;var e=i[t]={exports:{}};return n[t](e,e.exports,r),e.exports}r.d=function(t,n){for(var i in n)r.o(n,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};function e(t){return"number"==typeof t}function u(t){return void 0===t}function s(t){return null!==t&&t instanceof Object}function c(t){return t instanceof MediaStream}function f(t){return t instanceof HTMLVideoElement}function a(t){return t instanceof HTMLImageElement}r.r(o),r.d(o,{StreamCompositor:function(){return lt}});r(6994);var h={code:1100001,message:g},l={code:1103074,message:"video track is not readable"},v={code:1103076,message:"audio track is not readable"},d={code:1103077,message:"compositor blur not support."},m=Promise,p=document;var y="stream is not from zego",g="input param error";var b,w=function(){function t(t,n,i){this.t=t,this.i=n,this.u=i,this.fps=15,this.outputBitrate=1500,this.hasPortrait=!1,this.isClear=!1,this.canvasEl=p.createElement("canvas"),this.ctx=this.canvasEl.getContext("2d")}return t.prototype.setVideoConfig=function(t){var n=t.height,i=t.frameRate,r=t.bitrate;this.canvasEl.width=t.width,this.canvasEl.height=n,i&&(this.fps=i),r&&(this.outputBitrate=r)},t.prototype.setInputsOption=function(t){var n=this;this.isClear=!0,this.layers=t.filter((function(t){var n=t.stream,i=t.option,r=a(t.source),o=void 0!==i.contentType&&["ALL","VIDEO"].includes(i.contentType),e=!i.contentType||o,u=n&&n.getVideoTracks();if(0==(null==u?void 0:u.length)&&o)throw l;return r||e&&u&&(null==u?void 0:u.length)>0})).map((function(t){var i,r=t.source,o=t.stream,e=t.option;if(o&&"safari"===n.i.browser){var u=n.u.checkPreview(o);u.backgroundProcessor?(i=u.backgroundProcessor.getCanvas(),n.bgProcessor=u.backgroundProcessor,n.hasPortrait=!0):n.hasPortrait=!1}return{source:r,option:e,canvas:i}})),this.layers.sort((function(t,n){var i,r;return void 0!==(null===(i=t.option.layout)||void 0===i?void 0:i.zOrder)&&void 0!==(null===(r=n.option.layout)||void 0===r?void 0:r.zOrder)?t.option.layout.zOrder-n.option.layout.zOrder:-1}))},t.prototype.checkVideoInputs=function(t){var n=!0;return t.forEach((function(t){var i=t.stream,r=t.option,o=void 0!==r.contentType&&["ALL","VIDEO"].includes(r.contentType),e=i&&i.getVideoTracks();0==(null==e?void 0:e.length)&&o&&(n=!1)})),n},t.prototype.generateVideoTrack=function(){var t,n=this;if(this.hasPortrait?null===(t=this.bgProcessor)||void 0===t||t.setDrawBack((function(){n.draw()})):this.intervalId||(this.intervalId=setInterval((function(){n.draw()}),1e3/this.fps)),!this.canvasTrack){var i=this.canvasEl.captureStream("firefox"===this.i.browser?void 0:this.fps);this.canvasTrack=i.getVideoTracks()[0]}return this.canvasTrack},t.prototype.stopOutputStream=function(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.layers.forEach((function(t){t.source&&f(t.source)&&(t.source.pause(),t.source.remove(),t.source.srcObject=null,t.source=null)})),this.u.trackUtils.stopTrack(this.canvasTrack),this.canvasTrack=null,this.ctx=null,this.layers=[]},t.prototype.draw=function(){var t,n;if(this.ctx){this.ctx.clearRect(0,0,this.canvasEl.width,this.canvasEl.height);for(var i=0;i<this.layers.length;i++){var r=this.layers[i],o=r.source,e=r.option,u=r.canvas;if(e.layout){var s=e.layout,c=s.x,h=s.y,l=s.width,v=s.height,d=f(o)?o.videoWidth:a(o)?o.naturalWidth:0,m=f(o)?o.videoHeight:a(o)?o.naturalHeight:0;if(0==d||0==m)continue;var p=u||o;switch(e.objectFit){case"contain":if(l/v<=d/m){var y=(v-(b=l*m/d))/2;null===(t=this.ctx)||void 0===t||t.drawImage(p,c,h+y,l,b)}else{y=(l-(g=v*d/m))/2;null===(n=this.ctx)||void 0===n||n.drawImage(p,c+y,h,g,v)}break;case"cover":var g,b;if(l/v<=d/m)this.ctx.drawImage(p,(d-(g=l*m/v))/2,0,g,m,c,h,l,v);else this.ctx.drawImage(p,0,(m-(b=d*v/l))/2,d,b,c,h,l,v);break;case"fill":this.ctx.drawImage(p,c,h,l,v)}}}}},t}(),_=function(){function t(t,n,i){this.t=t,this.ac=n,this.u=i,this.inputs=[],this.descNode=this.ac.createMediaStreamDestination()}return t.prototype.setInputsOption=function(t){var n=this;this.inputs=t.filter((function(t){var i=t.stream,r=t.option,o=i&&i.getAudioTracks(),e=n.u.checkPreview(i),u=void 0!==r.contentType&&["ALL","AUDIO"].includes(r.contentType);if((0==(null==o?void 0:o.length)||(null==e?void 0:e.hasEmptyAudioTrack))&&u)throw v;return o&&(null==o?void 0:o.length)>0})),this.inputs.forEach((function(t){var n,i,r=t.audioNodes,o=t.option;(void 0===t.option.volume&&(t.option.volume=100),r)&&(!o.contentType||["ALL","AUDIO"].includes(o.contentType)?(!r.hasAudio&&(null===(n=null==r?void 0:r.srcNode)||void 0===n||n.connect(r.volumeNode)),r.hasAudio=!0,e(t.option.volume)&&(r.volumeNode.gain.value=t.option.volume/100)):(null===(i=null==r?void 0:r.srcNode)||void 0===i||i.disconnect(r.volumeNode),r.hasAudio=!1))}))},t.prototype.checkAudioInputs=function(t){var n=this,i=!0;return t.forEach((function(t){var r=t.stream,o=t.option,e=r&&r.getAudioTracks(),u=n.u.checkPreview(r),s=void 0!==o.contentType&&["ALL","AUDIO"].includes(o.contentType);(0==(null==e?void 0:e.length)||(null==u?void 0:u.hasEmptyAudioTrack))&&s&&(i=!1)})),i},t.prototype.generateAudioTrack=function(){for(var t,n=0;n<this.inputs.length;n++){var i=this.inputs[n],r=i.stream,o=i.option,e=!o.contentType||["ALL","AUDIO"].includes(o.contentType),u=this.createAudioNode(r,i.option.volume),s=u.srcNode,c=u.volumeNode;e&&(null==s||s.connect(c)),i.audioNodes={srcNode:s,volumeNode:c,hasAudio:e}}var f=null===(t=this.descNode)||void 0===t?void 0:t.stream.getAudioTracks();return f&&f.length>0?f[0]:(this.ac.resume(),null)},t.prototype.createAudioNode=function(t,n){var i=this.ac.createMediaStreamSource(t),r=this.ac.createGain();return r.gain.value=n/100,r.connect(this.descNode),{srcNode:i,volumeNode:r}},t.prototype.stopAudioCompositor=function(){for(var t=0;t<this.inputs.length;t++){var n=this.inputs[t],i=n.audioNodes,r=n.option;if(i){var o=i.srcNode,e=i.volumeNode;(!r.contentType||["ALL","AUDIO"].includes(r.contentType))&&(null==o||o.disconnect(e),null==e||e.disconnect(this.descNode)),i.volumeNode=null,i.srcNode=null}this.descNode=null}this.inputs=[]},t.prototype.replaceSource=function(t){var n=this;this.inputs.forEach((function(i){var r=i.stream,o=i.audioNodes;if(t===r&&o){var e=o.srcNode,u=o.volumeNode,s=o.hasAudio,c=n.ac.createMediaStreamSource(r);s&&(null==e||e.disconnect(u),c.connect(u)),o.srcNode=c}}))},t}();!function(t){t.STREAM_COMPOSITOR_MODULE="zc.scm.0"}(b||(b={}));var T=function(t){return t},N=function(t){return t},O={event:"/sdk/create_stream_zgp_compositor"},I={event:"/sdk/start_compositing_stream",error:{},media_stream_id:N,compose_stream_conf:T};var E,L,D="/sdk/init",M=D;!function(t){t[t.SWITCH_ONE=1]="SWITCH_ONE",t[t.SWITCH_TWO=2]="SWITCH_TWO"}(E||(E={})),function(t){t[t.ZegoGeoFenceTypeNone=0]="ZegoGeoFenceTypeNone",t[t.ZegoGeoFenceTypeInclude=1]="ZegoGeoFenceTypeInclude",t[t.ZegoGeoFenceTypeExclude=2]="ZegoGeoFenceTypeExclude"}(L||(L={}));var S,k;!function(t){t[t.TT_NONE=0]="TT_NONE",t[t.TT_PC=1]="TT_PC",t[t.TT_IOS=2]="TT_IOS",t[t.TT_ANDROID=3]="TT_ANDROID",t[t.TT_MAC=4]="TT_MAC",t[t.TT_LINUX=5]="TT_LINUX",t[t.TT_WEB=6]="TT_WEB",t[t.TT_MINIPROGRAM=7]="TT_MINIPROGRAM",t[t.TT_UNKNOWN=32]="TT_UNKNOWN"}(S||(S={})),function(t){t[t.disconnected=0]="disconnected",t[t.connecting=1]="connecting",t[t.connected=2]="connected"}(k||(k={}));var C,A,j,x;!function(t){t[t.logout=0]="logout",t[t.trylogin=1]="trylogin",t[t.login=2]="login"}(C||(C={})),function(t){t[t.I=0]="I",t[t.H=10]="H",t[t.M=100]="M",t[t.L=1e3]="L"}(A||(A={})),function(t){t[t.offline=0]="offline",t[t.online=1]="online"}(j||(j={})),function(t){t[t.NT_NONE=0]="NT_NONE",t[t.NT_LINE=1]="NT_LINE",t[t.NT_WIFI=2]="NT_WIFI",t[t.NT_2G=3]="NT_2G",t[t.NT_3G=4]="NT_3G",t[t.NT_4G=5]="NT_4G",t[t.NT_UNKNOWN=32]="NT_UNKNOWN"}(x||(x={}));var U;!function(t){t[t.debug=0]="debug",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error",t[t.report=99]="report",t[t.disable=100]="disable"}(U||(U={}));var W,G,P;!function(t){t[t.disable=0]="disable",t[t.websocket=1]="websocket",t[t.https=2]="https"}(W||(W={})),function(t){t[t.SDKProject_ZegoWebRTC=6]="SDKProject_ZegoWebRTC",t[t.SDKProject_ZegoMiniProgram=7]="SDKProject_ZegoMiniProgram"}(G||(G={})),function(t){t[t.UDP=0]="UDP",t[t.RTMP=1]="RTMP",t[t.FLV=2]="FLV",t[t.HLS=3]="HLS",t[t.WEBRTC=4]="WEBRTC"}(P||(P={}));var H,z;H=1,function(){var t=1}();!function(t){t[t.ClientType_None=0]="ClientType_None",t[t.ClientType_H5=1]="ClientType_H5",t[t.ClientType_SmallPragram=2]="ClientType_SmallPragram",t[t.ClientType_Webrtc=3]="ClientType_Webrtc"}(z||(z={}));var R,F,V,Q,K,Z,B,q,X,J,Y,$,tt;!function(t){t[t.Default=0]="Default",t[t.Extranet=1]="Extranet",t[t.Intranet=2]="Intranet"}(R||(R={})),function(t){t[t.logout=0]="logout",t[t.trylogin=1]="trylogin",t[t.login=2]="login"}(F||(F={})),function(t){t[t.logout=0]="logout",t[t.trylogin=1]="trylogin",t[t.login=2]="login",t[t.reconnect=3]="reconnect"}(V||(V={})),function(t){t[t.stop=0]="stop",t[t.start=1]="start"}(Q||(Q={})),function(t){t[t.CDN=0]="CDN",t[t.RTC=1]="RTC",t[t.L3=2]="L3",t[t.DG=3]="DG"}(K||(K={})),function(t){t[t.useAnalyzer=0]="useAnalyzer",t[t.useWorklet=1]="useWorklet"}(Z||(Z={})),function(t){t[t.Default=3]="Default",t[t.StandardVideoCall=4]="StandardVideoCall",t[t.HighVideoCall=5]="HighVideoCall",t[t.StandardChatroom=6]="StandardChatroom",t[t.HighQualityChatroom=7]="HighQualityChatroom",t[t.Broadcast=8]="Broadcast",t[t.Karaoke=9]="Karaoke",t[t.UNKNOWN=100]="UNKNOWN"}(B||(B={})),function(t){t.WIN32="WIN32",t.MAC="Mac",t.ANDROID="Android",t.LINUX="Linux",t.IOS="iOS",t.Harmony="Harmony",t.UNKNOWN="WTF"}(q||(q={})),function(t){t.CDN="cdn",t.L3="l3",t.RTC="rtc"}(X||(X={})),function(t){t[t.RTC=0]="RTC",t[t.CDN=1]="CDN",t[t.L3=2]="L3",t[t.DG=3]="DG",t[t.CUSTOM=5]="CUSTOM"}(J||(J={})),function(t){t[t.offline=0]="offline",t[t.online=1]="online"}(Y||(Y={})),function(t){t[t.MinQuality=0]="MinQuality",t[t.DieQuality=0]="DieQuality",t[t.PoorMinQuality=1]="PoorMinQuality",t[t.MiddleMinQuality=30]="MiddleMinQuality",t[t.GoodMinQuality=60]="GoodMinQuality",t[t.ExcellentMinQuality=85]="ExcellentMinQuality",t[t.MaxQuality=100]="MaxQuality"}($||($={})),function(t){t[t.Unknown=-1]="Unknown",t[t.Excellent=0]="Excellent",t[t.Good=1]="Good",t[t.Middle=2]="Middle",t[t.Poor=3]="Poor",t[t.Die=4]="Die"}(tt||(tt={}));var nt,it,rt=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=null),this.next=null,this.prev=null,this._id=t,this._data=n}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id?this._id:null},set:function(t){this._id=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this._data},set:function(t){this._data=t},enumerable:!1,configurable:!0}),t.prototype.hasNext=function(){return this.next&&this.next.id},t.prototype.hasPrev=function(){return this.prev&&this.prev.id},t}();!function(){function t(){this.start=new rt,this.end=new rt,this._idCounter=0,this._numNodes=0,this.start.next=this.end,this.start.prev=null,this.end.prev=this.start,this.end.next=null}t.prototype.insertBefore=function(t,n){var i=new rt(this._idCounter,n);return i.next=t,i.prev=t.prev,t.prev&&(t.prev.next=i),t.prev=i,++this._idCounter,++this._numNodes,i},t.prototype.addLast=function(t){return this.insertBefore(this.end,t)},t.prototype.add=function(t){return this.addLast(t)},t.prototype.getFirst=function(){return 0===this._numNodes?null:this.start.next},t.prototype.getLast=function(){return 0===this._numNodes?null:this.end.prev},t.prototype.size=function(){return this._numNodes},t.prototype.getFromFirst=function(t){var n=0,i=this.start.next;if(t>=0)for(;n<t&&null!==i;)i=i.next,++n;else i=null;if(null===i)throw"Index out of bounds.";return i},t.prototype.get=function(t){return 0===t?this.getFirst():t===this._numNodes-1?this.getLast():this.getFromFirst(t)},t.prototype.remove=function(t){return t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),--this._numNodes,t},t.prototype.removeFirst=function(){var t=null;return this._numNodes>0&&this.start.next&&(t=this.remove(this.start.next)),t},t.prototype.removeLast=function(){var t=null;return this._numNodes>0&&this.end.prev&&(t=this.remove(this.end.prev)),t},t.prototype.removeAll=function(){this.start.next=this.end,this.end.prev=this.start,this._numNodes=0,this._idCounter=0},t.prototype.each=function(t){for(var n=this.start;n.hasNext();)t(n=n.next)},t.prototype.find=function(t){for(var n=this.start,i=!1,r=null;n.hasNext()&&!i;)t(n=n.next)&&(r=n,i=!0);return r},t.prototype.map=function(t){for(var n=this.start,i=[];n.hasNext();)t(n=n.next)&&i.push(n);return i},t.prototype.push=function(t){return this.addLast(t)},t.prototype.unshift=function(t){this.insertBefore(this._numNodes>0?this.start.next:this.end,t)},t.prototype.pop=function(){return this.removeLast()},t.prototype.shift=function(){return this.removeFirst()}}();function ot(){return navigator.userAgent||""}!function(t){t.ONLY_BASELINE="only_baseline",t.HARD_SOFT_ENCODEC_FIRST="hard_or_soft_encodec_first",t.HIGH_PROFILE_FIRST="high_profile_first"}(nt||(nt={})),function(t){t[t.None=0]="None",t[t.Vocalist=1]="Vocalist",t[t.BackingSinging=2]="BackingSinging"}(it||(it={}));var et,ut=function(){return ut=Object.assign||function(t){for(var n,i=1,r=arguments.length;i<r;i++)for(var o in n=arguments[i])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},ut.apply(this,arguments)},st=function(t,n,i,r){return new(i||(i=Promise))((function(o,e){function u(t){try{c(r.next(t))}catch(t){e(t)}}function s(t){try{c(r.throw(t))}catch(t){e(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof i?n:new i((function(t){t(n)}))).then(u,s)}c((r=r.apply(t,n||[])).next())}))},ct=function(t,n){var i,r,o,e,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return e={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function s(s){return function(c){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;e&&(e=0,s[0]&&(u=0)),u;)try{if(i=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,r=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){u.label=s[1];break}if(6===s[0]&&u.label<o[1]){u.label=o[1],o=s;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(s);break}o[2]&&u.ops.pop(),u.trys.pop();continue}s=n.call(t,u)}catch(t){s=[6,t],r=0}finally{i=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},ft=function(){function t(t,n,i,r){this.t=t,this.i=n,this.u=i,this.ac=r,this.mixOutputConfig={width:0,height:0,frameRate:15,bitrate:2500},this.inputStreamOptions=[],this.fit="cover",this.videoCompositor=new w(t,n,i),this.audioCompositor=new _(t,r,i)}return t.prototype.setOutputConfig=function(t){var n=t.height,i=t.frameRate,r=t.bitrate;if(!e(t.width))throw Error("param width error");if(!e(n))throw Error("param height error");if(!u(i)&&!e(i))throw Error("param frameRate error");if(!u(r)&&!e(r))throw Error("param bitrate error");this.mixOutputConfig=ut(ut({},this.mixOutputConfig),t),this.videoCompositor.setVideoConfig(this.mixOutputConfig)},t.prototype.setInputEndpoint=function(t,n){return st(this,void 0,void 0,(function(){var i,r,o;return ct(this,(function(e){switch(e.label){case 0:if(i=function(t,n){if(t&&!c(t)&&t.zegoStream){if(n.info("cu.gs type:zego"),c(t.stream))return t.stream;throw new Error("The ZegoLocalStream type requires first calling the capture api to capture the stream")}return t}(t,this.t),!this.checkStreamIsLocal(i))throw Error(y);return r=this.inputStreamOptions.find((function(t){return t.stream===i})),this.checkInputOption(n,!!r),r?(r.option=this.assignObj(r.option,n),[3,3]):[3,1];case 1:return[4,this.createVideo(i)];case 2:o=e.sent(),this.addInputLayer({source:o,stream:i,option:ut({objectFit:this.fit},n)}),e.label=3;case 3:if(!this.videoCompositor.checkVideoInputs(this.inputStreamOptions))throw l;if(!this.audioCompositor.checkAudioInputs(this.inputStreamOptions))throw v;return this.videoCompositor.setInputsOption(this.inputStreamOptions),this.audioCompositor.setInputsOption(this.inputStreamOptions),[2]}}))}))},t.prototype.addImage=function(t,n){this.checkImg(t);var i=this.inputStreamOptions.find((function(n){return n.source===t}));this.checkInputOption(n,!!i),i?i.option=this.assignObj(i.option,n):this.addInputLayer({source:t,option:ut({objectFit:this.fit},n)}),this.videoCompositor.setInputsOption(this.inputStreamOptions)},t.prototype.removeImage=function(t){this.checkImg(t);var n=this.inputStreamOptions.findIndex((function(n){return n.source===t}));n>0&&(this.inputStreamOptions.splice(n,1),this.videoCompositor.setInputsOption(this.inputStreamOptions))},t.prototype.startComposingStream=function(){var t=this;return new m((function(n,i){if(!t.checkOutputs())return t.t.error("zc.sc.scs.0 output config error"),void i(h);if(!t.checkInputs())return t.t.error("zc.sc.scs.0 input params error"),void i(h);if(!t.checkBrowserSupport())return t.t.error("zc.sc.scs.0 browser not support compositor"),void i(d);t.videoCompositor.setInputsOption(t.inputStreamOptions);var r=t.videoCompositor.generateVideoTrack();t.audioCompositor.setInputsOption(t.inputStreamOptions);var o=t.audioCompositor.generateAudioTrack();t.uploadEvent();var e=[r];o&&e.push(o);var u=new MediaStream(e);t.outputStream=u,t.u.createCompositingPreviewer(u,t.mixOutputConfig,t.inputStreamOptions),n(u)}))},t.prototype.stopComposingStream=function(){var t=this;return new m((function(n){var i,r;if(t.outputStream){var o=t.u.checkPreview(t.outputStream);o&&(null===(i=o.rtcViewer)||void 0===i||i.destroy(),o.streamCompositor=null,t.u.removePreview(o)),null===(r=t.outputStream)||void 0===r||r.getTracks().forEach((function(n){t.u.trackUtils.stopTrack(n)}))}try{t.videoCompositor.stopOutputStream(),t.audioCompositor.stopAudioCompositor()}catch(t){n(!1)}t.inputStreamOptions=[],n(!0)}))},t.prototype.checkInputs=function(){var t=this.mixOutputConfig,n=t.width,i=t.height;return this.inputStreamOptions.every((function(t){var r=t.option.layout;return r.x<=n&&r.y<=i&&r.x+r.width<=n&&r.y+r.height<=i&&r.width<=n&&r.height<=i}))},t.prototype.checkOutputs=function(){var t=this.mixOutputConfig;return t.width>0&&t.height>0&&t.frameRate>0&&t.bitrate>0},t.prototype.uploadEvent=function(){var t=this.i.reporter.createSpan(et.H,{key:M},{key:""},I.event),n=this.inputStreamOptions.map((function(t){var n=t.option,i=n.layout,r=n.objectFit,o=n.contentType;return{content_control:"AUDIO"===o?1:"VIDEO"===o?2:0,x:i.x,y:i.y,w:i.width,h:i.height,order:i.zOrder,render_mode:"cover"===r?0:"contain"===r?1:2}})),i=this.mixOutputConfig;t.setAttributes({compose_stream_conf:I.compose_stream_conf({fps:i.frameRate,bitrate:i.bitrate,w:i.width,h:i.height,stream_cnt:n.length,input_stream_list:n})}),t.end()},t.prototype.checkImg=function(t){if(!t||!a(t)||!t.naturalWidth)throw this.t.error(b.STREAM_COMPOSITOR_MODULE+" source must be image and loaded"),Error("source must be image and loaded")},t.prototype.checkInputOption=function(t,n){var i=this,r=t.layout,o=t.objectFit,e=t.contentType;if(!u(r)){if(!s(r))throw Error("param layout error");["x","y","width","height"].forEach((function(t){i.checkNumParam(r,t,n)})),this.checkOptionalNumOptParam(r,"zOrder")}if(!u(o)&&!["cover","contain","fill"].includes(o))throw Error("param objectFit error");if(!u(e)&&!["ALL","VIDEO","AUDIO"].includes(e))throw Error("param contentType error");this.checkOptionalNumOptParam(t,"volume")},t.prototype.checkNumParam=function(t,n,i){if(i&&void 0===t[n]);else if(!e(t[n]))throw Error("param ".concat(n," error"))},t.prototype.checkOptionalNumOptParam=function(t,n){if(void 0!==t[n]&&!e(t[n]))throw Error("param ".concat(n," error"))},t.prototype.checkStreamIsLocal=function(t){var n=this.u.checkPreview(t),i=this.u.checkPlayer(t);return n&&(n.streamCompositor=this),!!n||!!i},t.prototype.addInputLayer=function(t){var n,i=t.option;void 0===(null===(n=i.layout)||void 0===n?void 0:n.zOrder)&&(i.layout.zOrder=0),this.inputStreamOptions.push(t)},t.prototype.createVideo=function(t){return st(this,void 0,void 0,(function(){var n=this;return ct(this,(function(i){return[2,new m((function(i,r){return st(n,void 0,void 0,(function(){var n,o,e,u,s=this;return ct(this,(function(c){return(n=p.createElement("video")).setAttribute("autoplay","autoplay"),n.setAttribute("muted","true"),n.muted=!0,n.setAttribute("playsinline","playsinline"),n.setAttribute("style","display:none"),o=null,e=function(){o&&(clearTimeout(o),o=null),n.play().catch((function(t){console.error(t)})),o=window.setTimeout((function(){s.t.warn("zc.sc.cv video track error"),r(l)}),1e3)},u=function(){o&&clearTimeout(o),n&&n.removeEventListener("playing",u),i(n)},n&&n.addEventListener("playing",u),n.srcObject=t,n.play().catch((function(t){console.error(t)})),o=window.setTimeout((function(){e()}),1e3),[2]}))}))}))]}))}))},t.prototype.assignObj=function(t,n){void 0===t&&(t={});var i=t;if(!s(t)||!s(n))return n;for(var r in n)i[r]=t.hasOwnProperty(r)?this.assignObj(t[r],n[r]):n[r];return i},t.prototype.replaceSource=function(t){this.audioCompositor.replaceSource(t)},t.prototype.checkBrowserSupport=function(){var t=!0,n=function(){var t=ot().toLowerCase().match(/cpu iphone os (.*?) like mac os/);return t&&t[1]||""}();return n&&n.includes("14_6")&&(t=!1),t},t}(),at=function(){function t(t){this.l=t}return t.prototype.addImage=function(t,n){this.l.addImage(t,n)},t.prototype.removeImage=function(t){this.l.removeImage(t)},t.prototype.setInputEndpoint=function(t,n){return this.l.setInputEndpoint(t,n)},t.prototype.setOutputConfig=function(t){this.l.setOutputConfig(t)},t.prototype.startComposingStream=function(){return this.l.startComposingStream()},t.prototype.stopComposingStream=function(){return this.l.stopComposingStream()},t}();!function(t){t[t.I=0]="I",t[t.H=10]="H",t[t.M=100]="M",t[t.L=1e3]="L"}(et||(et={}));var ht={createStreamCompositor:function(){var t=this.reporter.createSpan(et.H,{key:M},{key:""},O.event),n=new ft(this.logger,this.stateCenter,this.streamCenter,this.ac);return t.end(),new at(n)}},lt={install:function(t){for(var n in ht)Object.defineProperty(t.prototype,n,{value:ht[n],writable:!1})},get type(){return"StreamCompositor"}};return o}()}));