Skip to content

Commit 8696185

Browse files
committed
Remove audioUsage CallServiceConfig and rely on Builder parameter.
1 parent 66bb95e commit 8696185

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4298,6 +4298,8 @@ public final class io/getstream/video/android/core/notifications/internal/servic
42984298
public fun <init> ()V
42994299
public fun <init> (ZILjava/util/Map;)V
43004300
public synthetic fun <init> (ZILjava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
4301+
public fun <init> (ZLjava/util/Map;)V
4302+
public synthetic fun <init> (ZLjava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
43014303
public final fun component1 ()Z
43024304
public final fun component2 ()I
43034305
public final fun component3 ()Ljava/util/Map;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ public class StreamVideoBuilder @JvmOverloads constructor(
208208
callServiceConfig = callServiceConfig
209209
?: callServiceConfig().copy(
210210
runCallServiceInForeground = runForegroundServiceForCalls,
211-
audioUsage = audioUsage,
212211
),
213212
testSfuAddress = localSfuAddress,
214213
sounds = sounds,

stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallServiceConfig.kt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.getstream.video.android.core.notifications.internal.service
1818

19-
import android.media.AudioAttributes
19+
import io.getstream.video.android.core.defaultAudioUsage
2020
import io.getstream.video.android.model.StreamCallId
2121

2222
// Constants
@@ -35,13 +35,27 @@ internal const val ANY_MARKER = "ALL_CALL_TYPES"
3535
* @see livestreamGuestCallServiceConfig
3636
* @see audioCallServiceConfig
3737
*/
38-
public data class CallServiceConfig(
38+
39+
public data class CallServiceConfig
40+
@Deprecated(
41+
message = "The audioUsage parameter is deprecated. Set audioUsage directly in StreamVideoBuilder constructor.",
42+
replaceWith = ReplaceWith("CallServiceConfig(runCallServiceInForeground, callServicePerType)"),
43+
)
44+
constructor(
3945
val runCallServiceInForeground: Boolean = true,
40-
val audioUsage: Int = AudioAttributes.USAGE_VOICE_COMMUNICATION,
46+
@Deprecated(
47+
"This property will be ignored. Set audioUsage directly in StreamVideoBuilder constructor.",
48+
)
49+
val audioUsage: Int = defaultAudioUsage,
4150
val callServicePerType: Map<String, Class<*>> = mapOf(
4251
Pair(ANY_MARKER, CallService::class.java),
4352
),
44-
)
53+
) {
54+
constructor(
55+
runCallServiceInForeground: Boolean = true,
56+
callServicePerType: Map<String, Class<*>>,
57+
) : this(runCallServiceInForeground, defaultAudioUsage, callServicePerType)
58+
}
4559

4660
/**
4761
* Returns the default call foreground service configuration.
@@ -91,7 +105,6 @@ public fun livestreamAudioCallServiceConfig(): CallServiceConfig {
91105
public fun livestreamGuestCallServiceConfig(): CallServiceConfig {
92106
return CallServiceConfig(
93107
runCallServiceInForeground = true,
94-
audioUsage = AudioAttributes.USAGE_MEDIA,
95108
callServicePerType = mapOf(
96109
Pair(ANY_MARKER, CallService::class.java),
97110
Pair("livestream", LivestreamViewerService::class.java),

stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/notifications/internal/service/CallServiceConfigTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,12 @@ class CallServiceConfigTest {
115115
val servicePerTypeSize = config.callServicePerType.size
116116
val hostServiceClass = config.callServicePerType[ANY_MARKER]
117117
val livestreamServiceClass = config.callServicePerType["livestream"]
118-
val audioUsage = config.audioUsage
119118

120119
// Then
121120
assertEquals(true, runInForeground)
122121
assertEquals(2, servicePerTypeSize)
123122
assertEquals(CallService::class.java, hostServiceClass)
124123
assertEquals(LivestreamViewerService::class.java, livestreamServiceClass)
125-
assertEquals(AudioAttributes.USAGE_MEDIA, audioUsage)
126124
}
127125

128126
@Test

tutorials/tutorial-livestream/src/main/kotlin/io/getstream/video/android/tutorial/livestream/LiveGuest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
package io.getstream.video.android.tutorial.livestream
1818

19+
import android.media.AudioAttributes
1920
import android.widget.Toast
2021
import androidx.compose.foundation.layout.Box
2122
import androidx.compose.foundation.layout.padding
2223
import androidx.compose.runtime.Composable
23-
import androidx.compose.runtime.getValue
2424
import androidx.compose.ui.Alignment
2525
import androidx.compose.ui.Modifier
2626
import androidx.compose.ui.platform.LocalContext
@@ -63,6 +63,7 @@ fun LiveAudience(
6363
callServiceConfig = livestreamGuestCallServiceConfig(),
6464
ensureSingleInstance = false,
6565
loggingLevel = LoggingLevel(priority = Priority.VERBOSE),
66+
audioUsage = AudioAttributes.USAGE_MEDIA,
6667
).build()
6768

6869
// step3 - join a call, which type is `default` and id is `123`.

0 commit comments

Comments
 (0)