@ylink-sdk/stream
Advanced tools
Comparing version 0.1.3 to 0.1.5
@@ -1,3 +0,3 @@ | ||
import { AudioSender, ChannelStatus, Handler, ParamsInit, ParamsStart, StreamConfig, VideoReceiver, VideoSender } from './types'; | ||
import { EVENTS, MEDIA_STATUS, MEDIA_STREAM_DETAIL, MEDIA_STREAM_STATUS, STATUS } from './types/enums'; | ||
import { AudioSender, ChannelStatus, ParamsInit, ParamsStart, StreamConfig, StreamEventHandler, VideoReceiver, VideoSender } from './types'; | ||
import { EVENT, MEDIA_STATUS, MEDIA_STREAM_DETAIL, MEDIA_STREAM_STATUS, STATUS } from './types/enums'; | ||
export default class Stream { | ||
@@ -7,3 +7,3 @@ /** | ||
*/ | ||
static EVENTS: typeof EVENTS; | ||
static EVENT: typeof EVENT; | ||
/** | ||
@@ -33,3 +33,3 @@ * Stream 状态 | ||
*/ | ||
on(type: EVENTS, handler: Handler): void; | ||
on<T extends keyof StreamEventHandler, V extends Pick<StreamEventHandler, T>[T]>(type: T, handler: V): void; | ||
/** | ||
@@ -40,3 +40,3 @@ * 移除事件监听 | ||
*/ | ||
off(type: EVENTS, handler?: Handler): void; | ||
off<T extends keyof StreamEventHandler, V extends Pick<StreamEventHandler, T>[T]>(type: T, handler?: V): void; | ||
/** | ||
@@ -79,3 +79,3 @@ * 初始化 | ||
*/ | ||
getStreamStatus(): STATUS; | ||
getStatus(): STATUS; | ||
/** | ||
@@ -82,0 +82,0 @@ * 获取配置的服务器地址 |
/** | ||
* Stream 通知事件 | ||
*/ | ||
export declare enum EVENTS { | ||
export declare enum EVENT { | ||
/** | ||
@@ -6,0 +6,0 @@ * Stream 状态事件 |
@@ -0,1 +1,3 @@ | ||
import { MediaEventHandler } from './media'; | ||
import { EVENT, STATUS } from './enums'; | ||
/** | ||
@@ -158,2 +160,15 @@ * Stream 实例化配置 | ||
} | ||
export declare type Handler<T = Record<string, unknown>> = (event: T[keyof T]) => void; | ||
export declare type StreamEventHandler = { | ||
[EVENT.STREAM_STATUS]: (payload: { | ||
status: STATUS; | ||
}) => void; | ||
[EVENT.CHANNEL_BUSY]: () => void; | ||
[EVENT.CHANNEL_REFRESH]: () => void; | ||
[EVENT.AUDIO_CHANNEL_OPENED]: () => void; | ||
[EVENT.DATA_CHANNEL_OPENED]: () => void; | ||
[EVENT.VIDEO_CHANNEL_OPENED]: () => void; | ||
} & MediaEventHandler; | ||
/** | ||
* 联合类型转为交叉类型 | ||
*/ | ||
export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; |
@@ -1,2 +0,2 @@ | ||
import { MEDIA_STREAM_STATUS, MEDIA_STREAM_DETAIL } from './enums'; | ||
import { EVENT, MEDIA_STREAM_DETAIL, MEDIA_STREAM_STATUS } from './enums'; | ||
declare global { | ||
@@ -19,1 +19,39 @@ interface MediaStream { | ||
} | ||
export interface MediaEventHandler { | ||
[EVENT.AUDIO_INPUT_DEVICES_UPDATED]: (payload: { | ||
deviceList: MediaDeviceInfo[]; | ||
}) => void; | ||
[EVENT.AUDIO_OUTPUT_DEVICES_UPDATED]: (payload: { | ||
deviceList: MediaDeviceInfo[]; | ||
}) => void; | ||
[EVENT.VIDEO_INPUT_DEVICES_UPDATED]: (payload: { | ||
deviceList: MediaDeviceInfo[]; | ||
}) => void; | ||
[EVENT.AUDIO_INPUT_DEVICE_CHANGED]: (payload: { | ||
device: MediaDeviceInfo | null; | ||
}) => void; | ||
[EVENT.AUDIO_OUTPUT_DEVICE_CHANGED]: (payload: { | ||
device: MediaDeviceInfo | null; | ||
}) => void; | ||
[EVENT.VIDEO_INPUT_DEVICE_CHANGED]: (payload: { | ||
device: MediaDeviceInfo | null; | ||
}) => void; | ||
[EVENT.AUDIO_STREAM]: (payload: { | ||
stream: MediaStream | null; | ||
}) => void; | ||
[EVENT.VIDEO_STREAM]: (payload: { | ||
stream: MediaStream | null; | ||
}) => void; | ||
[EVENT.SHARE_CONTENT_STREAM]: (payload: { | ||
stream: MediaStream | null; | ||
}) => void; | ||
[EVENT.AUDIO_STREAM_STATUS]: (payload: { | ||
status: MEDIA_STREAM_STATUS; | ||
}) => void; | ||
[EVENT.VIDEO_STREAM_STATUS]: (payload: { | ||
status: MEDIA_STREAM_STATUS; | ||
}) => void; | ||
[EVENT.SHARE_CONTENT_STREAM_STATUS]: (payload: { | ||
status: MEDIA_STREAM_STATUS; | ||
}) => void; | ||
} |
@@ -1,1 +0,1 @@ | ||
var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,this._status))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,this._status))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.SHARE_CONTENT_STREAM="shareContentStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.SHARE_CONTENT_STREAM_STATUS="shareContentStreamStatus"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,y=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],D=y.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));D&&(S=D.describe(navigator.userAgent));var E=S&&"Safari"===S.name,A=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,_=S&&"Microsoft Edge"===S.name,C=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=g(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),g=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]=(n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+function(t){var e=Math.abs(t);if(e>=w)return Math.round(t/w)+"d";if(e>=N)return Math.round(t/N)+"h";if(e>=O)return Math.round(t/O)+"m";if(e>=b)return Math.round(t/b)+"s";return t+"ms"}(0),!n)return[];var o="color: "+r;t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:U()};return t},b=1e3,O=60*b,N=60*O,w=24*N;var U=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},R=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},P=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},V=new C({namespace:"STREAM:Media",debug:!1}),M=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.shareContentQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._shareContentStreamStatus={status:h.NULL},i.onShareContentStreamInactive=i.shareContentStreamInactive.bind(i),V.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStreamStatus",{get:function(){return this._shareContentStreamStatus},set:function(t){var e=this._shareContentStreamStatus;e.status===t.status&&e.detail===t.detail||(this._shareContentStreamStatus=t,this.emit(u.SHARE_CONTENT_STREAM_STATUS,this._shareContentStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e;V.debug(o.AUDIO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e;V.debug(o.VIDEO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeShareContentStream(),this.cleanup()}catch(t){V.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return V.error("enumerate devices error: ",t)}))]:(V.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],V.debug("deviceList: "+JSON.stringify(this.deviceList)),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&A?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!E&&Object.assign(e.audio,k),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(A?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,x),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),V.debug("audio constraints: "+JSON.stringify(e)),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),V.debug("getUserMedia error: "+a),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:j.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),V.debug("video constraints: "+JSON.stringify(t)),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getUserMedia error: "+o),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:G.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createShareContentStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:H}),V.debug("shareContent constraints: "+JSON.stringify(t)),e=null,i=this.shareContentStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getDisplayMedia error: "+o),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:F.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,shareContentStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,this.audioStream)},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,this.videoStream)},a.prototype.closeShareContentStream=function(){var t=this;this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onShareContentStreamInactive)})),this.shareContentStream.close());this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,this.shareContentStream)},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,this.audioStream),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,this.audioStream),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,this.videoStream),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,this.videoStream),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureShareContentStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.shareContentQueue=this.shareContentQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createShareContentStream()];case 1:return t=r.sent(),e=t.stream,n=t.shareContentStreamStatus,this.shareContentStreamStatus.status!==h.NULL||e?(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&!e||(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream.close(),this.shareContentStream=null),e&&e.addEventListener("inactive",this.onShareContentStreamInactive),A&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream=e,this.shareContentStreamStatus=n,this.emit(u.SHARE_CONTENT_STREAM,this.shareContentStream)),[2,Promise.resolve(this.shareContentStream)]):[2,Promise.resolve(this.shareContentStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.shareContentStreamInactive=function(){this.shareContentStream&&(this.shareContentStream.close(),this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,this.shareContentStream))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),k={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},x={aspectRatio:16/9,frameRate:30,width:640,height:360},H={width:1920,height:1080,frameRate:5},j=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),B=function(){return M.instance},X=new C({namespace:"STREAM:Store",debug:!1}),z=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(n+"/webapp/front/getMss",{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",X.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:t+"/libsfu.prod.js"}),this.createScriptTag({src:t+"/librtc.global.prod.js"})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src;return new Promise((function(t,n){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.onload=function(){t(i)},i.onerror=function(t){n(t)},document.head.appendChild(i)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.dataChannel,o=t.mediaEndpoint,r.label=1;case 1:return r.trys.push([1,8,,9]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return i?[4,i.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return o&&(o.stop(),o.destroy()),[3,9];case 8:return a=r.sent(),X.error(a),[3,9];case 9:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,[2]}}))}))},t}(),J=function(){return z.instance},Y=new C({namespace:"STREAM:Store",debug:!1}),Q=function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,Y.switchDebug(r),e={debug:r},z.createInstance(e),function(t){M.createInstance(t)}({debug:r}),J().setBaseUrl(n),J().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return B().on(u.AUDIO_STREAM,(function(t){J().emitter.emit(u.AUDIO_STREAM,t)})),B().on(u.VIDEO_STREAM,(function(t){J().emitter.emit(u.VIDEO_STREAM,t)})),B().on(u.SHARE_CONTENT_STREAM,(function(t){J().emitter.emit(u.SHARE_CONTENT_STREAM,t)})),B().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){J().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){J().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),B().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){J().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){J().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){J().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),B().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){J().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_STREAM_STATUS,(function(t){J().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),B().on(u.VIDEO_STREAM_STATUS,(function(t){J().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),B().on(u.SHARE_CONTENT_STREAM_STATUS,(function(t){J().emitter.emit(u.SHARE_CONTENT_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return J().emitter.on(t,e)},t.prototype.off=function(t,e){return J().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,B().init(t)];case 1:return e.sent(),J().status=c.INIT,J().emitter.emit(u.STREAM_STATUS,J().status),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return J().throwIfStatus(c.NULL),J().throwIfStatus(c.START),[4,J().loadLibRTCFiles().catch((function(t){Y.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return J().emitter.emit(u.CHANNEL_REFRESH),[4,J().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){Y.error(t)}))];case 1:return t=i.sent(),Y.debug("response "+t),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=J().baseURL;return"wss://"+(/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e)+"/webapp/socket/"+window.btoa(t.replace(/\w+:\/\//,""))}))]):(Y.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),J().setMediaEndpoint(f),J().setMediaEngine(v),J().status=c.START,J().emitter.emit(u.STREAM_STATUS,J().status),[2]}}))}))},t.prototype.stop=function(){J().throwIfNotStatus(c.START),J().cleanup(),B().shareContentStreamStatus.status!==h.NULL&&B().closeShareContentStream(),J().status=c.STOP,J().emitter.emit(u.STREAM_STATUS,J().status)},t.prototype.destroy=function(){this.stop(),this.cleanup(),J().status!==c.NULL&&(B().destroy(),J().status=c.NULL,J().emitter.emit(u.STREAM_STATUS,J().status))},t.prototype.getStreamStatus=function(){return J().status},t.prototype.getBaseUrl=function(){return J().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:J().audioChannelOpened,videoChannelOpened:J().videoChannelOpened,dataChannelOpened:J().dataChannelOpened}},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),t=J().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),J().setAudioChannel(o),o.onopen=function(){Y.debug("audioChannel onopen()"),J().audioChannelOpened=!0,J().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=J().audioChannel)?[4,t.close()]:(Y.error("audioChannel is miss"),[2]);case 1:return e.sent(),J().setAudioChannel(null),J().setAudioSender(null),J().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),t=J().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),J().setVideoChannel(o),o.onopen=function(){Y.debug("videoChannel onopen()"),J().videoChannelOpened=!0,J().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),t=J().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),J().setDataChannel(o),o.onopen=function(){Y.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),J().dataChannelOpened=!0,J().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened(),(t=J().audioChannel)?(e=J().audioSender?J().audioSender:t.createSender(),J().setAudioSender(e),[2,e]):(Y.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened(),!(t=J().audioSender))return Y.error("audioSender is miss"),[2];try{t.stop(),J().audioChannel&&J().audioChannel.removeSender(t.ssrc)}catch(t){Y.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),(t=J().videoChannel)?(e=J().videoSender?J().videoSender:t.createSender(),J().setVideoSender(e),e.onbusy=function(){Y.debug("onbusy"),J().emitter.emit(u.CHANNEL_BUSY);var t=J().audioChannel;t&&t.ans(!1)},[2,e]):(Y.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened();var t=J().videoSender;if(t)try{t.stop(),J().videoChannel&&J().videoChannel.removeSender(t.ssrc)}catch(t){Y.error("videoChannel removeSender() error: ",t)}else Y.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),(t=J().dataChannel)?(e=J().dataSender?J().dataSender:t.createSender(),J().setDataSender(e),[2,e]):(Y.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){J().throwIfNotStatus(c.START),J().throwIfDataNotOpened();var t=J().dataSender;t?(t.stop(),J().dataChannel&&J().dataChannel.removeSender(t.ssrc),J().setDataSender(null)):Y.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened();var e=J().audioChannel;if(!e)return Y.error("audioChannel is miss"),null;var n=e.createReceiver();return J().setAudioReceiver(n),t?(n.setSink(t),J().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(Y.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened();var e=t.ccid;if(Y.debug("createVideoReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=J().videoChannel;return n?n.createReceiver(e):(Y.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){J().throwIfNotStatus(c.START),J().throwIfDataNotOpened();var e=t.ccid;if(Y.debug("createDataReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=J().dataChannel;return n?n.createReceiver(e):(Y.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),t?(t.stop(),J().videoChannel&&J().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),t?(t.stop(),J().dataChannel&&J().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),(n=J().videoChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),(e=J().videoChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),(n=J().dataChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),(e=J().dataChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setAudioPlayerVolume=function(t){J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened();var e=J().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):Y.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return J().status===c.START&&J().audioChannelOpened&&J().audioSender||null},t.prototype.getVideoSender=function(){return J().status===c.START&&J().videoChannelOpened&&J().videoSender||null},t.prototype.getDataSender=function(){return J().status===c.START&&J().dataChannelOpened&&J().dataSender||null},t.prototype.createAudioStream=function(){return J().throwIfStatus(c.NULL),B().captureAudioStream()},t.prototype.closeAudioStream=function(){return J().throwIfStatus(c.NULL),B().closeAudioStream()},t.prototype.createVideoStream=function(){return J().throwIfStatus(c.NULL),B().captureVideoStream()},t.prototype.closeVideoStream=function(){return J().throwIfStatus(c.NULL),B().closeVideoStream()},t.prototype.createShareContentStream=function(){return J().throwIfNotStatus(c.START),B().captureShareContentStream()},t.prototype.closeShareContentStream=function(){return B().closeShareContentStream()},t.prototype.getAudioStream=function(){return B()?B().audioStream:null},t.prototype.getVideoStream=function(){return B()?B().videoStream:null},t.prototype.getShareContentStream=function(){return B()?B().shareContentStream:null},t.prototype.getAudioStreamStatus=function(){return B()?B().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return B()?B().videoStreamStatus:null},t.prototype.getShareContentStreamStatus=function(){return B()?B().shareContentStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return B()?B().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return B()?B().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return B()?B().videoInputDevice:null},t.prototype.getMicVolume=function(){return B()&&J().status!==c.NULL?B().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){J().throwIfStatus(c.NULL),t&&(B().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){J().throwIfStatus(c.NULL),t&&(B().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){J().throwIfStatus(c.NULL),t&&(B().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return B()?B().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return B()?B().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return B()?B().videoInputDevices:[]},t.EVENTS=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}();export{Q as default}; | ||
var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){"function"==typeof t&&t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.SHARE_CONTENT_STREAM="shareContentStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.SHARE_CONTENT_STREAM_STATUS="shareContentStreamStatus"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,y=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],D=y.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));D&&(S=D.describe(navigator.userAgent));var E=S&&"Safari"===S.name,A=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,_=S&&"Microsoft Edge"===S.name,C=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=g(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),g=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]=(n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+function(t){var e=Math.abs(t);if(e>=w)return Math.round(t/w)+"d";if(e>=N)return Math.round(t/N)+"h";if(e>=O)return Math.round(t/O)+"m";if(e>=b)return Math.round(t/b)+"s";return t+"ms"}(0),!n)return[];var o="color: "+r;t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:U()};return t},b=1e3,O=60*b,N=60*O,w=24*N;var U=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},R=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},P=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,R(e)]}}))}))},V=new C({namespace:"STREAM:Media",debug:!1}),M=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.shareContentQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._shareContentStreamStatus={status:h.NULL},i.onShareContentStreamInactive=i.shareContentStreamInactive.bind(i),V.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStreamStatus",{get:function(){return this._shareContentStreamStatus},set:function(t){var e=this._shareContentStreamStatus;e.status===t.status&&e.detail===t.detail||(this._shareContentStreamStatus=t,this.emit(u.SHARE_CONTENT_STREAM_STATUS,this._shareContentStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e.status;V.debug(o.AUDIO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e.status;V.debug(o.VIDEO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeShareContentStream(),this.cleanup()}catch(t){V.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return V.error("enumerate devices error: ",t)}))]:(V.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],V.debug("deviceList: "+JSON.stringify(this.deviceList)),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&A?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!E&&Object.assign(e.audio,k),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(A?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,x),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),V.debug("audio constraints: "+JSON.stringify(e)),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),V.debug("getUserMedia error: "+a),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:j.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),V.debug("video constraints: "+JSON.stringify(t)),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,P(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getUserMedia error: "+o),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:G.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createShareContentStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:H}),V.debug("shareContent constraints: "+JSON.stringify(t)),e=null,i=this.shareContentStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),V.debug("getDisplayMedia error: "+o),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:F.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,shareContentStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,{stream:this.audioStream})},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,{stream:this.videoStream})},a.prototype.closeShareContentStream=function(){var t=this;this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onShareContentStreamInactive)})),this.shareContentStream.close());this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,{stream:this.shareContentStream})},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureShareContentStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.shareContentQueue=this.shareContentQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createShareContentStream()];case 1:return t=r.sent(),e=t.stream,n=t.shareContentStreamStatus,this.shareContentStreamStatus.status!==h.NULL||e?(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&!e||(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream.close(),this.shareContentStream=null),e&&e.addEventListener("inactive",this.onShareContentStreamInactive),A&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream=e,this.shareContentStreamStatus=n,this.emit(u.SHARE_CONTENT_STREAM,{stream:this.shareContentStream})),[2,Promise.resolve(this.shareContentStream)]):[2,Promise.resolve(this.shareContentStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.shareContentStreamInactive=function(){this.shareContentStream&&(this.shareContentStream.close(),this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,{stream:this.shareContentStream}))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),k={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},x={aspectRatio:16/9,frameRate:30,width:640,height:360},H={width:1920,height:1080,frameRate:5},j=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),B=function(){return M.instance},X=new C({namespace:"STREAM:Store",debug:!1}),z=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(n+"/webapp/front/getMss",{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",X.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:t+"/libsfu.prod.js"}),this.createScriptTag({src:t+"/librtc.global.prod.js"})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src;return new Promise((function(t,n){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.onload=function(){t(i)},i.onerror=function(t){n(t)},document.head.appendChild(i)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.dataChannel,o=t.mediaEndpoint,r.label=1;case 1:return r.trys.push([1,8,,9]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return i?[4,i.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return o&&(o.stop(),o.destroy()),[3,9];case 8:return a=r.sent(),X.error(a),[3,9];case 9:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,[2]}}))}))},t}(),J=function(){return z.instance},Y=new C({namespace:"STREAM:Store",debug:!1}),Q=function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,Y.switchDebug(r),e={debug:r},z.createInstance(e),function(t){M.createInstance(t)}({debug:r}),J().setBaseUrl(n),J().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return B().on(u.AUDIO_STREAM,(function(t){J().emitter.emit(u.AUDIO_STREAM,t)})),B().on(u.VIDEO_STREAM,(function(t){J().emitter.emit(u.VIDEO_STREAM,t)})),B().on(u.SHARE_CONTENT_STREAM,(function(t){J().emitter.emit(u.SHARE_CONTENT_STREAM,t)})),B().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){J().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){J().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),B().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){J().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),B().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){J().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){J().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),B().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){J().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),B().on(u.AUDIO_STREAM_STATUS,(function(t){J().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),B().on(u.VIDEO_STREAM_STATUS,(function(t){J().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),B().on(u.SHARE_CONTENT_STREAM_STATUS,(function(t){J().emitter.emit(u.SHARE_CONTENT_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return J().emitter.on(t,e)},t.prototype.off=function(t,e){return J().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,B().init(t)];case 1:return e.sent(),J().status=c.INIT,J().emitter.emit(u.STREAM_STATUS,{status:J().status}),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return J().throwIfStatus(c.NULL),J().throwIfStatus(c.START),[4,J().loadLibRTCFiles().catch((function(t){Y.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return J().emitter.emit(u.CHANNEL_REFRESH),[4,J().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){Y.error(t)}))];case 1:return t=i.sent(),Y.debug("response "+t),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=J().baseURL;return"wss://"+(/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e)+"/webapp/socket/"+window.btoa(t.replace(/\w+:\/\//,""))}))]):(Y.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),J().setMediaEndpoint(f),J().setMediaEngine(v),J().status=c.START,J().emitter.emit(u.STREAM_STATUS,{status:J().status}),[2]}}))}))},t.prototype.stop=function(){J().throwIfNotStatus(c.START),J().cleanup(),B().shareContentStreamStatus.status!==h.NULL&&B().closeShareContentStream(),J().status=c.STOP,J().emitter.emit(u.STREAM_STATUS,{status:J().status})},t.prototype.destroy=function(){this.stop(),this.cleanup(),J().status!==c.NULL&&(B().destroy(),J().status=c.NULL,J().emitter.emit(u.STREAM_STATUS,{status:J().status}))},t.prototype.getStatus=function(){return J().status},t.prototype.getBaseUrl=function(){return J().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:J().audioChannelOpened,videoChannelOpened:J().videoChannelOpened,dataChannelOpened:J().dataChannelOpened}},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),t=J().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),J().setAudioChannel(o),o.onopen=function(){Y.debug("audioChannel onopen()"),J().audioChannelOpened=!0,J().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=J().audioChannel)?[4,t.close()]:(Y.error("audioChannel is miss"),[2]);case 1:return e.sent(),J().setAudioChannel(null),J().setAudioSender(null),J().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),t=J().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),J().setVideoChannel(o),o.onopen=function(){Y.debug("videoChannel onopen()"),J().videoChannelOpened=!0,J().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),t=J().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),J().setDataChannel(o),o.onopen=function(){Y.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),J().dataChannelOpened=!0,J().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened(),(t=J().audioChannel)?(e=J().audioSender?J().audioSender:t.createSender(),J().setAudioSender(e),[2,e]):(Y.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened(),!(t=J().audioSender))return Y.error("audioSender is miss"),[2];try{t.stop(),J().audioChannel&&J().audioChannel.removeSender(t.ssrc)}catch(t){Y.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),(t=J().videoChannel)?(e=J().videoSender?J().videoSender:t.createSender(),J().setVideoSender(e),e.onbusy=function(){Y.debug("onbusy"),J().emitter.emit(u.CHANNEL_BUSY);var t=J().audioChannel;t&&t.ans(!1)},[2,e]):(Y.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened();var t=J().videoSender;if(t)try{t.stop(),J().videoChannel&&J().videoChannel.removeSender(t.ssrc)}catch(t){Y.error("videoChannel removeSender() error: ",t)}else Y.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),(t=J().dataChannel)?(e=J().dataSender?J().dataSender:t.createSender(),J().setDataSender(e),[2,e]):(Y.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){J().throwIfNotStatus(c.START),J().throwIfDataNotOpened();var t=J().dataSender;t?(t.stop(),J().dataChannel&&J().dataChannel.removeSender(t.ssrc),J().setDataSender(null)):Y.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened();var e=J().audioChannel;if(!e)return Y.error("audioChannel is miss"),null;var n=e.createReceiver();return J().setAudioReceiver(n),t?(n.setSink(t),J().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(Y.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened();var e=t.ccid;if(Y.debug("createVideoReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=J().videoChannel;return n?n.createReceiver(e):(Y.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){J().throwIfNotStatus(c.START),J().throwIfDataNotOpened();var e=t.ccid;if(Y.debug("createDataReceiver ccid: ",e),!e)return Y.error("params is missing or params error"),null;var n=J().dataChannel;return n?n.createReceiver(e):(Y.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),t?(t.stop(),J().videoChannel&&J().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),t?(t.stop(),J().dataChannel&&J().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),(n=J().videoChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfVideoNotOpened(),(e=J().videoChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),(n=J().dataChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Y.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return J().throwIfNotStatus(c.START),J().throwIfDataNotOpened(),(e=J().dataChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Y.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setAudioPlayerVolume=function(t){J().throwIfNotStatus(c.START),J().throwIfAudioNotOpened();var e=J().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):Y.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return J().status===c.START&&J().audioChannelOpened&&J().audioSender||null},t.prototype.getVideoSender=function(){return J().status===c.START&&J().videoChannelOpened&&J().videoSender||null},t.prototype.getDataSender=function(){return J().status===c.START&&J().dataChannelOpened&&J().dataSender||null},t.prototype.createAudioStream=function(){return J().throwIfStatus(c.NULL),B().captureAudioStream()},t.prototype.closeAudioStream=function(){return J().throwIfStatus(c.NULL),B().closeAudioStream()},t.prototype.createVideoStream=function(){return J().throwIfStatus(c.NULL),B().captureVideoStream()},t.prototype.closeVideoStream=function(){return J().throwIfStatus(c.NULL),B().closeVideoStream()},t.prototype.createShareContentStream=function(){return J().throwIfNotStatus(c.START),B().captureShareContentStream()},t.prototype.closeShareContentStream=function(){return B().closeShareContentStream()},t.prototype.getAudioStream=function(){return B()?B().audioStream:null},t.prototype.getVideoStream=function(){return B()?B().videoStream:null},t.prototype.getShareContentStream=function(){return B()?B().shareContentStream:null},t.prototype.getAudioStreamStatus=function(){return B()?B().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return B()?B().videoStreamStatus:null},t.prototype.getShareContentStreamStatus=function(){return B()?B().shareContentStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return B()?B().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return B()?B().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return B()?B().videoInputDevice:null},t.prototype.getMicVolume=function(){return B()&&J().status!==c.NULL?B().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){J().throwIfStatus(c.NULL),t&&(B().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){J().throwIfStatus(c.NULL),t&&(B().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){J().throwIfStatus(c.NULL),t&&(B().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return B()?B().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return B()?B().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return B()?B().videoInputDevices:[]},t.EVENT=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}();export{Q as default}; |
@@ -1,1 +0,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).Stream=e()}(this,(function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,this._status))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,this._status))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.SHARE_CONTENT_STREAM="shareContentStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.SHARE_CONTENT_STREAM_STATUS="shareContentStreamStatus"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,y=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],D=y.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));D&&(S=D.describe(navigator.userAgent));var E=S&&"Safari"===S.name,A=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,_=S&&"Microsoft Edge"===S.name,C=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=b(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),g=C,b=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]=(n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+function(t){var e=Math.abs(t);if(e>=U)return Math.round(t/U)+"d";if(e>=w)return Math.round(t/w)+"h";if(e>=N)return Math.round(t/N)+"m";if(e>=O)return Math.round(t/O)+"s";return t+"ms"}(0),!n)return[];var o="color: "+r;t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:R()};return t},O=1e3,N=60*O,w=60*N,U=24*w;var R=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},P=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},V=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},M=new g({namespace:"STREAM:Media",debug:!1}),k=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.shareContentQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._shareContentStreamStatus={status:h.NULL},i.onShareContentStreamInactive=i.shareContentStreamInactive.bind(i),M.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStreamStatus",{get:function(){return this._shareContentStreamStatus},set:function(t){var e=this._shareContentStreamStatus;e.status===t.status&&e.detail===t.detail||(this._shareContentStreamStatus=t,this.emit(u.SHARE_CONTENT_STREAM_STATUS,this._shareContentStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e;M.debug(o.AUDIO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e;M.debug(o.VIDEO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeShareContentStream(),this.cleanup()}catch(t){M.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return M.error("enumerate devices error: ",t)}))]:(M.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],M.debug("deviceList: "+JSON.stringify(this.deviceList)),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&A?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!E&&Object.assign(e.audio,x),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(A?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,H),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),M.debug("audio constraints: "+JSON.stringify(e)),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),M.debug("getUserMedia error: "+a),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:G.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),M.debug("video constraints: "+JSON.stringify(t)),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getUserMedia error: "+o),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:F.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createShareContentStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:j}),M.debug("shareContent constraints: "+JSON.stringify(t)),e=null,i=this.shareContentStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,V(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getDisplayMedia error: "+o),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:B.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,shareContentStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,this.audioStream)},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,this.videoStream)},a.prototype.closeShareContentStream=function(){var t=this;this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onShareContentStreamInactive)})),this.shareContentStream.close());this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,this.shareContentStream)},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,this.audioStream),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,this.audioStream),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,this.videoStream),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,this.videoStream),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureShareContentStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.shareContentQueue=this.shareContentQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createShareContentStream()];case 1:return t=r.sent(),e=t.stream,n=t.shareContentStreamStatus,this.shareContentStreamStatus.status!==h.NULL||e?(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&!e||(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream.close(),this.shareContentStream=null),e&&e.addEventListener("inactive",this.onShareContentStreamInactive),A&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream=e,this.shareContentStreamStatus=n,this.emit(u.SHARE_CONTENT_STREAM,this.shareContentStream)),[2,Promise.resolve(this.shareContentStream)]):[2,Promise.resolve(this.shareContentStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.shareContentStreamInactive=function(){this.shareContentStream&&(this.shareContentStream.close(),this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,this.shareContentStream))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),x={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},H={aspectRatio:16/9,frameRate:30,width:640,height:360},j={width:1920,height:1080,frameRate:5},G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),B=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),X=function(){return k.instance},z=new g({namespace:"STREAM:Store",debug:!1}),J=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(n+"/webapp/front/getMss",{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",z.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:t+"/libsfu.prod.js"}),this.createScriptTag({src:t+"/librtc.global.prod.js"})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src;return new Promise((function(t,n){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.onload=function(){t(i)},i.onerror=function(t){n(t)},document.head.appendChild(i)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.dataChannel,o=t.mediaEndpoint,r.label=1;case 1:return r.trys.push([1,8,,9]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return i?[4,i.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return o&&(o.stop(),o.destroy()),[3,9];case 8:return a=r.sent(),z.error(a),[3,9];case 9:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,[2]}}))}))},t}(),Y=function(){return J.instance},Q=new g({namespace:"STREAM:Store",debug:!1});return function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,Q.switchDebug(r),e={debug:r},J.createInstance(e),function(t){k.createInstance(t)}({debug:r}),Y().setBaseUrl(n),Y().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return X().on(u.AUDIO_STREAM,(function(t){Y().emitter.emit(u.AUDIO_STREAM,t)})),X().on(u.VIDEO_STREAM,(function(t){Y().emitter.emit(u.VIDEO_STREAM,t)})),X().on(u.SHARE_CONTENT_STREAM,(function(t){Y().emitter.emit(u.SHARE_CONTENT_STREAM,t)})),X().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),X().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),X().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_STREAM_STATUS,(function(t){Y().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),X().on(u.VIDEO_STREAM_STATUS,(function(t){Y().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),X().on(u.SHARE_CONTENT_STREAM_STATUS,(function(t){Y().emitter.emit(u.SHARE_CONTENT_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return Y().emitter.on(t,e)},t.prototype.off=function(t,e){return Y().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,X().init(t)];case 1:return e.sent(),Y().status=c.INIT,Y().emitter.emit(u.STREAM_STATUS,Y().status),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return Y().throwIfStatus(c.NULL),Y().throwIfStatus(c.START),[4,Y().loadLibRTCFiles().catch((function(t){Q.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return Y().emitter.emit(u.CHANNEL_REFRESH),[4,Y().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){Q.error(t)}))];case 1:return t=i.sent(),Q.debug("response "+t),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=Y().baseURL;return"wss://"+(/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e)+"/webapp/socket/"+window.btoa(t.replace(/\w+:\/\//,""))}))]):(Q.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),Y().setMediaEndpoint(f),Y().setMediaEngine(v),Y().status=c.START,Y().emitter.emit(u.STREAM_STATUS,Y().status),[2]}}))}))},t.prototype.stop=function(){Y().throwIfNotStatus(c.START),Y().cleanup(),X().shareContentStreamStatus.status!==h.NULL&&X().closeShareContentStream(),Y().status=c.STOP,Y().emitter.emit(u.STREAM_STATUS,Y().status)},t.prototype.destroy=function(){this.stop(),this.cleanup(),Y().status!==c.NULL&&(X().destroy(),Y().status=c.NULL,Y().emitter.emit(u.STREAM_STATUS,Y().status))},t.prototype.getStreamStatus=function(){return Y().status},t.prototype.getBaseUrl=function(){return Y().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:Y().audioChannelOpened,videoChannelOpened:Y().videoChannelOpened,dataChannelOpened:Y().dataChannelOpened}},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),Y().setAudioChannel(o),o.onopen=function(){Q.debug("audioChannel onopen()"),Y().audioChannelOpened=!0,Y().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=Y().audioChannel)?[4,t.close()]:(Q.error("audioChannel is miss"),[2]);case 1:return e.sent(),Y().setAudioChannel(null),Y().setAudioSender(null),Y().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),Y().setVideoChannel(o),o.onopen=function(){Q.debug("videoChannel onopen()"),Y().videoChannelOpened=!0,Y().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),Y().setDataChannel(o),o.onopen=function(){Q.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),Y().dataChannelOpened=!0,Y().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),(t=Y().audioChannel)?(e=Y().audioSender?Y().audioSender:t.createSender(),Y().setAudioSender(e),[2,e]):(Q.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),!(t=Y().audioSender))return Q.error("audioSender is miss"),[2];try{t.stop(),Y().audioChannel&&Y().audioChannel.removeSender(t.ssrc)}catch(t){Q.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(t=Y().videoChannel)?(e=Y().videoSender?Y().videoSender:t.createSender(),Y().setVideoSender(e),e.onbusy=function(){Q.debug("onbusy"),Y().emitter.emit(u.CHANNEL_BUSY);var t=Y().audioChannel;t&&t.ans(!1)},[2,e]):(Q.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var t=Y().videoSender;if(t)try{t.stop(),Y().videoChannel&&Y().videoChannel.removeSender(t.ssrc)}catch(t){Q.error("videoChannel removeSender() error: ",t)}else Q.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(t=Y().dataChannel)?(e=Y().dataSender?Y().dataSender:t.createSender(),Y().setDataSender(e),[2,e]):(Q.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var t=Y().dataSender;t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeSender(t.ssrc),Y().setDataSender(null)):Q.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioChannel;if(!e)return Q.error("audioChannel is miss"),null;var n=e.createReceiver();return Y().setAudioReceiver(n),t?(n.setSink(t),Y().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(Q.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var e=t.ccid;if(Q.debug("createVideoReceiver ccid: ",e),!e)return Q.error("params is missing or params error"),null;var n=Y().videoChannel;return n?n.createReceiver(e):(Q.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var e=t.ccid;if(Q.debug("createDataReceiver ccid: ",e),!e)return Q.error("params is missing or params error"),null;var n=Y().dataChannel;return n?n.createReceiver(e):(Q.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),t?(t.stop(),Y().videoChannel&&Y().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(n=Y().videoChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Q.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(e=Y().videoChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Q.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(n=Y().dataChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Q.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(e=Y().dataChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Q.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setAudioPlayerVolume=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):Q.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return Y().status===c.START&&Y().audioChannelOpened&&Y().audioSender||null},t.prototype.getVideoSender=function(){return Y().status===c.START&&Y().videoChannelOpened&&Y().videoSender||null},t.prototype.getDataSender=function(){return Y().status===c.START&&Y().dataChannelOpened&&Y().dataSender||null},t.prototype.createAudioStream=function(){return Y().throwIfStatus(c.NULL),X().captureAudioStream()},t.prototype.closeAudioStream=function(){return Y().throwIfStatus(c.NULL),X().closeAudioStream()},t.prototype.createVideoStream=function(){return Y().throwIfStatus(c.NULL),X().captureVideoStream()},t.prototype.closeVideoStream=function(){return Y().throwIfStatus(c.NULL),X().closeVideoStream()},t.prototype.createShareContentStream=function(){return Y().throwIfNotStatus(c.START),X().captureShareContentStream()},t.prototype.closeShareContentStream=function(){return X().closeShareContentStream()},t.prototype.getAudioStream=function(){return X()?X().audioStream:null},t.prototype.getVideoStream=function(){return X()?X().videoStream:null},t.prototype.getShareContentStream=function(){return X()?X().shareContentStream:null},t.prototype.getAudioStreamStatus=function(){return X()?X().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return X()?X().videoStreamStatus:null},t.prototype.getShareContentStreamStatus=function(){return X()?X().shareContentStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return X()?X().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return X()?X().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return X()?X().videoInputDevice:null},t.prototype.getMicVolume=function(){return X()&&Y().status!==c.NULL?X().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return X()?X().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return X()?X().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return X()?X().videoInputDevices:[]},t.EVENTS=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}()})); | ||
!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).Stream=e()}(this,(function(){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},n.apply(this,arguments)};function i(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var o,a=function(){function t(){this.events=new Map}return t.prototype.emit=function(t,e){var n=this.events.get(t);n&&n.slice().map((function(t){"function"==typeof t&&t(e)}))},t.prototype.off=function(t,e){var n=this.events.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):this.events.set(t,[]))},t.prototype.on=function(t,e){var n=this.events.get(t);n?n.push(e):this.events.set(t,[e])},t}(),s=function(t){function n(e){var n=t.call(this)||this;return n.stream=null,n._enable=!1,n.interval=100,n.timer=null,n.stream=e,n}return e(n,t),n.prototype.analyse=function(){},n.prototype.start=function(){var t=this;this.stream&&(this.timer&&(clearInterval(this.timer),this.timer=null),this.analyse(),this.timer=setInterval((function(){return t.analyse()}),this.interval))},n.prototype.stop=function(){this.timer&&(clearInterval(this.timer),this.timer=null)},n.prototype.destroy=function(){this.stop()},n}(a);!function(t){t.AUDIO_STATUS_CHANGED="audioStatusChanged",t.VIDEO_STATUS_CHANGED="videoStatusChanged"}(o||(o={}));var u,c,d,h,l,p=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.AUDIO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getAudioTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),v=function(t){function n(e){var n=t.call(this,e)||this;return n._status={active:!1,hasStream:!1,track:!1},n.interval=3e3,n}return e(n,t),Object.defineProperty(n.prototype,"status",{get:function(){return this._status},set:function(t){var e=this._status;e.active===t.active&&e.hasStream===t.hasStream&&e.track===t.track||(this._status=t,this.emit(o.VIDEO_STATUS_CHANGED,{status:this._status}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.stream){var t=this.stream.getVideoTracks();this.status.active=void 0===this.stream.active?Boolean(t[0]):this.stream.active,void 0!==this.stream.active&&void 0!==this.stream.id?this.status.hasStream=!0:this.status.hasStream=!1,(this.status.active||this.status.hasStream)&&(this.status.track=this.checkAvariable(t))}else this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.streamInactive=function(){this.status.active=!1,this.status.hasStream=!1,this.status.track=!1},n.prototype.checkAvariable=function(t){return void 0===t&&(t=[]),t.some((function(t){return!("readyState"in t&&"live"!==t.readyState||"muted"in t&&!0===t.muted)}))},n.prototype.destroy=function(){this.stream&&this.stream.removeEventListener("inactive",this.streamInactive),t.prototype.destroy.call(this)},n}(s),f=function(t){function n(e){var n=t.call(this,e)||this;return n.volume=0,n.context=null,n.contextAnalyser=null,n.streamSource=null,n}return e(n,t),Object.defineProperty(n.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable=t,t&&this.stream?this.start():this.stop()},enumerable:!1,configurable:!0}),n.prototype.analyse=function(){if(this.context&&this.contextAnalyser&&this.streamSource){var t=this.contextAnalyser.frequencyBinCount,e=new Uint8Array(t);this.contextAnalyser.getByteFrequencyData(e);var n=e.reduce((function(t,e){return t+e}),0);this.volume=n/t}else this.volume=0},n.prototype.start=function(){this.createContextAnalyser(),this.createStreamSource(),this.streamSource&&t.prototype.start.call(this)},n.prototype.stop=function(){this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.volume=0,t.prototype.stop.call(this)},n.prototype.createContextAnalyser=function(){if((!this.context||!this.contextAnalyser)&&(window.AudioContext||window.webkitAudioContext)){var t=window.AudioContext||window.webkitAudioContext;this.context=new t,this.contextAnalyser=this.context.createAnalyser(),this.contextAnalyser.fftSize=1024,this.contextAnalyser.smoothingTimeConstant=.5}},n.prototype.createStreamSource=function(){if(this.streamSource&&(this.streamSource.disconnect(),this.streamSource=null),this.context&&this.stream&&this.stream.getAudioTracks().length>0){if(this.streamSource=this.context.createMediaStreamSource(this.stream),!this.contextAnalyser)return;this.streamSource.connect(this.contextAnalyser),"suspended"===this.context.state&&this.context.resume()}},n.prototype.destroy=function(){this.contextAnalyser&&(this.contextAnalyser.disconnect(),this.contextAnalyser=null),this.context&&(this.context=null),t.prototype.destroy.call(this)},n}(s);!function(t){t.STREAM_STATUS="streamStatus",t.CHANNEL_REFRESH="channelRefresh",t.CHANNEL_BUSY="channelBusy",t.AUDIO_CHANNEL_OPENED="audioChannelOpened",t.VIDEO_CHANNEL_OPENED="videoChannelOpened",t.DATA_CHANNEL_OPENED="dataChannelOpened",t.AUDIO_STREAM="audioStream",t.VIDEO_STREAM="videoStream",t.SHARE_CONTENT_STREAM="shareContentStream",t.AUDIO_INPUT_DEVICES_UPDATED="audioInputDevicesUpdated",t.AUDIO_OUTPUT_DEVICES_UPDATED="audioOutputDevicesUpdated",t.VIDEO_INPUT_DEVICES_UPDATED="videoInputDevicesUpdated",t.AUDIO_INPUT_DEVICE_CHANGED="audioInputDeviceChanged",t.AUDIO_OUTPUT_DEVICE_CHANGED="audioOutputDeviceChanged",t.VIDEO_INPUT_DEVICE_CHANGED="videoInputDeviceChanged",t.AUDIO_STREAM_STATUS="audioStreamStatus",t.VIDEO_STREAM_STATUS="videoStreamStatus",t.SHARE_CONTENT_STREAM_STATUS="shareContentStreamStatus"}(u||(u={})),function(t){t.NULL="null",t.INIT="initialized",t.START="started",t.STOP="stopped"}(c||(c={})),function(t){t.Null="null",t.INIT="initialized"}(d||(d={})),function(t){t.NULL="null",t.CAPTURING="capturing",t.FAILED="failed"}(h||(h={})),function(t){t.NO_DEVICE="No Device",t.PERMISSION_DENIED="Permission denied",t.COULD_NOT_START_VIDEO_SOURCE="Could not start video source",t.PERMISSION_DENIED_BY_SYSTEM="Permission denied by system",t.OTHER_EXCEPTIONS="Other exceptions"}(l||(l={}));var S,m=function(t,e){var n=e.match(t);return n&&n.length>0&&n[1]||""},I=/version\/(\d+(\.?_?\d+)+)/i,y=[{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},n=m(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},n=function(t,e){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},n=m(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},n=m(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||m(I,t);return n&&(e.version=n),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},n=m(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return n&&(e.version=n),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},n=m(I,t);return n&&(e.version=n),e}}],D=y.find((function(t){if(t.test instanceof Array)return t.test.some((function(t){return t.test(navigator.userAgent)}));throw new Error("Browser's test function is not valid")}));D&&(S=D.describe(navigator.userAgent));var E=S&&"Safari"===S.name,A=S&&"Firefox"===S.name,T=S&&"Chrome"===S.name,_=S&&"Microsoft Edge"===S.name,C=function(){function t(t){var e=t.namespace,n=t.debug;this.initialized=!0,this.isDebugging=n,this.backend=b(),this.namespace=e,this.useColors=this.backend.useColors,this.color=this.selectColor(e)}return t.prototype.logger=function(t){var e=this;t[0]=this.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var n=0;return t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(i,r){if("%%"===i)return i;n++;var o=e.backend.formatters[r];"function"==typeof o&&(i=o(t[n]),t.splice(n,1),n--);return i})),this.backend.formatArgs(t,this)},t.prototype.coerce=function(t){return t instanceof Error?t.stack||t.message:t},t.prototype.selectColor=function(t){var e=Array.from(t).reduce((function(t,e){return t=(t<<5)-t+e.charCodeAt(0),t|=0}),0);return this.backend.colors[Math.abs(e)%this.backend.colors.length]},t.prototype.switchDebug=function(t){this.isDebugging=t},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];t=this.logger(t),this.backend.log.apply(this,t)},t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.isDebugging&&(t=this.logger(t),this.backend.debug.apply(this,t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.warn.apply(this,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.backend.error.apply(this,t)},t}(),g=C,b=function(){var t={colors:["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],formatters:{j:function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,t)},debug:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.debug&&Function.prototype.apply.call(console.debug,console,t)},warn:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.warn&&Function.prototype.apply.call(console.warn,console,t)},error:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"object"==typeof console&&console.error&&Function.prototype.apply.call(console.error,console,t)},formatArgs:function(t,e){var n=e.useColors,i=e.namespace,r=e.color;if(t[0]=(n?"%c":"")+i+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+function(t){var e=Math.abs(t);if(e>=U)return Math.round(t/U)+"d";if(e>=w)return Math.round(t/w)+"h";if(e>=N)return Math.round(t/N)+"m";if(e>=O)return Math.round(t/O)+"s";return t+"ms"}(0),!n)return[];var o="color: "+r;t.splice(1,0,o,"color: inherit");var a=0,s=0;return t[0].replace(/%[a-zA-Z%]/g,(function(t){"%%"!==t&&(a++,"%c"===t&&(s=a))})),t.splice(s,0,o),t},useColors:R()};return t},O=1e3,N=60*O,w=60*N,U=24*w;var R=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.webkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},P=function(t){return t.close=t.stop=function(){!function(t){if(t)try{t.getTracks?t.getTracks().forEach((function(t){return t.stop()})):(t.getAudioTracks().forEach((function(t){return t.stop()})),t.getVideoTracks().forEach((function(t){return t.stop()})))}catch(e){"function"!=typeof t.stop&&"object"!=typeof t.stop||t.stop()}}(this)},t.pause=function(){this.getTracks().forEach((function(t){return t.enabled=!1}))},t.play=function(){this.getTracks().forEach((function(t){return t.enabled=!0}))},t.muteAudio=function(t){void 0===t&&(t=!0),this.getAudioTracks().forEach((function(e){return e.enabled=!t}))},t.muteVideo=function(t){void 0===t&&(t=!0),this.getVideoTracks().forEach((function(e){return e.enabled=!t}))},t},L=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getUserMedia?[4,navigator.mediaDevices.getUserMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getUserMedia?[4,new Promise((function(e,n){navigator.getUserMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},V=function(t){return i(void 0,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return navigator.mediaDevices.getDisplayMedia?[4,navigator.mediaDevices.getDisplayMedia(t)]:[3,2];case 1:case 3:return e=n.sent(),[3,5];case 2:return navigator.getDisplayMedia?[4,new Promise((function(e,n){navigator.getDisplayMedia(t,e,n)}))]:[3,4];case 4:throw new Error("Not Supported");case 5:return[2,P(e)]}}))}))},M=new g({namespace:"STREAM:Media",debug:!1}),k=function(t){function a(e){var n=e.debug,i=t.call(this)||this;return i.status=d.Null,i.deviceList=[],i.audioQueue=Promise.resolve(null),i.videoQueue=Promise.resolve(null),i.shareContentQueue=Promise.resolve(null),i._audioStream=null,i._videoStream=null,i._displayStream=null,i._audioInputDevice=null,i._audioOutputDevice=null,i._videoInputDevice=null,i._audioInputDeviceId="",i._audioOutputDeviceId="",i._videoInputDeviceId="",i._audioInputDevices=[],i._audioOutputDevices=[],i._videoInputDevices=[],i._audioStreamStatus={status:h.NULL},i._videoStreamStatus={status:h.NULL},i._shareContentStreamStatus={status:h.NULL},i.onShareContentStreamInactive=i.shareContentStreamInactive.bind(i),M.switchDebug(n),i.volumeAnalyser=new f(i.audioStream),i.audioAnalyser=new p(i.audioStream),i.videoAnalyser=new v(i.videoStream),i.setup(),i}return e(a,t),a.createInstance=function(t){return this.instance||(this.instance=new a(t)),this.instance},Object.defineProperty(a.prototype,"audioInputDevices",{get:function(){return this._audioInputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioInputDevices)||(this._audioInputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevices",{get:function(){return this._audioOutputDevices||[]},set:function(t){this.checkDeviceList(t,this._audioOutputDevices)||(this._audioOutputDevices=t,this.status===d.INIT&&this.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevices",{get:function(){return this._videoInputDevices||[]},set:function(t){this.checkDeviceList(t,this._videoInputDevices)||(this._videoInputDevices=t,this.status===d.INIT&&this.emit(u.VIDEO_INPUT_DEVICES_UPDATED,{deviceList:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDeviceId",{get:function(){return this._audioInputDeviceId||""},set:function(t){if(!this._audioInputDeviceId||this._audioInputDeviceId!==t){var e=this.audioInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioInputDevice=i,this._audioInputDeviceId=i?i.deviceId:"",this.audioStreamStatus.status!==h.NULL&&this.captureAudioStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDeviceId",{get:function(){return this._audioOutputDeviceId||""},set:function(t){if(!this._audioOutputDeviceId||this._audioOutputDeviceId!==t){var e=this.audioOutputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.audioOutputDevice=i,this._audioOutputDeviceId=i?i.deviceId:""}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDeviceId",{get:function(){return this._videoInputDeviceId||""},set:function(t){if(!this._videoInputDeviceId||this._videoInputDeviceId!==t){var e=this.videoInputDevices,n=void 0===e?[]:e,i=n.find((function(e){return e.deviceId===t}))||n[0]||null;this.videoInputDevice=i,this._videoInputDeviceId=i?i.deviceId:"",this.videoStreamStatus.status!==h.NULL&&this.captureVideoStream()}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioInputDevice",{get:function(){return this._audioInputDevice},set:function(t){var e=this._audioInputDevice&&!this.isSameDevice(this._audioInputDevice,t),n=!this._audioInputDevice&&!!t;(n||e)&&(this._audioInputDevice=t,!n&&e&&this.emit(u.AUDIO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioOutputDevice",{get:function(){return this._audioOutputDevice},set:function(t){var e=this._audioOutputDevice&&!this.isSameDevice(this._audioOutputDevice,t),n=!this._audioOutputDevice&&!!t;(n||e)&&(this._audioOutputDevice=t,!n&&e&&this.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoInputDevice",{get:function(){return this._videoInputDevice},set:function(t){var e=this._videoInputDevice&&!this.isSameDevice(this._videoInputDevice,t),n=!this._videoInputDevice&&!!t;(n||e)&&(this._videoInputDevice=t,!n&&e&&this.emit(u.VIDEO_INPUT_DEVICE_CHANGED,{device:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"supportNativeShare",{get:function(){return navigator.getDisplayMedia||navigator.mediaDevices.getDisplayMedia},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStream",{get:function(){return this._audioStream},set:function(t){this._audioStream!==t&&(this._audioStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStream",{get:function(){return this._videoStream},set:function(t){this._videoStream!==t&&(this._videoStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStream",{get:function(){return this._displayStream},set:function(t){this._displayStream!==t&&(this._displayStream=t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"audioStreamStatus",{get:function(){return this._audioStreamStatus},set:function(t){var e=this._audioStreamStatus;e.status===t.status&&e.detail===t.detail||(this._audioStreamStatus=t,this.emit(u.AUDIO_STREAM_STATUS,this._audioStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"videoStreamStatus",{get:function(){return this._videoStreamStatus},set:function(t){var e=this._videoStreamStatus;e.status===t.status&&e.detail===t.detail||(this._videoStreamStatus=t,this.emit(u.VIDEO_STREAM_STATUS,this._videoStreamStatus))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shareContentStreamStatus",{get:function(){return this._shareContentStreamStatus},set:function(t){var e=this._shareContentStreamStatus;e.status===t.status&&e.detail===t.detail||(this._shareContentStreamStatus=t,this.emit(u.SHARE_CONTENT_STREAM_STATUS,this._shareContentStreamStatus))},enumerable:!1,configurable:!0}),a.prototype.setup=function(){var t=this;this.audioAnalyser.on(o.AUDIO_STATUS_CHANGED,(function(e){var n=e.status;M.debug(o.AUDIO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.audioStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})})),this.videoAnalyser.on(o.VIDEO_STATUS_CHANGED,(function(e){var n=e.status;M.debug(o.VIDEO_STATUS_CHANGED+" "+JSON.stringify(n)),!n.hasStream||n.track&&n.active||(t.videoStreamStatus={status:h.FAILED,detail:l.OTHER_EXCEPTIONS})}))},a.prototype.cleanup=function(){this.deviceList=[],this.audioInputDevices=[],this.audioInputDeviceId="",this.audioOutputDevices=[],this.audioOutputDeviceId="",this.videoInputDevices=[],this.videoInputDeviceId="",this.volumeAnalyser.destroy(),this.audioAnalyser.destroy(),this.videoAnalyser.destroy()},a.prototype.init=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return this.throwIfStatus(d.INIT),navigator.mediaDevices&&(e=this,navigator.mediaDevices.ondevicechange=function(){e.detectDevice()}),[4,this.detectDevice(t)];case 1:return n.sent(),this.status=d.INIT,[2]}}))}))},a.prototype.destroy=function(){try{this.closeAudioStream(),this.closeVideoStream(),this.closeShareContentStream(),this.cleanup()}catch(t){M.error(t)}this.status=d.Null},a.prototype.detectDevice=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?[4,this.enumerateDevices().catch((function(t){return M.error("enumerate devices error: ",t)}))]:(M.error("mediaDevices or enumerateDevices is miss"),[2]);case 1:return e=r.sent(),this.deviceList=e&&e.map((function(t){return t.toJSON()}))||[],M.debug("deviceList: "+JSON.stringify(this.deviceList)),i=(n=this).audioInputDevice,o=n.audioOutputDevice,a=n.videoInputDevice,this.audioInputDevices=this.deviceList.filter((function(t){return"audioinput"===t.kind}))||[],this.audioInputDeviceId=this.checkDevice({deviceList:this.audioInputDevices,device:i,deviceId:t&&t.audioInputDeviceId||""}),this.audioOutputDevices=this.deviceList.filter((function(t){return"audiooutput"===t.kind}))||[],this.audioOutputDeviceId=this.checkDevice({deviceList:this.audioOutputDevices,device:o,deviceId:t&&t.audioOutputDeviceId||""}),this.videoInputDevices=this.deviceList.filter((function(t){return"videoinput"===t.kind}))||[],this.videoInputDeviceId=this.checkDevice({deviceList:this.videoInputDevices,device:a,deviceId:t&&t.videoInputDeviceId||""}),[2]}}))}))},a.prototype.enumerateDevices=function(){return new Promise((function(t,e){navigator.mediaDevices.enumerateDevices().then((function(e){t(e)})).catch((function(t){e(t)}))}))},a.prototype.genAudioConstraints=function(t){var e={audio:!1,video:!1},n=this.audioInputDevice,i=n||{deviceId:"",groupId:""},r=i.deviceId,o=i.groupId;return e.audio=!!n&&(t&&A?{deviceId:{exact:r},groupId:{exact:o}}:{deviceId:r,groupId:o}),e.audio&&!E&&Object.assign(e.audio,x),e},a.prototype.genVideoConstraints=function(){var t={audio:!1,video:!1},e=this.videoInputDevice,n=e||{deviceId:"",groupId:""},i=n.deviceId,r=n.groupId;return t.video=!!e&&(A?{deviceId:{exact:i},groupId:{exact:r}}:{deviceId:i,groupId:r}),t.video&&Object.assign(t.video,H),t},a.prototype.genDisplayConstraints=function(t){var e,i=t.quality;return this.supportNativeShare?e={video:n({},i)}:e},a.prototype.createAudioStream=function(t){return i(this,void 0,void 0,(function(){var e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:if(e=this.genAudioConstraints(t),M.debug("audio constraints: "+JSON.stringify(e)),n=this.audioStreamStatus,!e.audio)return[2,{stream:null,audioStreamStatus:n={status:h.FAILED,detail:l.NO_DEVICE}}];i=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(e)];case 2:return i=r.sent(),[3,4];case 3:return a=r.sent(),M.debug("getUserMedia error: "+a),o=a,[3,4];case 4:return i?n={status:h.CAPTURING}:(o=o||new Error("Stream is null"),n={status:h.FAILED,detail:G.get(o.message)||l.OTHER_EXCEPTIONS}),[2,{stream:i,audioStreamStatus:n}]}}))}))},a.prototype.createVideoStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.genVideoConstraints(),M.debug("video constraints: "+JSON.stringify(t)),e=this.videoStreamStatus,!t.video)return[2,{stream:null,videoStreamStatus:e={status:h.FAILED,detail:l.NO_DEVICE}}];n=null,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(t)];case 2:return n=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getUserMedia error: "+o),i=o,[3,4];case 4:return n?e={status:h.CAPTURING}:(i=i||new Error("Stream is null"),e={status:h.FAILED,detail:F.get(i.message)||l.OTHER_EXCEPTIONS}),[2,{stream:n,videoStreamStatus:e}]}}))}))},a.prototype.createShareContentStream=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:t=this.genDisplayConstraints({quality:j}),M.debug("shareContent constraints: "+JSON.stringify(t)),e=null,i=this.shareContentStreamStatus,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,V(t)];case 2:return e=r.sent(),[3,4];case 3:return o=r.sent(),M.debug("getDisplayMedia error: "+o),n=o,[3,4];case 4:return e?i={status:h.CAPTURING}:(n=n||new Error("Stream is null"),i={status:h.FAILED,detail:B.get(n.message)||l.OTHER_EXCEPTIONS}),[2,{stream:e,shareContentStreamStatus:i}]}}))}))},a.prototype.closeAudioStream=function(){this.audioStream&&this.audioStream.close(),this.audioStream=null,this.switchAudioAnalyserEnable({enable:!1}),this.setAudioAnalyserStream(this.audioStream),this.audioStreamStatus={status:h.NULL},this.emit(u.AUDIO_STREAM,{stream:this.audioStream})},a.prototype.closeVideoStream=function(){this.videoStream&&this.videoStream.close(),this.videoStream=null,this.switchVideoAnalyserEnable({enable:!1}),this.setVideoAnalyserStream(this.videoStream),this.videoStreamStatus={status:h.NULL},this.emit(u.VIDEO_STREAM,{stream:this.videoStream})},a.prototype.closeShareContentStream=function(){var t=this;this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(e){e.removeEventListener("ended",t.onShareContentStreamInactive)})),this.shareContentStream.close());this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,{stream:this.shareContentStream})},a.prototype.captureAudioStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.audioQueue=this.audioQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return this.switchAudioAnalyserEnable({enable:!1}),t=!(this.audioStreamStatus.status!==h.CAPTURING||!this.audioStream),[4,this.createAudioStream(t)];case 1:return e=r.sent(),n=e.stream,i=e.audioStreamStatus,this.audioStreamStatus.status===h.CAPTURING&&this.audioStream&&(this.audioStream.close(),this.audioStream=null),this.status!==d.INIT?(n&&n.close(),this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),[2,Promise.resolve(this.audioStream)]):(this.audioStream=n,this.audioStreamStatus=i,this.emit(u.AUDIO_STREAM,{stream:this.audioStream}),o=!0,n||i.status!==h.FAILED||(o=!1),this.setAudioAnalyserStream(n),this.switchAudioAnalyserEnable({enable:o}),[2,Promise.resolve(this.audioStream)])}}))}))}))},a.prototype.captureVideoStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.videoQueue=this.videoQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:return this.switchVideoAnalyserEnable({enable:!1}),[4,this.createVideoStream()];case 1:return t=r.sent(),e=t.stream,n=t.videoStreamStatus,this.videoStreamStatus.status===h.CAPTURING&&this.videoStream&&(this.videoStream.close(),this.videoStream=null),this.status!==d.INIT?(e&&e.close(),this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),[2,Promise.resolve(this.videoStream)]):(this.videoStream=e,this.videoStreamStatus=n,this.emit(u.VIDEO_STREAM,{stream:this.videoStream}),i=!0,e||n.status!==h.FAILED||(i=!1),this.setVideoAnalyserStream(e),this.switchVideoAnalyserEnable({enable:i}),[2,Promise.resolve(this.videoStream)])}}))}))}))},a.prototype.captureShareContentStream=function(){var t=this;return this.throwIfNotStatus(d.INIT),this.shareContentQueue=this.shareContentQueue.then((function(){return i(t,void 0,void 0,(function(){var t,e,n,i=this;return r(this,(function(r){switch(r.label){case 0:return[4,this.createShareContentStream()];case 1:return t=r.sent(),e=t.stream,n=t.shareContentStreamStatus,this.shareContentStreamStatus.status!==h.NULL||e?(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&!e||(this.shareContentStreamStatus.status===h.CAPTURING&&this.shareContentStream&&(this.shareContentStream.removeEventListener("inactive",this.onShareContentStreamInactive),(this.shareContentStream.getVideoTracks()||[]).forEach((function(t){t.removeEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream.close(),this.shareContentStream=null),e&&e.addEventListener("inactive",this.onShareContentStreamInactive),A&&e&&(e.getVideoTracks()||[]).forEach((function(t){t.addEventListener("ended",i.onShareContentStreamInactive)})),this.shareContentStream=e,this.shareContentStreamStatus=n,this.emit(u.SHARE_CONTENT_STREAM,{stream:this.shareContentStream})),[2,Promise.resolve(this.shareContentStream)]):[2,Promise.resolve(this.shareContentStream)]}}))}))}))},a.prototype.setAudioAnalyserStream=function(t){this.volumeAnalyser.stream=t,this.audioAnalyser.stream=t},a.prototype.setVideoAnalyserStream=function(t){this.videoAnalyser.stream=t},a.prototype.switchAudioAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.volumeAnalyser.enable=n,this.audioAnalyser.enable=n},a.prototype.switchVideoAnalyserEnable=function(t){var e=t.enable,n=void 0!==e&&e;this.videoAnalyser.enable=n},a.prototype.shareContentStreamInactive=function(){this.shareContentStream&&(this.shareContentStream.close(),this.shareContentStream=null,this.shareContentStreamStatus={status:h.NULL},this.emit(u.SHARE_CONTENT_STREAM,{stream:this.shareContentStream}))},a.prototype.checkDevice=function(t){var e=this,n=t.deviceList,i=t.device,r=t.deviceId;return(i=(i=r?n.find((function(t){return t.deviceId===r}))||null:i&&n.find((function(t){return e.isSameDevice(t,i)}))||null)||(n[0]||null))&&i.deviceId?i.deviceId:""},a.prototype.checkDeviceList=function(t,e){if(!t||!e||t.length!==e.length)return!1;for(var n=!0,i=0;i<t.length;i++){var r=t[i],o=e[i];if(!this.isSameDevice(r,o)){n=!1;break}}return n},a.prototype.isSameDevice=function(t,e,n){if(void 0===n&&(n=!1),!t||!e)return!1;var i=t.deviceId===e.deviceId&&t.label===e.label&&t.kind===e.kind;return n?t.groupId===e.groupId&&i:i},a.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},a.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},a}(a),x={autoGainControl:!0,echoCancellation:!0,latency:0,noiseSuppression:!0},H={aspectRatio:16/9,frameRate:30,width:640,height:360},j={width:1920,height:1080,frameRate:5},G=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.OTHER_EXCEPTIONS],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.OTHER_EXCEPTIONS],["Stream is null",l.OTHER_EXCEPTIONS]]),F=new Map([["No Device",l.NO_DEVICE],["Permission denied",l.PERMISSION_DENIED],["Permission dismissed",l.PERMISSION_DENIED],["Could not start video source",l.COULD_NOT_START_VIDEO_SOURCE],["The request is not allowed by the user agent or the platform in the current context.",l.PERMISSION_DENIED],["Failed to allocate videosource",l.COULD_NOT_START_VIDEO_SOURCE],["Stream is null",l.OTHER_EXCEPTIONS]]),B=new Map([["Permission denied by system",l.PERMISSION_DENIED_BY_SYSTEM],["The object can not be found here.",l.PERMISSION_DENIED_BY_SYSTEM],["The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",l.PERMISSION_DENIED_BY_SYSTEM]]),X=function(){return k.instance},z=new g({namespace:"STREAM:Store",debug:!1}),J=function(){function t(t){var e=this,n=t.debug;this.status=c.NULL,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,this.api={getMss:function(t){var n=e.baseURL;return"function"!=typeof fetch?Promise.reject():fetch(n+"/webapp/front/getMss",{headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(t)}).then((function(t){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,t.json()];case 1:return[2,e.sent()]}}))}))}))}},this.baseURL="https://meetings.ylyun.com",this.videoSDKLibDir="",z.switchDebug(n),this.emitter=new a}return t.createInstance=function(e){return this.instance||(this.instance=new t(e)),this.instance},t.prototype.setApi=function(t){this.api=t},t.prototype.setBaseUrl=function(t){this.baseURL=t},t.prototype.setVideoSDKLibDir=function(t){this.videoSDKLibDir=t},t.prototype.setMediaEndpoint=function(t){this.mediaEndpoint=t},t.prototype.setMediaEngine=function(t){this.mediaEngine=t},t.prototype.setAudioChannel=function(t){this.audioChannel=t},t.prototype.setVideoChannel=function(t){this.videoChannel=t},t.prototype.setDataChannel=function(t){this.dataChannel=t},t.prototype.setVideoSender=function(t){this.videoSender=t},t.prototype.setAudioSender=function(t){this.audioSender=t},t.prototype.setDataSender=function(t){this.dataSender=t},t.prototype.setAudioReceiver=function(t){this.audioReceiver=t},t.prototype.setAudioPlayer=function(t){this.audioPlayer=t},t.prototype.throwIfAudioNotOpened=function(t){if(!this.audioChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfVideoNotOpened=function(t){if(!this.videoChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfDataNotOpened=function(t){if(!this.dataChannelOpened)throw new Error(t||"Channel is not open")},t.prototype.throwIfStatus=function(t,e){if(this.status===t)throw new Error(e||"Invalid State")},t.prototype.throwIfNotStatus=function(t,e){if(this.status!==t)throw new Error(e||"Invalid State")},t.prototype.loadLibRTCFiles=function(){var t=this.videoSDKLibDir;return Promise.all([this.createScriptTag({src:t+"/libsfu.prod.js"}),this.createScriptTag({src:t+"/librtc.global.prod.js"})])},t.prototype.getLibRTCContext=function(){var t=window.LIBRTC.SFUTransportType,e=this.mediaEndpoint,n=this.mediaEngine;return e&&n?{mediaEndpoint:e,mediaEngine:n,SFUTransportType:t}:{SFUTransportType:t}},t.prototype.createScriptTag=function(t){var e=t.src;return new Promise((function(t,n){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.onload=function(){t(i)},i.onerror=function(t){n(t)},document.head.appendChild(i)}))},t.prototype.cleanup=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o,a;return r(this,(function(r){switch(r.label){case 0:e=(t=this).videoChannel,n=t.audioChannel,i=t.dataChannel,o=t.mediaEndpoint,r.label=1;case 1:return r.trys.push([1,8,,9]),n?[4,n.close()]:[3,3];case 2:r.sent(),r.label=3;case 3:return e?[4,e.close()]:[3,5];case 4:r.sent(),r.label=5;case 5:return i?[4,i.close()]:[3,7];case 6:r.sent(),r.label=7;case 7:return o&&(o.stop(),o.destroy()),[3,9];case 8:return a=r.sent(),z.error(a),[3,9];case 9:return this.mediaEndpoint=null,this.mediaEngine=null,this.videoChannel=null,this.audioChannel=null,this.dataChannel=null,this.videoSender=null,this.audioSender=null,this.dataSender=null,this.audioReceiver=null,this.audioPlayer=null,this.audioChannelOpened=!1,this.videoChannelOpened=!1,this.dataChannelOpened=!1,[2]}}))}))},t}(),Y=function(){return J.instance},Q=new g({namespace:"STREAM:Store",debug:!1});return function(){function t(t){var e,n=t.baseURL,i=t.videoSDKLibDir,r=t.debug;n=n||"https://meetings.ylyun.com",i=i||"",r=r||!1,Q.switchDebug(r),e={debug:r},J.createInstance(e),function(t){k.createInstance(t)}({debug:r}),Y().setBaseUrl(n),Y().setVideoSDKLibDir(i),this.setup()}return t.prototype.setup=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return X().on(u.AUDIO_STREAM,(function(t){Y().emitter.emit(u.AUDIO_STREAM,t)})),X().on(u.VIDEO_STREAM,(function(t){Y().emitter.emit(u.VIDEO_STREAM,t)})),X().on(u.SHARE_CONTENT_STREAM,(function(t){Y().emitter.emit(u.SHARE_CONTENT_STREAM,t)})),X().on(u.AUDIO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_OUTPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICES_UPDATED,t)})),X().on(u.VIDEO_INPUT_DEVICES_UPDATED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICES_UPDATED,t)})),X().on(u.AUDIO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_OUTPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.AUDIO_OUTPUT_DEVICE_CHANGED,t)})),X().on(u.VIDEO_INPUT_DEVICE_CHANGED,(function(t){Y().emitter.emit(u.VIDEO_INPUT_DEVICE_CHANGED,t)})),X().on(u.AUDIO_STREAM_STATUS,(function(t){Y().emitter.emit(u.AUDIO_STREAM_STATUS,t)})),X().on(u.VIDEO_STREAM_STATUS,(function(t){Y().emitter.emit(u.VIDEO_STREAM_STATUS,t)})),X().on(u.SHARE_CONTENT_STREAM_STATUS,(function(t){Y().emitter.emit(u.SHARE_CONTENT_STREAM_STATUS,t)})),[2]}))}))},t.prototype.cleanup=function(){},t.prototype.on=function(t,e){return Y().emitter.on(t,e)},t.prototype.off=function(t,e){return Y().emitter.off(t,e)},t.prototype.init=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:if(window.ActiveXObject||"ActiveXObject"in window)throw new Error("Not compatible with this browser yet, please use other browsers instead.");return[4,X().init(t)];case 1:return e.sent(),Y().status=c.INIT,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}),[2]}}))}))},t.prototype.start=function(t){return i(this,void 0,void 0,(function(){var e,n,o,a,s,d,h,l,p,v,f,S=this;return r(this,(function(m){switch(m.label){case 0:return Y().throwIfStatus(c.NULL),Y().throwIfStatus(c.START),[4,Y().loadLibRTCFiles().catch((function(t){Q.error(t)}))];case 1:return m.sent(),e=window.LIBRTC,n=e.NativeMediaEndpoint,o=e.NativeMediaEngine,a=t.mediaContent,s=t.user,d=t.meetingID,h=t.ctrlID,l=t.meetingNum,p=t.account,[4,(v=new o).init()];case 2:return m.sent(),(f=new n).onrefresh=function(){return i(S,void 0,void 0,(function(){var t,e,n;return r(this,(function(i){switch(i.label){case 0:return Y().emitter.emit(u.CHANNEL_REFRESH),[4,Y().api.getMss({accessMCs:a.accessMCs,topMC:a.topMC,confId:d,ccid:s.userID,userType:"audience"===s.role?"Broadcast":"Interactive"}).catch((function(t){Q.error(t)}))];case 1:return t=i.sent(),Q.debug("response "+t),t&&t.data&&t.data.MssInfo?(e=t.data.MssInfo.map((function(t){return t.ExtranetlUri})).flat(),n=t.data.MssInfo.map((function(t){return t.IntranetUri})).flat(),[2,e.concat(n).filter((function(t){return t.startsWith("ws")||t.startsWith("wss")})).map((function(t){var e=Y().baseURL;return"wss://"+(/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)?function(t){if(!t)return"";var e=/^([a-z][a-z\d+\-.]*:)?\/\/(\S+)/.exec(t);return!e||e.length<3?"":e[2]}(e):e)+"/webapp/socket/"+window.btoa(t.replace(/\w+:\/\//,""))}))]):(Q.error("getMss response error ",t),[2,[]])}}))}))},[4,f.init()];case 3:return m.sent(),[4,f.start({meeting_number:l||"",user_account:p||"",confid:d,ccid:s.userID,role:1,encrypt:a.crypto,token:h})];case 4:return m.sent(),Y().setMediaEndpoint(f),Y().setMediaEngine(v),Y().status=c.START,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}),[2]}}))}))},t.prototype.stop=function(){Y().throwIfNotStatus(c.START),Y().cleanup(),X().shareContentStreamStatus.status!==h.NULL&&X().closeShareContentStream(),Y().status=c.STOP,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status})},t.prototype.destroy=function(){this.stop(),this.cleanup(),Y().status!==c.NULL&&(X().destroy(),Y().status=c.NULL,Y().emitter.emit(u.STREAM_STATUS,{status:Y().status}))},t.prototype.getStatus=function(){return Y().status},t.prototype.getBaseUrl=function(){return Y().baseURL},t.prototype.getChannelStatus=function(){return{audioChannelOpened:Y().audioChannelOpened,videoChannelOpened:Y().videoChannelOpened,dataChannelOpened:Y().dataChannelOpened}},t.prototype.createAudioChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.audio.createChannel(n.createTransport(i.kAudio)),Y().setAudioChannel(o),o.onopen=function(){Q.debug("audioChannel onopen()"),Y().audioChannelOpened=!0,Y().emitter.emit(u.AUDIO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.closeAudioChannel=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=Y().audioChannel)?[4,t.close()]:(Q.error("audioChannel is miss"),[2]);case 1:return e.sent(),Y().setAudioChannel(null),Y().setAudioSender(null),Y().setAudioReceiver(null),[2]}}))}))},t.prototype.createVideoChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kVideo)),Y().setVideoChannel(o),o.onopen=function(){Q.debug("videoChannel onopen()"),Y().videoChannelOpened=!0,Y().emitter.emit(u.VIDEO_CHANNEL_OPENED)},[4,o.open()];case 1:return r.sent(),[2]}}))}))},t.prototype.createDataChannel=function(){return i(this,void 0,void 0,(function(){var t,e,n,i,o;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),t=Y().getLibRTCContext(),e=t.mediaEngine,n=t.mediaEndpoint,i=t.SFUTransportType,o=e.video.createChannel(n.createTransport(i.kData)),Y().setDataChannel(o),o.onopen=function(){Q.debug("dataChannel onopen()")},[4,o.open()];case 1:return r.sent(),Y().dataChannelOpened=!0,Y().emitter.emit(u.DATA_CHANNEL_OPENED),[2]}}))}))},t.prototype.createAudioSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),(t=Y().audioChannel)?(e=Y().audioSender?Y().audioSender:t.createSender(),Y().setAudioSender(e),[2,e]):(Q.error("audioChannel is miss"),[2,null])}))}))},t.prototype.removeAudioSender=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){if(Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened(),!(t=Y().audioSender))return Q.error("audioSender is miss"),[2];try{t.stop(),Y().audioChannel&&Y().audioChannel.removeSender(t.ssrc)}catch(t){Q.error("audioChannel removeSender() error: ",t)}return[2]}))}))},t.prototype.createVideoSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(t=Y().videoChannel)?(e=Y().videoSender?Y().videoSender:t.createSender(),Y().setVideoSender(e),e.onbusy=function(){Q.debug("onbusy"),Y().emitter.emit(u.CHANNEL_BUSY);var t=Y().audioChannel;t&&t.ans(!1)},[2,e]):(Q.error("videoChannel is miss"),[2,null])}))}))},t.prototype.removeVideoSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var t=Y().videoSender;if(t)try{t.stop(),Y().videoChannel&&Y().videoChannel.removeSender(t.ssrc)}catch(t){Q.error("videoChannel removeSender() error: ",t)}else Q.error("videoSender is miss")},t.prototype.createDataSender=function(){return i(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(t=Y().dataChannel)?(e=Y().dataSender?Y().dataSender:t.createSender(),Y().setDataSender(e),[2,e]):(Q.error("dataChannel is miss"),[2,null])}))}))},t.prototype.removeDataSender=function(){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var t=Y().dataSender;t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeSender(t.ssrc),Y().setDataSender(null)):Q.error("dataSender is miss")},t.prototype.createAudioReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioChannel;if(!e)return Q.error("audioChannel is miss"),null;var n=e.createReceiver();return Y().setAudioReceiver(n),t?(n.setSink(t),Y().setAudioPlayer(t),e.audioElement&&(e.audioElement.srcObject=null),n):(Q.error("audioPlayer is miss"),null)},t.prototype.createVideoReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened();var e=t.ccid;if(Q.debug("createVideoReceiver ccid: ",e),!e)return Q.error("params is missing or params error"),null;var n=Y().videoChannel;return n?n.createReceiver(e):(Q.error("videoChannel is miss"),null)},t.prototype.createDataReceiver=function(t){Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened();var e=t.ccid;if(Q.debug("createDataReceiver ccid: ",e),!e)return Q.error("params is missing or params error"),null;var n=Y().dataChannel;return n?n.createReceiver(e):(Q.error("dataChannel is miss"),null)},t.prototype.removeVideoReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),t?(t.stop(),Y().videoChannel&&Y().videoChannel.removeReceiver(t.ssrc),null):t},t.prototype.removeDataReceiver=function(t){return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),t?(t.stop(),Y().dataChannel&&Y().dataChannel.removeReceiver(t.ssrc),null):t},t.prototype.loadVideoRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(n=Y().videoChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Q.error("videoChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadVideoRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfVideoNotOpened(),(e=Y().videoChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Q.error("videoChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.loadDataRenderer=function(t,e){return void 0===e&&(e=!0),i(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(n=Y().dataChannel)&&t?T||_?[4,n.offscreen.load(t.transferControlToOffscreen(),e)]:[3,2]:(Q.error("dataChannel or el is miss"),[2,null]);case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return[2,i]}}))}))},t.prototype.unloadDataRenderer=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return Y().throwIfNotStatus(c.START),Y().throwIfDataNotOpened(),(e=Y().dataChannel)&&t?T||_?[4,e.offscreen.unload(t)]:[3,2]:(Q.error("dataChannel or renderer is miss"),[2]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},t.prototype.setAudioPlayerVolume=function(t){Y().throwIfNotStatus(c.START),Y().throwIfAudioNotOpened();var e=Y().audioPlayer;e?(t=t>=0&&t<1?t:t>=1&&t<=100?t/100:t,e.volume=t):Q.error("audioPlayer is miss")},t.prototype.getAudioSender=function(){return Y().status===c.START&&Y().audioChannelOpened&&Y().audioSender||null},t.prototype.getVideoSender=function(){return Y().status===c.START&&Y().videoChannelOpened&&Y().videoSender||null},t.prototype.getDataSender=function(){return Y().status===c.START&&Y().dataChannelOpened&&Y().dataSender||null},t.prototype.createAudioStream=function(){return Y().throwIfStatus(c.NULL),X().captureAudioStream()},t.prototype.closeAudioStream=function(){return Y().throwIfStatus(c.NULL),X().closeAudioStream()},t.prototype.createVideoStream=function(){return Y().throwIfStatus(c.NULL),X().captureVideoStream()},t.prototype.closeVideoStream=function(){return Y().throwIfStatus(c.NULL),X().closeVideoStream()},t.prototype.createShareContentStream=function(){return Y().throwIfNotStatus(c.START),X().captureShareContentStream()},t.prototype.closeShareContentStream=function(){return X().closeShareContentStream()},t.prototype.getAudioStream=function(){return X()?X().audioStream:null},t.prototype.getVideoStream=function(){return X()?X().videoStream:null},t.prototype.getShareContentStream=function(){return X()?X().shareContentStream:null},t.prototype.getAudioStreamStatus=function(){return X()?X().audioStreamStatus:null},t.prototype.getVideoStreamStatus=function(){return X()?X().videoStreamStatus:null},t.prototype.getShareContentStreamStatus=function(){return X()?X().shareContentStreamStatus:null},t.prototype.getActiveAudioInputDevice=function(){return X()?X().audioInputDevice:null},t.prototype.getActiveAudioOutputDevice=function(){return X()?X().audioOutputDevice:null},t.prototype.getActiveVideoInputDevice=function(){return X()?X().videoInputDevice:null},t.prototype.getMicVolume=function(){return X()&&Y().status!==c.NULL?X().volumeAnalyser.volume:0},t.prototype.switchAudioInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioInputDeviceId=t)},t.prototype.switchAudioOutputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().audioOutputDeviceId=t)},t.prototype.switchVideoInputDevice=function(t){Y().throwIfStatus(c.NULL),t&&(X().videoInputDeviceId=t)},t.prototype.getAudioInputDevices=function(){return X()?X().audioInputDevices:[]},t.prototype.getAudioOutputDevices=function(){return X()?X().audioOutputDevices:[]},t.prototype.getVideoInputDevices=function(){return X()?X().videoInputDevices:[]},t.EVENT=u,t.STATUS=c,t.MEDIA_STATUS=d,t.MEDIA_STREAM_STATUS=h,t.MEDIA_STREAM_DETAIL=l,t}()})); |
{ | ||
"name": "@ylink-sdk/stream", | ||
"version": "0.1.3", | ||
"version": "0.1.5", | ||
"main": "dist/ylink-sdk-stream.umd.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/ylink-sdk-stream.es.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123815
1122