Call and Participant State

When you join a call, we’ll automatically expose state in 3 different places: the Stream Video Client, the Call, and the participants.

var clientState = streamVideo.state;
var callState = call.state;
var participants = call.state.value.callParticipants;

Call State

When a Call is created, users can subscribe to receive notifications about any changes that may occur during the call’s lifecycle. To access the state of a call, use call.state.value to obtain the latest CallState snapshot, or use valueStream to listen for real-time changes to the CallState.

This functionality is particularly useful for determining which parts of the UI or application to render based on the current state or lifecycle of the ongoing call.

For example, you may want to display an indicator to users when a call is being recorded:

StreamBuilder<CallState>(
  stream: call.state.valueStream, // Subscribe to state changes
  builder: (context, snapshot) {
    final state = snapshot.data;
    if (state.isRecording) {
      return CallRecordingUI();
    } else {
      return RegularCallUI();
    }
  },
),

The following fields are available on the call:

AttributeDescription
currentUserIdThe user ID of the local user.
callParticipantsThe list of call participants.
isRingingFlowIf this call has ringing set to true.
sessionIdThe current session ID for the call.
statusThe current call state - see next section for more information.
liveStartedAtWhen call was set as live.
liveEndedAtWhen call was set as not live.
localParticipantShortcut to your own participant state.
otherParticipantsThe list of call participants other than yourself.
isRecordingIf the call is being recorded or not.
settingsThe settings for this call.
ownCapabilitiesWhich actions you have permission to do.
capabilitiesByRoleWhat different roles (user, admin, moderator etc.) are allowed to do.
isBackstageIf a call is in backstage mode or not.
isBroadcastingIf a call is broadcasting (to HLS) or not.
createdAtWhen the call was created.
startsAtWhen the call is scheduled to start.
endedAtWhen the call ended.
createdByUserIdUser ID which created the call.
isTranscribingA boolean indicating if transcriptions are active or or not for this call.
egressContains URL for playlist of recording.
reconnectionStatuswhether the call is reconnecting.
durationThe duration of the call.

Understanding Call Status

The status property of the CallState object indicates the current state of the call. Depending on where you are in the call lifecycle, CallStatus can have one of the following possible values.

Call StatusDescription
CallStatusIdleIndicates that there is no active call at the moment.
CallStatusIncomingIndicates that there’s an incoming call, and you need to display an incoming call screen.
CallStatusOutgoingIndicates that the user is making an outgoing call, and you need to display an outgoing call screen.
CallStatusConnecting
CallStatusReconnectingIndicates that the SDK is attempting to reconnect to the call. The number of attempts can be set via the attempt property.
CallStatusConnectedIndicates that the user is connected to the call and is ready to send and receive tracks.
CallStatusDisconnectedIndicates that the call has ended, failed, or has been canceled. The exact reason can be accessed via the DisconnectedReason property.
CallStatusJoining
CallStatusJoinedIndicates that the user has successfully joined the call.

By checking the CallStatus value in the CallState object, you can determine the current state of the call and adjust your UI accordingly.

Participant State

var participants = call.state.value.callParticipants;
var localParticipant = call.state.value.localParticipant;

In the call state, you can find the parameter callParticipants. This parameter allows you to access and manipulate the participants present on the call. By using callParticipants, you can easily map over the participants and observe changes in their configuration. For instance, you can keep track of which participant is currently speaking, which participant is the dominant speaker, and which participant is pinned to the call. Additionally, callParticipants allows you to monitor other changes to the call’s configuration as well.

Overall, callParticipants is a powerful tool that provides you with a lot of control and insight into the call’s current state and configuration. By leveraging this parameter effectively, you can create more advanced and robust call applications.

for (final user in call.state.value.callParticipants){
  if (user.isDominantSpeaker){
    setState(() => dominantSpeaker = user);
  }
}

The following fields are available on the participant:

AttributeDescription
userIdThe unique call id of the participant.
roleThe user’s role in the call.
customAny custom data added to the user.
trackIdPrefixReturns the user’s track ID prefix.
publishedTracksReturns the participant’s tracks.
isSpeakingReturns whether the participant is speaking.
isDominantSpeakerReturns whether the participant is a dominant speaker.
isPinnedReturns whether the participant is pinned.
isLocalReturns whether the participant is a dominant speaker.
isOnlineReturns whether the participant is online.
sessionIdReturns whether the participant is speaking.
connectionQualityThe participant’s connection quality.
joinedAtReturns the date when the user joined the call.
audioLevelThe audio level for the user.
reactionThe current reaction added by the user.
viewportVisibilityThe user’s visibility on the screen.

Combining CallState and CallParticipantState makes building custom UIs and integrations a breeze. If there is a property or API that is not exposed for your specific use case, feel free to reach out to us. We are constantly iterating and exposing APIs based on your feedback.

Client State

// Client state is available in the client object
var clientState = StreamVideo.instance.state;
AttributeDescription
userThe user you’re currently authenticated as.
connectionThe connection state of Stream Video.
activeCallThe call you’ve currently joined.
incomingCallContains the incoming call if ringing is set to true.
© Getstream.io, Inc. All Rights Reserved.