@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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
Formerly `@poolse/react-native-calls` (0.x).
|
|
4
4
|
|
|
5
|
+
## [3.10.1] - 2026-11-23
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Data channel (CL4, CL6): `publishData(topic, data, options)` over
|
|
10
|
+
LiveKit data packets on both cores (iOS `publish(data:)`, Android
|
|
11
|
+
`publishData`), options `reliable`, `base64` and `to`, capped at
|
|
12
|
+
`CALL_DATA_MAX_BYTES` (14 000, as the web `CallRoom`); `onCallData`
|
|
13
|
+
with `topic`, `payload` (base64), `text`, `fromIdentity`, `fromName`;
|
|
14
|
+
`callData`, a `CallDataChannel` for @poolse/sdk's `CallReactions` /
|
|
15
|
+
`ScreenAnnotations` and @poolse/react's `useCallReactions` /
|
|
16
|
+
`useScreenAnnotations`, so reactions and the pointer and drawing on a
|
|
17
|
+
shared screen interoperate with web and desktop. Snapshot
|
|
18
|
+
`selfIdentity`.
|
|
19
|
+
- Breakout rooms (CL5): `moveToRoom(session)` moves the live call's media
|
|
20
|
+
to another room of the same call (the bundle of
|
|
21
|
+
`POST /breakouts/:room/join` or `POST /calls/:id/breakouts/return`),
|
|
22
|
+
keeping the CallKit / Telecom call, the phase and mute and camera; it
|
|
23
|
+
falls back to the previous room if the new one can't be joined.
|
|
24
|
+
Snapshot `breakout` (`roomId`, `name`; null in the main room). In a
|
|
25
|
+
breakout room the alone check is off and a reconnect rejoins that room
|
|
26
|
+
with the fresh control token. The state machine and its vectors are
|
|
27
|
+
unchanged; runtime tests cover the move on both cores.
|
|
28
|
+
|
|
29
|
+
## [3.10.0] - 2026-11-23
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- Agents in calls (AGENTS_IN_CALLS.md): `participants` lists agents in the
|
|
34
|
+
call with `isAgent`, `agentLabel` and `agentMode` (token metadata `agent:
|
|
35
|
+
true`); they never keep a call alive (the alone check skips them) and an
|
|
36
|
+
agent joining is not someone answering.
|
|
37
|
+
- Escalations from the lock screen: Android posts the `agent_escalation`
|
|
38
|
+
data push natively with Approve / Decline / Answer (RemoteInput); iOS
|
|
39
|
+
registers the `poolse_agent_escalation` category (Approve, Decline and a
|
|
40
|
+
`UNTextInputNotificationAction` Answer). Both reply natively — `POST
|
|
41
|
+
/v1/agent-escalations/:id/reply` with the push's `reply_token`, no
|
|
42
|
+
session, no JS — and report through `onNotificationAction` with `action:
|
|
43
|
+
"escalation"` (`escalationId`, `decision`, `ok`, `error`); new
|
|
44
|
+
`onEscalationAction`. `messageReplyRequiresUnlock` covers these actions
|
|
45
|
+
too.
|
|
46
|
+
|
|
47
|
+
- Meeting rings (CA4): a ring push with `ring_type: "meeting"` and
|
|
48
|
+
`meeting_title` shows "Weekly sync is starting" on CallKit and on the
|
|
49
|
+
Android ring notification and screen, with Join / Not now buttons on
|
|
50
|
+
Android. `RingContext` gains `ringType`, `meetingTitle` and `meetingId`
|
|
51
|
+
(defaulted). Snapshots and `waiting` carry `ringType` and `meetingTitle`.
|
|
52
|
+
Custom Android ring activities get `EXTRA_RING_TYPE`, `EXTRA_MEETING_TITLE`
|
|
53
|
+
and `EXTRA_TITLE`.
|
|
54
|
+
- Meeting notices (MEETINGS.md §11.3). Android posts `type: "meeting"` data
|
|
55
|
+
pushes (`starting` with Join, `brief`) on a new "Meetings" channel. iOS
|
|
56
|
+
registers the `poolse_meeting` category with a Join action. A tap and Join
|
|
57
|
+
reach JS as a `CallAction` of type `open` / `join_meeting`, with the new
|
|
58
|
+
`scheduledMeetingId`. `takeCallAction` and `onCallAction` now work on iOS
|
|
59
|
+
too, for meeting notices.
|
|
60
|
+
- Noise suppression and background blur (CL7): `setNoiseSuppression`,
|
|
61
|
+
`noiseSuppressionSupported`, `setBackgroundBlur` and
|
|
62
|
+
`backgroundBlurSupported`. Snapshots carry `noiseSuppression` and
|
|
63
|
+
`backgroundBlur`. Blur works on iOS 15+ (LiveKit's
|
|
64
|
+
BackgroundBlurVideoProcessor). It is not available on Android yet.
|
|
65
|
+
- Move a call to this device (CL11): `moveCallHere(callId, options)`. The
|
|
66
|
+
device that lost the call gets `movedElsewhere: true` and ends with the new
|
|
67
|
+
reason `'moved'`, detected from LiveKit's duplicate-identity disconnect.
|
|
68
|
+
|
|
5
69
|
## 3.9.0 — 2026-11-22
|
|
6
70
|
|
|
7
71
|
- Recording and transcripts (server docs/RECORDING.md). poolse's transcript
|
package/README.md
CHANGED
|
@@ -151,6 +151,94 @@ server), the core:
|
|
|
151
151
|
const off = calls.onCanPublishChange((allowed) => setListenOnly(!allowed));
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
## Meetings: scheduled rings, background and noise, moving a call
|
|
155
|
+
|
|
156
|
+
**A meeting starting rings.** When a scheduled meeting is set to ring
|
|
157
|
+
everyone, the server sends the usual ring push with `ring_type: "meeting"`
|
|
158
|
+
and `meeting_title` (also `meeting_id`, `starts_at`). CallKit and the
|
|
159
|
+
Android ring screen then read "Weekly sync is starting" (with the
|
|
160
|
+
workspace, "Weekly sync is starting · Acme", when several are signed in),
|
|
161
|
+
and the Android buttons read Join / Not now. Answering joins the meeting's
|
|
162
|
+
room like any call. The snapshot says so too: `ringType: 'meeting'` and
|
|
163
|
+
`meetingTitle`, so the call screen can name the meeting.
|
|
164
|
+
|
|
165
|
+
**Meeting notices.** The server's "is starting" notice (for meetings set to
|
|
166
|
+
notify rather than ring) and the brief a few minutes before
|
|
167
|
+
(MEETINGS.md §11.3) are shown with the app closed. On Android the core posts
|
|
168
|
+
the `type: "meeting"` data push itself, on a "Meetings" channel, with the
|
|
169
|
+
workspace as subtext when several are signed in. "Starting" has a Join
|
|
170
|
+
button. A brief is replaced by that meeting's "starting" notice, and a
|
|
171
|
+
redelivered push is not posted twice. On iOS the server sends an alert push
|
|
172
|
+
with category `poolse_meeting`, and the core registers that category with a
|
|
173
|
+
Join action (`poolse_meeting_join`). On both platforms the tap and Join reach
|
|
174
|
+
the app as a `CallAction`: `{ type: 'open' | 'join_meeting', conversationId,
|
|
175
|
+
callId, media, serverId, scheduledMeetingId }`, through `takeCallAction()`
|
|
176
|
+
on a cold start and `onCallAction` while running. On Join, join the room
|
|
177
|
+
(`rooms.start(conversationId, media)` joins what is live). The core never
|
|
178
|
+
joins by itself.
|
|
179
|
+
|
|
180
|
+
**Noise suppression and background blur.**
|
|
181
|
+
`setNoiseSuppression(on)` / `noiseSuppressionSupported()`: on by default.
|
|
182
|
+
Android switches WebRTC's noise suppression on the microphone (echo
|
|
183
|
+
cancellation stays on). iOS uses Apple's voice processing, which does echo
|
|
184
|
+
cancellation and noise suppression together, so off bypasses both: offer
|
|
185
|
+
"off" only for headphones. `setBackgroundBlur(on)` /
|
|
186
|
+
`backgroundBlurSupported()`: iOS 15+ blurs behind you with Vision person
|
|
187
|
+
segmentation, kept across camera flips. Android has no blur yet: it needs an
|
|
188
|
+
ML Kit segmentation model, so it is planned for later, and
|
|
189
|
+
`backgroundBlurSupported()` is `false` there. Background pictures are not
|
|
190
|
+
available on native yet. The snapshot carries `noiseSuppression` and
|
|
191
|
+
`backgroundBlur`.
|
|
192
|
+
|
|
193
|
+
**Keep the call while you work.** Picture-in-picture for video calls is
|
|
194
|
+
`setPictureInPictureEnabled(true)` while a video call shows someone, and a
|
|
195
|
+
`<CallVideoView pictureInPicture>` on the main picture (iOS 15+); on Android
|
|
196
|
+
the whole activity floats (the plugin's `pictureInPicture` option), so draw
|
|
197
|
+
a compact layout while `isInPictureInPicture()`.
|
|
198
|
+
|
|
199
|
+
**Move a call to this device.**
|
|
200
|
+
`moveCallHere(callId, { conversationId, sessionToken, serverId? })` joins a
|
|
201
|
+
call you are on elsewhere from this device. The server keeps one device per
|
|
202
|
+
person in a call, so the other device is let go. Its snapshot gets
|
|
203
|
+
`movedElsewhere: true` and ends with `reason: 'moved'`: show "Moved to your
|
|
204
|
+
other device", not "Call ended". Offer it where `liveCalls` shows you already
|
|
205
|
+
in the call.
|
|
206
|
+
|
|
207
|
+
**Reactions, pointer and drawing (data channel).** `callData` is the call's
|
|
208
|
+
LiveKit data channel in the shape @poolse/sdk's `CallDataChannel` takes, so
|
|
209
|
+
the SDK's `CallReactions` and `ScreenAnnotations`, and @poolse/react's
|
|
210
|
+
`useCallReactions` / `useScreenAnnotations`, run on phones with the same
|
|
211
|
+
topics and messages as the web and desktop (`poolse.reaction`,
|
|
212
|
+
`poolse.annotate`):
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { callData } from '@poolse/native';
|
|
216
|
+
const reactions = useCallReactions(callData);
|
|
217
|
+
const { state, annotations } = useScreenAnnotations(callData, sharerUserId);
|
|
218
|
+
<CallVideoView participantId={sharerUserId} source="screen" fit="contain" />
|
|
219
|
+
<AnnotationOverlay state={state} annotations={annotations} drawing={penOn} />
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Lower level: `publishData(topic, data, { reliable?, base64?, to? })` sends
|
|
223
|
+
text (or base64 bytes) and resolves `false` with no call connected or over
|
|
224
|
+
`CALL_DATA_MAX_BYTES` (14 000, as on the web); `onCallData(cb)` gets
|
|
225
|
+
`{ topic, payload (base64), text, fromIdentity, fromName }` for every message
|
|
226
|
+
others send. `snapshot.selfIdentity` is your identity in the room.
|
|
227
|
+
|
|
228
|
+
**Breakout rooms.** A breakout room is another LiveKit room of the same call
|
|
229
|
+
(MEETINGS.md §5). `moveToRoom(session)` takes the bundle of `POST
|
|
230
|
+
/v1/breakouts/:room/join` (or `POST /v1/calls/:id/breakouts/return` to come
|
|
231
|
+
back, the SDK's `meetingsLive.breakouts.join` / `returnToMain`) and moves the
|
|
232
|
+
call's media there without hanging up: CallKit and Android's call service
|
|
233
|
+
keep the call, the phase stays `active`, mute and camera stay as they were,
|
|
234
|
+
and `snapshot.breakout` (`{ roomId, name }`, null in the main room) says
|
|
235
|
+
where you are. A screen share stops on the move. If the room can't be
|
|
236
|
+
joined, the media goes back to where it was. Being alone in a breakout room
|
|
237
|
+
never ends the call, and a network drop there rejoins the same room.
|
|
238
|
+
@poolse/react-native's `useNativeBreakouts(conversationId, callId, {
|
|
239
|
+
moveToRoom })` follows the split by itself: into your room as it opens, back
|
|
240
|
+
as it closes.
|
|
241
|
+
|
|
154
242
|
## Ringtone
|
|
155
243
|
|
|
156
244
|
```json
|
|
@@ -230,15 +318,18 @@ The ring notification's full-screen intent and heads-up tap start it with
|
|
|
230
318
|
`FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP` and these extras (constants
|
|
231
319
|
on `dev.poolse.callcore.android.PoolseIncomingCall`):
|
|
232
320
|
|
|
233
|
-
| Extra | Key | Type
|
|
234
|
-
| ------------------------- | -------------------------- |
|
|
235
|
-
| `EXTRA_CALL_ID` | `poolse_call_id` | String
|
|
236
|
-
| `EXTRA_CONVERSATION_ID` | `poolse_conversation_id` | String
|
|
237
|
-
| `EXTRA_CONVERSATION_NAME` | `poolse_conversation_name` | String, may be null
|
|
238
|
-
| `EXTRA_CALLER_NAME` | `poolse_caller_name` | String, may be null
|
|
239
|
-
| `EXTRA_CALLER_AVATAR_URL` | `poolse_caller_avatar_url` | String, may be null
|
|
240
|
-
| `EXTRA_MEDIA` | `poolse_media` | `"audio"` or `"video"`
|
|
241
|
-
| `EXTRA_RING_DEADLINE` | `poolse_ring_deadline` | Long, epoch ms
|
|
321
|
+
| Extra | Key | Type |
|
|
322
|
+
| ------------------------- | -------------------------- | --------------------------------------------------------------------- |
|
|
323
|
+
| `EXTRA_CALL_ID` | `poolse_call_id` | String |
|
|
324
|
+
| `EXTRA_CONVERSATION_ID` | `poolse_conversation_id` | String |
|
|
325
|
+
| `EXTRA_CONVERSATION_NAME` | `poolse_conversation_name` | String, may be null |
|
|
326
|
+
| `EXTRA_CALLER_NAME` | `poolse_caller_name` | String, may be null |
|
|
327
|
+
| `EXTRA_CALLER_AVATAR_URL` | `poolse_caller_avatar_url` | String, may be null |
|
|
328
|
+
| `EXTRA_MEDIA` | `poolse_media` | `"audio"` or `"video"` |
|
|
329
|
+
| `EXTRA_RING_DEADLINE` | `poolse_ring_deadline` | Long, epoch ms |
|
|
330
|
+
| `EXTRA_RING_TYPE` | `poolse_ring_type` | `"call"` or `"meeting"` |
|
|
331
|
+
| `EXTRA_MEETING_TITLE` | `poolse_meeting_title` | String or null |
|
|
332
|
+
| `EXTRA_TITLE` | `poolse_title` | The headline: "Weekly sync is starting", or the conversation / caller |
|
|
242
333
|
|
|
243
334
|
plus an opaque `poolse_ring` bundle that the functions below read; pass them
|
|
244
335
|
the Intent you were started with (and the new one in `onNewIntent`):
|
|
@@ -322,6 +413,35 @@ expo-notifications also hands these responses to its own JS listeners: in
|
|
|
322
413
|
`addNotificationResponseReceivedListener`, ignore an `actionIdentifier` of
|
|
323
414
|
`reply` or `mark_read` (only the default tap should open the chat).
|
|
324
415
|
|
|
416
|
+
## Agents in calls and escalations
|
|
417
|
+
|
|
418
|
+
`participants` lists agents in the call (server docs/AGENTS_IN_CALLS.md)
|
|
419
|
+
with `isAgent: true`, `agentLabel` ("Scout", "Jasir's agent") and
|
|
420
|
+
`agentMode`; show them with the Agent badge, never as a person. They never
|
|
421
|
+
keep a call alive.
|
|
422
|
+
|
|
423
|
+
Your agent attending a meeting for you asks by push (`type:
|
|
424
|
+
"agent_escalation"`). The core shows it with **Approve**, **Decline** and
|
|
425
|
+
**Answer** (a text field) and replies natively — from the lock screen, app
|
|
426
|
+
closed, no session — with the push's `reply_token` to `POST
|
|
427
|
+
/v1/agent-escalations/:id/reply` on the push's server.
|
|
428
|
+
|
|
429
|
+
- **Android**: the data push is posted on the "Questions from your agent"
|
|
430
|
+
channel; it times out at `expires_at`. After a reply it reads "Approved —
|
|
431
|
+
your agent will say so." and goes; a failure says why and keeps the
|
|
432
|
+
actions while trying again can work.
|
|
433
|
+
- **iOS**: an alert push with category `poolse_agent_escalation`
|
|
434
|
+
(time-sensitive); the core registers the category (actions
|
|
435
|
+
`poolse_escalation_approve`, `poolse_escalation_decline`,
|
|
436
|
+
`poolse_escalation_answer`) beside `poolse_message`. A failure posts
|
|
437
|
+
"Couldn't send your answer" with the same actions. In
|
|
438
|
+
`addNotificationResponseReceivedListener`, ignore those action ids.
|
|
439
|
+
|
|
440
|
+
Results arrive as `onNotificationAction` (or `onEscalationAction`) with
|
|
441
|
+
`action: 'escalation'`, `escalationId`, `decision`, `ok`, `error`. The
|
|
442
|
+
token works once: a reply is retried only when no answer came back.
|
|
443
|
+
`messageReplyRequiresUnlock` makes these actions ask for the unlock too.
|
|
444
|
+
|
|
325
445
|
## Signed in to several workspaces
|
|
326
446
|
|
|
327
447
|
The core can serve several API servers at once — one per workspace the user
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
android:name="dev.poolse.callcore.android.MessageActionReceiver"
|
|
31
31
|
android:exported="false" />
|
|
32
32
|
|
|
33
|
+
<receiver
|
|
34
|
+
android:name="dev.poolse.callcore.android.EscalationActionReceiver"
|
|
35
|
+
android:exported="false" />
|
|
36
|
+
|
|
33
37
|
<service
|
|
34
38
|
android:name="dev.poolse.callcore.android.CallForegroundService"
|
|
35
39
|
android:exported="false"
|
|
@@ -70,6 +70,12 @@ class CallCoreRuntime(
|
|
|
70
70
|
/** The call whose media has had someone else in it (for [onRemoteCount]). */
|
|
71
71
|
private var remoteSeenFor: String? = null
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* While [moveToRoom] connects: the room's bundle it came from, to go
|
|
75
|
+
* back to if the new room cannot be joined.
|
|
76
|
+
*/
|
|
77
|
+
private var movingFrom: CallSessionBundle? = null
|
|
78
|
+
|
|
73
79
|
private val resolved = object : LinkedHashMap<String, Unit>(RESOLVED_LRU, 0.75f, true) {
|
|
74
80
|
override fun removeEldestEntry(eldest: MutableMap.MutableEntry<String, Unit>?) = size > RESOLVED_LRU
|
|
75
81
|
}
|
|
@@ -159,6 +165,15 @@ class CallCoreRuntime(
|
|
|
159
165
|
/** The call waiting beside the current one, with its caller's names. Runtime thread only. */
|
|
160
166
|
val waitingRing: RingContext? get() = if (state.waiting == null) null else waitingRingCtx
|
|
161
167
|
|
|
168
|
+
/** The session bundle in use, null before the server accepted. Any thread. */
|
|
169
|
+
val currentBundle: CallSessionBundle? get() = bundle
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The breakout room the media is in (MEETINGS.md §5) as (room id,
|
|
173
|
+
* name); null in the call's main room. Any thread.
|
|
174
|
+
*/
|
|
175
|
+
val breakout: Pair<String, String?>? get() = bundle?.let { b -> b.breakoutRoomId?.let { it to b.breakoutName } }
|
|
176
|
+
|
|
162
177
|
/** True if [callId] was already resolved here — its ring must never surface again. */
|
|
163
178
|
fun isResolved(callId: String): Boolean = synchronized(resolved) { resolved.containsKey(callId) }
|
|
164
179
|
|
|
@@ -235,8 +250,53 @@ class CallCoreRuntime(
|
|
|
235
250
|
/** Caller-side: the bridge resolved every ring from `ring_states`. */
|
|
236
251
|
fun allRingsResolved(outcome: String) = post { dispatch(Event.AllRingsResolved(outcome)) }
|
|
237
252
|
|
|
238
|
-
fun onMediaConnected() = post {
|
|
239
|
-
|
|
253
|
+
fun onMediaConnected() = post {
|
|
254
|
+
movingFrom = null
|
|
255
|
+
dispatch(Event.MediaConnected)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
fun onMediaFailed() = post {
|
|
259
|
+
// The room [moveToRoom] went to would not have us: back to the one it
|
|
260
|
+
// came from. The call itself never noticed.
|
|
261
|
+
val back = movingFrom
|
|
262
|
+
if (back != null && (state.phase == Phase.ACTIVE || state.phase == Phase.RECONNECTING)) {
|
|
263
|
+
movingFrom = null
|
|
264
|
+
bundle = back
|
|
265
|
+
media.join(back)
|
|
266
|
+
sink.emit(state)
|
|
267
|
+
return@post
|
|
268
|
+
}
|
|
269
|
+
dispatch(Event.MediaFailed)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Breakout rooms (MEETINGS.md §5): carry the call on in another
|
|
274
|
+
* LiveKit room of the SAME call — the bundle of `POST
|
|
275
|
+
* /breakouts/:room/join`, or of `POST /calls/:id/breakouts/return` to
|
|
276
|
+
* come back. The machine never sees it: the phase, the system call
|
|
277
|
+
* (Telecom's foreground service / CallKit) and the timers stay; only
|
|
278
|
+
* the media swaps rooms, with mute and camera as they were. If the new
|
|
279
|
+
* room cannot be joined, the media goes back to the room it came from.
|
|
280
|
+
*
|
|
281
|
+
* [done] `false`: not now — no live call, or the bundle is another call's.
|
|
282
|
+
*/
|
|
283
|
+
fun moveToRoom(next: CallSessionBundle, done: ((Boolean) -> Unit)? = null) = post {
|
|
284
|
+
val current = bundle
|
|
285
|
+
if ((state.phase != Phase.ACTIVE && state.phase != Phase.RECONNECTING) ||
|
|
286
|
+
current == null || current.callId != next.callId
|
|
287
|
+
) {
|
|
288
|
+
done?.invoke(false)
|
|
289
|
+
return@post
|
|
290
|
+
}
|
|
291
|
+
if (movingFrom == null) movingFrom = current
|
|
292
|
+
bundle = next
|
|
293
|
+
// Who was in the last room says nothing about this one.
|
|
294
|
+
remoteSeenFor = null
|
|
295
|
+
timers.cancel(T_ALONE)
|
|
296
|
+
media.join(next)
|
|
297
|
+
sink.emit(state)
|
|
298
|
+
done?.invoke(true)
|
|
299
|
+
}
|
|
240
300
|
fun onMediaLost() = post { dispatch(Event.MediaLost) }
|
|
241
301
|
fun onMediaReconnecting() = post { dispatch(Event.MediaReconnecting) }
|
|
242
302
|
fun onMediaRecovered() = post { dispatch(Event.MediaRecovered) }
|
|
@@ -262,7 +322,9 @@ class CallCoreRuntime(
|
|
|
262
322
|
timers.cancel(T_ALONE)
|
|
263
323
|
return@post
|
|
264
324
|
}
|
|
325
|
+
// In a breakout room the others are in the call's other rooms.
|
|
265
326
|
if (state.phase != Phase.ACTIVE || callKind == "room" || remoteSeenFor != callId) return@post
|
|
327
|
+
if (bundle?.breakoutRoomId != null) return@post
|
|
266
328
|
scheduleAloneProbe(callId, 0)
|
|
267
329
|
}
|
|
268
330
|
|
|
@@ -277,6 +339,7 @@ class CallCoreRuntime(
|
|
|
277
339
|
private fun probeAlone(callId: String, attempt: Int) {
|
|
278
340
|
if (state.phase != Phase.ACTIVE) return
|
|
279
341
|
val b = bundle ?: return
|
|
342
|
+
if (b.breakoutRoomId != null) return
|
|
280
343
|
val g = gen
|
|
281
344
|
val last = attempt == ALONE_PROBES_MS.size - 1
|
|
282
345
|
// A still-live answer carries a fresh bundle; the current one stays
|
|
@@ -333,7 +396,7 @@ class CallCoreRuntime(
|
|
|
333
396
|
// fallback still need it); CallSessionStop clears it with the rest.
|
|
334
397
|
if (isTerminal(next.phase)) ring = null
|
|
335
398
|
// A bundle never outlives its call — whatever ended it.
|
|
336
|
-
if (isTerminal(next.phase)) { bundle = null; sessionToken = null }
|
|
399
|
+
if (isTerminal(next.phase)) { bundle = null; movingFrom = null; sessionToken = null }
|
|
337
400
|
// A waiting call that went away without becoming the current one
|
|
338
401
|
// (declined, cancelled, timed out) is resolved: its ring never again.
|
|
339
402
|
before.waiting?.let { w ->
|
|
@@ -416,6 +479,7 @@ class CallCoreRuntime(
|
|
|
416
479
|
Effect.CallSessionStop -> {
|
|
417
480
|
session.stop()
|
|
418
481
|
bundle = null
|
|
482
|
+
movingFrom = null
|
|
419
483
|
ring = null
|
|
420
484
|
sessionToken = null
|
|
421
485
|
}
|
|
@@ -431,6 +495,7 @@ class CallCoreRuntime(
|
|
|
431
495
|
markResolved(before.callId)
|
|
432
496
|
gen++
|
|
433
497
|
bundle = null
|
|
498
|
+
movingFrom = null
|
|
434
499
|
sessionToken = null
|
|
435
500
|
ring = waitingRingCtx
|
|
436
501
|
waitingRingCtx = null
|
|
@@ -484,9 +549,21 @@ class CallCoreRuntime(
|
|
|
484
549
|
when (result) {
|
|
485
550
|
is HttpResult.Ok -> {
|
|
486
551
|
// Fresh token (and possibly URL): rejoin with it. MEDIA_CONNECTED
|
|
487
|
-
// on the new room returns us to ACTIVE.
|
|
488
|
-
|
|
489
|
-
|
|
552
|
+
// on the new room returns us to ACTIVE. In a breakout room,
|
|
553
|
+
// /reconnect answers with the main room's session: keep the room
|
|
554
|
+
// (its token outlives a network drop) and take the rest.
|
|
555
|
+
val cur = bundle
|
|
556
|
+
val fresh = result.bundle
|
|
557
|
+
val b = if (cur?.breakoutRoomId != null && fresh.breakoutRoomId == null) {
|
|
558
|
+
fresh.copy(
|
|
559
|
+
livekitUrl = cur.livekitUrl,
|
|
560
|
+
livekitToken = cur.livekitToken,
|
|
561
|
+
breakoutRoomId = cur.breakoutRoomId,
|
|
562
|
+
breakoutName = cur.breakoutName,
|
|
563
|
+
)
|
|
564
|
+
} else fresh
|
|
565
|
+
bundle = b
|
|
566
|
+
media.join(b)
|
|
490
567
|
}
|
|
491
568
|
HttpResult.Gone -> dispatch(Event.HttpGone)
|
|
492
569
|
is HttpResult.AuthFailed -> dispatch(Event.HttpFailed(result.code))
|
|
@@ -64,6 +64,13 @@ data class CallSessionBundle(
|
|
|
64
64
|
*/
|
|
65
65
|
val recording: String? = null,
|
|
66
66
|
val transcription: String? = null,
|
|
67
|
+
/**
|
|
68
|
+
* The breakout room this bundle's `livekit` connects to (MEETINGS.md
|
|
69
|
+
* §5: `breakout: {room_id, name}` from `POST /breakouts/:room/join`);
|
|
70
|
+
* null for the call's main room.
|
|
71
|
+
*/
|
|
72
|
+
val breakoutRoomId: String? = null,
|
|
73
|
+
val breakoutName: String? = null,
|
|
67
74
|
)
|
|
68
75
|
|
|
69
76
|
/** LiveKit (or any SFU) — media only, no lifecycle opinions. */
|
|
@@ -146,7 +153,27 @@ data class RingContext(
|
|
|
146
153
|
val serverId: String? = null,
|
|
147
154
|
/** The push's `workspace_name`, for "Ana · Acme" when several servers are signed in. */
|
|
148
155
|
val workspaceName: String? = null,
|
|
149
|
-
|
|
156
|
+
/**
|
|
157
|
+
* The push's `ring_type`: `"meeting"` for a scheduled meeting starting
|
|
158
|
+
* (CA4), `"call"` (or null, older servers) for a person calling.
|
|
159
|
+
*/
|
|
160
|
+
val ringType: String? = null,
|
|
161
|
+
/** The push's `meeting_title` ("Weekly sync"), meeting rings only. */
|
|
162
|
+
val meetingTitle: String? = null,
|
|
163
|
+
/** The push's `meeting_id`, meeting rings only. */
|
|
164
|
+
val meetingId: String? = null,
|
|
165
|
+
) {
|
|
166
|
+
/** A scheduled meeting starting, not a person calling. */
|
|
167
|
+
val isMeeting: Boolean get() = ringType == "meeting"
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* What the ring surface names, before any workspace suffix: "Weekly
|
|
171
|
+
* sync is starting" for a meeting, else the conversation or caller.
|
|
172
|
+
*/
|
|
173
|
+
val displayTitle: String?
|
|
174
|
+
get() = if (isMeeting) "${meetingTitle ?: conversationName ?: "Meeting"} is starting"
|
|
175
|
+
else conversationName ?: callerName
|
|
176
|
+
}
|
|
150
177
|
|
|
151
178
|
/** Android: the phoneCall foreground service. iOS: the CallKit session. */
|
|
152
179
|
interface CallSessionPort {
|
|
@@ -130,7 +130,7 @@ internal class AndroidRingSurface(
|
|
|
130
130
|
val answer = incomingActivity(autoAnswer = true, requestOffset = 2)
|
|
131
131
|
|
|
132
132
|
val caller = Person.Builder()
|
|
133
|
-
.setName(ServerRegistry.ringTitle(context, ring, ring.
|
|
133
|
+
.setName(ServerRegistry.ringTitle(context, ring, ring.displayTitle) ?: "Incoming call")
|
|
134
134
|
.setImportant(true)
|
|
135
135
|
.build()
|
|
136
136
|
|
|
@@ -210,14 +210,14 @@ internal class AndroidRingSurface(
|
|
|
210
210
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
|
211
211
|
)
|
|
212
212
|
|
|
213
|
-
val who = ServerRegistry.ringTitle(context, ring, ring.
|
|
213
|
+
val who = ServerRegistry.ringTitle(context, ring, ring.displayTitle) ?: "Someone"
|
|
214
214
|
val what = if (ring.media == "video") "video call" else "call"
|
|
215
215
|
val notification = NotificationCompat.Builder(context, WAITING_CHANNEL_ID)
|
|
216
216
|
.setSmallIcon(config.smallIcon)
|
|
217
217
|
.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
218
218
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
219
219
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
|
220
|
-
.setContentTitle("$who — incoming $what")
|
|
220
|
+
.setContentTitle(if (ring.isMeeting) who else "$who — incoming $what")
|
|
221
221
|
.setContentText("You're on a call. Answering ends it.")
|
|
222
222
|
.setOngoing(true)
|
|
223
223
|
.setAutoCancel(false)
|