text: var Accessory, Service, Characteristic, hap, UUIDGen;
  
  var FFMPEG = require('./ffmpeg').FFMPEG;
  
  module.exports = function(homebridge) {
    Accessory = homebridge.platformAccessory;
    Service = homebridge.hap.Service;
    Characteristic = homebridge.hap.Characteristic;
    hap = homebridge.hap;
    UUIDGen = homebridge.hap.uuid;
  
    homebridge.registerPlatform("homebridge-camera-ffmpeg", "Camera-ffmpeg", ffmpegPlatform, true);
  }
  
  function ffmpegPlatform(log, config, api) {
    var self = this;
  
    self.log = log;
    self.config = config || {};
  
    if (api) {
      self.api = api;
  
      if (api.version < 2.1) {
        throw new Error("Unexpected API version.");
      }
  
      self.api.on('didFinishLaunching', self.didFinishLaunching.bind(this));
    }
  }
  
  ffmpegPlatform.prototype.configureAccessory = function(accessory) {
    // Won't be invoked
  }
  
  ffmpegPlatform.prototype.didFinishLaunching = function() {
    var self = this;
    var videoProcessor = self.config.videoProcessor || 'ffmpeg';
  
    if (self.config.cameras) {
      var configuredAccessories = [];
  
      var cameras = self.config.cameras;
      cameras.forEach(function(cameraConfig) {
        var cameraName = cameraConfig.name;
        var videoConfig = cameraConfig.videoConfig;
  
        if (!cameraName || !videoConfig) {
          self.log("Missing parameters.");
          return;
        }
  
        var uuid = UUIDGen.generate(cameraName);
        var cameraAccessory = new Accessory(cameraName, uuid, hap.Accessory.Categories.CAMERA);
  
        var cameraAccessoryInfo = cameraAccessory.getService(Service.AccessoryInformation);
        if (cameraConfig.manufacturer) {
          cameraAccessoryInfo.setCharacteristic(Characteristic.Manufacturer, cameraConfig.manufacturer);
        }
        if (cameraConfig.model) {
          cameraAccessoryInfo.setCharacteristic(Characteristic.Model, cameraConfig.model);
        }
        if (cameraConfig.serialNumber) {
          cameraAccessoryInfo.setCharacteristic(Characteristic.SerialNumber, cameraConfig.serialNumber);
        }
        if (cameraConfig.firmwareRevision) {
          cameraAccessoryInfo.setCharacteristic(Characteristic.FirmwareRevision, cameraConfig.firmwareRevision);
        }
  
        var cameraSource = new FFMPEG(hap, cameraConfig, self.log, videoProcessor);
        cameraAccessory.configureCameraSource(cameraSource);
        configuredAccessories.push(cameraAccessory);
      });
  
      self.api.publishCameraAccessories("Camera-ffmpeg", configuredAccessories);
    }
  }
  