Диагностика допуска правой камеры в интерфейс
This commit is contained in:
@@ -5,6 +5,8 @@ export type LiveViewerDiagnosticEventCode =
|
||||
| "live_receiver_recovery_exhausted"
|
||||
| "live_receiver_active_store_admitted"
|
||||
| "live_receiver_error"
|
||||
| "live_camera_source_projected"
|
||||
| "live_camera_window_admitted"
|
||||
| "live_camera_transport_restart_requested"
|
||||
| "live_camera_transport_playing";
|
||||
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
|
||||
import type { ObservationSourceDescriptor } from "../runtime/contracts";
|
||||
import {
|
||||
createLiveViewerInstanceId,
|
||||
createLiveViewerLineage,
|
||||
postLiveViewerDiagnostic,
|
||||
type LiveViewerDiagnostic,
|
||||
type LiveViewerLineage,
|
||||
} from "./liveViewerDiagnostics";
|
||||
import {
|
||||
closeObservationSource,
|
||||
openObservationSource,
|
||||
@@ -88,6 +95,51 @@ export function automaticLivePresentationIdentity(
|
||||
return JSON.stringify([source.id, acquisitionId, deliveryId]);
|
||||
}
|
||||
|
||||
export interface LiveCameraPresentationDiagnostic {
|
||||
key: string;
|
||||
event: LiveViewerDiagnostic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read-only boundary markers for the automatic camera path. They distinguish
|
||||
* a catalog/delivery failure from layout admission and player mounting without
|
||||
* changing presentation state or contacting the device.
|
||||
*/
|
||||
export function pendingLiveCameraPresentationDiagnostics(
|
||||
sources: readonly ObservationSourceDescriptor[],
|
||||
visibleSourceIds: ReadonlySet<string>,
|
||||
emittedKeys: ReadonlySet<string>,
|
||||
): LiveCameraPresentationDiagnostic[] {
|
||||
const pending: LiveCameraPresentationDiagnostic[] = [];
|
||||
for (const source of sources) {
|
||||
if (source.modality !== "video") continue;
|
||||
const presentationIdentity = automaticLivePresentationIdentity(source);
|
||||
const deliveryId = source.delivery?.id?.trim();
|
||||
if (!presentationIdentity || !deliveryId) continue;
|
||||
const projectedKey = `projected:${presentationIdentity}`;
|
||||
if (!emittedKeys.has(projectedKey)) {
|
||||
pending.push({
|
||||
key: projectedKey,
|
||||
event: {
|
||||
eventCode: "live_camera_source_projected",
|
||||
streamId: deliveryId,
|
||||
},
|
||||
});
|
||||
}
|
||||
const admittedKey = `admitted:${presentationIdentity}`;
|
||||
if (visibleSourceIds.has(source.id) && !emittedKeys.has(admittedKey)) {
|
||||
pending.push({
|
||||
key: admittedKey,
|
||||
event: {
|
||||
eventCode: "live_camera_window_admitted",
|
||||
streamId: deliveryId,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
return pending;
|
||||
}
|
||||
|
||||
/** A deliberate close fences every delivery generation in that acquisition. */
|
||||
export function livePresentationCloseFence(
|
||||
source: ObservationSourceDescriptor,
|
||||
@@ -216,6 +268,8 @@ export function useObservationLayout(
|
||||
const admittedLivePresentationIdentitiesRef = useRef(new Set<string>());
|
||||
const closedLiveAcquisitionSourcesRef = useRef(new Set<string>());
|
||||
const presentedLiveAcquisitionSourcesRef = useRef(new Set<string>());
|
||||
const emittedLiveCameraDiagnosticKeysRef = useRef(new Set<string>());
|
||||
const liveCameraDiagnosticLineageRef = useRef<LiveViewerLineage | null>(null);
|
||||
const initializedCatalog = useRef<string | null>(null);
|
||||
const sourceIdList = sources.map((source) => source.id).sort();
|
||||
const sourceIdsIdentity = sourceIdList.join("\u0000");
|
||||
@@ -432,6 +486,23 @@ export function useObservationLayout(
|
||||
admitAutomaticLivePresentations();
|
||||
}, [admitAutomaticLivePresentations, selectedDeliveryIdentity]);
|
||||
|
||||
useEffect(() => {
|
||||
const diagnostics = pendingLiveCameraPresentationDiagnostics(
|
||||
sources,
|
||||
new Set(visibleIds),
|
||||
emittedLiveCameraDiagnosticKeysRef.current,
|
||||
);
|
||||
if (!diagnostics.length) return;
|
||||
liveCameraDiagnosticLineageRef.current ??= createLiveViewerLineage(
|
||||
createLiveViewerInstanceId(),
|
||||
1,
|
||||
);
|
||||
for (const diagnostic of diagnostics) {
|
||||
emittedLiveCameraDiagnosticKeysRef.current.add(diagnostic.key);
|
||||
postLiveViewerDiagnostic(diagnostic.event, liveCameraDiagnosticLineageRef.current);
|
||||
}
|
||||
}, [selectedDeliveryIdentity, sources, visibleIds]);
|
||||
|
||||
const markPending = useCallback((source: ObservationSourceDescriptor, pending: boolean) => {
|
||||
const groupId = source.activation?.groupId;
|
||||
const affected = groupId
|
||||
|
||||
Reference in New Issue
Block a user