Skip to content

Commit

Permalink
Update the outline of the IStreamCall and the IStreamVideoCallPartici…
Browse files Browse the repository at this point in the history
…pant interfaces in the docs
  • Loading branch information
sierpinskid committed Jan 10, 2024
1 parent 0037cfd commit 254350a
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 51 deletions.
52 changes: 37 additions & 15 deletions Packages/StreamVideo/Runtime/Core/StatefulModels/IStreamCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,24 @@ namespace StreamVideo.Core.StatefulModels
{
public interface IStreamCall : IStreamStatefulModel
{
event ParticipantTrackChangedHandler TrackAdded;
/// <summary>
/// A new participant joined the call
/// </summary>
event ParticipantJoinedHandler ParticipantJoined;

/// <summary>
/// A participant left the call
/// </summary>
event ParticipantLeftHandler ParticipantLeft;

/// <summary>
/// A track was added for a participant in the call
/// </summary>
event ParticipantTrackChangedHandler ParticipantTrackAdded;

/// <summary>
/// The most actively speaking participant in the call has changed
/// </summary>
event DominantSpeakerChangedHandler DominantSpeakerChanged;

/// <summary>
Expand Down Expand Up @@ -48,19 +62,7 @@ public interface IStreamCall : IStreamStatefulModel
/// Participants are users that are currently in the call. You can also get all users associated with the call via <see cref="Members"/>
/// </summary>
IReadOnlyList<IStreamVideoCallParticipant> Participants { get; }

/// <summary>
/// Participant that is currently the most actively speaking.
/// When dominant speaker changes the <see cref="DominantSpeakerChanged"/> event will trigger.
/// You can also get the <see cref="PreviousDominantSpeaker"/>
/// </summary>
IStreamVideoCallParticipant DominantSpeaker { get; }

/// <summary>
/// Participant that was the last
/// </summary>
IStreamVideoCallParticipant PreviousDominantSpeaker { get; }


/// <summary>
/// Participant that are pinned to this call sorted by the time they were pinned.
/// Locally pinned participants are first, then the participant pinned remotely (by other participants with appropriate permissions).
Expand All @@ -78,7 +80,19 @@ public interface IStreamCall : IStreamStatefulModel
/// Any update to this collection will trigger the <see cref="SortedParticipantsUpdated"/> event.
/// </summary>
IEnumerable<IStreamVideoCallParticipant> SortedParticipants { get; }


/// <summary>
/// Participant that is currently the most actively speaking.
/// When dominant speaker changes the <see cref="DominantSpeakerChanged"/> event will trigger.
/// You can also get the <see cref="PreviousDominantSpeaker"/>
/// </summary>
IStreamVideoCallParticipant DominantSpeaker { get; }

/// <summary>
/// Participant that was the last
/// </summary>
IStreamVideoCallParticipant PreviousDominantSpeaker { get; }

IReadOnlyList<OwnCapability> OwnCapabilities { get; }

/// <summary>
Expand All @@ -104,7 +118,15 @@ public interface IStreamCall : IStreamStatefulModel
/// All three will be members but only "Jane" will be a participant. You can get call participants with <see cref="Participants"/>
/// </summary>
IEnumerable<CallMember> Members { get; }

/// <summary>
/// Is the call being currently recorded
/// </summary>
bool Recording { get; }

/// <summary>
/// Users that are blocked in this call
/// </summary>
IEnumerable<IStreamVideoUser> BlockedUsers { get; }
CallSettings Settings { get; }
bool Backstage { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace StreamVideo.Core.StatefulModels
/// </summary>
public interface IStreamVideoCallParticipant : IStreamStatefulModel
{
/// <summary>
/// A track was added for this participant. Tracks represents streams of video, and audio. You can get all tracks via <see cref="GetTracks"/>
/// </summary>
event ParticipantTrackChangedHandler TrackAdded;

/// <summary>
Expand Down Expand Up @@ -61,6 +64,9 @@ public interface IStreamVideoCallParticipant : IStreamStatefulModel
bool IsSpeaking { get; }
ConnectionQuality ConnectionQuality { get; }

/// <summary>
/// Get all tracks associated with this participant. You can also use <see cref="TrackAdded"/> to get notified when a track is added
/// </summary>
IEnumerable<IStreamTrack> GetTracks();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal sealed class StreamCall : StreamStatefulModelBase<StreamCall>,
IUpdateableFrom<CallStateResponseFieldsInternalDTO, StreamCall>,
IStreamCall
{
public event ParticipantTrackChangedHandler TrackAdded;
public event ParticipantTrackChangedHandler ParticipantTrackAdded;

public event ParticipantJoinedHandler ParticipantJoined;
public event ParticipantLeftHandler ParticipantLeft;
Expand Down Expand Up @@ -531,7 +531,7 @@ internal void UpdateFromSfu(PinsChanged pinsChanged, ICache cache)

//StreamTodo: missing TrackRemoved or perhaps we should not care whether a track was added/removed but only published/unpublished -> enabled/disabled
internal void NotifyTrackAdded(IStreamVideoCallParticipant participant, IStreamTrack track)
=> TrackAdded?.Invoke(participant, track);
=> ParticipantTrackAdded?.Invoke(participant, track);

internal void UpdateCapabilitiesByRoleFromDto(CallUpdatedEventInternalDTO callUpdatedEvent)
=> UpdateCapabilitiesByRole(callUpdatedEvent.CapabilitiesByRole);
Expand Down
142 changes: 108 additions & 34 deletions docusaurus/docs/Unity/03-guides/03-call-and-participant-state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: How the state is exposed

### Stateful models

Stream's Video SDK for Unity contains several **stateful** models that automatically receive events from the Stream Server and update its inner state. Thanks to this you can always rely on them having the most up-to-date state.
Stream's Video SDK for Unity contains several **stateful** models that automatically receive events from the Stream Server and update their inner state. Thanks to this you can always rely on them having the most up-to-date state.

Stateful models:
* **IStreamCall** - represents a call object
Expand All @@ -24,31 +24,82 @@ var callId = "my-call-id";
var streamCall = await _client.GetOrCreateCallAsync(callType, callId);
```

The following fields are available on the call
Here's an outline of the `IStreamCall` object:

| Attribute | Description |
### Events

| Event | Description |
| --- | --- |
| `Participants` | The list of call participants |
| `Members` | The list of call members |
| `Recording` | Boolean if the call is being recorded or not |
| `BlockedUsers` | The users who are blocked from this call |
| `Settings` | The settings for this call |
| `OwnCapabilities` | Which actions you have permission to do |
| `Backstage` | If a call is in backstage mode 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 |
| `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 |

The following methods are available on the call

| Attribute | Description |
| `ParticipantJoined` | Fired when a new participant joins the call |
| `ParticipantLeft` | Fired when a participant leaves the call |
| `ParticipantTrackAdded` | Fired when a track is added for a participant in the call |
| `DominantSpeakerChanged` | Fired when the most actively speaking participant in the call changes |
| `ReactionAdded` | Fired when a call participant adds a reaction to the call |
| `PinnedParticipantsUpdated` | Fired when the `PinnedParticipants` collection is updated |
| `RecordingStarted` | Fired when recording of the call starts |
| `RecordingStopped` | Fired when recording of the call stops |
| `SortedParticipantsUpdated` | Fired when the `SortedParticipants` collection is updated |

### Properties

| Property | Description |
| --- | --- |

| `HasPermissions` | method for checking if you have a certain permission |
| `Credentials` | Credentials for the call |
| `Participants` | List of users currently in the call |
| `PinnedParticipants` | List of participants pinned to the call, sorted by the time they were pinned |
| `SortedParticipants` | Participants sorted by pin status, screen-sharing status, dominant speaker, video participants, and audio-only participants |
| `DominantSpeaker` | The participant currently most actively speaking |
| `PreviousDominantSpeaker` | The participant who was last the dominant speaker |
| `OwnCapabilities` | List of actions the user has permission to do |
| `Id` | Call ID |
| `Cid` | Unique identifier for the call, combining `Type` and `Id` |
| `Type` | Type of call, determining the permissions schema used |
| `IsLocalUserOwner` | Indicates if the local user is the owner of the call |
| `Members` | Users permanently associated with the call, including those not currently in the call |
| `Recording` | Indicates if the call is currently being recorded |
| `BlockedUsers` | Users blocked in this call |
| `Settings` | Settings for the call |
| `Backstage` | Indicates if the call is in backstage mode |
| `CreatedAt` | Date/time of call creation |
| `UpdatedAt` | Date/time of the last call update |
| `StartsAt` | Date/time when the call will start |
| `EndedAt` | Date/time when the call ended |
| `Team` | Team that the call is restricted to |
| `CreatedBy` | The user who created the call |
| `Ingress` | Indicates if there is an active ingress session to this call |

### Methods

| Method | Description |
| --- | --- |
| `LeaveAsync` | Leave the call |
| `EndAsync` | End the call |
| `GoLiveAsync` | Start the live stream of the call |
| `StopLiveAsync` | Stop the live stream of the call |
| `StartRecordingAsync` | Start recording the call |
| `StopRecordingAsync` | Stop recording the call |
| `MuteAllUsersAsync` | Mute all users in the call |
| `BlockUserAsync` | Block a user from the call |
| `UnblockUserAsync` | Unblock a user from the call |
| `HasPermissions` | Check if you currently have a certain permission |
| `RequestPermissionAsync` | Request a permission from the call host |
| `RequestPermissionsAsync` | Request multiple permissions from the call host |
| `GrantPermissionsAsync` | Grant permissions to a user in this call |
| `RevokePermissionsAsync` | Revoke permissions from a user in this call |
| `AcceptAsync` | Mark an incoming call as accepted |
| `RejectAsync` | Mark an incoming call as rejected |
| `StartHLS` | Start HTTP Live Streaming |
| `StopHLS` | Stop HTTP Live Streaming |
| `RemoveMembersAsync` | Remove members from the call |
| `MuteUsersAsync` | Mute specific users in the call |
| `QueryMembersAsync` | Query members in the call |
| `SendReactionAsync` | Send a reaction in the call |
| `SendCustomEventAsync` | Send a custom event in the call |
| `PinLocally` | Pin a participant locally |
| `UnpinLocally` | Unpin a participant locally |
| `IsPinnedLocally` | Check if a participant is pinned locally |
| `IsPinnedRemotely` | Check if a participant is pinned remotely |
| `IsPinned` | Check if a participant is pinned |


### Participant State
Expand Down Expand Up @@ -81,18 +132,41 @@ streamCall.ParticipantJoined += OnParticipantJoined;
streamCall.ParticipantLeft += OnParticipantLeft;
```

The following fields are available on the participant
Here's an outline of the `IStreamVideoCallParticipant` object:

### Events

| Attribute | Description |
| Event | Description |
| --- | --- |
| `TrackAdded` | Fired when a track is added for this participant. Tracks represent streams of video and audio. |

### Properties

| Property | Description |
| --- | --- |
| `IsPinned` | Indicates if this participant is "pinned" in the call, giving them precedence in the `IStreamCall.SortedParticipants` list |
| `IsScreenSharing` | Indicates if this participant is currently streaming a screen share track |
| `IsVideoEnabled` | Indicates if this participant is currently streaming a video track |
| `IsAudioEnabled` | Indicates if this participant is currently streaming an audio track |
| `IsDominantSpeaker` | Indicates if this participant is currently the most actively speaking participant |
| `UserId` | The user ID of the participant |
| `SessionId` | A unique identifier for a participant in a call, allowing for multiple instances of the same user through different devices |
| `TrackLookupPrefix` | A prefix used for track lookup |
| `Name` | The name of the participant |
| `IsLocalParticipant` | Indicates if this is the participant from the local device |
| `User` | The `IStreamVideoUser` associated with the participant |
| `VideoTrack` | The video track of the participant |
| `AudioTrack` | The audio track of the participant |
| `ScreenShareTrack` | The screen share track of the participant |
| `JoinedAt` | The date and time when the participant joined the call |
| `AudioLevel` | The audio level of the participant |
| `IsSpeaking` | Indicates if the participant is currently speaking |
| `ConnectionQuality` | The quality of the connection for the participant |

### Methods

| Method | Description |
| --- | --- |
| `User` | The user object for this participant |
| `VideoTrack` | The video track object for this participant |
| `AudioTrack` | The participant's audio track object |
| `ScreenShareTrack` | The screensharing track object |
| `JoinedAt` | When this participant joined |
| `AudioLevel` | How loudly this user is talking. Float |
| `IsSpeaking` | If the user is speaking |
| `ConnectionQuality` | The participant's connection quality |
| `IsDominantSpeaker` | If this participant is the dominant speaker or not |
| `GetTracks` | Retrieves all tracks associated with this participant. This method can be used in conjunction with the `TrackAdded` event to manage tracks. |


0 comments on commit 254350a

Please sign in to comment.