description and source-codefunction FFMPEG(hap, ffmpegOpt) {
uuid = hap.uuid;
Service = hap.Service;
Characteristic = hap.Characteristic;
StreamController = hap.StreamController;
if (!ffmpegOpt.source) {
throw new Error("Missing source for camera.");
}
this.ffmpegSource = ffmpegOpt.source;
this.ffmpegImageSource = ffmpegOpt.stillImageSource;
this.services = [];
this.streamControllers = [];
this.pendingSessions = {};
this.ongoingSessions = {};
var numberOfStreams = ffmpegOpt.maxStreams || 2;
var videoResolutions = [];
var maxWidth = ffmpegOpt.maxWidth;
var maxHeight = ffmpegOpt.maxHeight;
var maxFPS = (ffmpegOpt.maxFPS > 30) ? 30 : ffmpegOpt.maxFPS;
if (maxWidth >= 320) {
if (maxHeight >= 240) {
videoResolutions.push([320, 240, maxFPS]);
if (maxFPS > 15) {
videoResolutions.push([320, 240, 15]);
}
}
if (maxHeight >= 180) {
videoResolutions.push([320, 180, maxFPS]);
if (maxFPS > 15) {
videoResolutions.push([320, 180, 15]);
}
}
}
if (maxWidth >= 480) {
if (maxHeight >= 360) {
videoResolutions.push([480, 360, maxFPS]);
}
if (maxHeight >= 270) {
videoResolutions.push([480, 270, maxFPS]);
}
}
if (maxWidth >= 640) {
if (maxHeight >= 480) {
videoResolutions.push([640, 480, maxFPS]);
}
if (maxHeight >= 360) {
videoResolutions.push([640, 360, maxFPS]);
}
}
if (maxWidth >= 1280) {
if (maxHeight >= 960) {
videoResolutions.push([1280, 960, maxFPS]);
}
if (maxHeight >= 720) {
videoResolutions.push([1280, 720, maxFPS]);
}
}
if (maxWidth >= 1920) {
if (maxHeight >= 1080) {
videoResolutions.push([1920, 1080, maxFPS]);
}
}
let options = {
proxy: false, // Requires RTP/RTCP MUX Proxy
srtp: true, // Supports SRTP AES_CM_128_HMAC_SHA1_80 encryption
video: {
resolutions: videoResolutions,
codec: {
profiles: [0, 1, 2], // Enum, please refer StreamController.VideoCodecParamProfileIDTypes
levels: [0, 1, 2] // Enum, please refer StreamController.VideoCodecParamLevelTypes
}
},
audio: {
codecs: [
{
type: "OPUS", // Audio Codec
samplerate: 24 // 8, 16, 24 KHz
},
{
type: "AAC-eld",
samplerate: 16
}
]
}
}
this.createCameraControlService();
this._createStreamControllers(numberOfStreams, options);
}