@poolse/native 3.8.0 → 3.9.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/CHANGELOG.md +15 -0
- package/README.md +33 -0
- package/android/src/main/java/dev/poolse/callcore/CallCoreRuntime.kt +8 -0
- package/android/src/main/java/dev/poolse/callcore/Ports.kt +26 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +21 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallHttpClient.kt +3 -0
- package/android/src/main/java/dev/poolse/callcore/android/SnapshotJson.kt +23 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +2 -0
- package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitMediaPort.kt +96 -9
- package/dist/index.cjs +15 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -2
- package/dist/index.d.ts +66 -2
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/ios/Core/CallCoreRuntime.swift +8 -0
- package/ios/Core/CallHttpClient.swift +11 -1
- package/ios/Core/Ports.swift +25 -1
- package/ios/Core/SnapshotEncoding.swift +17 -1
- package/ios/Module/PoolseCallsModule.swift +2 -0
- package/ios/Platform/CallCore.swift +16 -1
- package/ios/Platform/LiveKitMediaPort.swift +103 -14
- package/package.json +1 -1
- package/src/index.ts +78 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Formerly `@poolse/react-native-calls` (0.x).
|
|
4
4
|
|
|
5
|
+
## 3.9.0 — 2026-11-22
|
|
6
|
+
|
|
7
|
+
- Recording and transcripts (server docs/RECORDING.md). poolse's transcript
|
|
8
|
+
assistant (`poolse:…`, LiveKit kind agent) and LiveKit Egress's recorder
|
|
9
|
+
(`EG_…`, kind egress) are no longer reported as people: they are left out of
|
|
10
|
+
`participants`, video tiles, "someone answered" and the count that ends a
|
|
11
|
+
call left alone (SIP participants stay).
|
|
12
|
+
- Snapshots carry `canPublish`, `recording` and `transcription` (the
|
|
13
|
+
CallSummary's objects from answer / join / place / reconnect; `null` from a
|
|
14
|
+
server without them). New types `CallRecordingState`, `CallTranscriptionState`.
|
|
15
|
+
- Recording consent: when the server revokes publishing, the core stops
|
|
16
|
+
publishing without errors and keeps the mic / camera choices; when it comes
|
|
17
|
+
back it republishes them. `republish()` (for ConsentPrompt's `onAccepted`)
|
|
18
|
+
and `onCanPublishChange(cb)`.
|
|
19
|
+
|
|
5
20
|
## 3.8.0 — 2026-11-21
|
|
6
21
|
|
|
7
22
|
- Several workspaces (servers) at once:
|
package/README.md
CHANGED
|
@@ -109,6 +109,9 @@ The full API:
|
|
|
109
109
|
- Several workspaces: `addServer`, `removeServer`, `listServers`,
|
|
110
110
|
`serverOfNotification`, `DEFAULT_SERVER_ID`, `serverId` on `place` / `join`
|
|
111
111
|
/ `startRoom` and in snapshots, taps and action results (see below).
|
|
112
|
+
- Recording and transcripts: `snapshot.recording` / `snapshot.transcription`
|
|
113
|
+
(the server's state as of joining), `snapshot.canPublish`,
|
|
114
|
+
`onCanPublishChange`, `republish` (see below).
|
|
112
115
|
- Socket forwarding (optional): `onCallFinished`, `onRingEnded`. Feed them
|
|
113
116
|
from `@poolse/sdk` 3.1's user channel:
|
|
114
117
|
|
|
@@ -118,6 +121,36 @@ The full API:
|
|
|
118
121
|
userChannel.onCallFinished((e) => calls.onCallFinished(e.call_id, e.reason));
|
|
119
122
|
```
|
|
120
123
|
|
|
124
|
+
## Recording, consent and transcripts
|
|
125
|
+
|
|
126
|
+
When the server records or transcribes a call (docs/RECORDING.md on the
|
|
127
|
+
server), the core:
|
|
128
|
+
|
|
129
|
+
- leaves poolse's own participants out of everything it reports — the
|
|
130
|
+
transcript assistant (`poolse:assistant:…`, LiveKit kind agent) and the
|
|
131
|
+
recorder (LiveKit Egress, `EG_…`). They are never in
|
|
132
|
+
`snapshot.participants`, never get a video tile, never count as someone
|
|
133
|
+
answering, and don't keep a call alive when everyone else has left.
|
|
134
|
+
Phone (SIP) participants are listed as usual.
|
|
135
|
+
- carries the call's `recording` and `transcription` objects into the
|
|
136
|
+
snapshot, as the server sent them on answer / join / place and each
|
|
137
|
+
reconnect, so the indicator shows without another request. Later changes
|
|
138
|
+
come on the conversation socket (`recording:*`, `transcript:*`): use those
|
|
139
|
+
for anything after joining.
|
|
140
|
+
- follows the server's publish permission. With `consent: "required"`, the
|
|
141
|
+
server turns publishing off until you accept: `snapshot.canPublish` turns
|
|
142
|
+
`false`, nothing of yours goes out (you still hear and see the call), and
|
|
143
|
+
mute / camera taps are remembered rather than refused. Once you accept,
|
|
144
|
+
the server turns it back on and the core publishes the mic and camera as
|
|
145
|
+
you last had them. Call `republish()` from ConsentPrompt's `onAccepted` as
|
|
146
|
+
well; it is harmless before the permission is back.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
<ConsentPrompt onAccepted={() => calls.republish()} … />
|
|
150
|
+
|
|
151
|
+
const off = calls.onCanPublishChange((allowed) => setListenOnly(!allowed));
|
|
152
|
+
```
|
|
153
|
+
|
|
121
154
|
## Ringtone
|
|
122
155
|
|
|
123
156
|
```json
|
|
@@ -143,6 +143,12 @@ class CallCoreRuntime(
|
|
|
143
143
|
/** `room` or `call`, once the server's bundle says; null before. Runtime thread only. */
|
|
144
144
|
val callKind: String? get() = bundle?.kind
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* The bundle's capture state (`recording`, `transcription` as JSON
|
|
148
|
+
* text), as of the last answer/join/place/reconnect. Runtime thread only.
|
|
149
|
+
*/
|
|
150
|
+
val capture: Pair<String?, String?> get() = bundle?.recording to bundle?.transcription
|
|
151
|
+
|
|
146
152
|
/**
|
|
147
153
|
* The current call's id and control token — what authorizes acting on
|
|
148
154
|
* the call itself (ringing more people in). Null with no session yet.
|
|
@@ -301,6 +307,8 @@ class CallCoreRuntime(
|
|
|
301
307
|
fun switchCamera() = post { media.switchCamera() }
|
|
302
308
|
fun setSpeaker(on: Boolean) = post { media.setSpeaker(on) }
|
|
303
309
|
fun setAudioOutput(id: String) = post { media.setAudioOutput(id) }
|
|
310
|
+
/** Consent given: publish the mic/camera again (a no-op until the server allows it). */
|
|
311
|
+
fun republish() = post { media.republish() }
|
|
304
312
|
|
|
305
313
|
/** Re-emit the current state (the bridge's roster/route changed). */
|
|
306
314
|
fun reemit() = post { if (state.phase != Phase.IDLE) sink.emit(state) }
|
|
@@ -57,6 +57,13 @@ data class CallSessionBundle(
|
|
|
57
57
|
val kind: String = "call",
|
|
58
58
|
/** How many people the server says are being rung right now. */
|
|
59
59
|
val ringing: Int = 0,
|
|
60
|
+
/**
|
|
61
|
+
* The CallSummary's `recording` / `transcription` objects as JSON text
|
|
62
|
+
* (docs/RECORDING.md), carried to the snapshot untouched; null from a
|
|
63
|
+
* server before them.
|
|
64
|
+
*/
|
|
65
|
+
val recording: String? = null,
|
|
66
|
+
val transcription: String? = null,
|
|
60
67
|
)
|
|
61
68
|
|
|
62
69
|
/** LiveKit (or any SFU) — media only, no lifecycle opinions. */
|
|
@@ -78,6 +85,25 @@ interface MediaPort {
|
|
|
78
85
|
* speaker toggle.
|
|
79
86
|
*/
|
|
80
87
|
fun setAudioOutput(id: String) = setSpeaker(id == "speaker")
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Publish the mic and camera again as the user last had them, once the
|
|
91
|
+
* server lets this participant publish (consent given, docs/RECORDING.md §5).
|
|
92
|
+
*/
|
|
93
|
+
fun republish() {}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* poolse's own participants in a room — the transcript assistant
|
|
98
|
+
* (`poolse:assistant:<call>`, kind AGENT) and LiveKit Egress's recorder
|
|
99
|
+
* (`EG_…`, kind EGRESS). They are not people: never in the roster, never
|
|
100
|
+
* counted as someone in the call (docs/RECORDING.md §7). SIP (phone)
|
|
101
|
+
* participants are people and stay.
|
|
102
|
+
*/
|
|
103
|
+
object ServiceParticipants {
|
|
104
|
+
/** [kind]: LiveKit's participant kind, lowercased (`agent`, `egress`, `sip`, …). */
|
|
105
|
+
fun isService(identity: String, kind: String?): Boolean =
|
|
106
|
+
identity.startsWith("poolse:") || identity.startsWith("EG_") || kind == "agent" || kind == "egress"
|
|
81
107
|
}
|
|
82
108
|
|
|
83
109
|
/** The ring UX: CallStyle notification + full-screen activity + tones. */
|
|
@@ -89,6 +89,8 @@ class CallCore private constructor(context: Context) {
|
|
|
89
89
|
private var audioOutputId: String? = null
|
|
90
90
|
private var connectionQuality = "unknown"
|
|
91
91
|
private var videoPaused = false
|
|
92
|
+
/** False while the server holds our media back (recording consent). */
|
|
93
|
+
private var canPublish = true
|
|
92
94
|
|
|
93
95
|
/** Last snapshot emitted; read by the bridge's getCallState from any thread. */
|
|
94
96
|
@Volatile private var lastSnapshot: Map<String, Any?>? = null
|
|
@@ -276,6 +278,12 @@ class CallCore private constructor(context: Context) {
|
|
|
276
278
|
*/
|
|
277
279
|
fun setAudioOutput(id: String) = runtime.setAudioOutput(id)
|
|
278
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Consent given: publish the mic and camera again as the user last had
|
|
283
|
+
* them. Also happens by itself once the server lets us publish.
|
|
284
|
+
*/
|
|
285
|
+
fun republish() = runtime.republish()
|
|
286
|
+
|
|
279
287
|
/** The current call's id and control token. Any thread. */
|
|
280
288
|
val control: Pair<String, String>? get() = runtime.control
|
|
281
289
|
|
|
@@ -340,6 +348,9 @@ class CallCore private constructor(context: Context) {
|
|
|
340
348
|
connectionQuality = connectionQuality,
|
|
341
349
|
videoPaused = videoPaused,
|
|
342
350
|
screenSharing = screenSharing,
|
|
351
|
+
canPublish = canPublish,
|
|
352
|
+
recording = runtime.capture.first,
|
|
353
|
+
transcription = runtime.capture.second,
|
|
343
354
|
)
|
|
344
355
|
val withServers = snap?.let { withServers(it, state) }
|
|
345
356
|
lastSnapshot = withServers
|
|
@@ -390,6 +401,7 @@ class CallCore private constructor(context: Context) {
|
|
|
390
401
|
audioOutputId = null
|
|
391
402
|
connectionQuality = "unknown"
|
|
392
403
|
videoPaused = false
|
|
404
|
+
canPublish = true
|
|
393
405
|
}
|
|
394
406
|
|
|
395
407
|
/**
|
|
@@ -456,6 +468,10 @@ class CallCore private constructor(context: Context) {
|
|
|
456
468
|
runtime.post { cameraOn = on; cameraFacing = facing }
|
|
457
469
|
runtime.reemit()
|
|
458
470
|
}
|
|
471
|
+
override fun onCanPublish(allowed: Boolean) {
|
|
472
|
+
runtime.post { canPublish = allowed }
|
|
473
|
+
runtime.reemit()
|
|
474
|
+
}
|
|
459
475
|
override fun onLocalScreen(on: Boolean) {
|
|
460
476
|
runtime.post { screenSharing = on }
|
|
461
477
|
runtime.reemit()
|
|
@@ -726,6 +742,11 @@ interface MediaEvents {
|
|
|
726
742
|
* whether incoming video is paused to keep the audio going.
|
|
727
743
|
*/
|
|
728
744
|
fun onNetwork(quality: String, videoPaused: Boolean) {}
|
|
745
|
+
/**
|
|
746
|
+
* Whether the server lets us publish (false: recording consent not
|
|
747
|
+
* given yet, docs/RECORDING.md §5). Sent on every change.
|
|
748
|
+
*/
|
|
749
|
+
fun onCanPublish(allowed: Boolean) {}
|
|
729
750
|
}
|
|
730
751
|
|
|
731
752
|
/** One place call audio can play — a snapshot `audioOutputs[]` entry. */
|
|
@@ -174,6 +174,7 @@ internal class CallHttpClient(
|
|
|
174
174
|
livekitToken = livekit.getString("token"),
|
|
175
175
|
controlToken = root.optStringOrNull("control_token") ?: current.controlToken,
|
|
176
176
|
ringing = 0,
|
|
177
|
+
// recording / transcription: the current bundle's stand.
|
|
177
178
|
)
|
|
178
179
|
}
|
|
179
180
|
return CallSessionBundle(
|
|
@@ -190,6 +191,8 @@ internal class CallHttpClient(
|
|
|
190
191
|
ringing = call.optJSONObject("ring_states")?.let { states ->
|
|
191
192
|
states.keys().asSequence().count { states.optString(it) == "ringing" }
|
|
192
193
|
} ?: 0,
|
|
194
|
+
recording = call.optJSONObject("recording")?.toString() ?: current?.recording,
|
|
195
|
+
transcription = call.optJSONObject("transcription")?.toString() ?: current?.transcription,
|
|
193
196
|
)
|
|
194
197
|
}
|
|
195
198
|
|
|
@@ -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"
|
|
@@ -187,6 +187,8 @@ class PoolseCallsModule : Module() {
|
|
|
187
187
|
Function("switchCamera") { core()?.switchCamera() }
|
|
188
188
|
Function("setSpeaker") { on: Boolean -> core()?.setSpeaker(on) }
|
|
189
189
|
Function("setAudioOutput") { id: String -> core()?.setAudioOutput(id) }
|
|
190
|
+
// Recording consent accepted: mic and camera back as they were.
|
|
191
|
+
Function("republish") { core()?.republish() }
|
|
190
192
|
|
|
191
193
|
// What authorizes acting on the call itself (ringing people in).
|
|
192
194
|
AsyncFunction("callControl") {
|
|
@@ -9,6 +9,7 @@ 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
|
|
13
14
|
import dev.poolse.callcore.android.CallVideoSource
|
|
14
15
|
import dev.poolse.callcore.android.CallVideoSurface
|
|
@@ -24,6 +25,8 @@ import io.livekit.android.events.collect
|
|
|
24
25
|
import io.livekit.android.room.Room
|
|
25
26
|
import io.livekit.android.room.participant.ConnectionQuality
|
|
26
27
|
import io.livekit.android.room.participant.Participant
|
|
28
|
+
import io.livekit.android.room.participant.ParticipantPermission
|
|
29
|
+
import io.livekit.android.room.participant.RemoteParticipant
|
|
27
30
|
import io.livekit.android.room.track.CameraPosition
|
|
28
31
|
import io.livekit.android.room.track.LocalVideoTrack
|
|
29
32
|
import io.livekit.android.room.track.RemoteTrackPublication
|
|
@@ -88,6 +91,14 @@ class LiveKitMediaPort(
|
|
|
88
91
|
private var cameraWanted: Boolean? = null
|
|
89
92
|
private var joinedCallId: String? = null
|
|
90
93
|
|
|
94
|
+
/**
|
|
95
|
+
* The server lets us publish. False while it holds our media back for
|
|
96
|
+
* consent (docs/RECORDING.md §5): the choices above are kept, nothing
|
|
97
|
+
* is published (LiveKit unpublished what was live), and they come back
|
|
98
|
+
* as they were once permission returns.
|
|
99
|
+
*/
|
|
100
|
+
private var canPublish = true
|
|
101
|
+
|
|
91
102
|
/** Our own link to the SFU, as last reported. */
|
|
92
103
|
private var localQuality = "unknown"
|
|
93
104
|
|
|
@@ -140,10 +151,15 @@ class LiveKitMediaPort(
|
|
|
140
151
|
}
|
|
141
152
|
}.isSuccess
|
|
142
153
|
if (!connected || room !== newRoom) return@launch
|
|
154
|
+
// The token may say listen-only (consent required, not yet given):
|
|
155
|
+
// publish nothing then — the permission update brings it back.
|
|
156
|
+
val allowed = updateCanPublish(newRoom)
|
|
143
157
|
// Publishing failures must not fail the call: audio-only is a call.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
158
|
+
if (allowed) {
|
|
159
|
+
runCatching { newRoom.localParticipant.setMicrophoneEnabled(!mutedWanted) }
|
|
160
|
+
.onFailure { Log.w(TAG, "microphone publish failed", it) }
|
|
161
|
+
}
|
|
162
|
+
if (allowed && (cameraWanted ?: wantsVideo)) enableCamera(newRoom, true)
|
|
147
163
|
reportLocalCamera(newRoom)
|
|
148
164
|
refreshVideo()
|
|
149
165
|
}
|
|
@@ -177,6 +193,7 @@ class LiveKitMediaPort(
|
|
|
177
193
|
private fun resetWanted() {
|
|
178
194
|
mutedWanted = false
|
|
179
195
|
cameraWanted = null
|
|
196
|
+
canPublish = true
|
|
180
197
|
outputWanted = null
|
|
181
198
|
pauseJob?.cancel()
|
|
182
199
|
resumeJob?.cancel()
|
|
@@ -216,12 +233,15 @@ class LiveKitMediaPort(
|
|
|
216
233
|
|
|
217
234
|
override fun setMuted(muted: Boolean) {
|
|
218
235
|
mutedWanted = muted
|
|
236
|
+
// Not allowed to publish: only remembered, applied on republish.
|
|
237
|
+
if (!canPublish) return
|
|
219
238
|
val r = room ?: return
|
|
220
239
|
scope.launch { runCatching { r.localParticipant.setMicrophoneEnabled(!muted) } }
|
|
221
240
|
}
|
|
222
241
|
|
|
223
242
|
override fun setCamera(on: Boolean) {
|
|
224
243
|
cameraWanted = on
|
|
244
|
+
if (!canPublish) return
|
|
225
245
|
val r = room ?: return
|
|
226
246
|
scope.launch {
|
|
227
247
|
enableCamera(r, on)
|
|
@@ -239,6 +259,7 @@ class LiveKitMediaPort(
|
|
|
239
259
|
*/
|
|
240
260
|
override fun setScreenShare(on: Boolean, permission: Intent?) {
|
|
241
261
|
val r = room ?: return
|
|
262
|
+
if (on && !canPublish) return
|
|
242
263
|
if (on && permission == null) return
|
|
243
264
|
scope.launch {
|
|
244
265
|
runCatching { r.localParticipant.setScreenShareEnabled(on, if (on) permission else null) }
|
|
@@ -249,6 +270,42 @@ class LiveKitMediaPort(
|
|
|
249
270
|
}
|
|
250
271
|
}
|
|
251
272
|
|
|
273
|
+
// ── publish permission (recording consent) ──────────────────────────
|
|
274
|
+
|
|
275
|
+
/** Reads the local participant's permission; reports a change. Returns it. */
|
|
276
|
+
private fun updateCanPublish(r: Room): Boolean {
|
|
277
|
+
if (room !== r) return canPublish
|
|
278
|
+
val perms: ParticipantPermission? = r.localParticipant.permissions
|
|
279
|
+
val now = perms?.canPublish ?: true
|
|
280
|
+
if (now != canPublish) {
|
|
281
|
+
canPublish = now
|
|
282
|
+
Log.i(TAG, "canPublish=$now")
|
|
283
|
+
events.onCanPublish(now)
|
|
284
|
+
}
|
|
285
|
+
return now
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Mic and camera as the user last had them — after consent (the app
|
|
290
|
+
* calls this from its consent prompt; the permission update does it
|
|
291
|
+
* too). A no-op while the server still says listen-only.
|
|
292
|
+
*/
|
|
293
|
+
override fun republish() {
|
|
294
|
+
val r = room ?: return
|
|
295
|
+
if (r.state != Room.State.CONNECTED || !updateCanPublish(r)) return
|
|
296
|
+
val camera = cameraWanted ?: (media == "video")
|
|
297
|
+
scope.launch {
|
|
298
|
+
if (r.localParticipant.isMicrophoneEnabled() == mutedWanted) {
|
|
299
|
+
runCatching { r.localParticipant.setMicrophoneEnabled(!mutedWanted) }
|
|
300
|
+
.onFailure { Log.w(TAG, "microphone republish failed", it) }
|
|
301
|
+
}
|
|
302
|
+
if (camera && localCameraTrack(r) == null) enableCamera(r, true)
|
|
303
|
+
if (room !== r) return@launch
|
|
304
|
+
reportLocalCamera(r)
|
|
305
|
+
refreshVideo()
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
252
309
|
/** Front ↔ back on the published camera track. */
|
|
253
310
|
override fun switchCamera() {
|
|
254
311
|
val r = room ?: return
|
|
@@ -289,7 +346,7 @@ class LiveKitMediaPort(
|
|
|
289
346
|
internal fun cameraTrack(participantId: String?, local: Boolean): VideoTrack? {
|
|
290
347
|
val r = room ?: return null
|
|
291
348
|
if (local) return localCameraTrack(r)
|
|
292
|
-
val p = r.
|
|
349
|
+
val p = people(r).firstOrNull { it.identity?.value == participantId } ?: return null
|
|
293
350
|
return remoteCamera(p)
|
|
294
351
|
}
|
|
295
352
|
|
|
@@ -309,7 +366,7 @@ class LiveKitMediaPort(
|
|
|
309
366
|
internal fun screenTrack(participantId: String?, local: Boolean): VideoTrack? {
|
|
310
367
|
val r = room ?: return null
|
|
311
368
|
if (local) return localScreenTrack(r)
|
|
312
|
-
val p = r.
|
|
369
|
+
val p = people(r).firstOrNull { it.identity?.value == participantId } ?: return null
|
|
313
370
|
return remoteScreen(p)
|
|
314
371
|
}
|
|
315
372
|
|
|
@@ -471,7 +528,7 @@ class LiveKitMediaPort(
|
|
|
471
528
|
events.onConnected()
|
|
472
529
|
// Somebody may already be in (a late join, or a callee who
|
|
473
530
|
// answered before our media came up): they will not "connect".
|
|
474
|
-
if (room.
|
|
531
|
+
if (people(room).isNotEmpty()) events.onRemoteJoined()
|
|
475
532
|
emit(room)
|
|
476
533
|
refreshVideo()
|
|
477
534
|
}
|
|
@@ -485,7 +542,19 @@ class LiveKitMediaPort(
|
|
|
485
542
|
is RoomEvent.Disconnected -> {
|
|
486
543
|
if (event.reason != DisconnectReason.CLIENT_INITIATED) events.onLost()
|
|
487
544
|
}
|
|
488
|
-
|
|
545
|
+
// The transcript assistant or the recorder joining is nobody answering.
|
|
546
|
+
is RoomEvent.ParticipantConnected -> {
|
|
547
|
+
if (!isService(event.participant)) events.onRemoteJoined()
|
|
548
|
+
emit(room)
|
|
549
|
+
refreshVideo()
|
|
550
|
+
}
|
|
551
|
+
// Only ever ours: the server turned publishing off (consent) or back on.
|
|
552
|
+
is RoomEvent.ParticipantPermissionsChanged -> {
|
|
553
|
+
if (event.participant === room.localParticipant) {
|
|
554
|
+
val was = canPublish
|
|
555
|
+
if (updateCanPublish(room) && !was) republish()
|
|
556
|
+
}
|
|
557
|
+
}
|
|
489
558
|
// Anything that can make a camera appear, vanish or freeze:
|
|
490
559
|
// update the roster's cameraOn, the local camera state, and
|
|
491
560
|
// rebind every video view.
|
|
@@ -518,10 +587,28 @@ class LiveKitMediaPort(
|
|
|
518
587
|
}
|
|
519
588
|
}
|
|
520
589
|
|
|
590
|
+
/**
|
|
591
|
+
* The remote PEOPLE: poolse's transcript assistant and LiveKit Egress's
|
|
592
|
+
* recorder are in the room but are not someone in the call — never in
|
|
593
|
+
* the roster, the count that ends a call left alone, or a video tile.
|
|
594
|
+
* Phone (SIP) participants are people.
|
|
595
|
+
*/
|
|
596
|
+
private fun people(r: Room): List<RemoteParticipant> = r.remoteParticipants.values.filterNot(::isService)
|
|
597
|
+
|
|
598
|
+
private fun isService(p: Participant): Boolean {
|
|
599
|
+
val kind = when (p.kind) {
|
|
600
|
+
Participant.Kind.AGENT -> "agent"
|
|
601
|
+
Participant.Kind.EGRESS -> "egress"
|
|
602
|
+
Participant.Kind.SIP -> "sip"
|
|
603
|
+
else -> null
|
|
604
|
+
}
|
|
605
|
+
return ServiceParticipants.isService(p.identity?.value ?: "", kind)
|
|
606
|
+
}
|
|
607
|
+
|
|
521
608
|
/** The REMOTE roster — the local participant is never included. */
|
|
522
609
|
private fun emit(room: Room) {
|
|
523
610
|
events.onParticipants(
|
|
524
|
-
room.
|
|
611
|
+
people(room).map {
|
|
525
612
|
val identity = it.identity?.value ?: ""
|
|
526
613
|
MediaParticipant(
|
|
527
614
|
identity = identity,
|
|
@@ -578,7 +665,7 @@ class LiveKitMediaPort(
|
|
|
578
665
|
}
|
|
579
666
|
|
|
580
667
|
private fun hasRemoteVideo(r: Room) =
|
|
581
|
-
r.
|
|
668
|
+
people(r).any { it.getTrackPublication(Track.Source.CAMERA) != null }
|
|
582
669
|
|
|
583
670
|
private fun setVideoPaused(r: Room, paused: Boolean) {
|
|
584
671
|
Log.i(TAG, "incoming video ${if (paused) "paused" else "resumed"} quality=$localQuality")
|
package/dist/index.cjs
CHANGED
|
@@ -120,6 +120,19 @@ function setAudioOutput(id) {
|
|
|
120
120
|
if (native?.setAudioOutput) native.setAudioOutput(id);
|
|
121
121
|
else native?.setSpeaker(id === "speaker");
|
|
122
122
|
}
|
|
123
|
+
var republish = () => native?.republish?.();
|
|
124
|
+
function onCanPublishChange(cb) {
|
|
125
|
+
let last = null;
|
|
126
|
+
const check = (snapshot) => {
|
|
127
|
+
const now = snapshot?.canPublish ?? true;
|
|
128
|
+
if (now === last) return;
|
|
129
|
+
const first = last === null;
|
|
130
|
+
last = now;
|
|
131
|
+
if (!first || snapshot) cb(now);
|
|
132
|
+
};
|
|
133
|
+
check(getCallState());
|
|
134
|
+
return onCallState(check);
|
|
135
|
+
}
|
|
123
136
|
var onRingEnded = (callId, reason) => native?.onRingEnded(callId, reason);
|
|
124
137
|
var onCallFinished = (callId, reason) => native?.onCallFinished(callId, reason ?? null);
|
|
125
138
|
var canUseFullScreenIntent = () => native?.canUseFullScreenIntent() ?? true;
|
|
@@ -249,6 +262,7 @@ exports.nativeCallsAvailable = nativeCallsAvailable;
|
|
|
249
262
|
exports.onCallAction = onCallAction;
|
|
250
263
|
exports.onCallFinished = onCallFinished;
|
|
251
264
|
exports.onCallState = onCallState;
|
|
265
|
+
exports.onCanPublishChange = onCanPublishChange;
|
|
252
266
|
exports.onNotificationAction = onNotificationAction;
|
|
253
267
|
exports.onNotificationReply = onNotificationReply;
|
|
254
268
|
exports.onPictureInPicture = onPictureInPicture;
|
|
@@ -258,6 +272,7 @@ exports.openFullScreenIntentSettings = openFullScreenIntentSettings;
|
|
|
258
272
|
exports.pictureInPictureSupported = pictureInPictureSupported;
|
|
259
273
|
exports.place = place;
|
|
260
274
|
exports.removeServer = removeServer;
|
|
275
|
+
exports.republish = republish;
|
|
261
276
|
exports.ringIntoCall = ringIntoCall;
|
|
262
277
|
exports.screenShareSupported = screenShareSupported;
|
|
263
278
|
exports.serverOfNotification = serverOfNotification;
|