@signageos/samsung-wasm-decoder
v0.1.0
Published
Standalone H.264 video decoder for Samsung Tizen TVs using WASM EMSS (ElementaryMediaStreamSource) + a `<video>` element.
Keywords
Readme
samsung-wasm-decoder
Standalone H.264 video decoder for Samsung Tizen TVs using WASM EMSS (ElementaryMediaStreamSource) + a <video> element.
JS/TS API
This package exports:
createSamsungWasmDecoder(options)– creates a WASM-backed decoder instanceisSamsungWasmSupported()– checks WebAssembly + Samsung EMSS availabilitySamsungWasmDecoder(class)VideoDecoder(interface)ResultStatus(enum)
Rendering happens via a <video> element (default id: video-element).
Expected runtime
The TS wrapper expects an Emscripten module instance available as:
window.SamsungWasmDecoderModule
The native module must export the C functions declared in native/decoder.cpp.
Build
Prerequisites
- Samsung customized Emscripten SDK (the one that provides Tizen WebAssembly extensions)
- Node.js (for TypeScript compilation)
Compile
# Build both native WASM and TypeScript
make buildThis will:
- Download Samsung's Emscripten SDK (if not present)
- Compile the native C++ code to WASM
- Compile the TypeScript wrapper
Outputs:
dist/samsung-wasm-decoder.js– Emscripten-generated JS loaderdist/samsung-wasm-decoder.wasm– WebAssembly moduledist/index.js– TypeScript compiled wrapper
Build flags
The Makefile uses required flags for Samsung Tizen EMSS:
-s ENVIRONMENT_MAY_BE_TIZEN– enables Samsung Tizen Emscripten extensions (required for EMSS)-pthread -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=1– EMSS requires pthreads support
Runtime loading
The native build is modularized (-s MODULARIZE=1 -s EXPORT_NAME=SamsungWasmDecoderModule). The generated samsung-wasm-decoder.js exports a factory function.
You must instantiate it and assign the resulting module instance to window.SamsungWasmDecoderModule before calling createSamsungWasmDecoder():
// Include the generated JS via <script> and then:
window.SamsungWasmDecoderModule = await SamsungWasmDecoderModule({});After that:
import { createSamsungWasmDecoder } from '@signageos/samsung-wasm-decoder';
const decoder = createSamsungWasmDecoder({ videoElementId: 'video-element' });
await decoder.initialize({ width: 1920, height: 1080 });
// Feed Annex-B H.264 access units:
const decodeResult = await decoder.decodeAndRender(someNalAccessUnitArrayBuffer);
const flushResult = await decoder.flush();
await decoder.destroy();