This example extends a standard WHEPClient subscribe flow with castLabs DRMtoday integration to compare encrypted baseline playback and DRM-decrypted playback.
It is the subscriber-side pair for whip-castlabs.
- dual subscriber paths in one page:
- baseline subscriber (expected encrypted/garbled playback)
- DRM subscriber (castLabs/decrypted playback path)
- applying CastLabs subscriber settings to DRM configuration
- wiring peer
ontrackhandling through castLabs transform APIs - start/stop lifecycle for DRM subscriber while baseline can run continuously
The subscriber form includes:
environment: DRMtoday environment where your encrypted stream configuration resides.merchant: DRMtoday merchant account.encryption mode/ scheme setting: encryption profile associated with the stream.decrypt mode: ClearKey or Production DRM flow.key id/iv: values supplied by your merchant.
Notes:
- current key material handling in this example expects hex input values.
- form values are persisted and auto-restored with local storage helpers.
- starts automatically on page load
- standard WHEP path without DRM transform
- useful for validating that encrypted content is not directly viewable
On DRM subscribe start, the example:
- reads/saves CastLabs settings
- builds DRM config (
environment,merchant, encryption/decrypt mode, keyId/iv) - runs
rtcDrmConfigure(...) - creates WHEP subscriber with insertable streams enabled
- routes peer
ontracktortcDrmOnTrack(...)for decrypted playback
import { rtcDrmConfigure } from '@public/libs/castlabs/rtc-drm-transform/rtc-drm-transform.min.js'
await rtcDrmConfigure(drmConfig)
const subscriber = new red5prosdk.WHEPClient()
await subscriber.init({
endpoint,
streamName,
connectionParams,
rtcConfiguration: {
...rtcConfiguration,
encodedInsertableStreams: true,
},
})
subscriber.on('*', (event) => {
if (event.type === 'WebRTC.PeerConnection.Available') {
const pc = subscriber.getPeerConnection()
pc.ontrack = (e) => {
rtcDrmOnTrack(e, drmConfig)
}
}
})
await subscriber.subscribe()This example requires modern browser support for:
- Web Workers
- Insertable Streams
- TransformStream
Polyfills are included in the example page for track processor/generator APIs where needed.
This README does not attempt to document DRMtoday platform configuration. Use castLabs DRMtoday documentation for environment, merchant, and key provisioning details.
CastLabs subscriber behavior is independent from deployment mode. Endpoint and connection setup follows 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
}- baseline subscriber startup:
startBaselineSubscribe() - DRM subscriber startup:
startDrmSubscribe() - castLabs form read/save:
readCastLabsSubForm()/saveCastLabsSubSettings() - DRM config + configure call:
rtcDrmConfigure(...) - decrypted playback hook:
rtcDrmOnTrack(...) - shared subscriber factory:
createSubscriber()
Pair this with whip-castlabs for the sender-side encryption worker/transform setup.