@gjsify/webrtc 0.3.21 → 0.4.3
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.
- package/lib/esm/_virtual/_rolldown/runtime.js +1 -0
- package/lib/esm/get-user-media.js +1 -1
- package/lib/esm/gst-enum-maps.js +1 -1
- package/lib/esm/gst-init.js +1 -1
- package/lib/esm/gst-stats-parser.js +1 -1
- package/lib/esm/gst-utils.js +1 -1
- package/lib/esm/internal/gst-types.js +1 -0
- package/lib/esm/media-device-info.js +1 -1
- package/lib/esm/media-devices.js +1 -1
- package/lib/esm/media-stream-track.js +1 -1
- package/lib/esm/media-stream.js +1 -1
- package/lib/esm/rtc-certificate.js +1 -1
- package/lib/esm/rtc-data-channel.js +1 -1
- package/lib/esm/rtc-dtls-transport.js +1 -1
- package/lib/esm/rtc-dtmf-sender.js +1 -1
- package/lib/esm/rtc-error.js +1 -1
- package/lib/esm/rtc-events.js +1 -1
- package/lib/esm/rtc-ice-candidate.js +1 -1
- package/lib/esm/rtc-ice-transport.js +1 -1
- package/lib/esm/rtc-peer-connection.js +1 -1
- package/lib/esm/rtc-rtp-receiver.js +1 -1
- package/lib/esm/rtc-rtp-sender.js +1 -1
- package/lib/esm/rtc-rtp-transceiver.js +1 -1
- package/lib/esm/rtc-sctp-transport.js +1 -1
- package/lib/esm/rtc-session-description.js +1 -1
- package/lib/esm/rtc-stats-report.js +1 -1
- package/lib/esm/rtc-track-event.js +1 -1
- package/lib/esm/rtp-capabilities.js +1 -1
- package/lib/esm/tee-multiplexer.js +1 -1
- package/lib/esm/wpt-helpers.js +1 -1
- package/lib/types/gst-enum-maps.d.ts +2 -1
- package/lib/types/internal/gst-types.d.ts +83 -0
- package/lib/types/rtc-rtp-sender.d.ts +3 -2
- package/package.json +73 -70
- package/src/get-user-media.ts +0 -131
- package/src/gst-enum-maps.ts +0 -125
- package/src/gst-init.ts +0 -49
- package/src/gst-stats-parser.ts +0 -137
- package/src/gst-utils.ts +0 -41
- package/src/index.ts +0 -104
- package/src/media-device-info.ts +0 -33
- package/src/media-devices.ts +0 -191
- package/src/media-stream-track.ts +0 -159
- package/src/media-stream.ts +0 -96
- package/src/register/data-channel.ts +0 -11
- package/src/register/error.ts +0 -11
- package/src/register/media-devices.ts +0 -10
- package/src/register/media.ts +0 -15
- package/src/register/peer-connection.ts +0 -20
- package/src/register.spec.ts +0 -55
- package/src/register.ts +0 -10
- package/src/rtc-certificate.ts +0 -110
- package/src/rtc-data-channel.ts +0 -283
- package/src/rtc-dtls-transport.ts +0 -48
- package/src/rtc-dtmf-sender.ts +0 -146
- package/src/rtc-error.ts +0 -49
- package/src/rtc-events.ts +0 -64
- package/src/rtc-ice-candidate.ts +0 -115
- package/src/rtc-ice-transport.ts +0 -104
- package/src/rtc-peer-connection.ts +0 -1023
- package/src/rtc-rtp-receiver.ts +0 -122
- package/src/rtc-rtp-sender.ts +0 -444
- package/src/rtc-rtp-transceiver.ts +0 -127
- package/src/rtc-sctp-transport.ts +0 -48
- package/src/rtc-session-description.ts +0 -64
- package/src/rtc-stats-report.ts +0 -39
- package/src/rtc-track-event.ts +0 -45
- package/src/rtp-capabilities.ts +0 -48
- package/src/tee-multiplexer.ts +0 -75
- package/src/test.mts +0 -11
- package/src/webrtc.spec.ts +0 -1186
- package/src/wpt-helpers.ts +0 -156
- package/src/wpt-media.spec.ts +0 -1154
- package/src/wpt.spec.ts +0 -1136
- package/tsconfig.json +0 -36
- package/tsconfig.tsbuildinfo +0 -1
package/src/rtc-error.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// RTCError extends DOMException per W3C WebRTC spec §7.
|
|
2
|
-
//
|
|
3
|
-
// Reference: refs/node-datachannel/src/polyfill/RTCError.ts (MIT) +
|
|
4
|
-
// https://www.w3.org/TR/webrtc/#rtcerror-interface
|
|
5
|
-
//
|
|
6
|
-
// CLAUDE.md Rule 8 exception: the class below extends `DOMException`
|
|
7
|
-
// (a global). Seed the global before the class body is evaluated.
|
|
8
|
-
|
|
9
|
-
import '@gjsify/dom-exception/register';
|
|
10
|
-
|
|
11
|
-
export type RTCErrorDetailType =
|
|
12
|
-
| 'data-channel-failure'
|
|
13
|
-
| 'dtls-failure'
|
|
14
|
-
| 'fingerprint-failure'
|
|
15
|
-
| 'sctp-failure'
|
|
16
|
-
| 'sdp-syntax-error'
|
|
17
|
-
| 'hardware-encoder-not-available'
|
|
18
|
-
| 'hardware-encoder-error';
|
|
19
|
-
|
|
20
|
-
export interface RTCErrorInit {
|
|
21
|
-
errorDetail: RTCErrorDetailType;
|
|
22
|
-
sdpLineNumber?: number | null;
|
|
23
|
-
sctpCauseCode?: number | null;
|
|
24
|
-
receivedAlert?: number | null;
|
|
25
|
-
sentAlert?: number | null;
|
|
26
|
-
httpRequestStatusCode?: number | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class RTCError extends DOMException {
|
|
30
|
-
readonly errorDetail: RTCErrorDetailType;
|
|
31
|
-
readonly sdpLineNumber: number | null;
|
|
32
|
-
readonly sctpCauseCode: number | null;
|
|
33
|
-
readonly receivedAlert: number | null;
|
|
34
|
-
readonly sentAlert: number | null;
|
|
35
|
-
readonly httpRequestStatusCode: number | null;
|
|
36
|
-
|
|
37
|
-
constructor(init: RTCErrorInit, message?: string) {
|
|
38
|
-
super(message ?? init.errorDetail, 'OperationError');
|
|
39
|
-
if (!init || !init.errorDetail) {
|
|
40
|
-
throw new TypeError('RTCError: errorDetail is required');
|
|
41
|
-
}
|
|
42
|
-
this.errorDetail = init.errorDetail;
|
|
43
|
-
this.sdpLineNumber = init.sdpLineNumber ?? null;
|
|
44
|
-
this.sctpCauseCode = init.sctpCauseCode ?? null;
|
|
45
|
-
this.receivedAlert = init.receivedAlert ?? null;
|
|
46
|
-
this.sentAlert = init.sentAlert ?? null;
|
|
47
|
-
this.httpRequestStatusCode = init.httpRequestStatusCode ?? null;
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/rtc-events.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// W3C WebRTC event classes.
|
|
2
|
-
//
|
|
3
|
-
// Reference: refs/node-gst-webrtc/src/webrtc/events.ts (ISC) +
|
|
4
|
-
// https://www.w3.org/TR/webrtc/#rtcpeerconnectioniceevent-interface
|
|
5
|
-
// https://www.w3.org/TR/webrtc/#rtcdatachannelevent-interface
|
|
6
|
-
// https://www.w3.org/TR/webrtc/#rtcerrorevent-interface
|
|
7
|
-
//
|
|
8
|
-
// CLAUDE.md Rule 8 exception: the class declarations below extend the
|
|
9
|
-
// global `Event` constructor, which runs at module load. Seed the global
|
|
10
|
-
// before the class bodies are evaluated.
|
|
11
|
-
|
|
12
|
-
import '@gjsify/dom-events/register/event-target';
|
|
13
|
-
|
|
14
|
-
import type { RTCIceCandidate } from './rtc-ice-candidate.js';
|
|
15
|
-
import type { RTCDataChannel } from './rtc-data-channel.js';
|
|
16
|
-
import type { RTCError } from './rtc-error.js';
|
|
17
|
-
|
|
18
|
-
export interface RTCPeerConnectionIceEventInit extends EventInit {
|
|
19
|
-
candidate?: RTCIceCandidate | null;
|
|
20
|
-
url?: string | null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class RTCPeerConnectionIceEvent extends Event {
|
|
24
|
-
readonly candidate: RTCIceCandidate | null;
|
|
25
|
-
readonly url: string | null;
|
|
26
|
-
|
|
27
|
-
constructor(type: string, init: RTCPeerConnectionIceEventInit = {}) {
|
|
28
|
-
super(type, init);
|
|
29
|
-
this.candidate = init.candidate ?? null;
|
|
30
|
-
this.url = init.url ?? null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface RTCDataChannelEventInit extends EventInit {
|
|
35
|
-
channel: RTCDataChannel;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class RTCDataChannelEvent extends Event {
|
|
39
|
-
readonly channel: RTCDataChannel;
|
|
40
|
-
|
|
41
|
-
constructor(type: string, init: RTCDataChannelEventInit) {
|
|
42
|
-
super(type, init);
|
|
43
|
-
if (!init || !init.channel) {
|
|
44
|
-
throw new TypeError('RTCDataChannelEvent requires a `channel` member');
|
|
45
|
-
}
|
|
46
|
-
this.channel = init.channel;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface RTCErrorEventInit extends EventInit {
|
|
51
|
-
error: RTCError;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class RTCErrorEvent extends Event {
|
|
55
|
-
readonly error: RTCError;
|
|
56
|
-
|
|
57
|
-
constructor(type: string, init: RTCErrorEventInit) {
|
|
58
|
-
super(type, init);
|
|
59
|
-
if (!init || !init.error) {
|
|
60
|
-
throw new TypeError('RTCErrorEvent requires an `error` member');
|
|
61
|
-
}
|
|
62
|
-
this.error = init.error;
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/rtc-ice-candidate.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// RTCIceCandidate — W3C WebRTC ICE candidate descriptor.
|
|
2
|
-
//
|
|
3
|
-
// Reference: refs/node-gst-webrtc/src/webrtc/RTCIceCandidate.ts (ISC)
|
|
4
|
-
//
|
|
5
|
-
// Field extraction (type/protocol/port/...) uses a minimal SDP candidate-line
|
|
6
|
-
// parser per RFC 5245 §15.1.
|
|
7
|
-
|
|
8
|
-
export interface RTCIceCandidateInit {
|
|
9
|
-
candidate?: string;
|
|
10
|
-
sdpMid?: string | null;
|
|
11
|
-
sdpMLineIndex?: number | null;
|
|
12
|
-
usernameFragment?: string | null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type RTCIceComponent = 'rtp' | 'rtcp';
|
|
16
|
-
export type RTCIceProtocol = 'udp' | 'tcp';
|
|
17
|
-
export type RTCIceCandidateType = 'host' | 'srflx' | 'prflx' | 'relay';
|
|
18
|
-
export type RTCIceTcpCandidateType = 'active' | 'passive' | 'so';
|
|
19
|
-
|
|
20
|
-
interface ParsedCandidate {
|
|
21
|
-
foundation: string;
|
|
22
|
-
component: RTCIceComponent | null;
|
|
23
|
-
priority: number | null;
|
|
24
|
-
protocol: RTCIceProtocol | null;
|
|
25
|
-
address: string | null;
|
|
26
|
-
port: number | null;
|
|
27
|
-
type: RTCIceCandidateType | null;
|
|
28
|
-
relatedAddress: string | null;
|
|
29
|
-
relatedPort: number | null;
|
|
30
|
-
tcpType: RTCIceTcpCandidateType | null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function parseCandidate(line: string): Partial<ParsedCandidate> {
|
|
34
|
-
// Accepts both `candidate:...` and raw `a=candidate:...` forms.
|
|
35
|
-
let s = line.trim();
|
|
36
|
-
if (s.startsWith('a=')) s = s.slice(2);
|
|
37
|
-
if (s.startsWith('candidate:')) s = s.slice('candidate:'.length);
|
|
38
|
-
|
|
39
|
-
const parts = s.split(/\s+/);
|
|
40
|
-
if (parts.length < 8) return {};
|
|
41
|
-
|
|
42
|
-
const protocolRaw = parts[2]?.toLowerCase();
|
|
43
|
-
const typeIdx = parts.indexOf('typ');
|
|
44
|
-
const typeRaw = typeIdx >= 0 ? parts[typeIdx + 1] : undefined;
|
|
45
|
-
|
|
46
|
-
const raddrIdx = parts.indexOf('raddr');
|
|
47
|
-
const rportIdx = parts.indexOf('rport');
|
|
48
|
-
const tcpTypeIdx = parts.indexOf('tcptype');
|
|
49
|
-
|
|
50
|
-
const componentId = Number(parts[1]);
|
|
51
|
-
return {
|
|
52
|
-
foundation: parts[0],
|
|
53
|
-
component: componentId === 1 ? 'rtp' : componentId === 2 ? 'rtcp' : null,
|
|
54
|
-
priority: Number(parts[3]) || null,
|
|
55
|
-
protocol: (protocolRaw === 'udp' || protocolRaw === 'tcp') ? protocolRaw : null,
|
|
56
|
-
address: parts[4] ?? null,
|
|
57
|
-
port: Number(parts[5]) || null,
|
|
58
|
-
type: (typeRaw === 'host' || typeRaw === 'srflx' || typeRaw === 'prflx' || typeRaw === 'relay') ? typeRaw : null,
|
|
59
|
-
relatedAddress: raddrIdx >= 0 ? parts[raddrIdx + 1] ?? null : null,
|
|
60
|
-
relatedPort: rportIdx >= 0 ? Number(parts[rportIdx + 1]) || null : null,
|
|
61
|
-
tcpType: tcpTypeIdx >= 0
|
|
62
|
-
? (parts[tcpTypeIdx + 1] as RTCIceTcpCandidateType)
|
|
63
|
-
: null,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export class RTCIceCandidate {
|
|
68
|
-
readonly candidate: string;
|
|
69
|
-
readonly sdpMid: string | null;
|
|
70
|
-
readonly sdpMLineIndex: number | null;
|
|
71
|
-
readonly usernameFragment: string | null;
|
|
72
|
-
readonly foundation: string | null;
|
|
73
|
-
readonly component: RTCIceComponent | null;
|
|
74
|
-
readonly priority: number | null;
|
|
75
|
-
readonly protocol: RTCIceProtocol | null;
|
|
76
|
-
readonly address: string | null;
|
|
77
|
-
readonly port: number | null;
|
|
78
|
-
readonly type: RTCIceCandidateType | null;
|
|
79
|
-
readonly tcpType: RTCIceTcpCandidateType | null;
|
|
80
|
-
readonly relatedAddress: string | null;
|
|
81
|
-
readonly relatedPort: number | null;
|
|
82
|
-
|
|
83
|
-
constructor(init: RTCIceCandidateInit = {}) {
|
|
84
|
-
if (init.sdpMid == null && init.sdpMLineIndex == null) {
|
|
85
|
-
throw new TypeError(
|
|
86
|
-
'RTCIceCandidate requires either sdpMid or sdpMLineIndex',
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
this.candidate = init.candidate ?? '';
|
|
90
|
-
this.sdpMid = init.sdpMid ?? null;
|
|
91
|
-
this.sdpMLineIndex = init.sdpMLineIndex ?? null;
|
|
92
|
-
this.usernameFragment = init.usernameFragment ?? null;
|
|
93
|
-
|
|
94
|
-
const parsed = parseCandidate(this.candidate);
|
|
95
|
-
this.foundation = parsed.foundation ?? null;
|
|
96
|
-
this.component = parsed.component ?? null;
|
|
97
|
-
this.priority = parsed.priority ?? null;
|
|
98
|
-
this.protocol = parsed.protocol ?? null;
|
|
99
|
-
this.address = parsed.address ?? null;
|
|
100
|
-
this.port = parsed.port ?? null;
|
|
101
|
-
this.type = parsed.type ?? null;
|
|
102
|
-
this.tcpType = parsed.tcpType ?? null;
|
|
103
|
-
this.relatedAddress = parsed.relatedAddress ?? null;
|
|
104
|
-
this.relatedPort = parsed.relatedPort ?? null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
toJSON(): RTCIceCandidateInit {
|
|
108
|
-
return {
|
|
109
|
-
candidate: this.candidate,
|
|
110
|
-
sdpMid: this.sdpMid,
|
|
111
|
-
sdpMLineIndex: this.sdpMLineIndex,
|
|
112
|
-
usernameFragment: this.usernameFragment,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
package/src/rtc-ice-transport.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// W3C RTCIceTransport for GJS.
|
|
2
|
-
//
|
|
3
|
-
// Thin wrapper that reflects webrtcbin's ICE state. The RTCPeerConnection
|
|
4
|
-
// updates state/gatheringState via the WebrtcbinBridge signal handlers.
|
|
5
|
-
//
|
|
6
|
-
// Reference: W3C WebRTC spec § 5.6
|
|
7
|
-
// Reference: refs/wpt/webrtc/RTCIceTransport.html
|
|
8
|
-
|
|
9
|
-
import '@gjsify/dom-events/register/event-target';
|
|
10
|
-
|
|
11
|
-
import { RTCIceCandidate, type RTCIceCandidateInit } from './rtc-ice-candidate.js';
|
|
12
|
-
|
|
13
|
-
export type RTCIceRole = 'unknown' | 'controlling' | 'controlled';
|
|
14
|
-
export type RTCIceComponent = 'rtp' | 'rtcp';
|
|
15
|
-
export type RTCIceTransportState =
|
|
16
|
-
| 'new' | 'checking' | 'connected' | 'completed'
|
|
17
|
-
| 'disconnected' | 'failed' | 'closed';
|
|
18
|
-
|
|
19
|
-
export interface RTCIceParameters {
|
|
20
|
-
usernameFragment?: string;
|
|
21
|
-
password?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface RTCIceCandidatePair {
|
|
25
|
-
local: RTCIceCandidate;
|
|
26
|
-
remote: RTCIceCandidate;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type EventHandler = ((ev: Event) => void) | null;
|
|
30
|
-
|
|
31
|
-
export class RTCIceTransport extends EventTarget {
|
|
32
|
-
private _state: RTCIceTransportState = 'new';
|
|
33
|
-
private _gatheringState: RTCIceGatheringState = 'new';
|
|
34
|
-
private _role: RTCIceRole = 'unknown';
|
|
35
|
-
private _component: RTCIceComponent = 'rtp';
|
|
36
|
-
private _localCandidates: RTCIceCandidate[] = [];
|
|
37
|
-
private _remoteCandidates: RTCIceCandidate[] = [];
|
|
38
|
-
private _localParams: RTCIceParameters | null = null;
|
|
39
|
-
private _remoteParams: RTCIceParameters | null = null;
|
|
40
|
-
|
|
41
|
-
private _onstatechange: EventHandler = null;
|
|
42
|
-
private _ongatheringstatechange: EventHandler = null;
|
|
43
|
-
private _onselectedcandidatepairchange: EventHandler = null;
|
|
44
|
-
|
|
45
|
-
get state(): RTCIceTransportState { return this._state; }
|
|
46
|
-
get gatheringState(): RTCIceGatheringState { return this._gatheringState; }
|
|
47
|
-
get role(): RTCIceRole { return this._role; }
|
|
48
|
-
get component(): RTCIceComponent { return this._component; }
|
|
49
|
-
|
|
50
|
-
get onstatechange(): EventHandler { return this._onstatechange; }
|
|
51
|
-
set onstatechange(v: EventHandler) { this._onstatechange = v; }
|
|
52
|
-
get ongatheringstatechange(): EventHandler { return this._ongatheringstatechange; }
|
|
53
|
-
set ongatheringstatechange(v: EventHandler) { this._ongatheringstatechange = v; }
|
|
54
|
-
get onselectedcandidatepairchange(): EventHandler { return this._onselectedcandidatepairchange; }
|
|
55
|
-
set onselectedcandidatepairchange(v: EventHandler) { this._onselectedcandidatepairchange = v; }
|
|
56
|
-
|
|
57
|
-
getLocalCandidates(): RTCIceCandidate[] { return [...this._localCandidates]; }
|
|
58
|
-
getRemoteCandidates(): RTCIceCandidate[] { return [...this._remoteCandidates]; }
|
|
59
|
-
getSelectedCandidatePair(): RTCIceCandidatePair | null { return null; }
|
|
60
|
-
getLocalParameters(): RTCIceParameters | null { return this._localParams; }
|
|
61
|
-
getRemoteParameters(): RTCIceParameters | null { return this._remoteParams; }
|
|
62
|
-
|
|
63
|
-
// ---- Internal setters (called by RTCPeerConnection) ---------------------
|
|
64
|
-
|
|
65
|
-
/** @internal */
|
|
66
|
-
_setState(state: RTCIceTransportState): void {
|
|
67
|
-
if (this._state === state) return;
|
|
68
|
-
this._state = state;
|
|
69
|
-
const ev = new Event('statechange');
|
|
70
|
-
this._onstatechange?.call(this, ev);
|
|
71
|
-
this.dispatchEvent(ev);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** @internal */
|
|
75
|
-
_setGatheringState(state: RTCIceGatheringState): void {
|
|
76
|
-
if (this._gatheringState === state) return;
|
|
77
|
-
this._gatheringState = state;
|
|
78
|
-
const ev = new Event('gatheringstatechange');
|
|
79
|
-
this._ongatheringstatechange?.call(this, ev);
|
|
80
|
-
this.dispatchEvent(ev);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** @internal */
|
|
84
|
-
_addLocalCandidate(init: RTCIceCandidateInit): void {
|
|
85
|
-
this._localCandidates.push(new RTCIceCandidate(init));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** @internal */
|
|
89
|
-
_addRemoteCandidate(init: RTCIceCandidateInit): void {
|
|
90
|
-
this._remoteCandidates.push(new RTCIceCandidate(init));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** @internal */
|
|
94
|
-
_setLocalParameters(params: RTCIceParameters): void {
|
|
95
|
-
this._localParams = params;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** @internal */
|
|
99
|
-
_setRemoteParameters(params: RTCIceParameters): void {
|
|
100
|
-
this._remoteParams = params;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
type RTCIceGatheringState = 'new' | 'gathering' | 'complete';
|