@poolse/native 3.9.0 → 3.10.1
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/CHANGELOG.md +64 -0
- package/README.md +129 -9
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/dev/poolse/callcore/CallCoreRuntime.kt +83 -6
- package/android/src/main/java/dev/poolse/callcore/Ports.kt +28 -1
- package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +3 -3
- package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +155 -10
- package/android/src/main/java/dev/poolse/callcore/android/CallHttpClient.kt +7 -1
- package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +21 -1
- package/android/src/main/java/dev/poolse/callcore/android/CallVideo.kt +32 -0
- package/android/src/main/java/dev/poolse/callcore/android/EscalationNotification.kt +475 -0
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +9 -4
- package/android/src/main/java/dev/poolse/callcore/android/MeetingNotification.kt +127 -0
- package/android/src/main/java/dev/poolse/callcore/android/PoolseIncomingCall.kt +9 -0
- package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +9 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +48 -2
- package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitMediaPort.kt +121 -6
- package/android/src/test/java/dev/poolse/callcore/android/CallHttpClientTest.kt +15 -0
- package/dist/index.cjs +108 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +241 -23
- package/dist/index.d.ts +241 -23
- package/dist/index.js +98 -1
- package/dist/index.js.map +1 -1
- package/ios/Core/CallCoreRuntime.swift +79 -5
- package/ios/Core/CallHttpClient.swift +9 -2
- package/ios/Core/Ports.swift +31 -2
- package/ios/Core/SnapshotEncoding.swift +22 -3
- package/ios/Module/PoolseCallsModule.swift +48 -1
- package/ios/Platform/CallCore.swift +100 -1
- package/ios/Platform/CallKitController.swift +1 -1
- package/ios/Platform/EscalationNotifications.swift +195 -0
- package/ios/Platform/LiveKitMediaPort.swift +127 -3
- package/ios/Platform/MessageNotifications.swift +60 -1
- package/ios/Platform/VoipPush.swift +11 -2
- package/package.json +1 -1
- package/src/index.ts +354 -23
|
@@ -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
|
|
@@ -36,7 +37,7 @@ class PoolseCallsModule : Module() {
|
|
|
36
37
|
override fun definition() = ModuleDefinition {
|
|
37
38
|
Name("PoolseCalls")
|
|
38
39
|
|
|
39
|
-
Events("onCallState", "onCallAction", "onPictureInPicture", "onNotificationAction")
|
|
40
|
+
Events("onCallState", "onCallAction", "onPictureInPicture", "onNotificationAction", "onCallData")
|
|
40
41
|
|
|
41
42
|
// <CallVideoView>: renders a participant's (or our own) camera.
|
|
42
43
|
View(PoolseCallVideoView::class) {
|
|
@@ -59,9 +60,11 @@ class PoolseCallsModule : Module() {
|
|
|
59
60
|
CallCore.listener = { snapshot -> sendEvent("onCallState", mapOf("snapshot" to snapshot)) }
|
|
60
61
|
CallPictureInPicture.listener = { active -> sendEvent("onPictureInPicture", mapOf("active" to active)) }
|
|
61
62
|
MessageNotifications.actionListener = { event -> sendEvent("onNotificationAction", event) }
|
|
63
|
+
CallCore.dataListener = { message -> sendEvent("onCallData", message) }
|
|
62
64
|
}
|
|
63
65
|
OnStopObserving {
|
|
64
66
|
CallCore.listener = null
|
|
67
|
+
CallCore.dataListener = null
|
|
65
68
|
CallPictureInPicture.listener = null
|
|
66
69
|
MessageNotifications.actionListener = null
|
|
67
70
|
}
|
|
@@ -184,12 +187,47 @@ class PoolseCallsModule : Module() {
|
|
|
184
187
|
promise?.resolve(false)
|
|
185
188
|
}
|
|
186
189
|
}
|
|
190
|
+
// Capture processing (CL7). Blur is not available on Android yet.
|
|
191
|
+
Function("noiseSuppressionSupported") { core()?.noiseSuppressionSupported ?: false }
|
|
192
|
+
Function("setNoiseSuppression") { on: Boolean -> core()?.setNoiseSuppression(on) ?: false }
|
|
193
|
+
Function("backgroundBlurSupported") { core()?.backgroundBlurSupported ?: false }
|
|
194
|
+
Function("setBackgroundBlur") { on: Boolean -> core()?.setBackgroundBlur(on) ?: false }
|
|
187
195
|
Function("switchCamera") { core()?.switchCamera() }
|
|
188
196
|
Function("setSpeaker") { on: Boolean -> core()?.setSpeaker(on) }
|
|
189
197
|
Function("setAudioOutput") { id: String -> core()?.setAudioOutput(id) }
|
|
190
198
|
// Recording consent accepted: mic and camera back as they were.
|
|
191
199
|
Function("republish") { core()?.republish() }
|
|
192
200
|
|
|
201
|
+
// The call's data channel (CL4, CL6): `data` is UTF-8 text, or bytes
|
|
202
|
+
// as base64 with `options.base64`. Resolves false when not connected,
|
|
203
|
+
// over 14 000 bytes, or refused.
|
|
204
|
+
AsyncFunction("publishData") { topic: String, data: String, options: Map<String, Any?>?, promise: Promise ->
|
|
205
|
+
val core = core()
|
|
206
|
+
val bytes = runCatching {
|
|
207
|
+
if (options?.get("base64") == true) android.util.Base64.decode(data, android.util.Base64.DEFAULT)
|
|
208
|
+
else data.toByteArray(Charsets.UTF_8)
|
|
209
|
+
}.getOrNull()
|
|
210
|
+
if (core == null || bytes == null) {
|
|
211
|
+
promise.resolve(false)
|
|
212
|
+
return@AsyncFunction
|
|
213
|
+
}
|
|
214
|
+
val to = (options?.get("to") as? List<*>)?.filterIsInstance<String>() ?: emptyList()
|
|
215
|
+
core.publishData(topic, bytes, options?.get("reliable") as? Boolean ?: true, to) { promise.resolve(it) }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Breakout rooms (MEETINGS.md §5): the live call's media to another
|
|
219
|
+
// room of the same call, keeping the call service and the system
|
|
220
|
+
// call. `session` is the JSON of POST /breakouts/:room/join or
|
|
221
|
+
// /calls/:id/breakouts/return.
|
|
222
|
+
AsyncFunction("moveToRoom") { session: String, promise: Promise ->
|
|
223
|
+
val core = core()
|
|
224
|
+
if (core == null) {
|
|
225
|
+
promise.resolve(false)
|
|
226
|
+
return@AsyncFunction
|
|
227
|
+
}
|
|
228
|
+
core.moveToRoom(session) { promise.resolve(it) }
|
|
229
|
+
}
|
|
230
|
+
|
|
193
231
|
// What authorizes acting on the call itself (ringing people in).
|
|
194
232
|
AsyncFunction("callControl") {
|
|
195
233
|
val core = core() ?: return@AsyncFunction null
|
|
@@ -292,20 +330,28 @@ class PoolseCallsModule : Module() {
|
|
|
292
330
|
// Null on a notification posted before servers: the default one.
|
|
293
331
|
val serverId = intent.getStringExtra(MissedCallNotification.EXTRA_SERVER_ID)
|
|
294
332
|
?: context?.let { ServerRegistry.servers(it).get(null)?.id }
|
|
333
|
+
// A meeting notice's tap / Join (MeetingNotification).
|
|
334
|
+
val meetingId = intent.getStringExtra(MeetingNotification.EXTRA_SCHEDULED_MEETING_ID)
|
|
295
335
|
for (key in listOf(
|
|
296
336
|
MissedCallNotification.EXTRA_SERVER_ID,
|
|
297
337
|
MissedCallNotification.EXTRA_ACTION,
|
|
298
338
|
MissedCallNotification.EXTRA_CONVERSATION_ID,
|
|
299
339
|
MissedCallNotification.EXTRA_CALL_ID,
|
|
300
340
|
MissedCallNotification.EXTRA_MEDIA,
|
|
341
|
+
MeetingNotification.EXTRA_SCHEDULED_MEETING_ID,
|
|
301
342
|
)) intent.removeExtra(key)
|
|
302
|
-
if (
|
|
343
|
+
if (meetingId != null) {
|
|
344
|
+
context?.let { MeetingNotification.cancel(it, meetingId) }
|
|
345
|
+
} else if (callId != null) {
|
|
346
|
+
context?.let { MissedCallNotification.cancel(it, callId) }
|
|
347
|
+
}
|
|
303
348
|
return mapOf(
|
|
304
349
|
"type" to action,
|
|
305
350
|
"conversationId" to conversationId,
|
|
306
351
|
"callId" to callId,
|
|
307
352
|
"media" to media,
|
|
308
353
|
"serverId" to serverId,
|
|
354
|
+
"scheduledMeetingId" to meetingId,
|
|
309
355
|
)
|
|
310
356
|
}
|
|
311
357
|
|
|
@@ -11,6 +11,9 @@ import dev.poolse.callcore.CallSessionBundle
|
|
|
11
11
|
import dev.poolse.callcore.MediaPort
|
|
12
12
|
import dev.poolse.callcore.ServiceParticipants
|
|
13
13
|
import dev.poolse.callcore.android.AudioOutput
|
|
14
|
+
import dev.poolse.callcore.android.CallCore
|
|
15
|
+
import dev.poolse.callcore.android.CallDataSource
|
|
16
|
+
import dev.poolse.callcore.android.CaptureProcessingSource
|
|
14
17
|
import dev.poolse.callcore.android.CallVideoSource
|
|
15
18
|
import dev.poolse.callcore.android.CallVideoSurface
|
|
16
19
|
import dev.poolse.callcore.android.MediaEvents
|
|
@@ -28,6 +31,8 @@ import io.livekit.android.room.participant.Participant
|
|
|
28
31
|
import io.livekit.android.room.participant.ParticipantPermission
|
|
29
32
|
import io.livekit.android.room.participant.RemoteParticipant
|
|
30
33
|
import io.livekit.android.room.track.CameraPosition
|
|
34
|
+
import io.livekit.android.room.track.DataPublishReliability
|
|
35
|
+
import io.livekit.android.room.track.LocalAudioTrackOptions
|
|
31
36
|
import io.livekit.android.room.track.LocalVideoTrack
|
|
32
37
|
import io.livekit.android.room.track.RemoteTrackPublication
|
|
33
38
|
import io.livekit.android.room.track.Track
|
|
@@ -61,7 +66,7 @@ import org.json.JSONObject
|
|
|
61
66
|
class LiveKitMediaPort(
|
|
62
67
|
private val context: Context,
|
|
63
68
|
private val events: MediaEvents,
|
|
64
|
-
) : MediaPort, CallVideoSource, ScreenShareSource {
|
|
69
|
+
) : MediaPort, CallVideoSource, ScreenShareSource, CaptureProcessingSource, CallDataSource {
|
|
65
70
|
|
|
66
71
|
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
|
|
67
72
|
@Volatile private var room: Room? = null
|
|
@@ -112,6 +117,21 @@ class LiveKitMediaPort(
|
|
|
112
117
|
/** Remote camera publications this port switched off, by sid. */
|
|
113
118
|
private val pausedSids = mutableSetOf<String>()
|
|
114
119
|
|
|
120
|
+
/**
|
|
121
|
+
* WebRTC's noise suppression on the microphone (CL7). Echo
|
|
122
|
+
* cancellation, gain control and the high-pass filter stay on: a call
|
|
123
|
+
* without AEC echoes. Kept across calls.
|
|
124
|
+
*/
|
|
125
|
+
private var noiseSuppression = true
|
|
126
|
+
|
|
127
|
+
private fun captureOptions() = LocalAudioTrackOptions(
|
|
128
|
+
noiseSuppression = noiseSuppression,
|
|
129
|
+
echoCancellation = true,
|
|
130
|
+
autoGainControl = true,
|
|
131
|
+
highPassFilter = true,
|
|
132
|
+
typingNoiseDetection = true,
|
|
133
|
+
)
|
|
134
|
+
|
|
115
135
|
/** Live `<CallVideoView>` slots; rebound whenever what they show may have changed. */
|
|
116
136
|
private val surfaces = linkedSetOf<LiveKitVideoSurface>()
|
|
117
137
|
|
|
@@ -127,6 +147,7 @@ class LiveKitMediaPort(
|
|
|
127
147
|
loud = wantsVideo || bundle.kind == "room"
|
|
128
148
|
val newRoom = LiveKit.create(appContext = context.applicationContext)
|
|
129
149
|
configureAudio(newRoom, loud)
|
|
150
|
+
newRoom.audioTrackCaptureDefaults = captureOptions()
|
|
130
151
|
// A 1:1/small call: never let the SFU pause a subscribed camera for
|
|
131
152
|
// "not visible" — a track whose view mounts late would stay black.
|
|
132
153
|
// (Renderers are still registered with visibility via addRenderer.)
|
|
@@ -270,6 +291,62 @@ class LiveKitMediaPort(
|
|
|
270
291
|
}
|
|
271
292
|
}
|
|
272
293
|
|
|
294
|
+
// ── data channel (CL4, CL6) ─────────────────────────────────────────
|
|
295
|
+
|
|
296
|
+
override val localIdentity: String?
|
|
297
|
+
get() = room?.takeIf { it.state == Room.State.CONNECTED }?.localParticipant?.identity?.value
|
|
298
|
+
|
|
299
|
+
override fun publishData(
|
|
300
|
+
topic: String,
|
|
301
|
+
data: ByteArray,
|
|
302
|
+
reliable: Boolean,
|
|
303
|
+
to: List<String>,
|
|
304
|
+
done: (Boolean) -> Unit,
|
|
305
|
+
) {
|
|
306
|
+
val r = room
|
|
307
|
+
if (r == null || r.state != Room.State.CONNECTED || topic.isEmpty() || data.size > CallCore.DATA_MAX_BYTES) {
|
|
308
|
+
done(false)
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
scope.launch {
|
|
312
|
+
val sent = runCatching {
|
|
313
|
+
r.localParticipant.publishData(
|
|
314
|
+
data,
|
|
315
|
+
if (reliable) DataPublishReliability.RELIABLE else DataPublishReliability.LOSSY,
|
|
316
|
+
topic,
|
|
317
|
+
to.takeIf { it.isNotEmpty() }?.map { Participant.Identity(it) },
|
|
318
|
+
)
|
|
319
|
+
}.onFailure { Log.w(TAG, "data publish on $topic failed", it) }.isSuccess
|
|
320
|
+
done(sent)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ── capture processing (CL7) ────────────────────────────────────────
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Capture options are fixed when the microphone track is created, so a
|
|
328
|
+
* change mid-call unpublishes the live track and publishes a fresh one
|
|
329
|
+
* with the new options (a short gap in our audio, nothing else).
|
|
330
|
+
*/
|
|
331
|
+
override fun setNoiseSuppression(on: Boolean) {
|
|
332
|
+
if (on == noiseSuppression) return
|
|
333
|
+
noiseSuppression = on
|
|
334
|
+
val r = room ?: return
|
|
335
|
+
r.audioTrackCaptureDefaults = captureOptions()
|
|
336
|
+
if (r.state != Room.State.CONNECTED || !canPublish) return
|
|
337
|
+
scope.launch {
|
|
338
|
+
val track = r.localParticipant.getTrackPublication(Track.Source.MICROPHONE)?.track ?: return@launch
|
|
339
|
+
runCatching {
|
|
340
|
+
r.localParticipant.unpublishTrack(track, true)
|
|
341
|
+
r.localParticipant.setMicrophoneEnabled(!mutedWanted)
|
|
342
|
+
}.onFailure { Log.w(TAG, "noise suppression switch failed", it) }
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Background blur needs livekit-android-track-processors (ML Kit
|
|
347
|
+
// segmentation, several MB): not shipped yet. [backgroundBlurSupported]
|
|
348
|
+
// stays false.
|
|
349
|
+
|
|
273
350
|
// ── publish permission (recording consent) ──────────────────────────
|
|
274
351
|
|
|
275
352
|
/** Reads the local participant's permission; reports a change. Returns it. */
|
|
@@ -540,11 +617,15 @@ class LiveKitMediaPort(
|
|
|
540
617
|
// LiveKit gave up (or the server removed us). Our own leave()
|
|
541
618
|
// never gets here — the collector is cancelled first.
|
|
542
619
|
is RoomEvent.Disconnected -> {
|
|
620
|
+
// The same user joined from another device: LiveKit replaces
|
|
621
|
+
// the older participant (one identity per user). The reconnect
|
|
622
|
+
// that follows is refused, and the call ends as moved.
|
|
623
|
+
if (event.reason == DisconnectReason.DUPLICATE_IDENTITY) events.onMovedElsewhere()
|
|
543
624
|
if (event.reason != DisconnectReason.CLIENT_INITIATED) events.onLost()
|
|
544
625
|
}
|
|
545
626
|
// The transcript assistant or the recorder joining is nobody answering.
|
|
546
627
|
is RoomEvent.ParticipantConnected -> {
|
|
547
|
-
if (!isService(event.participant)) events.onRemoteJoined()
|
|
628
|
+
if (!isService(event.participant) && !isAgent(event.participant)) events.onRemoteJoined()
|
|
548
629
|
emit(room)
|
|
549
630
|
refreshVideo()
|
|
550
631
|
}
|
|
@@ -578,6 +659,12 @@ class LiveKitMediaPort(
|
|
|
578
659
|
qualityChanged(room)
|
|
579
660
|
emit(room)
|
|
580
661
|
}
|
|
662
|
+
is RoomEvent.DataReceived -> {
|
|
663
|
+
val topic = event.topic
|
|
664
|
+
if (!topic.isNullOrEmpty() && event.data.size <= CallCore.DATA_MAX_BYTES) {
|
|
665
|
+
events.onData(topic, event.data, event.participant?.identity?.value, event.participant?.name)
|
|
666
|
+
}
|
|
667
|
+
}
|
|
581
668
|
is RoomEvent.ActiveSpeakersChanged,
|
|
582
669
|
is RoomEvent.ParticipantMetadataChanged,
|
|
583
670
|
is RoomEvent.ParticipantAttributesChanged -> emit(room)
|
|
@@ -591,9 +678,13 @@ class LiveKitMediaPort(
|
|
|
591
678
|
* The remote PEOPLE: poolse's transcript assistant and LiveKit Egress's
|
|
592
679
|
* recorder are in the room but are not someone in the call — never in
|
|
593
680
|
* the roster, the count that ends a call left alone, or a video tile.
|
|
594
|
-
* Phone (SIP) participants are people.
|
|
681
|
+
* Agents are listed separately ([agents]). Phone (SIP) participants are people.
|
|
595
682
|
*/
|
|
596
|
-
private fun people(r: Room): List<RemoteParticipant> =
|
|
683
|
+
private fun people(r: Room): List<RemoteParticipant> =
|
|
684
|
+
r.remoteParticipants.values.filterNot { isService(it) || isAgent(it) }
|
|
685
|
+
|
|
686
|
+
private fun isAgent(p: Participant): Boolean =
|
|
687
|
+
p.metadata?.let { runCatching { JSONObject(it).optBoolean("agent", false) }.getOrNull() } == true
|
|
597
688
|
|
|
598
689
|
private fun isService(p: Participant): Boolean {
|
|
599
690
|
val kind = when (p.kind) {
|
|
@@ -605,10 +696,34 @@ class LiveKitMediaPort(
|
|
|
605
696
|
return ServiceParticipants.isService(p.identity?.value ?: "", kind)
|
|
606
697
|
}
|
|
607
698
|
|
|
699
|
+
/**
|
|
700
|
+
* Agents invited into the call (AGENTS_IN_CALLS.md §1): kind AGENT like
|
|
701
|
+
* poolse's room assistant, but marked `agent: true` in their token
|
|
702
|
+
* metadata — listed (with the badge), unlike the assistant and recorder.
|
|
703
|
+
*/
|
|
704
|
+
private fun agents(r: Room): List<Pair<RemoteParticipant, JSONObject>> =
|
|
705
|
+
r.remoteParticipants.values.mapNotNull { p ->
|
|
706
|
+
val m = p.metadata?.let { runCatching { JSONObject(it) }.getOrNull() }
|
|
707
|
+
if (m != null && m.optBoolean("agent", false)) p to m else null
|
|
708
|
+
}
|
|
709
|
+
|
|
608
710
|
/** The REMOTE roster — the local participant is never included. */
|
|
609
711
|
private fun emit(room: Room) {
|
|
712
|
+
val agentRows = agents(room).map { (p, m) ->
|
|
713
|
+
val identity = p.identity?.value ?: ""
|
|
714
|
+
MediaParticipant(
|
|
715
|
+
identity = identity,
|
|
716
|
+
speaking = p.isSpeaking,
|
|
717
|
+
muted = !p.isMicrophoneEnabled(),
|
|
718
|
+
connectionQuality = wire(p.connectionQuality),
|
|
719
|
+
externalId = externalIdOf(p) ?: identity,
|
|
720
|
+
isAgent = true,
|
|
721
|
+
agentLabel = m.optString("label", "").ifEmpty { null } ?: p.name?.ifEmpty { null },
|
|
722
|
+
agentMode = m.optString("mode", "").ifEmpty { null },
|
|
723
|
+
)
|
|
724
|
+
}
|
|
610
725
|
events.onParticipants(
|
|
611
|
-
people(room).map {
|
|
726
|
+
agentRows.let { agentList -> people(room).map {
|
|
612
727
|
val identity = it.identity?.value ?: ""
|
|
613
728
|
MediaParticipant(
|
|
614
729
|
identity = identity,
|
|
@@ -621,7 +736,7 @@ class LiveKitMediaPort(
|
|
|
621
736
|
connectionQuality = wire(it.connectionQuality),
|
|
622
737
|
externalId = externalIdOf(it) ?: identity,
|
|
623
738
|
)
|
|
624
|
-
},
|
|
739
|
+
} + agentList },
|
|
625
740
|
)
|
|
626
741
|
}
|
|
627
742
|
|
|
@@ -39,6 +39,21 @@ class CallHttpClientTest {
|
|
|
39
39
|
assertEquals(current.copy(livekitUrl = "wss://sfu2", livekitToken = "lk-2"), r.bundle)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
@Test fun `a breakout join's bundle names its room, the main room's never inherits it`() {
|
|
43
|
+
val room = CallHttpClient.parseBundle(
|
|
44
|
+
"""{"cv":1,"created":false,"control_token":"ctl","livekit":{"url":"wss://sfu","token":"lk-room"},
|
|
45
|
+
"breakout":{"room_id":"0b7e.2","name":"Design"},"call":{"id":"c1","conversation_id":"conv"}}""",
|
|
46
|
+
)
|
|
47
|
+
assertEquals("0b7e.2", room.breakoutRoomId)
|
|
48
|
+
assertEquals("Design", room.breakoutName)
|
|
49
|
+
val main = CallHttpClient.parseBundle(
|
|
50
|
+
"""{"control_token":"ctl","livekit":{"url":"wss://sfu","token":"lk"},"call":{"id":"c1","conversation_id":"conv"}}""",
|
|
51
|
+
room,
|
|
52
|
+
)
|
|
53
|
+
assertEquals(null, main.breakoutRoomId)
|
|
54
|
+
assertEquals(null, CallHttpClient.parseBundle("""{"livekit":{"token":"lk2"}}""", room).breakoutRoomId)
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
@Test fun `unparseable 2xx is a failure, not a retry`() {
|
|
43
58
|
assertTrue(CallHttpClient.classify(200, "<html>", null) is HttpResult.Failed)
|
|
44
59
|
assertTrue(CallHttpClient.classify(200, """{"livekit":{"token":"x"}}""", null) is HttpResult.Failed)
|
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,6 +118,10 @@ 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);
|
|
@@ -187,6 +194,11 @@ function onNotificationReply(cb) {
|
|
|
187
194
|
if (result.action === "reply") cb(result);
|
|
188
195
|
});
|
|
189
196
|
}
|
|
197
|
+
function onEscalationAction(cb) {
|
|
198
|
+
return onNotificationAction((result) => {
|
|
199
|
+
if (result.action === "escalation") cb(result);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
190
202
|
function takeNotificationActions() {
|
|
191
203
|
return native?.takeNotificationActions?.() ?? [];
|
|
192
204
|
}
|
|
@@ -212,6 +224,91 @@ function onPictureInPicture(cb) {
|
|
|
212
224
|
const sub = native.addListener("onPictureInPicture", (payload) => cb(payload.active));
|
|
213
225
|
return () => sub.remove();
|
|
214
226
|
}
|
|
227
|
+
var CALL_DATA_MAX_BYTES = 14e3;
|
|
228
|
+
function utf8Length(s) {
|
|
229
|
+
let n = 0;
|
|
230
|
+
for (let i = 0; i < s.length; i++) {
|
|
231
|
+
const c = s.charCodeAt(i);
|
|
232
|
+
if (c < 128) n += 1;
|
|
233
|
+
else if (c < 2048) n += 2;
|
|
234
|
+
else if (c >= 55296 && c <= 56319 && i + 1 < s.length) {
|
|
235
|
+
n += 4;
|
|
236
|
+
i++;
|
|
237
|
+
} else n += 3;
|
|
238
|
+
}
|
|
239
|
+
return n;
|
|
240
|
+
}
|
|
241
|
+
async function publishData(topic, data, options = {}) {
|
|
242
|
+
if (!native?.publishData || !topic) return false;
|
|
243
|
+
const size = options.base64 ? Math.floor(data.length * 3 / 4) : utf8Length(data);
|
|
244
|
+
if (size > CALL_DATA_MAX_BYTES) return false;
|
|
245
|
+
try {
|
|
246
|
+
return await native.publishData(topic, data, {
|
|
247
|
+
reliable: options.reliable ?? true,
|
|
248
|
+
base64: options.base64 ?? false,
|
|
249
|
+
...options.to ? { to: options.to } : {}
|
|
250
|
+
});
|
|
251
|
+
} catch {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function onCallData(cb) {
|
|
256
|
+
if (!native?.publishData) return () => void 0;
|
|
257
|
+
const sub = native.addListener("onCallData", cb);
|
|
258
|
+
return () => sub.remove();
|
|
259
|
+
}
|
|
260
|
+
var dataListeners = /* @__PURE__ */ new Map();
|
|
261
|
+
var dataSub = null;
|
|
262
|
+
var callData = {
|
|
263
|
+
getSelfId() {
|
|
264
|
+
return getCallState()?.selfIdentity ?? null;
|
|
265
|
+
},
|
|
266
|
+
sendData(topic, message, opts = {}) {
|
|
267
|
+
let text;
|
|
268
|
+
try {
|
|
269
|
+
text = JSON.stringify(message);
|
|
270
|
+
} catch {
|
|
271
|
+
return Promise.resolve(false);
|
|
272
|
+
}
|
|
273
|
+
return publishData(topic, text, opts);
|
|
274
|
+
},
|
|
275
|
+
onData(topic, fn) {
|
|
276
|
+
let set = dataListeners.get(topic);
|
|
277
|
+
if (!set) {
|
|
278
|
+
set = /* @__PURE__ */ new Set();
|
|
279
|
+
dataListeners.set(topic, set);
|
|
280
|
+
}
|
|
281
|
+
set.add(fn);
|
|
282
|
+
dataSub ??= onCallData((m) => {
|
|
283
|
+
const listeners = dataListeners.get(m.topic);
|
|
284
|
+
if (!listeners?.size || m.text == null) return;
|
|
285
|
+
let parsed;
|
|
286
|
+
try {
|
|
287
|
+
parsed = JSON.parse(m.text);
|
|
288
|
+
} catch {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const from = { userId: m.fromIdentity, name: m.fromName };
|
|
292
|
+
for (const l of [...listeners]) l(parsed, from);
|
|
293
|
+
});
|
|
294
|
+
return () => {
|
|
295
|
+
set.delete(fn);
|
|
296
|
+
if (set.size === 0) dataListeners.delete(topic);
|
|
297
|
+
if (dataListeners.size === 0 && dataSub) {
|
|
298
|
+
dataSub();
|
|
299
|
+
dataSub = null;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
async function moveToRoom(session) {
|
|
305
|
+
if (!native?.moveToRoom) return false;
|
|
306
|
+
try {
|
|
307
|
+
return await native.moveToRoom(typeof session === "string" ? session : JSON.stringify(session));
|
|
308
|
+
} catch {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
215
312
|
var nativeVideo;
|
|
216
313
|
function nativeVideoView() {
|
|
217
314
|
if (nativeVideo !== void 0) return nativeVideo;
|
|
@@ -242,11 +339,14 @@ function CallVideoView(props) {
|
|
|
242
339
|
return react.createElement(Native, props);
|
|
243
340
|
}
|
|
244
341
|
|
|
342
|
+
exports.CALL_DATA_MAX_BYTES = CALL_DATA_MAX_BYTES;
|
|
245
343
|
exports.CallVideoView = CallVideoView;
|
|
246
344
|
exports.DEFAULT_SERVER_ID = DEFAULT_SERVER_ID;
|
|
247
345
|
exports.addServer = addServer;
|
|
248
346
|
exports.answer = answer;
|
|
249
347
|
exports.answerWaiting = answerWaiting;
|
|
348
|
+
exports.backgroundBlurSupported = backgroundBlurSupported;
|
|
349
|
+
exports.callData = callData;
|
|
250
350
|
exports.canUseFullScreenIntent = canUseFullScreenIntent;
|
|
251
351
|
exports.configure = configure;
|
|
252
352
|
exports.conversationOfNotification = conversationOfNotification;
|
|
@@ -258,11 +358,16 @@ exports.hangUp = hangUp;
|
|
|
258
358
|
exports.isInPictureInPicture = isInPictureInPicture;
|
|
259
359
|
exports.join = join;
|
|
260
360
|
exports.listServers = listServers;
|
|
361
|
+
exports.moveCallHere = moveCallHere;
|
|
362
|
+
exports.moveToRoom = moveToRoom;
|
|
261
363
|
exports.nativeCallsAvailable = nativeCallsAvailable;
|
|
364
|
+
exports.noiseSuppressionSupported = noiseSuppressionSupported;
|
|
262
365
|
exports.onCallAction = onCallAction;
|
|
366
|
+
exports.onCallData = onCallData;
|
|
263
367
|
exports.onCallFinished = onCallFinished;
|
|
264
368
|
exports.onCallState = onCallState;
|
|
265
369
|
exports.onCanPublishChange = onCanPublishChange;
|
|
370
|
+
exports.onEscalationAction = onEscalationAction;
|
|
266
371
|
exports.onNotificationAction = onNotificationAction;
|
|
267
372
|
exports.onNotificationReply = onNotificationReply;
|
|
268
373
|
exports.onPictureInPicture = onPictureInPicture;
|
|
@@ -271,6 +376,7 @@ exports.onVoipToken = onVoipToken;
|
|
|
271
376
|
exports.openFullScreenIntentSettings = openFullScreenIntentSettings;
|
|
272
377
|
exports.pictureInPictureSupported = pictureInPictureSupported;
|
|
273
378
|
exports.place = place;
|
|
379
|
+
exports.publishData = publishData;
|
|
274
380
|
exports.removeServer = removeServer;
|
|
275
381
|
exports.republish = republish;
|
|
276
382
|
exports.ringIntoCall = ringIntoCall;
|
|
@@ -278,8 +384,10 @@ exports.screenShareSupported = screenShareSupported;
|
|
|
278
384
|
exports.serverOfNotification = serverOfNotification;
|
|
279
385
|
exports.setActiveConversation = setActiveConversation;
|
|
280
386
|
exports.setAudioOutput = setAudioOutput;
|
|
387
|
+
exports.setBackgroundBlur = setBackgroundBlur;
|
|
281
388
|
exports.setCamera = setCamera;
|
|
282
389
|
exports.setMuted = setMuted;
|
|
390
|
+
exports.setNoiseSuppression = setNoiseSuppression;
|
|
283
391
|
exports.setPictureInPictureEnabled = setPictureInPictureEnabled;
|
|
284
392
|
exports.setShowOnLockscreen = setShowOnLockscreen;
|
|
285
393
|
exports.setSpeaker = setSpeaker;
|