|
1 | 1 | /* |
2 | | - * Copyright 2025 LiveKit, Inc. |
| 2 | + * Copyright 2025-2026 LiveKit, Inc. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -27,9 +27,11 @@ import androidx.compose.runtime.produceState |
27 | 27 | import androidx.compose.runtime.remember |
28 | 28 | import androidx.compose.runtime.rememberUpdatedState |
29 | 29 | import io.livekit.android.ConnectOptions |
| 30 | +import io.livekit.android.RoomOptions |
30 | 31 | import io.livekit.android.annotations.Beta |
31 | 32 | import io.livekit.android.compose.local.rememberLiveKitRoom |
32 | 33 | import io.livekit.android.compose.types.AgentFailure |
| 34 | +import io.livekit.android.e2ee.E2EEOptions |
33 | 35 | import io.livekit.android.room.ConnectionState |
34 | 36 | import io.livekit.android.room.Room |
35 | 37 | import io.livekit.android.room.participant.AudioTrackPublishOptions |
@@ -76,7 +78,14 @@ data class SessionOptions( |
76 | 78 | * |
77 | 79 | * These options will be ignored for a [FixedTokenSource]. |
78 | 80 | */ |
79 | | - val tokenRequestOptions: TokenRequestOptions = TokenRequestOptions() |
| 81 | + val tokenRequestOptions: TokenRequestOptions = TokenRequestOptions(), |
| 82 | + |
| 83 | + /** |
| 84 | + * End-to-end encryption options for the [Room] created when [room] is null. |
| 85 | + * |
| 86 | + * Ignored when [room] is non-null; configure E2EE on that [Room] yourself if needed. |
| 87 | + */ |
| 88 | + val e2eeOptions: E2EEOptions? = null, |
80 | 89 | ) |
81 | 90 |
|
82 | 91 | /** |
@@ -220,7 +229,16 @@ internal class SessionImpl( |
220 | 229 | @Beta |
221 | 230 | @Composable |
222 | 231 | fun rememberSession(tokenSource: TokenSource, options: SessionOptions = SessionOptions()): Session { |
223 | | - val room = rememberLiveKitRoom(passedRoom = options.room, connect = false) |
| 232 | + val roomOptions = if (options.room == null && options.e2eeOptions != null) { |
| 233 | + RoomOptions(e2eeOptions = options.e2eeOptions) |
| 234 | + } else { |
| 235 | + null |
| 236 | + } |
| 237 | + val room = rememberLiveKitRoom( |
| 238 | + passedRoom = options.room, |
| 239 | + connect = false, |
| 240 | + roomOptions = roomOptions, |
| 241 | + ) |
224 | 242 | val connectionState = produceState(ConnectionState.DISCONNECTED, room) { |
225 | 243 | room::state.flow |
226 | 244 | .map { state -> |
|
0 commit comments