How casparcg/server works
Main Components
• Server Engine (Core) – This is found in the “src/core” folder. It includes frame handling, mixing, diagnostics, producers, and consumers. It is the central part that coordinates data streams.
• Accelerator – Located in “src/accelerator,” these components leverage GPU/OpenGL functionality for processing graphics and image manipulation.
• Modules – In “src/modules,” many plug-in modules add media-specific functionality. Examples include:
• FFmpeg module for handling audio/video encoding/decoding.
• Decklink module for hardware interfacing.
• ArtNet, Bluefish, Flash, HTML, Image, NewTek, OAL (audio), and Screen modules.
These modules allow for networked control, video capture, consumer/producer pipelines, and hardware interop.
• Protocol Layer – Found in “src/protocol,” this layer implements different communication protocols (AMCP and OSC, for instance) and related utilities. It deals with command parsing, client messaging, and HTTP request handling.
• Shell and Tools – The “src/shell” folder contains the main application entry point, configuration (casparcg.config), startup scripts, and platform-specific code. Additionally, “tools” provide build and packaging utilities.
• Common Libraries and Utilities – The “src/common” directory provides a shared set of helper functions and abstractions (logging, filesystem access, threading, timer utilities) that are used by the rest of the system.
• External/3rd-Party Dependencies – While not part of the core directory structure, note that the project relies on libraries like FFmpeg, TBB (Threading Building Blocks), SFML, GLEW, and Boost. These should be depicted externally to indicate integration points.
Relationships and Data Flow
• The Shell launches the Core engine. From here, control flows into:
• The Accelerator subsystem for GPU-accelerated image processing.
• The Protocol layer, which listens for client commands (via AMCP and OSC) and dispatches them to the core.
• Plug-in Modules that extend functionality, tied into either media capture (Producers) or media output (Consumers). Many of these modules are interconnected—producing frames to be later mixed and consumed.
• Utility layers (Common libraries) that serve as infrastructure across these main components.
Architectural Patterns and Design Principles
• Layered and Component-Based Design: Separate layers include the Presentation/Interface (Shell), Business Logic (Core and Accelerator), Protocol/Communication (AMCP, OSC), and External Integrations (third-party libraries).
Technologies and Frameworks
• C++ (as the language).
• CMake (build system).
• OpenGL (via Accelerator, as evidenced by shader files and OGL directories).
• The external libraries: FFmpeg, TBB, SFML, GLEW, and Boost.
• OS-specific modules such as “src/common/os/linux” and “src/common/os/windows” to show platform-dependent implementations in areas like filesystem and threading.
• Flow of data (e.g., frame data from producers → core mixing → consumers).
• Control flow (e.g., configuration commands from Shell → Core initialization).
• Interactions between the protocol layer (receiving commands) and the Core.
• Core system components (e.g., use rectangles).
• Component has a clear label and, where necessary, add annotations (e.g., “GPU acceleration via OpenGL”, “Media encoding/decoding via FFmpeg”).