@camstack/sdk 0.1.54 → 0.1.56
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/dist/index.cjs +27 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +27 -67
- package/dist/index.js.map +1 -1
- package/dist/system.d.ts +14 -3
- package/package.json +1 -1
- package/dist/adaptive-stream.d.ts +0 -91
package/dist/index.cjs
CHANGED
|
@@ -1126,6 +1126,31 @@ class System {
|
|
|
1126
1126
|
const proxies = filters ? this.mirror.query(filters) : this.mirror.getAllDevices();
|
|
1127
1127
|
return proxies.map((p) => this.attachBinding(p));
|
|
1128
1128
|
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Sync `DeviceInfo` snapshot (name, canonical type, online, …) for one device
|
|
1131
|
+
* from the warm-boot mirror — `null` if the mirror isn't booted or the device
|
|
1132
|
+
* is unknown. Unlike a `DeviceProxy` (cap accessors only), this carries the
|
|
1133
|
+
* display identity the UI needs to render a device on first paint.
|
|
1134
|
+
*/
|
|
1135
|
+
getDeviceInfo(deviceId) {
|
|
1136
|
+
return this.mirror?.getDeviceInfo(deviceId) ?? null;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* The `DeviceInfo` snapshots for the current device set (the warm-boot cache),
|
|
1140
|
+
* honouring the same `filters` as {@link listDevices}. Lets a UI render a named
|
|
1141
|
+
* device list immediately without waiting for per-device lifecycle events.
|
|
1142
|
+
*/
|
|
1143
|
+
listDeviceInfos(filters) {
|
|
1144
|
+
const mirror = this.mirror;
|
|
1145
|
+
if (!mirror) return [];
|
|
1146
|
+
const proxies = filters ? mirror.query(filters) : mirror.getAllDevices();
|
|
1147
|
+
const out = [];
|
|
1148
|
+
for (const p of proxies) {
|
|
1149
|
+
const info = mirror.getDeviceInfo(p.deviceId);
|
|
1150
|
+
if (info) out.push(info);
|
|
1151
|
+
}
|
|
1152
|
+
return out;
|
|
1153
|
+
}
|
|
1129
1154
|
/**
|
|
1130
1155
|
* Sync lookup by numeric id. `null` if the mirror has not been booted
|
|
1131
1156
|
* or the device is unknown.
|
|
@@ -1239,12 +1264,8 @@ class System {
|
|
|
1239
1264
|
get pipelineRunner() {
|
|
1240
1265
|
return this._systemProxy.pipelineRunner;
|
|
1241
1266
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
}
|
|
1245
|
-
get recordingEngine() {
|
|
1246
|
-
return this._systemProxy.recordingEngine;
|
|
1247
|
-
}
|
|
1267
|
+
// `platform-probe` is infra (addon-to-addon via `api.platformProbe`), not a
|
|
1268
|
+
// client-facing system cap — it isn't on SystemProxy, so no getter here.
|
|
1248
1269
|
get settingsStore() {
|
|
1249
1270
|
return this._systemProxy.settingsStore;
|
|
1250
1271
|
}
|
|
@@ -1944,65 +1965,6 @@ function getSourceFeatures(source) {
|
|
|
1944
1965
|
function getBackendRequiredFeatures() {
|
|
1945
1966
|
return FEATURE_MATRIX.filter((f) => f.requiresBackend);
|
|
1946
1967
|
}
|
|
1947
|
-
function selectOptimalStream(streams, constraints, defaultTransport) {
|
|
1948
|
-
if (streams.length === 0) return null;
|
|
1949
|
-
const viewportPixels = constraints.viewportWidth * constraints.viewportHeight * (constraints.pixelRatio ?? 1);
|
|
1950
|
-
const bw = constraints.bandwidthMbps ?? 100;
|
|
1951
|
-
const loss = constraints.packetLoss ?? 0;
|
|
1952
|
-
const rtt = constraints.rttMs ?? 50;
|
|
1953
|
-
let targetTier = "high";
|
|
1954
|
-
if (constraints.maxResolution === "low" || constraints.isCellular || bw < 1 || loss > 0.05) {
|
|
1955
|
-
targetTier = "low";
|
|
1956
|
-
} else if (constraints.maxResolution === "medium" || bw < 5 || viewportPixels < 5e5 || rtt > 200) {
|
|
1957
|
-
targetTier = "medium";
|
|
1958
|
-
} else if (constraints.maxResolution === "high" || viewportPixels > 2e6) {
|
|
1959
|
-
targetTier = "high";
|
|
1960
|
-
}
|
|
1961
|
-
const PROFILE_TIER = {
|
|
1962
|
-
main: "high",
|
|
1963
|
-
sub: "medium",
|
|
1964
|
-
ext: "low"
|
|
1965
|
-
};
|
|
1966
|
-
const preferTransport = defaultTransport ?? "native";
|
|
1967
|
-
const scored = streams.map((s) => {
|
|
1968
|
-
let score = 0;
|
|
1969
|
-
const streamTier = PROFILE_TIER[s.profile] ?? "medium";
|
|
1970
|
-
if (streamTier === targetTier) score += 100;
|
|
1971
|
-
else if (targetTier === "high" && streamTier === "medium" || targetTier === "medium" && streamTier === "high" || targetTier === "medium" && streamTier === "low" || targetTier === "low" && streamTier === "medium") score += 50;
|
|
1972
|
-
if (s.transport === preferTransport) score += 30;
|
|
1973
|
-
else if (s.transport === "native") score += 20;
|
|
1974
|
-
else if (s.transport === "rtsp") score += 15;
|
|
1975
|
-
else if (s.transport === "rtmp") score += 10;
|
|
1976
|
-
if (s.metadata?.width && s.metadata?.height) {
|
|
1977
|
-
const streamPixels = s.metadata.width * s.metadata.height;
|
|
1978
|
-
const ratio = streamPixels / Math.max(viewportPixels, 1);
|
|
1979
|
-
if (ratio >= 0.8 && ratio <= 2) score += 25;
|
|
1980
|
-
else if (ratio >= 0.5 && ratio <= 3) score += 15;
|
|
1981
|
-
if (ratio > 4 && bw < 10) score -= 20;
|
|
1982
|
-
}
|
|
1983
|
-
if (s.metadata?.codec) {
|
|
1984
|
-
if (bw < 5 && s.metadata.codec.includes("265")) score += 10;
|
|
1985
|
-
if (bw >= 10 && s.metadata.codec.includes("264")) score += 5;
|
|
1986
|
-
}
|
|
1987
|
-
return { ...s, score, targetTier };
|
|
1988
|
-
});
|
|
1989
|
-
scored.sort((a, b) => b.score - a.score);
|
|
1990
|
-
const best = scored[0];
|
|
1991
|
-
return {
|
|
1992
|
-
streamName: best.streamName,
|
|
1993
|
-
profile: best.profile,
|
|
1994
|
-
transport: best.transport,
|
|
1995
|
-
label: best.label,
|
|
1996
|
-
metadata: best.metadata,
|
|
1997
|
-
reason: `${best.targetTier} quality → ${best.profile}/${best.transport} (score: ${best.score})`
|
|
1998
|
-
};
|
|
1999
|
-
}
|
|
2000
|
-
function getNextEvalInterval(constraints, wasSwitch) {
|
|
2001
|
-
if (wasSwitch) return 10;
|
|
2002
|
-
if (constraints.isCellular) return 15;
|
|
2003
|
-
if ((constraints.packetLoss ?? 0) > 0.02) return 15;
|
|
2004
|
-
return 30;
|
|
2005
|
-
}
|
|
2006
1968
|
exports.DEFAULT_ENABLED_CLASSES = DEFAULT_ENABLED_CLASSES;
|
|
2007
1969
|
exports.DetectionClass = DetectionClass;
|
|
2008
1970
|
exports.ELIGIBLE_HA_DOMAINS = ELIGIBLE_HA_DOMAINS;
|
|
@@ -2028,7 +1990,6 @@ exports.faceClasses = faceClasses;
|
|
|
2028
1990
|
exports.getBackendRequiredFeatures = getBackendRequiredFeatures;
|
|
2029
1991
|
exports.getCanonicalDeviceType = getCanonicalDeviceType;
|
|
2030
1992
|
exports.getClassesForTimelinePreset = getClassesForTimelinePreset;
|
|
2031
|
-
exports.getNextEvalInterval = getNextEvalInterval;
|
|
2032
1993
|
exports.getParentClass = getParentClass;
|
|
2033
1994
|
exports.getParentDetectionClass = getParentDetectionClass;
|
|
2034
1995
|
exports.getSourceFeatures = getSourceFeatures;
|
|
@@ -2049,7 +2010,6 @@ exports.motionClasses = motionClasses;
|
|
|
2049
2010
|
exports.packageClasses = packageClasses;
|
|
2050
2011
|
exports.personClasses = personClasses;
|
|
2051
2012
|
exports.raceFastestEndpoint = raceFastestEndpoint;
|
|
2052
|
-
exports.selectOptimalStream = selectOptimalStream;
|
|
2053
2013
|
exports.sensorLabelClasses = sensorLabelClasses;
|
|
2054
2014
|
exports.vehicleClasses = vehicleClasses;
|
|
2055
2015
|
//# sourceMappingURL=index.cjs.map
|