LMultiview Reference Manual & Grid Layout Guide
The LMultiview class is the high-performance multi-view video grid compositor of the now2sdk framework, derived from the LObject class. It allows developers to composit multiple video sources (such as LLive, LFile, LStreamPlay, etc.) into a single multi-source monitoring layout. It is commonly used in professional broadcast switchers to display all incoming cameras, preview feeds, and program feeds on a single monitor.
Under the hood, LMultiview utilizes an offscreen OpenGL context (QOpenGLContext and QOffscreenSurface) to render composite frames on the GPU. This architecture ensures high-performance blending, scaling, text rendering for channel labels, and live audio peak level (VU meter) processing without consuming CPU cycles.
1. Composition Architecture
graph TD
A[LMultiview Composer Loop] --> B[Offscreen OpenGL FBO Renderer]
B --> C[GLSL Fragment Shader Processing]
C -->|1. Grid Cell Blending & Scaling| D[Composition Output]
C -->|2. Tally Border Rendering| D
C -->|3. Title Safe Channel Labels| D
C -->|4. Dual-Channel VU Peak Meters| D
H[MultiviewSink per Cell] -->|Peak Level Computation| I[Live VU Meters]
I --> D
Key Composition Features:
- GLSL Shader Compositing: Multiple video textures are blended and composited on the GPU according to the computed grid coordinates.
- Tally Borders: Supports Program (Red border) and Preview (Green border) tally states for each cell in the layout.
- Text Labels: Renders text overlays for channel names dynamically using OpenGL text textures.
- Live VU Meters: Displays left/right channel peak audio levels on top of each cell, updating in real-time based on incoming audio samples.
- Dynamic Orientations: The layout can be arranged with Program/Preview on top, bottom, left, or right, with the grid cells filling the remaining space.
2. API Reference & Public Methods
📌 Layout & Setup
void setupGrid(MultiviewOrientation orientation, int baseCount);
Configures the overall layout style:
orientation: Position of the main Program (PGM) and Preview (PVW) screens. Can beMultiviewOrientation::TOP,MultiviewOrientation::BOTTOM,MultiviewOrientation::LEFT, orMultiviewOrientation::RIGHT.baseCount: Number of rows (if TOP/BOTTOM) or columns (if LEFT/RIGHT) for the small grid area.
void setPVWSource(LObject* obj);
Sets the video source connected to the Preview (PVW) window.
void setPGMSource(LObject* obj);
Sets the video source connected to the Program (PGM) window.
📌 Grid Cells Management
void setGridPos(LObject* obj, int row, int col, int size = 0, const std::string& name = "");
Adds a video source to a specific position in the grid:
obj: The video source (e.g.LLive).row,col: 1-based row and column coordinates.size: Cell dimension multiplier.0for 1x1 standard size,1for 2x2 larger size.name: Optional label name.
void removeGridPos(int row, int col);
Removes the source at the specified row and column.
void setGridPGM(int row, int col);
Sets the tally border of the cell at row, col to Program (Red).
void setGridPVW(int row, int col);
Sets the tally border of the cell at row, col to Preview (Green).
void clearTally(int row, int col);
Clears any active tally border on the cell at row, col.
📌 UI Overlay & Monitoring
void setGridName(int row, int col, const std::string& name);
void setGridName(const std::string& key, const std::string& name);
Sets the display label text for a grid cell.
std::vector<GridCellInfo> getLayoutInfo();
Returns a list of all active cells containing their positions, dimensions, tally status, and audio peak values.
void setVideoFormat(const videoFormatProps& props);
void getVideoFormat(videoFormatProps& props);
Configures the output resolution and frame rate of the multi-view output frame.
📌 Licensing
bool setLicense(const std::string& licenseKey);
bool isLicensed() const;
Configures and verifies the module license. If unlicensed, a watermark is automatically overlayed on the output frame.
3. Integration Example
This example demonstrates how to set up LMultiview with Preview, Program, and 8 camera sources arranged in a grid:
#include "LMultiview.h"
#include "LLive.h"
#include "LOutput.h"
#include <iostream>
void initializeMultiviewSystem() {
LMultiview* multiview = new LMultiview();
// Set output format to 1080p 50fps
videoFormatProps vProps;
vProps.setVideoFormat = vF::fcc_1080p50;
multiview->setVideoFormat(vProps);
// Setup: Program/Preview on top, grid with 4 columns on the bottom
multiview->setupGrid(MultiviewOrientation::TOP, 4);
// Create 2 Main Outputs
LLive* pgmCam = new LLive();
LLive* pvwCam = new LLive();
multiview->setPGMSource(pgmCam);
multiview->setPVWSource(pvwCam);
// Register 8 Camera Inputs
for (int i = 0; i < 8; ++i) {
LLive* cam = new LLive();
// Position camera in a 2x4 grid on the bottom
int row = (i / 4) + 1;
int col = (i % 4) + 1;
multiview->setGridPos(cam, row, col, 0, "CAM " + std::to_string(i + 1));
}
// Connect Multiview to Output (e.g. DeckLink or NDI streaming)
LOutput* monitorOut = new LOutput();
monitorOut->connect(multiview);
monitorOut->Start();
std::cout << "Multiview engine running..." << std::endl;
}