@camera.ui/common 0.0.13 → 0.0.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/cameraUtils/ffmpeg-process.d.ts +23 -0
- package/dist/cameraUtils/ffmpeg-process.js +72 -0
- package/dist/cameraUtils/ffmpeg-process.js.map +1 -0
- package/dist/{utils → cameraUtils}/ffmpeg.d.ts +2 -0
- package/dist/{utils → cameraUtils}/ffmpeg.js +16 -0
- package/dist/cameraUtils/ffmpeg.js.map +1 -0
- package/dist/cameraUtils/index.d.ts +10 -0
- package/dist/cameraUtils/index.js +11 -0
- package/dist/cameraUtils/index.js.map +1 -0
- package/dist/cameraUtils/mp4.d.ts +10 -0
- package/dist/cameraUtils/mp4.js +53 -0
- package/dist/cameraUtils/mp4.js.map +1 -0
- package/dist/cameraUtils/ports.d.ts +7 -0
- package/dist/cameraUtils/ports.js +43 -0
- package/dist/cameraUtils/ports.js.map +1 -0
- package/dist/cameraUtils/processor.d.ts +49 -0
- package/dist/cameraUtils/processor.js +154 -0
- package/dist/cameraUtils/processor.js.map +1 -0
- package/dist/cameraUtils/return-audio-transcoder.d.ts +40 -0
- package/dist/cameraUtils/return-audio-transcoder.js +84 -0
- package/dist/cameraUtils/return-audio-transcoder.js.map +1 -0
- package/dist/cameraUtils/rtp-splitter.d.ts +35 -0
- package/dist/cameraUtils/rtp-splitter.js +86 -0
- package/dist/cameraUtils/rtp-splitter.js.map +1 -0
- package/dist/cameraUtils/rtp.d.ts +3 -0
- package/dist/cameraUtils/rtp.js +16 -0
- package/dist/cameraUtils/rtp.js.map +1 -0
- package/dist/cameraUtils/srtp.d.ts +8 -0
- package/dist/cameraUtils/srtp.js +22 -0
- package/dist/cameraUtils/srtp.js.map +1 -0
- package/dist/cameraUtils/utils.d.ts +1 -0
- package/dist/cameraUtils/utils.js +15 -0
- package/dist/cameraUtils/utils.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +9 -2
- package/dist/utils/ffmpeg.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface FfmpegProcessOptions {
|
|
2
|
+
ffmpegPath: string;
|
|
3
|
+
ffmpegArgs: (string | number)[];
|
|
4
|
+
logger?: {
|
|
5
|
+
error: (log: string) => unknown;
|
|
6
|
+
info: (log: string) => unknown;
|
|
7
|
+
};
|
|
8
|
+
logLabel?: string;
|
|
9
|
+
exitCallback?: (code: number | null, signal: string | null) => unknown;
|
|
10
|
+
stdoutCallback?: (data: any) => unknown;
|
|
11
|
+
startedCallback?: () => unknown;
|
|
12
|
+
}
|
|
13
|
+
export declare class FfmpegProcess {
|
|
14
|
+
readonly options: FfmpegProcessOptions;
|
|
15
|
+
private ff;
|
|
16
|
+
private processSubscription;
|
|
17
|
+
private started;
|
|
18
|
+
private stopped;
|
|
19
|
+
private exited;
|
|
20
|
+
constructor(options: FfmpegProcessOptions);
|
|
21
|
+
stop(): void;
|
|
22
|
+
writeStdin(input: string): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
const noop = () => null;
|
|
4
|
+
const onGlobalProcessStopped = new Subject();
|
|
5
|
+
// register a single event listener, rather than listener per ffmpeg process
|
|
6
|
+
// this helps avoid a warning for hitting too many listeners
|
|
7
|
+
process.on('exit', () => onGlobalProcessStopped.next(null));
|
|
8
|
+
export class FfmpegProcess {
|
|
9
|
+
options;
|
|
10
|
+
ff;
|
|
11
|
+
processSubscription = onGlobalProcessStopped.subscribe(() => this.stop());
|
|
12
|
+
started = false;
|
|
13
|
+
stopped = false;
|
|
14
|
+
exited = false;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.ff = spawn(options.ffmpegPath, options.ffmpegArgs.map((x) => x.toString()));
|
|
18
|
+
const { logger, logLabel } = options;
|
|
19
|
+
const logError = logger?.error || noop;
|
|
20
|
+
const logInfo = logger?.info || noop;
|
|
21
|
+
const logPrefix = logLabel ? `${logLabel}: ` : '';
|
|
22
|
+
if (options.stdoutCallback) {
|
|
23
|
+
const { stdoutCallback } = options;
|
|
24
|
+
this.ff.stdout.on('data', (data) => {
|
|
25
|
+
stdoutCallback(data);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
this.ff.stderr.on('data', (data) => {
|
|
29
|
+
if (!this.started) {
|
|
30
|
+
this.started = true;
|
|
31
|
+
options.startedCallback?.();
|
|
32
|
+
}
|
|
33
|
+
logInfo(logPrefix + data);
|
|
34
|
+
});
|
|
35
|
+
this.ff.stdin.on('error', (error) => {
|
|
36
|
+
if (!error.message.includes('EPIPE')) {
|
|
37
|
+
logError(logPrefix + error.message);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
this.ff.on('exit', (code, signal) => {
|
|
41
|
+
this.exited = true;
|
|
42
|
+
this.options.exitCallback?.(code, signal);
|
|
43
|
+
if (!code || code === 255) {
|
|
44
|
+
logInfo(logPrefix + 'stopped gracefully');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
logError(logPrefix + `exited with code ${code} and signal ${signal}`);
|
|
48
|
+
}
|
|
49
|
+
this.stop();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
stop() {
|
|
53
|
+
if (this.stopped) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.stopped = true;
|
|
57
|
+
this.processSubscription.unsubscribe();
|
|
58
|
+
this.ff.stderr.pause();
|
|
59
|
+
this.ff.stdout.pause();
|
|
60
|
+
if (!this.exited) {
|
|
61
|
+
this.ff.kill();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
writeStdin(input) {
|
|
65
|
+
if (this.stopped) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.ff.stdin.write(input);
|
|
69
|
+
this.ff.stdin.end();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=ffmpeg-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ffmpeg-process.js","sourceRoot":"","sources":["../../src/cameraUtils/ffmpeg-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAI/B,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;AACxB,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAAE,CAAC;AAE7C,4EAA4E;AAC5E,4DAA4D;AAC5D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAe5D,MAAM,OAAO,aAAa;IAOI;IANpB,EAAE,CAAiC;IACnC,mBAAmB,GAAG,sBAAsB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1E,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAG,KAAK,CAAC;IAChB,MAAM,GAAG,KAAK,CAAC;IAEvB,YAA4B,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;QACvD,IAAI,CAAC,EAAE,GAAG,KAAK,CACb,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAC5C,CAAC;QAEF,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QACrC,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,EAAE,IA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AAO,CAAC,SAAS,GAAG,oBAAoB,CAAC,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,SAAS,GAAG,oBAAoB,IAAI,eAAe,MAAM,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,IAAI;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,CAAC;QAEvC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEvB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAEM,UAAU,CAAC,KAAa;QAC7B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -6,4 +6,6 @@ export interface HardwareSource {
|
|
|
6
6
|
export interface HardwareResponse {
|
|
7
7
|
sources: HardwareSource[];
|
|
8
8
|
}
|
|
9
|
+
export declare function doesFfmpegSupportCodec(codec: string, ffmpegPath: string): Promise<boolean>;
|
|
10
|
+
export declare function isFfmpegInstalled(ffmpegPath: string): Promise<boolean>;
|
|
9
11
|
export declare function getHwaccelInfo(go2rtcEndpoint: string): Promise<FfmpegArgs>;
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import { exec } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
const execAwait = promisify(exec);
|
|
4
|
+
export async function doesFfmpegSupportCodec(codec, ffmpegPath) {
|
|
5
|
+
const output = await execAwait(`${ffmpegPath} -codecs`);
|
|
6
|
+
return output.stdout.includes(codec);
|
|
7
|
+
}
|
|
8
|
+
export async function isFfmpegInstalled(ffmpegPath) {
|
|
9
|
+
try {
|
|
10
|
+
await execAwait(`${ffmpegPath} -codecs`);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
1
17
|
export async function getHwaccelInfo(go2rtcEndpoint) {
|
|
2
18
|
let hwaccel = 'auto';
|
|
3
19
|
let hwaccelArgs = [];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ffmpeg.js","sourceRoot":"","sources":["../../src/cameraUtils/ffmpeg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAWlC,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,KAAa,EAAE,UAAkB;IAC5E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,UAAU,UAAU,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,UAAkB;IACxD,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,GAAG,UAAU,UAAU,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,cAAsB;IACzD,IA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AQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBACvC,OAAO,GAAG,MAAM,CAAC;oBACjB,WAAW,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;oBACjD,aAAa,GAAG,4BAA4B,CAAC;oBAC7C,MAAM;gBACR,CAAC;qBAAM,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC1C,uBAAuB;oBACvB,oBAAoB;oBACpB,kCAAkC;oBAClC,iBAAiB;oBACjB,MAAM;gBACR,CAAC;qBAAM,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;oBACxC,OAAO,GAAG,OAAO,CAAC;oBAClB,oBAAoB;oBACpB,kCAAkC;oBAClC,iBAAiB;oBACjB,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,aAAa;IACf,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './ffmpeg-process.js';
|
|
2
|
+
export * from './ffmpeg.js';
|
|
3
|
+
export * from './mp4.js';
|
|
4
|
+
export * from './ports.js';
|
|
5
|
+
export * from './processor.js';
|
|
6
|
+
export * from './return-audio-transcoder.js';
|
|
7
|
+
export * from './rtp-splitter.js';
|
|
8
|
+
export * from './rtp.js';
|
|
9
|
+
export * from './srtp.js';
|
|
10
|
+
export * from './utils.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './ffmpeg-process.js';
|
|
2
|
+
export * from './ffmpeg.js';
|
|
3
|
+
export * from './mp4.js';
|
|
4
|
+
export * from './ports.js';
|
|
5
|
+
export * from './processor.js';
|
|
6
|
+
export * from './return-audio-transcoder.js';
|
|
7
|
+
export * from './rtp-splitter.js';
|
|
8
|
+
export * from './rtp.js';
|
|
9
|
+
export * from './srtp.js';
|
|
10
|
+
export * from './utils.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cameraUtils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const NAL_TYPE_STAP_A = 24;
|
|
2
|
+
export declare const NAL_TYPE_FU_A = 28;
|
|
3
|
+
export declare const NAL_TYPE_NON_IDR = 1;
|
|
4
|
+
export declare const NAL_TYPE_IDR = 5;
|
|
5
|
+
export declare const NAL_TYPE_SEI = 6;
|
|
6
|
+
export declare const NAL_TYPE_SPS = 7;
|
|
7
|
+
export declare const NAL_TYPE_PPS = 8;
|
|
8
|
+
export declare const NAL_TYPE_DELIMITER = 9;
|
|
9
|
+
export declare const allowedNaluTypes: number[];
|
|
10
|
+
export declare function checkMp4StartsWithKeyFrame(mp4: Buffer, ffmpegPath: string): Promise<boolean>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { timeoutPromise } from './utils.js';
|
|
3
|
+
// https://yumichan.net/video-processing/video-compression/introduction-to-h264-nal-unit/
|
|
4
|
+
export const NAL_TYPE_STAP_A = 24;
|
|
5
|
+
export const NAL_TYPE_FU_A = 28;
|
|
6
|
+
export const NAL_TYPE_NON_IDR = 1;
|
|
7
|
+
export const NAL_TYPE_IDR = 5;
|
|
8
|
+
export const NAL_TYPE_SEI = 6;
|
|
9
|
+
export const NAL_TYPE_SPS = 7;
|
|
10
|
+
export const NAL_TYPE_PPS = 8;
|
|
11
|
+
export const NAL_TYPE_DELIMITER = 9;
|
|
12
|
+
export const allowedNaluTypes = [NAL_TYPE_STAP_A, NAL_TYPE_SPS, NAL_TYPE_PPS, NAL_TYPE_SEI, NAL_TYPE_DELIMITER];
|
|
13
|
+
export async function checkMp4StartsWithKeyFrame(mp4, ffmpegPath) {
|
|
14
|
+
const cp = spawn(ffmpegPath, ['-hide_banner', '-f', 'mp4', '-i', 'pipe:3', '-vcodec', 'copy', '-f', 'h264', 'pipe:4'], {
|
|
15
|
+
stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'],
|
|
16
|
+
});
|
|
17
|
+
const input = cp.stdio[3];
|
|
18
|
+
const output = cp.stdio[4];
|
|
19
|
+
const buffers = [];
|
|
20
|
+
input.write(mp4);
|
|
21
|
+
input.end();
|
|
22
|
+
output.on('data', (data) => buffers.push(data));
|
|
23
|
+
try {
|
|
24
|
+
await timeoutPromise(1000, new Promise((resolve) => cp.on('exit', resolve)));
|
|
25
|
+
const h264 = Buffer.concat(buffers);
|
|
26
|
+
let offset = 0;
|
|
27
|
+
while (offset < h264.length - 6) {
|
|
28
|
+
if (h264.readInt32BE(offset) !== 1) {
|
|
29
|
+
offset++;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
offset += 4;
|
|
33
|
+
let naluType = h264.readUInt8(offset) & 0x1f;
|
|
34
|
+
if (naluType === NAL_TYPE_FU_A) {
|
|
35
|
+
offset++;
|
|
36
|
+
naluType = h264.readUInt8(offset) & 0x1f;
|
|
37
|
+
}
|
|
38
|
+
if (naluType === NAL_TYPE_IDR) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (allowedNaluTypes.includes(naluType)) {
|
|
42
|
+
offset++;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
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OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Socket } from 'node:dgram';
|
|
2
|
+
export declare function reservePorts({ count, type, attemptNumber, }?: {
|
|
3
|
+
count?: number;
|
|
4
|
+
type?: 'udp' | 'tcp';
|
|
5
|
+
attemptNumber?: number;
|
|
6
|
+
}): Promise<number[]>;
|
|
7
|
+
export declare function bindToPort(socket: Socket, address?: string): Promise<number>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { pickPort } from 'pick-port';
|
|
2
|
+
// Need to reserve ports in sequence because ffmpeg uses the next port up by default. If it's taken, ffmpeg will error
|
|
3
|
+
export async function reservePorts({ count = 1, type = 'udp', attemptNumber = 0, } = {}) {
|
|
4
|
+
if (attemptNumber > 100) {
|
|
5
|
+
throw new Error('Failed to reserve ports after 100 tries');
|
|
6
|
+
}
|
|
7
|
+
const pickPortOptions = {
|
|
8
|
+
type,
|
|
9
|
+
reserveTimeout: 15, // 15 seconds is max setup time for HomeKit streams, so the port should be in use by then
|
|
10
|
+
}, port = await pickPort(pickPortOptions), ports = [port], tryAgain = () => {
|
|
11
|
+
return reservePorts({
|
|
12
|
+
count,
|
|
13
|
+
type,
|
|
14
|
+
attemptNumber: attemptNumber + 1,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
for (let i = 1; i < count; i++) {
|
|
18
|
+
try {
|
|
19
|
+
const targetConsecutivePort = port + i, openPort = await pickPort({
|
|
20
|
+
...pickPortOptions,
|
|
21
|
+
minPort: targetConsecutivePort,
|
|
22
|
+
maxPort: targetConsecutivePort,
|
|
23
|
+
});
|
|
24
|
+
ports.push(openPort);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// can't reserve next port, bail and get another set
|
|
28
|
+
return tryAgain();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return ports;
|
|
32
|
+
}
|
|
33
|
+
export function bindToPort(socket, address = '127.0.0.1') {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
socket.on('error', reject);
|
|
36
|
+
// 0 means select a random open port
|
|
37
|
+
socket.bind(0, address, () => {
|
|
38
|
+
const { port } = socket.address();
|
|
39
|
+
resolve(port);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=ports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/cameraUtils/ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAKrC,uHAAuH;AACvH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,KAAK,GAAG,CAAC,EACT,IAAI,GAAG,KAAK,EACZ,aAAa,GAAG,CAAC,MAKf,EAAE;IACJ,IAAI,aAAa,GAAG,GAAG,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,eAAe,GAAG;QACpB,IAAI;QACJ,cAAc,EAAE,EAAE,EAAE,yFAAyF;KAC9G,EACD,IAAI,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,EACtC,KAAK,GAAG,CAAC,IAAI,CAAC,EACd,QAAQ,GAAG,GAAG,EAAE;QACd,OAAO,YAAY,CAAC;YAClB,KAAK;YACL,IAAI;YACJ,aAAa,EAAE,aAAa,GAAG,CAAC;SACjC,CAAC,CAAC;IACL,CAAC,CAAC;IAEJ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC;YACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,EACpC,QAAQ,GAAG,MAAM,QAAQ,CAAC;gBACxB,GAAG,eAAe;gBAClB,OAAO,EAAE,qBAAqB;gBAC9B,OAAO,EAAE,qBAAqB;aAC/B,CAAC,CAAC;YAEL,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,oDAAoD;YACpD,OAAO,QAAQ,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,OAAO,GAAG,WAAW;IAC9D,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAE3B,oCAAoC;QACpC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE;YAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RtpPacket } from 'werift';
|
|
2
|
+
import type { Logger } from '../logger/index.js';
|
|
3
|
+
import type { RtpSplitter } from './rtp-splitter.js';
|
|
4
|
+
import type { SrtpOptions } from './srtp.js';
|
|
5
|
+
export declare function getSessionConfig(srtpOptions: SrtpOptions): {
|
|
6
|
+
keys: {
|
|
7
|
+
localMasterKey: Buffer;
|
|
8
|
+
localMasterSalt: Buffer;
|
|
9
|
+
remoteMasterKey: Buffer;
|
|
10
|
+
remoteMasterSalt: Buffer;
|
|
11
|
+
};
|
|
12
|
+
profile: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function getDurationSeconds(start: number): number;
|
|
15
|
+
export declare class AudioProcessor {
|
|
16
|
+
private audioSsrc;
|
|
17
|
+
private audioSrtp;
|
|
18
|
+
private audioSplitter;
|
|
19
|
+
private targetAddress;
|
|
20
|
+
private targetPort;
|
|
21
|
+
private payloadType;
|
|
22
|
+
private isOpus;
|
|
23
|
+
private packetTime;
|
|
24
|
+
private logger;
|
|
25
|
+
private audioSrtpSession;
|
|
26
|
+
private sequenceNumber;
|
|
27
|
+
private timestamp;
|
|
28
|
+
private buffer;
|
|
29
|
+
constructor(audioSsrc: number, audioSrtp: SrtpOptions, audioSplitter: RtpSplitter, targetAddress: string, targetPort: number, payloadType: number, isOpus: boolean, packetTime: number, logger: Logger);
|
|
30
|
+
processPacket(data: Buffer): void;
|
|
31
|
+
private process20ms;
|
|
32
|
+
private process60ms;
|
|
33
|
+
private sendPacket;
|
|
34
|
+
}
|
|
35
|
+
export declare class VideoProcessor {
|
|
36
|
+
private videoSsrc;
|
|
37
|
+
private videoSrtp;
|
|
38
|
+
private videoSplitter;
|
|
39
|
+
private targetAddress;
|
|
40
|
+
private targetPort;
|
|
41
|
+
private mtu;
|
|
42
|
+
private payloadType;
|
|
43
|
+
private logger;
|
|
44
|
+
private videoSrtpSession;
|
|
45
|
+
private sequenceNumber;
|
|
46
|
+
constructor(videoSsrc: number, videoSrtp: SrtpOptions, videoSplitter: RtpSplitter, targetAddress: string, targetPort: number, mtu: number, payloadType: number, logger: Logger);
|
|
47
|
+
processPacket(rtp: RtpPacket): void;
|
|
48
|
+
private fragmentPacket;
|
|
49
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { RtpHeader, RtpPacket, SrtpSession } from 'werift';
|
|
2
|
+
export function getSessionConfig(srtpOptions) {
|
|
3
|
+
return {
|
|
4
|
+
keys: {
|
|
5
|
+
localMasterKey: srtpOptions.srtpKey,
|
|
6
|
+
localMasterSalt: srtpOptions.srtpSalt,
|
|
7
|
+
remoteMasterKey: srtpOptions.srtpKey,
|
|
8
|
+
remoteMasterSalt: srtpOptions.srtpSalt,
|
|
9
|
+
},
|
|
10
|
+
profile: 1,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function getDurationSeconds(start) {
|
|
14
|
+
return (Date.now() - start) / 1000;
|
|
15
|
+
}
|
|
16
|
+
export class AudioProcessor {
|
|
17
|
+
audioSsrc;
|
|
18
|
+
audioSrtp;
|
|
19
|
+
audioSplitter;
|
|
20
|
+
targetAddress;
|
|
21
|
+
targetPort;
|
|
22
|
+
payloadType;
|
|
23
|
+
isOpus;
|
|
24
|
+
packetTime;
|
|
25
|
+
logger;
|
|
26
|
+
audioSrtpSession;
|
|
27
|
+
sequenceNumber = Math.floor(Math.random() * 65536);
|
|
28
|
+
timestamp = 0;
|
|
29
|
+
buffer = [];
|
|
30
|
+
constructor(audioSsrc, audioSrtp, audioSplitter, targetAddress, targetPort, payloadType, isOpus, packetTime, logger) {
|
|
31
|
+
this.audioSsrc = audioSsrc;
|
|
32
|
+
this.audioSrtp = audioSrtp;
|
|
33
|
+
this.audioSplitter = audioSplitter;
|
|
34
|
+
this.targetAddress = targetAddress;
|
|
35
|
+
this.targetPort = targetPort;
|
|
36
|
+
this.payloadType = payloadType;
|
|
37
|
+
this.isOpus = isOpus;
|
|
38
|
+
this.packetTime = packetTime;
|
|
39
|
+
this.logger = logger;
|
|
40
|
+
this.audioSrtpSession = new SrtpSession(getSessionConfig(this.audioSrtp));
|
|
41
|
+
if (this.isOpus) {
|
|
42
|
+
this.logger.log(`AudioProcessor created with OPUS codec, audio will be split into ${this.packetTime}ms frames`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.logger.log('AudioProcessor created with AAC codec, audio will be sent as is');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
processPacket(data) {
|
|
49
|
+
const rtp = RtpPacket.deSerialize(data);
|
|
50
|
+
if (this.isOpus) {
|
|
51
|
+
if (this.packetTime === 20) {
|
|
52
|
+
this.process20ms(rtp);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.process60ms(rtp);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.sendPacket(rtp);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
process20ms(rtp) {
|
|
63
|
+
rtp.header.sequenceNumber = this.sequenceNumber++;
|
|
64
|
+
rtp.header.timestamp = this.timestamp;
|
|
65
|
+
rtp.header.ssrc = this.audioSsrc;
|
|
66
|
+
rtp.header.payloadType = this.payloadType;
|
|
67
|
+
this.sendPacket(rtp);
|
|
68
|
+
this.timestamp += 16000 * 0.02; // 16kHz * 20ms
|
|
69
|
+
}
|
|
70
|
+
process60ms(rtp) {
|
|
71
|
+
this.buffer.push(rtp.payload.subarray(1)); // Remove TOC byte
|
|
72
|
+
if (this.buffer.length === 3) {
|
|
73
|
+
const toc = rtp.payload[0] & 0xfc; // Keep config bits
|
|
74
|
+
const frameCountByte = 0x83; // VBR flag set, 3 frames
|
|
75
|
+
const header = Buffer.from([toc | 0x03, frameCountByte]);
|
|
76
|
+
const payload = Buffer.concat([header, ...this.buffer]);
|
|
77
|
+
rtp.header.sequenceNumber = this.sequenceNumber++;
|
|
78
|
+
rtp.header.timestamp = this.timestamp;
|
|
79
|
+
rtp.header.ssrc = this.audioSsrc;
|
|
80
|
+
rtp.payload = payload;
|
|
81
|
+
this.sendPacket(rtp);
|
|
82
|
+
this.timestamp += 16000 * 0.06; // 16kHz * 60ms
|
|
83
|
+
this.buffer = [];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
sendPacket(rtp) {
|
|
87
|
+
const encryptedPacket = this.audioSrtpSession.encrypt(rtp.payload, rtp.header);
|
|
88
|
+
this.audioSplitter.send(encryptedPacket, {
|
|
89
|
+
port: this.targetPort,
|
|
90
|
+
address: this.targetAddress,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export class VideoProcessor {
|
|
95
|
+
videoSsrc;
|
|
96
|
+
videoSrtp;
|
|
97
|
+
videoSplitter;
|
|
98
|
+
targetAddress;
|
|
99
|
+
targetPort;
|
|
100
|
+
mtu;
|
|
101
|
+
payloadType;
|
|
102
|
+
logger;
|
|
103
|
+
videoSrtpSession;
|
|
104
|
+
sequenceNumber = Math.floor(Math.random() * 65536);
|
|
105
|
+
constructor(videoSsrc, videoSrtp, videoSplitter, targetAddress, targetPort, mtu, payloadType, logger) {
|
|
106
|
+
this.videoSsrc = videoSsrc;
|
|
107
|
+
this.videoSrtp = videoSrtp;
|
|
108
|
+
this.videoSplitter = videoSplitter;
|
|
109
|
+
this.targetAddress = targetAddress;
|
|
110
|
+
this.targetPort = targetPort;
|
|
111
|
+
this.mtu = mtu;
|
|
112
|
+
this.payloadType = payloadType;
|
|
113
|
+
this.logger = logger;
|
|
114
|
+
this.videoSrtpSession = new SrtpSession(getSessionConfig(this.videoSrtp));
|
|
115
|
+
}
|
|
116
|
+
processPacket(rtp) {
|
|
117
|
+
if (!rtp || !rtp.payload) {
|
|
118
|
+
this.logger.warn('Received invalid RTP packet, ignore...');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const fragments = this.fragmentPacket(rtp.payload, this.mtu - 12); // Subtract RTP header size
|
|
122
|
+
for (let i = 0; i < fragments.length; i++) {
|
|
123
|
+
const newRtp = new RtpPacket(new RtpHeader({
|
|
124
|
+
version: 2,
|
|
125
|
+
padding: false,
|
|
126
|
+
extension: false,
|
|
127
|
+
marker: i === fragments.length - 1 && rtp.header.marker,
|
|
128
|
+
payloadType: this.payloadType,
|
|
129
|
+
sequenceNumber: this.sequenceNumber++,
|
|
130
|
+
timestamp: rtp.header.timestamp,
|
|
131
|
+
ssrc: this.videoSsrc,
|
|
132
|
+
}), fragments[i]);
|
|
133
|
+
const encryptedPacket = this.videoSrtpSession.encrypt(newRtp.payload, newRtp.header);
|
|
134
|
+
this.videoSplitter.send(encryptedPacket, {
|
|
135
|
+
port: this.targetPort,
|
|
136
|
+
address: this.targetAddress,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
fragmentPacket(payload, maxFragmentSize) {
|
|
141
|
+
if (payload.length <= maxFragmentSize) {
|
|
142
|
+
return [payload];
|
|
143
|
+
}
|
|
144
|
+
const fragments = [];
|
|
145
|
+
let startIndex = 0;
|
|
146
|
+
while (startIndex < payload.length) {
|
|
147
|
+
const endIndex = Math.min(startIndex + maxFragmentSize, payload.length);
|
|
148
|
+
fragments.push(payload.subarray(startIndex, endIndex));
|
|
149
|
+
startIndex = endIndex;
|
|
150
|
+
}
|
|
151
|
+
return fragments;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.js","sourceRoot":"","sources":["../../src/cameraUtils/processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAM3D,MAAM,UAAU,gBAAgB,CAAC,WAAwB;IACvD,OAAO;QACL,IAAI,EAAE;YACJ,cAAc,EAAE,WAAW,CAAC,OAAO;YACnC,eAAe,EAAE,WAAW,CAAC,QAAQ;YACrC,eAAe,EAAE,WAAW,CAAC,OAAO;YACpC,gBAAgB,EAAE,WAAW,CAAC,QAAQ;SACvC;QACD,OAAO,EAAE,CAAC;KACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC;AACrC,CAAC;AAED,MAAM,OAAO,cAAc;IAQf;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAfF,gBAAgB,CAAc;IAE9B,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;IACnD,SAAS,GAAG,CAAC,CAAC;IACd,MAAM,GAAa,EAAE,CAAC;IAE9B,YACU,SAAiB,EACjB,SAAsB,EACtB,aAA0B,EAC1B,aAAqB,EACrB,U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C,UAAU,GAAG,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACxE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;YACvD,UAAU,GAAG,QAAQ,CAAC;QACxB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FfmpegProcess } from './ffmpeg-process.js';
|
|
2
|
+
import type { FfmpegProcessOptions } from './ffmpeg-process.js';
|
|
3
|
+
import type { RtpSplitter } from './rtp-splitter.js';
|
|
4
|
+
interface Source {
|
|
5
|
+
srtp_key: Buffer;
|
|
6
|
+
srtp_salt: Buffer;
|
|
7
|
+
}
|
|
8
|
+
interface PrepareStreamRequest {
|
|
9
|
+
targetAddress: string;
|
|
10
|
+
addressVersion: 'ipv4' | 'ipv6';
|
|
11
|
+
audio: Source;
|
|
12
|
+
}
|
|
13
|
+
interface StartStreamRequest {
|
|
14
|
+
audio: {
|
|
15
|
+
codec: 'OPUS' | 'AAC_eld' | string;
|
|
16
|
+
channel: number;
|
|
17
|
+
sample_rate: number;
|
|
18
|
+
pt: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare class ReturnAudioTranscoder {
|
|
22
|
+
private options;
|
|
23
|
+
readonly returnRtpSplitter: RtpSplitter;
|
|
24
|
+
private startStreamRequest;
|
|
25
|
+
readonly ffmpegProcess: FfmpegProcess;
|
|
26
|
+
readonly reservedPortsPromise: Promise<number[]>;
|
|
27
|
+
constructor(options: {
|
|
28
|
+
outputArgs: (string | number)[];
|
|
29
|
+
prepareStreamRequest: PrepareStreamRequest;
|
|
30
|
+
incomingAudioOptions: {
|
|
31
|
+
ssrc: number;
|
|
32
|
+
rtcpPort: number;
|
|
33
|
+
};
|
|
34
|
+
returnAudioSplitter: RtpSplitter;
|
|
35
|
+
startStreamRequest?: StartStreamRequest;
|
|
36
|
+
} & Omit<FfmpegProcessOptions, 'ffmpegArgs'>);
|
|
37
|
+
start(): Promise<void>;
|
|
38
|
+
stop(): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { FfmpegProcess } from './ffmpeg-process.js';
|
|
2
|
+
import { reservePorts } from './ports.js';
|
|
3
|
+
import { getSsrc } from './rtp.js';
|
|
4
|
+
import { createCryptoLine } from './srtp.js';
|
|
5
|
+
const defaultStartStreamReqeuest = {
|
|
6
|
+
audio: {
|
|
7
|
+
codec: 'AAC_eld',
|
|
8
|
+
channel: 1,
|
|
9
|
+
sample_rate: 16,
|
|
10
|
+
pt: 110,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export class ReturnAudioTranscoder {
|
|
14
|
+
options;
|
|
15
|
+
returnRtpSplitter;
|
|
16
|
+
startStreamRequest;
|
|
17
|
+
ffmpegProcess;
|
|
18
|
+
reservedPortsPromise = reservePorts({ count: 2 });
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.startStreamRequest = this.options.startStreamRequest || defaultStartStreamReqeuest;
|
|
22
|
+
this.ffmpegProcess = new FfmpegProcess({
|
|
23
|
+
ffmpegArgs: [
|
|
24
|
+
'-hide_banner',
|
|
25
|
+
'-protocol_whitelist',
|
|
26
|
+
'pipe,udp,rtp,file,crypto',
|
|
27
|
+
'-f',
|
|
28
|
+
'sdp',
|
|
29
|
+
'-acodec',
|
|
30
|
+
this.startStreamRequest.audio.codec === 'OPUS' ? 'libopus' : 'libfdk_aac',
|
|
31
|
+
'-i',
|
|
32
|
+
'pipe:',
|
|
33
|
+
'-map',
|
|
34
|
+
'0:0',
|
|
35
|
+
...this.options.outputArgs,
|
|
36
|
+
],
|
|
37
|
+
...this.options,
|
|
38
|
+
});
|
|
39
|
+
// allow return audio splitter to be passed in if you want to create one in the prepare stream phase, and create the transcoder in the stream request phase
|
|
40
|
+
this.returnRtpSplitter = options.returnAudioSplitter;
|
|
41
|
+
}
|
|
42
|
+
async start() {
|
|
43
|
+
const [rtpPort, rtcpPort] = await this.reservedPortsPromise, { targetAddress, addressVersion, audio: { srtp_key: srtpKey, srtp_salt: srtpSalt }, } = this.options.prepareStreamRequest, { ssrc: incomingAudioSsrc, rtcpPort: incomingAudioRtcpPort } = this.options.incomingAudioOptions, { codec, sample_rate, channel, pt: packetType } = this.startStreamRequest.audio;
|
|
44
|
+
this.ffmpegProcess.writeStdin(
|
|
45
|
+
// This SDP was generated using ffmpeg, and describes the type of packets we expect to receive from HomeKit.
|
|
46
|
+
[
|
|
47
|
+
'v=0',
|
|
48
|
+
'o=- 0 0 IN IP4 127.0.0.1',
|
|
49
|
+
's=Talk',
|
|
50
|
+
`c=IN ${addressVersion.replace('v', '').toUpperCase()} ${targetAddress}`,
|
|
51
|
+
't=0 0',
|
|
52
|
+
'a=tool:libavformat 58.38.100',
|
|
53
|
+
`m=audio ${rtpPort} RTP/AVP ${packetType}`,
|
|
54
|
+
'b=AS:24',
|
|
55
|
+
...(codec === 'OPUS'
|
|
56
|
+
? [`a=rtpmap:${packetType} opus/${sample_rate}000/${channel}`, `a=fmtp:${packetType} minptime=10;useinbandfec=1`]
|
|
57
|
+
: [
|
|
58
|
+
`a=rtpmap:${packetType} MPEG4-GENERIC/${sample_rate}000/${channel}`,
|
|
59
|
+
`a=fmtp:${packetType} profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=F8F0212C00BC00`,
|
|
60
|
+
]),
|
|
61
|
+
createCryptoLine({
|
|
62
|
+
srtpKey,
|
|
63
|
+
srtpSalt,
|
|
64
|
+
}),
|
|
65
|
+
].join('\n'));
|
|
66
|
+
this.returnRtpSplitter.addMessageHandler(({ isRtpMessage, message }) => {
|
|
67
|
+
// This splitter will receive all audio-related packets from HomeKit.
|
|
68
|
+
// This includes RTP + RTCP for return audio, as well as RTCP for incoming audio
|
|
69
|
+
if (!isRtpMessage && getSsrc(message) === incomingAudioSsrc) {
|
|
70
|
+
return {
|
|
71
|
+
port: incomingAudioRtcpPort,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
port: isRtpMessage ? rtpPort : rtcpPort,
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
stop() {
|
|
80
|
+
this.ffmpegProcess.stop();
|
|
81
|
+
this.returnRtpSplitter.close();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=return-audio-transcoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"return-audio-transcoder.js","sourceRoot":"","sources":["../../src/cameraUtils/return-audio-transcoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAyB7C,MAAM,0BAA0B,GAAuB;IACrD,KAAK,EAAE;QACL,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,EAAE;QACf,EAAE,EAAE,GAAG;KACR;CACF,CAAC;AAEF,MAAM,OAAO,qBAAqB;IAOtB;IANM,iBAAiB,CAAC;IAC1B,kBAAkB,CAAqB;IAC/B,aAAa,CAAgB;IAC7B,oBAAoB,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAElE,YACU,OASoC;QATpC,YAAO,GAAP,OAAO,CAS6B;QAE5C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,0BAA0B,CAAC;QAExF,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC;YACrC,UAAU,EAAE;gBACV,cAAc;gBACd,qBAAqB;gBACrB,0BAA0B;gBAC1B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,6BAA6B,CAAC;gBACjH,CAAC,CAAC;oBACE,YAAY,UAAU,kBAAkB,WAAW,OAAO,OAAO,EAAE;oBACnE,UAAU,UAAU,wGAAwG;iBAC7H,CAAC;YACN,gBAAgB,CAAC;gBACf,OAAO;gBACP,QAAQ;aACT,CAAC;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QAEF,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE;YACrE,qEAAqE;YACrE,gFAAgF;YAChF,IAAI,CAAC,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,iBAAiB,EAAE,CAAC;gBAC5D,OAAO;oBACL,IAAI,EAAE,qBAAqB;iBAC5B,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;aACxC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RemoteInfo, Socket } from 'node:dgram';
|
|
2
|
+
import type { Observable } from 'rxjs';
|
|
3
|
+
export interface SocketTarget {
|
|
4
|
+
port: number;
|
|
5
|
+
address?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RtpMessageDescription {
|
|
8
|
+
isRtpMessage: boolean;
|
|
9
|
+
payloadType: number;
|
|
10
|
+
info: RemoteInfo;
|
|
11
|
+
message: Buffer;
|
|
12
|
+
}
|
|
13
|
+
export type RtpMessageHandler = (description: RtpMessageDescription) => SocketTarget | null;
|
|
14
|
+
export declare class RtpSplitter {
|
|
15
|
+
socket?: Socket;
|
|
16
|
+
address?: string;
|
|
17
|
+
port?: number;
|
|
18
|
+
type?: 'udp4' | 'udp6';
|
|
19
|
+
onMessage?: Observable<{
|
|
20
|
+
message: Buffer;
|
|
21
|
+
info: RemoteInfo;
|
|
22
|
+
isRtpMessage: boolean;
|
|
23
|
+
payloadType: number;
|
|
24
|
+
}>;
|
|
25
|
+
private closed;
|
|
26
|
+
private cleanedUp;
|
|
27
|
+
private onClose;
|
|
28
|
+
constructor();
|
|
29
|
+
prepare(type: 'udp4' | 'udp6', address?: string, messageHandler?: RtpMessageHandler): Promise<void>;
|
|
30
|
+
addMessageHandler(handler: RtpMessageHandler): void;
|
|
31
|
+
addOneTimeMessageHandler(handler: RtpMessageHandler): void;
|
|
32
|
+
send(message: Buffer, sendTo: SocketTarget): void;
|
|
33
|
+
private cleanUp;
|
|
34
|
+
close(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createSocket } from 'node:dgram';
|
|
2
|
+
import { fromEvent, merge, ReplaySubject } from 'rxjs';
|
|
3
|
+
import { map, share, takeUntil } from 'rxjs/operators';
|
|
4
|
+
import { bindToPort } from './ports.js';
|
|
5
|
+
import { getPayloadType, isRtpMessagePayloadType } from './rtp.js';
|
|
6
|
+
export class RtpSplitter {
|
|
7
|
+
socket;
|
|
8
|
+
address;
|
|
9
|
+
port;
|
|
10
|
+
type;
|
|
11
|
+
onMessage;
|
|
12
|
+
closed = false;
|
|
13
|
+
cleanedUp = false;
|
|
14
|
+
onClose = new ReplaySubject();
|
|
15
|
+
constructor() { }
|
|
16
|
+
async prepare(type, address = '127.0.0.1', messageHandler) {
|
|
17
|
+
this.type = type;
|
|
18
|
+
const socket = createSocket(type);
|
|
19
|
+
const port = await bindToPort(socket, address);
|
|
20
|
+
socket.setSendBufferSize(1024 * 1024);
|
|
21
|
+
this.socket = socket;
|
|
22
|
+
this.address = address;
|
|
23
|
+
this.port = port;
|
|
24
|
+
this.onMessage = fromEvent(this.socket, 'message').pipe(map(([message, info]) => {
|
|
25
|
+
const payloadType = getPayloadType(message);
|
|
26
|
+
return {
|
|
27
|
+
message,
|
|
28
|
+
info,
|
|
29
|
+
isRtpMessage: isRtpMessagePayloadType(payloadType),
|
|
30
|
+
payloadType,
|
|
31
|
+
};
|
|
32
|
+
}), takeUntil(this.onClose), share());
|
|
33
|
+
if (messageHandler) {
|
|
34
|
+
this.addMessageHandler(messageHandler);
|
|
35
|
+
}
|
|
36
|
+
merge(fromEvent(this.socket, 'close'), fromEvent(this.socket, 'error'))
|
|
37
|
+
.pipe(takeUntil(this.onClose))
|
|
38
|
+
.subscribe(() => {
|
|
39
|
+
this.cleanUp();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
addMessageHandler(handler) {
|
|
43
|
+
this.onMessage?.subscribe((description) => {
|
|
44
|
+
const forwardingTarget = handler(description);
|
|
45
|
+
if (forwardingTarget) {
|
|
46
|
+
this.send(description.message, forwardingTarget);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
addOneTimeMessageHandler(handler) {
|
|
51
|
+
const subscription = this.onMessage?.subscribe((description) => {
|
|
52
|
+
const forwardingTarget = handler(description);
|
|
53
|
+
if (forwardingTarget) {
|
|
54
|
+
this.send(description.message, forwardingTarget);
|
|
55
|
+
}
|
|
56
|
+
// Unsubscribe nach der ersten Ausführung
|
|
57
|
+
subscription?.unsubscribe();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
send(message, sendTo) {
|
|
61
|
+
if (this.closed) {
|
|
62
|
+
// If we send a message on a closed socket, it will throw an ERR_SOCKET_DGRAM_NOT_RUNNING error
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.socket?.send(message, sendTo.port, sendTo.address || '127.0.0.1');
|
|
66
|
+
}
|
|
67
|
+
cleanUp() {
|
|
68
|
+
this.closed = true;
|
|
69
|
+
if (this.cleanedUp) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.address = undefined;
|
|
73
|
+
this.port = undefined;
|
|
74
|
+
this.type = undefined;
|
|
75
|
+
this.cleanedUp = true;
|
|
76
|
+
this.onClose.next(null);
|
|
77
|
+
}
|
|
78
|
+
close() {
|
|
79
|
+
if (this.closed) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.socket?.close();
|
|
83
|
+
this.cleanUp();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=rtp-splitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rtp-splitter.js","sourceRoot":"","sources":["../../src/cameraUtils/rtp-splitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAmBnE,MAAM,OAAO,WAAW;IACf,MAAM,CAAU;IAChB,OAAO,CAAU;IACjB,IAAI,CAAU;IACd,IAAI,CAAmB;IAEvB,SAAS,CAKb;IAEK,MAAM,GAAG,KAAK,CAAC;IACf,SAAS,GAAG,KAAK,CAAC;IAElB,OAAO,GAAG,IAAI,aAAa,EAAO,CAAC;IAE3C,gBAAe,CAAC;IAET,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,OAAO,GAAG,WAAW,EAAE,cAAkC;QACnG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/C,MAAM,CAAC,iBAAiB,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAEt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0x7f;
|
|
3
|
+
}
|
|
4
|
+
export function isRtpMessagePayloadType(payloadType) {
|
|
5
|
+
return payloadType > 90 || payloadType === 0;
|
|
6
|
+
}
|
|
7
|
+
export function getSsrc(message) {
|
|
8
|
+
try {
|
|
9
|
+
const payloadType = getPayloadType(message), isRtp = isRtpMessagePayloadType(payloadType);
|
|
10
|
+
return message.readUInt32BE(isRtp ? 8 : 4);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=rtp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rtp.js","sourceRoot":"","sources":["../../src/cameraUtils/rtp.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,WAAmB;IACzD,OAAO,WAAW,GAAG,EAAE,IAAI,WAAW,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,EACzC,KAAK,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAC/C,OAAO,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface SrtpOptions {
|
|
2
|
+
srtpKey: Buffer;
|
|
3
|
+
srtpSalt: Buffer;
|
|
4
|
+
}
|
|
5
|
+
export declare function encodeSrtpOptions({ srtpKey, srtpSalt }: SrtpOptions): string;
|
|
6
|
+
export declare function decodeSrtpOptions(encodedOptions: string): SrtpOptions;
|
|
7
|
+
export declare function createCryptoLine(srtpOptions: SrtpOptions): string;
|
|
8
|
+
export declare function generateSrtpOptions(): SrtpOptions;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
export function encodeSrtpOptions({ srtpKey, srtpSalt }) {
|
|
3
|
+
return Buffer.concat([srtpKey, srtpSalt]).toString('base64');
|
|
4
|
+
}
|
|
5
|
+
export function decodeSrtpOptions(encodedOptions) {
|
|
6
|
+
const crypto = Buffer.from(encodedOptions, 'base64');
|
|
7
|
+
return {
|
|
8
|
+
srtpKey: crypto.subarray(0, 16),
|
|
9
|
+
srtpSalt: crypto.subarray(16, 30),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function createCryptoLine(srtpOptions) {
|
|
13
|
+
const encodedOptions = encodeSrtpOptions(srtpOptions);
|
|
14
|
+
return `a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${encodedOptions}`;
|
|
15
|
+
}
|
|
16
|
+
export function generateSrtpOptions() {
|
|
17
|
+
return {
|
|
18
|
+
srtpKey: randomBytes(16),
|
|
19
|
+
srtpSalt: randomBytes(14),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=srtp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"srtp.js","sourceRoot":"","sources":["../../src/cameraUtils/srtp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,MAAM,UAAU,iBAAiB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAe;IAClE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,cAAsB;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAErD,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,WAAwB;IACvD,MAAM,cAAc,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAEtD,OAAO,6CAA6C,cAAc,EAAE,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;QACxB,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function timeoutPromise<T>(timeout: number, promise: Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function timeoutPromise(timeout, promise) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const t = setTimeout(() => reject(new Error('Operation timed out')), timeout);
|
|
4
|
+
promise
|
|
5
|
+
.then((v) => {
|
|
6
|
+
clearTimeout(t);
|
|
7
|
+
resolve(v);
|
|
8
|
+
})
|
|
9
|
+
.catch((e) => {
|
|
10
|
+
clearTimeout(t);
|
|
11
|
+
reject(e);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/cameraUtils/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAI,OAAe,EAAE,OAAmB;IACpE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAE9E,OAAO;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACV,YAAY,CAAC,CAAC,CAAC,CAAC;YAChB,OAAO,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,YAAY,CAAC,CAAC,CAAC,CAAC;YAChB,MAAM,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export * from './cameraUtils/ffmpeg-process.js';
|
|
2
|
+
export * from './cameraUtils/ffmpeg.js';
|
|
3
|
+
export * from './cameraUtils/mp4.js';
|
|
4
|
+
export * from './cameraUtils/ports.js';
|
|
5
|
+
export * from './cameraUtils/processor.js';
|
|
6
|
+
export * from './cameraUtils/return-audio-transcoder.js';
|
|
7
|
+
export * from './cameraUtils/rtp-splitter.js';
|
|
8
|
+
export * from './cameraUtils/rtp.js';
|
|
9
|
+
export * from './cameraUtils/srtp.js';
|
|
10
|
+
export * from './cameraUtils/utils.js';
|
|
1
11
|
export * from './logger/index.js';
|
|
2
12
|
export * from './messaging/index.js';
|
|
3
13
|
export * from './nats/index.js';
|
|
@@ -7,6 +17,5 @@ export * from './npm/index.js';
|
|
|
7
17
|
export * from './packer/index.js';
|
|
8
18
|
export * from './python/index.js';
|
|
9
19
|
export * from './utils/env.js';
|
|
10
|
-
export * from './utils/ffmpeg.js';
|
|
11
20
|
export * from './utils/subscribed.js';
|
|
12
21
|
export * from './utils/utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export * from './cameraUtils/ffmpeg-process.js';
|
|
2
|
+
export * from './cameraUtils/ffmpeg.js';
|
|
3
|
+
export * from './cameraUtils/mp4.js';
|
|
4
|
+
export * from './cameraUtils/ports.js';
|
|
5
|
+
export * from './cameraUtils/processor.js';
|
|
6
|
+
export * from './cameraUtils/return-audio-transcoder.js';
|
|
7
|
+
export * from './cameraUtils/rtp-splitter.js';
|
|
8
|
+
export * from './cameraUtils/rtp.js';
|
|
9
|
+
export * from './cameraUtils/srtp.js';
|
|
10
|
+
export * from './cameraUtils/utils.js';
|
|
1
11
|
export * from './logger/index.js';
|
|
2
12
|
export * from './messaging/index.js';
|
|
3
13
|
export * from './nats/index.js';
|
|
@@ -7,7 +17,6 @@ export * from './npm/index.js';
|
|
|
7
17
|
export * from './packer/index.js';
|
|
8
18
|
export * from './python/index.js';
|
|
9
19
|
export * from './utils/env.js';
|
|
10
|
-
export * from './utils/ffmpeg.js';
|
|
11
20
|
export * from './utils/subscribed.js';
|
|
12
21
|
export * from './utils/utils.js';
|
|
13
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0CAA0C,CAAC;AACzD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camera.ui/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "camera.ui utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"require": "./dist/index.js"
|
|
11
11
|
},
|
|
12
|
+
"./cameraUtils": {
|
|
13
|
+
"default": "./dist/cameraUtils/index.js",
|
|
14
|
+
"types": "./dist/cameraUtils/index.d.ts",
|
|
15
|
+
"require": "./dist/cameraUtils/index.js"
|
|
16
|
+
},
|
|
12
17
|
"./logger": {
|
|
13
18
|
"default": "./dist/logger/index.js",
|
|
14
19
|
"types": "./dist/logger/index.d.ts",
|
|
@@ -71,7 +76,9 @@
|
|
|
71
76
|
"fs-extra": "^11.2.0",
|
|
72
77
|
"msgpackr": "^1.11.0",
|
|
73
78
|
"nats": "^2.28.2",
|
|
74
|
-
"
|
|
79
|
+
"pick-port": "^2.1.0",
|
|
80
|
+
"systeminformation": "^5.23.5",
|
|
81
|
+
"werift": "^0.19.8"
|
|
75
82
|
},
|
|
76
83
|
"devDependencies": {
|
|
77
84
|
"@camera.ui/types": "^0.0.70",
|
package/dist/utils/ffmpeg.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ffmpeg.js","sourceRoot":"","sources":["../../src/utils/ffmpeg.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,cAAsB;IACzD,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,IAAI,WAAW,GAAa,EAAE,CAAC;IAC/B,IAAI,aAAa,GAAG,cAAc,CAAC;IACnC,MAAM,OAAO,GAAG,GAAG,CAAC;IAEpB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,cAAc,sBAAsB,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAqB,CAAC;QAEzD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACzB,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;oBACjC,OAAO,GAAG,OAAO,CAAC;oBAClB,WAAW,GAAG,CAAC,eAAe,EAAE,qBAAqB,EAAE,w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