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 = streamVideo.call(callType: "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:
Attribute | Description |
---|---|
participants | The list of call participants. |
localParticipant | Shortcut to your own participant state. |
remoteParticipants | The list of call participants other than yourself. |
activeSpeakers | The list of participants who are currently speaking. |
dominantSpeaker | The dominant speaker. |
members | The list of call members. |
screenSharingSession | If someone is screensharing, it will be available here. |
recordingState | if the call is being recorded or not. |
blockedUserIds | The user ids who are blocked from this call. |
settings | The settings for this call. |
ownCapabilities | Which actions you have permission to do. |
capabilitiesByRole | What different roles (user, admin, moderator etc.) are allowed to do. |
backstage | If a call is in backstage mode or not. |
broadcasting | If a call is broadcasting (to HLS) or not. |
createdAt | When the call was created. |
updatedAt | When the call was updated. |
startsAt | When the call is scheduled to start. |
endedAt | When the call ended. |
endedBy | User who ended the call. |
custom | Custom data on the call. |
team | Team that the call is restricted to. Default to null. |
createdBy | Who created the call. |
ingress | If there is an active ingress session to this call. IE if you're sending RTMP into the call |
transcribing | a boolean indicating if transciptions are active or or not for this call. |
egress | contains URL for playlist of recording. |
session | the session associated with the call. |
reconnectionStatus | whether the call is reconnecting. |
participantCount | number of participants connected to the call. |
duration | The duration of the call. |
statsReport | Returns 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:
Attribute | Description |
---|---|
user | The User object for the participant. |
id | The unique call id of the participant. |
roles | The user's roles in the call. |
hasVideo | Returns whether the participant has video. |
hasAudio | Returns whether the participant has audio. |
isScreensharing | Returns whether the participant is screenSharing. |
track | Returns the participant's video track. |
trackSize | Returns the size of the track for the participant. |
screenshareTrack | Returns the screensharing track for the participant. |
showTrack | Returns whether the track should be shown. |
isSpeaking | Returns whether the participant is speaking. |
isDominantSpeaker | Returns whether the participant is a dominant speaker. |
sessionId | Returns whether the participant is speaking. |
connectionQuality | The participant's connection quality. |
joinedAt | Returns the date when the user joined the call. |
pin | Holds pinning information. |
isPinned | Returns whether the user is pinned. |
audioLevel | The audio level for the user. |
audioLevels | A 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 = streamVideo.call(callType: 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:
Attribute | Description |
---|---|
user | The user you're currently authenticated as. |
connection | The connection state. See ConnectionState. |
activeCall | The call you've currently joined. |
ringingCall | Contains the call if you're calling someone or someone is calling you. |