@gjsify/webrtc 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{Gst as e,ensureGstInit as t}from"./gst-init.js";import{getUserMedia as n}from"./get-user-media.js";import{MediaDeviceInfo as r}from"./media-device-info.js";import"@gjsify/dom-events/register/event-target";const i={"Audio/Source":`audioinput`,"Video/Source":`videoinput`,"Audio/Sink":`audiooutput`};let a=!1;function isDeviceMonitorSafe(){try{let e=imports.gi.GLib;return!(e.getenv(`CI`)||!e.getenv(`DISPLAY`)&&!e.getenv(`WAYLAND_DISPLAY`))}catch{return!1}}var MediaDevices=class extends EventTarget{_ondevicechange=null;get ondevicechange(){return this._ondevicechange}set ondevicechange(e){this._ondevicechange=e}async getUserMedia(e){if(!e)throw TypeError(`Failed to execute 'getUserMedia' on 'MediaDevices': At least one of audio or video must be requested`);let t=await n(e);return a=!0,t}async enumerateDevices(){t();let n=null,o=[];try{if(!isDeviceMonitorSafe())return o;n=new e.DeviceMonitor,n.set_show_all_devices(!0);let t=e.Caps.from_string(`audio/x-raw`),s=e.Caps.from_string(`video/x-raw`);if(t&&(n.add_filter(`Audio/Source`,t),n.add_filter(`Audio/Sink`,t)),s&&n.add_filter(`Video/Source`,s),!n.start())return o;let c;try{c=n.get_devices()??[]}catch{return o}for(let e of c){let t=i[e.get_device_class?.()??``];if(!t)continue;let n=e.get_display_name?.()??``,s=``,c=``;try{let t=e.get_properties?.();if(t){let e=t.n_fields();for(let n=0;n<e;n++){let e=t.nth_field_name(n);if(e===`persistent-id`||e===`node.name`){let n=t.get_value(e);n&&!s&&(s=String(n))}if(e===`group-id`){let n=t.get_value(e);n&&(c=String(n))}}}}catch{}s||=n||`${t}-${o.length}`,a?o.push(new r({deviceId:s,kind:t,label:n,groupId:c})):o.some(e=>e.kind===t)||o.push(new r({deviceId:``,kind:t,label:``,groupId:``}))}}catch{return o}finally{try{n?.stop()}catch{}}let s={audioinput:0,videoinput:1,audiooutput:2};return o.sort((e,t)=>(s[e.kind]??3)-(s[t.kind]??3)),o}getSupportedConstraints(){return{deviceId:!0,width:!0,height:!0,frameRate:!0,sampleRate:!0,channelCount:!0,aspectRatio:!1,facingMode:!1,resizeMode:!1,echoCancellation:!1,autoGainControl:!1,noiseSuppression:!1,latency:!1,groupId:!1}}};export{MediaDevices};
1
+ import"./_virtual/_rolldown/runtime.js";import{Gst as e,ensureGstInit as t}from"./gst-init.js";import{getUserMedia as n}from"./get-user-media.js";import{MediaDeviceInfo as r}from"./media-device-info.js";import"@gjsify/dom-events/register/event-target";const i={"Audio/Source":`audioinput`,"Video/Source":`videoinput`,"Audio/Sink":`audiooutput`};let a=!1;function isDeviceMonitorSafe(){try{let e=imports.gi.GLib;return!(e.getenv(`CI`)||!e.getenv(`DISPLAY`)&&!e.getenv(`WAYLAND_DISPLAY`))}catch{return!1}}var MediaDevices=class extends EventTarget{_ondevicechange=null;get ondevicechange(){return this._ondevicechange}set ondevicechange(e){this._ondevicechange=e}async getUserMedia(e){if(!e)throw TypeError(`Failed to execute 'getUserMedia' on 'MediaDevices': At least one of audio or video must be requested`);let t=await n(e);return a=!0,t}async enumerateDevices(){t();let n=null,o=[];try{if(!isDeviceMonitorSafe())return o;n=new e.DeviceMonitor,n.set_show_all_devices(!0);let t=e.Caps.from_string(`audio/x-raw`),s=e.Caps.from_string(`video/x-raw`);if(t&&(n.add_filter(`Audio/Source`,t),n.add_filter(`Audio/Sink`,t)),s&&n.add_filter(`Video/Source`,s),!n.start())return o;let c;try{c=n.get_devices()??[]}catch{return o}for(let e of c){let t=e.get_device_class?.()??``,n=i[t];if(!n)continue;let s=e.get_display_name?.()??``,c=``,l=``;try{let t=e.get_properties?.();if(t){let e=t.n_fields();for(let n=0;n<e;n++){let e=t.nth_field_name(n);if(e===`persistent-id`||e===`node.name`){let n=t.get_value(e);n&&!c&&(c=String(n))}if(e===`group-id`){let n=t.get_value(e);n&&(l=String(n))}}}}catch{}c||=s||`${n}-${o.length}`,a?o.push(new r({deviceId:c,kind:n,label:s,groupId:l})):o.some(e=>e.kind===n)||o.push(new r({deviceId:``,kind:n,label:``,groupId:``}))}}catch{return o}finally{try{n?.stop()}catch{}}let s={audioinput:0,videoinput:1,audiooutput:2};return o.sort((e,t)=>(s[e.kind]??3)-(s[t.kind]??3)),o}getSupportedConstraints(){return{deviceId:!0,width:!0,height:!0,frameRate:!0,sampleRate:!0,channelCount:!0,aspectRatio:!1,facingMode:!1,resizeMode:!1,echoCancellation:!1,autoGainControl:!1,noiseSuppression:!1,latency:!1,groupId:!1}}};export{MediaDevices};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/webrtc",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "W3C WebRTC API for GJS using GStreamer webrtcbin as the peer-connection backend",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -61,10 +61,10 @@
61
61
  "peer-connection"
62
62
  ],
63
63
  "dependencies": {
64
- "@gjsify/buffer": "^0.22.0",
65
- "@gjsify/dom-events": "^0.22.0",
66
- "@gjsify/dom-exception": "^0.22.0",
67
- "@gjsify/webrtc-native": "^0.22.0"
64
+ "@gjsify/buffer": "^0.23.0",
65
+ "@gjsify/dom-events": "^0.23.0",
66
+ "@gjsify/dom-exception": "^0.23.0",
67
+ "@gjsify/webrtc-native": "^0.23.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@girs/gjs": "^4.1.0",
@@ -73,8 +73,8 @@
73
73
  "@girs/gst-1.0": "^4.1.0",
74
74
  "@girs/gstsdp-1.0": "^4.1.0",
75
75
  "@girs/gstwebrtc-1.0": "^4.1.0",
76
- "@gjsify/cli": "^0.22.0",
77
- "@gjsify/unit": "^0.22.0",
76
+ "@gjsify/cli": "^0.23.0",
77
+ "@gjsify/unit": "^0.23.0",
78
78
  "@types/node": "^25.9.2",
79
79
  "typescript": "^6.0.3"
80
80
  },