@gjsify/webrtc 0.49.0 → 0.51.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";const asWebRtcBin=e=>e,asWebRtcSrcPad=e=>e,asValveElement=e=>e,asRtpPayloaderElement=e=>e,asCapsFilterElement=e=>e,asVp8EncElement=e=>e;export{asCapsFilterElement,asRtpPayloaderElement,asValveElement,asVp8EncElement,asWebRtcBin,asWebRtcSrcPad};
1
+ import"../_virtual/_rolldown/runtime.js";import e from"gi://GObject?version=2.0";const asWebRtcBin=e=>e,emitWebRtcBin=(t,n,...r)=>e.signal_emit_by_name(t,n,...r),asWebRtcSrcPad=e=>e,asValveElement=e=>e,asRtpPayloaderElement=e=>e,asCapsFilterElement=e=>e,asVp8EncElement=e=>e;export{asCapsFilterElement,asRtpPayloaderElement,asValveElement,asVp8EncElement,asWebRtcBin,asWebRtcSrcPad,emitWebRtcBin};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{Gst as e}from"../gst-init.js";import{RTCDataChannel as t}from"../rtc-data-channel.js";import{DOMException as n}from"@gjsify/dom-exception";function coerceUnsignedShort(e,t){let n=Number(t);if(!Number.isFinite(n))throw TypeError(`createDataChannel: ${e} must be a finite number, got ${String(t)}`);let r=Math.trunc(n);if(r<0||r>65535)throw TypeError(`createDataChannel: ${e}=${r} is outside the [0, 65535] range`);return r}const r={createDataChannel(r,i={}){if(this._closed)throw new n(`Cannot create a data channel on a closed RTCPeerConnection`,`InvalidStateError`);if(typeof r!=`string`)throw TypeError(`createDataChannel: label must be a string`);if(new TextEncoder().encode(r).byteLength>65535)throw TypeError(`createDataChannel: label too long (> 65535 bytes)`);let a=i.maxPacketLifeTime==null?void 0:coerceUnsignedShort(`maxPacketLifeTime`,i.maxPacketLifeTime),o=i.maxRetransmits==null?void 0:coerceUnsignedShort(`maxRetransmits`,i.maxRetransmits),s=i.id==null?void 0:coerceUnsignedShort(`id`,i.id);if(a!==void 0&&o!==void 0)throw TypeError(`createDataChannel: maxPacketLifeTime and maxRetransmits are mutually exclusive`);if(i.negotiated===!0&&s===void 0)throw TypeError(`createDataChannel: negotiated=true requires an id`);if(s===65535)throw TypeError(`createDataChannel: id 65535 is reserved`);let c=e.Structure.new_empty(`data-channel-opts`);this._setStructureField(c,`ordered`,`boolean`,i.ordered),this._setStructureField(c,`max-packet-lifetime`,`int`,a),this._setStructureField(c,`max-retransmits`,`int`,o),this._setStructureField(c,`protocol`,`string`,i.protocol),this._setStructureField(c,`negotiated`,`boolean`,i.negotiated),this._setStructureField(c,`id`,`int`,s);let l=null;try{l=this._webrtcbin.emit(`create-data-channel`,r,c)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`create-data-channel failed: ${t}`)}if(!l)throw Error(`webrtcbin returned null data channel (check id/label/options)`);this._ensureSctpTransport();let u=new t(l,this.sctp??void 0);return this._dataChannels.set(l,u),u.addEventListener(`close`,()=>{this._dataChannels.delete(l)}),this._updateNegotiationNeeded(),u}};function installDataChannelMethods(e){Object.assign(e,r)}export{installDataChannelMethods};
1
+ import"../_virtual/_rolldown/runtime.js";import{Gst as e}from"../gst-init.js";import{emitWebRtcBin as t}from"../internal/gst-types.js";import{RTCDataChannel as n}from"../rtc-data-channel.js";import{DOMException as r}from"@gjsify/dom-exception";function coerceUnsignedShort(e,t){let n=Number(t);if(!Number.isFinite(n))throw TypeError(`createDataChannel: ${e} must be a finite number, got ${String(t)}`);let r=Math.trunc(n);if(r<0||r>65535)throw TypeError(`createDataChannel: ${e}=${r} is outside the [0, 65535] range`);return r}const i={createDataChannel(i,a={}){if(this._closed)throw new r(`Cannot create a data channel on a closed RTCPeerConnection`,`InvalidStateError`);if(typeof i!=`string`)throw TypeError(`createDataChannel: label must be a string`);if(new TextEncoder().encode(i).byteLength>65535)throw TypeError(`createDataChannel: label too long (> 65535 bytes)`);let o=a.maxPacketLifeTime==null?void 0:coerceUnsignedShort(`maxPacketLifeTime`,a.maxPacketLifeTime),s=a.maxRetransmits==null?void 0:coerceUnsignedShort(`maxRetransmits`,a.maxRetransmits),c=a.id==null?void 0:coerceUnsignedShort(`id`,a.id);if(o!==void 0&&s!==void 0)throw TypeError(`createDataChannel: maxPacketLifeTime and maxRetransmits are mutually exclusive`);if(a.negotiated===!0&&c===void 0)throw TypeError(`createDataChannel: negotiated=true requires an id`);if(c===65535)throw TypeError(`createDataChannel: id 65535 is reserved`);let l=e.Structure.new_empty(`data-channel-opts`);this._setStructureField(l,`ordered`,`boolean`,a.ordered),this._setStructureField(l,`max-packet-lifetime`,`int`,o),this._setStructureField(l,`max-retransmits`,`int`,s),this._setStructureField(l,`protocol`,`string`,a.protocol),this._setStructureField(l,`negotiated`,`boolean`,a.negotiated),this._setStructureField(l,`id`,`int`,c);let u=null;try{u=t(this._webrtcbin,`create-data-channel`,i,l)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`create-data-channel failed: ${t}`)}if(!u)throw Error(`webrtcbin returned null data channel (check id/label/options)`);this._ensureSctpTransport();let d=new n(u,this.sctp??void 0);return this._dataChannels.set(u,d),d.addEventListener(`close`,()=>{this._dataChannels.delete(u)}),this._updateNegotiationNeeded(),d}};function installDataChannelMethods(e){Object.assign(e,i)}export{installDataChannelMethods};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{Gst as e}from"../gst-init.js";import{withGstPromise as t}from"../gst-utils.js";import{RTCSessionDescription as n}from"../rtc-session-description.js";import{rewriteIceCredentials as r}from"../sdp-params.js";import{DOMException as i}from"@gjsify/dom-exception";const a={async createOffer(i){this._rejectIfClosed(`createOffer`);let a=e.Structure.new_empty(`offer-options`),o=this._iceRestartNeeded;o&&(this._setStructureField(a,`ice-restart`,`boolean`,!0),this._iceRestartNeeded=!1);let s=(await t(e=>{this._webrtcbin.emit(`create-offer`,a,e)})).get_value(`offer`),c=n.fromGstDesc(s).toJSON();return o&&(c.sdp=r(c.sdp)),c},async createAnswer(r){this._rejectIfClosed(`createAnswer`);let i=e.Structure.new_empty(`answer-options`),a=(await t(e=>{this._webrtcbin.emit(`create-answer`,i,e)})).get_value(`answer`);return n.fromGstDesc(a).toJSON()},async setLocalDescription(r){if(this._rejectIfClosed(`setLocalDescription`),!r||!r.type){let e=this.signalingState;if(e===`stable`||e===`have-local-offer`)r=await this.createOffer();else if(e===`have-remote-offer`||e===`have-remote-pranswer`)r=await this.createAnswer();else throw new i(`setLocalDescription: cannot auto-create SDP in signalingState '${e}'`,`InvalidStateError`)}if(r.type===`rollback`){let e=this.signalingState;if(e!==`have-local-offer`)throw new i(`setLocalDescription: cannot rollback in signalingState '${e}'`,`InvalidStateError`);let a=this.currentLocalDescription!==null,o=new n(r).toGstDesc();await t(e=>{this._webrtcbin.emit(`set-local-description`,o,e)}),a||this._clearTransports();return}this._pipeline.set_state(e.State.PLAYING);let a=new n(r).toGstDesc();await t(e=>{this._webrtcbin.emit(`set-local-description`,a,e)}),this._assignTransports()},async setRemoteDescription(r){if(this._rejectIfClosed(`setRemoteDescription`),!r||!r.sdp||!r.type)throw TypeError(`setRemoteDescription requires an RTCSessionDescriptionInit with sdp and type`);this._pipeline.set_state(e.State.PLAYING);let i=new n(r).toGstDesc();await t(e=>{this._webrtcbin.emit(`set-remote-description`,i,e)}),this.signalingState===`stable`&&(this._hasNegotiated=!0)},async addIceCandidate(e){if(this._rejectIfClosed(`addIceCandidate`),!e)return;let{candidate:t,sdpMLineIndex:n}=e;typeof t!=`string`||typeof n!=`number`||this._webrtcbin.emit(`add-ice-candidate`,n,t)}};function installSdpNegotiationMethods(e){Object.assign(e,a)}export{installSdpNegotiationMethods};
1
+ import"../_virtual/_rolldown/runtime.js";import{Gst as e}from"../gst-init.js";import{withGstPromise as t}from"../gst-utils.js";import{emitWebRtcBin as n}from"../internal/gst-types.js";import{RTCSessionDescription as r}from"../rtc-session-description.js";import{rewriteIceCredentials as i}from"../sdp-params.js";import{DOMException as a}from"@gjsify/dom-exception";const o={async createOffer(a){this._rejectIfClosed(`createOffer`);let o=e.Structure.new_empty(`offer-options`),s=this._iceRestartNeeded;s&&(this._setStructureField(o,`ice-restart`,`boolean`,!0),this._iceRestartNeeded=!1);let c=(await t(e=>{n(this._webrtcbin,`create-offer`,o,e)})).get_value(`offer`),l=r.fromGstDesc(c).toJSON();return s&&(l.sdp=i(l.sdp)),l},async createAnswer(i){this._rejectIfClosed(`createAnswer`);let a=e.Structure.new_empty(`answer-options`),o=(await t(e=>{n(this._webrtcbin,`create-answer`,a,e)})).get_value(`answer`);return r.fromGstDesc(o).toJSON()},async setLocalDescription(i){if(this._rejectIfClosed(`setLocalDescription`),!i||!i.type){let e=this.signalingState;if(e===`stable`||e===`have-local-offer`)i=await this.createOffer();else if(e===`have-remote-offer`||e===`have-remote-pranswer`)i=await this.createAnswer();else throw new a(`setLocalDescription: cannot auto-create SDP in signalingState '${e}'`,`InvalidStateError`)}if(i.type===`rollback`){let e=this.signalingState;if(e!==`have-local-offer`)throw new a(`setLocalDescription: cannot rollback in signalingState '${e}'`,`InvalidStateError`);let o=this.currentLocalDescription!==null,s=new r(i).toGstDesc();await t(e=>{n(this._webrtcbin,`set-local-description`,s,e)}),o||this._clearTransports();return}this._pipeline.set_state(e.State.PLAYING);let o=new r(i).toGstDesc();await t(e=>{n(this._webrtcbin,`set-local-description`,o,e)}),this._assignTransports()},async setRemoteDescription(i){if(this._rejectIfClosed(`setRemoteDescription`),!i||!i.sdp||!i.type)throw TypeError(`setRemoteDescription requires an RTCSessionDescriptionInit with sdp and type`);this._pipeline.set_state(e.State.PLAYING);let a=new r(i).toGstDesc();await t(e=>{n(this._webrtcbin,`set-remote-description`,a,e)}),this.signalingState===`stable`&&(this._hasNegotiated=!0)},async addIceCandidate(e){if(this._rejectIfClosed(`addIceCandidate`),!e)return;let{candidate:t,sdpMLineIndex:r}=e;typeof t!=`string`||typeof r!=`number`||n(this._webrtcbin,`add-ice-candidate`,r,t)}};function installSdpNegotiationMethods(e){Object.assign(e,o)}export{installSdpNegotiationMethods};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{MediaStreamTrack as e}from"../media-stream-track.js";import{filterStatsByTrackId as t,parseGstStats as n}from"../gst-stats-parser.js";import{withGstPromise as r}from"../gst-utils.js";import{DOMException as i}from"@gjsify/dom-exception";const a={async getStats(a){if(this._rejectIfClosed(`getStats`),a!=null&&a instanceof e){let e=this._senders.some(e=>e.track===a),t=this._receivers.some(e=>e.track===a);if(!e&&!t)throw new i(`The selector track is not associated with a sender or receiver of this connection`,`InvalidAccessError`)}let o=n(await r(e=>{this._webrtcbin.emit(`get-stats`,null,e)}));return a!=null&&a instanceof e?t(o,a.id):o},restartIce(){this._closed||(this._iceRestartNeeded=!0,this._updateNegotiationNeeded())},setConfiguration(e){if(this._rejectIfClosed(`setConfiguration`),e.bundlePolicy&&e.bundlePolicy!==(this._conf.bundlePolicy??`balanced`))throw new i(`setConfiguration: bundlePolicy cannot be changed`,`InvalidModificationError`);if(e.rtcpMuxPolicy&&e.rtcpMuxPolicy!==(this._conf.rtcpMuxPolicy??`require`))throw new i(`setConfiguration: rtcpMuxPolicy cannot be changed`,`InvalidModificationError`);e.iceServers&&this._applyIceServers(e.iceServers),e.iceTransportPolicy&&this._applyIceTransportPolicy(e.iceTransportPolicy),this._conf={...this._conf,...e}},getConfiguration(){return{...this._conf}}};function installStatsAndConfigMethods(e){Object.assign(e,a)}export{installStatsAndConfigMethods};
1
+ import"../_virtual/_rolldown/runtime.js";import{MediaStreamTrack as e}from"../media-stream-track.js";import{filterStatsByTrackId as t,parseGstStats as n}from"../gst-stats-parser.js";import{withGstPromise as r}from"../gst-utils.js";import{emitWebRtcBin as i}from"../internal/gst-types.js";import{DOMException as a}from"@gjsify/dom-exception";const o={async getStats(o){if(this._rejectIfClosed(`getStats`),o!=null&&o instanceof e){let e=this._senders.some(e=>e.track===o),t=this._receivers.some(e=>e.track===o);if(!e&&!t)throw new a(`The selector track is not associated with a sender or receiver of this connection`,`InvalidAccessError`)}let s=n(await r(e=>{i(this._webrtcbin,`get-stats`,null,e)}));return o!=null&&o instanceof e?t(s,o.id):s},restartIce(){this._closed||(this._iceRestartNeeded=!0,this._updateNegotiationNeeded())},setConfiguration(e){if(this._rejectIfClosed(`setConfiguration`),e.bundlePolicy&&e.bundlePolicy!==(this._conf.bundlePolicy??`balanced`))throw new a(`setConfiguration: bundlePolicy cannot be changed`,`InvalidModificationError`);if(e.rtcpMuxPolicy&&e.rtcpMuxPolicy!==(this._conf.rtcpMuxPolicy??`require`))throw new a(`setConfiguration: rtcpMuxPolicy cannot be changed`,`InvalidModificationError`);e.iceServers&&this._applyIceServers(e.iceServers),e.iceTransportPolicy&&this._applyIceTransportPolicy(e.iceTransportPolicy),this._conf={...this._conf,...e}},getConfiguration(){return{...this._conf}}};function installStatsAndConfigMethods(e){Object.assign(e,o)}export{installStatsAndConfigMethods};
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{Gst as e}from"../gst-init.js";import{MediaStreamTrack as t}from"../media-stream-track.js";import{w3cDirectionToGst as n}from"../gst-enum-maps.js";import{defaultRtpCapsString as r}from"../rtp-capabilities.js";import{RTCRtpSender as i}from"../rtc-rtp-sender.js";import{RTCRtpReceiver as a}from"../rtc-rtp-receiver.js";import{RTCRtpTransceiver as o}from"../rtc-rtp-transceiver.js";const s={addTransceiver(s,c){this._rejectIfClosed(`addTransceiver`);let l;if(typeof s==`string`){if(s!==`audio`&&s!==`video`)throw TypeError(`Failed to execute 'addTransceiver' on 'RTCPeerConnection': The provided value '${s}' is not a valid enum value of type MediaStreamTrackKind.`);l=s}else if(s instanceof t)l=s.kind;else throw TypeError(`Failed to execute 'addTransceiver' on 'RTCPeerConnection': parameter 1 is not of type 'MediaStreamTrack' or a valid MediaStreamTrackKind.`);if(c?.sendEncodings){let e=new Set;for(let t of c.sendEncodings){if(t.rid!==void 0){if(typeof t.rid!=`string`||t.rid.length===0||t.rid.length>16||!/^[a-zA-Z0-9]+$/.test(t.rid))throw TypeError(`Invalid RID value: ${t.rid}`);if(e.has(t.rid))throw TypeError(`Duplicate RID: ${t.rid}`);e.add(t.rid)}if(t.scaleResolutionDownBy!==void 0&&t.scaleResolutionDownBy<1)throw RangeError(`scaleResolutionDownBy must be >= 1.0`)}}let u=c?.direction??`sendrecv`;if(![`sendrecv`,`sendonly`,`recvonly`,`inactive`].includes(u))throw TypeError(`Failed to execute 'addTransceiver' on 'RTCPeerConnection': The provided value '${u}' is not a valid enum value of type RTCRtpTransceiverDirection.`);let d=s instanceof t&&s._gstSource,f=u===`sendrecv`||u===`sendonly`,p,m;if(d&&f){let e=s,t=new i(null,this._pipeline,this._webrtcbin);t._kind=l,t._onPipelineChanged=e=>{this._pipeline=e},t._setTrack(e),t._wirePipeline(e);let r=this._findNewGstTransceiver();if(!r)throw Error(`webrtcbin did not create a transceiver for the send pad`);p=r;let c=p.receiver??null,d=new a(l,c,this._pipeline),statsDelegate=e=>this.getStats(e);if(t._getStatsForTrack=statsDelegate,d._getStatsForTrack=statsDelegate,this.localDescription){let e=this._ensureTransports();t._transport=e,d._transport=e}m=new o(p,t,d),t._transceiver=m,this._transceivers.set(p,m),this._senders.push(t),this._receivers.push(d),p.direction=n(u)}else{let i=e.Caps.from_string(r(l)),a=n(u===`inactive`?`sendrecv`:u),o=this._webrtcbin.emit(`add-transceiver`,a,i);if(!o)throw Error(`webrtcbin did not create a transceiver`);p=o,m=this._transceivers.get(p),m||=this._createTransceiverWrapper(p),p.direction=n(u),s instanceof t&&m.sender._setTrack(s)}return this._updateNegotiationNeeded(),m}};function installTransceiverMethods(e){Object.assign(e,s)}export{installTransceiverMethods};
1
+ import"../_virtual/_rolldown/runtime.js";import{Gst as e}from"../gst-init.js";import{MediaStreamTrack as t}from"../media-stream-track.js";import{w3cDirectionToGst as n}from"../gst-enum-maps.js";import{emitWebRtcBin as r}from"../internal/gst-types.js";import{defaultRtpCapsString as i}from"../rtp-capabilities.js";import{RTCRtpSender as a}from"../rtc-rtp-sender.js";import{RTCRtpReceiver as o}from"../rtc-rtp-receiver.js";import{RTCRtpTransceiver as s}from"../rtc-rtp-transceiver.js";const c={addTransceiver(c,l){this._rejectIfClosed(`addTransceiver`);let u;if(typeof c==`string`){if(c!==`audio`&&c!==`video`)throw TypeError(`Failed to execute 'addTransceiver' on 'RTCPeerConnection': The provided value '${c}' is not a valid enum value of type MediaStreamTrackKind.`);u=c}else if(c instanceof t)u=c.kind;else throw TypeError(`Failed to execute 'addTransceiver' on 'RTCPeerConnection': parameter 1 is not of type 'MediaStreamTrack' or a valid MediaStreamTrackKind.`);if(l?.sendEncodings){let e=new Set;for(let t of l.sendEncodings){if(t.rid!==void 0){if(typeof t.rid!=`string`||t.rid.length===0||t.rid.length>16||!/^[a-zA-Z0-9]+$/.test(t.rid))throw TypeError(`Invalid RID value: ${t.rid}`);if(e.has(t.rid))throw TypeError(`Duplicate RID: ${t.rid}`);e.add(t.rid)}if(t.scaleResolutionDownBy!==void 0&&t.scaleResolutionDownBy<1)throw RangeError(`scaleResolutionDownBy must be >= 1.0`)}}let d=l?.direction??`sendrecv`;if(![`sendrecv`,`sendonly`,`recvonly`,`inactive`].includes(d))throw TypeError(`Failed to execute 'addTransceiver' on 'RTCPeerConnection': The provided value '${d}' is not a valid enum value of type RTCRtpTransceiverDirection.`);let f=c instanceof t&&c._gstSource,p=d===`sendrecv`||d===`sendonly`,m,h;if(f&&p){let e=c,t=new a(null,this._pipeline,this._webrtcbin);t._kind=u,t._onPipelineChanged=e=>{this._pipeline=e},t._setTrack(e),t._wirePipeline(e);let r=this._findNewGstTransceiver();if(!r)throw Error(`webrtcbin did not create a transceiver for the send pad`);m=r;let i=m.receiver??null,l=new o(u,i,this._pipeline),statsDelegate=e=>this.getStats(e);if(t._getStatsForTrack=statsDelegate,l._getStatsForTrack=statsDelegate,this.localDescription){let e=this._ensureTransports();t._transport=e,l._transport=e}h=new s(m,t,l),t._transceiver=h,this._transceivers.set(m,h),this._senders.push(t),this._receivers.push(l),m.direction=n(d)}else{let a=e.Caps.from_string(i(u)),o=n(d===`inactive`?`sendrecv`:d),s=r(this._webrtcbin,`add-transceiver`,o,a);if(!s)throw Error(`webrtcbin did not create a transceiver`);m=s,h=this._transceivers.get(m),h||=this._createTransceiverWrapper(m),m.direction=n(d),c instanceof t&&h.sender._setTrack(c)}return this._updateNegotiationNeeded(),h}};function installTransceiverMethods(e){Object.assign(e,c)}export{installTransceiverMethods};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{Gst as e,ensureWebrtcbinAvailable as t}from"./gst-init.js";import{MediaStream as n}from"./media-stream.js";import{gstToConnectionState as r,gstToIceConnectionState as i,gstToIceGatheringState as a,gstToSignalingState as o}from"./gst-enum-maps.js";import{asWebRtcBin as s,asWebRtcSrcPad as c}from"./internal/gst-types.js";import{RTCSessionDescription as l}from"./rtc-session-description.js";import{RTCIceCandidate as u}from"./rtc-ice-candidate.js";import{RTCDataChannelEvent as d,RTCPeerConnectionIceEvent as f}from"./rtc-events.js";import{RTCDataChannel as p}from"./rtc-data-channel.js";import{RTCRtpSender as m}from"./rtc-rtp-sender.js";import{RTCRtpReceiver as h}from"./rtc-rtp-receiver.js";import{RTCRtpTransceiver as g}from"./rtc-rtp-transceiver.js";import{RTCTrackEvent as _}from"./rtc-track-event.js";import{RTCIceTransport as v}from"./rtc-ice-transport.js";import{RTCDtlsTransport as y}from"./rtc-dtls-transport.js";import{RTCSctpTransport as b}from"./rtc-sctp-transport.js";import{RTCCertificate as x,generateCertificate as S}from"./rtc-certificate.js";import{installSdpNegotiationMethods as C}from"./rtc-peer-connection/sdp-negotiation.js";import{installDataChannelMethods as w}from"./rtc-peer-connection/data-channel.js";import{installTransceiverMethods as T}from"./rtc-peer-connection/transceivers.js";import{installTrackMethods as E}from"./rtc-peer-connection/tracks.js";import{installStatsAndConfigMethods as D}from"./rtc-peer-connection/stats-and-config.js";import{DOMException as O}from"@gjsify/dom-exception";import k from"gi://GLib?version=2.0";import A from"gi://GstWebRTC?version=1.0";import{WebrtcbinBridge as j}from"@gjsify/webrtc-native";import M from"gi://GObject?version=2.0";let N=0;var RTCPeerConnection=class extends EventTarget{_pipeline;_webrtcbin;_bridge;_conf;_closed=!1;_iceRestartNeeded=!1;_hasNegotiated=!1;_dataChannels=new Map;_transceivers=new Map;_senders=[];_receivers=[];_iceTransport=null;_dtlsTransport=null;_sctpTransport=null;canTrickleIceCandidates=!0;constructor(n){super(),t();let[r,i]=e.version();if(r<1||r===1&&i<20)throw new O(`@gjsify/webrtc requires GStreamer >= 1.20 (you have ${r}.${i}). webrtcbin is only stable from 1.20 onward.`,`NotSupportedError`);let a=++N;this._pipeline=new e.Pipeline({name:`gjsify-webrtc-pipeline-${a}`});let o=e.ElementFactory.make(`webrtcbin`,`gjsify-webrtcbin-${a}`);if(!o)throw Error(`Failed to create webrtcbin element`);if(this._webrtcbin=o,this._conf={...n},n?.certificates){for(let e of n.certificates)if(e instanceof x&&e.expires<=Date.now())throw new O(`RTCPeerConnection: one of the provided certificates has expired`,`InvalidAccessError`)}this._applyIceServers(n?.iceServers??[]),this._applyIceTransportPolicy(n?.iceTransportPolicy),this._applyBundlePolicy(n?.bundlePolicy),this._pipeline.add(this._webrtcbin),this._bridge=new j({bin:this._webrtcbin}),this._bridge.connect(`negotiation-needed`,()=>this._handleNegotiationNeeded()),this._bridge.connect(`icecandidate`,(e,t,n)=>this._handleIceCandidate(t,n)),this._bridge.connect(`datachannel`,(e,t)=>this._handleDataChannel(t)),this._bridge.connect(`new-transceiver`,(e,t)=>this._handleNewTransceiver(t)),this._bridge.connect(`pad-added`,(e,t)=>this._handlePadAdded(t)),this._bridge.connect(`connection-state-changed`,()=>this._dispatchStateChange(`connectionstatechange`)),this._bridge.connect(`ice-connection-state-changed`,()=>this._dispatchStateChange(`iceconnectionstatechange`)),this._bridge.connect(`ice-gathering-state-changed`,()=>this._dispatchStateChange(`icegatheringstatechange`)),this._bridge.connect(`signaling-state-changed`,()=>this._dispatchStateChange(`signalingstatechange`)),this._pipeline.set_state(e.State.PLAYING)}_applyIceServers(e){let t=!1;for(let n of e){let e=Array.isArray(n.urls)?n.urls:[n.urls];if(e.length===0)throw SyntaxError(`RTCIceServer.urls must not be empty`);for(let r of e){if(typeof r!=`string`||r.length===0)throw TypeError(`RTCIceServer.urls entries must be non-empty strings`);let e=r.indexOf(`:`);if(e<0)throw TypeError(`Invalid ICE server URL "${r}"`);let i=r.slice(0,e+1),a=r.slice(e+1);if(i===`stun:`||i===`stuns:`){if(t)continue;s(this._webrtcbin).stun_server=`${i}//${a}`,t=!0}else if(i===`turn:`||i===`turns:`){if(typeof n.username!=`string`||typeof n.credential!=`string`)throw TypeError(`TURN server credential for ${r} missing`);let e=`${i}//${encodeURIComponent(n.username)}:${encodeURIComponent(n.credential)}@${a}`;try{this._webrtcbin.emit(`add-turn-server`,e)}catch{s(this._webrtcbin).turn_server=e}}else throw TypeError(`Unsupported ICE server protocol "${i}"`)}}}_applyIceTransportPolicy(e){if(!e)return;let t=e===`relay`?A.WebRTCICETransportPolicy.RELAY:A.WebRTCICETransportPolicy.ALL;try{s(this._webrtcbin).ice_transport_policy=t}catch{}}_applyBundlePolicy(e){if(!e)return;let t;switch(e){case`balanced`:t=A.WebRTCBundlePolicy.BALANCED;break;case`max-compat`:t=A.WebRTCBundlePolicy.MAX_COMPAT;break;case`max-bundle`:t=A.WebRTCBundlePolicy.MAX_BUNDLE;break;default:return}try{s(this._webrtcbin).bundle_policy=t}catch{}}get signalingState(){if(this._closed)return`closed`;try{return o(s(this._webrtcbin).signaling_state)}catch{return`stable`}}get connectionState(){if(this._closed)return`closed`;try{return r(s(this._webrtcbin).connection_state)}catch{return`new`}}get iceConnectionState(){if(this._closed)return`closed`;try{return i(s(this._webrtcbin).ice_connection_state)}catch{return`new`}}get iceGatheringState(){try{return a(s(this._webrtcbin).ice_gathering_state)}catch{return`new`}}_descProp(e){try{let t=s(this._webrtcbin)[e];return t?l.fromGstDesc(t):null}catch{return null}}get localDescription(){return this._descProp(`local_description`)}get remoteDescription(){return this._descProp(`remote_description`)}get currentLocalDescription(){return this._descProp(`current_local_description`)}get currentRemoteDescription(){return this._descProp(`current_remote_description`)}get pendingLocalDescription(){return this._descProp(`pending_local_description`)}get pendingRemoteDescription(){return this._descProp(`pending_remote_description`)}get sctp(){return this._sctpTransport}get peerIdentity(){return Promise.reject(TypeError(`peerIdentity assertions are not implemented`))}get idpErrorInfo(){return null}get idpLoginUrl(){return null}_rejectIfClosed(e){if(this._closed)throw new O(`RTCPeerConnection.${e}: connection is closed`,`InvalidStateError`)}_setStructureField(e,t,n,r){if(r==null)return;let i=new M.Value;n===`boolean`?(i.init(M.TYPE_BOOLEAN),i.set_boolean(!!r)):n===`int`?(i.init(M.TYPE_INT),i.set_int(Number(r))):n===`string`&&(i.init(M.TYPE_STRING),i.set_string(String(r))),e.set_value(t,i),i.unset()}close(){this._closed||(this._closed=!0,k.idle_add(k.PRIORITY_DEFAULT,()=>{try{this._pipeline.set_state(e.State.NULL)}catch{}for(let e of this._dataChannels.values())try{e._disconnectSignals()}catch{}this._dataChannels.clear();for(let e of this._senders)try{e._teardownPipeline()}catch{}for(let e of this._receivers)try{e._dispose()}catch{}this._transceivers.clear(),this._senders.length=0,this._receivers.length=0,this._dtlsTransport&&this._dtlsTransport._setState(`closed`),this._iceTransport&&this._iceTransport._setState(`closed`),this._sctpTransport&&this._sctpTransport._setState(`closed`);try{this._bridge.dispose_bridge()}catch{}return k.SOURCE_REMOVE}))}getIdentityAssertion(){return Promise.reject(Error(`getIdentityAssertion is not implemented`))}_findNewGstTransceiver(){for(let e=0;;e++){let t=this._webrtcbin.emit(`get-transceiver`,e);if(!t)return null;if(!this._transceivers.has(t))return t}}_ensureTransports(){return this._dtlsTransport||=(this._iceTransport=new v,new y(this._iceTransport)),this._dtlsTransport}_ensureSctpTransport(){if(this._sctpTransport)return;let e=this._ensureTransports();this._sctpTransport=new b(e)}_assignTransports(){let e=this._ensureTransports();for(let t of this._senders)t._transport=e;for(let t of this._receivers)t._transport=e}_clearTransports(){for(let e of this._senders)e._transport=null;for(let e of this._receivers)e._transport=null}_createTransceiverWrapper(e){let t=`audio`;try{e.kind===A.WebRTCKind.VIDEO&&(t=`video`)}catch{}let n=e.receiver??null,r=e.sender??null,i=new h(t,n,this._pipeline),a=new m(r,this._pipeline,this._webrtcbin);a._kind=t,a._onPipelineChanged=e=>{this._pipeline=e};let statsDelegate=e=>this.getStats(e);if(a._getStatsForTrack=statsDelegate,i._getStatsForTrack=statsDelegate,this.localDescription){let e=this._ensureTransports();a._transport=e,i._transport=e}try{let t=e.mlineindex;typeof t==`number`&&t>=0&&a._setMlineIndex(t)}catch{}let o=new g(e,a,i);return a._transceiver=o,this._transceivers.set(e,o),this._senders.push(a),this._receivers.push(i),o}_handleNegotiationNeeded(){if(this._closed)return;let e=new Event(`negotiationneeded`);this._onnegotiationneeded?.call(this,e),this.dispatchEvent(e)}_negotiationNeededQueued=!1;_updateNegotiationNeeded(){this._closed||this._hasNegotiated&&this.signalingState===`stable`&&(this._negotiationNeededQueued||(this._negotiationNeededQueued=!0,Promise.resolve().then(()=>{this._negotiationNeededQueued=!1,this.signalingState===`stable`&&this._handleNegotiationNeeded()})))}_handleIceCandidate(e,t){let n=new f(`icecandidate`,{candidate:new u({candidate:t,sdpMLineIndex:e})});this._onicecandidate?.call(this,n),this.dispatchEvent(n)}_handleNewTransceiver(e){this._closed||this._transceivers.has(e)||this._createTransceiverWrapper(e)}_handlePadAdded(t){if(this._closed||t.direction!==e.PadDirection.SRC)return;let r=c(t).transceiver;if(!r)return;let i=this._transceivers.get(r);i||=this._createTransceiverWrapper(r),i.receiver._connectToPad(t);let a=new n([i.receiver.track]),o=new _(`track`,{receiver:i.receiver,track:i.receiver.track,streams:[a],transceiver:i});this._ontrack?.call(this,o),this.dispatchEvent(o)}_handleDataChannel(e){this._ensureSctpTransport();let t=e.channel,n=this._dataChannels.get(t);n||(n=new p(e,this._sctpTransport??void 0),this._dataChannels.set(t,n),n.addEventListener(`close`,()=>{this._dataChannels.delete(t)}));let r=new d(`datachannel`,{channel:n});this._ondatachannel?.call(this,r),this.dispatchEvent(r)}_dispatchStateChange(e){e===`connectionstatechange`?this._syncDtlsState():e===`iceconnectionstatechange`?this._syncIceState():e===`icegatheringstatechange`&&this._syncIceGatheringState();let t=new Event(e);switch(e){case`connectionstatechange`:this._onconnectionstatechange?.call(this,t);break;case`iceconnectionstatechange`:this._oniceconnectionstatechange?.call(this,t);break;case`icegatheringstatechange`:this._onicegatheringstatechange?.call(this,t);break;case`signalingstatechange`:this._onsignalingstatechange?.call(this,t);break}this.dispatchEvent(t)}_syncDtlsState(){if(!this._dtlsTransport)return;let e=this.connectionState;this._dtlsTransport._setState({new:`new`,connecting:`connecting`,connected:`connected`,disconnected:`connected`,failed:`failed`,closed:`closed`}[e]??`new`),e===`connected`&&this._sctpTransport&&this._sctpTransport._setState(`connected`)}_syncIceState(){if(!this._iceTransport)return;let e=this.iceConnectionState;this._iceTransport._setState(e)}_syncIceGatheringState(){if(!this._iceTransport)return;let e=this.iceGatheringState;this._iceTransport._setGatheringState(e)}_onconnectionstatechange=null;_ondatachannel=null;_onicecandidate=null;_oniceconnectionstatechange=null;_onicegatheringstatechange=null;_onnegotiationneeded=null;_onsignalingstatechange=null;get onconnectionstatechange(){return this._onconnectionstatechange}set onconnectionstatechange(e){this._onconnectionstatechange=e}get ondatachannel(){return this._ondatachannel}set ondatachannel(e){this._ondatachannel=e}get onicecandidate(){return this._onicecandidate}set onicecandidate(e){this._onicecandidate=e}get oniceconnectionstatechange(){return this._oniceconnectionstatechange}set oniceconnectionstatechange(e){this._oniceconnectionstatechange=e}get onicegatheringstatechange(){return this._onicegatheringstatechange}set onicegatheringstatechange(e){this._onicegatheringstatechange=e}get onnegotiationneeded(){return this._onnegotiationneeded}set onnegotiationneeded(e){this._onnegotiationneeded=e}get onsignalingstatechange(){return this._onsignalingstatechange}set onsignalingstatechange(e){this._onsignalingstatechange=e}_ontrack=null;get ontrack(){return this._ontrack}set ontrack(e){this._ontrack=e}get onicecandidateerror(){return null}set onicecandidateerror(e){}static generateCertificate(e){return S(e)}};C(RTCPeerConnection.prototype),w(RTCPeerConnection.prototype),T(RTCPeerConnection.prototype),E(RTCPeerConnection.prototype),D(RTCPeerConnection.prototype);export{RTCPeerConnection};
1
+ import"./_virtual/_rolldown/runtime.js";import{Gst as e,ensureWebrtcbinAvailable as t}from"./gst-init.js";import{MediaStream as n}from"./media-stream.js";import{gstToConnectionState as r,gstToIceConnectionState as i,gstToIceGatheringState as a,gstToSignalingState as o}from"./gst-enum-maps.js";import{asWebRtcBin as s,asWebRtcSrcPad as c,emitWebRtcBin as l}from"./internal/gst-types.js";import{RTCSessionDescription as u}from"./rtc-session-description.js";import{RTCIceCandidate as d}from"./rtc-ice-candidate.js";import{RTCDataChannelEvent as f,RTCPeerConnectionIceEvent as p}from"./rtc-events.js";import{RTCDataChannel as m}from"./rtc-data-channel.js";import{RTCRtpSender as h}from"./rtc-rtp-sender.js";import{RTCRtpReceiver as g}from"./rtc-rtp-receiver.js";import{RTCRtpTransceiver as _}from"./rtc-rtp-transceiver.js";import{RTCTrackEvent as v}from"./rtc-track-event.js";import{RTCIceTransport as y}from"./rtc-ice-transport.js";import{RTCDtlsTransport as b}from"./rtc-dtls-transport.js";import{RTCSctpTransport as x}from"./rtc-sctp-transport.js";import{RTCCertificate as S,generateCertificate as C}from"./rtc-certificate.js";import{installSdpNegotiationMethods as w}from"./rtc-peer-connection/sdp-negotiation.js";import{installDataChannelMethods as T}from"./rtc-peer-connection/data-channel.js";import{installTransceiverMethods as E}from"./rtc-peer-connection/transceivers.js";import{installTrackMethods as D}from"./rtc-peer-connection/tracks.js";import{installStatsAndConfigMethods as O}from"./rtc-peer-connection/stats-and-config.js";import{DOMException as k}from"@gjsify/dom-exception";import A from"gi://GLib?version=2.0";import j from"gi://GstWebRTC?version=1.0";import{WebrtcbinBridge as M}from"@gjsify/webrtc-native";import N from"gi://GObject?version=2.0";let P=0;var RTCPeerConnection=class extends EventTarget{_pipeline;_webrtcbin;_bridge;_conf;_closed=!1;_iceRestartNeeded=!1;_hasNegotiated=!1;_dataChannels=new Map;_transceivers=new Map;_senders=[];_receivers=[];_iceTransport=null;_dtlsTransport=null;_sctpTransport=null;canTrickleIceCandidates=!0;constructor(n){super(),t();let[r,i]=e.version();if(r<1||r===1&&i<20)throw new k(`@gjsify/webrtc requires GStreamer >= 1.20 (you have ${r}.${i}). webrtcbin is only stable from 1.20 onward.`,`NotSupportedError`);let a=++P;this._pipeline=new e.Pipeline({name:`gjsify-webrtc-pipeline-${a}`});let o=e.ElementFactory.make(`webrtcbin`,`gjsify-webrtcbin-${a}`);if(!o)throw Error(`Failed to create webrtcbin element`);if(this._webrtcbin=o,this._conf={...n},n?.certificates){for(let e of n.certificates)if(e instanceof S&&e.expires<=Date.now())throw new k(`RTCPeerConnection: one of the provided certificates has expired`,`InvalidAccessError`)}this._applyIceServers(n?.iceServers??[]),this._applyIceTransportPolicy(n?.iceTransportPolicy),this._applyBundlePolicy(n?.bundlePolicy),this._pipeline.add(this._webrtcbin),this._bridge=new M({bin:this._webrtcbin}),this._bridge.connect(`negotiation-needed`,()=>this._handleNegotiationNeeded()),this._bridge.connect(`icecandidate`,(e,t,n)=>this._handleIceCandidate(t,n)),this._bridge.connect(`datachannel`,(e,t)=>this._handleDataChannel(t)),this._bridge.connect(`new-transceiver`,(e,t)=>this._handleNewTransceiver(t)),this._bridge.connect(`pad-added`,(e,t)=>this._handlePadAdded(t)),this._bridge.connect(`connection-state-changed`,()=>this._dispatchStateChange(`connectionstatechange`)),this._bridge.connect(`ice-connection-state-changed`,()=>this._dispatchStateChange(`iceconnectionstatechange`)),this._bridge.connect(`ice-gathering-state-changed`,()=>this._dispatchStateChange(`icegatheringstatechange`)),this._bridge.connect(`signaling-state-changed`,()=>this._dispatchStateChange(`signalingstatechange`)),this._pipeline.set_state(e.State.PLAYING)}_applyIceServers(e){let t=!1;for(let n of e){let e=Array.isArray(n.urls)?n.urls:[n.urls];if(e.length===0)throw SyntaxError(`RTCIceServer.urls must not be empty`);for(let r of e){if(typeof r!=`string`||r.length===0)throw TypeError(`RTCIceServer.urls entries must be non-empty strings`);let e=r.indexOf(`:`);if(e<0)throw TypeError(`Invalid ICE server URL "${r}"`);let i=r.slice(0,e+1),a=r.slice(e+1);if(i===`stun:`||i===`stuns:`){if(t)continue;s(this._webrtcbin).stun_server=`${i}//${a}`,t=!0}else if(i===`turn:`||i===`turns:`){if(typeof n.username!=`string`||typeof n.credential!=`string`)throw TypeError(`TURN server credential for ${r} missing`);let e=`${i}//${encodeURIComponent(n.username)}:${encodeURIComponent(n.credential)}@${a}`;try{l(this._webrtcbin,`add-turn-server`,e)}catch{s(this._webrtcbin).turn_server=e}}else throw TypeError(`Unsupported ICE server protocol "${i}"`)}}}_applyIceTransportPolicy(e){if(!e)return;let t=e===`relay`?j.WebRTCICETransportPolicy.RELAY:j.WebRTCICETransportPolicy.ALL;try{s(this._webrtcbin).ice_transport_policy=t}catch{}}_applyBundlePolicy(e){if(!e)return;let t;switch(e){case`balanced`:t=j.WebRTCBundlePolicy.BALANCED;break;case`max-compat`:t=j.WebRTCBundlePolicy.MAX_COMPAT;break;case`max-bundle`:t=j.WebRTCBundlePolicy.MAX_BUNDLE;break;default:return}try{s(this._webrtcbin).bundle_policy=t}catch{}}get signalingState(){if(this._closed)return`closed`;try{return o(s(this._webrtcbin).signaling_state)}catch{return`stable`}}get connectionState(){if(this._closed)return`closed`;try{return r(s(this._webrtcbin).connection_state)}catch{return`new`}}get iceConnectionState(){if(this._closed)return`closed`;try{return i(s(this._webrtcbin).ice_connection_state)}catch{return`new`}}get iceGatheringState(){try{return a(s(this._webrtcbin).ice_gathering_state)}catch{return`new`}}_descProp(e){try{let t=s(this._webrtcbin)[e];return t?u.fromGstDesc(t):null}catch{return null}}get localDescription(){return this._descProp(`local_description`)}get remoteDescription(){return this._descProp(`remote_description`)}get currentLocalDescription(){return this._descProp(`current_local_description`)}get currentRemoteDescription(){return this._descProp(`current_remote_description`)}get pendingLocalDescription(){return this._descProp(`pending_local_description`)}get pendingRemoteDescription(){return this._descProp(`pending_remote_description`)}get sctp(){return this._sctpTransport}get peerIdentity(){return Promise.reject(TypeError(`peerIdentity assertions are not implemented`))}get idpErrorInfo(){return null}get idpLoginUrl(){return null}_rejectIfClosed(e){if(this._closed)throw new k(`RTCPeerConnection.${e}: connection is closed`,`InvalidStateError`)}_setStructureField(e,t,n,r){if(r==null)return;let i=new N.Value;n===`boolean`?(i.init(N.TYPE_BOOLEAN),i.set_boolean(!!r)):n===`int`?(i.init(N.TYPE_INT),i.set_int(Number(r))):n===`string`&&(i.init(N.TYPE_STRING),i.set_string(String(r))),e.set_value(t,i),i.unset()}close(){this._closed||(this._closed=!0,A.idle_add(A.PRIORITY_DEFAULT,()=>{try{this._pipeline.set_state(e.State.NULL)}catch{}for(let e of this._dataChannels.values())try{e._disconnectSignals()}catch{}this._dataChannels.clear();for(let e of this._senders)try{e._teardownPipeline()}catch{}for(let e of this._receivers)try{e._dispose()}catch{}this._transceivers.clear(),this._senders.length=0,this._receivers.length=0,this._dtlsTransport&&this._dtlsTransport._setState(`closed`),this._iceTransport&&this._iceTransport._setState(`closed`),this._sctpTransport&&this._sctpTransport._setState(`closed`);try{this._bridge.dispose_bridge()}catch{}return A.SOURCE_REMOVE}))}getIdentityAssertion(){return Promise.reject(Error(`getIdentityAssertion is not implemented`))}_findNewGstTransceiver(){for(let e=0;;e++){let t=l(this._webrtcbin,`get-transceiver`,e);if(!t)return null;if(!this._transceivers.has(t))return t}}_ensureTransports(){return this._dtlsTransport||=(this._iceTransport=new y,new b(this._iceTransport)),this._dtlsTransport}_ensureSctpTransport(){if(this._sctpTransport)return;let e=this._ensureTransports();this._sctpTransport=new x(e)}_assignTransports(){let e=this._ensureTransports();for(let t of this._senders)t._transport=e;for(let t of this._receivers)t._transport=e}_clearTransports(){for(let e of this._senders)e._transport=null;for(let e of this._receivers)e._transport=null}_createTransceiverWrapper(e){let t=`audio`;try{e.kind===j.WebRTCKind.VIDEO&&(t=`video`)}catch{}let n=e.receiver??null,r=e.sender??null,i=new g(t,n,this._pipeline),a=new h(r,this._pipeline,this._webrtcbin);a._kind=t,a._onPipelineChanged=e=>{this._pipeline=e};let statsDelegate=e=>this.getStats(e);if(a._getStatsForTrack=statsDelegate,i._getStatsForTrack=statsDelegate,this.localDescription){let e=this._ensureTransports();a._transport=e,i._transport=e}try{let t=e.mlineindex;typeof t==`number`&&t>=0&&a._setMlineIndex(t)}catch{}let o=new _(e,a,i);return a._transceiver=o,this._transceivers.set(e,o),this._senders.push(a),this._receivers.push(i),o}_handleNegotiationNeeded(){if(this._closed)return;let e=new Event(`negotiationneeded`);this._onnegotiationneeded?.call(this,e),this.dispatchEvent(e)}_negotiationNeededQueued=!1;_updateNegotiationNeeded(){this._closed||this._hasNegotiated&&this.signalingState===`stable`&&(this._negotiationNeededQueued||(this._negotiationNeededQueued=!0,Promise.resolve().then(()=>{this._negotiationNeededQueued=!1,this.signalingState===`stable`&&this._handleNegotiationNeeded()})))}_handleIceCandidate(e,t){let n=new p(`icecandidate`,{candidate:new d({candidate:t,sdpMLineIndex:e})});this._onicecandidate?.call(this,n),this.dispatchEvent(n)}_handleNewTransceiver(e){this._closed||this._transceivers.has(e)||this._createTransceiverWrapper(e)}_handlePadAdded(t){if(this._closed||t.direction!==e.PadDirection.SRC)return;let r=c(t).transceiver;if(!r)return;let i=this._transceivers.get(r);i||=this._createTransceiverWrapper(r),i.receiver._connectToPad(t);let a=new n([i.receiver.track]),o=new v(`track`,{receiver:i.receiver,track:i.receiver.track,streams:[a],transceiver:i});this._ontrack?.call(this,o),this.dispatchEvent(o)}_handleDataChannel(e){this._ensureSctpTransport();let t=e.channel,n=this._dataChannels.get(t);n||(n=new m(e,this._sctpTransport??void 0),this._dataChannels.set(t,n),n.addEventListener(`close`,()=>{this._dataChannels.delete(t)}));let r=new f(`datachannel`,{channel:n});this._ondatachannel?.call(this,r),this.dispatchEvent(r)}_dispatchStateChange(e){e===`connectionstatechange`?this._syncDtlsState():e===`iceconnectionstatechange`?this._syncIceState():e===`icegatheringstatechange`&&this._syncIceGatheringState();let t=new Event(e);switch(e){case`connectionstatechange`:this._onconnectionstatechange?.call(this,t);break;case`iceconnectionstatechange`:this._oniceconnectionstatechange?.call(this,t);break;case`icegatheringstatechange`:this._onicegatheringstatechange?.call(this,t);break;case`signalingstatechange`:this._onsignalingstatechange?.call(this,t);break}this.dispatchEvent(t)}_syncDtlsState(){if(!this._dtlsTransport)return;let e=this.connectionState;this._dtlsTransport._setState({new:`new`,connecting:`connecting`,connected:`connected`,disconnected:`connected`,failed:`failed`,closed:`closed`}[e]??`new`),e===`connected`&&this._sctpTransport&&this._sctpTransport._setState(`connected`)}_syncIceState(){if(!this._iceTransport)return;let e=this.iceConnectionState;this._iceTransport._setState(e)}_syncIceGatheringState(){if(!this._iceTransport)return;let e=this.iceGatheringState;this._iceTransport._setGatheringState(e)}_onconnectionstatechange=null;_ondatachannel=null;_onicecandidate=null;_oniceconnectionstatechange=null;_onicegatheringstatechange=null;_onnegotiationneeded=null;_onsignalingstatechange=null;get onconnectionstatechange(){return this._onconnectionstatechange}set onconnectionstatechange(e){this._onconnectionstatechange=e}get ondatachannel(){return this._ondatachannel}set ondatachannel(e){this._ondatachannel=e}get onicecandidate(){return this._onicecandidate}set onicecandidate(e){this._onicecandidate=e}get oniceconnectionstatechange(){return this._oniceconnectionstatechange}set oniceconnectionstatechange(e){this._oniceconnectionstatechange=e}get onicegatheringstatechange(){return this._onicegatheringstatechange}set onicegatheringstatechange(e){this._onicegatheringstatechange=e}get onnegotiationneeded(){return this._onnegotiationneeded}set onnegotiationneeded(e){this._onnegotiationneeded=e}get onsignalingstatechange(){return this._onsignalingstatechange}set onsignalingstatechange(e){this._onsignalingstatechange=e}_ontrack=null;get ontrack(){return this._ontrack}set ontrack(e){this._ontrack=e}get onicecandidateerror(){return null}set onicecandidateerror(e){}static generateCertificate(e){return C(e)}};w(RTCPeerConnection.prototype),T(RTCPeerConnection.prototype),E(RTCPeerConnection.prototype),D(RTCPeerConnection.prototype),O(RTCPeerConnection.prototype);export{RTCPeerConnection};
@@ -33,6 +33,51 @@ export interface WebRtcBin extends Gst.Element {
33
33
  * properties (they are class-installed by GstWebRTCBin).
34
34
  */
35
35
  export declare const asWebRtcBin: (el: Gst.Element) => WebRtcBin;
36
+ /**
37
+ * `webrtcbin`'s ACTION signals — the half `WebRtcBin` above was missing, and the
38
+ * half every API call in this package goes through.
39
+ *
40
+ * READ FROM THE ELEMENT, not from the documentation: `GObject.signal_query` over
41
+ * `GstWebRTCBin`'s registered ids, GStreamer 1.28.6, 2026-09-11. That is the only
42
+ * source that can be right, because these signals exist nowhere a type generator
43
+ * can see them — `@girs/gst-1.0` types every element as the base `Gst.Element`,
44
+ * and webrtcbin installs its own at element-class init.
45
+ *
46
+ * `emit` COULD NOT hold this. An interface extending `Gst.Element` may not
47
+ * redeclare `emit` over a different key union (measured: TS2430, 'incorrectly
48
+ * extends'), so the names live here and the call goes through the lower-level
49
+ * entry point instead.
50
+ *
51
+ * The `| null` on three returns is NOT from the query — a GObject return type
52
+ * carries no nullability — it is measured on a fresh bin: `get-transceiver 0` and
53
+ * `create-data-channel` both answer `null` there, which is also what
54
+ * `_findNewGstTransceiver` walks indices against and what both creating calls
55
+ * refuse before using.
56
+ */
57
+ export interface WebRtcBinSignals {
58
+ 'add-ice-candidate': (mlineIndex: number, candidate: string | null) => void;
59
+ 'add-transceiver': (direction: GstWebRTC.WebRTCRTPTransceiverDirection, caps: Gst.Caps) => GstWebRTC.WebRTCRTPTransceiver | null;
60
+ 'add-turn-server': (uri: string) => boolean;
61
+ 'create-answer': (options: Gst.Structure | null, promise: Gst.Promise) => void;
62
+ 'create-data-channel': (label: string, options: Gst.Structure | null) => GstWebRTC.WebRTCDataChannel | null;
63
+ 'create-offer': (options: Gst.Structure | null, promise: Gst.Promise) => void;
64
+ 'get-stats': (pad: Gst.Pad | null, promise: Gst.Promise) => void;
65
+ 'get-transceiver': (index: number) => GstWebRTC.WebRTCRTPTransceiver | null;
66
+ 'set-local-description': (description: GstWebRTC.WebRTCSessionDescription, promise: Gst.Promise | null) => void;
67
+ 'set-remote-description': (description: GstWebRTC.WebRTCSessionDescription, promise: Gst.Promise | null) => void;
68
+ }
69
+ /**
70
+ * Emit one of webrtcbin's action signals, with its name and its arguments checked.
71
+ *
72
+ * `el.emit(name, …)` used to take any string and check nothing; `@girs` 5.0.0 ended
73
+ * that by typing `emit` on the object's OWN signal names, which for a
74
+ * `Gst.ElementFactory.make('webrtcbin')` result are `Gst.Element`'s and not
75
+ * webrtcbin's. `GObject.signal_emit_by_name` is the lower-level entry point
76
+ * ts-for-gir names for a signal a static type cannot know, and it is the same
77
+ * emission — A/B'd on a live webrtcbin under gjs 1.86, the two answer identically
78
+ * for a boolean (`add-turn-server`), for an object and for a null.
79
+ */
80
+ export declare const emitWebRtcBin: <K extends keyof WebRtcBinSignals>(el: Gst.Element, signal: K, ...args: Parameters<WebRtcBinSignals[K]>) => ReturnType<WebRtcBinSignals[K]>;
36
81
  /**
37
82
  * GStreamer pad augmented with the `transceiver` field that webrtcbin's
38
83
  * SRC pads carry. The base `Gst.Pad` typing has no concept of this — it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/webrtc",
3
- "version": "0.49.0",
3
+ "version": "0.51.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,21 +61,21 @@
61
61
  "peer-connection"
62
62
  ],
63
63
  "dependencies": {
64
- "@gjsify/buffer": "^0.49.0",
65
- "@gjsify/dom-events": "^0.49.0",
66
- "@gjsify/dom-exception": "^0.49.0",
67
- "@gjsify/webcrypto": "^0.49.0",
68
- "@gjsify/webrtc-native": "^0.49.0"
64
+ "@gjsify/buffer": "^0.51.0",
65
+ "@gjsify/dom-events": "^0.51.0",
66
+ "@gjsify/dom-exception": "^0.51.0",
67
+ "@gjsify/webcrypto": "^0.51.0",
68
+ "@gjsify/webrtc-native": "^0.51.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@girs/gjs": "4.6.0",
72
- "@girs/glib-2.0": "4.6.0",
73
- "@girs/gobject-2.0": "4.6.0",
74
- "@girs/gst-1.0": "4.6.0",
75
- "@girs/gstsdp-1.0": "4.6.0",
76
- "@girs/gstwebrtc-1.0": "4.6.0",
77
- "@gjsify/cli": "^0.49.0",
78
- "@gjsify/unit": "^0.49.0",
71
+ "@girs/gjs": "5.0.0",
72
+ "@girs/glib-2.0": "5.0.0",
73
+ "@girs/gobject-2.0": "5.0.0",
74
+ "@girs/gst-1.0": "5.0.0",
75
+ "@girs/gstsdp-1.0": "5.0.0",
76
+ "@girs/gstwebrtc-1.0": "5.0.0",
77
+ "@gjsify/cli": "^0.51.0",
78
+ "@gjsify/unit": "^0.51.0",
79
79
  "@types/node": "^25.9.2",
80
80
  "typescript": "^6.0.3"
81
81
  },