Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 4f371b81 authored by Simon Chan's avatar Simon Chan
Browse files

chore: update some docs

parent 76d6d433
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
import { AdbPacketHeader, AdbPacketSerializeStream, type AdbBackend, type AdbPacketData, type AdbPacketInit } from '@yume-chan/adb';
import { DuplexStreamFactory, pipeFrom, ReadableStream, WritableStream } from '@yume-chan/stream-extra';
import { DuplexStreamFactory, pipeFrom, ReadableStream, WritableStream, type ReadableWritablePair } from '@yume-chan/stream-extra';
import { EMPTY_UINT8_ARRAY, StructDeserializeStream } from '@yume-chan/struct';

export const ADB_DEVICE_FILTER: USBDeviceFilter = {
+0 −3
Original line number Diff line number Diff line
@@ -102,9 +102,6 @@ export class AdbPacketDispatcher implements Closeable {
            .then(() => {
                this.dispose();
            }, (e) => {
                // https://github.com/MattiasBuelens/web-streams-polyfill/issues/115
                // `e` is always `AbortError` (instead of what I give in `abortController.abort()`)
                // so we can't check if `e` is a real error.
                if (!this._closed) {
                    this._disconnected.reject(e);
                }
+13 −7
Original line number Diff line number Diff line
# @yume-chan/scrcpy
# @yume-chan/scrcpy-decoder-tinyh264

Decode and render video stream using TinyH264, the old Android H.264 software decoder (now deprecated and removed), compiled into WebAssembly, and wrapped in Web Worker to prevent blocking the main thread.
Decode and render H.264 streams using TinyH264, the old Android H.264 software decoder (now deprecated and removed), compiled into WebAssembly, and wrapped in Web Worker to prevent blocking the main thread.

The video stream will be decoded into YUV frames, and converted to RGB using a WebGL shader, all on CPU. So it's slow and inefficient, but it works on most browsers.
The video stream will be decoded into YUV frames on CPU, then converted to RGB using a WebGL shader (using GPU). It's slow, but works on most browsers.

**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.

@@ -14,9 +14,11 @@ The video stream will be decoded into YUV frames, and converted to RGB using a W

## Usage

The bundler you use must also support the `new Worker(new URL('./worker.js', import.meta.url))` syntax. It's known to work with Webpack 5.
The bundler you use must support the `new Worker(new URL('./worker.js', import.meta.url))` syntax. It's known that Webpack 5 works.

It only supports Baseline level 4 codec, but many newer devices default to higher profile/levels. You can limit it by the `codecOptions` option.
### Limit profile/level

Because it only supports Baseline level 4 codec, but many newer devices default to higher profiles/levels, you can limit it by using the `codecOptions` option:

```ts
new ScrcpyOptions1_24({
@@ -27,11 +29,15 @@ new ScrcpyOptions1_24({
})
```

However, it will fail on some very old devices that doesn't support Baseline level 4 codec. You can retry without the `codecOptions` option.
However, it can fail on some very old devices that doesn't support even Baseline level 4 codec. You can retry without the `codecOptions` option if that happens.

### Render the video

It draws frames onto `decoder.element` (a `<canvas>` element), you can insert it anywhere you want to display the video.

```ts
const decoder = new TinyH264Decoder();
document.body.appendChild(decoder.element); // It draws frames onto `decoder.element`
document.body.appendChild(decoder.element);

videoPacketStream // from `@yume-chan/scrcpy`
    .pipeTo(decoder.writable)
+5 −3
Original line number Diff line number Diff line
# @yume-chan/scrcpy-decoder-webcodecs

Decode and render video stream using the [WebCodecs API](https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API).
Decode and render H.264 streams using the [WebCodecs API](https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API).

It has no dependencies and high performance, but are only available on recent versions of Chrome.
It has no dependencies and high performance, but is only available on recent versions of Chrome.

**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.

@@ -17,9 +17,11 @@ It has no dependencies and high performance, but are only available on recent ve

## Usage

It draws frames onto `decoder.element` (a `<canvas>` element), you can insert it anywhere you want to display the video.

```ts
const decoder = new WebCodecsDecoder();
document.body.appendChild(decoder.element); // It draws frames onto `decoder.element`
document.body.appendChild(decoder.element);

videoPacketStream // from `@yume-chan/scrcpy`
    .pipeTo(decoder.writable)