@poolse/native 3.8.0 → 3.10.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +127 -9
  3. package/android/src/main/AndroidManifest.xml +4 -0
  4. package/android/src/main/java/dev/poolse/callcore/CallCoreRuntime.kt +8 -0
  5. package/android/src/main/java/dev/poolse/callcore/Ports.kt +47 -1
  6. package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +3 -3
  7. package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +112 -10
  8. package/android/src/main/java/dev/poolse/callcore/android/CallHttpClient.kt +3 -0
  9. package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +21 -1
  10. package/android/src/main/java/dev/poolse/callcore/android/CallVideo.kt +14 -0
  11. package/android/src/main/java/dev/poolse/callcore/android/EscalationNotification.kt +475 -0
  12. package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +9 -4
  13. package/android/src/main/java/dev/poolse/callcore/android/MeetingNotification.kt +127 -0
  14. package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +9 -0
  15. package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +9 -0
  16. package/android/src/main/java/dev/poolse/callcore/android/SnapshotJson.kt +23 -0
  17. package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +17 -1
  18. package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitMediaPort.kt +174 -11
  19. package/dist/index.cjs +33 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +197 -23
  22. package/dist/index.d.ts +197 -23
  23. package/dist/index.js +26 -1
  24. package/dist/index.js.map +1 -1
  25. package/ios/Core/CallCoreRuntime.swift +8 -0
  26. package/ios/Core/CallHttpClient.swift +11 -1
  27. package/ios/Core/Ports.swift +47 -2
  28. package/ios/Core/SnapshotEncoding.swift +39 -4
  29. package/ios/Module/PoolseCallsModule.swift +28 -1
  30. package/ios/Platform/CallCore.swift +68 -2
  31. package/ios/Platform/CallKitController.swift +1 -1
  32. package/ios/Platform/EscalationNotifications.swift +195 -0
  33. package/ios/Platform/LiveKitMediaPort.swift +178 -15
  34. package/ios/Platform/MessageNotifications.swift +60 -1
  35. package/ios/Platform/VoipPush.swift +11 -2
  36. package/package.json +1 -1
  37. package/src/index.ts +231 -23
@@ -3,6 +3,8 @@ package dev.poolse.callcore.android
3
3
  import dev.poolse.callcore.Direction
4
4
  import dev.poolse.callcore.MachineState
5
5
  import dev.poolse.callcore.Phase
6
+ import org.json.JSONArray
7
+ import org.json.JSONObject
6
8
 
7
9
  /**
8
10
  * The one place a [MachineState] becomes the contract's `Snapshot`
@@ -32,6 +34,11 @@ internal fun MachineState.toSnapshot(
32
34
  videoPaused: Boolean = false,
33
35
  /** We are sharing our screen. */
34
36
  screenSharing: Boolean = false,
37
+ /** False while the server holds our media back (recording consent not given yet). */
38
+ canPublish: Boolean = true,
39
+ /** The CallSummary's `recording` / `transcription` objects, JSON text (null: not known). */
40
+ recording: String? = null,
41
+ transcription: String? = null,
35
42
  ): Map<String, Any?>? {
36
43
  if (phase == Phase.IDLE) return null
37
44
  return buildMap {
@@ -42,6 +49,11 @@ internal fun MachineState.toSnapshot(
42
49
  put("screenSharing", screenSharing)
43
50
  put("audioOutputs", audioOutputs)
44
51
  put("audioOutputId", audioOutputId)
52
+ // false: listen-only until the server lets go (docs/RECORDING.md §5).
53
+ put("canPublish", canPublish)
54
+ // The capture state as of joining; null when not known.
55
+ put("recording", jsonMap(recording))
56
+ put("transcription", jsonMap(transcription))
45
57
  // Optional in the contract: present only while a camera is published.
46
58
  if (cameraFacing != null) put("cameraFacing", cameraFacing)
47
59
  // The call waiting beside this one: null when none.
@@ -83,6 +95,17 @@ private fun MachineState.snapshotCore(
83
95
  )
84
96
  }
85
97
 
98
+ /** JSON object text → plain maps/lists for the bridge; null when absent or not an object. */
99
+ private fun jsonMap(text: String?): Map<String, Any?>? =
100
+ text?.let { runCatching { plain(JSONObject(it)) as Map<String, Any?> }.getOrNull() }
101
+
102
+ private fun plain(v: Any?): Any? = when (v) {
103
+ is JSONObject -> v.keys().asSequence().associateWith { plain(v.opt(it)) }
104
+ is JSONArray -> (0 until v.length()).map { plain(v.opt(it)) }
105
+ JSONObject.NULL -> null
106
+ else -> v
107
+ }
108
+
86
109
  private val Phase.wire: String
87
110
  get() = when (this) {
88
111
  Phase.IDLE -> "idle"
@@ -10,6 +10,7 @@ import android.os.Build
10
10
  import android.provider.Settings
11
11
  import android.util.Log
12
12
  import dev.poolse.callcore.android.CallCore
13
+ import dev.poolse.callcore.android.MeetingNotification
13
14
  import dev.poolse.callcore.android.MessageNotifications
14
15
  import dev.poolse.callcore.android.MissedCallNotification
15
16
  import dev.poolse.callcore.android.ServerRegistry
@@ -184,9 +185,16 @@ class PoolseCallsModule : Module() {
184
185
  promise?.resolve(false)
185
186
  }
186
187
  }
188
+ // Capture processing (CL7). Blur is not available on Android yet.
189
+ Function("noiseSuppressionSupported") { core()?.noiseSuppressionSupported ?: false }
190
+ Function("setNoiseSuppression") { on: Boolean -> core()?.setNoiseSuppression(on) ?: false }
191
+ Function("backgroundBlurSupported") { core()?.backgroundBlurSupported ?: false }
192
+ Function("setBackgroundBlur") { on: Boolean -> core()?.setBackgroundBlur(on) ?: false }
187
193
  Function("switchCamera") { core()?.switchCamera() }
188
194
  Function("setSpeaker") { on: Boolean -> core()?.setSpeaker(on) }
189
195
  Function("setAudioOutput") { id: String -> core()?.setAudioOutput(id) }
196
+ // Recording consent accepted: mic and camera back as they were.
197
+ Function("republish") { core()?.republish() }
190
198
 
191
199
  // What authorizes acting on the call itself (ringing people in).
192
200
  AsyncFunction("callControl") {
@@ -290,20 +298,28 @@ class PoolseCallsModule : Module() {
290
298
  // Null on a notification posted before servers: the default one.
291
299
  val serverId = intent.getStringExtra(MissedCallNotification.EXTRA_SERVER_ID)
292
300
  ?: context?.let { ServerRegistry.servers(it).get(null)?.id }
301
+ // A meeting notice's tap / Join (MeetingNotification).
302
+ val meetingId = intent.getStringExtra(MeetingNotification.EXTRA_SCHEDULED_MEETING_ID)
293
303
  for (key in listOf(
294
304
  MissedCallNotification.EXTRA_SERVER_ID,
295
305
  MissedCallNotification.EXTRA_ACTION,
296
306
  MissedCallNotification.EXTRA_CONVERSATION_ID,
297
307
  MissedCallNotification.EXTRA_CALL_ID,
298
308
  MissedCallNotification.EXTRA_MEDIA,
309
+ MeetingNotification.EXTRA_SCHEDULED_MEETING_ID,
299
310
  )) intent.removeExtra(key)
300
- if (callId != null) context?.let { MissedCallNotification.cancel(it, callId) }
311
+ if (meetingId != null) {
312
+ context?.let { MeetingNotification.cancel(it, meetingId) }
313
+ } else if (callId != null) {
314
+ context?.let { MissedCallNotification.cancel(it, callId) }
315
+ }
301
316
  return mapOf(
302
317
  "type" to action,
303
318
  "conversationId" to conversationId,
304
319
  "callId" to callId,
305
320
  "media" to media,
306
321
  "serverId" to serverId,
322
+ "scheduledMeetingId" to meetingId,
307
323
  )
308
324
  }
309
325
 
@@ -9,7 +9,9 @@ import androidx.core.content.ContextCompat
9
9
  import com.twilio.audioswitch.AudioDevice
10
10
  import dev.poolse.callcore.CallSessionBundle
11
11
  import dev.poolse.callcore.MediaPort
12
+ import dev.poolse.callcore.ServiceParticipants
12
13
  import dev.poolse.callcore.android.AudioOutput
14
+ import dev.poolse.callcore.android.CaptureProcessingSource
13
15
  import dev.poolse.callcore.android.CallVideoSource
14
16
  import dev.poolse.callcore.android.CallVideoSurface
15
17
  import dev.poolse.callcore.android.MediaEvents
@@ -24,7 +26,10 @@ import io.livekit.android.events.collect
24
26
  import io.livekit.android.room.Room
25
27
  import io.livekit.android.room.participant.ConnectionQuality
26
28
  import io.livekit.android.room.participant.Participant
29
+ import io.livekit.android.room.participant.ParticipantPermission
30
+ import io.livekit.android.room.participant.RemoteParticipant
27
31
  import io.livekit.android.room.track.CameraPosition
32
+ import io.livekit.android.room.track.LocalAudioTrackOptions
28
33
  import io.livekit.android.room.track.LocalVideoTrack
29
34
  import io.livekit.android.room.track.RemoteTrackPublication
30
35
  import io.livekit.android.room.track.Track
@@ -58,7 +63,7 @@ import org.json.JSONObject
58
63
  class LiveKitMediaPort(
59
64
  private val context: Context,
60
65
  private val events: MediaEvents,
61
- ) : MediaPort, CallVideoSource, ScreenShareSource {
66
+ ) : MediaPort, CallVideoSource, ScreenShareSource, CaptureProcessingSource {
62
67
 
63
68
  private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
64
69
  @Volatile private var room: Room? = null
@@ -88,6 +93,14 @@ class LiveKitMediaPort(
88
93
  private var cameraWanted: Boolean? = null
89
94
  private var joinedCallId: String? = null
90
95
 
96
+ /**
97
+ * The server lets us publish. False while it holds our media back for
98
+ * consent (docs/RECORDING.md §5): the choices above are kept, nothing
99
+ * is published (LiveKit unpublished what was live), and they come back
100
+ * as they were once permission returns.
101
+ */
102
+ private var canPublish = true
103
+
91
104
  /** Our own link to the SFU, as last reported. */
92
105
  private var localQuality = "unknown"
93
106
 
@@ -101,6 +114,21 @@ class LiveKitMediaPort(
101
114
  /** Remote camera publications this port switched off, by sid. */
102
115
  private val pausedSids = mutableSetOf<String>()
103
116
 
117
+ /**
118
+ * WebRTC's noise suppression on the microphone (CL7). Echo
119
+ * cancellation, gain control and the high-pass filter stay on: a call
120
+ * without AEC echoes. Kept across calls.
121
+ */
122
+ private var noiseSuppression = true
123
+
124
+ private fun captureOptions() = LocalAudioTrackOptions(
125
+ noiseSuppression = noiseSuppression,
126
+ echoCancellation = true,
127
+ autoGainControl = true,
128
+ highPassFilter = true,
129
+ typingNoiseDetection = true,
130
+ )
131
+
104
132
  /** Live `<CallVideoView>` slots; rebound whenever what they show may have changed. */
105
133
  private val surfaces = linkedSetOf<LiveKitVideoSurface>()
106
134
 
@@ -116,6 +144,7 @@ class LiveKitMediaPort(
116
144
  loud = wantsVideo || bundle.kind == "room"
117
145
  val newRoom = LiveKit.create(appContext = context.applicationContext)
118
146
  configureAudio(newRoom, loud)
147
+ newRoom.audioTrackCaptureDefaults = captureOptions()
119
148
  // A 1:1/small call: never let the SFU pause a subscribed camera for
120
149
  // "not visible" — a track whose view mounts late would stay black.
121
150
  // (Renderers are still registered with visibility via addRenderer.)
@@ -140,10 +169,15 @@ class LiveKitMediaPort(
140
169
  }
141
170
  }.isSuccess
142
171
  if (!connected || room !== newRoom) return@launch
172
+ // The token may say listen-only (consent required, not yet given):
173
+ // publish nothing then — the permission update brings it back.
174
+ val allowed = updateCanPublish(newRoom)
143
175
  // Publishing failures must not fail the call: audio-only is a call.
144
- runCatching { newRoom.localParticipant.setMicrophoneEnabled(!mutedWanted) }
145
- .onFailure { Log.w(TAG, "microphone publish failed", it) }
146
- if (cameraWanted ?: wantsVideo) enableCamera(newRoom, true)
176
+ if (allowed) {
177
+ runCatching { newRoom.localParticipant.setMicrophoneEnabled(!mutedWanted) }
178
+ .onFailure { Log.w(TAG, "microphone publish failed", it) }
179
+ }
180
+ if (allowed && (cameraWanted ?: wantsVideo)) enableCamera(newRoom, true)
147
181
  reportLocalCamera(newRoom)
148
182
  refreshVideo()
149
183
  }
@@ -177,6 +211,7 @@ class LiveKitMediaPort(
177
211
  private fun resetWanted() {
178
212
  mutedWanted = false
179
213
  cameraWanted = null
214
+ canPublish = true
180
215
  outputWanted = null
181
216
  pauseJob?.cancel()
182
217
  resumeJob?.cancel()
@@ -216,12 +251,15 @@ class LiveKitMediaPort(
216
251
 
217
252
  override fun setMuted(muted: Boolean) {
218
253
  mutedWanted = muted
254
+ // Not allowed to publish: only remembered, applied on republish.
255
+ if (!canPublish) return
219
256
  val r = room ?: return
220
257
  scope.launch { runCatching { r.localParticipant.setMicrophoneEnabled(!muted) } }
221
258
  }
222
259
 
223
260
  override fun setCamera(on: Boolean) {
224
261
  cameraWanted = on
262
+ if (!canPublish) return
225
263
  val r = room ?: return
226
264
  scope.launch {
227
265
  enableCamera(r, on)
@@ -239,6 +277,7 @@ class LiveKitMediaPort(
239
277
  */
240
278
  override fun setScreenShare(on: Boolean, permission: Intent?) {
241
279
  val r = room ?: return
280
+ if (on && !canPublish) return
242
281
  if (on && permission == null) return
243
282
  scope.launch {
244
283
  runCatching { r.localParticipant.setScreenShareEnabled(on, if (on) permission else null) }
@@ -249,6 +288,68 @@ class LiveKitMediaPort(
249
288
  }
250
289
  }
251
290
 
291
+ // ── capture processing (CL7) ────────────────────────────────────────
292
+
293
+ /**
294
+ * Capture options are fixed when the microphone track is created, so a
295
+ * change mid-call unpublishes the live track and publishes a fresh one
296
+ * with the new options (a short gap in our audio, nothing else).
297
+ */
298
+ override fun setNoiseSuppression(on: Boolean) {
299
+ if (on == noiseSuppression) return
300
+ noiseSuppression = on
301
+ val r = room ?: return
302
+ r.audioTrackCaptureDefaults = captureOptions()
303
+ if (r.state != Room.State.CONNECTED || !canPublish) return
304
+ scope.launch {
305
+ val track = r.localParticipant.getTrackPublication(Track.Source.MICROPHONE)?.track ?: return@launch
306
+ runCatching {
307
+ r.localParticipant.unpublishTrack(track, true)
308
+ r.localParticipant.setMicrophoneEnabled(!mutedWanted)
309
+ }.onFailure { Log.w(TAG, "noise suppression switch failed", it) }
310
+ }
311
+ }
312
+
313
+ // Background blur needs livekit-android-track-processors (ML Kit
314
+ // segmentation, several MB): not shipped yet. [backgroundBlurSupported]
315
+ // stays false.
316
+
317
+ // ── publish permission (recording consent) ──────────────────────────
318
+
319
+ /** Reads the local participant's permission; reports a change. Returns it. */
320
+ private fun updateCanPublish(r: Room): Boolean {
321
+ if (room !== r) return canPublish
322
+ val perms: ParticipantPermission? = r.localParticipant.permissions
323
+ val now = perms?.canPublish ?: true
324
+ if (now != canPublish) {
325
+ canPublish = now
326
+ Log.i(TAG, "canPublish=$now")
327
+ events.onCanPublish(now)
328
+ }
329
+ return now
330
+ }
331
+
332
+ /**
333
+ * Mic and camera as the user last had them — after consent (the app
334
+ * calls this from its consent prompt; the permission update does it
335
+ * too). A no-op while the server still says listen-only.
336
+ */
337
+ override fun republish() {
338
+ val r = room ?: return
339
+ if (r.state != Room.State.CONNECTED || !updateCanPublish(r)) return
340
+ val camera = cameraWanted ?: (media == "video")
341
+ scope.launch {
342
+ if (r.localParticipant.isMicrophoneEnabled() == mutedWanted) {
343
+ runCatching { r.localParticipant.setMicrophoneEnabled(!mutedWanted) }
344
+ .onFailure { Log.w(TAG, "microphone republish failed", it) }
345
+ }
346
+ if (camera && localCameraTrack(r) == null) enableCamera(r, true)
347
+ if (room !== r) return@launch
348
+ reportLocalCamera(r)
349
+ refreshVideo()
350
+ }
351
+ }
352
+
252
353
  /** Front ↔ back on the published camera track. */
253
354
  override fun switchCamera() {
254
355
  val r = room ?: return
@@ -289,7 +390,7 @@ class LiveKitMediaPort(
289
390
  internal fun cameraTrack(participantId: String?, local: Boolean): VideoTrack? {
290
391
  val r = room ?: return null
291
392
  if (local) return localCameraTrack(r)
292
- val p = r.remoteParticipants.values.firstOrNull { it.identity?.value == participantId } ?: return null
393
+ val p = people(r).firstOrNull { it.identity?.value == participantId } ?: return null
293
394
  return remoteCamera(p)
294
395
  }
295
396
 
@@ -309,7 +410,7 @@ class LiveKitMediaPort(
309
410
  internal fun screenTrack(participantId: String?, local: Boolean): VideoTrack? {
310
411
  val r = room ?: return null
311
412
  if (local) return localScreenTrack(r)
312
- val p = r.remoteParticipants.values.firstOrNull { it.identity?.value == participantId } ?: return null
413
+ val p = people(r).firstOrNull { it.identity?.value == participantId } ?: return null
313
414
  return remoteScreen(p)
314
415
  }
315
416
 
@@ -471,7 +572,7 @@ class LiveKitMediaPort(
471
572
  events.onConnected()
472
573
  // Somebody may already be in (a late join, or a callee who
473
574
  // answered before our media came up): they will not "connect".
474
- if (room.remoteParticipants.isNotEmpty()) events.onRemoteJoined()
575
+ if (people(room).isNotEmpty()) events.onRemoteJoined()
475
576
  emit(room)
476
577
  refreshVideo()
477
578
  }
@@ -483,9 +584,25 @@ class LiveKitMediaPort(
483
584
  // LiveKit gave up (or the server removed us). Our own leave()
484
585
  // never gets here — the collector is cancelled first.
485
586
  is RoomEvent.Disconnected -> {
587
+ // The same user joined from another device: LiveKit replaces
588
+ // the older participant (one identity per user). The reconnect
589
+ // that follows is refused, and the call ends as moved.
590
+ if (event.reason == DisconnectReason.DUPLICATE_IDENTITY) events.onMovedElsewhere()
486
591
  if (event.reason != DisconnectReason.CLIENT_INITIATED) events.onLost()
487
592
  }
488
- is RoomEvent.ParticipantConnected -> { events.onRemoteJoined(); emit(room); refreshVideo() }
593
+ // The transcript assistant or the recorder joining is nobody answering.
594
+ is RoomEvent.ParticipantConnected -> {
595
+ if (!isService(event.participant) && !isAgent(event.participant)) events.onRemoteJoined()
596
+ emit(room)
597
+ refreshVideo()
598
+ }
599
+ // Only ever ours: the server turned publishing off (consent) or back on.
600
+ is RoomEvent.ParticipantPermissionsChanged -> {
601
+ if (event.participant === room.localParticipant) {
602
+ val was = canPublish
603
+ if (updateCanPublish(room) && !was) republish()
604
+ }
605
+ }
489
606
  // Anything that can make a camera appear, vanish or freeze:
490
607
  // update the roster's cameraOn, the local camera state, and
491
608
  // rebind every video view.
@@ -518,10 +635,56 @@ class LiveKitMediaPort(
518
635
  }
519
636
  }
520
637
 
638
+ /**
639
+ * The remote PEOPLE: poolse's transcript assistant and LiveKit Egress's
640
+ * recorder are in the room but are not someone in the call — never in
641
+ * the roster, the count that ends a call left alone, or a video tile.
642
+ * Agents are listed separately ([agents]). Phone (SIP) participants are people.
643
+ */
644
+ private fun people(r: Room): List<RemoteParticipant> =
645
+ r.remoteParticipants.values.filterNot { isService(it) || isAgent(it) }
646
+
647
+ private fun isAgent(p: Participant): Boolean =
648
+ p.metadata?.let { runCatching { JSONObject(it).optBoolean("agent", false) }.getOrNull() } == true
649
+
650
+ private fun isService(p: Participant): Boolean {
651
+ val kind = when (p.kind) {
652
+ Participant.Kind.AGENT -> "agent"
653
+ Participant.Kind.EGRESS -> "egress"
654
+ Participant.Kind.SIP -> "sip"
655
+ else -> null
656
+ }
657
+ return ServiceParticipants.isService(p.identity?.value ?: "", kind)
658
+ }
659
+
660
+ /**
661
+ * Agents invited into the call (AGENTS_IN_CALLS.md §1): kind AGENT like
662
+ * poolse's room assistant, but marked `agent: true` in their token
663
+ * metadata — listed (with the badge), unlike the assistant and recorder.
664
+ */
665
+ private fun agents(r: Room): List<Pair<RemoteParticipant, JSONObject>> =
666
+ r.remoteParticipants.values.mapNotNull { p ->
667
+ val m = p.metadata?.let { runCatching { JSONObject(it) }.getOrNull() }
668
+ if (m != null && m.optBoolean("agent", false)) p to m else null
669
+ }
670
+
521
671
  /** The REMOTE roster — the local participant is never included. */
522
672
  private fun emit(room: Room) {
673
+ val agentRows = agents(room).map { (p, m) ->
674
+ val identity = p.identity?.value ?: ""
675
+ MediaParticipant(
676
+ identity = identity,
677
+ speaking = p.isSpeaking,
678
+ muted = !p.isMicrophoneEnabled(),
679
+ connectionQuality = wire(p.connectionQuality),
680
+ externalId = externalIdOf(p) ?: identity,
681
+ isAgent = true,
682
+ agentLabel = m.optString("label", "").ifEmpty { null } ?: p.name?.ifEmpty { null },
683
+ agentMode = m.optString("mode", "").ifEmpty { null },
684
+ )
685
+ }
523
686
  events.onParticipants(
524
- room.remoteParticipants.values.map {
687
+ agentRows.let { agentList -> people(room).map {
525
688
  val identity = it.identity?.value ?: ""
526
689
  MediaParticipant(
527
690
  identity = identity,
@@ -534,7 +697,7 @@ class LiveKitMediaPort(
534
697
  connectionQuality = wire(it.connectionQuality),
535
698
  externalId = externalIdOf(it) ?: identity,
536
699
  )
537
- },
700
+ } + agentList },
538
701
  )
539
702
  }
540
703
 
@@ -578,7 +741,7 @@ class LiveKitMediaPort(
578
741
  }
579
742
 
580
743
  private fun hasRemoteVideo(r: Room) =
581
- r.remoteParticipants.values.any { it.getTrackPublication(Track.Source.CAMERA) != null }
744
+ people(r).any { it.getTrackPublication(Track.Source.CAMERA) != null }
582
745
 
583
746
  private fun setVideoPaused(r: Room, paused: Boolean) {
584
747
  Log.i(TAG, "incoming video ${if (paused) "paused" else "resumed"} quality=$localQuality")
package/dist/index.cjs CHANGED
@@ -63,6 +63,9 @@ function place(conversationId, options) {
63
63
  function join(callId, conversationId, sessionToken, serverId) {
64
64
  return native?.join(callId, conversationId, sessionToken, serverId ?? null) ?? Promise.resolve();
65
65
  }
66
+ function moveCallHere(callId, options) {
67
+ return join(callId, options.conversationId, options.sessionToken, options.serverId);
68
+ }
66
69
  async function startRoom(conversationId, options) {
67
70
  if (!native) throw new Error("The native call core is not in this build.");
68
71
  const origin = originOf(options.serverId);
@@ -115,11 +118,28 @@ var switchCamera = () => native?.switchCamera();
115
118
  var screenShareSupported = () => native?.screenShareSupported?.() ?? false;
116
119
  var startScreenShare = async () => await native?.startScreenShare?.() ?? false;
117
120
  var stopScreenShare = () => native?.stopScreenShare?.();
121
+ var noiseSuppressionSupported = () => native?.noiseSuppressionSupported?.() ?? false;
122
+ var setNoiseSuppression = (on) => native?.setNoiseSuppression?.(on) ?? false;
123
+ var backgroundBlurSupported = () => native?.backgroundBlurSupported?.() ?? false;
124
+ var setBackgroundBlur = (on) => native?.setBackgroundBlur?.(on) ?? false;
118
125
  var setSpeaker = (on) => native?.setSpeaker(on);
119
126
  function setAudioOutput(id) {
120
127
  if (native?.setAudioOutput) native.setAudioOutput(id);
121
128
  else native?.setSpeaker(id === "speaker");
122
129
  }
130
+ var republish = () => native?.republish?.();
131
+ function onCanPublishChange(cb) {
132
+ let last = null;
133
+ const check = (snapshot) => {
134
+ const now = snapshot?.canPublish ?? true;
135
+ if (now === last) return;
136
+ const first = last === null;
137
+ last = now;
138
+ if (!first || snapshot) cb(now);
139
+ };
140
+ check(getCallState());
141
+ return onCallState(check);
142
+ }
123
143
  var onRingEnded = (callId, reason) => native?.onRingEnded(callId, reason);
124
144
  var onCallFinished = (callId, reason) => native?.onCallFinished(callId, reason ?? null);
125
145
  var canUseFullScreenIntent = () => native?.canUseFullScreenIntent() ?? true;
@@ -174,6 +194,11 @@ function onNotificationReply(cb) {
174
194
  if (result.action === "reply") cb(result);
175
195
  });
176
196
  }
197
+ function onEscalationAction(cb) {
198
+ return onNotificationAction((result) => {
199
+ if (result.action === "escalation") cb(result);
200
+ });
201
+ }
177
202
  function takeNotificationActions() {
178
203
  return native?.takeNotificationActions?.() ?? [];
179
204
  }
@@ -234,6 +259,7 @@ exports.DEFAULT_SERVER_ID = DEFAULT_SERVER_ID;
234
259
  exports.addServer = addServer;
235
260
  exports.answer = answer;
236
261
  exports.answerWaiting = answerWaiting;
262
+ exports.backgroundBlurSupported = backgroundBlurSupported;
237
263
  exports.canUseFullScreenIntent = canUseFullScreenIntent;
238
264
  exports.configure = configure;
239
265
  exports.conversationOfNotification = conversationOfNotification;
@@ -245,10 +271,14 @@ exports.hangUp = hangUp;
245
271
  exports.isInPictureInPicture = isInPictureInPicture;
246
272
  exports.join = join;
247
273
  exports.listServers = listServers;
274
+ exports.moveCallHere = moveCallHere;
248
275
  exports.nativeCallsAvailable = nativeCallsAvailable;
276
+ exports.noiseSuppressionSupported = noiseSuppressionSupported;
249
277
  exports.onCallAction = onCallAction;
250
278
  exports.onCallFinished = onCallFinished;
251
279
  exports.onCallState = onCallState;
280
+ exports.onCanPublishChange = onCanPublishChange;
281
+ exports.onEscalationAction = onEscalationAction;
252
282
  exports.onNotificationAction = onNotificationAction;
253
283
  exports.onNotificationReply = onNotificationReply;
254
284
  exports.onPictureInPicture = onPictureInPicture;
@@ -258,13 +288,16 @@ exports.openFullScreenIntentSettings = openFullScreenIntentSettings;
258
288
  exports.pictureInPictureSupported = pictureInPictureSupported;
259
289
  exports.place = place;
260
290
  exports.removeServer = removeServer;
291
+ exports.republish = republish;
261
292
  exports.ringIntoCall = ringIntoCall;
262
293
  exports.screenShareSupported = screenShareSupported;
263
294
  exports.serverOfNotification = serverOfNotification;
264
295
  exports.setActiveConversation = setActiveConversation;
265
296
  exports.setAudioOutput = setAudioOutput;
297
+ exports.setBackgroundBlur = setBackgroundBlur;
266
298
  exports.setCamera = setCamera;
267
299
  exports.setMuted = setMuted;
300
+ exports.setNoiseSuppression = setNoiseSuppression;
268
301
  exports.setPictureInPictureEnabled = setPictureInPictureEnabled;
269
302
  exports.setShowOnLockscreen = setShowOnLockscreen;
270
303
  exports.setSpeaker = setSpeaker;