UNPKG

@yume-chan/scrcpy-decoder-webcodecs

Version:

Raw H.264 stream decoder and renderer using WebCodecs API (requires modern browser).

27 lines 974 B
import { h264ParseConfiguration } from "@yume-chan/scrcpy"; import { H26xDecoder } from "./h26x.js"; import { hexTwoDigits } from "./utils.js"; export class H264Decoder extends H26xDecoder { #decoder; #updateSize; constructor(decoder, updateSize) { super(decoder); this.#decoder = decoder; this.#updateSize = updateSize; } configure(data) { const { profileIndex, constraintSet, levelIndex, croppedWidth, croppedHeight, } = h264ParseConfiguration(data); this.#updateSize(croppedWidth, croppedHeight); // https://www.rfc-editor.org/rfc/rfc6381#section-3.3 // ISO Base Media File Format Name Space const codec = "avc1." + hexTwoDigits(profileIndex) + hexTwoDigits(constraintSet) + hexTwoDigits(levelIndex); this.#decoder.configure({ codec: codec, optimizeForLatency: true, }); } } //# sourceMappingURL=h264.js.map