IController is a controller interface extending a stream connector with the capability of sending and receiving commands with the server.

This interface can serve the both roles: player or streamer.

Hierarchy

Implemented by

Properties

closed: boolean

True when connector is closed, in other words when onClose event is fired

codecs: Set<string>

Indicate codecs supported, should be set before than onOpen happen

log: ILog

Start a log

Param

Returns

a Log object with the levels of log to call

opened: boolean

True when connector is opened, in other words when onOpen event is fired

stream?: MediaStream

Media Stream description delivred from the server if we are player, or build from the local camera if we are the streamer.

streamName: string

Stream name, for example as+bc3f535f-37f3-458b-8171-b4c5e77a6137

Methods

  • Event unsubscription

    Parameters

    • name: "open" | "close" | "playing" | "Close" | "RTPProps" | "MediaReport" | "VideoBitrate" | "Playing" | "Open" | "rtpprops" | "mediareport" | "videobitrate"

      Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)

    • event: Function

      Unsubscriber Function, must be the one passed to on or once subscription methods

    Returns boolean

  • Event subscription

    Parameters

    • name: "open" | "close" | "playing" | "Close" | "RTPProps" | "MediaReport" | "VideoBitrate" | "Playing" | "Open" | "rtpprops" | "mediareport" | "videobitrate"

      Name of event without the on prefix (ex: log to onLog event declared)

    • event: Function

      Subscriber Function

    • Optional options: {
          signal?: AbortSignal;
      }
      • Optional signal?: AbortSignal

        Optional AbortSignal to stop this or multiple subscriptions in same time

    Returns void

  • Event subscription only one time, once time fired it's automatically unsubscribe

    Parameters

    • name: "open" | "close" | "playing" | "Close" | "RTPProps" | "MediaReport" | "VideoBitrate" | "Playing" | "Open" | "rtpprops" | "mediareport" | "videobitrate"

      Name of event without the on prefix (ex: log to onLog event declared)

    • event: Function

      Subscriber Function

    • Optional options: {
          signal?: AbortSignal;
      }
      • Optional signal?: AbortSignal

        Optional AbortSignal to stop this or multiple subscriptions in same time

    Returns void

  • Parameters

    • kind: "audio" | "video"

      'video' or 'audio' to replace the track of the given kind

    • track: null | MediaStreamTrack

    Returns Promise<void>

    Promise that resolves when the track is replaced

    Throws

    Error if the kind is not supported or if the operation fails

    This method allows to replace the current track of the given kind with a new one. If the track is null, it will remove the current track of that kind.

  • Send a generic command to control the streaming session

    Parameters

    • type: string

      type of command

    • params: object

      parameters of the command

    Returns void

    Example

    controller.send('video_bitrate', {video_bitrate: 0});
    
  • Sets server properties for packet error (nack) and delayed packet loss (drop) for a streamer controller and fires an onRTPProps event if changed successfully. NOTE: Method can also retrieve current server values if called without arguments.

    Parameters

    • Optional nack: number

      Waiting period before declaring a packet error

    • Optional drop: number

      Waiting period before considering delayed packets as lost

    Returns void

  • Configure the audio and video track to play for a player controller

    Parameters

    • tracks: {
          audio?: number;
          video?: number;
      }
      • Optional audio?: number

        Audio track

      • Optional video?: number

        Video track

    Returns void

  • Configure the video bitrate on the server side for a streamer controller

    Parameters

    • value: number

      video bitrate in bps

    Returns void

Events

  • Call when connector is open

    Parameters

    • stream: MediaStream

      MediaStream description provided from the server if we are the player, or build from the local camera if we are the streamer.

    Returns void

  • Call to distribute video bitrate informations

    Parameters

    • videoBitrate: number

      Current video bitrate

    • videoBitrateConstraint: number

      Video bitrate constraint computed by the server

    Returns void

Generated using TypeDoc