@furious.luke/argus-js 0.5.1 → 0.5.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/README.md +7 -0
- package/dist/index.cjs +35 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,12 @@ Argus is a distributed video ingestion service. A stream flows through three par
|
|
|
17
17
|
|
|
18
18
|
This library is only the browser publishing half. It deliberately does **not** talk to the control plane or mint tokens — that requires your secret API key and must stay server-side.
|
|
19
19
|
|
|
20
|
+
Voice catalogue discovery and voice selection follow the same boundary. Your
|
|
21
|
+
server obtains the catalogue and includes its selected voice configuration when
|
|
22
|
+
creating the stream; the browser receives only its join token and gateway URLs.
|
|
23
|
+
`argus-js` therefore exposes the resulting assistant speech track but never a
|
|
24
|
+
voice configuration or control-plane credential.
|
|
25
|
+
|
|
20
26
|
```
|
|
21
27
|
┌──────────┐ 1. request join token ┌────────────┐
|
|
22
28
|
│ browser │ ───────────────────────▶ │ your server│ ──(API key)──▶ Argus control plane
|
|
@@ -181,6 +187,7 @@ the customer server owns a live control-token notify subscription.
|
|
|
181
187
|
| `gatewayHandshakeTimeoutMs` | `number` | Overall deadline for the initial gateway race and `accepted` → `ready` handshake. Unaccepted sockets are replaced after 3 seconds so a blackholed TCP flow cannot consume the full deadline. Defaults to 20 seconds. |
|
|
182
188
|
| `peerConnectionTimeoutMs` | `number` | Deadline after the initial offer for WebRTC to reach `connected`. Defaults to 30 seconds. |
|
|
183
189
|
| `signalingReconnectTimeoutMs` | `number` | How long to retry a dropped signaling socket against the selected regional gateway. Defaults to 20 seconds. |
|
|
190
|
+
| `preferredVideoCodecs` | `string[]` | Preferred video codecs, most-preferred first, as RTP MIME types (e.g. `"video/VP9"`, `"video/H264"`). Each published video track offers these ahead of the rest, so the browser sends the first one the media server also accepts. Defaults to `["video/VP9"]`. Pass `[]` to leave the browser's native order untouched. Codecs the browser lacks (or `setCodecPreferences` support, e.g. older Safari) are ignored — negotiation always falls back cleanly. |
|
|
184
191
|
| `callbacks` | `PublisherCallbacks` | Optional lifecycle callbacks (see below). |
|
|
185
192
|
|
|
186
193
|
### Methods & properties
|
package/dist/index.cjs
CHANGED
|
@@ -370,6 +370,7 @@ var Publisher = class {
|
|
|
370
370
|
};
|
|
371
371
|
if (initialTrack) {
|
|
372
372
|
const sender = initialTrack.type === "audio" ? this.addMicrophoneTrack(pc, initialTrack.track, initialTrack.stream) : pc.addTrack(initialTrack.track, initialTrack.stream);
|
|
373
|
+
if (initialTrack.type !== "audio") this.preferVideoCodecs(pc, sender);
|
|
373
374
|
this.typeSenders.set(
|
|
374
375
|
initialTrack.type,
|
|
375
376
|
sender
|
|
@@ -1580,6 +1581,39 @@ var Publisher = class {
|
|
|
1580
1581
|
this.microphoneTransceiver = transceiver;
|
|
1581
1582
|
return transceiver.sender;
|
|
1582
1583
|
}
|
|
1584
|
+
/**
|
|
1585
|
+
* Reorders the codecs a video sender offers so the browser prefers the
|
|
1586
|
+
* configured codecs (VP9 by default). This is what actually controls the wire
|
|
1587
|
+
* format: the browser is the offerer and sends its own top-of-offer codec, and
|
|
1588
|
+
* the media server (Pion) answers by mirroring the offer's codec order — so the
|
|
1589
|
+
* server's own registration order has no say. Floating VP9 to the front of the
|
|
1590
|
+
* offer is therefore the lever. Codecs not in the preference keep their native
|
|
1591
|
+
* order behind it, so anything VP9 can't satisfy still negotiates.
|
|
1592
|
+
*
|
|
1593
|
+
* Best-effort: browsers lacking `getCapabilities`/`setCodecPreferences` (older
|
|
1594
|
+
* Safari) keep their default order, and any failure is swallowed — codec
|
|
1595
|
+
* preference is an optimization, never a requirement for publishing.
|
|
1596
|
+
*/
|
|
1597
|
+
preferVideoCodecs(pc, sender) {
|
|
1598
|
+
const preferred = this.opts.preferredVideoCodecs ?? ["video/VP9"];
|
|
1599
|
+
if (preferred.length === 0) return;
|
|
1600
|
+
if (sender.track && sender.track.kind !== "video") return;
|
|
1601
|
+
if (typeof RTCRtpSender === "undefined" || typeof RTCRtpSender.getCapabilities !== "function") return;
|
|
1602
|
+
if (typeof pc.getTransceivers !== "function") return;
|
|
1603
|
+
const caps = RTCRtpSender.getCapabilities("video");
|
|
1604
|
+
if (!caps?.codecs) return;
|
|
1605
|
+
const transceiver = pc.getTransceivers().find((t) => t.sender === sender);
|
|
1606
|
+
if (!transceiver || typeof transceiver.setCodecPreferences !== "function") return;
|
|
1607
|
+
const rank = (mimeType) => {
|
|
1608
|
+
const idx = preferred.findIndex((p) => p.toLowerCase() === mimeType.toLowerCase());
|
|
1609
|
+
return idx === -1 ? preferred.length : idx;
|
|
1610
|
+
};
|
|
1611
|
+
const ordered = caps.codecs.map((codec, index) => ({ codec, index })).sort((a, b) => rank(a.codec.mimeType) - rank(b.codec.mimeType) || a.index - b.index).map((entry) => entry.codec);
|
|
1612
|
+
try {
|
|
1613
|
+
transceiver.setCodecPreferences(ordered);
|
|
1614
|
+
} catch {
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1583
1617
|
/** Registers one physical video track under its logical type and source stream. */
|
|
1584
1618
|
registerTrack(track, stream, type) {
|
|
1585
1619
|
this.published.set(track, type);
|
|
@@ -1653,6 +1687,7 @@ var Publisher = class {
|
|
|
1653
1687
|
throw new SenderRestoreError(`inactive ${type} sender still has a track`);
|
|
1654
1688
|
}
|
|
1655
1689
|
addedSender = pc.addTrack(track, stream);
|
|
1690
|
+
this.preferVideoCodecs(pc, addedSender);
|
|
1656
1691
|
this.typeSenders.set(type, addedSender);
|
|
1657
1692
|
}
|
|
1658
1693
|
return {
|