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)
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)
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
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
leaveStreamRoom
Leaves a Stream Room.
Params
streamRoomId
Types.StreamRoomId
ID of the Stream Room to leave
enableStreamRoomRecording
Enables server-side recording for the Stream Room.
Params
streamRoomId
Types.StreamRoomId
ID of the Stream Room
getStreamRoomRecordingKeys
Gets encryption keys used for Stream Room recordings.
Params
streamRoomId
Types.StreamRoomId
ID of the Stream Room
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
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
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
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
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)
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
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
Returns
Promise<StreamPublishResult> ·
result of the publish operation
updateStream
Updates a published Stream after adding/removing tracks.
Params
streamHandle
StreamHandle
handle returned by createStream
Returns
Promise<StreamPublishResult> ·
result of the update operation
unpublishStream
Stops publishing the Stream.
Params
streamHandle
StreamHandle
handle returned by createStream
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
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
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
addRemoteStreamListener
Registers a listener for remote tracks in the Stream Room.
Params
listener
RemoteStreamListener
listener configuration
subscribeFor
Subscribe for the Stream Room events on the given subscription query.
Params
subscriptionQueries
string[]
list of queries
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
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
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
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
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.