# Call Configurations

## Table of Contents

1. [Overview](#overview)
2. [Implementation Details](#implementation-details)
3. [Default Configurations](#default-configurations)
4. [Managing CallServiceConfigRegistry](#managing-callserviceconfigregistry)
   - [Setting CallServiceConfigRegistry](#setting-callserviceconfigregistry)
   - [Accessing CallServiceConfigRegistry](#accessing-callserviceconfigregistry)
5. [Configuring Call Behavior](#configuring-call-behavior)
   - [Registering Configurations](#registering-configurations)
   - [Retrieving Configurations](#retrieving-configurations)
   - [Updating Configurations](#updating-configurations)

6. [Examples for Different Call Types](#examples-for-different-call-types)

## Overview

This document outlines how to configure specific behavior for different types of calls (e.g., default call, livestream call, audio call) using the Stream SDK. Users can customise the following behavior for each call type:

1. **Show or hide foreground notifications.**
2. **Set the type of audio usage for the call** from:
   - `AudioAttributes.USAGE_VOICE_COMMUNICATION` (default)
   - `AudioAttributes.USAGE_MEDIA`
3. **Set a custom foreground service class.**

### Default Behavior

If no `CallServiceConfigRegistry` is explicitly provided, the SDK uses default behavior to ensure compatibility and smooth functioning. Users can override these defaults as needed.

## Implementation Details

We introduced a new class, `CallServiceConfigRegistry`, to manage call type configurations and provide an easy way to register, retrieve, and update them.

## Default Configurations

To simplify the process, we provide default configurations through the `DefaultCallConfigurations` class. These can be used directly for common scenarios.
The following table outlines the default properties and their specific usage:

| Property            |
| ------------------- |
| default             |
| livestream          |
| livestreamAudioCall |
| livestreamGuestCall |
| audioCall           |

### Example: Guest Livestream Call Configuration

```kotlin
client.state.callConfigRegistry.register(
    DefaultCallConfigurations.getLivestreamGuestCallServiceConfig()
)
```

## Managing CallServiceConfigRegistry

### Setting CallServiceConfigRegistry

Users can pass their own `CallServiceConfigRegistry` instance into the `StreamVideoBuilder` constructor as an argument. For example:

```kotlin
val customRegistry = CallServiceConfigRegistry()
val streamVideoBuilder = StreamVideoBuilder(callServiceConfigRegistry = customRegistry)

```

### Accessing CallServiceConfigRegistry

Users can access the `CallServiceConfigRegistry` through `ClientState.callConfigRegistry`. This provides a global point to manage and retrieve configurations:

```kotlin
val registry = client.state.callConfigRegistry
```

### Practical Tip

Ensure the `CallServiceConfigRegistry` is initialized and passed into the `StreamVideoBuilder` before any call configurations are required. This ensures seamless integration and functionality.

## Configuring Call Behavior

### Registering Configurations

You can register configurations for different call types using the `CallServiceConfigRegistry` class:

#### Explicit Registration

```kotlin
val registry = CallServiceConfigRegistry()

// Register a configuration explicitly
registry.register(CallType.Default.name, CallServiceConfig())
```

#### Using a Builder

```kotlin
registry.register("livestream") {
    setServiceClass(MyCallService::class.java)
    setRunCallServiceInForeground(true)
}
```

#### Registering Multiple Configurations

```kotlin
registry.register(
    mapOf(
        CallType.AudioCall.name to CallServiceConfig(),
        CallType.Default.name to CallServiceConfig()
    )
)
```

### Retrieving Configurations

You can retrieve a configuration for a specific call type using:

```kotlin
val config = registry.get(CallType.Default.name)
```

### Updating Configurations

To update an existing configuration:

```kotlin
registry.update(CallType.Default.name) {
    setRunCallServiceInForeground(false)
}
```

## Examples for Different Call Types

With the provided APIs, users can set specific configurations for various call types. Below are examples:

### Example: Default Call Configuration

```kotlin
val registry = CallServiceConfigRegistry()

/**
 * Either you can directly use the default configurations
 */
registry.register(CallType.Default.name, DefaultCallConfigurations.default)

/**
 * Or you can customise the default configurations via .copy() like this
 */
registry.register(CallType.Default.name, DefaultCallConfigurations.default.copy(audioUsage = ... // Customise the audio usage and other properties here
))

/**
 * Or you can just use customise all from ground up
 */
registry.register(CallType.Default.name) {
    setServiceClass(YourCustomService::class.java)
    setRunCallServiceInForeground(true)
    setAudioUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
}

/**
 * Finally Setting call configurations to the stream sdk
 */
StreamVideoBuilder.build(
// other arguments...
   callServiceConfigRegistry = registry)
```

### Example: Livestream Call Configuration

```kotlin
val registry = CallServiceConfigRegistry()

/**
 * Either you can directly use the default configurations
 */
registry.register(CallType.Livestream.name, DefaultCallConfigurations.livestream)

/**
 * Or you can customise the default configurations via .copy() like this
 */
registry.register(CallType.Livestream.name, DefaultCallConfigurations.livestream.copy(audioUsage = ... // Customise the audio usage and other properties here
))

/**
 * Or you can just use customise all from ground up
 */
registry.register(CallType.Livestream.name) {
    setServiceClass(YourCustomService::class.java)
    setRunCallServiceInForeground(false)
    setAudioUsage(AudioAttributes.USAGE_MEDIA)
}

```

### Example: Audio Call Configuration

```kotlin
val registry = CallServiceConfigRegistry()

/**
 * Either you can directly use the default configurations
 */
registry.register(CallType.AudioCall.name, DefaultCallConfigurations.audioCall)

/**
 * Or you can customise the default configurations via .copy() like this
 */
registry.register(CallType.AudioCall.name, DefaultCallConfigurations.audioCall.copy(audioUsage = ... // Customise the audio usage and other properties here
))

/**
 * Or you can just use customise all from ground up
 */
registry.register(CallType.AudioCall.name) {
   setRunCallServiceInForeground(false)
   setAudioUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
}

```

## Summary

The `CallServiceConfigRegistry` class provides a flexible and efficient way to customise call behavior for various scenarios. By leveraging this feature, users can:

- Define custom behavior for specific call types.
- Update configurations dynamically.
- Use predefined default configurations for common use cases.

This functionality ensures that the Stream SDK remains adaptable to diverse application requirements.


---

This page was last updated at 2026-05-19T19:59:10.746Z.

For the most recent version of this documentation, visit [https://getstream.io/video/docs/android/guides/call-service-configurations/](https://getstream.io/video/docs/android/guides/call-service-configurations/).