| 32 | } |
| 33 | |
| 34 | export class TinyH264Decoder implements ScrcpyVideoDecoder { |
| 35 | static readonly capabilities: Record<string, ScrcpyVideoDecoderCapability> = |
| 36 | { |
| 37 | h264: { |
| 38 | maxProfile: AndroidAvcProfile.Baseline, |
| 39 | maxLevel: AndroidAvcLevel.Level4, |
| 40 | }, |
| 41 | }; |
| 42 | |
| 43 | #renderer: HTMLCanvasElement | OffscreenCanvas; |
| 44 | get renderer() { |
| 45 | return this.#renderer; |
| 46 | } |
| 47 | |
| 48 | #sizeChanged = new StickyEventEmitter<{ width: number; height: number }>(); |
| 49 | get sizeChanged() { |
| 50 | return this.#sizeChanged.event; |
| 51 | } |
| 52 | |
| 53 | #width: number = 0; |
| 54 | get width() { |
| 55 | return this.#width; |
| 56 | } |
| 57 | |
| 58 | #height: number = 0; |
| 59 | get height() { |
| 60 | return this.#height; |
| 61 | } |
| 62 | |
| 63 | #frameRendered = 0; |
| 64 | get framesRendered() { |
| 65 | return this.#frameRendered; |
| 66 | } |
| 67 | |
| 68 | #frameSkipped = 0; |
| 69 | get framesSkipped() { |
| 70 | return this.#frameSkipped; |
| 71 | } |
| 72 | |
| 73 | #writable: WritableStream<ScrcpyMediaStreamPacket>; |
| 74 | get writable() { |
| 75 | return this.#writable; |
| 76 | } |
| 77 | |
| 78 | #yuvCanvas: YuvCanvas | undefined; |
| 79 | #initializer: PromiseResolver<TinyH264Wrapper> | undefined; |
| 80 | |
| 81 | constructor({ canvas }: TinyH264Decoder.Options = {}) { |
| 82 | if (canvas) { |
| 83 | this.#renderer = canvas; |
| 84 | } else { |
| 85 | this.#renderer = createCanvas(); |
| 86 | } |
| 87 | |
| 88 | this.#writable = new WritableStream<ScrcpyMediaStreamPacket>({ |
| 89 | write: async (packet) => { |
| 90 | switch (packet.type) { |
| 91 | case "configuration": |
nothing calls this directly
no outgoing calls
no test coverage detected