Home Reference Source
import {LocalMediaHandler} from '@quobis/sippojs'
public class | source

LocalMediaHandler

Provides access to methods for managing actions related to local media. Instances of this class are obtained calling Call#getLocalMediaHandler or Conference#getLocalMediaHandler

Events

  • videoStream - Emitted every time videoStream changes.
  • * - Emitted every time a change that can affect to any property happens.

Method Summary

Public Methods
public

Updates media types adding video when screen is false or adds an internal mark to know video must be enabled when screen sharing ends.

public

Indicates if it is possible to change to a different camera

public

Indicates if video can be enabled or disabled

public

Force the update of the devices list

public

Return the MediaDeviceInfo of the active audio device

public

Return the MediaDeviceInfo of the active video device

public

Returns the list of available audio input devices

public

Returns the list of available audio output devices

public

Returns the list of available video input devices

public

getCurrentMediaConstraints(param: {mediaTypes: ?MediaTypes, mediaConstraints: ?MediaStreamConstraints}): MediaStreamConstraints

Obtains current enabled media stream constraints.

public

Return the media constraints configured for the call

public

getMediaTypes(): MediaTypes

Return the media types configured for the call

public

Returns the local video stream

public

Returns a boolean value indicating if the call has a local audio track

public

Returns a boolean value indicating if the call has a local video track

public

Returns a boolean value indicating if local audio is muted

public

Returns a boolean value indication if local video is muted

public

Mutes or unmutes the audio.

public

Mutes or unmutes the video.

public

Updates the audio input device in used to the specified one

public

Updates the video input device in used to the specified one

public

async setAvailableAudioInputDevices(availableAudioInputDevices: MediaDeviceInfo[]): Promise<undefined>

Replaces the list of available audio input devices

public

async setAvailableVideoInputDevices(availableVideoInputDevices: MediaDeviceInfo[]): Promise<undefined>

Replaces the list of available video input devices

public

Update constraints of local media.

public

async setMediaTypes(mediaTypes: MediaTypes): Promise<undefined>

Update the enabled local media.

public

Changes the local video stream to the next available camera.

public

Shares the screen.

public

Enables or disables the video.

Public Methods

public async addVideo(): Promise<undefined> source

Updates media types adding video when screen is false or adds an internal mark to know video must be enabled when screen sharing ends.

Return:

Promise<undefined>

public canToggleCamera(): boolean source

Indicates if it is possible to change to a different camera

Return:

boolean

public canToggleVideo(): boolean source

Indicates if video can be enabled or disabled

Return:

boolean

public async forceUpdateDevices() source

Force the update of the devices list

public getActiveAudioDevice(): * source

Return the MediaDeviceInfo of the active audio device

Return:

*

MediaDeviceInfo

public getActiveVideoDevice(): * source

Return the MediaDeviceInfo of the active video device

Return:

*

MediaDeviceInfo

public getAvailableAudioInputDevices(): MediaDeviceInfo[] source

Returns the list of available audio input devices

Return:

MediaDeviceInfo[]

A list of MediaDeviceInfo objects that can be used as audio input

public getAvailableAudioOutputDevices(): MediaDeviceInfo[] source

Returns the list of available audio output devices

Return:

MediaDeviceInfo[]

A list of MediaDeviceInfo objects that can be used as audio output

public getAvailableVideoInputDevices(): MediaDeviceInfo[] source

Returns the list of available video input devices

Return:

MediaDeviceInfo[]

A list of MediaDeviceInfo objects that can be used as video input

public getCurrentMediaConstraints(param: {mediaTypes: ?MediaTypes, mediaConstraints: ?MediaStreamConstraints}): MediaStreamConstraints source

Obtains current enabled media stream constraints. This is a combination of the media stream constraints configured for the call and the current media types.

Params:

NameTypeAttributeDescription
param {mediaTypes: ?MediaTypes, mediaConstraints: ?MediaStreamConstraints}

public getMediaConstraints(): MediaStreamConstraints source

Return the media constraints configured for the call

public getMediaTypes(): MediaTypes source

Return the media types configured for the call

Return:

MediaTypes

public getVideoStream(): ManagedStream | undefined source

Returns the local video stream

public hasAudioTrack(): boolean source

Returns a boolean value indicating if the call has a local audio track

Return:

boolean

public hasVideoTrack(): boolean source

Returns a boolean value indicating if the call has a local video track

Return:

boolean

public isAudioMuted(): boolean source

Returns a boolean value indicating if local audio is muted

Return:

boolean

public isVideoMuted(): boolean source

Returns a boolean value indication if local video is muted

Return:

boolean

public muteAudio(mute: boolean) source

Mutes or unmutes the audio. If no parameter is specified it toggles current value.

Params:

NameTypeAttributeDescription
mute boolean
  • optional

If specified forces audio to be mute or unmute

public muteVideo(mute: boolean) source

Mutes or unmutes the video. If no parameter is specified it toggles current value.

Note that this method just turns the emitted video black and implies no media renegotiation. Therefore, a video track will continue to be streamed. If you are instead looking for a method to stop sending video altogether check LocalMediaHandler.toggleVideo.

Params:

NameTypeAttributeDescription
mute boolean
  • optional

When specified forces video to be mute or unmute

public async setActiveAudioInputDevice(audioInputDevice: MediaDeviceInfo): Promise<undefined> source

Updates the audio input device in used to the specified one

Params:

NameTypeAttributeDescription
audioInputDevice MediaDeviceInfo
  • optional

If no value is specified the default one is selected

Return:

Promise<undefined>

public async setActiveVideoInputDevice(videoInputDevice: MediaDeviceInfo): Promise<undefined> source

Updates the video input device in used to the specified one

Params:

NameTypeAttributeDescription
videoInputDevice MediaDeviceInfo
  • optional

If no value is specified the default one is selected

Return:

Promise<undefined>

public async setAvailableAudioInputDevices(availableAudioInputDevices: MediaDeviceInfo[]): Promise<undefined> source

Replaces the list of available audio input devices

Params:

NameTypeAttributeDescription
availableAudioInputDevices MediaDeviceInfo[]

The list of MediaDeviceInfo objects to be used as audio input

Return:

Promise<undefined>

public async setAvailableVideoInputDevices(availableVideoInputDevices: MediaDeviceInfo[]): Promise<undefined> source

Replaces the list of available video input devices

Params:

NameTypeAttributeDescription
availableVideoInputDevices MediaDeviceInfo[]

The list of MediaDeviceInfo objects to be used as audio input

Return:

Promise<undefined>

public async setMediaConstraints(mediaConstraints: MediaStreamConstraints): Promise<undefined> source

Update constraints of local media. This feature is only available when the call has already been connected if "media-update" capability is present.

Params:

NameTypeAttributeDescription
mediaConstraints MediaStreamConstraints

The requested media constraints

Return:

Promise<undefined>

Example:

Change video resolution
const audio = true;
const video = {
  height: 256,
  width: 256,
};
await call.setMediaConstraints({audio, video});
console.log("media updated");

public async setMediaTypes(mediaTypes: MediaTypes): Promise<undefined> source

Update the enabled local media. This feature is only available when the call has already been connected if "media-update" capability is present.

Params:

NameTypeAttributeDescription
mediaTypes MediaTypes

The requested media

Return:

Promise<undefined>

Example:

Disable video
await call.setMediaTypes({audio: true, video: false, screen: false});
console.log("media updated");

public async toggleCamera(): Promise<undefined> source

Changes the local video stream to the next available camera.

Return:

Promise<undefined>

public async toggleScreen(screen: boolean): Promise<undefined> source

Shares the screen. This feature is only available if "screen-sharing" capability is present.

Params:

NameTypeAttributeDescription
screen boolean
  • optional

send screen if true, camera if false. If not specified it toggles from the last state.

Return:

Promise<undefined>

public async toggleVideo(video: boolean): Promise<undefined> source

Enables or disables the video. If no parameter is specified it toggles current value.

Note that this method will imply a media renegotation because the video track will be added or removed from the RTCPeerConnection. As a consequence, remote participants will receive a change in their remote participants streams.

Params:

NameTypeAttributeDescription
video boolean
  • optional

If specified forces video to be enabled or not

Return:

Promise<undefined>