From 8e2d43e339f80260a3752f0babad26c2c6e7c55c Mon Sep 17 00:00:00 2001 From: stevenrick Date: Fri, 10 Jun 2022 14:50:42 -0700 Subject: [PATCH] fix recordStatus for all device types --- JS_Files/audio.js | 11 +++++- JS_Files/camera.js | 4 +-- JS_Files/chronosense.js | 13 +++---- JS_Files/screen_capture_device.js | 56 +++++++++++++++++++++++++++---- 4 files changed, 67 insertions(+), 17 deletions(-) diff --git a/JS_Files/audio.js b/JS_Files/audio.js index e246b6d..5d906a6 100644 --- a/JS_Files/audio.js +++ b/JS_Files/audio.js @@ -55,10 +55,19 @@ export class Audio { * * @return {string} - Device identifier used to describe device output */ - getKind() { + getKind() { return this.#kind; } + /** + * Getter function to retrieve the device recording status based on video and audio + * + * @return {string} - Device identifier used to describe device recording status + */ + getRecordStatus() { + return (this.#audioCheckbox.checked); + } + monitorAudio(stream) { let max_level_L = 0; let old_level_L = 0; diff --git a/JS_Files/camera.js b/JS_Files/camera.js index 0634714..5fe62dc 100644 --- a/JS_Files/camera.js +++ b/JS_Files/camera.js @@ -70,8 +70,8 @@ export class Camera { * * @return {string} - Device identifier used to describe device recording status */ - getRecordStatus() { - return (this.#audioCheckbox.checked || this.#videoCheckbox.checked); + getRecordStatus() { + return (this.#audioCheckbox.checked || this.#videoCheckbox.checked); } diff --git a/JS_Files/chronosense.js b/JS_Files/chronosense.js index 3db10c3..50bf780 100644 --- a/JS_Files/chronosense.js +++ b/JS_Files/chronosense.js @@ -481,14 +481,11 @@ async function recordAllSelectedDevices() { }) selectedDevices.forEach((device) => { // Checks whether or not Audio or Video is selected if not do not start - if (device.getRecordStatus() == false) { - console.log('Audio and Video are both off') - } - else { - // Start recording - device.setDirName(recordDirectory); - device.startRecording(); - numRecording++; + if (device.getRecordStatus()) { + // Start recording + device.setDirName(recordDirectory); + device.startRecording(); + numRecording++; } }); } diff --git a/JS_Files/screen_capture_device.js b/JS_Files/screen_capture_device.js index 7f97aa0..c0791ca 100644 --- a/JS_Files/screen_capture_device.js +++ b/JS_Files/screen_capture_device.js @@ -2,9 +2,10 @@ const remote = require('@electron/remote'); import { AVRecorder } from './avRecorder.js'; export class ScreenCaptureDevice { - - #label = "Screen Capture"; - #deviceId = "ScreenCaptureModule"; + #deviceId = "ScreenCapture"; + #groupId = "ScreenCapture"; + #kind = "screencapture"; + #label = "ScreenCapture"; #videoElement = null; #optionContainer = null; #sources = [] @@ -27,10 +28,51 @@ export class ScreenCaptureDevice { /** * Constructor for a ScreenCaptureDevice object that captures stream of video/audio from user screens & windows. * + * @param {string} deviceId - Identifier for the device used in input capture. + * @param {string} groupId - Identifier for the device group used in input capture. + * @param {string} kind - Identifier for type of input from device. + * @param {string} label - Name Identifier (Sensical to user for reading). */ - constructor() { - this.getCaptureSources(); - } + constructor(deviceId, groupId, kind, label) { + this.#deviceId = "ScreenCapture"; + this.#groupId = "ScreenCapture"; + this.#kind = "screencapture"; + this.#label = "ScreenCapture"; + + this.getCaptureSources(); + } + + getPluginDiv() { + let _pluginDiv = this.#pluginDiv; + return _pluginDiv; + } + + /** + * Getter function to retrieve the object's Group ID + * + * @return {string} - Group identifier used to connect it to other similar devices + */ + getGroupId() { + return this.#groupId; + } + + /** + * Getter function to retrieve the object's "kind" + * + * @return {string} - Device identifier used to describe device output + */ + getKind() { + return this.#kind; + } + + /** + * Getter function to retrieve the device recording status based on video and audio + * + * @return {string} - Device identifier used to describe device recording status + */ + getRecordStatus() { + return (this.#videoCheckbox.checked); + } fixForMacOS() { if(process.platform === "darwin") { @@ -46,6 +88,8 @@ export class ScreenCaptureDevice { return _pluginDiv; } + + /** * Collects all of the possible screen and window sources into an array for later use. *