This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Webcast FCast is a web-to-FCast streaming service that renders web pages in headless Chromium and streams them as HLS to FCast receivers. The architecture consists of:
- FastAPI HTTP API (
app/serve/http_api.py) - Main service endpoint - CLI interface (
app/cli.py) - Command-line client using Typer - Session management (
app/core/session.py) - Manages streaming sessions and HLS output - Browser rendering (
app/render/) - Playwright driver with Xvfb for headless display - FFmpeg capture (
app/capture/ffmpeg_hls.py) - Captures display and encodes to HLS - FCast integration (
app/sender/fcast_adapter.py) - Sends streams to FCast receivers
python -m venv .venv && source .venv/bin/activate
pip install -e .
python -m playwright install --with-deps chromium
mkdir -p sessionspytest -q # Run all tests
pytest tests/unit/ # Unit tests only
pytest tests/integration/ # Integration tests onlyruff check . # Check code style and quality# Local development
SESSIONS_DIR=$PWD/sessions HOST_PORT=8080 uvicorn app.serve.http_api:app --reload --host 0.0.0.0 --port 8080
# Using CLI
python app/cli.py start https://example.com --receiver "Living Room"The service orchestrates multiple components for each streaming session:
- Xvfb - Virtual framebuffer for headless display
- Playwright - Browser automation for web page rendering
- FFmpeg - Screen capture and HLS encoding
- FCast Sender - Delivers stream to receiver
Sessions are managed with unique IDs and have states: starting, playing, stopping, stopped, error.
SESSIONS_DIR- Directory for HLS output files (default:/sessions)HOST_PORT- API server port (default:8080)FC_HOSTNAME_OVERRIDE- Override hostname for FCast URLsAPI- CLI client API endpoint (default:http://localhost:8080)
SessionManager- Creates, tracks, and cleans up streaming sessionsBrowserController- Manages Playwright browser instances with cookie/user-data supportFfmpegHls- Configurable HLS encoding with video profilesSender- FCast device communication using fcast-client library
- Unit tests focus on individual components (Xvfb, FFmpeg commands, sessions)
- Integration tests verify API endpoints and service interaction
- Tests use pytest with environment setup for sessions directory