mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-05 10:49:24 +02:00
feat(decoder): add sizeChanged
event
This commit is contained in:
parent
4fbd24fc7f
commit
bef336da08
4 changed files with 23 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import { PromiseResolver } from "@yume-chan/async";
|
||||
import { EventEmitter } from "@yume-chan/event";
|
||||
import type { ScrcpyMediaStreamPacket } from "@yume-chan/scrcpy";
|
||||
import {
|
||||
AndroidAvcLevel,
|
||||
|
@ -51,6 +52,11 @@ export class TinyH264Decoder implements ScrcpyVideoDecoder {
|
|||
return this.#renderer;
|
||||
}
|
||||
|
||||
#sizeChanged = new EventEmitter<{ width: number; height: number }>();
|
||||
get sizeChanged() {
|
||||
return this.#sizeChanged.event;
|
||||
}
|
||||
|
||||
#frameRendered = 0;
|
||||
get frameRendered() {
|
||||
return this.#frameRendered;
|
||||
|
@ -112,6 +118,10 @@ export class TinyH264Decoder implements ScrcpyVideoDecoder {
|
|||
cropLeft,
|
||||
cropTop,
|
||||
} = h264ParseConfiguration(data);
|
||||
this.#sizeChanged.fire({
|
||||
width: croppedWidth,
|
||||
height: croppedHeight,
|
||||
});
|
||||
|
||||
// H.264 Baseline profile only supports YUV 420 pixel format
|
||||
const chromaWidth = encodedWidth / 2;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Disposable } from "@yume-chan/event";
|
||||
import type { Disposable, Event } from "@yume-chan/event";
|
||||
import type {
|
||||
ScrcpyMediaStreamPacket,
|
||||
ScrcpyVideoCodecId,
|
||||
|
@ -12,6 +12,7 @@ export interface ScrcpyVideoDecoderCapability {
|
|||
|
||||
export interface ScrcpyVideoDecoder extends Disposable {
|
||||
readonly renderer: HTMLElement;
|
||||
readonly sizeChanged: Event<{ width: number; height: number }>;
|
||||
readonly frameRendered: number;
|
||||
readonly frameSkipped: number;
|
||||
readonly writable: WritableStream<ScrcpyMediaStreamPacket>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue