@sentinel-nvr/web 0.6.2 → 0.8.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/dist/{chunk-G6UTEJFH.js → chunk-LXJOTTBC.js} +174 -131
- package/dist/chunk-LXJOTTBC.js.map +1 -0
- package/dist/{controller-DlX3you7.d.ts → controller-DErJv0mV.d.ts} +32 -23
- package/dist/player/index.d.ts +1 -1
- package/dist/player/index.js +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-G6UTEJFH.js.map +0 -1
|
@@ -267,10 +267,10 @@ var WebRtcSession = class {
|
|
|
267
267
|
// src/player/controller.ts
|
|
268
268
|
var MSCls = window.ManagedMediaSource || window.MediaSource;
|
|
269
269
|
var SWAP_MS = 2600;
|
|
270
|
+
var MARK_CAP_MS = 12e3;
|
|
270
271
|
var SCRUB_OFF_DELAY_MS = 1500;
|
|
271
|
-
var
|
|
272
|
-
var
|
|
273
|
-
var SCRUB_LAND_MS = 5e3;
|
|
272
|
+
var TARGET_FLOOR_MS = 120;
|
|
273
|
+
var TARGET_MIN_STEP_MS = 250;
|
|
274
274
|
var PlayerController = class {
|
|
275
275
|
v;
|
|
276
276
|
fz;
|
|
@@ -305,9 +305,6 @@ var PlayerController = class {
|
|
|
305
305
|
rwPending = null;
|
|
306
306
|
rwLastSeekTs = null;
|
|
307
307
|
rwLastSeekAt = 0;
|
|
308
|
-
rwRateBusy = false;
|
|
309
|
-
rwPendingRate = null;
|
|
310
|
-
rwLastRateAt = 0;
|
|
311
308
|
relayPoll;
|
|
312
309
|
wdLastCt = -1;
|
|
313
310
|
wdLastAt = 0;
|
|
@@ -323,7 +320,16 @@ var PlayerController = class {
|
|
|
323
320
|
swapT = 0;
|
|
324
321
|
posterFor = 0;
|
|
325
322
|
scrubOffT = 0;
|
|
326
|
-
|
|
323
|
+
// marked seek: width the new position arrives with (0 = timer path), send time (telemetry); presented width / frames at session start
|
|
324
|
+
swapW = 0;
|
|
325
|
+
swapAt = 0;
|
|
326
|
+
shownW = 0;
|
|
327
|
+
sessFrames0 = 0;
|
|
328
|
+
scrubMoves = 0;
|
|
329
|
+
rwTargetBusy = false;
|
|
330
|
+
rwPendingTarget = null;
|
|
331
|
+
rwLastTarget = 0;
|
|
332
|
+
rwLastTargetAt = 0;
|
|
327
333
|
// relay-pos answers are only valid for the command generation they were asked under; a poll sent BEFORE a
|
|
328
334
|
// seek/rate change and answered after it would drag the playhead back to the old position (and the
|
|
329
335
|
// auto-follow timeline with it → visible back-and-forth). seekAt: the server may still report the pre-swap
|
|
@@ -398,7 +404,7 @@ var PlayerController = class {
|
|
|
398
404
|
if (!this.live && !this.rw?.active) this.setLabel("loading");
|
|
399
405
|
});
|
|
400
406
|
for (const n of ["loadeddata", "playing", "canplay", "seeked"]) on(n, () => {
|
|
401
|
-
if (v.videoWidth) this.freezeHide();
|
|
407
|
+
if (v.videoWidth && !v.srcObject && !this.posterUntilSeek) this.freezeHide();
|
|
402
408
|
if (!this.live && this.label === "loading") this.setLabel("playing");
|
|
403
409
|
if (this.L.stallT) {
|
|
404
410
|
clearTimeout(this.L.stallT);
|
|
@@ -415,7 +421,10 @@ var PlayerController = class {
|
|
|
415
421
|
});
|
|
416
422
|
on("play", () => this.emit());
|
|
417
423
|
on("loadedmetadata", () => this.setAspect(this.v.videoWidth, this.v.videoHeight));
|
|
418
|
-
on("resize", () =>
|
|
424
|
+
on("resize", () => {
|
|
425
|
+
this.setAspect(this.v.videoWidth, this.v.videoHeight);
|
|
426
|
+
if (this.v.videoWidth && !this.v.requestVideoFrameCallback) this.markerCheck(this.v.videoWidth);
|
|
427
|
+
});
|
|
419
428
|
on("volumechange", () => this.emit());
|
|
420
429
|
on("error", () => {
|
|
421
430
|
const e = v.error;
|
|
@@ -536,7 +545,14 @@ var PlayerController = class {
|
|
|
536
545
|
/** Wall-clock position of the picture on screen (Scrypted's getRecordingStreamCurrentTime). */
|
|
537
546
|
currentTs() {
|
|
538
547
|
if (this.rw?.active) {
|
|
539
|
-
if (this.rwPosTs != null)
|
|
548
|
+
if (this.rwPosTs != null) {
|
|
549
|
+
const v = this.rwPosTs + (Date.now() - this.rwPosAt) * (this.rwRate || 1);
|
|
550
|
+
if ((this.rwScrub || this.scrubMoves > 0) && this.rwLastTarget) {
|
|
551
|
+
const lo = Math.min(this.rwPosTs, this.rwLastTarget), hi = Math.max(this.rwPosTs, this.rwLastTarget);
|
|
552
|
+
return Math.min(hi, Math.max(lo, v));
|
|
553
|
+
}
|
|
554
|
+
return v;
|
|
555
|
+
}
|
|
540
556
|
if (this.rwBase != null && this.v.currentTime > 0) return this.rwStartMs + (this.v.currentTime - this.rwBase) * 1e3 * (this.rwRate || 1);
|
|
541
557
|
return this.rwStartMs;
|
|
542
558
|
}
|
|
@@ -553,9 +569,14 @@ var PlayerController = class {
|
|
|
553
569
|
if (!v.requestVideoFrameCallback) return;
|
|
554
570
|
const tok = {};
|
|
555
571
|
this.fc.tok = tok;
|
|
556
|
-
const tick = () => {
|
|
572
|
+
const tick = (_now, md) => {
|
|
557
573
|
if (this.fc.tok !== tok) return;
|
|
558
574
|
this.fc.n++;
|
|
575
|
+
const w = md && md.width || this.v.videoWidth;
|
|
576
|
+
if (w) {
|
|
577
|
+
this.shownW = w;
|
|
578
|
+
this.markerCheck(w);
|
|
579
|
+
}
|
|
559
580
|
try {
|
|
560
581
|
v.requestVideoFrameCallback(tick);
|
|
561
582
|
} catch {
|
|
@@ -566,6 +587,10 @@ var PlayerController = class {
|
|
|
566
587
|
} catch {
|
|
567
588
|
}
|
|
568
589
|
}
|
|
590
|
+
/** a presented frame of width w: is it the first frame of the marked seek's new position? */
|
|
591
|
+
markerCheck(w) {
|
|
592
|
+
if (this.swapPending && this.swapW && w === this.swapW) this.swapVisible("marker");
|
|
593
|
+
}
|
|
569
594
|
presentedFrames() {
|
|
570
595
|
if (this.v.requestVideoFrameCallback) return this.fc.n;
|
|
571
596
|
try {
|
|
@@ -576,7 +601,7 @@ var PlayerController = class {
|
|
|
576
601
|
}
|
|
577
602
|
freezeArm(hold) {
|
|
578
603
|
if (this.freezeT) clearTimeout(this.freezeT);
|
|
579
|
-
this.freezeT = window.setTimeout(() => this.freezeHide(),
|
|
604
|
+
this.freezeT = window.setTimeout(() => this.freezeHide(), 9e4);
|
|
580
605
|
const v = this.v;
|
|
581
606
|
if (hold && v.requestVideoFrameCallback) {
|
|
582
607
|
const tok = {};
|
|
@@ -600,35 +625,45 @@ var PlayerController = class {
|
|
|
600
625
|
fc.dataset.src = "video";
|
|
601
626
|
return true;
|
|
602
627
|
}
|
|
628
|
+
/** Freeze the current picture. A still that is already visible stays (redrawing would copy from an element whose stream
|
|
629
|
+
* may already be gone → black) — it is only re-armed. */
|
|
603
630
|
freezeShow(hold = false) {
|
|
604
631
|
try {
|
|
632
|
+
if (this.posterUp()) {
|
|
633
|
+
if (!this.posterUntilSeek) this.freezeArm(hold);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
605
636
|
if (this.drawVideo()) this.freezeArm(hold);
|
|
606
637
|
} catch {
|
|
607
638
|
}
|
|
608
639
|
}
|
|
609
|
-
/** poster/freeze stays until the seek's picture is visible (swapVisible)
|
|
640
|
+
/** poster/freeze stays until the seek's picture is visible (swapVisible); safety net MARK_CAP_MS */
|
|
610
641
|
holdUntilSwap() {
|
|
611
642
|
if (this.freezeT) clearTimeout(this.freezeT);
|
|
612
643
|
this.freezeTok = null;
|
|
613
644
|
this.posterUntilSeek = true;
|
|
614
|
-
this.freezeT = window.setTimeout(() => this.swapVisible(),
|
|
645
|
+
this.freezeT = window.setTimeout(() => this.swapVisible("cap"), MARK_CAP_MS);
|
|
615
646
|
}
|
|
616
|
-
/**
|
|
617
|
-
*
|
|
647
|
+
/** A jump inside a running relay session: the current picture stands still at once (the old position must not keep playing
|
|
648
|
+
* while the new one crosses the pipeline); an already visible still (event frame) is kept. Lifted by swapVisible. */
|
|
618
649
|
freezeCurrent() {
|
|
619
650
|
if (!this.rw?.active || !this.rw.id) return;
|
|
620
651
|
try {
|
|
621
|
-
if (this.drawVideo()) this.holdUntilSwap();
|
|
652
|
+
if (this.posterUp() || this.drawVideo()) this.holdUntilSwap();
|
|
622
653
|
} catch {
|
|
623
654
|
}
|
|
624
655
|
}
|
|
625
656
|
/** the picture of the last seek is on screen: lift a held poster, report playing */
|
|
626
|
-
swapVisible() {
|
|
657
|
+
swapVisible(how = "timer") {
|
|
627
658
|
if (this.swapT) {
|
|
628
659
|
clearTimeout(this.swapT);
|
|
629
660
|
this.swapT = 0;
|
|
630
661
|
}
|
|
662
|
+
const was = this.swapPending;
|
|
631
663
|
this.swapPending = false;
|
|
664
|
+
this.swapW = 0;
|
|
665
|
+
if (was && this.swapAt) rlog("swap", { how, ms: Date.now() - this.swapAt, w: this.shownW });
|
|
666
|
+
this.swapAt = 0;
|
|
632
667
|
if (this.posterUntilSeek) this.freezeHide();
|
|
633
668
|
if (this.label === "loading" && this.rw?.active) this.setLabel("playing");
|
|
634
669
|
}
|
|
@@ -673,10 +708,11 @@ var PlayerController = class {
|
|
|
673
708
|
posterUp() {
|
|
674
709
|
return !this.fz.classList.contains("hidden");
|
|
675
710
|
}
|
|
711
|
+
/** scrub on MSE: the still stays while the gesture runs (lifted by the seek's `seeked`/`playing`) */
|
|
676
712
|
freezeHold() {
|
|
677
713
|
if (this.freezeT) {
|
|
678
714
|
clearTimeout(this.freezeT);
|
|
679
|
-
this.freezeT = window.setTimeout(() => this.freezeHide(),
|
|
715
|
+
this.freezeT = window.setTimeout(() => this.freezeHide(), 9e4);
|
|
680
716
|
}
|
|
681
717
|
}
|
|
682
718
|
/** Event click: the stored frame is the poster until the seek lands. */
|
|
@@ -687,9 +723,9 @@ var PlayerController = class {
|
|
|
687
723
|
img.crossOrigin = "anonymous";
|
|
688
724
|
img.onload = () => {
|
|
689
725
|
if (this.camId !== cam || this.posterFor !== ts || this.destroyed) return;
|
|
690
|
-
const
|
|
691
|
-
if (
|
|
692
|
-
this.freezeFromImage(img, true,
|
|
726
|
+
const firstFramePending = !!this.rw?.active && this.presentedFrames() <= this.sessFrames0;
|
|
727
|
+
if (this.swapPending) this.freezeFromImage(img, true, true, "event");
|
|
728
|
+
else if (firstFramePending || !this.rw?.active) this.freezeFromImage(img, true, false, "event");
|
|
693
729
|
};
|
|
694
730
|
img.src = this.api.url(`api/evframe?camera=${encodeURIComponent(cam)}&ts=${ts}`);
|
|
695
731
|
}
|
|
@@ -994,7 +1030,10 @@ var PlayerController = class {
|
|
|
994
1030
|
this.v.pause();
|
|
995
1031
|
} catch {
|
|
996
1032
|
}
|
|
997
|
-
this.
|
|
1033
|
+
this.img.onload = () => {
|
|
1034
|
+
this.img.onload = null;
|
|
1035
|
+
if (this.live) this.freezeHide();
|
|
1036
|
+
};
|
|
998
1037
|
this.transport = "mjpeg";
|
|
999
1038
|
this.setLabel("liveMjpeg");
|
|
1000
1039
|
this.setMjpeg(true);
|
|
@@ -1005,8 +1044,11 @@ var PlayerController = class {
|
|
|
1005
1044
|
return !this.recWebrtcDisabled && !!(window.RTCPeerConnection && window.WebSocket);
|
|
1006
1045
|
}
|
|
1007
1046
|
recWebrtcTeardown() {
|
|
1047
|
+
const seekStill = this.posterUntilSeek && this.posterUp();
|
|
1008
1048
|
this.posterUntilSeek = false;
|
|
1009
1049
|
this.swapPending = false;
|
|
1050
|
+
this.swapW = 0;
|
|
1051
|
+
if (seekStill) this.freezeArm(true);
|
|
1010
1052
|
if (this.swapT) {
|
|
1011
1053
|
clearTimeout(this.swapT);
|
|
1012
1054
|
this.swapT = 0;
|
|
@@ -1015,10 +1057,9 @@ var PlayerController = class {
|
|
|
1015
1057
|
clearTimeout(this.scrubOffT);
|
|
1016
1058
|
this.scrubOffT = 0;
|
|
1017
1059
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
}
|
|
1060
|
+
this.rwTargetBusy = false;
|
|
1061
|
+
this.rwPendingTarget = null;
|
|
1062
|
+
this.rwLastTarget = 0;
|
|
1022
1063
|
this.stopRelayPoll();
|
|
1023
1064
|
this.rw?.stop();
|
|
1024
1065
|
this.rw = void 0;
|
|
@@ -1030,8 +1071,6 @@ var PlayerController = class {
|
|
|
1030
1071
|
this.rwLastSeekTs = null;
|
|
1031
1072
|
this.rwSrate = 1;
|
|
1032
1073
|
this.rwRate = 1;
|
|
1033
|
-
this.rwRateBusy = false;
|
|
1034
|
-
this.rwPendingRate = null;
|
|
1035
1074
|
}
|
|
1036
1075
|
recWebrtcStart(ts) {
|
|
1037
1076
|
if (this.destroyed) return;
|
|
@@ -1100,10 +1139,15 @@ var PlayerController = class {
|
|
|
1100
1139
|
if (this.rw === s && this.rwPending) {
|
|
1101
1140
|
const p = this.rwPending;
|
|
1102
1141
|
this.rwPending = null;
|
|
1103
|
-
if (Math.abs(p.ts - this.rwStartMs) > 1500)
|
|
1142
|
+
if (Math.abs(p.ts - this.rwStartMs) > 1500) {
|
|
1143
|
+
if (p.mark) this.freezeCurrent();
|
|
1144
|
+
this.recRelaySeek(p.ts, p.rate, p.srate, p.mark);
|
|
1145
|
+
}
|
|
1104
1146
|
}
|
|
1105
1147
|
}
|
|
1106
1148
|
});
|
|
1149
|
+
this.sessFrames0 = this.presentedFrames();
|
|
1150
|
+
this.shownW = 0;
|
|
1107
1151
|
this.rw = s;
|
|
1108
1152
|
s.start();
|
|
1109
1153
|
this.startRelayPoll();
|
|
@@ -1123,31 +1167,39 @@ var PlayerController = class {
|
|
|
1123
1167
|
this.recWebrtcDisabled = true;
|
|
1124
1168
|
this.playAt(ts, {});
|
|
1125
1169
|
}
|
|
1126
|
-
/** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor.
|
|
1127
|
-
|
|
1170
|
+
/** Hard server-side seek, coalesced: one in flight, latest wins, 150 ms floor. `mark` = a user jump with a still picture
|
|
1171
|
+
* (see SWAP_MS): the server answers with the marker width the new position arrives with. */
|
|
1172
|
+
recRelaySeek(ts, rate = 1, srate = 1, mark = false) {
|
|
1128
1173
|
const s = this.rw;
|
|
1129
1174
|
if (!s?.id) return;
|
|
1130
1175
|
if (this.rwSeekBusy) {
|
|
1131
|
-
this.rwPending = { ts, rate, srate };
|
|
1176
|
+
this.rwPending = { ts, rate, srate, mark: mark || !!this.rwPending?.mark };
|
|
1132
1177
|
return;
|
|
1133
1178
|
}
|
|
1134
|
-
if (this.rwLastSeekTs === ts && this.rwRate === rate && this.rwSrate === srate && Date.now() - this.rwLastSeekAt < 1e3) return;
|
|
1179
|
+
if (!mark && this.rwLastSeekTs === ts && this.rwRate === rate && this.rwSrate === srate && Date.now() - this.rwLastSeekAt < 1e3) return;
|
|
1135
1180
|
const wait = 150 - (Date.now() - this.rwLastSeekAt);
|
|
1136
1181
|
if (wait > 0) {
|
|
1137
1182
|
this.rwSeekBusy = true;
|
|
1138
|
-
this.rwPending = { ts, rate, srate };
|
|
1183
|
+
this.rwPending = { ts, rate, srate, mark: mark || !!this.rwPending?.mark };
|
|
1139
1184
|
window.setTimeout(() => {
|
|
1140
1185
|
this.rwSeekBusy = false;
|
|
1141
1186
|
const p = this.rwPending;
|
|
1142
1187
|
this.rwPending = null;
|
|
1143
|
-
if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate);
|
|
1188
|
+
if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate, p.mark);
|
|
1144
1189
|
}, wait);
|
|
1145
1190
|
return;
|
|
1146
1191
|
}
|
|
1192
|
+
if (mark) {
|
|
1193
|
+
this.rwScrub = false;
|
|
1194
|
+
if (this.scrubOffT) {
|
|
1195
|
+
clearTimeout(this.scrubOffT);
|
|
1196
|
+
this.scrubOffT = 0;
|
|
1197
|
+
}
|
|
1198
|
+
this.scrubMoves = 0;
|
|
1199
|
+
}
|
|
1147
1200
|
this.rwStartMs = ts;
|
|
1148
1201
|
this.rwSrate = srate;
|
|
1149
1202
|
this.rwRate = this.rwScrub ? srate : rate;
|
|
1150
|
-
this.rwPendingRate = null;
|
|
1151
1203
|
this.rwLastSeekTs = ts;
|
|
1152
1204
|
this.rwLastSeekAt = Date.now();
|
|
1153
1205
|
this.cad.lastNew = Date.now();
|
|
@@ -1162,76 +1214,83 @@ var PlayerController = class {
|
|
|
1162
1214
|
this.seekAt = Date.now();
|
|
1163
1215
|
this.cmdSeq++;
|
|
1164
1216
|
this.swapPending = true;
|
|
1217
|
+
this.swapW = 0;
|
|
1218
|
+
this.swapAt = Date.now();
|
|
1165
1219
|
if (this.swapT) {
|
|
1166
1220
|
clearTimeout(this.swapT);
|
|
1167
1221
|
this.swapT = 0;
|
|
1168
1222
|
}
|
|
1169
|
-
const
|
|
1223
|
+
const seq = this.cmdSeq;
|
|
1224
|
+
const done = (ok, w) => {
|
|
1170
1225
|
this.rwSeekBusy = false;
|
|
1171
1226
|
if (!ok) {
|
|
1172
1227
|
this.relayRecover();
|
|
1173
1228
|
return;
|
|
1174
1229
|
}
|
|
1175
|
-
if (this.swapPending
|
|
1230
|
+
if (this.swapPending && seq === this.cmdSeq) {
|
|
1231
|
+
if (w) {
|
|
1232
|
+
this.swapW = w;
|
|
1233
|
+
if (this.shownW === w) this.swapVisible("marker");
|
|
1234
|
+
} else this.swapArm();
|
|
1235
|
+
}
|
|
1176
1236
|
const p = this.rwPending;
|
|
1177
1237
|
this.rwPending = null;
|
|
1178
|
-
if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate);
|
|
1238
|
+
if (p && this.rw?.id) this.recRelaySeek(p.ts, p.rate, p.srate, p.mark);
|
|
1179
1239
|
};
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1240
|
+
const q = `api/relay-seek?session=${encodeURIComponent(s.id)}&start=${Math.round(ts)}&rate=${rate}&srate=${srate}` + (mark ? `&mark=1&avoid=${this.shownW || this.v.videoWidth || 0}` : "");
|
|
1241
|
+
fetch(this.api.url(q), { cache: "no-store" }).then((r) => {
|
|
1242
|
+
if (!r.ok) return done(false, 0);
|
|
1243
|
+
if (r.status === 200) return r.json().then((j) => done(true, Number(j?.w) || 0), () => done(true, 0));
|
|
1244
|
+
return done(true, 0);
|
|
1245
|
+
}).catch(() => done(false, 0));
|
|
1246
|
+
}
|
|
1247
|
+
/** Scrub target (timeline centre), coalesced: one in flight, latest wins, 120 ms floor, 250 ms minimum step. */
|
|
1248
|
+
recRelayTarget(ts) {
|
|
1184
1249
|
const s = this.rw;
|
|
1185
|
-
if (!s?.active || !s.id
|
|
1186
|
-
if (this.
|
|
1187
|
-
this.
|
|
1250
|
+
if (!s?.active || !s.id) return;
|
|
1251
|
+
if (this.rwTargetBusy) {
|
|
1252
|
+
this.rwPendingTarget = ts;
|
|
1188
1253
|
return;
|
|
1189
1254
|
}
|
|
1190
|
-
if (this.
|
|
1191
|
-
|
|
1192
|
-
const wait = 120 - (Date.now() - this.rwLastRateAt);
|
|
1255
|
+
if (Math.abs(ts - this.rwLastTarget) < TARGET_MIN_STEP_MS) return;
|
|
1256
|
+
const wait = TARGET_FLOOR_MS - (Date.now() - this.rwLastTargetAt);
|
|
1193
1257
|
if (wait > 0) {
|
|
1194
|
-
this.
|
|
1195
|
-
this.
|
|
1258
|
+
this.rwTargetBusy = true;
|
|
1259
|
+
this.rwPendingTarget = ts;
|
|
1196
1260
|
window.setTimeout(() => {
|
|
1197
|
-
this.
|
|
1198
|
-
const p = this.
|
|
1199
|
-
this.
|
|
1200
|
-
if (p != null && this.rw?.id) this.
|
|
1261
|
+
this.rwTargetBusy = false;
|
|
1262
|
+
const p = this.rwPendingTarget;
|
|
1263
|
+
this.rwPendingTarget = null;
|
|
1264
|
+
if (p != null && this.rw?.id) this.recRelayTarget(p);
|
|
1201
1265
|
}, wait);
|
|
1202
1266
|
return;
|
|
1203
1267
|
}
|
|
1204
|
-
|
|
1205
|
-
this.
|
|
1206
|
-
this.rwRate = r;
|
|
1207
|
-
this.rwLastRateAt = Date.now();
|
|
1208
|
-
this.cmdSeq++;
|
|
1209
|
-
if (c != null) {
|
|
1210
|
-
this.rwPosTs = c;
|
|
1211
|
-
this.rwPosAt = Date.now();
|
|
1212
|
-
}
|
|
1268
|
+
this.rwLastTarget = ts;
|
|
1269
|
+
this.rwLastTargetAt = Date.now();
|
|
1213
1270
|
this.wdGrace = Date.now() + 8e3;
|
|
1214
1271
|
this.cad.lastNew = Date.now();
|
|
1215
|
-
this.
|
|
1216
|
-
this.api.control(`api/relay-
|
|
1272
|
+
this.rwTargetBusy = true;
|
|
1273
|
+
this.api.control(`api/relay-target?session=${encodeURIComponent(s.id)}&ts=${Math.round(ts)}`).then((ok) => {
|
|
1217
1274
|
if (!ok) this.relayRecover();
|
|
1218
1275
|
}).then(() => {
|
|
1219
|
-
this.
|
|
1220
|
-
const p = this.
|
|
1221
|
-
this.
|
|
1222
|
-
if (p != null && this.rw?.id && p
|
|
1276
|
+
this.rwTargetBusy = false;
|
|
1277
|
+
const p = this.rwPendingTarget;
|
|
1278
|
+
this.rwPendingTarget = null;
|
|
1279
|
+
if (p != null && this.rw?.id && Math.abs(p - this.rwLastTarget) >= TARGET_MIN_STEP_MS) this.recRelayTarget(p);
|
|
1223
1280
|
});
|
|
1224
1281
|
}
|
|
1225
|
-
|
|
1282
|
+
/** profile on/off; `off` also ends the server's target steering, so it is sent even when the profile was never entered
|
|
1283
|
+
* (single-notch gesture) as long as the gesture steered (`force`) */
|
|
1284
|
+
recRelayScrub(on, force = false) {
|
|
1226
1285
|
const s = this.rw;
|
|
1227
|
-
if (!s?.active || !s.id
|
|
1286
|
+
if (!s?.active || !s.id) return;
|
|
1287
|
+
if (this.rwScrub === on && !(force && !on)) return;
|
|
1228
1288
|
this.rwScrub = on;
|
|
1229
1289
|
this.cmdSeq++;
|
|
1230
1290
|
if (!on) {
|
|
1231
1291
|
const c = this.currentTs();
|
|
1232
1292
|
this.rwSrate = 1;
|
|
1233
1293
|
this.rwRate = this.rate;
|
|
1234
|
-
this.rwPendingRate = null;
|
|
1235
1294
|
if (c != null) {
|
|
1236
1295
|
this.rwPosTs = c;
|
|
1237
1296
|
this.rwPosAt = Date.now();
|
|
@@ -1318,6 +1377,7 @@ var PlayerController = class {
|
|
|
1318
1377
|
this.wdDead = 0;
|
|
1319
1378
|
this.rwPosTs = d.t;
|
|
1320
1379
|
this.rwPosAt = Date.now();
|
|
1380
|
+
if ((this.rwScrub || this.scrubMoves > 0) && typeof d.r === "number" && isFinite(d.r) && d.r) this.rwRate = d.r;
|
|
1321
1381
|
this.emit();
|
|
1322
1382
|
} else if (d && d.t <= 0) {
|
|
1323
1383
|
if (++this.wdDead >= 3) {
|
|
@@ -1415,8 +1475,11 @@ var PlayerController = class {
|
|
|
1415
1475
|
}
|
|
1416
1476
|
this.recPaused = false;
|
|
1417
1477
|
const t0 = Math.max(ts, this.clips[idx0].startTime);
|
|
1418
|
-
|
|
1419
|
-
|
|
1478
|
+
const jump = !opts.scrub;
|
|
1479
|
+
if (this.rw?.active && this.rw.id) {
|
|
1480
|
+
if (jump) this.freezeCurrent();
|
|
1481
|
+
this.recRelaySeek(t0, this.rate || 1, opts.srate || 1, jump);
|
|
1482
|
+
} else if (this.rw?.active && !this.live) this.rwPending = { ts: t0, rate: this.rate || 1, srate: opts.srate || 1, mark: jump };
|
|
1420
1483
|
else {
|
|
1421
1484
|
if (this.live) {
|
|
1422
1485
|
this.freezeShow(true);
|
|
@@ -1783,11 +1846,12 @@ var PlayerController = class {
|
|
|
1783
1846
|
if (this.rw?.active) {
|
|
1784
1847
|
this.recPausedTs = this.currentTs();
|
|
1785
1848
|
this.freezeShow();
|
|
1849
|
+
this.recWebrtcTeardown();
|
|
1786
1850
|
if (this.freezeT) {
|
|
1787
1851
|
clearTimeout(this.freezeT);
|
|
1788
1852
|
this.freezeT = 0;
|
|
1789
1853
|
}
|
|
1790
|
-
this.
|
|
1854
|
+
this.freezeTok = null;
|
|
1791
1855
|
try {
|
|
1792
1856
|
this.v.pause();
|
|
1793
1857
|
} catch {
|
|
@@ -1905,10 +1969,7 @@ var PlayerController = class {
|
|
|
1905
1969
|
clearTimeout(this.scrubOffT);
|
|
1906
1970
|
this.scrubOffT = 0;
|
|
1907
1971
|
}
|
|
1908
|
-
|
|
1909
|
-
clearTimeout(this.scrubLandT);
|
|
1910
|
-
this.scrubLandT = 0;
|
|
1911
|
-
}
|
|
1972
|
+
this.scrubMoves = 0;
|
|
1912
1973
|
if (!this.rw?.active) {
|
|
1913
1974
|
this.freezeShow();
|
|
1914
1975
|
if (!this.live) {
|
|
@@ -1919,73 +1980,50 @@ var PlayerController = class {
|
|
|
1919
1980
|
}
|
|
1920
1981
|
}
|
|
1921
1982
|
}
|
|
1922
|
-
/**
|
|
1923
|
-
|
|
1983
|
+
/** true between the end of a gesture and the profile switch back (SCRUB_OFF_DELAY_MS): the timeline must not auto-follow
|
|
1984
|
+
* the playhead in that window — the servo is still converging on the centre the user left */
|
|
1985
|
+
scrubSettling() {
|
|
1986
|
+
return this.scrubOffT !== 0;
|
|
1987
|
+
}
|
|
1988
|
+
/** scroll position while the gesture runs: the centre becomes the server's steering target (velocity unused since 0.7.0) */
|
|
1989
|
+
scrubMove(centerTs, _vel, _smoothTs) {
|
|
1924
1990
|
if (!this.rw?.active) {
|
|
1925
1991
|
this.freezeHold();
|
|
1926
1992
|
return;
|
|
1927
1993
|
}
|
|
1928
1994
|
if (!this.rw.id) return;
|
|
1929
|
-
|
|
1930
|
-
if (Math.abs(
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
const drift = cur == null ? null : tgt - cur;
|
|
1936
|
-
if (drift == null || Math.abs(drift) > Math.max(4500, 1200 * Math.abs(r))) this.scrubSeek(tgt, r);
|
|
1937
|
-
else this.recRelayRate(r);
|
|
1938
|
-
}
|
|
1939
|
-
/** hold / release: land exactly on the centre at 1× (or go live near now) */
|
|
1995
|
+
const c = this.currentTs();
|
|
1996
|
+
if (++this.scrubMoves >= 2 || c != null && Math.abs(centerTs - c) > 6e4) this.recRelayScrub(true);
|
|
1997
|
+
this.recRelayTarget(this.clampRange(centerTs));
|
|
1998
|
+
}
|
|
1999
|
+
/** release / hard landing: near now → live; relay in scrub → just the final target (no seek: the servo stops there);
|
|
2000
|
+
* MSE / no session → preview seek */
|
|
1940
2001
|
scrubSeek(ts, srate = 1) {
|
|
1941
2002
|
if (this.nearNow(ts)) {
|
|
1942
2003
|
this.goLive();
|
|
1943
2004
|
return;
|
|
1944
2005
|
}
|
|
2006
|
+
if (this.rw?.active && this.rw.id && this.scrubMoves > 0) {
|
|
2007
|
+
this.recRelayTarget(this.clampRange(ts));
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
1945
2010
|
this.playAt(this.clampRange(ts), { scrub: true, srate });
|
|
1946
2011
|
}
|
|
1947
|
-
/**
|
|
1948
|
-
* the playhead in that window — the time-lapse overshot the centre, following would drag the view away and the landing
|
|
1949
|
-
* seek would drag it back (visible back-and-forth of the timeline itself) */
|
|
1950
|
-
scrubSettling() {
|
|
1951
|
-
return this.scrubOffT !== 0 || this.scrubLandT !== 0;
|
|
1952
|
-
}
|
|
1953
|
-
/** drift between the timeline centre and the playhead (null without a position) */
|
|
1954
|
-
scrubDrift(ts) {
|
|
1955
|
-
const c = this.currentTs();
|
|
1956
|
-
return c == null ? null : this.clampRange(ts) - c;
|
|
1957
|
-
}
|
|
1958
|
-
/** brief hold mid-gesture (relay): time-lapse → 1× in place; a seek only when the picture is far off (each seek = ~2.4 s
|
|
1959
|
-
* of stale stream before the new picture — a seek per wheel step made the picture run back and forth). MSE: preview seek. */
|
|
2012
|
+
/** brief hold mid-gesture: nothing to do on the relay (the target already stands), MSE: preview seek */
|
|
1960
2013
|
scrubHold(ts) {
|
|
1961
|
-
if (!this.rw?.active)
|
|
1962
|
-
|
|
1963
|
-
return;
|
|
1964
|
-
}
|
|
1965
|
-
if (!this.rw.id) return;
|
|
1966
|
-
const d = this.scrubDrift(ts);
|
|
1967
|
-
if (d == null || Math.abs(d) > Math.max(SCRUB_HOLD_SEEK_MS, 1200 * Math.abs(this.rwRate))) {
|
|
1968
|
-
this.scrubSeek(ts, 1);
|
|
1969
|
-
return;
|
|
1970
|
-
}
|
|
1971
|
-
if (this.rwScrub && this.rwSrate !== 1) this.recRelayRate(1);
|
|
2014
|
+
if (!this.rw?.active) this.scrubSeek(ts);
|
|
2015
|
+
else if (this.rw.id) this.recRelayTarget(this.clampRange(ts));
|
|
1972
2016
|
}
|
|
1973
|
-
/** gesture settled → after SCRUB_OFF_DELAY_MS of quiet (a new gesture cancels it)
|
|
1974
|
-
* time-lapse drifted, then back to the normal profile. Landing per pause would be a seek per wheel step again. */
|
|
2017
|
+
/** gesture settled → final target, then back to the normal profile after SCRUB_OFF_DELAY_MS of quiet (a new gesture cancels it) */
|
|
1975
2018
|
scrubIdle(ts) {
|
|
2019
|
+
if (ts != null && this.rw?.active && this.rw.id && this.scrubMoves > 0) this.recRelayTarget(this.clampRange(ts));
|
|
1976
2020
|
if (this.scrubOffT) clearTimeout(this.scrubOffT);
|
|
1977
2021
|
this.scrubOffT = window.setTimeout(() => {
|
|
1978
2022
|
this.scrubOffT = 0;
|
|
1979
|
-
this.
|
|
2023
|
+
const steered = this.scrubMoves > 0;
|
|
2024
|
+
this.scrubMoves = 0;
|
|
2025
|
+
this.recRelayScrub(false, steered);
|
|
1980
2026
|
}, SCRUB_OFF_DELAY_MS);
|
|
1981
|
-
if (this.scrubLandT) clearTimeout(this.scrubLandT);
|
|
1982
|
-
this.scrubLandT = window.setTimeout(() => {
|
|
1983
|
-
this.scrubLandT = 0;
|
|
1984
|
-
if (ts != null && this.rw?.active && this.rw.id) {
|
|
1985
|
-
const d = this.scrubDrift(ts);
|
|
1986
|
-
if (d != null && Math.abs(d) > SCRUB_LAND_MS) this.scrubSeek(ts, 1);
|
|
1987
|
-
}
|
|
1988
|
-
}, SCRUB_LAND_DELAY_MS);
|
|
1989
2027
|
}
|
|
1990
2028
|
// ---- visibility ---------------------------------------------------------------------------
|
|
1991
2029
|
hiddenTs = null;
|
|
@@ -1998,8 +2036,13 @@ var PlayerController = class {
|
|
|
1998
2036
|
if (this.transport === "mjpeg") this.img.removeAttribute("src");
|
|
1999
2037
|
} else if (this.rw?.active) {
|
|
2000
2038
|
this.hiddenTs = this.currentTs();
|
|
2001
|
-
this.freezeShow(
|
|
2039
|
+
this.freezeShow();
|
|
2002
2040
|
this.recWebrtcTeardown();
|
|
2041
|
+
if (this.freezeT) {
|
|
2042
|
+
clearTimeout(this.freezeT);
|
|
2043
|
+
this.freezeT = 0;
|
|
2044
|
+
}
|
|
2045
|
+
this.freezeTok = null;
|
|
2003
2046
|
}
|
|
2004
2047
|
} else {
|
|
2005
2048
|
if (this.live) this.goLive();
|
|
@@ -2019,4 +2062,4 @@ export {
|
|
|
2019
2062
|
WebRtcSession,
|
|
2020
2063
|
PlayerController
|
|
2021
2064
|
};
|
|
2022
|
-
//# sourceMappingURL=chunk-
|
|
2065
|
+
//# sourceMappingURL=chunk-LXJOTTBC.js.map
|