mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 09:49:24 +02:00
fix(decoder): don't modify packet pts
This commit is contained in:
parent
72bf025804
commit
3b71612b31
1 changed files with 11 additions and 3 deletions
|
@ -160,9 +160,11 @@ export class WebCodecsVideoDecoder implements ScrcpyVideoDecoder {
|
||||||
this.#pause = new PauseControllerImpl(
|
this.#pause = new PauseControllerImpl(
|
||||||
(packet) => this.#decoder.decode(packet),
|
(packet) => this.#decoder.decode(packet),
|
||||||
(packet, skipRendering) => {
|
(packet, skipRendering) => {
|
||||||
|
let pts: bigint;
|
||||||
|
|
||||||
if (skipRendering) {
|
if (skipRendering) {
|
||||||
// Set `pts` to 0 as a marker for skipping rendering this frame
|
// Set `pts` to 0 as a marker for skipping rendering this frame
|
||||||
packet.pts = 0n;
|
pts = 0n;
|
||||||
} else {
|
} else {
|
||||||
// Set `pts` to current time to track decoding time
|
// Set `pts` to current time to track decoding time
|
||||||
|
|
||||||
|
@ -175,9 +177,15 @@ export class WebCodecsVideoDecoder implements ScrcpyVideoDecoder {
|
||||||
|
|
||||||
// Multiply `performance.now()` by 1000 to get microseconds.
|
// Multiply `performance.now()` by 1000 to get microseconds.
|
||||||
// Use string concatenation to prevent precision loss.
|
// Use string concatenation to prevent precision loss.
|
||||||
packet.pts = BigInt(ms + (us + "000").slice(0, 3));
|
pts = BigInt(ms + (us + "000").slice(0, 3));
|
||||||
}
|
}
|
||||||
return this.#decoder.decode(packet);
|
|
||||||
|
// Create a copy of `packet` because other code (like recording)
|
||||||
|
// needs the original `pts`
|
||||||
|
return this.#decoder.decode({
|
||||||
|
...packet,
|
||||||
|
pts,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue