The MediaDeviceService allows the application to manage the devices that are used during the conference.

Typical application workflow:

1. The application calls the getEglContext method to get the WebRTC EglBaseContext to share WebRTC mechanisms with the application.

2. The application sets the MediaCryptoCallback through the setCryptoCallback method to internally register the component for encrypting and decrypting WebRTC communication packets.

3. Then, the application is able to attach the stream to the specific receiver using the attachMediaStream method. It can detach the stream by calling the unAttachMediaStream method.

4. The application can also check information about cameras in use through the getCameraContext method. The switchCamera method enables the app to change the current camera to another one.

Available in the package



getEglContext(): EglBaseInteracts.Context

Gets EglBaseContext from WebRTC to share WebRTC mechanisms with the application.

Returns: @Nullable EglBaseInteracts.Context - the current EglBaseContext or a null value if media are not created.


setCryptoCallback(@Nullable callback: AbstractNativeMediaCryptoCallback): void

Enables MediaCryptoCallback.

Note: This method is disabled by default. Before joining conferences, turn setCryptoCallback off and on again.


callbackAbstractNativeMediaCryptoCallbacknullable callback, the null value disables the callback


attachMediaStream(@NonNull stream: MediaStream, @NonNull videoSink: VideoSink): boolean

Attaches a stream to the given receiver.

Note: If a stream is already attached to the receiver, this method will detach it.


streamMediaStreamnon null valid media stream to attach
videoSinkVideoSinknon null videosink that will receive updates

Returns: boolean


unAttachMediaStream(@NonNull videoSink: VideoSink): boolean

Detaches the stream from the given videoSink.


videoSinkVideoSinknon null receiver instance

Returns: boolean - the release indicator.


switchCamera(): Promise<Boolean>

Switches the current camera to another available camera that is connected to the device. On Android, the second camera exists by default but on other devices, there may be none, one, two, or even more cameras.

It updates the camera provider's information with the new camera type: front or back.

Returns: @NonNull Promise<Boolean> - the promise to resolve.


getCameraContext(): CameraContext

Retrieves the instance of the camera information.

Returns: @NonNull CameraContext - the CameraContext