Skip to content

Commit 92e88c4

Browse files
kixelatedclaude
andcommitted
Merge origin/dev into the Windows D3D11 backend branch
Dev landed #1720 (VAAPI reintroduction), which reworked the same moq-video files. The merge is clean: the Windows Media Foundation encoder and the Linux VAAPI encoder sit on separate cfg-gated candidate lines, and the Frame enum gains both Surface/Texture without collision. Re-ran taplo afterward, which normalized two column-width-150 arrays the merge surfaced: deny.toml's allow-git list (collapsed) and the cros-codecs dependency features in moq-video's Cargo.toml (expanded). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 parents 342a9fa + 1537ef9 commit 92e88c4

60 files changed

Lines changed: 1429 additions & 405 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 139 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,9 @@ strip = true
109109
# doesn't have that feature yet, so consume a fork branch until it's merged.
110110
[patch.crates-io]
111111
nvidia-video-codec-sdk = { git = "https://github.com/kixelated/nvidia-video-codec-sdk.git", branch = "dynamic-loading" }
112+
# moq-video's `vaapi` feature uses discord/cros-codecs (`vaapi_dlopen`), which
113+
# pulls cros-libva 0.0.13. The `dlopen` feature it needs (load libva at runtime
114+
# so a vaapi-enabled binary still links without libva-dev and still loads on a
115+
# libva-less machine, falling back to software) lives only on discord's fork, so
116+
# point the published 0.0.13 at it. Drop once `dlopen` is upstreamed.
117+
cros-libva = { git = "https://github.com/discord/cros-libva.git", branch = "discord-0.0.13" }

deny.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,8 @@ allow-registry = ["https://github.com/rust-lang/crates.io-index"]
7070
# moq-video patches nvidia-video-codec-sdk to a fork that adds dlopen
7171
# (`dynamic-loading`); see the root Cargo.toml [patch.crates-io]. Drop this once
7272
# the feature is upstreamed and the patch is removed.
73-
allow-git = ["https://github.com/kixelated/nvidia-video-codec-sdk"]
73+
#
74+
# The `vaapi` feature pulls discord/cros-codecs (the maintained fork: cros-libva
75+
# 0.0.13 + a hardened H.264 VAAPI encoder) and patches cros-libva to discord's
76+
# fork for the `dlopen` feature. Drop these once `dlopen` is upstreamed.
77+
allow-git = ["https://github.com/kixelated/nvidia-video-codec-sdk", "https://github.com/discord/cros-codecs", "https://github.com/discord/cros-libva"]

doc/bin/cli.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ moq-cli publish --url https://relay.example.com --broadcast cam.hang capture --n
9090

9191
Video capture uses a native per-platform backend (AVFoundation on macOS, V4L2 on
9292
Linux, Media Foundation on Windows) and picks a hardware H.264 encoder
93-
(VideoToolbox on macOS, NVENC on Linux NVIDIA) when one is present, falling back
94-
to the built-in software encoder (openh264); force either with `--hardware` /
95-
`--software`. `--camera` takes a bare integer as a device index, otherwise a
93+
(VideoToolbox on macOS, NVENC on Linux NVIDIA, VAAPI on Linux Intel/AMD) when one
94+
is present, falling back to the built-in software encoder (openh264); force either
95+
with `--hardware` / `--software`. `--camera` takes a bare integer as a device index, otherwise a
9696
device path (Linux) or name (a friendly-name substring on Windows, the
9797
AVFoundation `uniqueID` on macOS). Audio capture uses cpal (CoreAudio / WASAPI /
9898
ALSA) and encodes Opus.

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@
104104
# cpal's `alsa-sys` (moq-audio `capture` feature) links libasound on
105105
# Linux via pkg-config; macOS uses CoreAudio, so no dep there.
106106
pkgs.alsa-lib
107+
# moq-video `vaapi` feature: cros-libva runs bindgen against the libva
108+
# headers at build time (found via pkg-config), even though libva is
109+
# dlopen'd at runtime (`vaapi_dlopen`). macOS has no VAAPI.
110+
pkgs.libva
107111
];
108112

109113
# JavaScript dependencies

js/json/src/consumer.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ export class Consumer<T> {
3333
this.#framesRead = 0;
3434
}
3535

36-
const frame = await this.#group.readFrame();
36+
let frame: Uint8Array | undefined;
37+
try {
38+
frame = await this.#group.readFrame();
39+
} catch {
40+
// The group was reset or we fell behind its eviction window. Resync from
41+
// the next group, which begins with a fresh snapshot (frame 0), so no
42+
// partial state is presented.
43+
this.#group = undefined;
44+
continue;
45+
}
46+
3747
if (frame === undefined) {
3848
// The group is exhausted; advance to the next one.
3949
this.#group = undefined;

js/net/examples/publish.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ async function main() {
77
// Create a broadcast (a collection of tracks)
88
const broadcast = new Moq.Broadcast();
99

10+
// Insert the "chat" track up front. A subscriber is served directly from this
11+
// track, no requested() round-trip needed. Mirrors the Rust createTrack/insertTrack.
12+
publishTrack(broadcast.createTrack("chat"));
13+
1014
// Publish the broadcast to the connection
1115
connection.publish(Moq.Path.from("my-broadcast"), broadcast);
1216
console.log("Published broadcast: my-broadcast");
1317

14-
// Wait for subscription requests
18+
// Tracks created on demand (instead of up front) are still supported: handle any
19+
// subscribe for a track that wasn't statically inserted.
1520
for (;;) {
1621
const request = await broadcast.requested();
1722
if (!request) break;
1823

19-
// Accept the request for the "chat" track
20-
if (request.name === "chat") {
21-
// accept() commits the track's immutable properties and returns the Track.
22-
publishTrack(request.accept());
23-
} else {
24-
// Reject other tracks
25-
request.reject(new Error("track not found"));
26-
}
24+
// Reject anything we didn't insert above.
25+
request.reject(new Error("track not found"));
2726
}
2827
}
2928

0 commit comments

Comments
 (0)