MultimediaSession

Represents an active voice session within a conversation.

A MultimediaSession provides:

Lifecycle

  1. A session is created in MultimediaSessionStatus.Created status.

  2. Call join to begin the audio connection (MultimediaSessionStatus.Connecting).

  3. Once connected, status becomes MultimediaSessionStatus.Connected or MultimediaSessionStatus.Answered when a remote participant joins.

  4. Call end (or leave) to terminate the session (MultimediaSessionStatus.Ended).

Observe lifecycle transitions via the event flow, which emits MultimediaSessionEvent instances.

See also

Samples

session.muteMicrophone()
session.unmuteMicrophone()
session.hold(true)
session.activate()
session.end()
scope.launch {
    session.event.collect { event ->
        when (event) {
            is MultimediaSessionEvent.Connection.Connected -> {
                // Call connected successfully
            }
            is MultimediaSessionEvent.Connection.Reconnecting -> {
                // Network interruption, attempting to reconnect
            }
            is MultimediaSessionEvent.Connection.Disconnected -> {
                // Call ended or lost connection
            }
            is MultimediaSessionEvent.ParticipantChanged -> {
                // Agent joined or participant state changed
            }
            is MultimediaSessionEvent.Error -> {
                val errorCode = event.code
            }
            else -> {}
        }
    }
}

Properties

Link copied to clipboard
abstract val address: String

The address associated with this session (typically the phone number or SIP URI).

Link copied to clipboard
abstract val conversationId: UUID

The unique identifier of the conversation this session belongs to.

Link copied to clipboard
abstract val createdAt: Long

The timestamp in milliseconds (epoch) when this session was created.

Link copied to clipboard
abstract val displayName: String

The display name for this session, shown in notifications and the telecom framework.

Link copied to clipboard
abstract val event: SharedFlow<MultimediaSessionEvent>

A stream of MultimediaSessionEvent instances emitted during the session lifecycle.

Link copied to clipboard
abstract val identifier: Int

A numeric identifier for this session, used internally for telecom framework integration.

Link copied to clipboard
abstract val isActive: Boolean

Whether this session is currently active (not on hold). false when the session is held.

Link copied to clipboard

Whether the microphone is currently muted.

Link copied to clipboard
abstract val isSpeakerMuted: Boolean

Whether the speaker is currently muted.

Link copied to clipboard

A stream of the local MultimediaParticipant.

Link copied to clipboard

A stream of remote MultimediaParticipant instances currently in the session.

Link copied to clipboard

The current MultimediaSessionStatus of this session.

Functions

Link copied to clipboard
open fun activate()

Takes the session off hold. Equivalent to hold(onHold = false).

Link copied to clipboard
abstract fun audioInput(muteMicrophone: Boolean)

Enables or disables the microphone (audio input).

Link copied to clipboard
abstract fun audioOutput(muteSpeaker: Boolean)

Enables or disables the speaker (audio output).

Link copied to clipboard
open fun deactivate()

Places the session on hold. Equivalent to hold(onHold = true).

Link copied to clipboard
open fun end()

Ends the session. Equivalent to leave.

Link copied to clipboard
abstract fun hold(onHold: Boolean)

Places the session on hold or takes it off hold.

Link copied to clipboard
abstract fun join()

Joins the multimedia session, initiating the audio connection.

Link copied to clipboard
abstract fun leave()

Leaves the multimedia session and tears down the audio connection.

Link copied to clipboard
open fun muteMicrophone()

Mutes the microphone. Equivalent to audioInput(muteMicrophone = true).

Link copied to clipboard
open fun muteSpeakers()

Mutes the speaker. Equivalent to audioOutput(muteSpeaker = true).

Link copied to clipboard
open fun unmuteMicrophone()

Unmutes the microphone. Equivalent to audioInput(muteMicrophone = false).

Link copied to clipboard
open fun unmuteSpeakers()

Unmutes the speaker. Equivalent to audioOutput(muteSpeaker = false).