PrivMX DOCS
API Reference/PrivMX Endpoint Web/Streams

StreamApi

Class representing instance of Streams API

Methods

createStreamRoom

Creates a new Stream Room in given Context.

Params

contextId

string

ID of the Context to create the Stream Room in

users

UserWithPubKey[]

array of UserWithPubKey structs which indicates who will have access to the created Stream Room

managers

UserWithPubKey[]

array of UserWithPubKey structs which indicates who will have access (and management rights) to the created Stream Room

publicMeta

Uint8Array

public (unencrypted) metadata

privateMeta

Uint8Array

private (encrypted) metadata

policies

ContainerPolicy

Stream Room's policies (pass undefined to use defaults)

createStreamRoom(contextId, users, managers, publicMeta, privateMeta, policies)

Returns

Promise<Types.StreamRoomId> · ID of the created Stream Room

updateStreamRoom

Updates an existing Stream Room.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room to update

users

UserWithPubKey[]

array of UserWithPubKey structs which indicates who will have access to the Stream Room

managers

UserWithPubKey[]

array of UserWithPubKey structs which indicates who will have access (and management rights) to the Stream Room

publicMeta

Uint8Array

public (unencrypted) metadata

privateMeta

Uint8Array

private (encrypted) metadata

version

number

current version of the updated Stream Room

force

boolean

force update (without checking version)

forceGenerateNewKey

boolean

force to regenerate a key for the Stream Room

policies

ContainerPolicy

Stream Room's policies (pass undefined to keep current/defaults)

updateStreamRoom(streamRoomId, users, managers, publicMeta, privateMeta, version, force, forceGenerateNewKey, policies)

listStreamRooms

Gets a list of Stream Rooms in given Context.

Params

contextId

string

ID of the Context to get the Stream Rooms from

query

PagingQuery

struct with list query parameters

listStreamRooms(contextId, query)

Returns

Promise<PagingList<StreamRoom>> · list of Stream Rooms

joinStreamRoom

Joins a Stream Room. This is required before calling createStream/publishStream and before subscribing to remote streams in the room.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room to join

joinStreamRoom(streamRoomId)

leaveStreamRoom

Leaves a Stream Room.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room to leave

leaveStreamRoom(streamRoomId)

enableStreamRoomRecording

Enables server-side recording for the Stream Room.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room

enableStreamRoomRecording(streamRoomId)

getStreamRoomRecordingKeys

Gets encryption keys used for Stream Room recordings.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room

getStreamRoomRecordingKeys(streamRoomId)

Returns

Promise<EndpointTypes.RecordingEncKey[]> · list of recording encryption keys

getStreamRoom

Gets a single Stream Room by given Stream Room ID.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room to get

getStreamRoom(streamRoomId)

Returns

Promise<StreamRoom> · information about the Stream Room

deleteStreamRoom

Deletes a Stream Room by given Stream Room ID.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room to delete

deleteStreamRoom(streamRoomId)

createStream

Creates a local Stream handle for publishing media in given Stream Room. Call addStreamTrack/removeStreamTrack to stage tracks and publishStream/updateStream to send changes to the server.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room to create the stream in

createStream(streamRoomId)

Returns

Promise<StreamHandle> · handle to a local Stream instance

listStreams

Gets a list of currently published streams in given Stream Room.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room to list streams from

listStreams(streamRoomId)

Returns

Promise<StreamInfo[]> · list of StreamInfo structs describing currently published streams

addStreamTrack

Adds a local media track definition to a Stream handle. The track is staged locally and becomes visible to others after publishStream/updateStream.

Params

streamHandle

StreamHandle

handle returned by createStream

meta

Types.StreamTrackInit

track/data channel metadata (track: MediaStreamTrack, dataChannel: DataChannelMeta)

addStreamTrack(streamHandle, meta)

Returns

Promise<Types.StreamTrackId> · StreamTrackId assigned locally for this track

removeStreamTrack

Removes a previously added media track from a Stream handle. For already published streams the removal is applied on updateStream.

Params

streamHandle

StreamHandle

handle returned by createStream

meta

Types.StreamTrackInit

media track metadata previously passed to addStreamTrack

removeStreamTrack(streamHandle, meta)

publishStream

Publishes the Stream (with currently staged tracks) to the server.

Params

streamHandle

StreamHandle

handle returned by createStream

onStreamState

(state: RTCPeerConnectionState) => void

optional callback invoked on RTCPeerConnection state changes

publishStream(streamHandle, onStreamState)

Returns

Promise<StreamPublishResult> · result of the publish operation

updateStream

Updates a published Stream after adding/removing tracks.

Params

streamHandle

StreamHandle

handle returned by createStream

updateStream(streamHandle)

Returns

Promise<StreamPublishResult> · result of the update operation

unpublishStream

Stops publishing the Stream.

Params

streamHandle

StreamHandle

handle returned by createStream

unpublishStream(streamHandle)

subscribeToRemoteStreams

Subscribes to selected remote streams (and optionally specific tracks) in the Stream Room.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room

subscriptions

EndpointTypes.StreamSubscription[]

list of remote streams/tracks to subscribe to

subscribeToRemoteStreams(streamRoomId, subscriptions)

modifyRemoteStreamsSubscriptions

Modifies current remote streams subscriptions.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room

subscriptionsToAdd

EndpointTypes.StreamSubscription[]

list of subscriptions to add

subscriptionsToRemove

StreamSubscription[]

list of subscriptions to remove

modifyRemoteStreamsSubscriptions(streamRoomId, subscriptionsToAdd, subscriptionsToRemove)

unsubscribeFromRemoteStreams

Unsubscribes from selected remote streams (and optionally specific tracks) in the Stream Room.

Params

streamRoomId

Types.StreamRoomId

ID of the Stream Room

subscriptions

StreamSubscription[]

list of subscriptions to remove

unsubscribeFromRemoteStreams(streamRoomId, subscriptions)

addRemoteStreamListener

Registers a listener for remote tracks in the Stream Room.

Params

listener

RemoteStreamListener

listener configuration

addRemoteStreamListener(listener)

subscribeFor

Subscribe for the Stream Room events on the given subscription query.

Params

subscriptionQueries

string[]

list of queries

subscribeFor(subscriptionQueries)

Returns

Promise<string[]> · list of subscriptionIds in maching order to subscriptionQueries

unsubscribeFrom

Unsubscribe from events for the given subscriptionId.

Params

subscriptionIds

string[]

list of subscriptionId

unsubscribeFrom(subscriptionIds)

buildSubscriptionQuery

Generate subscription Query for the Stream Room events.

Params

eventType

StreamEventType

type of event which you listen for

selectorType

StreamEventSelectorType

scope on which you listen for events

selectorId

string

ID of the selector

buildSubscriptionQuery(eventType, selectorType, selectorId)

Returns

Promise<string> · subscription ID

addAudioLevelStatsListener

Registers a callback for audio level statistics produced by the WebRTC client.

Params

onStats

(stats: AudioLevelsStats) => void

callback invoked with current audio levels stats

addAudioLevelStatsListener(onStats)

sendData

Sends binary data over a WebRTC DataChannel associated with a published Stream data track.

Params

streamTrackId

Types.StreamTrackId

StreamTrackId of the data track created via addStreamTrack

data

Uint8Array

bytes to send to remote participants

sendData(streamTrackId, data)

We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.

StreamApi | PrivMX Docs