feat: Add comprehensive documentation suite and reorganize project structure

- Created complete documentation in docs/ directory
- Added PROJECT_OVERVIEW.md with feature highlights and getting started guide
- Added ARCHITECTURE.md with system design and technical details
- Added SECURITY.md with comprehensive security implementation guide
- Added DEVELOPMENT.md with development workflows and best practices
- Added DEPLOYMENT.md with production deployment instructions
- Added API.md with complete REST API documentation
- Added CONTRIBUTING.md with contribution guidelines
- Added CHANGELOG.md with version history and migration notes
- Reorganized all documentation files into docs/ directory for better organization
- Updated README.md with proper documentation links and quick navigation
- Enhanced project structure with professional documentation standards
This commit is contained in:
SamiAhmed7777
2025-10-21 00:39:45 -07:00
commit 0b7e2d0a5b
6080 changed files with 1332936 additions and 0 deletions

View File

@@ -0,0 +1,137 @@
# EasyStream Complete Database Setup
This directory contains the complete database schema for the EasyStream video streaming platform.
## 🗄️ Complete Database Schema
The `__install/easystream.sql` file contains **ALL** tables needed for a production-ready EasyStream installation:
### Core Tables
- **db_accountuser** - User accounts with token balances and streaming settings
- **db_videofiles** - Video files with processing status and analytics
- **db_settings** - Platform configuration settings
- **db_sessions** - User session management
### RBAC (Role-Based Access Control)
- **db_roles** - System roles (guest, member, verified, creator, moderator, admin, super_admin)
- **db_user_roles** - User role assignments with expiration
- **db_role_permissions** - Permission mappings for each role
### Live Streaming
- **db_live_streams** - Live stream sessions with SRS integration
- **db_stream_viewers** - Real-time viewer tracking
- Stream analytics and recording management
### API & Analytics
- **db_api_keys** - API key management with rate limiting
- **db_api_logs** - Complete API request logging
- **db_video_analytics** - Detailed video viewing analytics
- **db_platform_metrics** - Aggregated platform statistics
### Token Monetization System
- **token_transactions** - All token-based transactions
- **token_purchases** - USD to token conversions
- **token_donations** - User-to-user token transfers
### Branding & Customization
- **db_branding_settings** - Complete theme customization
- **db_branding_images** - Logo and image management
- Color schemes, typography, and layout settings
### Additional Features
- IP tracking and fingerprinting
- Email logging and notifications
- Password reset management
- Enhanced security features
## 🚀 Quick Setup
### For Docker Users (Recommended)
1. **Start your Docker containers:**
```bash
docker-compose up -d
```
2. **Load the schema:**
```bash
docker exec -i easystream-db mysql -u easystream -peasystream easystream < __install/easystream.sql
```
### Manual Setup
If you prefer to run the SQL manually:
```bash
# Copy SQL to container
docker cp __install/easystream.sql vs-db:/tmp/schema.sql
# Execute the schema
docker exec vs-db mysql -u root -proot easystream -e "source /tmp/schema.sql"
# Clean up
docker exec vs-db rm /tmp/schema.sql
```
## ✅ What Gets Created
After running the setup, your EasyStream platform will have:
- **Complete user management** with role-based permissions
- **Video processing pipeline** with HLS streaming support
- **Live streaming capabilities** integrated with SRS
- **Comprehensive analytics** for videos, streams, and platform metrics
- **Token-based monetization** system ready for payments
- **Full branding customization** with theme management
- **Production-ready API** with logging and rate limiting
- **Advanced security features** including IP tracking and fingerprinting
## 🔧 Default Configuration
The schema includes sensible defaults:
- **7 user roles** from guest to super_admin with appropriate permissions
- **Token system** configured with "EasyCoins" as the default currency
- **Branding settings** with a clean blue theme
- **Platform metrics** initialized and ready for data collection
- **API rate limits** set to 100/hour for public, 1000/hour for members
## 📊 Database Statistics
The complete schema creates approximately:
- **25+ core tables** for full functionality
- **50+ indexes** for optimal performance
- **100+ default settings** for immediate use
- **Foreign key constraints** for data integrity
- **Triggers** for automatic balance updates
## 🛠️ Maintenance
The database is designed for production use with:
- Proper indexing for performance
- Foreign key constraints for data integrity
- Timestamp tracking for audit trails
- JSON columns for flexible metadata storage
- Partitioning-ready for high-volume analytics
## 🔍 Verification
After setup, verify your installation by checking that key tables exist:
```sql
SHOW TABLES LIKE 'db_%';
SHOW TABLES LIKE 'token_%';
```
You should see all the tables listed above.
## 📝 Notes
- This schema is compatible with MariaDB 10.6+ and MySQL 8.0+
- All tables use UTF8MB4 charset for full Unicode support
- JSON columns are used for flexible metadata storage
- The schema is designed to handle high-volume production workloads
Your EasyStream platform is now ready for production use! 🎉

29
deploy/abr.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
set -e # Exit on any error for debugging
# Create directories for ABR variants (0=360p, 1=480p, 2=720p)
mkdir -p "/var/www/hls/abr/${ABR_STREAM_KEY}/0"
mkdir -p "/var/www/hls/abr/${ABR_STREAM_KEY}/1"
mkdir -p "/var/www/hls/abr/${ABR_STREAM_KEY}/2"
echo "[ABR] Waiting for RTMP stream key '${ABR_STREAM_KEY}'..."
while true; do
ffmpeg -hide_banner -loglevel warning \
-i "rtmp://srs/live/${ABR_STREAM_KEY}" \
-filter:v:0 "scale=w=-2:h=360" -c:v:0 libx264 -b:v:0 800k -maxrate:v:0 856k -bufsize:v:0 1200k -preset veryfast -g 48 -sc_threshold 0 \
-filter:v:1 "scale=w=-2:h=480" -c:v:1 libx264 -b:v:1 1400k -maxrate:v:1 1498k -bufsize:v:1 2100k -preset veryfast -g 48 -sc_threshold 0 \
-filter:v:2 "scale=w=-2:h=720" -c:v:2 libx264 -b:v:2 2800k -maxrate:v:2 2996k -bufsize:v:2 4200k -preset veryfast -g 48 -sc_threshold 0 \
-map a:0 -c:a aac -b:a:0 128k -ac 2 \
-map a:0 -c:a aac -b:a:1 128k -ac 2 \
-map a:0 -c:a aac -b:a:2 128k -ac 2 \
-map v:0 -map v:1 -map v:2 -var_stream_map 'v:0,a:0 v:1,a:1 v:2,a:2' \
-f hls -hls_time 4 -hls_playlist_type event -hls_flags independent_segments \
-master_pl_name master.m3u8 \
-hls_segment_filename "/var/www/hls/abr/${ABR_STREAM_KEY}/%v/seg_%06d.ts" \
"/var/www/hls/abr/${ABR_STREAM_KEY}/%v/index.m3u8" || true
echo "[ABR] ffmpeg exited. Retrying in 5s..."
sleep 5
done

View File

@@ -0,0 +1,115 @@
# PowerShell script to add missing database tables to Docker container
# This script executes the combined SQL file in the MariaDB container
Write-Host "Adding missing database tables to Docker container..." -ForegroundColor Green
# Check if Docker is running
try {
docker ps | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Docker is not running or not accessible" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "Error: Docker command not found. Please install Docker first." -ForegroundColor Red
exit 1
}
# Check if the database container is running
$containerStatus = docker ps --filter "name=vs-db" --format "{{.Status}}"
if (-not $containerStatus) {
Write-Host "Error: Database container 'vs-db' is not running" -ForegroundColor Red
Write-Host "Please start the Docker containers first with: docker-compose up -d" -ForegroundColor Yellow
exit 1
}
Write-Host "Database container status: $containerStatus" -ForegroundColor Cyan
# Wait for database to be ready
Write-Host "Checking database connectivity..." -ForegroundColor Yellow
$maxAttempts = 30
$attempt = 0
do {
$attempt++
Write-Host "Attempt $attempt/$maxAttempts - Testing database connection..." -ForegroundColor Gray
$result = docker exec vs-db mysqladmin ping -h 127.0.0.1 -u root -proot --silent 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "Database is ready!" -ForegroundColor Green
break
}
if ($attempt -eq $maxAttempts) {
Write-Host "Error: Database is not responding after $maxAttempts attempts" -ForegroundColor Red
exit 1
}
Start-Sleep -Seconds 2
} while ($attempt -lt $maxAttempts)
# Execute the SQL file
Write-Host "Executing SQL script to add missing tables..." -ForegroundColor Yellow
try {
# Copy the SQL file to the container
docker cp "deploy/add_missing_tables.sql" vs-db:/tmp/add_missing_tables.sql
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to copy SQL file to container" -ForegroundColor Red
exit 1
}
# Execute the SQL file
$output = docker exec vs-db mysql -u root -proot easystream -e "source /tmp/add_missing_tables.sql" 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "Error executing SQL script:" -ForegroundColor Red
Write-Host $output -ForegroundColor Red
exit 1
}
# Clean up the temporary file
docker exec vs-db rm /tmp/add_missing_tables.sql
Write-Host "Success! All missing database tables have been added." -ForegroundColor Green
Write-Host $output -ForegroundColor Cyan
} catch {
Write-Host "Error: Failed to execute SQL script - $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
# Verify tables were created
Write-Host "Verifying table creation..." -ForegroundColor Yellow
$verifyTables = @(
"db_roles",
"db_user_roles",
"db_role_permissions",
"db_live_streams",
"db_stream_viewers",
"db_api_keys",
"db_api_logs",
"db_video_analytics",
"db_platform_metrics"
)
$allTablesExist = $true
foreach ($table in $verifyTables) {
$tableExists = docker exec vs-db mysql -u root -proot easystream -e "SHOW TABLES LIKE '$table';" --silent
if ($tableExists -match $table) {
Write-Host "✓ Table '$table' created successfully" -ForegroundColor Green
} else {
Write-Host "✗ Table '$table' was not created" -ForegroundColor Red
$allTablesExist = $false
}
}
if ($allTablesExist) {
Write-Host "`nAll database tables have been successfully added to the Docker container!" -ForegroundColor Green
Write-Host "The EasyStream platform now has complete RBAC, Live Streaming, and Analytics functionality." -ForegroundColor Cyan
} else {
Write-Host "`nSome tables were not created successfully. Please check the error messages above." -ForegroundColor Red
exit 1
}
Write-Host "`nDatabase setup complete! You can now use all platform features." -ForegroundColor Green

View File

@@ -0,0 +1,90 @@
#!/bin/bash
# Bash script to add missing database tables to Docker container
# This script executes the combined SQL file in the MariaDB container
echo "Adding missing database tables to Docker container..."
# Check if Docker is running
if ! docker ps >/dev/null 2>&1; then
echo "Error: Docker is not running or not accessible"
exit 1
fi
# Check if the database container is running
if ! docker ps --filter "name=vs-db" --format "{{.Names}}" | grep -q "vs-db"; then
echo "Error: Database container 'vs-db' is not running"
echo "Please start the Docker containers first with: docker-compose up -d"
exit 1
fi
echo "Database container is running"
# Wait for database to be ready
echo "Checking database connectivity..."
max_attempts=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
echo "Attempt $attempt/$max_attempts - Testing database connection..."
if docker exec vs-db mysqladmin ping -h 127.0.0.1 -u root -proot --silent >/dev/null 2>&1; then
echo "Database is ready!"
break
fi
if [ $attempt -eq $max_attempts ]; then
echo "Error: Database is not responding after $max_attempts attempts"
exit 1
fi
sleep 2
done
# Execute the SQL file
echo "Executing SQL script to add missing tables..."
# Copy the SQL file to the container
if ! docker cp "deploy/add_missing_tables.sql" vs-db:/tmp/add_missing_tables.sql; then
echo "Error: Failed to copy SQL file to container"
exit 1
fi
# Execute the SQL file
if ! docker exec vs-db mysql -u root -proot easystream -e "source /tmp/add_missing_tables.sql"; then
echo "Error: Failed to execute SQL script"
exit 1
fi
# Clean up the temporary file
docker exec vs-db rm /tmp/add_missing_tables.sql
echo "Success! All missing database tables have been added."
# Verify tables were created
echo "Verifying table creation..."
tables=("db_roles" "db_user_roles" "db_role_permissions" "db_live_streams" "db_stream_viewers" "db_api_keys" "db_api_logs" "db_video_analytics" "db_platform_metrics")
all_tables_exist=true
for table in "${tables[@]}"; do
if docker exec vs-db mysql -u root -proot easystream -e "SHOW TABLES LIKE '$table';" --silent | grep -q "$table"; then
echo "✓ Table '$table' created successfully"
else
echo "✗ Table '$table' was not created"
all_tables_exist=false
fi
done
if [ "$all_tables_exist" = true ]; then
echo ""
echo "All database tables have been successfully added to the Docker container!"
echo "The EasyStream platform now has complete RBAC, Live Streaming, and Analytics functionality."
else
echo ""
echo "Some tables were not created successfully. Please check the error messages above."
exit 1
fi
echo ""
echo "Database setup complete! You can now use all platform features."

View File

40
deploy/cron/crontab Normal file
View File

@@ -0,0 +1,40 @@
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# conversion check every 1 minute
*/1 * * * * root php /srv/easystream/f_modules/m_frontend/m_cron/convert_queue.php 1> /dev/null 2>&1
# check for expired subs daily at midnight
0 0 * * * root php /srv/easystream/f_modules/m_frontend/m_cron/expired_subs.php 1> /dev/null 2>&1
# update dashboard stats every 6 hours
0 */6 * * * root php /srv/easystream/f_modules/m_frontend/m_cron/admin_dashboard.php update 1> /dev/null 2>&1
# check disk space usage every 3 hours
0 */3 * * * root php /srv/easystream/f_modules/m_frontend/m_cron/disk_usage.php 1> /dev/null 2>&1
# update followers/subs weekly, Sundays at 19:30
30 19 * * 0 root php /srv/easystream/f_modules/m_frontend/m_cron/update_followers_subs.php 1> /dev/null 2>&1
# transfer check every 3 minutes
*/3 * * * * root php /srv/easystream/f_modules/m_frontend/m_cron/transfer_queue.php 1> /dev/null 2>&1
# clean chat notifications and usernames every 2 days at 09:00
0 9 */2 * * root php /srv/easystream/f_modules/m_frontend/m_cron/clean_chat.php 1> /dev/null 2>&1
# clean temps daily at 00:15
15 0 * * * root php /srv/easystream/f_modules/m_frontend/m_cron/clean_temps.php 1> /dev/null 2>&1
# VOD server tasks (paths configured via cfg.php written by init)
*/3 * * * * root php /srv/easystream/f_modules/m_frontend/m_cron/vod-server/recording_previews.php 1> /dev/null 2>&1
*/5 * * * * root php /srv/easystream/f_modules/m_frontend/m_cron/vod-server/recording_fix.php 1> /dev/null 2>&1
0 */12 * * * root php /srv/easystream/f_modules/m_frontend/m_cron/vod-server/clear_vods.php 1> /dev/null 2>&1
*/10 * * * * root php /srv/easystream/f_modules/m_frontend/m_cron/vod-server/sync_df.php 1> /dev/null 2>&1
0 */3 * * * root php /srv/easystream/f_modules/m_frontend/m_cron/vod-server/sync_vods.php 1> /dev/null 2>&1
# chat-server: sync subs and follows nightly
10 0 * * * root php /srv/easystream/f_modules/m_frontend/m_cron/chat-server/sync_subs.php 1> /dev/null 2>&1
# cleanup old logs daily at 04:30
30 4 * * * root php /srv/easystream/f_scripts/cleanup_logs.php 1> /dev/null 2>&1

47
deploy/cron/init.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/sh
set -e
# Write cron cfgs for chat-server and vod-server based on env
CHAT_CFG="/srv/easystream/f_modules/m_frontend/m_cron/chat-server/cfg.php"
VOD_CFG="/srv/easystream/f_modules/m_frontend/m_cron/vod-server/cfg.php"
mkdir -p "$(dirname "$CHAT_CFG")" "$(dirname "$VOD_CFG")"
cat > "$CHAT_CFG" <<'EOF'
<?php
ini_set("error_reporting", E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED);
define('_ISVALID', true);
/* database */
$dbhost = getenv('DB_HOST') ?: 'db';
$dbname = getenv('DB_NAME') ?: 'easystream';
$dbuser = getenv('DB_USER') ?: 'easystream';
$dbpass = getenv('DB_PASS') ?: 'easystream';
/* main url */
$base = getenv('CRON_BASE_URL') ?: 'http://localhost:8080';
/* cron salt key */
$ssk = getenv('CRON_SSK') ?: 'CHANGE_ME_IN_BACKEND';
EOF
cat > "$VOD_CFG" <<'EOF'
<?php
ini_set("error_reporting", E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED);
define('_ISVALID', true);
/* path to recordings */
$path = getenv('VOD_REC_PATH') ?: '/mnt/rec';
/* main url */
$base = getenv('CRON_BASE_URL') ?: 'http://localhost:8080';
/* cron salt key */
$ssk = getenv('CRON_SSK') ?: 'CHANGE_ME_IN_BACKEND';
EOF
# Ensure f_data is writable (best effort, may be a bind mount)
chown -R 33:33 /srv/easystream/f_data 2>/dev/null || true
chmod -R g+rwX /srv/easystream/f_data 2>/dev/null || true
# Load crontab and start cron in foreground
crontab /etc/cron.d/easystream
cron -f

27
deploy/ffmpeg-profiles.md Normal file
View File

@@ -0,0 +1,27 @@
FFmpeg ABR Profiles (Examples)
This project ships an example ABR pipeline in `deploy/abr.sh`. Below are suggested profiles and flags you can adapt.
Targets (H.264 + AAC, 48 fps GOP=48):
- 360p: 800 kbps (maxrate 856k, bufsize 1200k)
- 480p: 1400 kbps (maxrate 1498k, bufsize 2100k)
- 720p: 2800 kbps (maxrate 2996k, bufsize 4200k)
Recommended flags:
- Video: `-c:v libx264 -preset veryfast -g 48 -sc_threshold 0 -filter:v "scale=w=-2:h=<height>"`
- Audio: `-c:a aac -b:a 128k -ac 2`
- HLS: `-f hls -hls_time 4 -hls_playlist_type event -hls_flags independent_segments`
- Var streams: `-var_stream_map 'v:0,a:0 v:1,a:1 v:2,a:2'`
- Output pattern: `-master_pl_name master.m3u8 -hls_segment_filename /var/www/hls/abr/${ABR_STREAM_KEY}/%v/seg_%06d.ts /var/www/hls/abr/${ABR_STREAM_KEY}/%v/index.m3u8`
Usage:
- Set `ABR_STREAM_KEY` to the incoming RTMP stream key used by SRS.
- Start the ABR container (already included in docker-compose) to generate `/hls/abr/<key>/{0,1,2}/index.m3u8` and `master.m3u8`.
SRS-based Transcoding (Optional)
SRS supports an internal `transcode` directive. If you prefer SRS to run FFmpeg for you, add a `transcode` block to `deploy/srs.conf` mapping the input app/stream to multi-rendition outputs, and write resulting HLS to the same `/srs/hls` volume.

View File

@@ -0,0 +1,132 @@
# PowerShell script to set up the complete EasyStream database
# This script executes the comprehensive database schema
Write-Host "Setting up complete EasyStream database schema..." -ForegroundColor Green
# Check if Docker is running
try {
docker ps | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Docker is not running or not accessible" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "Error: Docker command not found. Please install Docker first." -ForegroundColor Red
exit 1
}
# Check if the database container is running
$containerStatus = docker ps --filter "name=vs-db" --format "{{.Status}}"
if (-not $containerStatus) {
Write-Host "Error: Database container 'vs-db' is not running" -ForegroundColor Red
Write-Host "Please start the Docker containers first with: docker-compose up -d" -ForegroundColor Yellow
exit 1
}
Write-Host "Database container status: $containerStatus" -ForegroundColor Cyan
# Wait for database to be ready
Write-Host "Checking database connectivity..." -ForegroundColor Yellow
$maxAttempts = 30
$attempt = 0
do {
$attempt++
Write-Host "Attempt $attempt/$maxAttempts - Testing database connection..." -ForegroundColor Gray
$result = docker exec vs-db mysqladmin ping -h 127.0.0.1 -u root -proot --silent 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "Database is ready!" -ForegroundColor Green
break
}
if ($attempt -eq $maxAttempts) {
Write-Host "Error: Database is not responding after $maxAttempts attempts" -ForegroundColor Red
exit 1
}
Start-Sleep -Seconds 2
} while ($attempt -lt $maxAttempts)
# Execute the complete database schema
Write-Host "Executing complete EasyStream database schema..." -ForegroundColor Yellow
try {
# Copy the SQL file to the container
docker cp "deploy/create_db.sql" vs-db:/tmp/complete_schema.sql
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to copy SQL file to container" -ForegroundColor Red
exit 1
}
# Execute the SQL file
$output = docker exec vs-db mysql -u root -proot easystream -e "source /tmp/complete_schema.sql" 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "Error executing SQL script:" -ForegroundColor Red
Write-Host $output -ForegroundColor Red
exit 1
}
# Clean up the temporary file
docker exec vs-db rm /tmp/complete_schema.sql
Write-Host "Success! Complete EasyStream database schema has been applied." -ForegroundColor Green
} catch {
Write-Host "Error: Failed to execute SQL script - $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
# Verify key tables were created
Write-Host "Verifying database setup..." -ForegroundColor Yellow
$keyTables = @(
"db_accountuser",
"db_videofiles",
"db_roles",
"db_user_roles",
"db_role_permissions",
"db_live_streams",
"db_stream_viewers",
"db_api_keys",
"db_api_logs",
"db_video_analytics",
"db_platform_metrics",
"token_transactions",
"token_purchases",
"token_donations",
"db_branding_settings",
"db_branding_images"
)
$allTablesExist = $true
$createdCount = 0
foreach ($table in $keyTables) {
$tableExists = docker exec vs-db mysql -u root -proot easystream -e "SHOW TABLES LIKE '$table';" --silent
if ($tableExists -match $table) {
Write-Host "✓ Table '$table' ready" -ForegroundColor Green
$createdCount++
} else {
Write-Host "✗ Table '$table' missing" -ForegroundColor Red
$allTablesExist = $false
}
}
if ($allTablesExist) {
Write-Host "`n🎉 SUCCESS! Complete EasyStream database is ready!" -ForegroundColor Green
Write-Host "📊 Created/verified $createdCount essential tables" -ForegroundColor Cyan
Write-Host "🚀 Platform features now available:" -ForegroundColor Cyan
Write-Host " • User management with RBAC" -ForegroundColor White
Write-Host " • Video processing and analytics" -ForegroundColor White
Write-Host " • Live streaming with SRS" -ForegroundColor White
Write-Host " • API management and logging" -ForegroundColor White
Write-Host " • Token monetization system" -ForegroundColor White
Write-Host " • Complete branding customization" -ForegroundColor White
Write-Host " • Advanced analytics and metrics" -ForegroundColor White
} else {
Write-Host "`nSome tables were not created successfully. Please check the error messages above." -ForegroundColor Red
exit 1
}
Write-Host "`n✅ EasyStream is production-ready! All database tables are in place." -ForegroundColor Green

View File

@@ -0,0 +1,101 @@
#!/bin/bash
# Bash script to set up the complete EasyStream database
# This script executes the comprehensive database schema
echo "Setting up complete EasyStream database schema..."
# Check if Docker is running
if ! docker ps >/dev/null 2>&1; then
echo "Error: Docker is not running or not accessible"
exit 1
fi
# Check if the database container is running
if ! docker ps --filter "name=vs-db" --format "{{.Names}}" | grep -q "vs-db"; then
echo "Error: Database container 'vs-db' is not running"
echo "Please start the Docker containers first with: docker-compose up -d"
exit 1
fi
echo "Database container is running"
# Wait for database to be ready
echo "Checking database connectivity..."
max_attempts=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
echo "Attempt $attempt/$max_attempts - Testing database connection..."
if docker exec vs-db mysqladmin ping -h 127.0.0.1 -u root -proot --silent >/dev/null 2>&1; then
echo "Database is ready!"
break
fi
if [ $attempt -eq $max_attempts ]; then
echo "Error: Database is not responding after $max_attempts attempts"
exit 1
fi
sleep 2
done
# Execute the complete database schema
echo "Executing complete EasyStream database schema..."
# Copy the SQL file to the container
if ! docker cp "deploy/create_db.sql" vs-db:/tmp/complete_schema.sql; then
echo "Error: Failed to copy SQL file to container"
exit 1
fi
# Execute the SQL file
if ! docker exec vs-db mysql -u root -proot easystream -e "source /tmp/complete_schema.sql"; then
echo "Error: Failed to execute SQL script"
exit 1
fi
# Clean up the temporary file
docker exec vs-db rm /tmp/complete_schema.sql
echo "Success! Complete EasyStream database schema has been applied."
# Verify key tables were created
echo "Verifying database setup..."
tables=("db_accountuser" "db_videofiles" "db_roles" "db_user_roles" "db_role_permissions" "db_live_streams" "db_stream_viewers" "db_api_keys" "db_api_logs" "db_video_analytics" "db_platform_metrics" "token_transactions" "token_purchases" "token_donations" "db_branding_settings" "db_branding_images")
all_tables_exist=true
created_count=0
for table in "${tables[@]}"; do
if docker exec vs-db mysql -u root -proot easystream -e "SHOW TABLES LIKE '$table';" --silent | grep -q "$table"; then
echo "✓ Table '$table' ready"
created_count=$((created_count + 1))
else
echo "✗ Table '$table' missing"
all_tables_exist=false
fi
done
if [ "$all_tables_exist" = true ]; then
echo ""
echo "🎉 SUCCESS! Complete EasyStream database is ready!"
echo "📊 Created/verified $created_count essential tables"
echo "🚀 Platform features now available:"
echo " • User management with RBAC"
echo " • Video processing and analytics"
echo " • Live streaming with SRS"
echo " • API management and logging"
echo " • Token monetization system"
echo " • Complete branding customization"
echo " • Advanced analytics and metrics"
else
echo ""
echo "Some tables were not created successfully. Please check the error messages above."
exit 1
fi
echo ""
echo "✅ EasyStream is production-ready! All database tables are in place."

76
deploy/srs.conf Normal file
View File

@@ -0,0 +1,76 @@
listen 1935;
max_connections 1000;
daemon off;
vhost __defaultVhost__ {
hls {
enabled on;
hls_path /srs/hls;
hls_fragment 2;
hls_window 10;
}
http_remux {
enabled on;
}
# Record RTMP to files for VOD processing (FLV segments)
dvr {
enabled on;
dvr_path /srs/rec/[app]/[stream].[timestamp].flv;
dvr_plan segment;
dvr_duration 300; # 5-minute segments
dvr_wait_keyframe on; # Fixed: start segments on keyframe (was dvr_wait_key)
}
# For local testing, allow all; lock down for production
play { }
publish { }
}
# Example: SRS-driven transcoding (optional)
#
# transcode live to live_abr {
# enabled on;
# ffmpeg /usr/local/bin/ffmpeg;
# # 360p, 480p, 720p outputs; adjust bitrates/presets as needed
# engine 360p {
# enabled on;
# vfilter {
# vf scale=w=-2:h=360
# }
# vcodec libx264;
# vbitrate 800;
# vfps 24;
# vparams "-preset veryfast -g 48 -sc_threshold 0";
# acodec aac;
# abitrate 128;
# aparams "-ac 2";
# output rtmp://127.0.0.1/live_abr/[stream]?v=360p;
# }
# engine 480p {
# enabled on;
# vfilter {
# vf scale=w=-2:h=480
# }
# vcodec libx264;
# vbitrate 1400;
# vfps 24;
# vparams "-preset veryfast -g 48 -sc_threshold 0";
# acodec aac;
# abitrate 128;
# aparams "-ac 2";
# output rtmp://127.0.0.1/live_abr/[stream]?v=480p;
# }
# engine 720p {
# enabled on;
# vfilter {
# vf scale=w=-2:h=720
# }
# vcodec libx264;
# vbitrate 2800;
# vfps 24;
# vparams "-preset veryfast -g 48 -sc_threshold 0";
# acodec aac;
# abitrate 128;
# aparams "-ac 2";
# output rtmp://127.0.0.1/live_abr/[stream]?v=720p;
# }
# }