-
Notifications
You must be signed in to change notification settings - Fork 6
gwp multiplexing sample
This sample demonstrates how to display multiple cameras simultaneously over a single WebSocket connection using GWP's multiplexing feature. The pattern is well suited to multi-camera grids, video walls, and surveillance dashboards.
View HTML source code. Copy the code or use your browser's "Save As" to download and run locally.
Multiplexing lets multiple GWP players share a single WebSocket connection to the Media Gateway instead of creating one connection per player. The shared connection provides:
- Reduced connection overhead: one WebSocket instead of N connections.
- Lower network and server resource usage.
- Better scalability for large numbers of simultaneous cameras.
- One shared service that manages all streams.
- Flexible grid layouts: 2x2 (4 cameras), 3x3 (9 cameras), or 4x4 (16 cameras).
- All cameras share a single WebSocket via
buildMediaGatewayService(). - Each player can be controlled independently.
- Add or remove cameras by GUID at runtime.
- Per-camera status indicators.
- Real-time statistics for connections, active players, and streaming count.
The sample is built around four steps: create the shared service, build players, start them through the service, and then control each player independently.
Create one Media Gateway service that every player will share:
const mediaGatewayService = await gwp.buildMediaGatewayService(
`https://${mediaGateway}/media`,
getToken
);Each camera gets its own player instance:
const player = gwp.buildPlayer(containerElement);Call startWithService() instead of start() so the player connects through the shared service:
await player.startWithService(cameraGuid, mediaGatewayService);
player.playLive();Each player can be controlled independently despite sharing the connection:
player1.playLive();
player2.pause();
player3.seek(timestamp);| Feature | Multiplexed | Individual connections |
|---|---|---|
| WebSocket connections | 1 (shared) | N (one per player) |
| Network overhead | Low | High (N connections) |
| Media Gateway load | Lower | Higher |
| Scalability | Better for many cameras | Limited by connection count |
| Failure impact | All players affected | Only the failed player affected |
| Setup complexity | Slightly more complex | Simpler |
Use these guidelines to decide whether multiplexing fits your deployment.
- Displaying four or more cameras simultaneously.
- Building video walls or dashboards.
- Connection count is limited.
- Network efficiency is a priority.
- All cameras connect to the same Media Gateway.
- Displaying one to three cameras.
- Cameras connect to different Media Gateways.
- Isolation is critical (one failure should not affect others).
- Simplicity is preferred over efficiency.
- All players must connect to the same Media Gateway.
- If the shared WebSocket fails, all players are affected.
- Do not mix
start()andstartWithService()on the same service. - Error recovery is slightly more complex than for individual connections.
- Genetec Web Player developer guide: Embedding the Genetec Web Player in browser-based applications.
- Web Player sample application: Single-player GWP sample with playback, PTZ, and dewarping controls.
- GWP API reference: Genetec Web Player API reference (TypeScript definitions and methods).
- Overview
- Connecting to Security Center
- SDK certificates
- Referencing SDK assemblies
- SDK compatibility
- Entities
- Entity cache
- Entity loading, cache, and query options
- Transactions
- Events
- Actions
- Security Desk
- Custom events
- ReportManager
- ReportManager query reference
- Access control raw events
- DownloadAllRelatedData and StrictResults
- Privileges
- Partitions
- About custom fields
- About video
- About cameras
- Enrolling a video unit
- Archiver and auxiliary archiver roles
- Archive transfer
- About access control
- About cardholders and credentials
- About doors, areas, elevators, and access points
- About access rules and schedules
- About access control units and interface modules
- Enrolling an access control unit
- Door templates
- Visitors
- Mobile credentials
- About threat levels
- About alarms
- Maps
- Logging
- Overview
- Certificates
- Lifecycle
- Threading
- State management
- Configuration
- Restricted configuration
- Events
- Queries
- Request manager
- Database
- Entity ownership
- Engine extensions
- Entity mappings
- Server management
- Custom privileges
- Custom entity types
- Resolving non-SDK assemblies
- Deploying plugins
- .NET 8 support
- Overview
- Certificates
- Creating modules
- Tasks
- Pages
- Components
- Tile extensions
- Services
- Contextual actions
- Options extensions
- Configuration pages
- Monitors
- Shared components
- Commands
- Extending events
- Map extensions
- Timeline providers
- Image extractors
- Credential encoders
- Credential readers
- Cardholder fields extractors
- Badge printers
- Content builders
- Dashboard widgets
- Incidents
- Logon providers
- Pinnable content builders
- Custom report pages
- Overview
- Getting started
- MediaPlayer
- VideoSourceFilter
- MediaExporter
- MediaFile
- G64 converters
- FileCryptingManager
- PlaybackSequenceQuerier
- PlaybackStreamReader
- OverlayFactory
- PtzCoordinatesManager
- AudioTransmitter
- AudioRecorder
- AnalogMonitorController
- Camera blocking
- Overview
- Getting started
- Referencing entities
- Entity operations
- About access control in the Web SDK
- About video in the Web SDK
- Users and user groups
- Partitions
- Custom fields
- Custom card formats
- Actions
- Events and alarms
- Incidents
- Reports
- Tasks
- Macros
- Custom entity types
- System endpoints
- Performance guide
- Reference
- Under the hood
- Troubleshooting