{"version":3,"sources":["webpack:///./src/views/recorder/components/volume-tester/index.ts","webpack:///./src/views/recorder/lib/devices.ts"],"names":["VolumeTester","selectDevice","id","type","LocalStorage","setInputDevice","setVideoInputDevice","getInputDevice","getVideoInputDevice","getDevices","navigator","mediaDevices","enumerateDevices","console","log","inputDevice","constraints","video","audio","channelCount","echoCancellation","deviceId","undefined","getUserMedia","stream","getTracks","forEach","t","stop","devices","deviceType","inputDevices","filter","x","kind","map","name","label","length","error"],"mappings":"oJAAA,uBACeA,2B,kQCOFC,EAAe,SAACC,GAA0C,IAA9BC,yDAAmB,QAC7C,UAATA,EAAkBC,OAAaC,eAAeH,GAC7CE,OAAaE,oBAAoBJ,IAG3BK,EAAiB,WAA+B,IAA9BJ,yDAAmB,QAChD,MAAgB,UAATA,EACHC,OAAaG,iBACbH,OAAaI,uBAGNC,EAAU,uDAAG,0HAAiC,GAA1BN,iCAAmB,QAC7CO,UAAUC,cAAiBD,UAAUC,aAAaC,iBAAgB,gBACpB,OAAjDC,QAAQC,IAAI,qCAAqC,kBAC1C,IAAE,OAmBJ,OAhBDC,EAAcR,IACdS,EACK,UAATb,EACI,CACEc,OAAO,EACPC,MAAO,CACLC,aAAc,EACdC,kBAAkB,EAClBC,SAAUN,QAA4BO,IAG1C,CACEJ,OAAO,EACPD,MAAO,CACLI,SAAUN,QAA4BO,IAEzC,kBAGgBZ,UAAUC,aAAaY,aAAaP,GAAY,OAC3B,OADpCQ,EAAS,EAAH,KACZA,EAAOC,YAAYC,SAAQ,SAAAC,GAAC,OAAIA,EAAEC,UAAQ,UACpBlB,UAAUC,aAAaC,mBAAkB,QAQtB,OARnCiB,EAAU,EAAH,KAEPC,EACK,UAAT3B,EAAmB,aAAe,aAC9B4B,EAAeF,EAClBG,QAAO,SAAAC,GAAC,OAAIA,EAAEC,OAASJ,KACvBK,KAAI,SAAAF,GAAC,MAAK,CAAE/B,GAAI+B,EAAEZ,SAAUe,KAAMH,EAAEI,WAClCtB,GAAegB,EAAaO,OAAS,GACxCrC,EAAa8B,EAAa,GAAG7B,GAAIC,GAAM,kBAClC4B,GAAY,QAE4B,OAF5B,6BAEnBlB,QAAQ0B,MAAM,yBAA0B,EAAF,IAAS,kBACxC,IAAE,0DAEZ,kBAzCsB","file":"assets/js/chunk-456ac820.1e1d4c5f.js","sourcesContent":["import VolumeTester from \"./VolumeTester.vue\";\r\nexport default VolumeTester;\r\n","import LocalStorage from \"@/core/utils/LocalStorage\";\r\n\r\ntype DeviceType = \"video\" | \"audio\";\r\nexport interface Device {\r\n id: string;\r\n name: string;\r\n}\r\n\r\nexport const selectDevice = (id: string, type: DeviceType = \"audio\") => {\r\n if (type === \"audio\") LocalStorage.setInputDevice(id);\r\n else LocalStorage.setVideoInputDevice(id);\r\n};\r\n\r\nexport const getInputDevice = (type: DeviceType = \"audio\") => {\r\n return type === \"audio\"\r\n ? LocalStorage.getInputDevice()\r\n : LocalStorage.getVideoInputDevice();\r\n};\r\n\r\nexport const getDevices = async (type: DeviceType = \"audio\") => {\r\n if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {\r\n console.log(\"enumerateDevices() not supported.\");\r\n return [];\r\n }\r\n\r\n const inputDevice = getInputDevice();\r\n const constraints: MediaStreamConstraints =\r\n type === \"audio\"\r\n ? {\r\n video: false,\r\n audio: {\r\n channelCount: 1,\r\n echoCancellation: false,\r\n deviceId: inputDevice ? inputDevice : undefined,\r\n },\r\n }\r\n : {\r\n audio: false,\r\n video: {\r\n deviceId: inputDevice ? inputDevice : undefined,\r\n },\r\n };\r\n\r\n try {\r\n const stream = await navigator.mediaDevices.getUserMedia(constraints);\r\n stream.getTracks().forEach(t => t.stop());\r\n const devices = await navigator.mediaDevices.enumerateDevices();\r\n\r\n const deviceType: MediaDeviceKind =\r\n type === \"audio\" ? \"audioinput\" : \"videoinput\";\r\n const inputDevices = devices\r\n .filter(x => x.kind === deviceType)\r\n .map(x => ({ id: x.deviceId, name: x.label } as Device));\r\n if (!inputDevice && inputDevices.length > 0)\r\n selectDevice(inputDevices[0].id, type);\r\n return inputDevices;\r\n } catch (error) {\r\n console.error(\"Error getting devices:\", error);\r\n return [];\r\n }\r\n};\r\n"],"sourceRoot":""}