UNPKG

@homebridge/camera-utils

Version:

Utilities to simplify homebridge camera plugin development

23 lines 764 B
import { Buffer } from 'node:buffer'; import { randomBytes } from 'node:crypto'; export function encodeSrtpOptions({ srtpKey, srtpSalt }) { return Buffer.concat([srtpKey, srtpSalt]).toString('base64'); } export function decodeSrtpOptions(encodedOptions) { const crypto = Buffer.from(encodedOptions, 'base64'); return { srtpKey: crypto.slice(0, 16), srtpSalt: crypto.slice(16, 30), }; } export function createCryptoLine(srtpOptions) { const encodedOptions = encodeSrtpOptions(srtpOptions); return `a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${encodedOptions}`; } export function generateSrtpOptions() { return { srtpKey: randomBytes(16), srtpSalt: randomBytes(14), }; } //# sourceMappingURL=srtp.js.map