# VIDX Embed Server Replica

This repository packages the VIDX snippet runtime and the server-side pieces needed to reproduce the current Ubuntu deployment on a fresh host with as little manual setup as possible.

## What is included

- snippet HTML files in `snippets/`
- player/runtime assets in `vidx-embed.js`, `rtc-logo-watermark.png`, and `index-page.html`
- same-origin PHP helpers for HLS proxying, stats, and viewer tracking
- deployment templates for Apache, MediaMTX, FFmpeg ingest, and ws_rtsp
- bootstrap scripts to install packages, render templates, enable services, and publish the site

## Quick Start

1. Clone the repo on the new Ubuntu server.
2. Copy the camera env template and set the real upstream RTSP source:

```bash
cp deploy/env/cam1.env.example deploy/env/cam1.env
nano deploy/env/cam1.env
```

3. Run the bootstrap script:

```bash
sudo bash deploy/scripts/bootstrap-ubuntu.sh
```

## Default Deployment Shape

- Apache site root: `/var/www/dev.cc-group.org`
- VIDX app path: `/var/www/dev.cc-group.org/vidx_embed`
- MediaMTX config: `/root/mediamtx/mediamtx.yml`
- FFmpeg ingest service: `cam1.service`
- ws_rtsp config: `/etc/ws_rtsp.ini`
- ws_rtsp Apache UI: `http://<host>:8088`

## Verification

After bootstrap, verify the stack with:

```bash
systemctl status mediamtx
systemctl status cam1
systemctl status ws_rtsp
sudo systemctl status apache2
ss -ltnp | grep -E ':(80|443|8080|8088|8554|8888|8889)\b'
```

Open these URLs in a browser or with `curl`:

- `http://<host>/vidx_embed/index-page.html`
- `http://<host>/vidx_embed/hls-proxy.php?path=cam1&file=index.m3u8`
- `http://<host>:8088`
- `https://<host>/hls/cam1/index.m3u8` once SSL is configured
- `https://<host>/webrtc/` once SSL is configured

## Notes

- The real camera RTSP URL/token is intentionally not committed.
- SSL certificate files are not committed. The SSL vhost template is installed only when matching cert files exist or after Certbot has been run.
- `rtccom - Copy/` is intentionally ignored as duplicate backup content.
