Skip to content

Commit 38e5991

Browse files
authored
Fix RoomOptions initializer with empty encryption param (#799)
This reverts commit 9b567f8.
1 parent 462d444 commit 38e5991

File tree

3 files changed

+11
-32
lines changed

3 files changed

+11
-32
lines changed

.changes/options-init

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patch type="fixed" "RoomOptions init collision"

Sources/LiveKit/Types/Options/RoomOptions.swift

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Foundation
1818

1919
@objc
20-
public final class RoomOptions: NSObject, Sendable {
20+
public final class RoomOptions: NSObject, Sendable, Loggable {
2121
// default options for capturing
2222
@objc
2323
public let defaultCameraCaptureOptions: CameraCaptureOptions
@@ -101,34 +101,6 @@ public final class RoomOptions: NSObject, Sendable {
101101
stopLocalTrackOnUnpublish: Bool = true,
102102
suspendLocalVideoTracksInBackground: Bool = true,
103103
e2eeOptions: E2EEOptions? = nil,
104-
reportRemoteTrackStatistics: Bool = false)
105-
{
106-
self.defaultCameraCaptureOptions = defaultCameraCaptureOptions
107-
self.defaultScreenShareCaptureOptions = defaultScreenShareCaptureOptions
108-
self.defaultAudioCaptureOptions = defaultAudioCaptureOptions
109-
self.defaultVideoPublishOptions = defaultVideoPublishOptions
110-
self.defaultAudioPublishOptions = defaultAudioPublishOptions
111-
self.defaultDataPublishOptions = defaultDataPublishOptions
112-
self.adaptiveStream = adaptiveStream
113-
self.dynacast = dynacast
114-
self.stopLocalTrackOnUnpublish = stopLocalTrackOnUnpublish
115-
self.suspendLocalVideoTracksInBackground = suspendLocalVideoTracksInBackground
116-
self.e2eeOptions = e2eeOptions
117-
encryptionOptions = nil // don't pass both
118-
self.reportRemoteTrackStatistics = reportRemoteTrackStatistics
119-
}
120-
121-
@objc
122-
public init(defaultCameraCaptureOptions: CameraCaptureOptions = CameraCaptureOptions(),
123-
defaultScreenShareCaptureOptions: ScreenShareCaptureOptions = ScreenShareCaptureOptions(),
124-
defaultAudioCaptureOptions: AudioCaptureOptions = AudioCaptureOptions(),
125-
defaultVideoPublishOptions: VideoPublishOptions = VideoPublishOptions(),
126-
defaultAudioPublishOptions: AudioPublishOptions = AudioPublishOptions(),
127-
defaultDataPublishOptions: DataPublishOptions = DataPublishOptions(),
128-
adaptiveStream: Bool = false,
129-
dynacast: Bool = false,
130-
stopLocalTrackOnUnpublish: Bool = true,
131-
suspendLocalVideoTracksInBackground: Bool = true,
132104
encryptionOptions: EncryptionOptions? = nil,
133105
reportRemoteTrackStatistics: Bool = false)
134106
{
@@ -142,9 +114,15 @@ public final class RoomOptions: NSObject, Sendable {
142114
self.dynacast = dynacast
143115
self.stopLocalTrackOnUnpublish = stopLocalTrackOnUnpublish
144116
self.suspendLocalVideoTracksInBackground = suspendLocalVideoTracksInBackground
145-
e2eeOptions = nil // don't pass both
117+
self.e2eeOptions = e2eeOptions
146118
self.encryptionOptions = encryptionOptions
147119
self.reportRemoteTrackStatistics = reportRemoteTrackStatistics
120+
121+
super.init()
122+
123+
if e2eeOptions != nil, encryptionOptions != nil {
124+
log("Specifying both 'e2eeOptions' and 'encryptionOptions' is not supported. Migrate to 'EncryptionOptions' to enable data channel encryption (requires support from all platforms).", .error)
125+
}
148126
}
149127

150128
// MARK: - Equal

Tests/LiveKitTests/DataChannel/EncryptedDataChannelTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class EncryptedDataChannelTests: LKTestCase, @unchecked Sendable {
138138
await self.fulfillment(of: [self.decryptionErrorExpectation], timeout: 5)
139139

140140
XCTAssertNotNil(self.lastDecryptionError, "Decryption error should have occurred")
141-
XCTAssertNil(self.receivedData, "No data should be received when decryption fails")
141+
XCTAssert(self.receivedData.isEmpty, "No data should be received when decryption fails")
142142
}
143143
}
144144

@@ -188,7 +188,7 @@ class EncryptedDataChannelTests: LKTestCase, @unchecked Sendable {
188188
await self.fulfillment(of: [self.decryptionErrorExpectation], timeout: 5)
189189

190190
XCTAssertNotNil(self.lastDecryptionError, "Decryption error should have occurred with mismatched per-participant keys")
191-
XCTAssertNil(self.receivedData, "No data should be received when per-participant key decryption fails")
191+
XCTAssert(self.receivedData.isEmpty, "No data should be received when per-participant key decryption fails")
192192
}
193193
}
194194

0 commit comments

Comments
 (0)