chuvsu-js 5.5.3 → 5.5.5
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/dist/webinar/gateway.d.ts +2 -0
- package/dist/webinar/gateway.js +6 -0
- package/dist/webinar/media-protocol.js +3 -0
- package/dist/webinar/media-types.d.ts +2 -0
- package/dist/webinar/parse.js +3 -0
- package/dist/webinar/playback.d.ts +2 -0
- package/dist/webinar/playback.js +19 -3
- package/dist/webinar/types.d.ts +2 -0
- package/docs/webinar.md +17 -1
- package/package.json +1 -1
|
@@ -6,6 +6,8 @@ export declare class WebinarGateway {
|
|
|
6
6
|
private session;
|
|
7
7
|
private client;
|
|
8
8
|
getSession(): WebinarSession;
|
|
9
|
+
/** Cookie-authenticated state socket for managed reconnection and health checks. */
|
|
10
|
+
createStateSocket(): WebinarSocket;
|
|
9
11
|
/** Cookie-authenticated signaling socket; audio/video WebRTC stays in the browser. */
|
|
10
12
|
createMediaSocket(): WebinarSocket;
|
|
11
13
|
openSession(opts: {
|
package/dist/webinar/gateway.js
CHANGED
|
@@ -13,6 +13,12 @@ export class WebinarGateway {
|
|
|
13
13
|
throw new AuthError("Open a webinar session first");
|
|
14
14
|
return structuredClone(this.session);
|
|
15
15
|
}
|
|
16
|
+
/** Cookie-authenticated state socket for managed reconnection and health checks. */
|
|
17
|
+
createStateSocket() {
|
|
18
|
+
if (!this.session)
|
|
19
|
+
throw new AuthError("Open a webinar session first");
|
|
20
|
+
return this.http.createWebSocket(this.session.connections.state);
|
|
21
|
+
}
|
|
16
22
|
/** Cookie-authenticated signaling socket; audio/video WebRTC stays in the browser. */
|
|
17
23
|
createMediaSocket() {
|
|
18
24
|
if (!this.session)
|
|
@@ -23,6 +23,9 @@ export function webinarMediaMessages(session, kind, streamId, hasAudio = false)
|
|
|
23
23
|
? {
|
|
24
24
|
userId: session.user.id,
|
|
25
25
|
caleeName: `GLOBAL_AUDIO_${session.meeting.voiceBridge}`,
|
|
26
|
+
...(session.mediaSettings?.listenOnlyMediaServer
|
|
27
|
+
? { mediaServer: session.mediaSettings.listenOnlyMediaServer }
|
|
28
|
+
: {}),
|
|
26
29
|
}
|
|
27
30
|
: {}),
|
|
28
31
|
...(kind === "screen" ? { hasAudio } : {}),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { WebinarSocketFactory } from "./types.js";
|
|
2
2
|
export interface WebinarMediaOptions {
|
|
3
|
+
/** Inject a compatible receive stream in runtimes without a global MediaStream. */
|
|
4
|
+
streamFactory?: () => MediaStream;
|
|
3
5
|
socketFactory?: WebinarSocketFactory;
|
|
4
6
|
peerFactory?: (config: RTCConfiguration) => RTCPeerConnection;
|
|
5
7
|
timeout?: number;
|
package/dist/webinar/parse.js
CHANGED
|
@@ -95,6 +95,9 @@ export function parseWebinarSession(opts) {
|
|
|
95
95
|
iceServers: opts.iceServers,
|
|
96
96
|
mediaSettings: {
|
|
97
97
|
listenOnlyOffering: record(opts.config.media).listenOnlyOffering !== false,
|
|
98
|
+
...(/^[A-Za-z0-9_-]{1,64}$/u.test(string(kurento.listenOnlyMediaServer))
|
|
99
|
+
? { listenOnlyMediaServer: string(kurento.listenOnlyMediaServer) }
|
|
100
|
+
: {}),
|
|
98
101
|
forceRelay: record(opts.config.media).forceRelay === true,
|
|
99
102
|
forceRelayOnFirefox: kurento.forceRelayOnFirefox === true,
|
|
100
103
|
},
|
|
@@ -11,6 +11,7 @@ export declare class WebinarPlayback {
|
|
|
11
11
|
private started;
|
|
12
12
|
private answered;
|
|
13
13
|
private offering;
|
|
14
|
+
private audioFlowing;
|
|
14
15
|
private localCandidates;
|
|
15
16
|
private remoteCandidates;
|
|
16
17
|
private pendingReceive;
|
|
@@ -22,6 +23,7 @@ export declare class WebinarPlayback {
|
|
|
22
23
|
private abort;
|
|
23
24
|
private signal;
|
|
24
25
|
constructor(session: WebinarSession, kind: WebinarPlaybackKind, socket: WebinarSocket, opts: WebinarMediaOptions, streamId?: string, hasAudio?: boolean);
|
|
26
|
+
private resolveWhenReady;
|
|
25
27
|
connect(timeout: number, opts?: WebinarReceiveOptions): Promise<void>;
|
|
26
28
|
private send;
|
|
27
29
|
private receive;
|
package/dist/webinar/playback.js
CHANGED
|
@@ -13,6 +13,7 @@ export class WebinarPlayback {
|
|
|
13
13
|
started = false;
|
|
14
14
|
answered = false;
|
|
15
15
|
offering;
|
|
16
|
+
audioFlowing = false;
|
|
16
17
|
localCandidates = [];
|
|
17
18
|
remoteCandidates = [];
|
|
18
19
|
pendingReceive = Promise.resolve();
|
|
@@ -29,7 +30,7 @@ export class WebinarPlayback {
|
|
|
29
30
|
this.offering =
|
|
30
31
|
kind !== "audio" || session.mediaSettings?.listenOnlyOffering !== false;
|
|
31
32
|
this.messages = webinarMediaMessages(session, kind, streamId, hasAudio);
|
|
32
|
-
this.stream = new MediaStream();
|
|
33
|
+
this.stream = opts.streamFactory ? opts.streamFactory() : new MediaStream();
|
|
33
34
|
this.connection = (opts.peerFactory ?? ((config) => new RTCPeerConnection(config)))({
|
|
34
35
|
iceServers: session.iceServers,
|
|
35
36
|
iceTransportPolicy: session.mediaSettings?.forceRelay ||
|
|
@@ -46,6 +47,7 @@ export class WebinarPlayback {
|
|
|
46
47
|
this.connection.addEventListener("track", (event) => {
|
|
47
48
|
if (!this.stream.getTracks().some((track) => track.id === event.track.id))
|
|
48
49
|
this.stream.addTrack(event.track);
|
|
50
|
+
this.resolveWhenReady();
|
|
49
51
|
});
|
|
50
52
|
this.connection.addEventListener("icecandidate", (event) => {
|
|
51
53
|
if (!event.candidate || this.closed)
|
|
@@ -57,8 +59,7 @@ export class WebinarPlayback {
|
|
|
57
59
|
this.send(this.messages.candidate(candidate));
|
|
58
60
|
});
|
|
59
61
|
this.connection.addEventListener("connectionstatechange", () => {
|
|
60
|
-
|
|
61
|
-
this.connectionResolve?.();
|
|
62
|
+
this.resolveWhenReady();
|
|
62
63
|
if (!this.closed && this.connection.connectionState === "failed")
|
|
63
64
|
this.fail(new WebinarProtocolError("Webinar media connection failed"));
|
|
64
65
|
});
|
|
@@ -82,6 +83,15 @@ export class WebinarPlayback {
|
|
|
82
83
|
this.fail(new WebinarProtocolError("Webinar media signaling failed"));
|
|
83
84
|
});
|
|
84
85
|
}
|
|
86
|
+
resolveWhenReady() {
|
|
87
|
+
if (this.connection.connectionState !== "connected")
|
|
88
|
+
return;
|
|
89
|
+
if (this.kind === "audio" &&
|
|
90
|
+
(!this.audioFlowing ||
|
|
91
|
+
!this.stream.getTracks().some((track) => track.kind === "audio")))
|
|
92
|
+
return;
|
|
93
|
+
this.connectionResolve?.();
|
|
94
|
+
}
|
|
85
95
|
async connect(timeout, opts = {}) {
|
|
86
96
|
if (this.closed || this.started)
|
|
87
97
|
throw new WebinarProtocolError("Playback already opened or closed");
|
|
@@ -157,6 +167,12 @@ export class WebinarPlayback {
|
|
|
157
167
|
else
|
|
158
168
|
await this.connection.addIceCandidate(candidate);
|
|
159
169
|
}
|
|
170
|
+
else if (message.id === "webRTCAudioSuccess" && this.kind === "audio") {
|
|
171
|
+
if (message.success !== "MEDIA_FLOWING" && message.success !== true)
|
|
172
|
+
throw new WebinarProtocolError("Webinar audio is not flowing");
|
|
173
|
+
this.audioFlowing = true;
|
|
174
|
+
this.resolveWhenReady();
|
|
175
|
+
}
|
|
160
176
|
else if (["error", "webRTCAudioError"].includes(string(message.id))) {
|
|
161
177
|
throw new WebinarProtocolError("Webinar media rejected by server");
|
|
162
178
|
}
|
package/dist/webinar/types.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface WebinarSession {
|
|
|
27
27
|
iceServers: RTCIceServer[];
|
|
28
28
|
mediaSettings?: {
|
|
29
29
|
listenOnlyOffering: boolean;
|
|
30
|
+
/** Server-advertised adapter for receive-only audio, independent of SFU protocol. */
|
|
31
|
+
listenOnlyMediaServer?: string;
|
|
30
32
|
forceRelay: boolean;
|
|
31
33
|
forceRelayOnFirefox: boolean;
|
|
32
34
|
};
|
package/docs/webinar.md
CHANGED
|
@@ -38,6 +38,18 @@ owner-scoped WebSocket signaling relay and provide its browser endpoint through
|
|
|
38
38
|
connections and audio/video remain directly between the browser and BBB. Never
|
|
39
39
|
serialize the gateway cookie jar or share a relay with another participant.
|
|
40
40
|
|
|
41
|
+
For managed backend reconnection, `gateway.createStateSocket()` creates the state
|
|
42
|
+
transport using the gateway's existing cookies and TLS configuration. Pass it as
|
|
43
|
+
`new WebinarClient(gateway.getSession(), { socketFactory: () => gateway.createStateSocket() })`.
|
|
44
|
+
Close the preceding state client before replacing it; constructing the socket
|
|
45
|
+
alone does not authenticate or rejoin the participant.
|
|
46
|
+
|
|
47
|
+
`WebinarMediaOptions.streamFactory` complements `peerFactory` for runtimes without
|
|
48
|
+
a global `MediaStream`. Supply a compatible receive stream through
|
|
49
|
+
`streamFactory: () => stream`; the library does not install global polyfills.
|
|
50
|
+
Receive-only audio still requires a real WebRTC peer connection and consumes
|
|
51
|
+
network bandwidth. These factories do not automatically enable media.
|
|
52
|
+
|
|
41
53
|
## State and events
|
|
42
54
|
|
|
43
55
|
- `getUsers()`, `getPresenter()`, `getModerators()` distinguish participant roles.
|
|
@@ -141,7 +153,11 @@ No backend media receiver or forwarding is required. `listen()` receives the
|
|
|
141
153
|
mixed room audio, not separate speaker tracks. Every playback exposes `stream`,
|
|
142
154
|
`connection`, `getStats()`, `onError()`, `onClose()`, and idempotent `close()`.
|
|
143
155
|
Listen-only negotiation follows the server's `media.listenOnlyOffering` setting:
|
|
144
|
-
client offers and server offers are both supported.
|
|
156
|
+
client offers and server offers are both supported. The server-advertised
|
|
157
|
+
listen-only media adapter is retained in the start request; the SFU protocol name
|
|
158
|
+
does not select that adapter. Audio resolves only after its receive track,
|
|
159
|
+
connected transport, and server `MEDIA_FLOWING` confirmation are present, matching
|
|
160
|
+
BBB's own listen-only client. Server-offered audio sends
|
|
145
161
|
`subscriberAnswer`; ICE candidates queue until negotiation is ready. The server's
|
|
146
162
|
`forceRelay` and `forceRelayOnFirefox` settings select the browser ICE policy.
|
|
147
163
|
These contracts are covered by mock protocol tests; live receive-only audio still
|