Signaling

Signaling

Starts WebSocket connection and manages the messages between peers.

Constructor

# new Signaling(options)

Parameters:
Name Type Description
options Object

General signaling options.

Properties
Name Type Description
streamName String

Millicast stream name to get subscribed.

url String

WebSocket URL to signal Millicast server and establish a WebRTC connection.

Example
const millicastSignaling = new Signaling(options)

Extends

  • EventEmitter

Methods

# close()

Close WebSocket connection with Millicast server.

Example
millicastSignaling.close()

# (async) cmd(cmd, dataopt) → {Promise.<Object>}

Send command to the server.

Parameters:
Name Type Attributes Description
cmd String

Command name.

data Object <optional>

Command parameters.

Returns:

Promise object which represents the command response.

Type
Promise.<Object>

# (async) connect() → {Promise.<WebSocket>}

Starts a WebSocket connection with signaling server.

Returns:

Promise object which represents the WebSocket object of the establshed connection.

Type
Promise.<WebSocket>
Example
const response = await millicastSignaling.connect()

# (async) publish(sdp, options, recordopt, sourceIdopt) → {Promise.<String>}

Establish WebRTC connection with Millicast Server as Publisher role.

Parameters:
Name Type Attributes Default Description
sdp String

The SDP information created by your offer.

options SignalingPublishOptions | VideoCodec

Signaling Publish Options or Deprecated Codec for publish stream (h264 default).

record Boolean <optional>
null

Deprecated, use options parameter instead Enable stream recording. If record is not provided, use default Token configuration. Only available in Tokens with recording enabled.

sourceId String <optional>
null

Deprecated, use options parameter instead Source unique id. Only available in Tokens with multisource enabled.*

Returns:

Promise object which represents the SDP command response.

Type
Promise.<String>
Example
const response = await millicastSignaling.publish(sdp, {codec: 'h264'})

# (async) subscribe(sdp, options, pinnedSourceId, excludedSourceIds) → {Promise.<String>}

Establish WebRTC connection with Millicast Server as Subscriber role.

Parameters:
Name Type Default Description
sdp String

The SDP information created by your offer.

options SignalingSubscribeOptions | Boolean

Signaling Subscribe Options or Deprecated Enable VAD multiplexing for secondary sources.

pinnedSourceId String null

Deprecated, use options parameter instead Id of the main source that will be received by the default MediaStream.

excludedSourceIds Array.<String> null

Deprecated, use options parameter instead Do not receive media from the these source ids.

Returns:

Promise object which represents the SDP command response.

Type
Promise.<String>
Example
const response = await millicastSignaling.subscribe(sdp)

Events

# broadcastEvent

Passthrough of available Millicast broadcast events.

Active - Fires when the live stream is, or has started broadcasting.

Inactive - Fires when the stream has stopped broadcasting, but is still available.

Stopped - This event is not currently used, but is reserved for future usage.

Viewercount - Fires when the viewer count changes.

More information here: https://docs.dolby.io/streaming-apis/docs/web#broadcast-events

Type:
  • Object
Properties
Name Type Description
type String

In this case the type of this message is "event".

name "active" | "inactive" | "stopped" | "vad" | "layers" | "migrate" | "viewercount"

Event name.

data String | Date | Array | Object

Custom event data.

# wsConnectionClose

WebSocket connection with signaling server was successfully closed.

# wsConnectionError

WebSocket connection failed with signaling server. Returns url of WebSocket

Type:
  • String

# wsConnectionSuccess

WebSocket connection was successfully established with signaling server.

Type:
  • Object
Properties
Name Type Description
ws WebSocket

WebSocket object which represents active connection.

tm TransactionManager

TransactionManager object that simplify WebSocket commands.