Class: ELive

ELive(config)

Main class for ElasticLive. It can help to make P2P call and broadcast room. It can also join the broadcast room and adjust constraints.

The order of using ELive is as follows.

  • Create a Config object.
  • Create an ELive object.
  • Call the call () method for communication, call the cast () method for creating a broadcast, and call the watch method when watching a broadcast.
  • Execute callback with elive.on ('event').
  • Exit the ELive object. by close ()
  • Callback events

    ELive callback events include the following.

  • onDisplayUserMedia: event that occurs when taking control of the local media device.
  • onCall: event that occurs when the call method is succeeds. If the other peer is not yet connected, real connection is established when the onComplete event.
  • onComplete: event that occurs when two peers connect to each other via the call method with same room name.
  • onCast: event that occurs when the cast method is succeeds.
  • onWatch: event that occurs when the watch method is succeeds.
  • onMessage: event that occurs when the other peer send a message to this peer.
  • onSearch: event that occurs when the search methos is succeeds.
  • Basic example

Constructor

new ELive(config)

Constructor of ELive
Parameters:
Name Type Description
config config please refer the config page
Example
const elive = new ELive({...})
elive.call('demo')
elive.on('onCall|onCast|onWatch|onComplete', (msg) => {})
...
elive.close()

Methods

(async) call(name)

Create or join a 1:1 room. You can receive a 'onCall' and 'onComplete' callback events.
Parameters:
Name Type Description
name string name of 1:1 room

(async) captureScreen()

Capture the screen and use it as the source of local media.

(async) cast(name)

Create a broadcast room. You can receive a 'onCast' callback event.
Parameters:
Name Type Description
name string name of broadcast room

(async) close()

Close all connection

getDevices()

Get list of all local media devices such as video, speaker and mic.

getHealth()

Get the quality of the stream realtime. WebRTC is variable in quality depending on network conditions.

getRoomId()

Get a room id

muteLocal(isMute)

Mute local media
Parameters:
Name Type Description
isMute boolean

muteRemote(isMute)

Mute remote media
Parameters:
Name Type Description
isMute boolean

onEvent(message)

Method for callback event to sdk users.

ELive callback events include the following.

  • onDisplayUserMedia: event that occurs when taking control of the local media device.
  • onCall: event that occurs when the call method is succeeds. If the other peer is not yet connected, real connection is established when the onComplete event.
  • onComplete: event that occurs when two peers connect to each other via the call method with same room name.
  • onCast: event that occurs when the cast method is succeeds.
  • onWatch: event that occurs when the watch method is succeeds.
  • onMessage: event that occurs when the other peer send a message to this peer.
  • onSearch: event that occurs when the search methos is succeeds.
  • Parameters:
    Name Type Description
    message EventEmitter.message
    Search the room of the current service. If there is no parameter, it searches all rooms of the service.
    Parameters:
    Name Type Description
    id string search keyword for room

    sendMessage(msg)

    Send a message to a peer. It can be used for text messaging and data transfer. It is only available in P2P mode yet.
    Parameters:
    Name Type Description
    msg string

    setAgc()

    Set the AutoGainControl value. Default value is a true.

    (async) setAudioInput()

    Use a specific audio input device as local media. You can gather a device list from getDevices()

    setChannelCount()

    Set the number of audio channel. Default value is 2.

    setEchoCancellation()

    Set the echo canellation value. Default value is a true.

    setFrameRate()

    Set the framerate value. It is selectable from 10 to 30.

    setLatency()

    Set the echo latency of audio.

    setNoiseSuppression()

    Set the noise suppression value. Default value is a true.

    setResolution()

    Set the resolution value. It is selectable from 240p to 1280p. Default value is a (640,480)

    (async) setVideoInput()

    Use a specific video input device as local media. You can gather a device list from getDevices()

    setVolume()

    volume value should be number from 0.0 to 1.0.

    (async) showLocalVideo()

    Use this when you want to display the local input device in the local video tag before calling call or cast method.

    stopCaptureScreen()

    Stop the captureScreen

    (async) switchCamera()

    If there is more than one camera, switch it.

    (async) watch(name)

    Participate to a broadcast room as a viewer. You can receive a 'onWatch' callback event.
    Parameters:
    Name Type Description
    name string name of broadcast room