Browser (WebAssembly)

The nc-web crate compiles our encoders and decoders to WebAssembly with wasm-bindgen. The demo runs on this module; so can your page. Every codec the native build has is in it.

Build the module

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli --version 0.2.105 --locked
tools/web/build.sh        # writes web/pkg/ and web/pkg/relaxed/

Each directory holds nc_web.js (an ES module) and nc_web_bg.wasm. The two builds give bit-identical output: pkg/ uses SIMD128, pkg/relaxed/ adds relaxed SIMD. web/wasm.js picks the relaxed build where WebAssembly.validate accepts a relaxed-SIMD probe, else the plain one.

Browser support

The JavaScript API

Minimal standalone page

Draws a moving picture on a canvas, encodes it with H.264 at 300 kbps, decodes every packet and draws the decoded picture beside the source. It loads the demo's module from ../../pkg/: run it here. To use it elsewhere, copy it next to a pkg/ directory from the build and change the import path; serve it over HTTP, as browsers do not load modules from file:// pages.

Loading…