@livekit/react-native 1.1.1 → 1.2.0

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.
package/README.md CHANGED
@@ -29,7 +29,7 @@ This library depends on `@livekit/react-native-webrtc`, which has additional ins
29
29
  - [iOS Installation Guide](https://github.com/livekit/react-native-webrtc/blob/master/Documentation/iOSInstallation.md)
30
30
  - [Android Installation Guide](https://github.com/livekit/react-native-webrtc/blob/master/Documentation/AndroidInstallation.md)
31
31
 
32
- ----
32
+ ---
33
33
 
34
34
  Once the `@livekit/react-native-webrtc` dependency is installed, one last step is needed to finish the installation:
35
35
 
@@ -38,21 +38,16 @@ Once the `@livekit/react-native-webrtc` dependency is installed, one last step i
38
38
  In your [MainApplication.java](https://github.com/livekit/client-sdk-react-native/blob/main/example/android/app/src/main/java/com/example/livekitreactnative/MainApplication.java) file:
39
39
 
40
40
  ```
41
- import com.livekit.reactnative.video.SimulcastVideoEncoderFactoryWrapper;
42
- import com.oney.WebRTCModule.WebRTCModuleOptions;
43
- import com.oney.WebRTCModule.webrtcutils.H264AndSoftwareVideoDecoderFactory;
44
-
45
- import org.webrtc.*;
41
+ import com.livekit.reactnative.LiveKitReactNative;
46
42
 
47
43
  public class MainApplication extends Application implements ReactApplication {
48
44
 
49
45
  @Override
50
46
  public void onCreate() {
51
47
  // Place this above any other RN related initialization
52
- WebRTCModuleOptions options = WebRTCModuleOptions.getInstance();
53
- options.videoEncoderFactory = new SimulcastVideoEncoderFactoryWrapper(null, true, true);
54
- options.videoDecoderFactory = new H264AndSoftwareVideoDecoderFactory(null);
55
- // ...
48
+ LiveKitReactNative.setup();
49
+
50
+ //...
56
51
  }
57
52
  }
58
53
  ```
@@ -62,19 +57,15 @@ public class MainApplication extends Application implements ReactApplication {
62
57
  In your [AppDelegate.m](https://github.com/livekit/client-sdk-react-native/blob/main/example/ios/LivekitReactNativeExample/AppDelegate.mm) file:
63
58
 
64
59
  ```
65
- #import "WebRTCModule.h"
66
- #import "WebRTCModuleOptions.h"
60
+ #import "LivekitReactNative.h"
67
61
 
68
62
  @implementation AppDelegate
69
63
 
70
64
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
71
65
  {
72
66
  // Place this above any other RN related initialization
73
- RTCDefaultVideoEncoderFactory *videoEncoderFactory = [[RTCDefaultVideoEncoderFactory alloc] init];
74
- RTCVideoEncoderFactorySimulcast *simulcastVideoEncoderFactory =
75
- [[RTCVideoEncoderFactorySimulcast alloc] initWithPrimary:videoEncoderFactory fallback:videoEncoderFactory];
76
- WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance];
77
- options.videoEncoderFactory = simulcastVideoEncoderFactory;
67
+ [LivekitReactNative setup];
68
+
78
69
  //...
79
70
  }
80
71
  ```
@@ -115,8 +106,12 @@ const [room] = useState(() => new Room());
115
106
  const { participants } = useRoom(room);
116
107
 
117
108
  useEffect(() => {
118
- AudioSession.startAudioSession();
119
- room.connect(url, token, {});
109
+ let connect = async () => {
110
+ await AudioSession.startAudioSession();
111
+ await room.connect(url, token, {});
112
+ console.log('connected to ', url, ' ', token);
113
+ };
114
+ connect();
120
115
  return () => {
121
116
  room.disconnect();
122
117
  AudioSession.stopAudioSession();
@@ -135,6 +130,40 @@ const videoView = participants.length > 0 && (
135
130
 
136
131
  Additional documentation for the LiveKit SDK can be found at https://docs.livekit.io/references/client-sdks/
137
132
 
133
+ ## Audio sessions
134
+
135
+ As seen in the above example, we've introduced a new class `AudioSession` that helps
136
+ to manage the audio session on native platforms. This class wraps either [AudioManager](https://developer.android.com/reference/android/media/AudioManager) on Android, or [AVAudioSession](https://developer.apple.com/documentation/avfaudio/avaudiosession) on iOS.
137
+
138
+ You can customize the configuration of the audio session with `configureAudio`.
139
+
140
+ ```js
141
+ useEffect(() => {
142
+ let connect = async () => {
143
+ // configure audio session prior to starting it.
144
+ await AudioSession.configureAudio({
145
+ android: {
146
+ preferredOutputList: ['earpiece'],
147
+ // See [AudioManager](https://developer.android.com/reference/android/media/AudioManager)
148
+ // for details on audio and focus modes.
149
+ audioMode: 'normal',
150
+ audioFocusMode: 'gain',
151
+ },
152
+ ios: {
153
+ defaultOutput: 'earpiece',
154
+ },
155
+ });
156
+ await AudioSession.startAudioSession();
157
+ await room.connect(url, token, {});
158
+ };
159
+ connect();
160
+ return () => {
161
+ room.disconnect();
162
+ AudioSession.stopAudioSession();
163
+ };
164
+ }, [url, token, room]);
165
+ ```
166
+
138
167
  ## Screenshare
139
168
 
140
169
  Enabling screenshare requires extra installation steps:
@@ -205,10 +234,12 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the
205
234
  Apache License 2.0
206
235
 
207
236
  <!--BEGIN_REPO_NAV-->
237
+
208
238
  <br/><table>
239
+
209
240
  <thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
210
241
  <tbody>
211
- <tr><td>Client SDKs</td><td><a href="https://github.com/livekit/components-js">Components</a> · <a href="https://github.com/livekit/client-sdk-js">JavaScript</a> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <b>React Native (beta)</b></td></tr><tr></tr>
242
+ <tr><td>Client SDKs</td><td><a href="https://github.com/livekit/components-js">Components</a> · <a href="https://github.com/livekit/client-sdk-js">JavaScript</a> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <b>React Native</b> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/livekit/client-sdk-python">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
212
243
  <tr><td>Server SDKs</td><td><a href="https://github.com/livekit/server-sdk-js">Node.js</a> · <a href="https://github.com/livekit/server-sdk-go">Golang</a> · <a href="https://github.com/livekit/server-sdk-ruby">Ruby</a> · <a href="https://github.com/livekit/server-sdk-kotlin">Java/Kotlin</a> · <a href="https://github.com/agence104/livekit-server-sdk-php">PHP (community)</a> · <a href="https://github.com/tradablebits/livekit-server-sdk-python">Python (community)</a></td></tr><tr></tr>
213
244
  <tr><td>Services</td><td><a href="https://github.com/livekit/livekit">Livekit server</a> · <a href="https://github.com/livekit/egress">Egress</a> · <a href="https://github.com/livekit/ingress">Ingress</a></td></tr><tr></tr>
214
245
  <tr><td>Resources</td><td><a href="https://docs.livekit.io">Docs</a> · <a href="https://github.com/livekit-examples">Example apps</a> · <a href="https://livekit.io/cloud">Cloud</a> · <a href="https://docs.livekit.io/oss/deployment">Self-hosting</a> · <a href="https://github.com/livekit/livekit-cli">CLI</a></td></tr>
@@ -129,7 +129,8 @@ dependencies {
129
129
  // noinspection GradleDynamicVersion
130
130
  api 'com.facebook.react:react-native:+'
131
131
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
132
- api 'com.github.davidliu:audioswitch:c498d866c57f1d88056d5e7e7a78d622e3b0c046'
133
- api 'io.github.webrtc-sdk:android:104.5112.09'
132
+ api 'com.github.davidliu:audioswitch:fb33b237aa50b3d1d2dea0e0695ecb7b38a98971'
133
+ api 'io.github.webrtc-sdk:android:104.5112.10'
134
+ implementation project(':livekit_react-native-webrtc')
134
135
  implementation "androidx.annotation:annotation:1.4.0"
135
136
  }
@@ -0,0 +1,16 @@
1
+ package com.livekit.reactnative
2
+
3
+ import com.livekit.reactnative.video.SimulcastVideoEncoderFactoryWrapper
4
+ import com.livekit.reactnative.video.WrappedVideoDecoderFactoryProxy
5
+ import com.oney.WebRTCModule.WebRTCModuleOptions
6
+
7
+
8
+ object LiveKitReactNative {
9
+
10
+ @JvmStatic
11
+ fun setup() {
12
+ val options = WebRTCModuleOptions.getInstance()
13
+ options.videoEncoderFactory = SimulcastVideoEncoderFactoryWrapper(null, true, true)
14
+ options.videoDecoderFactory = WrappedVideoDecoderFactoryProxy()
15
+ }
16
+ }
@@ -2,6 +2,7 @@ package com.livekit.reactnative
2
2
 
3
3
  import com.facebook.react.bridge.*
4
4
  import com.livekit.reactnative.audio.AudioDeviceKind
5
+ import com.livekit.reactnative.audio.AudioManagerUtils
5
6
  import com.livekit.reactnative.audio.AudioSwitchManager
6
7
 
7
8
 
@@ -23,6 +24,19 @@ class LivekitReactNativeModule(reactContext: ReactApplicationContext) : ReactCon
23
24
  }
24
25
  audioManager.preferredDeviceList = preferredDeviceList
25
26
  }
27
+
28
+ androidConfig.getString("audioMode")?.let { audioModeString ->
29
+ val audioMode = AudioManagerUtils.audioModeFromString(audioModeString)
30
+ if (audioMode != null) {
31
+ audioManager.setAudioMode(audioMode)
32
+ }
33
+ }
34
+ androidConfig.getString("audioFocusMode")?.let { focusModeString ->
35
+ val focusMode = AudioManagerUtils.focusModeFromString(focusModeString)
36
+ if (focusMode != null) {
37
+ audioManager.setFocusMode(focusMode)
38
+ }
39
+ }
26
40
  }
27
41
 
28
42
  @ReactMethod
@@ -0,0 +1,44 @@
1
+ package com.livekit.reactnative.audio
2
+
3
+ import android.media.AudioManager
4
+ import android.util.Log
5
+
6
+
7
+ object AudioManagerUtils {
8
+ private const val TAG = "AudioManagerUtils"
9
+
10
+ fun audioModeFromString(audioModeString: String?): Int? {
11
+ if (audioModeString == null) {
12
+ return null
13
+ }
14
+
15
+ var audioMode: Int? = null
16
+ when (audioModeString) {
17
+ "normal" -> audioMode = AudioManager.MODE_NORMAL
18
+ "callScreening" -> audioMode = AudioManager.MODE_CALL_SCREENING
19
+ "inCall" -> audioMode = AudioManager.MODE_IN_CALL
20
+ "inCommunication" -> audioMode = AudioManager.MODE_IN_COMMUNICATION
21
+ "ringtone" -> audioMode = AudioManager.MODE_RINGTONE
22
+ else -> Log.w(TAG, "Unknown audio mode: $audioModeString")
23
+ }
24
+
25
+ return audioMode
26
+ }
27
+
28
+ fun focusModeFromString(focusModeString: String?): Int? {
29
+ if (focusModeString == null) {
30
+ return null
31
+ }
32
+
33
+ var focusMode: Int? = null
34
+ when (focusModeString) {
35
+ "gain" -> focusMode = AudioManager.AUDIOFOCUS_GAIN
36
+ "gainTransient" -> focusMode = AudioManager.AUDIOFOCUS_GAIN_TRANSIENT
37
+ "gainTransientExclusive" -> focusMode = AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE
38
+ "gainTransientMayDuck" -> focusMode = AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK
39
+ else -> Log.w(TAG, "Unknown audio focus mode: $focusModeString")
40
+ }
41
+
42
+ return focusMode
43
+ }
44
+ }
@@ -43,6 +43,20 @@ public class AudioSwitchManager {
43
43
  @Nullable
44
44
  private AudioSwitch audioSwitch;
45
45
 
46
+ /**
47
+ * The audio focus mode to use while started.
48
+ *
49
+ * Defaults to [AudioManager.AUDIOFOCUS_GAIN].
50
+ */
51
+ private int focusMode = AudioManager.AUDIOFOCUS_GAIN;
52
+
53
+ /**
54
+ * The audio mode to use while started.
55
+ *
56
+ * Defaults to [AudioManager.MODE_NORMAL].
57
+ */
58
+ private int audioMode = AudioManager.MODE_NORMAL;
59
+
46
60
  public AudioSwitchManager(@NonNull Context context) {
47
61
  this.context = context;
48
62
  this.audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
@@ -64,6 +78,8 @@ public class AudioSwitchManager {
64
78
  audioFocusChangeListener,
65
79
  preferredDeviceList
66
80
  );
81
+ audioSwitch.setFocusMode(focusMode);
82
+ audioSwitch.setAudioMode(audioMode);
67
83
  audioSwitch.start(audioDeviceChangeListener);
68
84
  audioSwitch.activate();
69
85
  });
@@ -137,4 +153,12 @@ public class AudioSwitchManager {
137
153
  selectAudioOutput(kind.audioDeviceClass);
138
154
  }
139
155
  }
156
+
157
+ public void setFocusMode(int focusMode) {
158
+ this.focusMode = focusMode;
159
+ }
160
+
161
+ public void setAudioMode(int audioMode) {
162
+ this.audioMode = audioMode;
163
+ }
140
164
  }
@@ -0,0 +1,19 @@
1
+ package com.livekit.reactnative.video
2
+
3
+ import com.oney.WebRTCModule.EglUtils
4
+ import org.webrtc.VideoCodecInfo
5
+ import org.webrtc.VideoDecoder
6
+ import org.webrtc.VideoDecoderFactory
7
+ import org.webrtc.WrappedVideoDecoderFactory
8
+
9
+ class WrappedVideoDecoderFactoryProxy : VideoDecoderFactory {
10
+
11
+ private val factory by lazy { WrappedVideoDecoderFactory(EglUtils.getRootEglBaseContext()) }
12
+ override fun createDecoder(codecInfo: VideoCodecInfo): VideoDecoder? {
13
+ return factory.createDecoder(codecInfo)
14
+ }
15
+
16
+ override fun getSupportedCodecs(): Array<VideoCodecInfo> {
17
+ return factory.supportedCodecs
18
+ }
19
+ }
@@ -8,4 +8,6 @@
8
8
 
9
9
  @interface LivekitReactNative : NSObject <RCTBridgeModule>
10
10
 
11
+ +(void)setup;
12
+
11
13
  @end
@@ -1,5 +1,7 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import "LivekitReactNative.h"
3
+ #import "WebRTCModule.h"
4
+ #import "WebRTCModuleOptions.h"
3
5
  #import <WebRTC/RTCAudioSession.h>
4
6
  #import <WebRTC/RTCAudioSessionConfiguration.h>
5
7
  #import <AVFAudio/AVFAudio.h>
@@ -31,6 +33,13 @@ RCT_EXPORT_MODULE();
31
33
  return NO;
32
34
  }
33
35
 
36
+ +(void)setup {
37
+ RTCDefaultVideoEncoderFactory *videoEncoderFactory = [[RTCDefaultVideoEncoderFactory alloc] init];
38
+ RTCVideoEncoderFactorySimulcast *simulcastVideoEncoderFactory = [[RTCVideoEncoderFactorySimulcast alloc] initWithPrimary:videoEncoderFactory fallback:videoEncoderFactory];
39
+ WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance];
40
+ options.videoEncoderFactory = simulcastVideoEncoderFactory;
41
+ }
42
+
34
43
  /// Configure default audio config for WebRTC
35
44
  RCT_EXPORT_METHOD(configureAudio:(NSDictionary *) config){
36
45
  NSDictionary *iOSConfig = [config objectForKey:@"ios"];
@@ -34,6 +34,13 @@ const LivekitReactNative = _reactNative.NativeModules.LivekitReactNative ? _reac
34
34
  * 3. `"headset"`
35
35
  * 4. `"bluetooth"`
36
36
  *
37
+ * * audioMode - The audio mode to use for the audio session. Defaults to 'normal'.
38
+ *
39
+ * * audioFocusMode - The focus mode to use for the audio session. Defaults to 'gain'.
40
+ *
41
+ * See [AudioManager](https://developer.android.com/reference/android/media/AudioManager) for details
42
+ * on audio and focus modes.
43
+ *
37
44
  * ----
38
45
  * iOS
39
46
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["AudioSession.ts"],"names":["LINKING_ERROR","Platform","select","ios","default","LivekitReactNative","NativeModules","Proxy","get","Error","AudioSession","config","configureAudio","startAudioSession","stopAudioSession","OS","getAudioOutputs","deviceId","selectAudioOutput","showAudioRoutePicker"],"mappings":";;;;;;;AAAA;;;;AACA,MAAMA,aAAa,GAChB,gFAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,kBAAkB,GAAGC,2BAAcD,kBAAd,GACvBC,2BAAcD,kBADS,GAEvB,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUe,MAAMU,YAAN,CAAmB;;;;gBAAbA,Y,oBAMK,MAAOC,MAAP,IAAsC;AAC5D,QAAMN,kBAAkB,CAACO,cAAnB,CAAkCD,MAAlC,CAAN;AACD,C;;gBARkBD,Y,uBAaQ,YAAY;AACrC,QAAML,kBAAkB,CAACQ,iBAAnB,EAAN;AACD,C;;gBAfkBH,Y,sBAoBO,YAAY;AACpC,QAAML,kBAAkB,CAACS,gBAAnB,EAAN;AACD,C;;gBAtBkBJ,Y,qBAmDM,YAA+B;AACtD,MAAIT,sBAASc,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAO,CAAC,SAAD,EAAY,eAAZ,CAAP;AACD,GAFD,MAEO,IAAId,sBAASc,EAAT,KAAgB,SAApB,EAA+B;AACpC,WAAQ,MAAMV,kBAAkB,CAACW,eAAnB,EAAd;AACD,GAFM,MAEA;AACL,WAAO,EAAP;AACD;AACF,C;;gBA3DkBN,Y,uBAoEQ,MAAOO,QAAP,IAA4B;AACrD,QAAMZ,kBAAkB,CAACa,iBAAnB,CAAqCD,QAArC,CAAN;AACD,C;;gBAtEkBP,Y,0BA6EW,YAAY;AACxC,MAAIT,sBAASc,EAAT,KAAgB,KAApB,EAA2B;AACzB,UAAMV,kBAAkB,CAACc,oBAAnB,EAAN;AACD;AACF,C","sourcesContent":["import { NativeModules, Platform } from 'react-native';\nconst LINKING_ERROR =\n `The package '@livekit/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst LivekitReactNative = NativeModules.LivekitReactNative\n ? NativeModules.LivekitReactNative\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Configuration for the underlying AudioSession.\n *\n * ----\n * Android specific options:\n *\n * * preferredOutputList - The preferred order in which to automatically select an audio output.\n * This is ignored when an output is manually selected with {@link AudioSession.selectAudioOutput}.\n *\n * By default, the order is set to:\n * 1. `\"speaker\"`\n * 2. `\"earpiece\"`\n * 3. `\"headset\"`\n * 4. `\"bluetooth\"`\n *\n * ----\n * iOS\n *\n * * defaultOutput - The default preferred output to use when a wired headset or bluetooth output is unavailable.\n *\n * By default, this is set to `\"speaker\"`\n */\nexport type AudioConfiguration = {\n android: {\n preferredOutputList: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n };\n ios: {\n defaultOutput: 'speaker' | 'earpiece';\n };\n};\n\nexport default class AudioSession {\n /**\n * Applies the provided audio configuration to the underlying AudioSession.\n *\n * Must be called prior to connecting to a Room for the configuration to apply correctly.\n */\n static configureAudio = async (config: AudioConfiguration) => {\n await LivekitReactNative.configureAudio(config);\n };\n\n /**\n * Starts an AudioSession.\n */\n static startAudioSession = async () => {\n await LivekitReactNative.startAudioSession();\n };\n\n /**\n * Stops the existing AudioSession.\n */\n static stopAudioSession = async () => {\n await LivekitReactNative.stopAudioSession();\n };\n\n /**\n * Gets the available audio outputs for use with {@link selectAudioOutput}.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * For Android, will return if available:\n * * \"speaker\"\n * * \"earpiece\"\n * * \"headset\"\n * * \"bluetooth\"\n *\n * Note: For applications targeting SDK versions over 30, the runtime BLUETOOTH_CONNECT\n * permission must be requested to send audio to bluetooth headsets.\n *\n * ----\n *\n * For iOS, due to OS limitations, the only available types are:\n * * \"default\" - Use default iOS audio routing\n * * \"force_speaker\" - Force audio output through speaker\n *\n * See also {@link showAudioRoutePicker} to display a route picker that\n * can choose between other audio devices (i.e. headset/bluetooth/airplay),\n * or use a library like `react-native-avroutepicker` for a native platform\n * control.\n *\n * @returns the available audio output types\n */\n static getAudioOutputs = async (): Promise<string[]> => {\n if (Platform.OS === 'ios') {\n return ['default', 'force_speaker'];\n } else if (Platform.OS === 'android') {\n return (await LivekitReactNative.getAudioOutputs()) as string[];\n } else {\n return [];\n }\n };\n\n /**\n * Select the provided audio output if available.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * @param deviceId A deviceId retrieved from {@link getAudioOutputs}\n */\n static selectAudioOutput = async (deviceId: string) => {\n await LivekitReactNative.selectAudioOutput(deviceId);\n };\n\n /**\n * iOS only, requires iOS 11+.\n *\n * Displays an AVRoutePickerView for the user to choose their audio output.\n */\n static showAudioRoutePicker = async () => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.showAudioRoutePicker();\n }\n };\n}\n"]}
1
+ {"version":3,"sources":["AudioSession.ts"],"names":["LINKING_ERROR","Platform","select","ios","default","LivekitReactNative","NativeModules","Proxy","get","Error","AudioSession","config","configureAudio","startAudioSession","stopAudioSession","OS","getAudioOutputs","deviceId","selectAudioOutput","showAudioRoutePicker"],"mappings":";;;;;;;AAAA;;;;AACA,MAAMA,aAAa,GAChB,gFAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,kBAAkB,GAAGC,2BAAcD,kBAAd,GACvBC,2BAAcD,kBADS,GAEvB,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBe,MAAMU,YAAN,CAAmB;;;;gBAAbA,Y,oBAMK,MAAOC,MAAP,IAAsC;AAC5D,QAAMN,kBAAkB,CAACO,cAAnB,CAAkCD,MAAlC,CAAN;AACD,C;;gBARkBD,Y,uBAaQ,YAAY;AACrC,QAAML,kBAAkB,CAACQ,iBAAnB,EAAN;AACD,C;;gBAfkBH,Y,sBAoBO,YAAY;AACpC,QAAML,kBAAkB,CAACS,gBAAnB,EAAN;AACD,C;;gBAtBkBJ,Y,qBAmDM,YAA+B;AACtD,MAAIT,sBAASc,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAO,CAAC,SAAD,EAAY,eAAZ,CAAP;AACD,GAFD,MAEO,IAAId,sBAASc,EAAT,KAAgB,SAApB,EAA+B;AACpC,WAAQ,MAAMV,kBAAkB,CAACW,eAAnB,EAAd;AACD,GAFM,MAEA;AACL,WAAO,EAAP;AACD;AACF,C;;gBA3DkBN,Y,uBAoEQ,MAAOO,QAAP,IAA4B;AACrD,QAAMZ,kBAAkB,CAACa,iBAAnB,CAAqCD,QAArC,CAAN;AACD,C;;gBAtEkBP,Y,0BA6EW,YAAY;AACxC,MAAIT,sBAASc,EAAT,KAAgB,KAApB,EAA2B;AACzB,UAAMV,kBAAkB,CAACc,oBAAnB,EAAN;AACD;AACF,C","sourcesContent":["import { NativeModules, Platform } from 'react-native';\nconst LINKING_ERROR =\n `The package '@livekit/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst LivekitReactNative = NativeModules.LivekitReactNative\n ? NativeModules.LivekitReactNative\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Configuration for the underlying AudioSession.\n *\n * ----\n * Android specific options:\n *\n * * preferredOutputList - The preferred order in which to automatically select an audio output.\n * This is ignored when an output is manually selected with {@link AudioSession.selectAudioOutput}.\n *\n * By default, the order is set to:\n * 1. `\"speaker\"`\n * 2. `\"earpiece\"`\n * 3. `\"headset\"`\n * 4. `\"bluetooth\"`\n *\n * * audioMode - The audio mode to use for the audio session. Defaults to 'normal'.\n *\n * * audioFocusMode - The focus mode to use for the audio session. Defaults to 'gain'.\n *\n * See [AudioManager](https://developer.android.com/reference/android/media/AudioManager) for details\n * on audio and focus modes.\n *\n * ----\n * iOS\n *\n * * defaultOutput - The default preferred output to use when a wired headset or bluetooth output is unavailable.\n *\n * By default, this is set to `\"speaker\"`\n */\nexport type AudioConfiguration = {\n android?: {\n preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n audioMode?:\n | 'normal'\n | 'callScreening'\n | 'inCall'\n | 'inCommunication'\n | 'ringtone';\n audioFocusMode?:\n | 'gain'\n | 'gainTransient'\n | 'gainTransientExclusive'\n | 'gainTransientMayDuck';\n };\n ios?: {\n defaultOutput?: 'speaker' | 'earpiece';\n };\n};\n\nexport default class AudioSession {\n /**\n * Applies the provided audio configuration to the underlying AudioSession.\n *\n * Must be called prior to connecting to a Room for the configuration to apply correctly.\n */\n static configureAudio = async (config: AudioConfiguration) => {\n await LivekitReactNative.configureAudio(config);\n };\n\n /**\n * Starts an AudioSession.\n */\n static startAudioSession = async () => {\n await LivekitReactNative.startAudioSession();\n };\n\n /**\n * Stops the existing AudioSession.\n */\n static stopAudioSession = async () => {\n await LivekitReactNative.stopAudioSession();\n };\n\n /**\n * Gets the available audio outputs for use with {@link selectAudioOutput}.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * For Android, will return if available:\n * * \"speaker\"\n * * \"earpiece\"\n * * \"headset\"\n * * \"bluetooth\"\n *\n * Note: For applications targeting SDK versions over 30, the runtime BLUETOOTH_CONNECT\n * permission must be requested to send audio to bluetooth headsets.\n *\n * ----\n *\n * For iOS, due to OS limitations, the only available types are:\n * * \"default\" - Use default iOS audio routing\n * * \"force_speaker\" - Force audio output through speaker\n *\n * See also {@link showAudioRoutePicker} to display a route picker that\n * can choose between other audio devices (i.e. headset/bluetooth/airplay),\n * or use a library like `react-native-avroutepicker` for a native platform\n * control.\n *\n * @returns the available audio output types\n */\n static getAudioOutputs = async (): Promise<string[]> => {\n if (Platform.OS === 'ios') {\n return ['default', 'force_speaker'];\n } else if (Platform.OS === 'android') {\n return (await LivekitReactNative.getAudioOutputs()) as string[];\n } else {\n return [];\n }\n };\n\n /**\n * Select the provided audio output if available.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * @param deviceId A deviceId retrieved from {@link getAudioOutputs}\n */\n static selectAudioOutput = async (deviceId: string) => {\n await LivekitReactNative.selectAudioOutput(deviceId);\n };\n\n /**\n * iOS only, requires iOS 11+.\n *\n * Displays an AVRoutePickerView for the user to choose their audio output.\n */\n static showAudioRoutePicker = async () => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.showAudioRoutePicker();\n }\n };\n}\n"]}
@@ -26,6 +26,13 @@ const LivekitReactNative = NativeModules.LivekitReactNative ? NativeModules.Live
26
26
  * 3. `"headset"`
27
27
  * 4. `"bluetooth"`
28
28
  *
29
+ * * audioMode - The audio mode to use for the audio session. Defaults to 'normal'.
30
+ *
31
+ * * audioFocusMode - The focus mode to use for the audio session. Defaults to 'gain'.
32
+ *
33
+ * See [AudioManager](https://developer.android.com/reference/android/media/AudioManager) for details
34
+ * on audio and focus modes.
35
+ *
29
36
  * ----
30
37
  * iOS
31
38
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["AudioSession.ts"],"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","LivekitReactNative","Proxy","get","Error","AudioSession","config","configureAudio","startAudioSession","stopAudioSession","OS","getAudioOutputs","deviceId","selectAudioOutput","showAudioRoutePicker"],"mappings":";;AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AACA,MAAMC,aAAa,GAChB,gFAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,kBAAkB,GAAGN,aAAa,CAACM,kBAAd,GACvBN,aAAa,CAACM,kBADS,GAEvB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,eAAe,MAAMQ,YAAN,CAAmB;;gBAAbA,Y,oBAMK,MAAOC,MAAP,IAAsC;AAC5D,QAAML,kBAAkB,CAACM,cAAnB,CAAkCD,MAAlC,CAAN;AACD,C;;gBARkBD,Y,uBAaQ,YAAY;AACrC,QAAMJ,kBAAkB,CAACO,iBAAnB,EAAN;AACD,C;;gBAfkBH,Y,sBAoBO,YAAY;AACpC,QAAMJ,kBAAkB,CAACQ,gBAAnB,EAAN;AACD,C;;gBAtBkBJ,Y,qBAmDM,YAA+B;AACtD,MAAIT,QAAQ,CAACc,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAO,CAAC,SAAD,EAAY,eAAZ,CAAP;AACD,GAFD,MAEO,IAAId,QAAQ,CAACc,EAAT,KAAgB,SAApB,EAA+B;AACpC,WAAQ,MAAMT,kBAAkB,CAACU,eAAnB,EAAd;AACD,GAFM,MAEA;AACL,WAAO,EAAP;AACD;AACF,C;;gBA3DkBN,Y,uBAoEQ,MAAOO,QAAP,IAA4B;AACrD,QAAMX,kBAAkB,CAACY,iBAAnB,CAAqCD,QAArC,CAAN;AACD,C;;gBAtEkBP,Y,0BA6EW,YAAY;AACxC,MAAIT,QAAQ,CAACc,EAAT,KAAgB,KAApB,EAA2B;AACzB,UAAMT,kBAAkB,CAACa,oBAAnB,EAAN;AACD;AACF,C","sourcesContent":["import { NativeModules, Platform } from 'react-native';\nconst LINKING_ERROR =\n `The package '@livekit/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst LivekitReactNative = NativeModules.LivekitReactNative\n ? NativeModules.LivekitReactNative\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Configuration for the underlying AudioSession.\n *\n * ----\n * Android specific options:\n *\n * * preferredOutputList - The preferred order in which to automatically select an audio output.\n * This is ignored when an output is manually selected with {@link AudioSession.selectAudioOutput}.\n *\n * By default, the order is set to:\n * 1. `\"speaker\"`\n * 2. `\"earpiece\"`\n * 3. `\"headset\"`\n * 4. `\"bluetooth\"`\n *\n * ----\n * iOS\n *\n * * defaultOutput - The default preferred output to use when a wired headset or bluetooth output is unavailable.\n *\n * By default, this is set to `\"speaker\"`\n */\nexport type AudioConfiguration = {\n android: {\n preferredOutputList: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n };\n ios: {\n defaultOutput: 'speaker' | 'earpiece';\n };\n};\n\nexport default class AudioSession {\n /**\n * Applies the provided audio configuration to the underlying AudioSession.\n *\n * Must be called prior to connecting to a Room for the configuration to apply correctly.\n */\n static configureAudio = async (config: AudioConfiguration) => {\n await LivekitReactNative.configureAudio(config);\n };\n\n /**\n * Starts an AudioSession.\n */\n static startAudioSession = async () => {\n await LivekitReactNative.startAudioSession();\n };\n\n /**\n * Stops the existing AudioSession.\n */\n static stopAudioSession = async () => {\n await LivekitReactNative.stopAudioSession();\n };\n\n /**\n * Gets the available audio outputs for use with {@link selectAudioOutput}.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * For Android, will return if available:\n * * \"speaker\"\n * * \"earpiece\"\n * * \"headset\"\n * * \"bluetooth\"\n *\n * Note: For applications targeting SDK versions over 30, the runtime BLUETOOTH_CONNECT\n * permission must be requested to send audio to bluetooth headsets.\n *\n * ----\n *\n * For iOS, due to OS limitations, the only available types are:\n * * \"default\" - Use default iOS audio routing\n * * \"force_speaker\" - Force audio output through speaker\n *\n * See also {@link showAudioRoutePicker} to display a route picker that\n * can choose between other audio devices (i.e. headset/bluetooth/airplay),\n * or use a library like `react-native-avroutepicker` for a native platform\n * control.\n *\n * @returns the available audio output types\n */\n static getAudioOutputs = async (): Promise<string[]> => {\n if (Platform.OS === 'ios') {\n return ['default', 'force_speaker'];\n } else if (Platform.OS === 'android') {\n return (await LivekitReactNative.getAudioOutputs()) as string[];\n } else {\n return [];\n }\n };\n\n /**\n * Select the provided audio output if available.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * @param deviceId A deviceId retrieved from {@link getAudioOutputs}\n */\n static selectAudioOutput = async (deviceId: string) => {\n await LivekitReactNative.selectAudioOutput(deviceId);\n };\n\n /**\n * iOS only, requires iOS 11+.\n *\n * Displays an AVRoutePickerView for the user to choose their audio output.\n */\n static showAudioRoutePicker = async () => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.showAudioRoutePicker();\n }\n };\n}\n"]}
1
+ {"version":3,"sources":["AudioSession.ts"],"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","LivekitReactNative","Proxy","get","Error","AudioSession","config","configureAudio","startAudioSession","stopAudioSession","OS","getAudioOutputs","deviceId","selectAudioOutput","showAudioRoutePicker"],"mappings":";;AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AACA,MAAMC,aAAa,GAChB,gFAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,kBAAkB,GAAGN,aAAa,CAACM,kBAAd,GACvBN,aAAa,CAACM,kBADS,GAEvB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,eAAe,MAAMQ,YAAN,CAAmB;;gBAAbA,Y,oBAMK,MAAOC,MAAP,IAAsC;AAC5D,QAAML,kBAAkB,CAACM,cAAnB,CAAkCD,MAAlC,CAAN;AACD,C;;gBARkBD,Y,uBAaQ,YAAY;AACrC,QAAMJ,kBAAkB,CAACO,iBAAnB,EAAN;AACD,C;;gBAfkBH,Y,sBAoBO,YAAY;AACpC,QAAMJ,kBAAkB,CAACQ,gBAAnB,EAAN;AACD,C;;gBAtBkBJ,Y,qBAmDM,YAA+B;AACtD,MAAIT,QAAQ,CAACc,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAO,CAAC,SAAD,EAAY,eAAZ,CAAP;AACD,GAFD,MAEO,IAAId,QAAQ,CAACc,EAAT,KAAgB,SAApB,EAA+B;AACpC,WAAQ,MAAMT,kBAAkB,CAACU,eAAnB,EAAd;AACD,GAFM,MAEA;AACL,WAAO,EAAP;AACD;AACF,C;;gBA3DkBN,Y,uBAoEQ,MAAOO,QAAP,IAA4B;AACrD,QAAMX,kBAAkB,CAACY,iBAAnB,CAAqCD,QAArC,CAAN;AACD,C;;gBAtEkBP,Y,0BA6EW,YAAY;AACxC,MAAIT,QAAQ,CAACc,EAAT,KAAgB,KAApB,EAA2B;AACzB,UAAMT,kBAAkB,CAACa,oBAAnB,EAAN;AACD;AACF,C","sourcesContent":["import { NativeModules, Platform } from 'react-native';\nconst LINKING_ERROR =\n `The package '@livekit/react-native' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst LivekitReactNative = NativeModules.LivekitReactNative\n ? NativeModules.LivekitReactNative\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n/**\n * Configuration for the underlying AudioSession.\n *\n * ----\n * Android specific options:\n *\n * * preferredOutputList - The preferred order in which to automatically select an audio output.\n * This is ignored when an output is manually selected with {@link AudioSession.selectAudioOutput}.\n *\n * By default, the order is set to:\n * 1. `\"speaker\"`\n * 2. `\"earpiece\"`\n * 3. `\"headset\"`\n * 4. `\"bluetooth\"`\n *\n * * audioMode - The audio mode to use for the audio session. Defaults to 'normal'.\n *\n * * audioFocusMode - The focus mode to use for the audio session. Defaults to 'gain'.\n *\n * See [AudioManager](https://developer.android.com/reference/android/media/AudioManager) for details\n * on audio and focus modes.\n *\n * ----\n * iOS\n *\n * * defaultOutput - The default preferred output to use when a wired headset or bluetooth output is unavailable.\n *\n * By default, this is set to `\"speaker\"`\n */\nexport type AudioConfiguration = {\n android?: {\n preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n audioMode?:\n | 'normal'\n | 'callScreening'\n | 'inCall'\n | 'inCommunication'\n | 'ringtone';\n audioFocusMode?:\n | 'gain'\n | 'gainTransient'\n | 'gainTransientExclusive'\n | 'gainTransientMayDuck';\n };\n ios?: {\n defaultOutput?: 'speaker' | 'earpiece';\n };\n};\n\nexport default class AudioSession {\n /**\n * Applies the provided audio configuration to the underlying AudioSession.\n *\n * Must be called prior to connecting to a Room for the configuration to apply correctly.\n */\n static configureAudio = async (config: AudioConfiguration) => {\n await LivekitReactNative.configureAudio(config);\n };\n\n /**\n * Starts an AudioSession.\n */\n static startAudioSession = async () => {\n await LivekitReactNative.startAudioSession();\n };\n\n /**\n * Stops the existing AudioSession.\n */\n static stopAudioSession = async () => {\n await LivekitReactNative.stopAudioSession();\n };\n\n /**\n * Gets the available audio outputs for use with {@link selectAudioOutput}.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * For Android, will return if available:\n * * \"speaker\"\n * * \"earpiece\"\n * * \"headset\"\n * * \"bluetooth\"\n *\n * Note: For applications targeting SDK versions over 30, the runtime BLUETOOTH_CONNECT\n * permission must be requested to send audio to bluetooth headsets.\n *\n * ----\n *\n * For iOS, due to OS limitations, the only available types are:\n * * \"default\" - Use default iOS audio routing\n * * \"force_speaker\" - Force audio output through speaker\n *\n * See also {@link showAudioRoutePicker} to display a route picker that\n * can choose between other audio devices (i.e. headset/bluetooth/airplay),\n * or use a library like `react-native-avroutepicker` for a native platform\n * control.\n *\n * @returns the available audio output types\n */\n static getAudioOutputs = async (): Promise<string[]> => {\n if (Platform.OS === 'ios') {\n return ['default', 'force_speaker'];\n } else if (Platform.OS === 'android') {\n return (await LivekitReactNative.getAudioOutputs()) as string[];\n } else {\n return [];\n }\n };\n\n /**\n * Select the provided audio output if available.\n *\n * {@link startAudioSession} must be called prior to using this method.\n *\n * @param deviceId A deviceId retrieved from {@link getAudioOutputs}\n */\n static selectAudioOutput = async (deviceId: string) => {\n await LivekitReactNative.selectAudioOutput(deviceId);\n };\n\n /**\n * iOS only, requires iOS 11+.\n *\n * Displays an AVRoutePickerView for the user to choose their audio output.\n */\n static showAudioRoutePicker = async () => {\n if (Platform.OS === 'ios') {\n await LivekitReactNative.showAudioRoutePicker();\n }\n };\n}\n"]}
@@ -13,6 +13,13 @@
13
13
  * 3. `"headset"`
14
14
  * 4. `"bluetooth"`
15
15
  *
16
+ * * audioMode - The audio mode to use for the audio session. Defaults to 'normal'.
17
+ *
18
+ * * audioFocusMode - The focus mode to use for the audio session. Defaults to 'gain'.
19
+ *
20
+ * See [AudioManager](https://developer.android.com/reference/android/media/AudioManager) for details
21
+ * on audio and focus modes.
22
+ *
16
23
  * ----
17
24
  * iOS
18
25
  *
@@ -21,11 +28,13 @@
21
28
  * By default, this is set to `"speaker"`
22
29
  */
23
30
  export declare type AudioConfiguration = {
24
- android: {
25
- preferredOutputList: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];
31
+ android?: {
32
+ preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];
33
+ audioMode?: 'normal' | 'callScreening' | 'inCall' | 'inCommunication' | 'ringtone';
34
+ audioFocusMode?: 'gain' | 'gainTransient' | 'gainTransientExclusive' | 'gainTransientMayDuck';
26
35
  };
27
- ios: {
28
- defaultOutput: 'speaker' | 'earpiece';
36
+ ios?: {
37
+ defaultOutput?: 'speaker' | 'earpiece';
29
38
  };
30
39
  };
31
40
  export default class AudioSession {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livekit/react-native",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "LiveKit for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -15,10 +15,13 @@
15
15
  "cpp",
16
16
  "livekit-react-native.podspec",
17
17
  "!lib/typescript/example",
18
+ "!lib/typescript/ci",
18
19
  "!android/build",
19
20
  "!android/.gradle",
20
21
  "!android/.idea",
21
22
  "!ios/build",
23
+ "!example",
24
+ "!ci",
22
25
  "!**/__tests__",
23
26
  "!**/__fixtures__",
24
27
  "!**/__mocks__"
@@ -49,7 +52,7 @@
49
52
  "@babel/preset-env": "^7.20.0",
50
53
  "@babel/runtime": "^7.20.0",
51
54
  "@commitlint/config-conventional": "^16.2.1",
52
- "@livekit/react-native-webrtc": "^104.0.0-beta.0",
55
+ "@livekit/react-native-webrtc": "^104.0.1",
53
56
  "@react-native-community/eslint-config": "^3.2.0",
54
57
  "@release-it/conventional-changelog": "^4.2.0",
55
58
  "@tsconfig/react-native": "^2.0.2",
@@ -73,14 +76,14 @@
73
76
  "typescript": "4.8.4"
74
77
  },
75
78
  "peerDependencies": {
79
+ "@livekit/react-native-webrtc": "^104.0.1",
76
80
  "react": "*",
77
- "react-native": "*",
78
- "@livekit/react-native-webrtc": "^104.0.0"
81
+ "react-native": "*"
79
82
  },
80
83
  "scripts": {
81
84
  "test": "jest",
82
- "build-docs": "typedoc",
83
- "typescript": "tsc --noEmit",
85
+ "build-docs": "typedoc --tsconfig tsconfig.build.json",
86
+ "typescript": "tsc --noEmit -p tsconfig.build.json",
84
87
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
85
88
  "prepare": "bob build",
86
89
  "release": "release-it",
@@ -91,14 +94,35 @@
91
94
  "jest": {
92
95
  "preset": "react-native",
93
96
  "modulePathIgnorePatterns": [
94
- "<rootDir>/example/node_modules",
97
+ "<rootDir>/ci",
98
+ "<rootDir>/example",
95
99
  "<rootDir>/lib/"
96
100
  ]
97
101
  },
98
102
  "commitlint": {
99
103
  "extends": [
100
104
  "@commitlint/config-conventional"
101
- ]
105
+ ],
106
+ "rules": {
107
+ "type-enum": [
108
+ 2,
109
+ "always",
110
+ [
111
+ "build",
112
+ "chore",
113
+ "ci",
114
+ "docs",
115
+ "feat",
116
+ "fix",
117
+ "perf",
118
+ "refactor",
119
+ "revert",
120
+ "style",
121
+ "test",
122
+ "example"
123
+ ]
124
+ ]
125
+ }
102
126
  },
103
127
  "release-it": {
104
128
  "hooks": {
@@ -125,7 +149,8 @@
125
149
  },
126
150
  "plugins": {
127
151
  "@release-it/conventional-changelog": {
128
- "preset": "angular"
152
+ "preset": "angular",
153
+ "ignoreRecommendedBump": true
129
154
  }
130
155
  }
131
156
  },
@@ -31,6 +31,13 @@ const LivekitReactNative = NativeModules.LivekitReactNative
31
31
  * 3. `"headset"`
32
32
  * 4. `"bluetooth"`
33
33
  *
34
+ * * audioMode - The audio mode to use for the audio session. Defaults to 'normal'.
35
+ *
36
+ * * audioFocusMode - The focus mode to use for the audio session. Defaults to 'gain'.
37
+ *
38
+ * See [AudioManager](https://developer.android.com/reference/android/media/AudioManager) for details
39
+ * on audio and focus modes.
40
+ *
34
41
  * ----
35
42
  * iOS
36
43
  *
@@ -39,11 +46,22 @@ const LivekitReactNative = NativeModules.LivekitReactNative
39
46
  * By default, this is set to `"speaker"`
40
47
  */
41
48
  export type AudioConfiguration = {
42
- android: {
43
- preferredOutputList: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];
49
+ android?: {
50
+ preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];
51
+ audioMode?:
52
+ | 'normal'
53
+ | 'callScreening'
54
+ | 'inCall'
55
+ | 'inCommunication'
56
+ | 'ringtone';
57
+ audioFocusMode?:
58
+ | 'gain'
59
+ | 'gainTransient'
60
+ | 'gainTransientExclusive'
61
+ | 'gainTransientMayDuck';
44
62
  };
45
- ios: {
46
- defaultOutput: 'speaker' | 'earpiece';
63
+ ios?: {
64
+ defaultOutput?: 'speaker' | 'earpiece';
47
65
  };
48
66
  };
49
67