Skip to main content

Permissions & Moderation

Permissions for a video call can be quite complicated. Use cases like educational apps, live events, audio rooms and livestreams require detailed permissions.

Requesting & Granting permission

This example shows how to check if you have permissions to do something and ask for permission. Let's say that you've joined an audio room and want to speak

// see if you currently have this permission
val hasPermission = call.state.hasPermission("send-audio").value

// request the host to grant you this permission
val response = call.requestPermissions("send-audio")

The host can proceed to grant you permission:

val requests = call.state.permissionRequests.value
requests.forEach {
it.grant() // or it.reject()
}

You can also grant permissions directly using call.grantPermissions() method like the example below:

val grantResponse = call.grantPermissions("thierry", listOf("send-audio"))

You can request the following 3 permissions: send-audio, send-video, and screenshare.

Android Runtime Permissions

If you want to facilitate an audio or video call, you should grant the following runtime permissions on Android: CAMERA, and RECORD_AUDIO.

You can requests those permissions by yourself at the right moment, but you can also request permissions with Stream APIs like the example below:

val permissionState = rememberCallPermissionsState(call = call)

Button(onClick = { permissionState.launchPermissionRequest() }) {
Text(text = "Request permissions")
}

// or you can request permissions when display the screen.microphone
LaunchedEffect(Unit) {
permissionState.launchPermissionRequest()
}

You can also request a single permission for a camera and microphone like the example below:

// request a camera permission
val cameraPermissionState = rememberCameraPermissionState(call = call)
cameraPermissionState.launchPermissionRequest()

// request a microphone permission
val microphonePermissionState = rememberMicrophonePermissionState(call = call)
microphonePermissionState.launchPermissionRequest()
note

The permissions are required and any usage of the Call object without them may result in a crash.

In order to notify an inconsistency the SDK will log a warning when Call.join() is being called without the required permissions. This is completely ok, if you have a call type which does not require streaming audio or video from the users device (e.g. audio_room or live broadcast where the user is only a guest and listens in to the stream).

The SDK by default will check for runtime permissions based on call capabilities, so if your call requires audio to be sent, the SDK will expect that the android.Manifest.permission.RECORD_AUDIO is granted.

danger

If you are not overriding the runForegroundServiceForCalls flag to false in the StreamVideoBuilder the resulting foreground service that starts for keeping the call alive can not run without the permissions and will crash with a detailed message.

If you wish to override the behavior on which permissions are required for your calls you can provide a new implementation of StreamPermissionCheck to the StreamVideoBuilder.

Moderation Capabilities

You can block a user or remove them from a call

// block a user
val response = call.blockUser("tommaso")

// remove a member from a call
val response = call.removeMember("tommaso")

Alternatively you can also mute users

call.muteAllUsers() // mutes all users other than yourself
call.muteUser("tommaso") // mute user with id "tommaso" specifically

Did you find this page helpful?