Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    Class SimplePeerAVClient

    An implementation of the AVClient which uses the simple-peer library and the Foundry socket server for signaling. Credit to bekit#4213 for identifying simple-peer as a viable technology and providing a POC implementation.

    Hierarchy (View Summary)

    Index

    Properties

    audioBroadcastEnabled: boolean = false

    Is outbound broadcast of local audio enabled?

    levelsStream: MediaStream = null

    The dedicated audio stream used to measure volume levels for voice activity detection.

    localStream: MediaStream = null

    The local Stream which captures input video and audio

    master: AVMaster

    The master orchestration instance

    peers: Map<any, any> = ...

    A mapping of connected peers

    remoteStreams: Map<any, any> = ...

    A mapping of connected remote streams

    settings: AVSettings

    The active audio/video settings being used

    Accessors

    • get isMuted(): boolean

      Is the current user muted?

      Returns boolean

    • get isVoiceActivated(): boolean

      Is audio broadcasting voice-activation enabled?

      Returns boolean

    • get isVoiceAlways(): boolean

      Is audio broadcasting always enabled?

      Returns boolean

    • get isVoicePTT(): boolean

      Is audio broadcasting push-to-talk enabled?

      Returns boolean

    Methods

    • Listen for Audio/Video updates on the av socket to broker connections between peers

      Returns void

    • Returns Promise<boolean>

    • Connect to a peer directly, either as the initiator or as the receiver

      Parameters

      • userId: string

        The Foundry user ID with whom we are connecting

      • isInitiator: boolean = false

        Is the current user initiating the connection, or responding to it?

      Returns SimplePeer

      The constructed and configured SimplePeer instance

    • Disconnect from all current peer streams

      Returns Promise<any[]>

      A Promise which resolves once all peers have been disconnected

    • Disconnect from a peer by stopping current stream tracks and destroying the SimplePeer instance

      Parameters

      • userId: string

        The Foundry user ID from whom we are disconnecting

      Returns Promise<void>

      A Promise which resolves once the disconnection is complete

    • Provide an Object of available audio sources which can be used by this implementation. Each object key should be a device id and the key should be a human-readable label.

      Returns Promise<{ object: any }>

    • Provide an Object of available audio sources which can be used by this implementation. Each object key should be a device id and the key should be a human-readable label.

      Returns Promise<{ object: any }>

    • Provide an Object of available video sources which can be used by this implementation. Each object key should be a device id and the key should be a human-readable label.

      Returns Promise<{ object: any }>

    • Initialize a local media stream for the current user

      Returns Promise<MediaStream>

    • Initialize a stream connection with a new peer

      Parameters

      • userId: string

        The Foundry user ID for which the peer stream should be established

      Returns Promise<SimplePeer>

      A Promise which resolves once the peer stream is initialized

    • Parameters

      • changed: any

      Returns Promise<void>

    • Receive a request to establish a peer signal with some other User id

      Parameters

      • userId: string

        The Foundry user ID who is requesting to establish a connection

      • data: object

        The connection details provided by SimplePeer

      Returns void

    • Parameters

      • userId: any
      • videoElement: any

      Returns Promise<void>

    • Parameters

      • enabled: any

      Returns void

    • Parameters

      • enabled: any

      Returns void

    • Replace the local stream for each connected peer with a re-generated MediaStream.

      Returns Promise<void>