-
- All Implemented Interfaces:
-
io.livekit.android.room.RTCEngine.Listener,io.livekit.android.room.datastream.incoming.IncomingDataStreamManager,io.livekit.android.room.participant.ParticipantListener,io.livekit.android.room.rpc.RpcManager
public final class Room implements RTCEngine.Listener, ParticipantListener, RpcManager, IncomingDataStreamManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumRoom.Statepublic final classRoom.Sid
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Room(Context context, RTCEngine engine, EglBase eglBase, LocalParticipant.Factory localParticipantFactory, DefaultsManager defaultsManager, CoroutineDispatcher defaultDispatcher, CoroutineDispatcher ioDispatcher, AudioHandler audioHandler, CloseableManager closeableManager, E2EEManager.Factory e2EEManagerFactory, CommunicationWorkaround communicationWorkaround, AudioProcessingController audioProcessingController, LKObjects lkObjects, Function1<ConnectivityManager.NetworkCallback, NetworkCallbackManager> networkCallbackManagerFactory, AudioDeviceModule audioDeviceModule, RegionUrlProvider.Factory regionUrlProviderFactory, ConnectionWarmer connectionWarmer, AudioRecordPrewarmer audioRecordPrewarmer, IncomingDataStreamManager incomingDataStreamManager, RemoteParticipant.Factory remoteParticipantFactory)
-
Method Summary
Modifier and Type Method Description final EventListenable<RoomEvent>getEvents()final Room.SidgetSid()The session id of the room. final UnitsetSid(@FlowObservable() Room.Sid sid)final StringgetName()final UnitsetName(@FlowObservable() String name)final Room.StategetState()final UnitsetState(@FlowObservable() Room.State state)final StringgetMetadata()final UnitsetMetadata(@FlowObservable() String metadata)final BooleangetIsRecording()final UnitsetIsRecording(@FlowObservable() Boolean isRecording)final E2EEManagergetE2eeManager()end-to-end encryption manager final UnitsetE2eeManager(E2EEManager e2eeManager)end-to-end encryption manager final BooleangetAdaptiveStream()Automatically manage quality of subscribed video tracks, subscribe to the an appropriate resolution based on the size of the video elements that tracks are attached to. final UnitsetAdaptiveStream(Boolean adaptiveStream)Automatically manage quality of subscribed video tracks, subscribe to the an appropriate resolution based on the size of the video elements that tracks are attached to. final BooleangetAudioProcessorIsEnabled()audio processing is enabled final UnitsetAudioProcessorIsEnabled(Boolean audioProcessorIsEnabled)audio processing is enabled final BooleangetDynacast()final UnitsetDynacast(Boolean dynacast)final E2EEOptionsgetE2eeOptions()Options for end-to-end encryption. final UnitsetE2eeOptions(E2EEOptions e2eeOptions)Options for end-to-end encryption. final LocalAudioTrackOptionsgetAudioTrackCaptureDefaults()Default options to use when creating an audio track. final UnitsetAudioTrackCaptureDefaults(LocalAudioTrackOptions audioTrackCaptureDefaults)Default options to use when creating an audio track. final AudioTrackPublishDefaultsgetAudioTrackPublishDefaults()Default options to use when publishing an audio track. final UnitsetAudioTrackPublishDefaults(AudioTrackPublishDefaults audioTrackPublishDefaults)Default options to use when publishing an audio track. final LocalVideoTrackOptionsgetVideoTrackCaptureDefaults()Default options to use when creating a video track. final UnitsetVideoTrackCaptureDefaults(LocalVideoTrackOptions videoTrackCaptureDefaults)Default options to use when creating a video track. final VideoTrackPublishDefaultsgetVideoTrackPublishDefaults()Default options to use when publishing a video track. final UnitsetVideoTrackPublishDefaults(VideoTrackPublishDefaults videoTrackPublishDefaults)Default options to use when publishing a video track. final LocalVideoTrackOptionsgetScreenShareTrackCaptureDefaults()Default options to use when creating a screen share track. final UnitsetScreenShareTrackCaptureDefaults(LocalVideoTrackOptions screenShareTrackCaptureDefaults)Default options to use when creating a screen share track. final VideoTrackPublishDefaultsgetScreenShareTrackPublishDefaults()Default options to use when publishing a screen share track. final UnitsetScreenShareTrackPublishDefaults(VideoTrackPublishDefaults screenShareTrackPublishDefaults)Default options to use when publishing a screen share track. final ReconnectPolicygetReconnectPolicy()ReconnectPolicy to use when reconnecting to the server. final UnitsetReconnectPolicy(ReconnectPolicy reconnectPolicy)ReconnectPolicy to use when reconnecting to the server. final LocalParticipantgetLocalParticipant()final Map<Participant.Identity, RemoteParticipant>getRemoteParticipants()final AudioSwitchHandlergetAudioSwitchHandler()final ServerInfogetServerInfo()final List<Participant>getActiveSpeakers()final AudioHandlergetAudioHandler()The AudioHandler for setting up the audio as need. final AudioProcessingControllergetAudioProcessingController()final LKObjectsgetLkObjects()A holder for objects that are used internally within LiveKit. final Room.SidgetSid()Gets the sid of the room. final UnitprepareConnection(String url, String token)prepareConnection should be called as soon as the page is loaded, in order to speed up the connection attempt. final <ERROR CLASS>connect(String url, String token, ConnectOptions options)Connect to a LiveKit Room. final Unitdisconnect()Disconnect from the room. final UnitsetRoomOptions(RoomOptions options)Copies all the options to the Room object. final Unitrelease()Release all resources held by this object. final ParticipantgetParticipantBySid(String sid)final ParticipantgetParticipantBySid(Participant.Sid sid)final ParticipantgetParticipantByIdentity(String identity)final ParticipantgetParticipantByIdentity(Participant.Identity identity)final UnitsetSpeakerMute(Boolean muted)Control muting/unmuting all audio output. final UnitsetMicrophoneMute(Boolean muted)Control muting/unmuting the audio input. UnitregisterRpcMethod(String method, SuspendFunction1<RpcInvocationData, String> handler)Establishes the participant as a receiver for calls of the specified RPC method. UnitunregisterRpcMethod(String method)Unregisters a previously registered RPC method. StringperformRpc(Participant.Identity destinationIdentity, String method, String payload, Duration responseTimeout)Initiate an RPC call to a remote participant UnitonRpcPacketReceived(LivekitModels.DataPacket dp)final UnitinitVideoRenderer(SurfaceViewRenderer viewRenderer)Initialize a SurfaceViewRenderer for rendering a video from this room. final UnitinitVideoRenderer(TextureViewRenderer viewRenderer)Initialize a TextureViewRenderer for rendering a video from this room. final UnitgetPublisherRTCStats(RTCStatsCollectorCallback callback)Get stats for the publisher peer connection. final UnitgetSubscriberRTCStats(RTCStatsCollectorCallback callback)Get stats for the subscriber peer connection. -
Methods inherited from class io.livekit.android.room.Room
onDataReceived, onEngineResumed, onEngineResuming, onSpeakingChanged, onTrackPublished, registerByteStreamHandler, registerTextStreamHandler, unregisterByteStreamHandler, unregisterTextStreamHandler -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
Room
Room(Context context, RTCEngine engine, EglBase eglBase, LocalParticipant.Factory localParticipantFactory, DefaultsManager defaultsManager, CoroutineDispatcher defaultDispatcher, CoroutineDispatcher ioDispatcher, AudioHandler audioHandler, CloseableManager closeableManager, E2EEManager.Factory e2EEManagerFactory, CommunicationWorkaround communicationWorkaround, AudioProcessingController audioProcessingController, LKObjects lkObjects, Function1<ConnectivityManager.NetworkCallback, NetworkCallbackManager> networkCallbackManagerFactory, AudioDeviceModule audioDeviceModule, RegionUrlProvider.Factory regionUrlProviderFactory, ConnectionWarmer connectionWarmer, AudioRecordPrewarmer audioRecordPrewarmer, IncomingDataStreamManager incomingDataStreamManager, RemoteParticipant.Factory remoteParticipantFactory)
-
-
Method Detail
-
getEvents
final EventListenable<RoomEvent> getEvents()
-
getSid
@FlowObservable() final Room.Sid getSid()
-
setSid
final Unit setSid(@FlowObservable() Room.Sid sid)
-
getName
@FlowObservable() final String getName()
-
setName
final Unit setName(@FlowObservable() String name)
-
getState
@FlowObservable() final Room.State getState()
-
setState
final Unit setState(@FlowObservable() Room.State state)
-
getMetadata
@FlowObservable() final String getMetadata()
-
setMetadata
final Unit setMetadata(@FlowObservable() String metadata)
-
getIsRecording
@FlowObservable() final Boolean getIsRecording()
-
setIsRecording
final Unit setIsRecording(@FlowObservable() Boolean isRecording)
-
getE2eeManager
final E2EEManager getE2eeManager()
end-to-end encryption manager
-
setE2eeManager
final Unit setE2eeManager(E2EEManager e2eeManager)
end-to-end encryption manager
-
getAdaptiveStream
final Boolean getAdaptiveStream()
Automatically manage quality of subscribed video tracks, subscribe to the an appropriate resolution based on the size of the video elements that tracks are attached to.
Also observes the visibility of attached tracks and pauses receiving data if they are not visible.
Defaults to false.
-
setAdaptiveStream
final Unit setAdaptiveStream(Boolean adaptiveStream)
Automatically manage quality of subscribed video tracks, subscribe to the an appropriate resolution based on the size of the video elements that tracks are attached to.
Also observes the visibility of attached tracks and pauses receiving data if they are not visible.
Defaults to false.
-
getAudioProcessorIsEnabled
final Boolean getAudioProcessorIsEnabled()
audio processing is enabled
-
setAudioProcessorIsEnabled
final Unit setAudioProcessorIsEnabled(Boolean audioProcessorIsEnabled)
audio processing is enabled
-
getDynacast
final Boolean getDynacast()
-
setDynacast
final Unit setDynacast(Boolean dynacast)
-
getE2eeOptions
final E2EEOptions getE2eeOptions()
Options for end-to-end encryption. Must be setup prior to connect.
If null, e2ee will be disabled.
-
setE2eeOptions
final Unit setE2eeOptions(E2EEOptions e2eeOptions)
Options for end-to-end encryption. Must be setup prior to connect.
If null, e2ee will be disabled.
-
getAudioTrackCaptureDefaults
final LocalAudioTrackOptions getAudioTrackCaptureDefaults()
Default options to use when creating an audio track.
-
setAudioTrackCaptureDefaults
final Unit setAudioTrackCaptureDefaults(LocalAudioTrackOptions audioTrackCaptureDefaults)
Default options to use when creating an audio track.
-
getAudioTrackPublishDefaults
final AudioTrackPublishDefaults getAudioTrackPublishDefaults()
Default options to use when publishing an audio track.
-
setAudioTrackPublishDefaults
final Unit setAudioTrackPublishDefaults(AudioTrackPublishDefaults audioTrackPublishDefaults)
Default options to use when publishing an audio track.
-
getVideoTrackCaptureDefaults
final LocalVideoTrackOptions getVideoTrackCaptureDefaults()
Default options to use when creating a video track.
-
setVideoTrackCaptureDefaults
final Unit setVideoTrackCaptureDefaults(LocalVideoTrackOptions videoTrackCaptureDefaults)
Default options to use when creating a video track.
-
getVideoTrackPublishDefaults
final VideoTrackPublishDefaults getVideoTrackPublishDefaults()
Default options to use when publishing a video track.
-
setVideoTrackPublishDefaults
final Unit setVideoTrackPublishDefaults(VideoTrackPublishDefaults videoTrackPublishDefaults)
Default options to use when publishing a video track.
-
getScreenShareTrackCaptureDefaults
final LocalVideoTrackOptions getScreenShareTrackCaptureDefaults()
Default options to use when creating a screen share track.
-
setScreenShareTrackCaptureDefaults
final Unit setScreenShareTrackCaptureDefaults(LocalVideoTrackOptions screenShareTrackCaptureDefaults)
Default options to use when creating a screen share track.
-
getScreenShareTrackPublishDefaults
final VideoTrackPublishDefaults getScreenShareTrackPublishDefaults()
Default options to use when publishing a screen share track.
-
setScreenShareTrackPublishDefaults
final Unit setScreenShareTrackPublishDefaults(VideoTrackPublishDefaults screenShareTrackPublishDefaults)
Default options to use when publishing a screen share track.
-
getReconnectPolicy
final ReconnectPolicy getReconnectPolicy()
ReconnectPolicy to use when reconnecting to the server.
-
setReconnectPolicy
final Unit setReconnectPolicy(ReconnectPolicy reconnectPolicy)
ReconnectPolicy to use when reconnecting to the server.
-
getLocalParticipant
final LocalParticipant getLocalParticipant()
-
getRemoteParticipants
@FlowObservable() final Map<Participant.Identity, RemoteParticipant> getRemoteParticipants()
-
getAudioSwitchHandler
final AudioSwitchHandler getAudioSwitchHandler()
-
getServerInfo
final ServerInfo getServerInfo()
-
getActiveSpeakers
@FlowObservable() final List<Participant> getActiveSpeakers()
-
getAudioHandler
final AudioHandler getAudioHandler()
The AudioHandler for setting up the audio as need.
By default, this is an instance of AudioSwitchHandler.
This can be substituted for your own custom implementation through LiveKitOverrides.audioOptions when creating the room with LiveKit.create.
-
getAudioProcessingController
final AudioProcessingController getAudioProcessingController()
-
getLkObjects
final LKObjects getLkObjects()
A holder for objects that are used internally within LiveKit.
-
getSid
final Room.Sid getSid()
Gets the sid of the room.
If the sid is not yet available, will suspend until received.
-
prepareConnection
final Unit prepareConnection(String url, String token)
prepareConnection should be called as soon as the page is loaded, in order to speed up the connection attempt. This function will
perform DNS resolution and pre-warm the DNS cache
establish TLS connection and cache TLS keys
With LiveKit Cloud, it will also determine the best edge data center for the current client to connect to if a token is provided.
-
connect
final <ERROR CLASS> connect(String url, String token, ConnectOptions options)
Connect to a LiveKit Room.
-
disconnect
final Unit disconnect()
Disconnect from the room.
-
setRoomOptions
final Unit setRoomOptions(RoomOptions options)
Copies all the options to the Room object.
Any null values in options will not overwrite existing values. To clear existing values on the Room object, explicitly set the value directly instead of using this method.
-
release
final Unit release()
Release all resources held by this object.
Once called, this room object must not be used to connect to a server and a new one must be created.
-
getParticipantBySid
final Participant getParticipantBySid(String sid)
-
getParticipantBySid
final Participant getParticipantBySid(Participant.Sid sid)
-
getParticipantByIdentity
final Participant getParticipantByIdentity(String identity)
-
getParticipantByIdentity
final Participant getParticipantByIdentity(Participant.Identity identity)
-
setSpeakerMute
final Unit setSpeakerMute(Boolean muted)
Control muting/unmuting all audio output.
Note: using this mute will only mute local audio output, and will still receive the data from remote audio tracks. Consider turning off ConnectOptions.autoSubscribe and manually unsubscribing if you need more fine-grained control over the data usage.
-
setMicrophoneMute
final Unit setMicrophoneMute(Boolean muted)
Control muting/unmuting the audio input.
Note: using this mute will only zero the microphone audio data, and will still send data to remote participants (although they will not hear anything). Consider using TrackPublication.muted for more fine-grained control over the data usage.
-
registerRpcMethod
Unit registerRpcMethod(String method, SuspendFunction1<RpcInvocationData, String> handler)
Establishes the participant as a receiver for calls of the specified RPC method. Will overwrite any existing callback for the same method.
Example:
room.registerRpcMethod("greet") { (requestId, callerIdentity, payload, responseTimeout) -> Log.i("TAG", "Received greeting from ${callerIdentity}: ${payload}") // Return a string "Hello, ${callerIdentity}!" }The handler receives an RpcInvocationData with the following parameters:
requestId: A unique identifier for this RPC requestcallerIdentity: The identity of the RemoteParticipant who initiated the RPC callpayload: The data sent by the caller (as a string)responseTimeout: The maximum time available to return a response
The handler should return a string. If unable to respond within RpcInvocationData.responseTimeout, the request will result in an error on the caller's side.
You may throw errors of type RpcError with a string
messagein the handler, and they will be received on the caller's side with the message intact. Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as1500("Application Error").- Parameters:
method- The name of the indicated RPC methodhandler- Will be invoked when an RPC request for this method is received
-
unregisterRpcMethod
Unit unregisterRpcMethod(String method)
Unregisters a previously registered RPC method.
- Parameters:
method- The name of the RPC method to unregister
-
performRpc
String performRpc(Participant.Identity destinationIdentity, String method, String payload, Duration responseTimeout)
Initiate an RPC call to a remote participant
- Parameters:
destinationIdentity- The identity of the destination participant.method- The method name to call.payload- The payload to pass to the method.responseTimeout- Timeout for receiving a response after initial connection.
-
onRpcPacketReceived
Unit onRpcPacketReceived(LivekitModels.DataPacket dp)
-
initVideoRenderer
final Unit initVideoRenderer(SurfaceViewRenderer viewRenderer)
Initialize a SurfaceViewRenderer for rendering a video from this room.
-
initVideoRenderer
final Unit initVideoRenderer(TextureViewRenderer viewRenderer)
Initialize a TextureViewRenderer for rendering a video from this room.
-
getPublisherRTCStats
final Unit getPublisherRTCStats(RTCStatsCollectorCallback callback)
Get stats for the publisher peer connection.
-
getSubscriberRTCStats
final Unit getSubscriberRTCStats(RTCStatsCollectorCallback callback)
Get stats for the subscriber peer connection.
-
-
-
-