Skip to content

Commit c6646c3

Browse files
authored
Remove RoomOptions from Room.connect (#346)
This was causing confusion in users who expected it to overwrite the existing room options
1 parent e636133 commit c6646c3

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

livekit-android-sdk/src/main/java/io/livekit/android/LiveKit.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class LiveKit {
105105
}
106106
room.adaptiveStream = options.adaptiveStream
107107
room.dynacast = options.dynacast
108+
room.e2eeOptions = options.e2eeOptions
108109

109110
return room
110111
}

livekit-android-sdk/src/main/java/io/livekit/android/RoomOptions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ data class RoomOptions(
3535
val dynacast: Boolean = false,
3636

3737
/**
38-
* Options for end-to-end encryption.
38+
* @see [Room.e2eeOptions]
3939
*/
4040
val e2eeOptions: E2EEOptions? = null,
4141

livekit-android-sdk/src/main/java/io/livekit/android/room/Room.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import io.livekit.android.Version
3333
import io.livekit.android.audio.AudioHandler
3434
import io.livekit.android.dagger.InjectionNames
3535
import io.livekit.android.e2ee.E2EEManager
36+
import io.livekit.android.e2ee.E2EEOptions
3637
import io.livekit.android.events.*
3738
import io.livekit.android.memory.CloseableManager
3839
import io.livekit.android.renderer.TextureViewRenderer
@@ -161,6 +162,13 @@ constructor(
161162
localParticipant.dynacast = value
162163
}
163164

165+
/**
166+
* Options for end-to-end encryption. Must be setup prior to [connect].
167+
*
168+
* If null, e2ee will be disabled.
169+
*/
170+
var e2eeOptions: E2EEOptions? = null
171+
164172
/**
165173
* Default options to use when creating an audio track.
166174
*/
@@ -210,15 +218,17 @@ constructor(
210218
videoTrackCaptureDefaults = videoTrackCaptureDefaults,
211219
audioTrackPublishDefaults = audioTrackPublishDefaults,
212220
videoTrackPublishDefaults = videoTrackPublishDefaults,
213-
e2eeOptions = null,
221+
e2eeOptions = e2eeOptions,
214222
)
215223

216-
suspend fun connect(url: String, token: String, options: ConnectOptions = ConnectOptions(), roomOptions: RoomOptions = getCurrentRoomOptions()) {
224+
suspend fun connect(url: String, token: String, options: ConnectOptions = ConnectOptions()) {
217225
if (this::coroutineScope.isInitialized) {
218226
coroutineScope.cancel()
219227
}
220228
coroutineScope = CoroutineScope(defaultDispatcher + SupervisorJob())
221229

230+
val roomOptions = getCurrentRoomOptions()
231+
222232
// Setup local participant.
223233
localParticipant.reinitialize()
224234
coroutineScope.launch {

livekit-android-sdk/src/test/java/io/livekit/android/room/RoomTest.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ class RoomTest {
7171
override fun create(dynacast: Boolean): LocalParticipant {
7272
return Mockito.mock(LocalParticipant::class.java)
7373
.apply {
74-
whenever(this.events).thenReturn(object : EventListenable<ParticipantEvent> {
75-
override val events: SharedFlow<ParticipantEvent> = MutableSharedFlow()
76-
})
74+
whenever(this.events).thenReturn(
75+
object : EventListenable<ParticipantEvent> {
76+
override val events: SharedFlow<ParticipantEvent> = MutableSharedFlow()
77+
},
78+
)
7779
}
7880
}
7981
}

sample-app-common/src/main/java/io/livekit/android/sample/CallViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ class CallViewModel(
178178

179179
private suspend fun connectToRoom() {
180180
try {
181+
room.e2eeOptions = getE2EEOptions()
181182
room.connect(
182183
url = url,
183184
token = token,
184-
roomOptions = RoomOptions(e2eeOptions = getE2EEOptions()),
185185
)
186186

187187
// Create and publish audio/video tracks

0 commit comments

Comments
 (0)