@7365admin1/layer-common 4.97.1-staging.626 → 4.97.1-staging.628
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.
|
@@ -49,6 +49,7 @@ const notice = computed(() => cctvNotice(failure.value));
|
|
|
49
49
|
|
|
50
50
|
let pc: RTCPeerConnection | null = null;
|
|
51
51
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
52
|
+
const LIVE_START_MS = 10000;
|
|
52
53
|
let run = 0; // bumps on every start/stop so a late answer from an old attempt is ignored
|
|
53
54
|
|
|
54
55
|
function stop() {
|
|
@@ -85,7 +86,8 @@ async function tryWebrtc(token: number) {
|
|
|
85
86
|
const conn = new RTCPeerConnection({ iceServers: stun ? [{ urls: stun }] : [] });
|
|
86
87
|
pc = conn;
|
|
87
88
|
conn.addTransceiver("video", { direction: "recvonly" });
|
|
88
|
-
|
|
89
|
+
// Video only: asking for sound can make the engine open a second connection to a recorder that
|
|
90
|
+
// has no audio on this stream, and recorders block boxes that open too many.
|
|
89
91
|
const connected = new Promise<void>((resolve, reject) => {
|
|
90
92
|
// A track is announced as soon as the answer is read, before any picture can arrive (the engine
|
|
91
93
|
// may be unreachable for video). "Live" waits for the first decoded frame; otherwise stills.
|
|
@@ -110,7 +112,7 @@ async function tryWebrtc(token: number) {
|
|
|
110
112
|
if (token !== run) return;
|
|
111
113
|
await conn.setRemoteDescription({ type: "answer", sdp: answer.sdp });
|
|
112
114
|
await connected;
|
|
113
|
-
if (token === run) mode.value = "live";
|
|
115
|
+
if (token === run && mode.value === "connecting") mode.value = "live";
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
async function pollStill(token: number) {
|
|
@@ -147,7 +149,11 @@ async function start() {
|
|
|
147
149
|
mode.value = "connecting";
|
|
148
150
|
failure.value = null;
|
|
149
151
|
try {
|
|
150
|
-
|
|
152
|
+
// One limit for the whole attempt, the answer request included: a recorder that will not open
|
|
153
|
+
// another stream can keep that request waiting for half a minute.
|
|
154
|
+
const attempt = tryWebrtc(token);
|
|
155
|
+
attempt.catch(() => undefined); // a late failure after the limit is already handled below
|
|
156
|
+
await Promise.race([attempt, new Promise<never>((_, reject) => setTimeout(() => reject(new Error("webrtc-timeout")), LIVE_START_MS))]);
|
|
151
157
|
} catch (e: any) {
|
|
152
158
|
if (token !== run) return;
|
|
153
159
|
// The engine being offline is the same for the still picture, so say it instead of pretending to fall back.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.628",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|