# RCWeb Screen Broadcast App

The **RCWeb Screen Broadcast App** (`app/screen-c`) is the broadcaster half of a dedicated RCWeb screen sharing pair. It follows the **Asymmetric Pattern**: a broadcaster captures a browser tab, app window, or screen, then sends the media directly to every `screen-view` or `screen-out` client in the same room over WebRTC.

![icon](pwa-512x512.png "Screen Broadcast App Icon")

## What it does

- **Browser-driven screen picking**: Lets the broadcaster choose what to share through the browser's native display picker, with hints for tabs, windows, or full screens.
- **One-to-many streaming**: Creates one WebRTC connection per viewer so the same shared display can be sent to everyone watching the room.
- **Local preview and telemetry**: Shows a live preview of the captured display plus transport details before and during transmission.
- **Room invite flow**: Generates a viewer URL for the current RCWeb room so it is easy to open or share the matching `screen-view` page.

## How it works

- **RCWeb signaling**: `script.js` uses `rc.sendFunctionCall(...)` to announce broadcaster presence, accept stream requests from viewers, and exchange WebRTC offers, answers, and ICE candidates.
- **Broadcaster-owned negotiation**: The broadcaster always creates the WebRTC offers, which keeps the broadcaster/viewer handshake simpler than a symmetric mesh app.
- **Display capture**: The broadcaster uses `navigator.mediaDevices.getDisplayMedia(...)` so the browser can present the user with available tabs, windows, and screens to share.
- **Room cleanup**: Viewer cards are removed when RCWeb reports that the corresponding client has left the room or closed the page.

## Notes

- Browser screen capture typically requires **HTTPS** or **localhost** and must be started from a user interaction.
- The app uses STUN servers for ICE discovery, but it does **not** include a TURN relay.
