#!/bin/bash # # WebRTC Latency Test POC - Installation Script # Installs dependencies for the WebRTC latency testing system # set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" GREEN='\033[0;32m' CYAN='\033[0;36m' YELLOW='\033[1;33m' NC='\033[0m' success() { echo -e "${GREEN}✓${NC} $1"; } warn() { echo -e "${YELLOW}⚠${NC} $1"; } header() { echo -e "\n${CYAN}$1${NC}"; } echo "" echo "╔══════════════════════════════════════════════════════════════╗" echo "║ WEBRTC LATENCY TEST - INSTALLATION ║" echo "╚══════════════════════════════════════════════════════════════╝" echo "" # ============================================================ # 1. CHECK PYTHON # ============================================================ header "[1/5] Checking Python version..." PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}') PYTHON_MAJOR=$(echo $PYTHON_VERSION | cut -d. -f1) PYTHON_MINOR=$(echo $PYTHON_VERSION | cut -d. -f2) if [ "$PYTHON_MAJOR" -ge 3 ] && [ "$PYTHON_MINOR" -ge 8 ]; then success "Python $PYTHON_VERSION detected" else echo -e "${YELLOW}⚠${NC} Python 3.8+ required (found $PYTHON_VERSION)" echo " Please install Python 3.8 or later" exit 1 fi # ============================================================ # 2. INSTALL PYTHON DEPENDENCIES # ============================================================ header "[2/5] Installing Python dependencies..." cd "$PROJECT_DIR" if [ -f "requirements.txt" ]; then pip3 install -r requirements.txt --quiet success "Python dependencies installed" else # Fallback: install common dependencies pip3 install --quiet \ aiortc>=1.6.0 \ aiohttp>=3.8.0 \ opencv-python>=4.8.0 \ numpy>=1.24.0 \ av>=10.0.0 \ playwright>=1.40.0 success "Python dependencies installed (fallback)" fi # ============================================================ # 3. INSTALL PLAYWRIGHT BROWSER # ============================================================ header "[3/5] Installing Playwright and Chromium..." pip3 install playwright --quiet # Install Chromium (headless browser for automated tests) playwright install chromium --quiet 2>/dev/null || { echo " Downloading Chromium (may take a moment)..." playwright install chromium } success "Playwright and Chromium installed" # ============================================================ # 4. VERIFY DOCKER # ============================================================ header "[4/5] Checking Docker..." if command -v docker &> /dev/null; then DOCKER_VERSION=$(docker --version | awk '{print $3}') success "Docker $DOCKER_VERSION detected" else warn "Docker not found (optional for LiveKit)" echo " To install Docker:" echo " curl -fsSL https://get.docker.com -o get-docker.sh" echo " sh get-docker.sh" fi # ============================================================ # 5. CREATE LOG DIRECTORY # ============================================================ header "[5/5] Setting up log directories..." mkdir -p /tmp/webrtc-logs 2>/dev/null || true success "Log directories created" # ============================================================ # COMPLETE # ============================================================ echo "" echo "╔══════════════════════════════════════════════════════════════╗" echo "║ INSTALLATION COMPLETE! ║" echo "╚══════════════════════════════════════════════════════════════╝" echo "" echo " Components installed:" echo " • Python WebRTC server (aiortc)" echo " • OpenCV for video processing" echo " • Playwright for automated tests" echo " • Chromium headless browser" echo "" echo " To start the server:" echo " $SCRIPT_DIR/start_webrtc.sh" echo "" echo " To run automated tests:" echo " python3 test_latency_playwright.py " echo "" success "Installation completed successfully!" echo ""