How marionlxy/rtvs works
Project Type and Purpose
• RTVS is a commercial-grade, real-time video platform that handles live and historical video streaming using multiple protocols, including 1078 and 28181.
• Its purpose is to deliver low-latency (≈200ms) video transmission across various platforms (desktop browsers, mobile, WeChat, native apps) and provide a complete end‐to‐end video solution with integrated control, monitoring, and gateways for protocol conversion.
• The README and file tree indicate that besides the core streaming server, there are supporting projects (e.g., JT808GW, gbSip) and related services (attachment services, simulators).
Analyzing the File Structure
• The top-level layout includes multiple directories:
• .github: Contains CI/CD workflows (automation and deployment pipelines).
• script: This is a key directory that includes subdirectories/scripts related to:
• Cluster and deployment configurations (clusterMyData, run_all.sh, run_cluster.sh).
• Protocol-specific gateway configuration (gw808 for the 808 gateway; gb28181 for national standard GB28181 interfaces; rtvsMyData for configuration and logs).
• Support for media streaming via WebRTC (webrtc folder, including mediasoup installation script and server scripts).
• Monitoring & logging components (grafana, influxdb, mysql, nginx) which illustrate that the project uses InfluxDB/Grafana for metrics, MySQL for storage, and Nginx for reverse proxy.
• test: Contains test assets including HTML pages and images to verify streaming performance.
• wx: Contains components for the WeChat mini-program integration.
• Configuration files, docker-related scripts, and deployment scripts indicate that the system is containerized and built for easy deployment across various environments.
a. Main Components:
• Frontend Clients:
• Web clients (JavaScript UI controls, test pages),
• Mobile/WeChat mini-program (wx folder),
• Possibly native apps (Android demo).
• API/Signal Processing Server:
• The core RTVS backend that handles video processing, signal management, and API endpoints.
• Protocol Gateways:
• JT808 or 808 gateway (script/gw808),
• GB28181 gateway (script/gb28181),
• These components convert or handle signaling for devices using the respective protocols.
• Media Streaming Engine:
• WebRTC and potentially other streaming mechanisms (e.g., FMP4, RTMP, HLS) with an emphasis on hardware decoding and adaptive streaming; see script/webrtc.
• Data Storage & Logging:
• MySQL (script/mysql) for system records and historical video metadata.
• InfluxDB (script/influxdb) for performance metrics and monitoring.
• Monitoring & Visualization:
• Grafana dashboards (script/grafana) to monitor system performance and logs.
• Reverse Proxy & Deployment:
• Nginx (script/nginx) for routing, load balancing, or HTTPS termination.
• Docker automation scripts for running the entire system (e.g., run_all.sh, run_attachment.sh).
• CI/CD Pipeline:
• GitHub workflows (.github/workflows) for automated testing/deployment.
b. Relationships and Interactions:
• Clients make API/service requests to the Backend server.
• The Backend interfaces with protocol gateways (808, GB28181) to connect with external devices.
• Media streaming components handle real-time video data selection (from hardware decoders) and interact with the Backend for session control.
• The database systems (MySQL) persist metadata and logs, while InfluxDB collects real-time metrics.
• Nginx acts as the entry point, routing requests from clients to the appropriate backend services.
• Docker scripts coordinate deployments and cluster management for scaling.
c. Architectural Patterns and Design Principles:
• Modular Separation: The design distinguishes between UI clients, API logic, protocol gateways, and media processing.
• Containerization and Orchestration: Deployment scripts and docker images imply container-based deployment, simplifying scalability.
• Loose Coupling: Use of standard API endpoints and protocols makes it easier to plug in external modules (e.g., attach additional protocols or data sources).
• Monitoring and Logging: Dedicated services for InfluxDB and Grafana indicate a focus on observability.
• Horizontal Scalability: Cluster and run_all scripts are geared toward scaling the system to handle many concurrent video streams.
d. Technologies, Frameworks, and Libraries:
• Docker for containerization.
• Nginx as a reverse proxy.
• MySQL and InfluxDB for data persistence and monitoring.
• Grafana for visualization.
• WebRTC for real-time communication, with mediasoup likely supporting this under script/webrtc.
• Scripting (Bash) plays a crucial role in deployment (various shell scripts).