# hyprtile-remoteviewer: next steps after dummy VP9 works

The colorful chessboard in `ffplay out.ivf` means the dummy capture -> libvpx VP9 -> IVF path works.

The next milestone is **real Hyprland/wlroots output capture into `out.ivf`**, still without networking.

## Milestone 1: add wlroots protocol XMLs

Install Wayland tooling:

```sh
sudo apt install build-essential pkg-config libvpx-dev libwayland-dev wayland-protocols wayland-scanner
```

Add these protocol XML files to `protocols/`:

- `wlr-screencopy-unstable-v1.xml`
- `wlr-virtual-pointer-unstable-v1.xml` later
- `virtual-keyboard-unstable-v1.xml` later

For now only screencopy is required.

On many distros these XMLs are not in `wayland-protocols`; they come from wlroots/wlr-protocols. Copy them from your wlroots checkout or package.

## Milestone 2: generate client protocol C/header

Run:

```sh
make protocols
```

This should create:

```text
build/protocols/wlr-screencopy-unstable-v1-client-protocol.h
build/protocols/wlr-screencopy-unstable-v1-protocol.c
```

## Milestone 3: implement real capture in `src/capture_wayland_wlr.c`

Implementation order:

1. Connect to Wayland with `wl_display_connect(NULL)`.
2. Get the registry.
3. Bind:
   - `wl_compositor` not strictly needed for screencopy
   - `wl_shm`
   - `zwlr_screencopy_manager_v1`
   - all `wl_output` globals
4. For each `wl_output`, listen for `name`, `description`, `mode`, `scale`, `geometry`.
5. Select the output matching `--output DP-1`.
6. Request a frame:

```c
frame = zwlr_screencopy_manager_v1_capture_output(manager, 0, output->wl_output);
```

7. In the frame listener, handle:
   - `buffer`: allocate `wl_shm` buffer with the requested format/size/stride
   - `flags`: remember Y-invert if present
   - `ready`: pass the mapped SHM memory to `htr_vp9_encode()`
   - `failed`: log and request a new frame
8. After every `ready`, destroy the frame object and request the next frame.

## Milestone 4: test real capture

Build:

```sh
make clean
make WAYLAND_WLR=1
```

List outputs:

```sh
hyprctl monitors
./build/hyprtile-remoteviewer list-outputs
```

Capture:

```sh
./build/hyprtile-remoteviewer host --output DP-1 --fps 30 --bitrate 2500 > out.ivf
ffplay out.ivf
```

At this point `ffplay` should show your real Hyprland output.

## Milestone 5: after real video works

Do not start networking yet until local IVF capture is stable.

Then implement in order:

1. UDP RTP VP9 output or WebRTC video sender.
2. DataChannel/WebSocket input messages.
3. `wlr-virtual-pointer` mouse injection.
4. `virtual-keyboard` or `uinput` keyboard injection.
