Skip to main content

Call & Participant State

Video Call State

When you join a call, we'll automatically expose observable objects in 3 different places:

let clientState = streamVideo.state
let callState = call.state
let participants = call.state.participants

Call State

The call state is kept in sync (updates are received) only when you join the call.

Here's an example of how you can access the call state:

let call = "default", callId: "mycall")
let joinResult = try await call.join(create: true)
// state is now available at
let state = call.state

The following fields are available on the call:

participantsThe list of call participants.
localParticipantShortcut to your own participant state.
remoteParticipantsThe list of call participants other than yourself.
activeSpeakersThe list of participants who are currently speaking.
dominantSpeakerThe dominant speaker.
membersThe list of call members.
screenSharingSessionIf someone is screensharing, it will be available here.
recordingStateif the call is being recorded or not.
blockedUserIdsThe user ids who are blocked from this call.
settingsThe settings for this call.
ownCapabilitiesWhich actions you have permission to do.
capabilitiesByRoleWhat different roles (user, admin, moderator etc.) are allowed to do.
backstageIf a call is in backstage mode or not.
broadcastingIf a call is broadcasting (to HLS) or not.
createdAtWhen the call was created.
updatedAtWhen the call was updated.
startsAtWhen the call is scheduled to start.
endedAtWhen the call ended.
endedByUser who ended the call.
customCustom data on the call.
teamTeam that the call is restricted to. Default to null.
createdByWho created the call.
ingressIf there is an active ingress session to this call. IE if you're sending RTMP into the call
transcribinga boolean indicating if transciptions are active or or not for this call.
egresscontains URL for playlist of recording.
sessionthe session associated with the call.
reconnectionStatuswhether the call is reconnecting.
participantCountnumber of participants connected to the call.
durationThe duration of the call.
statsReportReturns stats of the call, updated every 5 seconds.

Participant State

The CallParticipant is the most essential component used to render a participant in a call. It contains all of the information to render a participant, such as audio & video renderers, availabilities of audio & video, the screen sharing session, reactions, and etc. Here's how you iterate over the participants:

// all participants
let cancellable = call.state.$participants.sink { participants in
// ..

// you
let localParticipant: CallParticipant? = call.state.localParticipant

The following fields are available on the participant:

userThe User object for the participant.
idThe unique call id of the participant.
rolesThe user's roles in the call.
hasVideoReturns whether the participant has video.
hasAudioReturns whether the participant has audio.
isScreensharingReturns whether the participant is screenSharing.
trackReturns the participant's video track.
trackSizeReturns the size of the track for the participant.
screenshareTrackReturns the screensharing track for the participant.
showTrackReturns whether the track should be shown.
isSpeakingReturns whether the participant is speaking.
isDominantSpeakerReturns whether the participant is a dominant speaker.
sessionIdReturns whether the participant is speaking.
connectionQualityThe participant's connection quality.
joinedAtReturns the date when the user joined the call.
pinHolds pinning information.
isPinnedReturns whether the user is pinned.
audioLevelThe audio level for the user.
audioLevelsA list of the last 10 audio levels. Convenient for audio visualizations.

Participants Sorting

If you want to change the default sorting of the participants, you can use the Call object's method updateParticipantsSorting.

Here's an example that will sort participants alphabetically, by their name:

let nameComparator: StreamSortComparator<CallParticipant> = {
comparison($0, $1, keyPath: \.name)
let call = callType, callId: callId)
call.updateParticipantsSorting(with: [nameComparator])

Client State

// client state is available on the client object
let state = streamVideo.state

And contains these fields:

userThe user you're currently authenticated as.
connectionThe connection state. See ConnectionState.
activeCallThe call you've currently joined.
ringingCallContains the call if you're calling someone or someone is calling you.

Did you find this page helpful?