This example shows how to publish with WHIPClient and send AMF metadata during an active stream.
It is the sender-side pair for whep-amf.
- WHIP publish lifecycle with explicit media stream setup (
initWithStream(...)) - sending AMF metadata after publish starts
- keeping publish active while dispatching metadata updates
- pairing publish-side metadata send with subscriber-side metadata receipts
After publish starts, the AMF Metadata form is enabled.
Submitting the form triggers:
publisher.send('onMetaData', { metadata: data })Where:
'onMetaData'is the method name used for metadata dispatch- payload contains the metadata text entered in the UI
This example acquires media from r5-publish-settings and initializes with initWithStream(...):
const mediaStream = await publishSettingsEl.refreshStream()
await publisher.initWithStream(
{
endpoint,
streamName,
mediaElementId: 'publisher-video',
connectionParams,
streamMode,
},
mediaStream
)
await publisher.publish()const publisher = new red5prosdk.WHIPClient()
await publisher.initWithStream(
{
endpoint,
streamName,
mediaElementId: 'publisher-video',
},
mediaStream
)
await publisher.publish()
// Send AMF metadata while publishing
publisher.send('onMetaData', {
metadata: 'chapter=1'
})AMF metadata behavior is independent from deployment mode. Endpoint and connection parameter setup follows the standard WHIP pattern.
endpointtargets the server directly (origin).connectionParamsis optional unless your server/plugins require extra values.
const endpoint = `https://${host}:443/live/whip/${streamName}`
const connectionParams = {}endpointtargets Stream Manager proxy routing.connectionParamscommonly includes Stream Manager and auth metadata.
const endpoint = `https://${host}/as/v1/proxy/whip/${app}/${streamName}`
const connectionParams = {
// e.g. region, nodeGroup, auth metadata
}- publish flow:
startPublish() - metadata send handler:
sendAmfMetadata() - AMF form enable/disable state:
syncAmfMetadataControls() - publisher event handling:
onPublisherEvent()
Pair this with whep-amf to see how Subscribe.Metadata receives and displays these metadata updates.