@mega-yfue/eufy-sdk 0.5.0-beta.33 → 0.5.0-beta.35
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.js
CHANGED
|
@@ -17119,32 +17119,35 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
17119
17119
|
* Frames are packed back to back, so a frame header can itself be cut by a datagram boundary. The start
|
|
17120
17120
|
* of a header left at the end of a datagram is carried into the next one rather than discarded; dropping
|
|
17121
17121
|
* it would lose that frame and every frame after it until a datagram happened to begin on a header.
|
|
17122
|
+
* Payload fragments retain their original slices and are copied once, when the complete frame is delivered.
|
|
17122
17123
|
*/
|
|
17123
17124
|
reassemble(dataType, datagramBody) {
|
|
17124
17125
|
const pending = this.pendingByDataType.get(dataType);
|
|
17125
|
-
let body = pending ? Buffer.concat([pending.buf, datagramBody]) : datagramBody;
|
|
17126
|
-
const carryHeader = pending?.header;
|
|
17127
17126
|
this.pendingByDataType.delete(dataType);
|
|
17128
|
-
|
|
17129
|
-
|
|
17130
|
-
|
|
17127
|
+
let body = pending && !pending.header ? Buffer.concat([...pending.chunks, datagramBody]) : datagramBody;
|
|
17128
|
+
if (pending?.header) {
|
|
17129
|
+
const taken = Math.min(pending.header.bytesToRead - pending.byteLength, body.length);
|
|
17130
|
+
pending.chunks.push(body.subarray(0, taken));
|
|
17131
|
+
pending.byteLength += taken;
|
|
17132
|
+
body = body.subarray(taken);
|
|
17133
|
+
if (pending.byteLength < pending.header.bytesToRead) {
|
|
17134
|
+
this.pendingByDataType.set(dataType, pending);
|
|
17131
17135
|
return;
|
|
17132
17136
|
}
|
|
17133
|
-
this.handleFrame(
|
|
17134
|
-
body = body.subarray(carryHeader.bytesToRead);
|
|
17137
|
+
this.handleFrame(pending.header, Buffer.concat(pending.chunks, pending.byteLength), dataType);
|
|
17135
17138
|
}
|
|
17136
17139
|
while (body.length >= P2P_DATA_HEADER_BYTES && body.subarray(0, 4).toString() === MAGIC_WORD) {
|
|
17137
17140
|
const header = parseDataFrameHeader(body);
|
|
17138
17141
|
const payload = body.subarray(P2P_DATA_HEADER_BYTES);
|
|
17139
17142
|
if (payload.length < header.bytesToRead) {
|
|
17140
|
-
this.pendingByDataType.set(dataType, { header,
|
|
17143
|
+
this.pendingByDataType.set(dataType, { header, chunks: [payload], byteLength: payload.length });
|
|
17141
17144
|
return;
|
|
17142
17145
|
}
|
|
17143
17146
|
this.handleFrame(header, payload.subarray(0, header.bytesToRead), dataType);
|
|
17144
17147
|
body = body.subarray(P2P_DATA_HEADER_BYTES + header.bytesToRead);
|
|
17145
17148
|
}
|
|
17146
17149
|
if (body.length > 0 && body.length < P2P_DATA_HEADER_BYTES && MAGIC_WORD.startsWith(body.subarray(0, 4).toString())) {
|
|
17147
|
-
this.pendingByDataType.set(dataType, {
|
|
17150
|
+
this.pendingByDataType.set(dataType, { chunks: [body], byteLength: body.length });
|
|
17148
17151
|
}
|
|
17149
17152
|
}
|
|
17150
17153
|
/**
|
|
@@ -20419,7 +20422,8 @@ var Fmp4Muxer = class {
|
|
|
20419
20422
|
fragTicks = 0;
|
|
20420
20423
|
// ticks accumulated in the open fragment
|
|
20421
20424
|
samples = [];
|
|
20422
|
-
|
|
20425
|
+
/** Ticks from the first video sample's start to the newest sample's end, at its provisional duration. */
|
|
20426
|
+
videoTicks = 0;
|
|
20423
20427
|
audioRequested;
|
|
20424
20428
|
audioCodec;
|
|
20425
20429
|
/** Decoder config of an AAC-ELD track, taken from its frames; absent for AAC-LC, whose `esds` config is fixed. */
|
|
@@ -20443,6 +20447,10 @@ var Fmp4Muxer = class {
|
|
|
20443
20447
|
* Push one access unit. Returns any completed segments: the `init` on the first keyframe, and/or a
|
|
20444
20448
|
* media fragment when this frame closed the open one. Returns `undefined` if nothing is emitted yet
|
|
20445
20449
|
* (e.g. delta frames before the first keyframe).
|
|
20450
|
+
*
|
|
20451
|
+
* A sample lasts until the next frame's `timestampMs`, measured from the first keyframe's, so the video
|
|
20452
|
+
* timeline follows the arrival clock; a frame that shares the previous one's timestamp leaves that
|
|
20453
|
+
* sample one tick long, and the next frame's duration absorbs the difference.
|
|
20446
20454
|
*/
|
|
20447
20455
|
push(frame, timestampMs = now()) {
|
|
20448
20456
|
if (frame.codec === "av1")
|
|
@@ -20461,15 +20469,14 @@ var Fmp4Muxer = class {
|
|
|
20461
20469
|
this.height = declared?.height ?? frame.height;
|
|
20462
20470
|
this.firstVideoTimestampMs = timestampMs;
|
|
20463
20471
|
}
|
|
20464
|
-
if (this.
|
|
20465
|
-
const
|
|
20466
|
-
|
|
20467
|
-
|
|
20468
|
-
|
|
20469
|
-
|
|
20470
|
-
|
|
20472
|
+
if (this.firstVideoTimestampMs !== void 0 && this.samples.length) {
|
|
20473
|
+
const previous = this.samples[this.samples.length - 1];
|
|
20474
|
+
const arrival = Math.round((timestampMs - this.firstVideoTimestampMs) * (TIMESCALE / 1e3));
|
|
20475
|
+
const duration = Math.max(1, arrival - (this.videoTicks - previous.duration));
|
|
20476
|
+
this.fragTicks += duration - previous.duration;
|
|
20477
|
+
this.videoTicks += duration - previous.duration;
|
|
20478
|
+
previous.duration = duration;
|
|
20471
20479
|
}
|
|
20472
|
-
this.lastVideoTimestampMs = timestampMs;
|
|
20473
20480
|
let fragment;
|
|
20474
20481
|
if (frame.keyframe && this.samples.length > 0 && this.fragTicks >= this.fragmentTicks) {
|
|
20475
20482
|
if (!this.initSent) {
|
|
@@ -20481,6 +20488,7 @@ var Fmp4Muxer = class {
|
|
|
20481
20488
|
}
|
|
20482
20489
|
this.samples.push({ data: annexbToAvcc(frame.data), duration: this.firstDuration, keyframe: frame.keyframe });
|
|
20483
20490
|
this.fragTicks += this.firstDuration;
|
|
20491
|
+
this.videoTicks += this.firstDuration;
|
|
20484
20492
|
if (!this.initSent && (!this.audioRequested || this.audioCodec || this.audioDisabled)) {
|
|
20485
20493
|
init = this.buildInit();
|
|
20486
20494
|
this.initSent = true;
|