# Local integration / third-party software

GameShelf v0.3 adds an application-level secure-context WebCodecs-first selection, keeping both colour and alpha decoding separate. The pinned vendor code/binaries and local patches below have not changed for v0.3. WebCodecs-unsupported initialization can fall back to the separate software WASM engine; it never selects the vendor's browser/native-video engine. Hardware decoding is not guaranteed by the WebCodecs API. HTTPS server and frame-timestamp speed metrics live in GameShelf's own code.

Pinned: alpha-video-web 1.0.2, range-source-web 1.1.0. Download URLs and archive SHA-256 are in `provenance.json`. Original npm archives are kept at the project root. `python tools/prepare-vendor.py` verifies checksums, re-extracts them and applies the local JS changes reproducibly. The WASM binaries are unchanged.

## Licensing

- alpha-video-web JS and range-source-web: MIT. See their respective `LICENSE` files.
- The demuxer includes libwebm (BSD-3-Clause plus WebM patent grant).
- VP8/VP9 WASM Workers include FFmpeg 6.1 libavcodec/libavutil (LGPL-2.1-or-later). They are separate, replaceable ESM files; do not classify the whole bundle as MIT. The package's `THIRD_PARTY_NOTICES.md`, `licenses/LGPL-2.1.txt`, `licenses/FFmpeg-LICENSE.md` and libwebm notices are shipped in dist.
- The upstream package also contains optional AV1/dav1d modules (BSD-2-Clause). Their notice is retained. GameShelf B rejects non-VP8/VP9 input.

Sources and build instructions: [upstream repository](https://github.com/MediaCacheDev/alpha-video), `scripts/build_wasm.sh`, `web/scripts/inline-worker.mjs`. The upstream `THIRD_PARTY_NOTICES.md` lists FFmpeg 6.1 source at https://ffmpeg.org/releases/ffmpeg-6.1.tar.xz and its SHA-256. To modify FFmpeg, rebuild the vpx decoder Workers using the upstream instructions and replace `dist/decode-worker-vpx-*.mjs`; the application imports them dynamically, without a signature restriction. Windows can run the prepared bundle without Emscripten. Rebuilding upstream C/C++ is a separate toolchain task.

## Local JS changes

In alpha-video-web `dist/index.mjs` and `dist/chunk-RTUK4AWF.mjs`, replace the bare range-source-web import with a same-origin relative import (no package manager at runtime). In the latter file:

- Add actual Worker creation/termination, texture allocation/deletion/context loss, renderer, frame and shared-context counters (`gameShelfDiagnostics`).
- Add composited-frame callback with timestamp/canvas, and codec/duration metadata. This permits progress watchdogs and an alpha-pixel check of trusted built-in fixtures.
- Stop the animation callback immediately if a frame hook destroys the player.
- Advance the playback clock with a bounded (max 1 second) elapsed step even if visible-page requestAnimationFrame is delayed beyond 250ms. The upstream clock discarded these steps entirely, which froze visible but throttled browser previews. GameShelf already cancels on document.hidden. Log long rendering gaps separately; completion does not imply full frame rate.
- Delete compiled vertex/fragment shaders after linking; the shared context/program remain for the page. One shared context prevents the Safari context-count exhaustion caused by creating/losing one context per clip. Idle drawing buffer shrinks to 1×1.
- Propagate AbortSignal to decoder Worker startup and terminate a starting Worker on cancel. Per-player Workers, textures, frame buffers and demuxer handles are closed on destroy.

The shared demuxer WASM module, one WebGL context/program, and a cached Worker-script Blob URL per loaded decoder kind intentionally live for the page. They are not per-play allocations, do not accumulate across 100 switches, and are released on page teardown. Diagnostic video URL counters do not include this explicitly reported Worker-script cache.

No code detects or modifies the user's game files. No Worker or WASM is fetched from a CDN.
