@ksp-gonogo/kerbcast 1.4.0
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 +186 -0
- package/LICENSE +369 -0
- package/README.md +112 -0
- package/dist/__generated__/types.d.ts +529 -0
- package/dist/__generated__/types.js +50 -0
- package/dist/client.d.ts +433 -0
- package/dist/client.js +821 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/noise.d.ts +34 -0
- package/dist/noise.js +274 -0
- package/dist/panZoom.d.ts +190 -0
- package/dist/panZoom.js +302 -0
- package/dist/testing/index.d.ts +217 -0
- package/dist/testing/index.js +606 -0
- package/package.json +57 -0
- package/src/__generated__/types.ts +488 -0
- package/src/client.test.ts +1673 -0
- package/src/client.ts +1219 -0
- package/src/domStubs.test.ts +49 -0
- package/src/index.ts +29 -0
- package/src/noise.test.ts +340 -0
- package/src/noise.ts +317 -0
- package/src/panZoom.test.ts +404 -0
- package/src/panZoom.ts +405 -0
- package/src/testing/index.ts +689 -0
- package/src/testing.test.ts +156 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.12.0 - 2026-06-07
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `BrowserKerbcastTransport` accepts an options object with `iceGatheringTimeoutMs`
|
|
8
|
+
(default 2000 ms). `waitForIceComplete` now resolves at the earlier of gathering
|
|
9
|
+
completing or the timeout, so connect does not stall the full STUN timeout on
|
|
10
|
+
LAN topologies where the STUN server is unreachable.
|
|
11
|
+
- `KerbcastClientConfig.iceGatheringTimeoutMs` threads the timeout into the default
|
|
12
|
+
transport when no custom transport is provided.
|
|
13
|
+
- `BrowserKerbcastTransportOptions` exported from the package root.
|
|
14
|
+
- `KerbcastPeer.getStats?()` optional method; `BrowserKerbcastTransport` implements
|
|
15
|
+
it via `RTCPeerConnection.getStats(null)`. Third-party transports and existing
|
|
16
|
+
mocks keep compiling without changes.
|
|
17
|
+
- `KerbcastClient.inboundVideoStats()` returns a `Map<number, InboundVideoStats>`
|
|
18
|
+
keyed by flightId. Resolves to an empty map when not connected or when the
|
|
19
|
+
transport does not implement `getStats`.
|
|
20
|
+
- `InboundVideoStats` type exported from the package root.
|
|
21
|
+
- `MockSidecar.setInboundStats(flightId, partialStats)` configures the stats the
|
|
22
|
+
fake `getStats()` returns, keyed by track id (legacy mode) or mid (dynamic mode).
|
|
23
|
+
- `DiscoveredCamera` widened to match the full `GET /cameras` payload: added
|
|
24
|
+
`lifecycle`, `panYawMin`, `panYawMax`, `panPitchMin`, `panPitchMax`,
|
|
25
|
+
`encoderBitrateBps`, `targetBitrateBps`, `degradeLevel`. `maxWidth`/`maxHeight`
|
|
26
|
+
were already present. Additive -- existing consumers that destructure only
|
|
27
|
+
the previous fields continue working unchanged.
|
|
28
|
+
- `PanZoomController` headless state machine for pan/zoom camera control.
|
|
29
|
+
Manages rate deduplication, analog deadzone, optimistic nudge accumulators,
|
|
30
|
+
FoV slider debounce, and echo-sync idle rules. `KerbcastCameraHandle`
|
|
31
|
+
satisfies `PanZoomCommandSink` structurally. Exported from the package root
|
|
32
|
+
along with `PanZoomCommandSink`, `PanZoomBounds`, and `PanZoomControllerOptions`.
|
|
33
|
+
|
|
34
|
+
## 0.3.1 — 2026-05-21
|
|
35
|
+
|
|
36
|
+
Export `KerbcastTransport`, `KerbcastPeer`, `KerbcastDataChannel` from
|
|
37
|
+
the package root. 0.3.0 introduced these as a public extension
|
|
38
|
+
point for tests and non-browser consumers but didn't re-export
|
|
39
|
+
them, so the only way to reference the types was a deep import
|
|
40
|
+
into `dist/client.d.ts`. Strictly additive — no behaviour change.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## 0.3.0 — 2026-05-21
|
|
44
|
+
|
|
45
|
+
High-level `KerbcastClient` class wraps the WebRTC peer, the
|
|
46
|
+
`kerbcast-control` data channel, per-camera state cache, and
|
|
47
|
+
per-track `MediaStream`s. Consumers no longer hand-roll
|
|
48
|
+
`RTCPeerConnection`, build JSON wire messages, or thread SDP offers
|
|
49
|
+
through `fetch`.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { KerbcastClient, Layer } from "@jonpepler/kerbcast";
|
|
53
|
+
|
|
54
|
+
const client = new KerbcastClient({ host: "192.168.1.74", port: 8088 });
|
|
55
|
+
await client.connect();
|
|
56
|
+
|
|
57
|
+
const cam = client.camera(2592004302);
|
|
58
|
+
await cam.setLayers([Layer.Near, Layer.Scaled]);
|
|
59
|
+
await cam.setFov(35);
|
|
60
|
+
await cam.setDegrade(0.5);
|
|
61
|
+
|
|
62
|
+
document.querySelector("video")!.srcObject = cam.mediaStream;
|
|
63
|
+
|
|
64
|
+
cam.on("change", (state) => { /* per-camera state delta */ });
|
|
65
|
+
client.on("adaptive-shed", (e) => { /* shed level + reason */ });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- `KerbcastClient` owns the peer, control channel, and registry of
|
|
71
|
+
cameras. `connect(flightIds?)`, `disconnect()`, `camera(flightId)`,
|
|
72
|
+
`discover()`.
|
|
73
|
+
- `KerbcastCameraHandle` exposes `setLayers`, `setRenderSize`,
|
|
74
|
+
`setFov`, `setPan`, `setDegrade`, `requestKeyframe`, plus a
|
|
75
|
+
`mediaStream` getter that yields the per-camera `MediaStream`
|
|
76
|
+
once the track arrives.
|
|
77
|
+
- Typed event API on both `KerbcastClient`
|
|
78
|
+
(`state-change` / `cameras-change` / `adaptive-shed` / `error`)
|
|
79
|
+
and `KerbcastCameraHandle` (`change` / `stream`). Subscribing
|
|
80
|
+
returns an unsubscribe function.
|
|
81
|
+
- `KerbcastTransport` interface — swappable transport for tests and
|
|
82
|
+
non-browser consumers. Default `BrowserKerbcastTransport` uses
|
|
83
|
+
`RTCPeerConnection`.
|
|
84
|
+
- `client.discover()` fetches the sidecar's `/cameras` listing
|
|
85
|
+
without opening a peer connection, for picking a subset to
|
|
86
|
+
`connect()` with.
|
|
87
|
+
|
|
88
|
+
### Restructured
|
|
89
|
+
|
|
90
|
+
- Generated wire-format types moved from `src/index.ts` to
|
|
91
|
+
`src/__generated__/types.ts`. `src/index.ts` is now hand-written
|
|
92
|
+
and re-exports both the generated types and the new client.
|
|
93
|
+
- Consumers that imported types from the package root keep working
|
|
94
|
+
(`import { ClientMessage } from "@jonpepler/kerbcast"` still
|
|
95
|
+
resolves to the same wire-format types).
|
|
96
|
+
|
|
97
|
+
Version line is shared with the Rust sidecar (`sidecar/Cargo.toml`).
|
|
98
|
+
CI verifies the two agree before any publish.
|
|
99
|
+
|
|
100
|
+
## 0.2.0 — 2026-05-21
|
|
101
|
+
|
|
102
|
+
New `set-degrade` client message and matching `degradeLevel` field
|
|
103
|
+
on `CameraState`. Lets consumers request artificial signal
|
|
104
|
+
degradation per camera (e.g. when in-game CommNet signal weakens);
|
|
105
|
+
sidecar applies `max` across active subscribers and squeezes the
|
|
106
|
+
encoder bitrate + skips a fraction of frames to produce the
|
|
107
|
+
macroblocking + stuttering aesthetic of real signal loss. Also a
|
|
108
|
+
real CPU optimisation: if every consumer wants degraded video, the
|
|
109
|
+
encoder runs lighter.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const msg: ClientMessage = {
|
|
113
|
+
type: "set-degrade",
|
|
114
|
+
content: { flightId: 2592004302, level: 0.7 },
|
|
115
|
+
};
|
|
116
|
+
dc.send(JSON.stringify(msg));
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Wire-format additions
|
|
120
|
+
|
|
121
|
+
- `ClientMessage::SetDegrade { flightId, level }` — level clamps to
|
|
122
|
+
`[0.0, 1.0]`; out-of-range values are clamped by the sidecar.
|
|
123
|
+
- `CameraState.degradeLevel` — sidecar-pushed effective degrade
|
|
124
|
+
(max across subscribers).
|
|
125
|
+
|
|
126
|
+
Additive: existing 0.1.0 consumers keep working — they just don't
|
|
127
|
+
see the new field unless they read it.
|
|
128
|
+
|
|
129
|
+
## 0.1.0 — 2026-05-21
|
|
130
|
+
|
|
131
|
+
Initial release as `@jonpepler/kerbcast` on GitHub Packages.
|
|
132
|
+
TypeScript bindings for the kerbcast sidecar's WebRTC data-channel
|
|
133
|
+
protocol, generated from Rust types via
|
|
134
|
+
[typeshare](https://github.com/1Password/typeshare).
|
|
135
|
+
|
|
136
|
+
### Client → server messages
|
|
137
|
+
|
|
138
|
+
- `hello` — handshake; server replies with `Hello` + `CameraSnapshot`.
|
|
139
|
+
- `set-layers` — operator layer mask per camera (`NEAR` / `SCALED` /
|
|
140
|
+
`GALAXY`).
|
|
141
|
+
- `set-render-size` — operator capture dimensions per camera (even
|
|
142
|
+
pixels, capped at the ring's allocated max).
|
|
143
|
+
- `set-fov` — operator FoV in degrees (silently rejected for fixed-FoV
|
|
144
|
+
parts; clients should clamp to `fovMin`/`fovMax` from the camera's
|
|
145
|
+
`CameraState`).
|
|
146
|
+
- `set-pan` — reserved for the future Hullcam VDS pan/tilt extension.
|
|
147
|
+
Rejected today on every shipping part (`supportsPan == false`).
|
|
148
|
+
- `request-keyframe` — recover the H.264 stream after packet loss.
|
|
149
|
+
|
|
150
|
+
### Server → client messages
|
|
151
|
+
|
|
152
|
+
- `hello` — reply to client `hello` with sidecar version + encoder
|
|
153
|
+
backend name.
|
|
154
|
+
- `camera-snapshot` — full state of every currently-attached camera.
|
|
155
|
+
Sent on handshake and after structural changes (vessel switch, ring
|
|
156
|
+
added / removed).
|
|
157
|
+
- `camera-state-changed` — single-camera delta on operator request or
|
|
158
|
+
adaptive event.
|
|
159
|
+
- `adaptive-shed` — KSP-FPS adaptive shedding level changed; carries a
|
|
160
|
+
human-readable `reason` so client UIs can show *why* quality
|
|
161
|
+
changed rather than just *that* it did.
|
|
162
|
+
- `error` — malformed / invalid client message.
|
|
163
|
+
|
|
164
|
+
### Per-camera capabilities
|
|
165
|
+
|
|
166
|
+
`CameraState` exposes feature flags so clients can render controls
|
|
167
|
+
only for what each part advertises:
|
|
168
|
+
|
|
169
|
+
- `supportsZoom`, `fov`, `fovMin`, `fovMax` — true for parts whose
|
|
170
|
+
Hullcam module is `MuMechModuleHullCameraZoom` (19 of 21 stock
|
|
171
|
+
Hullcam VDS parts).
|
|
172
|
+
- `supportsPan`, `panYawMin`/`Max`, `panPitchMin`/`Max`, `panYaw`,
|
|
173
|
+
`panPitch` — reserved; always false on shipping parts.
|
|
174
|
+
- `encoderBitrateBps`, `targetBitrateBps` — current encoder bitrate
|
|
175
|
+
and REMB-driven target. Diverge briefly when receivers' bandwidth
|
|
176
|
+
estimates move; converge after the consume loop's next bitrate
|
|
177
|
+
threshold check.
|
|
178
|
+
|
|
179
|
+
### Wire format
|
|
180
|
+
|
|
181
|
+
JSON-per-message over an `RTCDataChannel` labelled `kerbcast-control`,
|
|
182
|
+
opened by the browser after SDP exchange completes. Messages use
|
|
183
|
+
adjacent tagging — `{ "type": "set-layers", "content": { ... } }` —
|
|
184
|
+
because that's the discriminator shape typeshare can faithfully model
|
|
185
|
+
across TypeScript / Kotlin / Swift / Scala / Go. Unit variants
|
|
186
|
+
(`hello`) carry no `content`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
kerbcast
|
|
2
|
+
Copyright (c) 2026 Jon Pepler
|
|
3
|
+
|
|
4
|
+
This work is licensed under the Creative Commons
|
|
5
|
+
Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
6
|
+
Full legal text follows.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
|
|
10
|
+
Public License
|
|
11
|
+
|
|
12
|
+
By exercising the Licensed Rights (defined below), You accept and agree
|
|
13
|
+
to be bound by the terms and conditions of this Creative Commons
|
|
14
|
+
Attribution-NonCommercial-ShareAlike 4.0 International Public License
|
|
15
|
+
("Public License"). To the extent this Public License may be
|
|
16
|
+
interpreted as a contract, You are granted the Licensed Rights in
|
|
17
|
+
consideration of Your acceptance of these terms and conditions, and the
|
|
18
|
+
Licensor grants You such rights in consideration of benefits the
|
|
19
|
+
Licensor receives from making the Licensed Material available under
|
|
20
|
+
these terms and conditions.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Section 1 -- Definitions.
|
|
24
|
+
|
|
25
|
+
a. Adapted Material means material subject to Copyright and Similar
|
|
26
|
+
Rights that is derived from or based upon the Licensed Material
|
|
27
|
+
and in which the Licensed Material is translated, altered,
|
|
28
|
+
arranged, transformed, or otherwise modified in a manner requiring
|
|
29
|
+
permission under the Copyright and Similar Rights held by the
|
|
30
|
+
Licensor. For purposes of this Public License, where the Licensed
|
|
31
|
+
Material is a musical work, performance, or sound recording,
|
|
32
|
+
Adapted Material is always produced where the Licensed Material is
|
|
33
|
+
synched in timed relation with a moving image.
|
|
34
|
+
|
|
35
|
+
b. Adapter's License means the license You apply to Your Copyright
|
|
36
|
+
and Similar Rights in Your contributions to Adapted Material in
|
|
37
|
+
accordance with the terms and conditions of this Public License.
|
|
38
|
+
|
|
39
|
+
c. BY-NC-SA Compatible License means a license listed at
|
|
40
|
+
creativecommons.org/compatiblelicenses, approved by Creative
|
|
41
|
+
Commons as essentially the equivalent of this Public License.
|
|
42
|
+
|
|
43
|
+
d. Copyright and Similar Rights means copyright and/or similar rights
|
|
44
|
+
closely related to copyright including, without limitation,
|
|
45
|
+
performance, broadcast, sound recording, and Sui Generis Database
|
|
46
|
+
Rights, without regard to how the rights are labeled or
|
|
47
|
+
categorized. For purposes of this Public License, the rights
|
|
48
|
+
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
49
|
+
Rights.
|
|
50
|
+
|
|
51
|
+
e. Effective Technological Measures means those measures that, in the
|
|
52
|
+
absence of proper authority, may not be circumvented under laws
|
|
53
|
+
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
54
|
+
Treaty adopted on December 20, 1996, and/or similar international
|
|
55
|
+
agreements.
|
|
56
|
+
|
|
57
|
+
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
58
|
+
any other exception or limitation to Copyright and Similar Rights
|
|
59
|
+
that applies to Your use of the Licensed Material.
|
|
60
|
+
|
|
61
|
+
g. License Elements means the license attributes listed in the name
|
|
62
|
+
of a Creative Commons Public License. The License Elements of this
|
|
63
|
+
Public License are Attribution, NonCommercial, and ShareAlike.
|
|
64
|
+
|
|
65
|
+
h. Licensed Material means the artistic or literary work, database,
|
|
66
|
+
or other material to which the Licensor applied this Public
|
|
67
|
+
License.
|
|
68
|
+
|
|
69
|
+
i. Licensed Rights means the rights granted to You subject to the
|
|
70
|
+
terms and conditions of this Public License, which are limited to
|
|
71
|
+
all Copyright and Similar Rights that apply to Your use of the
|
|
72
|
+
Licensed Material and that the Licensor has authority to license.
|
|
73
|
+
|
|
74
|
+
j. Licensor means the individual(s) or entity(ies) granting rights
|
|
75
|
+
under this Public License.
|
|
76
|
+
|
|
77
|
+
k. NonCommercial means not primarily intended for or directed towards
|
|
78
|
+
commercial advantage or monetary compensation. For purposes of
|
|
79
|
+
this Public License, the exchange of the Licensed Material for
|
|
80
|
+
other material subject to Copyright and Similar Rights by digital
|
|
81
|
+
file-sharing or similar means is NonCommercial provided there is
|
|
82
|
+
no payment of monetary compensation in connection with the
|
|
83
|
+
exchange.
|
|
84
|
+
|
|
85
|
+
l. Share means to provide material to the public by any means or
|
|
86
|
+
process that requires permission under the Licensed Rights, such
|
|
87
|
+
as reproduction, public display, public performance, distribution,
|
|
88
|
+
dissemination, communication, or importation, and to make material
|
|
89
|
+
available to the public including in ways that members of the
|
|
90
|
+
public may access the material from a place and at a time
|
|
91
|
+
individually chosen by them.
|
|
92
|
+
|
|
93
|
+
m. Sui Generis Database Rights means rights other than copyright
|
|
94
|
+
resulting from Directive 96/9/EC of the European Parliament and of
|
|
95
|
+
the Council of 11 March 1996 on the legal protection of databases,
|
|
96
|
+
as amended and/or succeeded, as well as other essentially
|
|
97
|
+
equivalent rights anywhere in the world.
|
|
98
|
+
|
|
99
|
+
n. You means the individual or entity exercising the Licensed Rights
|
|
100
|
+
under this Public License. Your has a corresponding meaning.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
Section 2 -- Scope.
|
|
104
|
+
|
|
105
|
+
a. License grant.
|
|
106
|
+
|
|
107
|
+
1. Subject to the terms and conditions of this Public License,
|
|
108
|
+
the Licensor hereby grants You a worldwide, royalty-free,
|
|
109
|
+
non-sublicensable, non-exclusive, irrevocable license to
|
|
110
|
+
exercise the Licensed Rights in the Licensed Material to:
|
|
111
|
+
|
|
112
|
+
a. reproduce and Share the Licensed Material, in whole or
|
|
113
|
+
in part, for NonCommercial purposes only; and
|
|
114
|
+
|
|
115
|
+
b. produce, reproduce, and Share Adapted Material for
|
|
116
|
+
NonCommercial purposes only.
|
|
117
|
+
|
|
118
|
+
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
119
|
+
Exceptions and Limitations apply to Your use, this Public
|
|
120
|
+
License does not apply, and You do not need to comply with
|
|
121
|
+
its terms and conditions.
|
|
122
|
+
|
|
123
|
+
3. Term. The term of this Public License is specified in Section
|
|
124
|
+
6(a).
|
|
125
|
+
|
|
126
|
+
4. Media and formats; technical modifications allowed. The
|
|
127
|
+
Licensor authorizes You to exercise the Licensed Rights in
|
|
128
|
+
all media and formats whether now known or hereafter created,
|
|
129
|
+
and to make technical modifications necessary to do so. The
|
|
130
|
+
Licensor waives and/or agrees not to assert any right or
|
|
131
|
+
authority to forbid You from making technical modifications
|
|
132
|
+
necessary to exercise the Licensed Rights, including
|
|
133
|
+
technical modifications necessary to circumvent Effective
|
|
134
|
+
Technological Measures. For purposes of this Public License,
|
|
135
|
+
simply making modifications authorized by this Section 2(a)
|
|
136
|
+
(4) never produces Adapted Material.
|
|
137
|
+
|
|
138
|
+
5. Downstream recipients.
|
|
139
|
+
|
|
140
|
+
a. Offer from the Licensor -- Licensed Material. Every
|
|
141
|
+
recipient of the Licensed Material automatically
|
|
142
|
+
receives an offer from the Licensor to exercise the
|
|
143
|
+
Licensed Rights under the terms and conditions of this
|
|
144
|
+
Public License.
|
|
145
|
+
|
|
146
|
+
b. Additional offer from the Licensor -- Adapted Material.
|
|
147
|
+
Every recipient of Adapted Material from You
|
|
148
|
+
automatically receives an offer from the Licensor to
|
|
149
|
+
exercise the Licensed Rights in the Adapted Material
|
|
150
|
+
under the conditions of the Adapter's License You apply.
|
|
151
|
+
|
|
152
|
+
c. No downstream restrictions. You may not offer or impose
|
|
153
|
+
any additional or different terms or conditions on, or
|
|
154
|
+
apply any Effective Technological Measures to, the
|
|
155
|
+
Licensed Material if doing so restricts exercise of the
|
|
156
|
+
Licensed Rights by any recipient of the Licensed
|
|
157
|
+
Material.
|
|
158
|
+
|
|
159
|
+
6. No endorsement. Nothing in this Public License constitutes or
|
|
160
|
+
may be construed as permission to assert or imply that You
|
|
161
|
+
are, or that Your use of the Licensed Material is, connected
|
|
162
|
+
with, or sponsored, endorsed, or granted official status by,
|
|
163
|
+
the Licensor or others designated to receive attribution as
|
|
164
|
+
provided in Section 3(a)(1)(A)(i).
|
|
165
|
+
|
|
166
|
+
b. Other rights.
|
|
167
|
+
|
|
168
|
+
1. Moral rights, such as the right of integrity, are not
|
|
169
|
+
licensed under this Public License, nor are publicity,
|
|
170
|
+
privacy, and/or other similar personality rights; however, to
|
|
171
|
+
the extent possible, the Licensor waives and/or agrees not to
|
|
172
|
+
assert any such rights held by the Licensor to the limited
|
|
173
|
+
extent necessary to allow You to exercise the Licensed
|
|
174
|
+
Rights, but not otherwise.
|
|
175
|
+
|
|
176
|
+
2. Patent and trademark rights are not licensed under this
|
|
177
|
+
Public License.
|
|
178
|
+
|
|
179
|
+
3. To the extent possible, the Licensor waives any right to
|
|
180
|
+
collect royalties from You for the exercise of the Licensed
|
|
181
|
+
Rights, whether directly or through a collecting society
|
|
182
|
+
under any voluntary or waivable statutory or compulsory
|
|
183
|
+
licensing scheme. In all other cases the Licensor expressly
|
|
184
|
+
reserves any right to collect such royalties, including when
|
|
185
|
+
the Licensed Material is used other than for NonCommercial
|
|
186
|
+
purposes.
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
Section 3 -- License Conditions.
|
|
190
|
+
|
|
191
|
+
Your exercise of the Licensed Rights is expressly made subject to the
|
|
192
|
+
following conditions.
|
|
193
|
+
|
|
194
|
+
a. Attribution.
|
|
195
|
+
|
|
196
|
+
1. If You Share the Licensed Material (including in modified
|
|
197
|
+
form), You must:
|
|
198
|
+
|
|
199
|
+
a. retain the following if it is supplied by the Licensor
|
|
200
|
+
with the Licensed Material:
|
|
201
|
+
|
|
202
|
+
i. identification of the creator(s) of the Licensed
|
|
203
|
+
Material and any others designated to receive
|
|
204
|
+
attribution, in any reasonable manner requested by
|
|
205
|
+
the Licensor (including by pseudonym if
|
|
206
|
+
designated);
|
|
207
|
+
|
|
208
|
+
ii. a copyright notice;
|
|
209
|
+
|
|
210
|
+
iii. a notice that refers to this Public License;
|
|
211
|
+
|
|
212
|
+
iv. a notice that refers to the disclaimer of
|
|
213
|
+
warranties;
|
|
214
|
+
|
|
215
|
+
v. a URI or hyperlink to the Licensed Material to the
|
|
216
|
+
extent reasonably practicable;
|
|
217
|
+
|
|
218
|
+
b. indicate if You modified the Licensed Material and
|
|
219
|
+
retain an indication of any previous modifications; and
|
|
220
|
+
|
|
221
|
+
c. indicate the Licensed Material is licensed under this
|
|
222
|
+
Public License, and include the text of, or the URI or
|
|
223
|
+
hyperlink to, this Public License.
|
|
224
|
+
|
|
225
|
+
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
226
|
+
reasonable manner based on the medium, means, and context in
|
|
227
|
+
which You Share the Licensed Material. For example, it may be
|
|
228
|
+
reasonable to satisfy the conditions by providing a URI or
|
|
229
|
+
hyperlink to a resource that includes the required
|
|
230
|
+
information.
|
|
231
|
+
3. If requested by the Licensor, You must remove any of the
|
|
232
|
+
information required by Section 3(a)(1)(A) to the extent
|
|
233
|
+
reasonably practicable.
|
|
234
|
+
|
|
235
|
+
b. ShareAlike.
|
|
236
|
+
|
|
237
|
+
In addition to the conditions in Section 3(a), if You Share
|
|
238
|
+
Adapted Material You produce, the following conditions also apply.
|
|
239
|
+
|
|
240
|
+
1. The Adapter's License You apply must be a Creative Commons
|
|
241
|
+
license with the same License Elements, this version or
|
|
242
|
+
later, or a BY-NC-SA Compatible License.
|
|
243
|
+
|
|
244
|
+
2. You must include the text of, or the URI or hyperlink to, the
|
|
245
|
+
Adapter's License You apply. You may satisfy this condition
|
|
246
|
+
in any reasonable manner based on the medium, means, and
|
|
247
|
+
context in which You Share Adapted Material.
|
|
248
|
+
|
|
249
|
+
3. You may not offer or impose any additional or different terms
|
|
250
|
+
or conditions on, or apply any Effective Technological
|
|
251
|
+
Measures to, Adapted Material that restrict exercise of the
|
|
252
|
+
rights granted under the Adapter's License You apply.
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
Section 4 -- Sui Generis Database Rights.
|
|
256
|
+
|
|
257
|
+
Where the Licensed Rights include Sui Generis Database Rights that
|
|
258
|
+
apply to Your use of the Licensed Material:
|
|
259
|
+
|
|
260
|
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
261
|
+
to extract, reuse, reproduce, and Share all or a substantial
|
|
262
|
+
portion of the contents of the database for NonCommercial purposes
|
|
263
|
+
only;
|
|
264
|
+
|
|
265
|
+
b. if You include all or a substantial portion of the database
|
|
266
|
+
contents in a database in which You have Sui Generis Database
|
|
267
|
+
Rights, then the database in which You have Sui Generis Database
|
|
268
|
+
Rights (but not its individual contents) is Adapted Material,
|
|
269
|
+
including for purposes of Section 3(b); and
|
|
270
|
+
|
|
271
|
+
c. You must comply with the conditions in Section 3(a) if You Share
|
|
272
|
+
all or a substantial portion of the contents of the database.
|
|
273
|
+
|
|
274
|
+
For the avoidance of doubt, this Section 4 supplements and does not
|
|
275
|
+
replace Your obligations under this Public License where the Licensed
|
|
276
|
+
Rights include other Copyright and Similar Rights.
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
280
|
+
|
|
281
|
+
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
282
|
+
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
283
|
+
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
284
|
+
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
285
|
+
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
286
|
+
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
287
|
+
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
288
|
+
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
289
|
+
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
290
|
+
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
291
|
+
|
|
292
|
+
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
293
|
+
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
294
|
+
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
295
|
+
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
296
|
+
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
297
|
+
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
298
|
+
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
299
|
+
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
300
|
+
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
301
|
+
|
|
302
|
+
c. The disclaimer of warranties and limitation of liability provided
|
|
303
|
+
above shall be interpreted in a manner that, to the extent
|
|
304
|
+
possible, most closely approximates an absolute disclaimer and
|
|
305
|
+
waiver of all liability.
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
Section 6 -- Term and Termination.
|
|
309
|
+
|
|
310
|
+
a. This Public License applies for the term of the Copyright and
|
|
311
|
+
Similar Rights licensed here. However, if You fail to comply with
|
|
312
|
+
this Public License, then Your rights under this Public License
|
|
313
|
+
terminate automatically.
|
|
314
|
+
|
|
315
|
+
b. Where Your right to use the Licensed Material has terminated under
|
|
316
|
+
Section 6(a), it reinstates:
|
|
317
|
+
|
|
318
|
+
1. automatically as of the date the violation is cured, provided
|
|
319
|
+
it is cured within 30 days of Your discovery of the
|
|
320
|
+
violation; or
|
|
321
|
+
|
|
322
|
+
2. upon express reinstatement by the Licensor.
|
|
323
|
+
|
|
324
|
+
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
325
|
+
right the Licensor may have to seek remedies for Your violations
|
|
326
|
+
of this Public License.
|
|
327
|
+
|
|
328
|
+
c. For the avoidance of doubt, the Licensor may also offer the
|
|
329
|
+
Licensed Material under separate terms or conditions or stop
|
|
330
|
+
distributing the Licensed Material at any time; however, doing so
|
|
331
|
+
will not terminate this Public License.
|
|
332
|
+
|
|
333
|
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
334
|
+
License.
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
Section 7 -- Other Terms and Conditions.
|
|
338
|
+
|
|
339
|
+
a. The Licensor shall not be bound by any additional or different
|
|
340
|
+
terms or conditions communicated by You unless expressly agreed.
|
|
341
|
+
|
|
342
|
+
b. Any arrangements, understandings, or agreements regarding the
|
|
343
|
+
Licensed Material not stated herein are separate from and
|
|
344
|
+
independent of the terms and conditions of this Public License.
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
Section 8 -- Interpretation.
|
|
348
|
+
|
|
349
|
+
a. For the avoidance of doubt, this Public License does not, and
|
|
350
|
+
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
351
|
+
conditions on any use of the Licensed Material that could lawfully
|
|
352
|
+
be made without permission under this Public License.
|
|
353
|
+
|
|
354
|
+
b. To the extent possible, if any provision of this Public License is
|
|
355
|
+
deemed unenforceable, it shall be automatically reformed to the
|
|
356
|
+
minimum extent necessary to make it enforceable. If the provision
|
|
357
|
+
cannot be reformed, it shall be severed from this Public License
|
|
358
|
+
without affecting the enforceability of the remaining terms and
|
|
359
|
+
conditions.
|
|
360
|
+
|
|
361
|
+
c. No term or condition of this Public License will be waived and no
|
|
362
|
+
failure to comply consented to unless expressly agreed to by the
|
|
363
|
+
Licensor.
|
|
364
|
+
|
|
365
|
+
d. Nothing in this Public License constitutes or may be interpreted
|
|
366
|
+
as a limitation upon, or waiver of, any privileges and immunities
|
|
367
|
+
that apply to the Licensor or You, including from the legal
|
|
368
|
+
processes of any jurisdiction or authority.
|
|
369
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @ksp-gonogo/kerbcast
|
|
2
|
+
|
|
3
|
+
TypeScript client for the kerbcast sidecar. Used by browsers and other
|
|
4
|
+
clients that consume the sidecar's H.264 streams.
|
|
5
|
+
|
|
6
|
+
`KerbcastClient` owns the WebRTC peer, the `kerbcast-control` data
|
|
7
|
+
channel, and the per-camera state cache and `MediaStream`s.
|
|
8
|
+
Consumers get a high-level RPC surface plus typed event
|
|
9
|
+
subscriptions. The wire-format types are still exported for anyone
|
|
10
|
+
rolling their own transport.
|
|
11
|
+
|
|
12
|
+
The Rust crate and this package ship the same SemVer version,
|
|
13
|
+
bumped together by `./scripts/bump-version.sh`.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
Hosted on public npm. No registry route or auth needed:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm add @ksp-gonogo/kerbcast
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Use
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { KerbcastClient, Layer } from "@ksp-gonogo/kerbcast";
|
|
27
|
+
|
|
28
|
+
const client = new KerbcastClient({ host: "192.168.1.74", port: 8088 });
|
|
29
|
+
await client.connect();
|
|
30
|
+
|
|
31
|
+
const cam = client.camera(2592004302);
|
|
32
|
+
await cam.setLayers([Layer.Near, Layer.Scaled]);
|
|
33
|
+
await cam.setFov(35);
|
|
34
|
+
await cam.setRenderSize(384, 384);
|
|
35
|
+
await cam.setDegrade(0.5);
|
|
36
|
+
|
|
37
|
+
const videoEl = document.querySelector("video")!;
|
|
38
|
+
videoEl.srcObject = cam.mediaStream;
|
|
39
|
+
|
|
40
|
+
cam.on("change", (state) => {
|
|
41
|
+
console.log("camera state", state);
|
|
42
|
+
});
|
|
43
|
+
client.on("adaptive-shed", (event) => {
|
|
44
|
+
console.log("shed level", event.level, "ksp fps", event.kspFps);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Tear down when done.
|
|
48
|
+
client.disconnect();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Pre-handshake discovery
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const cameras = await client.discover();
|
|
55
|
+
// Pick the cameras you want, then connect with that subset.
|
|
56
|
+
await client.connect(cameras.slice(0, 2).map((c) => c.flightId));
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Lower-level access
|
|
60
|
+
|
|
61
|
+
The wire-format types are also exported for consumers that want to
|
|
62
|
+
roll their own transport (a Node.js consumer outside a browser, a
|
|
63
|
+
test harness, an alternative-language gateway, etc).
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import type { ClientMessage } from "@ksp-gonogo/kerbcast";
|
|
67
|
+
|
|
68
|
+
declare const controlChannel: RTCDataChannel;
|
|
69
|
+
|
|
70
|
+
const setLayers: ClientMessage = {
|
|
71
|
+
type: "set-layers",
|
|
72
|
+
content: { flightId: 2592004302, layers: ["NEAR", "SCALED"] },
|
|
73
|
+
};
|
|
74
|
+
controlChannel.send(JSON.stringify(setLayers));
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Per-camera capabilities
|
|
78
|
+
|
|
79
|
+
`CameraState` includes capability flags so consumers render only the
|
|
80
|
+
controls each part actually supports.
|
|
81
|
+
|
|
82
|
+
- `supportsZoom`, `fov`, `fovMin`, `fovMax`. 19 of 21 stock Hullcam
|
|
83
|
+
VDS parts support runtime FoV via `MuMechModuleHullCameraZoom`.
|
|
84
|
+
- `supportsPan`, `panYawMin/Max`, `panPitchMin/Max`. Reserved for the
|
|
85
|
+
planned mod extension that adds steerable mounts. Always `false`
|
|
86
|
+
right now.
|
|
87
|
+
- `encoderBitrateBps`, `targetBitrateBps`. Current encoder bitrate
|
|
88
|
+
and the REMB-driven target. They diverge briefly when receivers'
|
|
89
|
+
bandwidth estimates move.
|
|
90
|
+
- `degradeLevel`. Effective signal-degradation level (max across
|
|
91
|
+
subscribers). Sidecar applies it via bitrate squeeze plus frame
|
|
92
|
+
skip, producing the macroblocking and stuttering aesthetic of
|
|
93
|
+
in-game CommNet signal loss. Also a real CPU optimisation when
|
|
94
|
+
every consumer wants degraded video.
|
|
95
|
+
|
|
96
|
+
## Multi-language
|
|
97
|
+
|
|
98
|
+
`typeshare` also generates Kotlin, Swift, Scala, and Go. Those
|
|
99
|
+
land alongside `client-sdk/typescript/` as consumers appear. A C#
|
|
100
|
+
binding is pending an upstream `typeshare` C# generator or a
|
|
101
|
+
hand-written shim.
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
[CC BY-NC-SA 4.0](https://github.com/ksp-gonogo/kerbcast/blob/main/LICENSE).
|
|
106
|
+
|
|
107
|
+
## Versioning
|
|
108
|
+
|
|
109
|
+
[SemVer](https://semver.org/) against the wire format and client
|
|
110
|
+
API. See [CHANGELOG.md](https://github.com/ksp-gonogo/kerbcast/blob/main/client-sdk/typescript/CHANGELOG.md).
|
|
111
|
+
While the protocol is at `0.x`, any minor bump may require consumer
|
|
112
|
+
updates. Strict SemVer applies at `1.0.0`.
|