@mega-yfue/eufy-sdk 0.5.0-beta.20 → 0.5.0-beta.21
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/core/contracts.d.ts
CHANGED
|
@@ -171,9 +171,10 @@ export declare class RecordingDownloadError extends Error {
|
|
|
171
171
|
* A recording downloaded from the station, as elementary streams.
|
|
172
172
|
*
|
|
173
173
|
* `video` is Annex-B H.264 in decode order, `audio` AAC-LC 16 kHz mono in ADTS framing (absent when the
|
|
174
|
-
* recording carried none that could be decoded). `frames` counts the distinct video
|
|
175
|
-
* `missingFrames`
|
|
176
|
-
*
|
|
174
|
+
* recording carried none that could be decoded). `frames` counts the distinct video sequences emitted.
|
|
175
|
+
* `missingFrames` counts gaps between received sequences and received sequences that yielded no usable
|
|
176
|
+
* picture, including at either end. `durationMs` spans the first to the last emitted picture by the
|
|
177
|
+
* camera's own timestamps; `fps` is derived from those stamps.
|
|
177
178
|
*/
|
|
178
179
|
export interface RecordingDownload {
|
|
179
180
|
video: Buffer;
|
package/dist/index.js
CHANGED
|
@@ -18670,9 +18670,11 @@ function decodeRecording(frames, eccPrivateKeyHex) {
|
|
|
18670
18670
|
if (eccPrivateKey.length !== 32)
|
|
18671
18671
|
throw new RecordingDownloadError("undecodable", "the cipher key is not a P-256 key");
|
|
18672
18672
|
const decoder = new VideoFrameDecoder(eccPrivateKey);
|
|
18673
|
+
const assembler = new AccessUnitAssembler();
|
|
18673
18674
|
const video = [];
|
|
18674
18675
|
const audio = [];
|
|
18675
18676
|
const numbers = /* @__PURE__ */ new Set();
|
|
18677
|
+
const receivedNumbers = /* @__PURE__ */ new Set();
|
|
18676
18678
|
let firstStamp;
|
|
18677
18679
|
let lastStamp;
|
|
18678
18680
|
for (const { commandId, raw } of frames) {
|
|
@@ -18680,14 +18682,15 @@ function decodeRecording(frames, eccPrivateKeyHex) {
|
|
|
18680
18682
|
const header = parseVideoFrameHeader(raw);
|
|
18681
18683
|
if (!header)
|
|
18682
18684
|
continue;
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18685
|
+
receivedNumbers.add(header.sequence);
|
|
18686
|
+
const units = assembler.push(raw, (payload) => header.keyframe ? decoder.decodeFrame(payload)?.h264 : payload.length >= VIDEO_HEADER_LEN2 + header.payloadLength ? payload.subarray(VIDEO_HEADER_LEN2, VIDEO_HEADER_LEN2 + header.payloadLength) : void 0);
|
|
18687
|
+
for (const unit of units) {
|
|
18688
|
+
video.push(unit.data);
|
|
18689
|
+
numbers.add(header.sequence);
|
|
18690
|
+
const stamp = raw.readUIntLE(14, 6);
|
|
18691
|
+
firstStamp ??= stamp;
|
|
18692
|
+
lastStamp = stamp;
|
|
18693
|
+
}
|
|
18691
18694
|
} else if (commandId === CommandType.CMD_AUDIO_FRAME) {
|
|
18692
18695
|
const mediaKey = decoder.currentMediaKey;
|
|
18693
18696
|
if (!mediaKey || raw.length < AUDIO_BODY_START || raw[5] !== AUDIO_CODEC_AAC_LC)
|
|
@@ -18703,9 +18706,10 @@ function decodeRecording(frames, eccPrivateKeyHex) {
|
|
|
18703
18706
|
if (!video.length)
|
|
18704
18707
|
throw new RecordingDownloadError("undecodable", "no video frame of the recording decoded");
|
|
18705
18708
|
const ordered = [...numbers];
|
|
18706
|
-
|
|
18707
|
-
|
|
18708
|
-
|
|
18709
|
+
const received = [...receivedNumbers];
|
|
18710
|
+
let missingFrames = receivedNumbers.size - numbers.size;
|
|
18711
|
+
for (let i = 1; i < received.length; i++) {
|
|
18712
|
+
const step = received[i] - received[i - 1] & 65535;
|
|
18709
18713
|
if (step > 1 && step < 32768)
|
|
18710
18714
|
missingFrames += step - 1;
|
|
18711
18715
|
}
|