Skip to content

Commit 56e8e46

Browse files
feat(core): add CallType.AudioRoom for the audio_room server call type (#1685)
Adds CallType.AudioRoom (name = "audio_room") to mirror the same-named call type used by React and iOS. Overrides sortPreset to LivestreamOrAudioRoom so group audio chats self-sort with role-aware ordering out of the box. Distinct from CallType.AudioCall (Android-specific 1:1 voice call). AudioCall keeps SortPreset.Default — role-based sort doesn't apply to a two-participant call. Updates CallType.fromName to include AudioRoom in the lookup list. Tests: extends CallTypeSortPresetTest with assertions for AudioRoom.sortPreset and the fromName("audio_room") resolution path. apiCheck vs develop: additive only.
1 parent 3c79cf6 commit 56e8e46

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

stream-video-android-core/api/stream-video-android-core.api

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9648,6 +9648,11 @@ public final class io/getstream/video/android/core/call/CallType$AudioCall : io/
96489648
public static final field INSTANCE Lio/getstream/video/android/core/call/CallType$AudioCall;
96499649
}
96509650

9651+
public final class io/getstream/video/android/core/call/CallType$AudioRoom : io/getstream/video/android/core/call/CallType {
9652+
public static final field INSTANCE Lio/getstream/video/android/core/call/CallType$AudioRoom;
9653+
public fun getSortPreset ()Lio/getstream/video/android/core/sorting/SortPreset;
9654+
}
9655+
96519656
public final class io/getstream/video/android/core/call/CallType$Companion {
96529657
public final fun fromName (Ljava/lang/String;)Lio/getstream/video/android/core/call/CallType;
96539658
}

stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/CallType.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ sealed class CallType(val name: String) {
3030
object Livestream : CallType("livestream") {
3131
override val sortPreset: SortPreset get() = SortPreset.LivestreamOrAudioRoom
3232
}
33+
34+
/**
35+
* Group audio chat (mirrors React's `audio_room` and iOS's `audio_room` call type).
36+
* Distinct from [AudioCall], which is the Android-specific 1:1 voice call type.
37+
*/
38+
object AudioRoom : CallType("audio_room") {
39+
override val sortPreset: SortPreset get() = SortPreset.LivestreamOrAudioRoom
40+
}
41+
3342
object AudioCall : CallType("audio_call")
3443
object Default : CallType("default")
3544
object AnyMarker : CallType("ALL_CALL_TYPES")
@@ -43,7 +52,13 @@ sealed class CallType(val name: String) {
4352

4453
companion object {
4554
fun fromName(name: String): CallType? {
46-
return listOf(Livestream, AudioCall, Default, AnyMarker).find { it.name == name }
55+
return listOf(
56+
Livestream,
57+
AudioRoom,
58+
AudioCall,
59+
Default,
60+
AnyMarker,
61+
).find { it.name == name }
4762
}
4863
}
4964
}

stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/sorting/CallTypeSortPresetTest.kt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,27 @@ class CallTypeSortPresetTest {
3737
assertThat(CallType.Livestream.sortPreset).isEqualTo(SortPreset.LivestreamOrAudioRoom)
3838
}
3939

40+
@Test
41+
fun `AudioRoom call type uses SortPreset LivestreamOrAudioRoom`() {
42+
// CallType.AudioRoom mirrors the "audio_room" server type used by React and iOS.
43+
// It applies the same livestream-style sort (activity + roles).
44+
assertThat(CallType.AudioRoom.sortPreset).isEqualTo(SortPreset.LivestreamOrAudioRoom)
45+
}
46+
4047
@Test
4148
fun `AudioCall call type falls back to SortPreset Default (1to1 audio is not livestream-like)`() {
42-
// CallType.AudioCall represents a 1:1 audio call, not the React/iOS audio_room
43-
// concept. Auto-applying LivestreamOrAudioRoom there would mis-sort the two
44-
// participants. Stays on Default until a dedicated AudioRoom call type lands.
49+
// CallType.AudioCall represents a 1:1 audio call, distinct from AudioRoom (group
50+
// audio). Auto-applying LivestreamOrAudioRoom there would mis-sort the two
51+
// participants. AudioCall stays on Default.
4552
assertThat(CallType.AudioCall.sortPreset).isEqualTo(SortPreset.Default)
4653
}
4754

55+
@Test
56+
fun `fromName audio_room resolves to AudioRoom call type with LivestreamOrAudioRoom preset`() {
57+
val resolved = CallType.fromName("audio_room")?.sortPreset ?: SortPreset.Default
58+
assertThat(resolved).isEqualTo(SortPreset.LivestreamOrAudioRoom)
59+
}
60+
4861
@Test
4962
fun `Custom call types default to SortPreset Default`() {
5063
val custom = CallType.CustomCallType("my_custom_type")

0 commit comments

Comments
 (0)