@voltkit-rtc/client 0.7.0 → 0.7.2
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/CHANGELOG.md +99 -0
- package/README.md +39 -2
- package/dist/cjs/broadcast.d.ts +21 -2
- package/dist/cjs/broadcast.d.ts.map +1 -1
- package/dist/cjs/broadcast.js +75 -11
- package/dist/cjs/broadcast.js.map +1 -1
- package/dist/cjs/chat.d.ts +13 -0
- package/dist/cjs/chat.d.ts.map +1 -1
- package/dist/cjs/chat.js +65 -9
- package/dist/cjs/chat.js.map +1 -1
- package/dist/cjs/index.d.ts +78 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +269 -61
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/broadcast.d.ts +21 -2
- package/dist/esm/broadcast.d.ts.map +1 -1
- package/dist/esm/broadcast.js +75 -11
- package/dist/esm/broadcast.js.map +1 -1
- package/dist/esm/chat.d.ts +13 -0
- package/dist/esm/chat.d.ts.map +1 -1
- package/dist/esm/chat.js +65 -9
- package/dist/esm/chat.js.map +1 -1
- package/dist/esm/index.d.ts +78 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +269 -61
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/broadcast.ts +68 -11
- package/src/chat.ts +63 -8
- package/src/index.ts +266 -56
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,104 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.2
|
|
4
|
+
|
|
5
|
+
Bug fixes found by checking this SDK for the bug classes a frontend tester
|
|
6
|
+
reported in the Flutter SDK (2026-10-18, VK-01…VK-18).
|
|
7
|
+
|
|
8
|
+
- **BR-01: `BroadcastPublisher.stop()` wins over a `start()` under way.**
|
|
9
|
+
Stopping while `start()` waited for the camera, or for the media server's
|
|
10
|
+
answer, did not stop it: the start went on air afterwards, a late answer
|
|
11
|
+
turned the state to `failed` after `stopped` and left the server's session
|
|
12
|
+
open, and a start finishing after a restart replaced the new broadcast. Two
|
|
13
|
+
`start()` calls at once both went on air. Now the interrupted `start()`
|
|
14
|
+
rejects with an `AbortError`, a camera it captured afterwards is released,
|
|
15
|
+
a WHIP session the server opened for it is deleted, and a newer broadcast is
|
|
16
|
+
never touched. A second `start()` while one is under way is refused.
|
|
17
|
+
- **BR-02: `stopMusic()` stops a `publishMusic()` still under way.** Called
|
|
18
|
+
while the music's producer was being made, `stopMusic()` returned with
|
|
19
|
+
nothing to stop, and the music went out afterwards. A second
|
|
20
|
+
`publishMusic()` while one was under way could leave two music producers,
|
|
21
|
+
the first no longer tracked. Now the call under way rejects with
|
|
22
|
+
`unpublished` and its producer is closed here and at the server, and music
|
|
23
|
+
publishes run one at a time, in call order.
|
|
24
|
+
- **BR-03: every way a session ends releases local media.** A session ended
|
|
25
|
+
by another connection for the same identity (`closed: replaced`), by the
|
|
26
|
+
server closing the socket without `roomClosed`, or by a reconnect that gave
|
|
27
|
+
up (`closed: gave-up`) reported `closed` with the camera, microphone, screen
|
|
28
|
+
share and music still capturing, and a recording still uploading, until the
|
|
29
|
+
app called `close()`. Now they are released as the session closes, as
|
|
30
|
+
`kicked` and `roomClosed` always did.
|
|
31
|
+
- **BR-04: a late `updateToken()` never replaces a newer token.** When a
|
|
32
|
+
promotion's token arrived while `updateToken()` waited for its answer, the
|
|
33
|
+
promotion closed the socket, the waiting call fell back to keeping its own
|
|
34
|
+
token, and the reconnect joined with that older token instead of the
|
|
35
|
+
promotion's. The server's own refresh arriving meanwhile, and two calls
|
|
36
|
+
answered in reverse order, lost the newer token the same way. Now a token
|
|
37
|
+
the server hands over, or a later call's, wins, and the waiting call resolves
|
|
38
|
+
to the expiry of the token held. A refused newer call still leaves an
|
|
39
|
+
accepted earlier one in place.
|
|
40
|
+
- **BR-05: a video that fails to subscribe frees its slot for the next.** At
|
|
41
|
+
the fan-out limit (`maxVideoSubscriptions`), a subscription that failed gave
|
|
42
|
+
its slot back but left the videos waiting for one where they were, until
|
|
43
|
+
another video ended or the session reconnected. Now the oldest waiting video
|
|
44
|
+
takes the slot, after repeated failures too; nothing is started while the
|
|
45
|
+
connection is down (the reconnect lists every video again).
|
|
46
|
+
- **BR-06: a video that ends while its subscription is being set up leaves
|
|
47
|
+
nothing behind.** Its consumer, made after it ended, stayed open and kept a
|
|
48
|
+
fan-out slot for the rest of the session, and a `track` could be emitted for
|
|
49
|
+
it after it had ended. Now that consumer is closed, no `track` is emitted,
|
|
50
|
+
its slot goes to the next waiting video, and no error is reported. Two
|
|
51
|
+
announcements of the same video no longer start two subscriptions.
|
|
52
|
+
- **BR-07: a replaced connection fails what waited on it at once.** Calling
|
|
53
|
+
`connect()` on a live session opened a new socket and left the requests sent
|
|
54
|
+
on the old one waiting 15 s for replies that could never be read, then
|
|
55
|
+
failing with `timeout`. An earlier `connect()` still under way could, as it
|
|
56
|
+
failed, close the newer connection (two `connect()` calls before the first
|
|
57
|
+
socket opened both failed). Now those requests fail at once with
|
|
58
|
+
`not-connected` and are never resent, and a failing older `connect()`
|
|
59
|
+
leaves the newer one alone. The same for `ChatClient`.
|
|
60
|
+
|
|
61
|
+
## 0.7.1
|
|
62
|
+
|
|
63
|
+
Bug fixes. No API changes; nothing to change in your code. An external review
|
|
64
|
+
(2026-10-16) found lifecycle bugs in the Flutter SDK and transport bugs in the
|
|
65
|
+
Node SDK. This release fixes the same kinds of bug, found in this SDK by the
|
|
66
|
+
check that followed.
|
|
67
|
+
|
|
68
|
+
- **BROWSER-01: `close()` is final while a connection is being made.**
|
|
69
|
+
- Before, closing while `connect()` waited for the join left `connect()`
|
|
70
|
+
pending for about 15 s, after which it failed with `timeout`.
|
|
71
|
+
- Closing just after the join, while the session was still being set up, put
|
|
72
|
+
`connectionState` back to `connected` and emitted `joined` after `closed`.
|
|
73
|
+
- Closing during a reconnect could emit an `error` after `closed`.
|
|
74
|
+
|
|
75
|
+
Now `close()` fails `connect()` and every request in flight at once, with
|
|
76
|
+
`not-connected`, and nothing is emitted after `closed`. The same holds for
|
|
77
|
+
`ChatClient`. `ChatClient.close()` now also closes a socket opened by a
|
|
78
|
+
`connect()` after an earlier `close()`, which it could not reach before.
|
|
79
|
+
- **BROWSER-02: a reconnect that ends the session closes its socket.** When
|
|
80
|
+
the server refused a reconnect for good (`room-ended`, `bad-token`, …), or the
|
|
81
|
+
reconnect attempts ran out, the session reported `closed: gave-up` but kept
|
|
82
|
+
the refused socket open and attached. Now that socket is closed and later
|
|
83
|
+
requests are refused without being sent. Both `StreamClient` and `ChatClient`.
|
|
84
|
+
- **BROWSER-03: `endRoom()` resolves when the room closes first.** The server
|
|
85
|
+
tells the room it has closed before it replies to `endRoom`, and that closes
|
|
86
|
+
the session, so the reply was never read and `endRoom()` failed with `timeout`
|
|
87
|
+
15 s later, although the room had ended. Now a `roomClosed` that arrives
|
|
88
|
+
first resolves `endRoom()` with `{ ok: true }`, as the reply would. A refusal,
|
|
89
|
+
or a dropped connection with neither, still fails.
|
|
90
|
+
- **BROWSER-04: WHIP failures while reading the answer are `WhipError`s.**
|
|
91
|
+
`BroadcastPublisher.start()` failed with a raw `TimeoutError` or `TypeError`
|
|
92
|
+
when the media server's answer timed out or the connection dropped after its
|
|
93
|
+
headers. Now they are `WhipError`s with `status` 0, like the same failures
|
|
94
|
+
before the headers. The publish URL is never in the message.
|
|
95
|
+
- **BROWSER-05: a `null` message frame is ignored.** Valid JSON that is not a
|
|
96
|
+
message object no longer throws out of the socket's message listener; other
|
|
97
|
+
frames that are not messages were already ignored.
|
|
98
|
+
- Docs: the README says 60 fps is delivered only when the capture source
|
|
99
|
+
provides it (most phone and laptop cameras give browsers 30 fps), how to check
|
|
100
|
+
a camera's rates, and that billing follows the frame rate delivered.
|
|
101
|
+
|
|
3
102
|
## 0.7.0
|
|
4
103
|
|
|
5
104
|
Additive: every 0.6 call works as before. Pairs with the controller's wallet
|
package/README.md
CHANGED
|
@@ -165,6 +165,18 @@ sends 30 and says why on `error`, as a warning that stops nothing:
|
|
|
165
165
|
camera; in a project without 60 fps it changes nothing and warns again.
|
|
166
166
|
(Before 0.7.0 the project case was also reported as `frame-rate-fallback`.)
|
|
167
167
|
|
|
168
|
+
60 fps is delivered only when the capture source provides it.
|
|
169
|
+
Phone makers usually keep 60 fps for their own camera app, so browsers and most
|
|
170
|
+
apps get 30 fps. Check a camera's supported rates in `chrome://media-internals`
|
|
171
|
+
→ Video Capture. Billing follows the frame rate actually delivered. In our
|
|
172
|
+
tests a laptop webcam gave Chrome 20 fps at 1080p, and a phone whose own camera
|
|
173
|
+
app records 1080p60 gave 25–30 fps (14 fps in a dim room). Read what you got,
|
|
174
|
+
not what you asked for: `track.getSettings().frameRate` is the rate the camera
|
|
175
|
+
was opened at, and `getVideoStats()` reports the rate captured (`source.fps`,
|
|
176
|
+
where the browser supplies it) and sent (`fps`). For 60 fps, use a webcam or
|
|
177
|
+
capture card listed at 60 fps, or a virtual camera such as OBS Virtual Camera
|
|
178
|
+
set to 60 fps.
|
|
179
|
+
|
|
168
180
|
The full guide, with data use:
|
|
169
181
|
[voltkit.in/docs/video-quality](https://voltkit.in/docs/video-quality).
|
|
170
182
|
|
|
@@ -228,7 +240,7 @@ codes:
|
|
|
228
240
|
- **Fan-out:** a session billed from the wallet receives at most
|
|
229
241
|
`maxVideoSubscriptions` videos at once (25 by default). Further videos wait,
|
|
230
242
|
with one `video-subscription-limit` warning each, and are received as others
|
|
231
|
-
end.
|
|
243
|
+
end, fail to subscribe, or end while their subscription is being set up.
|
|
232
244
|
|
|
233
245
|
With an older server (no `media` in the join result) the `videoPolicy` alone
|
|
234
246
|
applies, as in 0.6.
|
|
@@ -377,6 +389,11 @@ await client.stopMusic();
|
|
|
377
389
|
`client.musicPublishing` is whether music is published at all, and
|
|
378
390
|
`client.musicEnabled` whether the audience hears it now.
|
|
379
391
|
|
|
392
|
+
`stopMusic()` also stops a `publishMusic()` that is still under way: that call
|
|
393
|
+
rejects with `unpublished` and nothing goes out. Calls to `publishMusic()` take
|
|
394
|
+
effect in the order they are made: a newer one replaces music still being
|
|
395
|
+
published, and the replaced call rejects with `unpublished`.
|
|
396
|
+
|
|
380
397
|
Music is HD and free: it always goes out at 128 kbps stereo, also in a project
|
|
381
398
|
limited to standard audio, and the service never bills it. Sending or hearing
|
|
382
399
|
music never changes anyone's rate; the microphone and video alone decide it.
|
|
@@ -435,7 +452,7 @@ await client.getRoomState();
|
|
|
435
452
|
| `error` | a failure or recoverable warning such as `frame-rate-fallback`; inspect its code |
|
|
436
453
|
| `usageLimit` | your project ran out of minutes or hit a usage limit; the session ends at `endsAt` unless it is topped up |
|
|
437
454
|
| `videoLimited` | your camera video is held back by this device (`cpu`) or the upload (`bandwidth`), or that cleared (`none`) |
|
|
438
|
-
| `closed` | terminal — `replaced`, `kicked`, `room-closed` or `gave-up`, or `left` when your own `close()` ends the session |
|
|
455
|
+
| `closed` | terminal — `replaced`, `kicked`, `room-closed` or `gave-up`, or `left` when your own `close()` ends the session. Whatever the reason, the camera, microphone, screen share, music and recording are released with it, as `close()` does |
|
|
439
456
|
| `connectionStateChanged` | `{ state, previous }`: `idle` → `connecting` → `connected` ⇄ `reconnecting` → `closed` |
|
|
440
457
|
| `participantUpdated` | someone changed their display metadata (`setMetadata`) |
|
|
441
458
|
| `claimChanged` | a slot was taken, went away, came back, was locked or freed: `{ key, identity, state, reason }` |
|
|
@@ -479,6 +496,11 @@ reconnect. `tokenExpiring` fires only when nobody refreshed the token: the
|
|
|
479
496
|
server stops when the account may no longer be used, and a dropped socket
|
|
480
497
|
cannot receive one.
|
|
481
498
|
|
|
499
|
+
A newer token always wins over an `updateToken` still waiting for its answer:
|
|
500
|
+
one the server hands over meanwhile (its own refresh, or a promotion's, which
|
|
501
|
+
carries the new role) or one from a later `updateToken` call. The waiting call
|
|
502
|
+
then resolves to the expiry of the token now held.
|
|
503
|
+
|
|
482
504
|
### Wallet and usage notices
|
|
483
505
|
|
|
484
506
|
```ts
|
|
@@ -553,6 +575,12 @@ were removed, the account ran out).
|
|
|
553
575
|
this connection lost. Do not reconnect on it: the two would take turns evicting
|
|
554
576
|
each other.
|
|
555
577
|
|
|
578
|
+
You do not need to call `connect()` again yourself. If you do, the newer call
|
|
579
|
+
wins: the older connection is closed, requests still waiting on it fail at
|
|
580
|
+
once with `not-connected` (they are never sent again: the server may already
|
|
581
|
+
have acted on them), and an older `connect()` still under way fails without
|
|
582
|
+
touching the new one. `ChatClient` behaves the same.
|
|
583
|
+
|
|
556
584
|
## Chat
|
|
557
585
|
|
|
558
586
|
Every room has a chat channel of the same name. `StreamClient` carries it on the
|
|
@@ -639,6 +667,15 @@ the user clicks "go live", and keep it out of logs and analytics.
|
|
|
639
667
|
`start()` rejects with `WhipError` if the media server refuses. `isRefused`
|
|
640
668
|
means the URL itself was not accepted — expired, for another stream, or the
|
|
641
669
|
account is out of minutes — and a retry with the same URL is refused again.
|
|
670
|
+
A media server that cannot be reached, does not answer within 15 s, or drops
|
|
671
|
+
the connection while answering is a `WhipError` too, with `status` 0.
|
|
672
|
+
|
|
673
|
+
`stop()` wins over a `start()` still under way, such as one waiting for the
|
|
674
|
+
camera permission or for the media server's answer. That `start()` rejects
|
|
675
|
+
with an `AbortError` (`err.name === 'AbortError'`), nothing goes on air for it,
|
|
676
|
+
a camera it captured afterwards is released, and a session the server opened
|
|
677
|
+
for it is ended. You can call `start()` again straight after `stop()`. A second
|
|
678
|
+
`start()` while one is under way is refused: call `stop()` first.
|
|
642
679
|
|
|
643
680
|
Video is offered as **H.264 only**. The media server repackages H.264 into HLS
|
|
644
681
|
untouched; any other codec makes it transcode every frame. A browser with no
|
package/dist/cjs/broadcast.d.ts
CHANGED
|
@@ -84,6 +84,16 @@ export declare class BroadcastPublisher {
|
|
|
84
84
|
private micOn;
|
|
85
85
|
private current;
|
|
86
86
|
private readonly listeners;
|
|
87
|
+
/**
|
|
88
|
+
* Bumped by every start() and stop(). A start compares it after each wait:
|
|
89
|
+
* once stop() has run, that start is over, and what it was waiting for
|
|
90
|
+
* (a camera, the media server's answer) arrives to be released, never
|
|
91
|
+
* adopted -- otherwise a stopped broadcast went on air anyway, or tore
|
|
92
|
+
* down the one started after it.
|
|
93
|
+
*/
|
|
94
|
+
private operation;
|
|
95
|
+
/** The start() under way, by its operation; a second one is refused meanwhile. */
|
|
96
|
+
private starting;
|
|
87
97
|
constructor(whipUrl: string);
|
|
88
98
|
get state(): BroadcastState;
|
|
89
99
|
/** What is being published, for a local preview. */
|
|
@@ -91,7 +101,12 @@ export declare class BroadcastPublisher {
|
|
|
91
101
|
on<K extends keyof BroadcastEvents>(event: K, fn: BroadcastEvents[K]): () => void;
|
|
92
102
|
private emit;
|
|
93
103
|
private set;
|
|
94
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Go on air. Resolves once the media server has accepted the stream.
|
|
106
|
+
* Rejects with an `AbortError` when `stop()` runs first: a camera captured
|
|
107
|
+
* for it afterwards is released, and a session the server opened for it is
|
|
108
|
+
* ended.
|
|
109
|
+
*/
|
|
95
110
|
start(options?: BroadcastStartOptions): Promise<MediaStream>;
|
|
96
111
|
/**
|
|
97
112
|
* Put H.264 first, and offer nothing else for video.
|
|
@@ -123,7 +138,11 @@ export declare class BroadcastPublisher {
|
|
|
123
138
|
get micEnabled(): boolean;
|
|
124
139
|
/** Turn the camera on or off without leaving the air. */
|
|
125
140
|
setCamEnabled(enabled: boolean): void;
|
|
126
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Go off air and release the camera and microphone. Idempotent. A start()
|
|
143
|
+
* still under way is over: it rejects with an `AbortError`, and you can
|
|
144
|
+
* start again at once.
|
|
145
|
+
*/
|
|
127
146
|
stop(): Promise<void>;
|
|
128
147
|
private teardown;
|
|
129
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../src/broadcast.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAc,KAAK,UAAU,EAAE,KAAK,YAAY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QAAQ,CAAuB;gBAEV,OAAO,EAAE,MAAM;IAE5C,IAAI,KAAK,IAAI,cAAc,CAE1B;IAED,oDAAoD;IACpD,IAAI,WAAW,IAAI,WAAW,GAAG,IAAI,CAEpC;IAED,EAAE,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAUjF,OAAO,CAAC,IAAI;IAUZ,OAAO,CAAC,GAAG;IAMX;;;;;OAKG;IACG,KAAK,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,WAAW,CAAC;IA2EtE;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IAelB,kFAAkF;IAClF,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMrC;;;;;;;OAOG;IACG,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxE,gFAAgF;IAChF,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIvC,gCAAgC;IAChC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIpC,yDAAyD;IACzD,UAAU,IAAI,IAAI;IAIlB,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,yDAAyD;IACzD,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIrC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B,OAAO,CAAC,QAAQ;CAajB"}
|
package/dist/cjs/broadcast.js
CHANGED
|
@@ -38,28 +38,39 @@ const WHIP_TIMEOUT_MS = 15_000;
|
|
|
38
38
|
const ICE_GATHER_TIMEOUT_MS = 3_000;
|
|
39
39
|
/** Helper formats that ride along with a codec. Not codecs in their own right. */
|
|
40
40
|
const HELPER_FORMATS = new Set(['video/rtx', 'video/red', 'video/ulpfec', 'video/flexfec-03']);
|
|
41
|
+
/** Why a start() gave up: stop() ran while it was under way, and stop wins. */
|
|
42
|
+
const stoppedWhileStarting = () => new DOMException('the broadcast was stopped while it was starting', 'AbortError');
|
|
41
43
|
/**
|
|
42
44
|
* Send an SDP offer to a WHIP endpoint and return the answer, plus the session
|
|
43
45
|
* resource the server names for ending it.
|
|
44
46
|
*/
|
|
45
47
|
async function whipOffer(whipUrl, offerSdp, timeoutMs = WHIP_TIMEOUT_MS) {
|
|
48
|
+
// One deadline for the request and the whole answer: the signal stays
|
|
49
|
+
// armed while the body is read.
|
|
50
|
+
const signal = AbortSignal.timeout(timeoutMs);
|
|
51
|
+
// Never echo the URL or the error: the URL carries the publish token.
|
|
52
|
+
const failed = (err, otherwise) => new WhipError(0, signal.aborted || err?.name === 'TimeoutError' ? 'the media server did not answer in time' : otherwise);
|
|
46
53
|
let res;
|
|
47
54
|
try {
|
|
48
55
|
res = await fetch(whipUrl, {
|
|
49
56
|
method: 'POST',
|
|
50
57
|
headers: { 'Content-Type': 'application/sdp', Accept: 'application/sdp' },
|
|
51
58
|
body: offerSdp,
|
|
52
|
-
signal
|
|
59
|
+
signal,
|
|
53
60
|
});
|
|
54
61
|
}
|
|
55
62
|
catch (err) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
throw failed(err, 'could not reach the media server');
|
|
64
|
+
}
|
|
65
|
+
let body;
|
|
66
|
+
try {
|
|
67
|
+
// A deadline or a connection lost after the headers is the same failure
|
|
68
|
+
// as one before them, and is reported the same way.
|
|
69
|
+
body = await res.text();
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
throw failed(err, 'the connection to the media server was lost');
|
|
61
73
|
}
|
|
62
|
-
const body = await res.text();
|
|
63
74
|
if (res.status !== 201 && res.status !== 200) {
|
|
64
75
|
const line = body.split('\n')[0]?.trim().slice(0, 200);
|
|
65
76
|
throw new WhipError(res.status, line || 'the media server refused the stream');
|
|
@@ -109,6 +120,16 @@ class BroadcastPublisher {
|
|
|
109
120
|
micOn = true;
|
|
110
121
|
current = 'idle';
|
|
111
122
|
listeners = new Map();
|
|
123
|
+
/**
|
|
124
|
+
* Bumped by every start() and stop(). A start compares it after each wait:
|
|
125
|
+
* once stop() has run, that start is over, and what it was waiting for
|
|
126
|
+
* (a camera, the media server's answer) arrives to be released, never
|
|
127
|
+
* adopted -- otherwise a stopped broadcast went on air anyway, or tore
|
|
128
|
+
* down the one started after it.
|
|
129
|
+
*/
|
|
130
|
+
operation = 0;
|
|
131
|
+
/** The start() under way, by its operation; a second one is refused meanwhile. */
|
|
132
|
+
starting = null;
|
|
112
133
|
constructor(whipUrl) {
|
|
113
134
|
this.whipUrl = whipUrl;
|
|
114
135
|
}
|
|
@@ -144,14 +165,27 @@ class BroadcastPublisher {
|
|
|
144
165
|
this.current = state;
|
|
145
166
|
this.emit('state', state);
|
|
146
167
|
}
|
|
147
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Go on air. Resolves once the media server has accepted the stream.
|
|
170
|
+
* Rejects with an `AbortError` when `stop()` runs first: a camera captured
|
|
171
|
+
* for it afterwards is released, and a session the server opened for it is
|
|
172
|
+
* ended.
|
|
173
|
+
*/
|
|
148
174
|
async start(options = {}) {
|
|
149
|
-
if (this.pc)
|
|
175
|
+
if (this.pc || this.starting !== null)
|
|
150
176
|
throw new Error('already publishing; call stop() first');
|
|
177
|
+
const operation = ++this.operation;
|
|
178
|
+
this.starting = operation;
|
|
179
|
+
const stopped = () => operation !== this.operation;
|
|
180
|
+
const owns = !options.stream;
|
|
181
|
+
let captured = null;
|
|
151
182
|
this.set('connecting');
|
|
152
183
|
try {
|
|
153
|
-
this.ownsMedia = !options.stream;
|
|
154
184
|
const media = options.stream ?? await navigator.mediaDevices.getUserMedia(options.constraints ?? { audio: true, video: { width: 1280, height: 720 } });
|
|
185
|
+
captured = media;
|
|
186
|
+
if (stopped())
|
|
187
|
+
throw stoppedWhileStarting();
|
|
188
|
+
this.ownsMedia = owns;
|
|
155
189
|
this.media = media;
|
|
156
190
|
const pc = new RTCPeerConnection();
|
|
157
191
|
this.pc = pc;
|
|
@@ -182,19 +216,43 @@ class BroadcastPublisher {
|
|
|
182
216
|
this.audioSender = transceiver.sender;
|
|
183
217
|
await pc.setLocalDescription(await pc.createOffer());
|
|
184
218
|
await iceGathered(pc);
|
|
219
|
+
if (stopped())
|
|
220
|
+
throw stoppedWhileStarting();
|
|
185
221
|
const offerSdp = pc.localDescription?.sdp;
|
|
186
222
|
if (!offerSdp)
|
|
187
223
|
throw new WhipError(0, 'could not create an offer in this browser');
|
|
188
224
|
const answer = await whipOffer(this.whipUrl, offerSdp);
|
|
225
|
+
if (stopped()) {
|
|
226
|
+
// The server opened a session for a start that is over: end it, as
|
|
227
|
+
// stop() would have, had it known of it.
|
|
228
|
+
if (answer.resource)
|
|
229
|
+
void whipEnd(answer.resource);
|
|
230
|
+
throw stoppedWhileStarting();
|
|
231
|
+
}
|
|
189
232
|
this.resource = answer.resource;
|
|
190
233
|
await pc.setRemoteDescription({ type: 'answer', sdp: answer.answerSdp });
|
|
234
|
+
if (stopped())
|
|
235
|
+
throw stoppedWhileStarting();
|
|
191
236
|
return media;
|
|
192
237
|
}
|
|
193
238
|
catch (err) {
|
|
239
|
+
if (stopped()) {
|
|
240
|
+
// stop() released what this start had handed over, and a newer
|
|
241
|
+
// start() may be on air now: only what arrived after stop() is ours
|
|
242
|
+
// to release here.
|
|
243
|
+
if (owns && captured)
|
|
244
|
+
for (const t of captured.getTracks())
|
|
245
|
+
t.stop();
|
|
246
|
+
throw stoppedWhileStarting();
|
|
247
|
+
}
|
|
194
248
|
this.teardown();
|
|
195
249
|
this.set('failed');
|
|
196
250
|
throw err;
|
|
197
251
|
}
|
|
252
|
+
finally {
|
|
253
|
+
if (this.starting === operation)
|
|
254
|
+
this.starting = null;
|
|
255
|
+
}
|
|
198
256
|
}
|
|
199
257
|
/**
|
|
200
258
|
* Put H.264 first, and offer nothing else for video.
|
|
@@ -271,8 +329,14 @@ class BroadcastPublisher {
|
|
|
271
329
|
for (const t of this.media?.getVideoTracks() ?? [])
|
|
272
330
|
t.enabled = enabled;
|
|
273
331
|
}
|
|
274
|
-
/**
|
|
332
|
+
/**
|
|
333
|
+
* Go off air and release the camera and microphone. Idempotent. A start()
|
|
334
|
+
* still under way is over: it rejects with an `AbortError`, and you can
|
|
335
|
+
* start again at once.
|
|
336
|
+
*/
|
|
275
337
|
async stop() {
|
|
338
|
+
this.operation += 1;
|
|
339
|
+
this.starting = null;
|
|
276
340
|
const resource = this.resource;
|
|
277
341
|
this.teardown();
|
|
278
342
|
if (resource)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../src/broadcast.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAiEH,8BA4BC;AAMD,0BAOC;AAxGD,yCAA4E;AAE5E,yDAAyD;AACzD,MAAa,SAAU,SAAQ,KAAK;IAIb;IAHrB;;OAEG;IACH,YAAqB,MAAc,EAAE,OAAe;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QADI,WAAM,GAAN,MAAM,CAAQ;QAEjC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC;IACpD,CAAC;CACF;AAjBD,8BAiBC;AAiCD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,kFAAkF;AAClF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAE/F;;;GAGG;AACI,KAAK,UAAU,SAAS,CAC7B,OAAe,EAC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C,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cjs/chat.d.ts
CHANGED
|
@@ -93,6 +93,11 @@ export declare class ChatClient {
|
|
|
93
93
|
private token;
|
|
94
94
|
private joinResult;
|
|
95
95
|
private closedByUs;
|
|
96
|
+
/**
|
|
97
|
+
* Bumped by close(). A connect() under way when it ran -- the app's, or a
|
|
98
|
+
* reconnect's -- sees the change after its await and stops.
|
|
99
|
+
*/
|
|
100
|
+
private lifecycle;
|
|
96
101
|
private reconnecting;
|
|
97
102
|
private reconnectAttempt;
|
|
98
103
|
/** Set by the first successful join. Only a session that has joined is reconnected. */
|
|
@@ -105,10 +110,18 @@ export declare class ChatClient {
|
|
|
105
110
|
connect(): Promise<ChatJoinResult>;
|
|
106
111
|
private openSocket;
|
|
107
112
|
private detachSocket;
|
|
113
|
+
/**
|
|
114
|
+
* A reconnect that ends the session lets go of its socket: a refused join
|
|
115
|
+
* leaves it open, and it would otherwise stay attached, and sending, after
|
|
116
|
+
* closed.
|
|
117
|
+
*/
|
|
118
|
+
private releaseSocket;
|
|
108
119
|
/** Single-flight, with backoff: the same shape as the room client's. */
|
|
109
120
|
private scheduleReconnect;
|
|
110
121
|
close(): void;
|
|
111
122
|
private rpc;
|
|
123
|
+
/** Fail what was sent on `ws` and is still waiting. */
|
|
124
|
+
private failPending;
|
|
112
125
|
private failAllPending;
|
|
113
126
|
private onMessage;
|
|
114
127
|
sendMessage(text: string, opts?: SendMessageOptions): Promise<{
|
package/dist/cjs/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/chat.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;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