Skip to content

Commit

Permalink
add more code example
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Jan 6, 2025
1 parent 7678a45 commit 1bee935
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"libusb",
"logcat",
"muxer",
"muxers",
"muxing",
"MVVM",
"nohostname",
Expand Down
28 changes: 28 additions & 0 deletions docs/scrcpy/control/reset-video.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,31 @@ await writer.resetVideo();
// Using `AdbScrcpyClient`
await client.controller!.resetVideo();
```

Because the transmission delay, some video packets for previous configuration might still arrive after the reset video command. You can still send them to existing consumers (decoders, muxers, or remote clients), but new consumers should only be started when the next `configuration` packet is received.

```ts transpile
import { ScrcpyMediaStreamPacket } from "@yume-chan/scrcpy";

declare const videoPacketStream: ReadableStream<ScrcpyMediaStreamPacket>;

let consumers: unknown[] = [];
let pendingConsumers: unknown[] = []; // New decoders, muxers, or remote clients waiting for the next `configuration` packet

for await (const packet of videoPacketStream) {
switch (packet.type) {
case "configuration":
if (pendingConsumers.length) {
// Initialize pending consumers

consumers = consumers.concat(pendingConsumers);
pendingConsumers = [];
}
// Send packets to `consumers`
break;
case "data":
// Send packets to `consumers`
break;
}
}
```
2 changes: 2 additions & 0 deletions docs/scrcpy/video/web-codecs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,5 @@ By default, Chromium browsers uses FFMpeg internally for WebCodecs API. However,
Decoding H.265 requires the [**HEVC Video Extensions**](https://www.microsoft.com/store/productId/9NMZLZ57R3T7) ($0.99) or **HEVC Video Extensions from Device Manufacturer** (free but not available anymore) app from Microsoft Store.

Decoding AV1 requires the [**AV1 Video Extension**](https://www.microsoft.com/store/productId/9MVZQVXJBQ9V) (free) app from Microsoft Store.

[`isConfigSupported`](#feature-detection) method can be used to detect whether the corresponding app is installed.

0 comments on commit 1bee935

Please sign in to comment.