chuvsu-js 5.5.3 → 5.5.4

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.
@@ -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 } : {}),
@@ -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;
@@ -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();
@@ -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
- if (this.connection.connectionState === "connected")
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
  }
@@ -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
@@ -141,7 +141,11 @@ No backend media receiver or forwarding is required. `listen()` receives the
141
141
  mixed room audio, not separate speaker tracks. Every playback exposes `stream`,
142
142
  `connection`, `getStats()`, `onError()`, `onClose()`, and idempotent `close()`.
143
143
  Listen-only negotiation follows the server's `media.listenOnlyOffering` setting:
144
- client offers and server offers are both supported. Server-offered audio sends
144
+ client offers and server offers are both supported. The server-advertised
145
+ listen-only media adapter is retained in the start request; the SFU protocol name
146
+ does not select that adapter. Audio resolves only after its receive track,
147
+ connected transport, and server `MEDIA_FLOWING` confirmation are present, matching
148
+ BBB's own listen-only client. Server-offered audio sends
145
149
  `subscriberAnswer`; ICE candidates queue until negotiation is ready. The server's
146
150
  `forceRelay` and `forceRelayOnFirefox` settings select the browser ICE policy.
147
151
  These contracts are covered by mock protocol tests; live receive-only audio still
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chuvsu-js",
3
- "version": "5.5.3",
3
+ "version": "5.5.4",
4
4
  "description": "Библиотека для расписания и личного кабинета ЧГУ им. И. Н. Ульянова",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",