This example is a standard WHEPClient subscribe flow with additional castLabs forensic watermark overlay integration.
It demonstrates how to:
- authenticate against castLabs watermark APIs,
- request overlay image(s),
- render the overlay(s) on top of live playback,
- capture screenshots for single-frame forensic extraction workflows.
For product context on castLabs forensic watermarking, see STARDUSTmark.
To use this example, you will need:
- A castLabs account.
- Your Organization URN.
- A key created in castLabs account tools for watermark overlay API use:
- Access Key Id
- Secret Access Key
- A valid User URN associated with your account/workflow.
After the above is available, fill in the castLabs form in this example:
Access Key Id- API key identifier.Secret Access Key- API key secret.Organization URN- organization identifier.User URN- user identifier.Watermark Id- watermark payload identifier to request.Number of Overlays- number of overlay image requests to perform.
Settings are persisted locally and restored on reload.
- Start a live broadcast from any publish example (16:9 is recommended, e.g.
640x360). - Open this example and configure watermark credentials/settings.
- Click
Start Subscribe. - The example authenticates and requests overlay image(s), then subscribes and renders the overlay(s) on top of playback.
- Use
Stop Subscribeto stop playback and clear overlays.
At subscribe start, the example:
- reads/saves form settings,
- requests watermark overlay image(s) from castLabs service,
- draws each returned PNG overlay over the subscriber video container,
- initializes/subscribes with
WHEPClient.
If overlay acquisition fails, subscribe is aborted and overlay state is reset.
Once playback and overlay are visible:
- Take a screenshot of the live video area.
- Upload the screenshot to castLabs watermark extraction tooling.
- Run blind extraction (or other extraction mode your workflow uses).
- Review extraction output and use recovered metadata in your forensic process.
You may need to tune extraction settings in castLabs tooling depending on capture quality, scaling, and compression artifacts.
Watermark overlay behavior is independent from deployment mode. Endpoint and connectionParams follow the same WHEP pattern as other examples.
const endpoint = `https://${host}:443/live/whep/${streamName}`
const connectionParams = {}const endpoint = `https://${host}/as/v1/proxy/whep/${app}/${streamName}`
const connectionParams = {
// e.g. region, nodeGroup, auth metadata
}- subscribe flow:
startSubscribe() - overlay request path:
requestOverlays() - overlay render path:
addOverlay() - overlay reset path:
clearOverlays() - form persistence helpers:
src/lib/castlabs-watermark-configuration.ts - castLabs API wrapper:
src/service/castlabs.ts
