livedesk 0.1.84 → 0.1.86
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/hub/src/remote-hub.js
CHANGED
|
@@ -1663,7 +1663,7 @@ export function createRemoteHub(options = {}) {
|
|
|
1663
1663
|
transferProtocol: descriptor.transferProtocol,
|
|
1664
1664
|
transferProtocolVersion: descriptor.transferProtocolVersion,
|
|
1665
1665
|
handshake: descriptor.handshake,
|
|
1666
|
-
fps: clampNumber(options.fps, 1,
|
|
1666
|
+
fps: clampNumber(options.fps, 1, 30, mode === 'thumbnail' ? 1 : 2),
|
|
1667
1667
|
capturedAt: now,
|
|
1668
1668
|
receivedAt: now,
|
|
1669
1669
|
byteLength: 68,
|
|
@@ -3861,7 +3861,7 @@ export function createRemoteHub(options = {}) {
|
|
|
3861
3861
|
}
|
|
3862
3862
|
|
|
3863
3863
|
function normalizeLiveStreamStartOptions(options = {}) {
|
|
3864
|
-
const fps = clampNumber(options.fps, 1,
|
|
3864
|
+
const fps = clampNumber(options.fps, 1, 30, 8);
|
|
3865
3865
|
const maxWidth = clampNumber(options.maxWidth, 320, 3840, 640);
|
|
3866
3866
|
const maxHeight = clampNumber(options.maxHeight, 180, 2160, 360);
|
|
3867
3867
|
const quality = clampNumber(options.quality, 20, 95, 45);
|
|
@@ -4008,6 +4008,7 @@ export function createRemoteHub(options = {}) {
|
|
|
4008
4008
|
const { fps, maxWidth, maxHeight, quality, monitorIndex, transfer } = normalized;
|
|
4009
4009
|
const commandId = safeString(options.commandId, 128) || crypto.randomUUID();
|
|
4010
4010
|
if (device.activeLiveStream?.streamId === streamId
|
|
4011
|
+
&& options.forceRestart !== true
|
|
4011
4012
|
&& liveStreamMatchesOptions(device.activeLiveStream, normalized)
|
|
4012
4013
|
&& liveStreamIsReusable(device.activeLiveStream)) {
|
|
4013
4014
|
if (options.silentReuse !== true) {
|
|
@@ -4030,6 +4031,16 @@ export function createRemoteHub(options = {}) {
|
|
|
4030
4031
|
reused: true
|
|
4031
4032
|
};
|
|
4032
4033
|
}
|
|
4034
|
+
if (options.forceRestart === true && device.activeLiveStream?.streamId === streamId) {
|
|
4035
|
+
emitRemoteEvent('RemoteLiveStreamForcedRestart', device, {
|
|
4036
|
+
streamId,
|
|
4037
|
+
fps,
|
|
4038
|
+
mode: transfer.mode,
|
|
4039
|
+
frameMode: transfer.frameMode,
|
|
4040
|
+
monitorIndex,
|
|
4041
|
+
reason: safeString(options.restartReason || 'browser-stale', 128)
|
|
4042
|
+
});
|
|
4043
|
+
}
|
|
4033
4044
|
if (device.activeLiveStream?.streamId === streamId
|
|
4034
4045
|
&& liveStreamMatchesOptions(device.activeLiveStream, normalized)
|
|
4035
4046
|
&& device.activeLiveStream.open === true
|
package/hub/src/server.js
CHANGED
|
@@ -173,7 +173,7 @@ function normalizeTransferFiles(value) {
|
|
|
173
173
|
function normalizeLiveOptions(payload = {}) {
|
|
174
174
|
const mode = String(payload.frameMode || payload.mode || 'mode3-h264-hw').trim() || 'mode3-h264-hw';
|
|
175
175
|
return {
|
|
176
|
-
fps: clampNumber(payload.fps, 1,
|
|
176
|
+
fps: clampNumber(payload.fps, 1, 30, 2),
|
|
177
177
|
maxWidth: clampNumber(payload.maxWidth, 320, 3840, 640),
|
|
178
178
|
maxHeight: clampNumber(payload.maxHeight, 180, 2160, 360),
|
|
179
179
|
quality: clampNumber(payload.quality, 20, 95, 45),
|
|
@@ -207,7 +207,7 @@ function updateFrameSubscription(ws, payload = {}) {
|
|
|
207
207
|
startFrameSubscriptionLive(ws, 'subscribe');
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
function startFrameSubscriptionLive(ws, reason = 'subscribe', onlyDeviceId = '') {
|
|
210
|
+
function startFrameSubscriptionLive(ws, reason = 'subscribe', onlyDeviceId = '', overrideLiveOptions = null) {
|
|
211
211
|
const subscribedIds = [...(ws.liveDeskDeviceIds || [])];
|
|
212
212
|
if (!ws.liveDeskAutoStart || subscribedIds.length === 0) {
|
|
213
213
|
return;
|
|
@@ -220,6 +220,9 @@ function startFrameSubscriptionLive(ws, reason = 'subscribe', onlyDeviceId = '')
|
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
const liveOptions = overrideLiveOptions && typeof overrideLiveOptions === 'object'
|
|
224
|
+
? { ...ws.liveDeskLiveOptions, ...overrideLiveOptions }
|
|
225
|
+
: ws.liveDeskLiveOptions;
|
|
223
226
|
const lookup = new Map(remoteHub.listDevices({ includeDataUrl: false }).map(device => [device.deviceId, device]));
|
|
224
227
|
const started = [];
|
|
225
228
|
const skipped = [];
|
|
@@ -234,13 +237,13 @@ function startFrameSubscriptionLive(ws, reason = 'subscribe', onlyDeviceId = '')
|
|
|
234
237
|
skipped.push({ deviceId, reason: device?.connected ? 'live-unavailable' : 'not-connected' });
|
|
235
238
|
continue;
|
|
236
239
|
}
|
|
237
|
-
const monitorIndex = Object.prototype.hasOwnProperty.call(
|
|
238
|
-
?
|
|
239
|
-
:
|
|
240
|
+
const monitorIndex = Object.prototype.hasOwnProperty.call(liveOptions.monitorSelections || {}, deviceId)
|
|
241
|
+
? liveOptions.monitorSelections[deviceId]
|
|
242
|
+
: liveOptions.monitorIndex;
|
|
240
243
|
const result = remoteHub.startLiveStream(deviceId, {
|
|
241
|
-
...
|
|
244
|
+
...liveOptions,
|
|
242
245
|
monitorIndex,
|
|
243
|
-
silentReuse: reason === 'watchdog'
|
|
246
|
+
silentReuse: reason === 'watchdog' && liveOptions.forceRestart !== true
|
|
244
247
|
});
|
|
245
248
|
if (result?.ok) {
|
|
246
249
|
started.push({ deviceId, streamId: result.streamId, fps: result.fps, reused: result.reused === true });
|
|
@@ -260,6 +263,29 @@ function startFrameSubscriptionLive(ws, reason = 'subscribe', onlyDeviceId = '')
|
|
|
260
263
|
});
|
|
261
264
|
}
|
|
262
265
|
|
|
266
|
+
function restartFrameSubscriptionLive(ws, payload = {}) {
|
|
267
|
+
const requestedIds = normalizeDeviceIds(payload.deviceIds ?? payload.devices ?? payload.deviceId);
|
|
268
|
+
const targetIds = requestedIds.length > 0
|
|
269
|
+
? requestedIds
|
|
270
|
+
: [...(ws.liveDeskDeviceIds || [])];
|
|
271
|
+
if (targetIds.length === 0) {
|
|
272
|
+
sendJson(ws, { type: 'RemoteFrameSubscriptionError', error: 'restart-device-missing' });
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const restartOptions = {
|
|
276
|
+
...normalizeLiveOptions({
|
|
277
|
+
...ws.liveDeskLiveOptions,
|
|
278
|
+
...payload
|
|
279
|
+
}),
|
|
280
|
+
forceRestart: true,
|
|
281
|
+
restartToken: String(payload.restartToken || `${Date.now()}`).slice(0, 128),
|
|
282
|
+
restartReason: String(payload.restartReason || payload.reason || 'browser-stale').slice(0, 128)
|
|
283
|
+
};
|
|
284
|
+
for (const deviceId of targetIds.slice(0, 16)) {
|
|
285
|
+
startFrameSubscriptionLive(ws, restartOptions.restartReason, deviceId, restartOptions);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
263
289
|
function updateAudioSubscription(ws, payload = {}) {
|
|
264
290
|
const deviceIds = normalizeDeviceIds(payload.deviceIds ?? payload.devices ?? payload.deviceId);
|
|
265
291
|
ws.liveDeskAudioDeviceIds = new Set(deviceIds);
|
|
@@ -728,6 +754,8 @@ frameWss.on('connection', (ws, req) => {
|
|
|
728
754
|
const payload = JSON.parse(Buffer.isBuffer(data) ? data.toString('utf8') : String(data || ''));
|
|
729
755
|
if (payload?.type === 'subscribe') {
|
|
730
756
|
updateFrameSubscription(ws, payload);
|
|
757
|
+
} else if (payload?.type === 'restart-live') {
|
|
758
|
+
restartFrameSubscriptionLive(ws, payload);
|
|
731
759
|
}
|
|
732
760
|
} catch {
|
|
733
761
|
sendJson(ws, { type: 'RemoteFrameSubscriptionError', error: 'invalid-message' });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livedesk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.86",
|
|
4
4
|
"description": "LiveDesk Hub and client launcher",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"node": ">=20"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@livedesk/client": "0.1.
|
|
33
|
+
"@livedesk/client": "0.1.63",
|
|
34
34
|
"cors": "^2.8.5",
|
|
35
35
|
"express": "^4.21.2",
|
|
36
36
|
"ws": "^8.18.3"
|