@livekit/react-native 2.6.2 → 2.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,30 +24,25 @@ object LiveKitReactNative {
24
24
 
25
25
  val audioDeviceModule: JavaAudioDeviceModule
26
26
  get() {
27
- val adm = this.adm
27
+ return this.adm
28
28
  ?: throw IllegalStateException("Audio device module is not initialized! Did you remember to call LiveKitReactNative.setup in your Application.onCreate?")
29
- return adm
30
29
  }
31
30
 
32
- private lateinit var _audioProcessingController: AudioProcessingController
31
+ private var _audioProcessingController: CustomAudioProcessingController? = null
33
32
 
34
33
  val audioProcessingController: AudioProcessingController
35
34
  get() {
36
- if (!::_audioProcessingController.isInitialized) {
37
- throw IllegalStateException("audioProcessingController is not initialized! Did you remember to call LiveKitReactNative.setup in your Application.onCreate?")
38
- }
39
- return _audioProcessingController
35
+ return this._audioProcessingController
36
+ ?: throw IllegalStateException("audioProcessingController is not initialized! Did you remember to call LiveKitReactNative.setup in your Application.onCreate?")
40
37
  }
41
38
 
42
39
 
43
- lateinit var _audioRecordSamplesDispatcher: AudioRecordSamplesDispatcher
40
+ private var _audioRecordSamplesDispatcher: AudioRecordSamplesDispatcher? = null
44
41
 
45
42
  val audioRecordSamplesDispatcher: AudioRecordSamplesDispatcher
46
43
  get() {
47
- if (!::_audioRecordSamplesDispatcher.isInitialized) {
44
+ return this._audioRecordSamplesDispatcher ?:
48
45
  throw IllegalStateException("audioRecordSamplesDispatcher is not initialized! Did you remember to call LiveKitReactNative.setup in your Application.onCreate?")
49
- }
50
- return _audioRecordSamplesDispatcher
51
46
  }
52
47
 
53
48
 
@@ -73,6 +68,13 @@ object LiveKitReactNative {
73
68
 
74
69
  setupAdm(context)
75
70
  options.audioDeviceModule = adm
71
+ // CustomAudioProcessingController can't be instantiated before WebRTC is loaded.
72
+ options.audioProcessingFactoryFactory = Callable {
73
+ val apc = CustomAudioProcessingController()
74
+ _audioProcessingController = apc
75
+ return@Callable apc.externalAudioProcessor
76
+ }
77
+
76
78
  }
77
79
 
78
80
  private fun setupAdm(context: Context) {
@@ -94,15 +96,11 @@ object LiveKitReactNative {
94
96
  adm?.release()
95
97
  adm = null
96
98
 
99
+ _audioProcessingController = null
100
+
101
+ // adm needs to be re-setup with a new one each time.
97
102
  setupAdm(context)
98
103
  options.audioDeviceModule = adm
99
104
 
100
- // CustomAudioProcessingController can't be instantiated before WebRTC is loaded.
101
- options.audioProcessingFactoryFactory = Callable {
102
- val apc = CustomAudioProcessingController()
103
- _audioProcessingController = apc
104
- return@Callable apc.externalAudioProcessor
105
- }
106
-
107
105
  }
108
106
  }
@@ -198,10 +198,10 @@ public class LivekitReactNativeModule: RCTEventEmitter {
198
198
 
199
199
  @objc(createMultibandVolumeProcessor:pcId:trackId:)
200
200
  public func createMultibandVolumeProcessor(_ options: NSDictionary, pcId: NSNumber, trackId: String) -> String {
201
- let bands = (options["bands"] as? NSString)?.integerValue ?? 5
202
- let minFrequency = (options["minFrequency"] as? NSString)?.floatValue ?? 1000
203
- let maxFrequency = (options["maxFrequency"] as? NSString)?.floatValue ?? 8000
204
- let intervalMs = (options["updateInterval"] as? NSString)?.floatValue ?? 40
201
+ let bands = (options["bands"] as? NSNumber)?.intValue ?? 5
202
+ let minFrequency = (options["minFrequency"] as? NSNumber)?.floatValue ?? 1000
203
+ let maxFrequency = (options["maxFrequency"] as? NSNumber)?.floatValue ?? 8000
204
+ let intervalMs = (options["updateInterval"] as? NSNumber)?.floatValue ?? 40
205
205
 
206
206
  let renderer = MultibandVolumeAudioRenderer(
207
207
  bands: bands,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livekit/react-native",
3
- "version": "2.6.2",
3
+ "version": "2.6.4",
4
4
  "description": "LiveKit for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",