@mega-yfue/eufy-sdk 0.5.0-beta.13 → 0.5.0-beta.14
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 +16 -7
- package/dist/index.js +24 -11
- package/dist/index.js.map +2 -2
- package/dist/transport/p2p/fmp4.d.ts +6 -1
- package/package.json +1 -1
package/dist/core/contracts.d.ts
CHANGED
|
@@ -551,16 +551,25 @@ export type AudioCodec = "aac-lc" | "aac-eld" | "g711a";
|
|
|
551
551
|
/**
|
|
552
552
|
* One audio access unit, carrying the codec the station declared for it.
|
|
553
553
|
*
|
|
554
|
-
* Sample rate and channel count are
|
|
555
|
-
* 16 kHz mono for every audio type rather than reading them
|
|
556
|
-
*
|
|
554
|
+
* Sample rate and channel count are absent for `aac-lc` and `g711a`: they are not on the wire, and the v6 app
|
|
555
|
+
* assumes 16 kHz mono for every audio type rather than reading them. An `aac-lc` frame is one ADTS frame and
|
|
556
|
+
* `g711a` is raw A-law. An `aac-eld` frame is one raw access unit with no transport framing, so it carries the
|
|
557
|
+
* AudioSpecificConfig that decodes it.
|
|
557
558
|
*/
|
|
558
|
-
export
|
|
559
|
+
export type LiveAudioFrame = {
|
|
559
560
|
/** Codec declared in the frame header. */
|
|
560
|
-
codec:
|
|
561
|
-
/**
|
|
561
|
+
codec: "aac-lc" | "g711a";
|
|
562
|
+
/** One ADTS frame for `aac-lc`, raw A-law samples for `g711a`. */
|
|
562
563
|
data: Buffer;
|
|
563
|
-
|
|
564
|
+
config?: undefined;
|
|
565
|
+
} | {
|
|
566
|
+
/** Codec declared in the frame header. */
|
|
567
|
+
codec: "aac-eld";
|
|
568
|
+
/** One raw AAC-ELD access unit. */
|
|
569
|
+
data: Buffer;
|
|
570
|
+
/** AudioSpecificConfig (ISO/IEC 14496-3) that decodes `data`. */
|
|
571
|
+
config: Buffer;
|
|
572
|
+
};
|
|
564
573
|
/**
|
|
565
574
|
* One fragmented-MP4 (CMAF) output unit from the native muxer. `init` (the `ftyp`+`moov` init
|
|
566
575
|
* segment) is present exactly once, on the first fragment; every fragment carries a `moof`+`mdat`
|
package/dist/index.js
CHANGED
|
@@ -17931,6 +17931,7 @@ var AUDIO_HEADER_LEN = 16;
|
|
|
17931
17931
|
var AUDIO_TYPE_OFFSET = 5;
|
|
17932
17932
|
var SC4 = Buffer.from([0, 0, 0, 1]);
|
|
17933
17933
|
var SC3 = Buffer.from([0, 0, 1]);
|
|
17934
|
+
var AAC_ELD_AUDIO_SPECIFIC_CONFIG = Buffer.from("f8f03000", "hex");
|
|
17934
17935
|
var AUDIO_CODECS = { 0: "aac-lc", 2: "g711a", 7: "aac-eld" };
|
|
17935
17936
|
var MAX_TRACED_DECODE_FAILURES = 3;
|
|
17936
17937
|
var DEFAULT_KEEPALIVE_MS = 3e3;
|
|
@@ -18159,7 +18160,7 @@ var LiveStream = class extends EventEmitter3 {
|
|
|
18159
18160
|
if (!codec) {
|
|
18160
18161
|
this.logger.debug(`[live] dropping audio frame: unknown codec id ${codecId ?? "missing"}`);
|
|
18161
18162
|
} else {
|
|
18162
|
-
this.emit("audio", { codec, data: audio });
|
|
18163
|
+
this.emit("audio", codec === "aac-eld" ? { codec, data: audio, config: AAC_ELD_AUDIO_SPECIFIC_CONFIG } : { codec, data: audio });
|
|
18163
18164
|
}
|
|
18164
18165
|
}
|
|
18165
18166
|
}
|
|
@@ -20177,7 +20178,7 @@ var CODEC_BOXES = {
|
|
|
20177
20178
|
h264: { sample: "avc1", config: "avcC" },
|
|
20178
20179
|
h265: { sample: "hvc1", config: "hvcC" }
|
|
20179
20180
|
};
|
|
20180
|
-
var AAC_ELD_SAMPLES_PER_FRAME =
|
|
20181
|
+
var AAC_ELD_SAMPLES_PER_FRAME = 480;
|
|
20181
20182
|
var ADTS_FREQUENCY_INDEX_16K = 8;
|
|
20182
20183
|
var ADTS_CHANNELS_MONO = 1;
|
|
20183
20184
|
var Fmp4Muxer = class {
|
|
@@ -20195,6 +20196,8 @@ var Fmp4Muxer = class {
|
|
|
20195
20196
|
lastVideoTimestampMs;
|
|
20196
20197
|
audioRequested;
|
|
20197
20198
|
audioCodec;
|
|
20199
|
+
/** Decoder config of an AAC-ELD track, taken from its frames; absent for AAC-LC, whose `esds` config is fixed. */
|
|
20200
|
+
audioConfig;
|
|
20198
20201
|
audioDisabled = false;
|
|
20199
20202
|
audioSamples = [];
|
|
20200
20203
|
audioBaseDecodeTime = 0;
|
|
@@ -20261,7 +20264,10 @@ var Fmp4Muxer = class {
|
|
|
20261
20264
|
}
|
|
20262
20265
|
return void 0;
|
|
20263
20266
|
}
|
|
20264
|
-
/**
|
|
20267
|
+
/**
|
|
20268
|
+
* Add one station-declared AAC access unit to the audio track: an ADTS frame for AAC-LC, a raw access unit
|
|
20269
|
+
* described by its frame's config for AAC-ELD. G.711 remains available via `live()`.
|
|
20270
|
+
*/
|
|
20265
20271
|
pushAudio(frame, timestampMs = now()) {
|
|
20266
20272
|
if (!this.audioRequested || this.audioDisabled)
|
|
20267
20273
|
return void 0;
|
|
@@ -20277,12 +20283,19 @@ var Fmp4Muxer = class {
|
|
|
20277
20283
|
if (this.audioCodec && this.audioCodec !== frame.codec) {
|
|
20278
20284
|
return this.disableAudio();
|
|
20279
20285
|
}
|
|
20280
|
-
|
|
20281
|
-
if (
|
|
20282
|
-
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
|
|
20286
|
+
let sample;
|
|
20287
|
+
if (frame.codec === "aac-eld") {
|
|
20288
|
+
this.audioConfig = frame.config;
|
|
20289
|
+
sample = frame.data;
|
|
20290
|
+
} else {
|
|
20291
|
+
const header = parseAdtsHeader(frame.data);
|
|
20292
|
+
if (!header || header.frameLength > frame.data.length) {
|
|
20293
|
+
throw new Error(`fMP4 muxer: ${frame.codec} frame is not a complete ADTS access unit`);
|
|
20294
|
+
}
|
|
20295
|
+
if (header.frequencyIndex !== ADTS_FREQUENCY_INDEX_16K || header.channels !== ADTS_CHANNELS_MONO) {
|
|
20296
|
+
return this.disableAudio();
|
|
20297
|
+
}
|
|
20298
|
+
sample = frame.data.subarray(header.headerLength, header.frameLength);
|
|
20286
20299
|
}
|
|
20287
20300
|
this.audioCodec = frame.codec;
|
|
20288
20301
|
this.firstAudioTimestampMs ??= timestampMs;
|
|
@@ -20294,7 +20307,7 @@ var Fmp4Muxer = class {
|
|
|
20294
20307
|
this.audioSamples[this.audioSamples.length - 1].duration = measured;
|
|
20295
20308
|
}
|
|
20296
20309
|
this.audioSamples.push({
|
|
20297
|
-
data:
|
|
20310
|
+
data: sample,
|
|
20298
20311
|
duration: frame.codec === "aac-eld" ? AAC_ELD_SAMPLES_PER_FRAME : AAC_SAMPLES_PER_FRAME,
|
|
20299
20312
|
keyframe: true
|
|
20300
20313
|
});
|
|
@@ -20567,7 +20580,7 @@ var Fmp4Muxer = class {
|
|
|
20567
20580
|
return box("mp4a", head, this.esds());
|
|
20568
20581
|
}
|
|
20569
20582
|
esds() {
|
|
20570
|
-
const config = this.
|
|
20583
|
+
const config = this.audioConfig ?? Buffer.from([20, 8]);
|
|
20571
20584
|
const specific = descriptor(5, config);
|
|
20572
20585
|
const decoder = descriptor(4, Buffer.concat([Buffer.from([64, 21, 0, 0, 0]), u32(64e3), u32(32e3), specific]));
|
|
20573
20586
|
const sl = descriptor(6, Buffer.from([2]));
|