Permission and Moderation

In some types of calls, there’s a requirement to moderate the behaviour of the participants.

Examples include muting a participant, or ending the call for everyone. Those capabilities are usually reserved for the hosts of the call (users with elevated capabilities). They usually have additional moderation controls in their UI, that allow them to achieve these actions.

The Flutter SDK for Stream Video has support for such capabilities, with the usage of the permissions features for the Call class.

Current Permissions

To check if a user has certain permissions, such as transmitting audio, video, or screen sharing, you can use the hasPermission method on the Call class:

final canScreenShare = call.hasPermission(CallPermission.screenshare);

Requesting and Granting Permissions

If a user does not have permission for an action, it can be requested by calling requestPermissions() on the current Call object.

This method accepts a list of CallPermission allowing for multiple permission requests to be batched into a single call:

call.requestPermissions([CallPermission.screenshare, CallPermission.sendVideo]);

As a call admin, you can grant permission to other users by calling call.grantPermissions along with the user’s id and the list of permissions you would like to grant:

call.grantPermissions(userId: 'nash', permissions: [CallPermission.screenshare, CallPermission.sendVideo]);

During a call, it is advised to set up a handler to listen and react to permission requests as they arrive. This can be done by passing a callback function to the onPermissionRequest property present on the Call object:

@override
void initState() {
  super.initState();
  widget.call.onPermissionRequest = (CoordinatorCallPermissionRequestEvent request) {
    // TODO Handle Permission requests
    // For example: widget.call.grantPermissions(userId: request.user.id, permissions: request.permissions); 
  };
}

The CoordinatorCallPermissionRequestEvent includes the following attributes which can be used to either grant or reject permission requests:

  • Call Cid
  • Created At
  • Permissions
  • User

Moderation Capabilities

As with all calls, there may be times when user permissions need to be revoked, or the user needs to be banned, muted, or subjected to other actions to limit their interaction.

To facilitate these requests, the SDK provides several methods for limiting user interaction during the call lifecycle.

Revoke Permissions

Similar to its sister method grantPermissions, the revokePermissions method exists on the current Call object. It enables users to easily remove permissions assigned to a specific user by providing their user ID and the list of permissions to be revoked..

call.revokePermissions(userId: 'nash', permissions: [CallPermission.screenshare, CallPermission.sendVideo]);

Mute Users

To disable the audio tracks of all users on a call or a specific user in a call, the muteOthers and muteUser functions can be called, respectively.

call.muteAllUsers();
call.muteUsers(userIds: ['thierry']);

In the above example, we are only muting a single user. However, muteUsers does allow us to mute multiple users since it accepts a list of user IDs.

Blocking Members

Blocking and unblocking users can be done by calling blockUser or unblockUser on the current Call object.

call.blockUser('deven');

call.unblockUser('deven');

Ending the Call

As a host, you are able to end the current call for everyone using the call.end method.

await call.end();

To silently leave a call, the disconnect method can be used in place of the end method.

© Getstream.io, Inc. All Rights Reserved.