<commit_before>'use strict';
var uuid, Service, Characteristic, StreamController;

var fs = require('fs');
var request = require('request').defaults({ encoding: null });
var spawn = require('child_process').spawn;

function SensrCamera(hap, sensrCameraOptions, log) {
    uuid = hap.uuid;
    Service = hap.Service;
    Characteristic = hap.Characteristic;
    StreamController = hap.StreamController;

    this.options = sensrCameraOptions;
    this.log = log;

    this.services = [];
    this.streamControllers = [];

    this.pendingSessions = {};
    this.ongoingSessions = {};

    // TODO: These should be dynamic to some degree
    var numberOfStreams = 1;
    var maxWidth = 640;
    var maxHeight = 480;
    var maxFPS = 15;

    this.createCameraControlService();
    this._createStreamControllers(numberOfStreams);
}

SensrCamera.prototype.handleCloseConnection = function (connectionID) {
    this.streamControllers.forEach(function (controller) {
        controller.handleCloseConnection(connectionID);
    });
}


SensrCamera.prototype.handleSnapshotRequest = function (req, callback) {
    let resolution = req.width + 'x' + req.height;
    this.log('Request made for handleSnapshotRequest.', this.options.live);

    request({ url: this.options.still }, function (err, response, buffer) {
        this.log(err, response);
        callback(err, buffer);
    });
}

SensrCamera.prototype.createCameraControlService = function () {
    var controlService = new Service.CameraControl();

    this.services.push(controlService);
}

SensrCamera.prototype._createStreamControllers = function (maxStreams, options) {
    let self = this;
    options = options || {
        video: {
            codec: {
                profiles: [0, 1, 2], // Enum, please refer StreamController.VideoCodecParamProfileIDTypes
                levels: [0, 1, 2] // Enum, please refer StreamController.VideoCodecParamLevelTypes
            },
            resolutions: [
                [640, 480, 15]
            ]
        },
        audio: {
            codecs: [<commit_msg>Removed log<commit_after>'use strict';
var uuid, Service, Characteristic, StreamController;

var fs = require('fs');
var request = require('request').defaults({ encoding: null });
var spawn = require('child_process').spawn;

function SensrCamera(hap, sensrCameraOptions, log) {
    uuid = hap.uuid;
    Service = hap.Service;
    Characteristic = hap.Characteristic;
    StreamController = hap.StreamController;

    this.options = sensrCameraOptions;
    this.log = log;

    this.services = [];
    this.streamControllers = [];

    this.pendingSessions = {};
    this.ongoingSessions = {};

    // TODO: These should be dynamic to some degree
    var numberOfStreams = 1;
    var maxWidth = 640;
    var maxHeight = 480;
    var maxFPS = 15;

    this.createCameraControlService();
    this._createStreamControllers(numberOfStreams);
}

SensrCamera.prototype.handleCloseConnection = function (connectionID) {
    this.streamControllers.forEach(function (controller) {
        controller.handleCloseConnection(connectionID);
    });
}


SensrCamera.prototype.handleSnapshotRequest = function (req, callback) {
    let resolution = req.width + 'x' + req.height;
    this.log('Request made for handleSnapshotRequest.', this.options.still);

    request({ url: this.options.still }, function (err, response, buffer) {
        callback(err, buffer);
    });
}

SensrCamera.prototype.createCameraControlService = function () {
    var controlService = new Service.CameraControl();

    this.services.push(controlService);
}

SensrCamera.prototype._createStreamControllers = function (maxStreams, options) {
    let self = this;
    options = options || {
        video: {
            codec: {
                profiles: [0, 1, 2], // Enum, please refer StreamController.VideoCodecParamProfileIDTypes
                levels: [0, 1, 2] // Enum, please refer StreamController.VideoCodecParamLevelTypes
            },
            resolutions: [
                [640, 480, 15]
            ]
        },
        audio: {
            codecs: [
{'fraction_non_alphanumeric': 0.114013671875, 'fraction_numerical': 0.01123046875, 'mean_word_length': 3.0285152409046217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1492619', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1141, 'n_words': 261}