# RCWeb Camera Broadcast App

The **RCWeb Camera Broadcast App** (`app/camera-c`) is the broadcaster half of a dedicated RCWeb camera streaming pair. It follows the **Asymmetric Pattern**: a broadcaster captures the local camera and microphone, then sends the media directly to every `camera-view` client in the same room over WebRTC.

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

## What it does

- **Device selection**: Lets the broadcaster choose a camera and microphone source from the browser's available devices.
- **One-to-many streaming**: Creates one WebRTC connection per viewer so the same source can be shared with everyone watching the room.
- **Local preview**: Shows the broadcaster a live preview plus simple audio/video status chips 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 `camera-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.
- **Track replacement**: Switching camera or microphone sources updates the existing peer connections by replacing the sender tracks and renegotiating.
- **Room cleanup**: Viewer cards are removed when RCWeb reports that the corresponding client has left the room or closed the page.

## Notes

- Browser access to camera and microphone typically requires **HTTPS** or **localhost**.
- The app uses STUN servers for ICE discovery, but it does **not** include a TURN relay.
