From 63cf93a05cda46cee4d3633712373569cae18c58 Mon Sep 17 00:00:00 2001 From: Izzy Deane Date: Sat, 27 Jul 2024 17:16:13 -0400 Subject: [PATCH 01/19] Implemented initial TransformObsSourceScale effect definition --- .../integrations/builtin/obs/communicator.ts | 8 +- .../obs/effects/transform-obs-source-scale.ts | 91 +++++++++++++++++++ .../builtin/obs/obs-integration.ts | 2 + .../integrations/builtin/obs/obs-remote.ts | 17 ++++ 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts diff --git a/src/backend/integrations/builtin/obs/communicator.ts b/src/backend/integrations/builtin/obs/communicator.ts index 520940995..045d54bd6 100644 --- a/src/backend/integrations/builtin/obs/communicator.ts +++ b/src/backend/integrations/builtin/obs/communicator.ts @@ -13,7 +13,8 @@ import { getImageSources, getMediaSources, getColorSources, - getSupportedImageFormats + getSupportedImageFormats, + getTransformableSources } from "./obs-remote"; export function setupFrontendListeners( @@ -39,6 +40,11 @@ export function setupFrontendListeners( getSourcesWithFilters ); + frontendCommunicator.onAsync>( + "obs-get-transformable-sources", + getTransformableSources + ); + frontendCommunicator.onAsync>( "obs-get-audio-sources", getAudioSources diff --git a/src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts b/src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts new file mode 100644 index 000000000..6478304ad --- /dev/null +++ b/src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts @@ -0,0 +1,91 @@ +import { EffectType } from "../../../../../types/effects"; +import { OBSSource } from "../obs-remote"; + +export const TransformSourceScaleEffectType: EffectType<{ + textSourceName: string; + textSource: "static" | "file"; + text: string; + file: string; +}> = { + definition: { + id: "firebot:obs-set-source-text", + name: "Set OBS Source Text", + description: "Sets the text in an OBS text source", + icon: "fad fa-font-case", + categories: ["common"] + }, + optionsTemplate: ` + +
+ +
+ + {{$select.selected.name}} + +
+
+ + No transformable sources found. + +
+
+ No sources found. {{ isObsConfigured ? "Is OBS running?" : "Have you configured the OBS integration?" }} +
+
+ + + + + + `, + optionsController: ($scope: any, backendCommunicator: any, $q: any) => { + $scope.isObsConfigured = false; + + $scope.transformableSources = []; + + if ($scope.effect.textSource == null) { + $scope.effect.textSource = "static"; + } + + $scope.selectTextSource = (textSourceName: string) => { + $scope.effect.textSourceName = textSourceName; + }; + + $scope.toggleSource = () => { + $scope.effect.textSource = $scope.effect.textSource === "static" ? "file" : "static"; + }; + + $scope.textFileUpdated = (file: string) => { + $scope.effect.file = file; + }; + + $scope.getTransformableSources = () => { + $scope.isObsConfigured = backendCommunicator.fireEventSync("obs-is-configured"); + + $q.when( + backendCommunicator.fireEventAsync("obs-get-transformable-sources") + ).then((transformableSources: OBSSource[]) => { + $scope.transformableSources = transformableSources; + $scope.selected = $scope.transformableSources?.find(source => source.name === $scope.effect.textSourceName); + }); + }; + $scope.getTransformableSources(); + }, + optionsValidator: (effect) => { + if (effect.textSourceName == null) { + return ["Please select a text source."]; + } + return []; + }, + onTriggerEvent: async ({ effect }) => { + // await settransformableSourcesettings(effect.textSourceName, { + // text: effect.textSource === "static" ? effect.text : null, + // readFromFile: effect.textSource === "file", + // file: effect.textSource === "file" ? effect.file : null + // }); + return true; + } +}; diff --git a/src/backend/integrations/builtin/obs/obs-integration.ts b/src/backend/integrations/builtin/obs/obs-integration.ts index 1739b4ceb..2c686713d 100644 --- a/src/backend/integrations/builtin/obs/obs-integration.ts +++ b/src/backend/integrations/builtin/obs/obs-integration.ts @@ -23,6 +23,7 @@ import { CreateRecordChapter } from "./effects/create-recording-chapter"; import { ToggleSourceVisibilityEffectType } from "./effects/toggle-obs-source-visibility"; import { ToggleSourceFilterEffectType } from "./effects/toggle-obs-source-filter"; import { ToggleSourceMutedEffectType } from "./effects/toggle-obs-source-muted"; +import { TransformSourceScaleEffectType } from "./effects/transform-obs-source-scale"; import { StartStreamEffectType } from "./effects/start-stream"; import { StopStreamEffectType } from "./effects/stop-stream"; import { StartVirtualCamEffectType } from "./effects/start-virtual-cam"; @@ -142,6 +143,7 @@ class ObsIntegration effectManager.registerEffect(ToggleSourceVisibilityEffectType); effectManager.registerEffect(ToggleSourceFilterEffectType); effectManager.registerEffect(ToggleSourceMutedEffectType); + effectManager.registerEffect(TransformSourceScaleEffectType); effectManager.registerEffect(StartStreamEffectType); effectManager.registerEffect(StopStreamEffectType); effectManager.registerEffect(StartVirtualCamEffectType); diff --git a/src/backend/integrations/builtin/obs/obs-remote.ts b/src/backend/integrations/builtin/obs/obs-remote.ts index be3f14c27..4c5b1a646 100644 --- a/src/backend/integrations/builtin/obs/obs-remote.ts +++ b/src/backend/integrations/builtin/obs/obs-remote.ts @@ -783,6 +783,23 @@ export async function getAudioSources(): Promise> { return audioSupportedSources; } +export async function getTransformableSources(): Promise> { + const sources = await getAllSources(); + const transformableSources = []; + for (const source of sources) { + try { + const getMonitorResponse = await obs.call("GetInputAudioMonitorType", { + inputName: source.name + }); + if (getMonitorResponse?.monitorType == null) { + transformableSources.push(source); + } + } catch (e) {} + } + + return transformableSources; +} + export async function toggleSourceMuted(sourceName: string) { try { await obs.call("ToggleInputMute", { From 29576f2dcdb28887bd6f8ca94727b948c423632f Mon Sep 17 00:00:00 2001 From: Izzy Deane Date: Sun, 28 Jul 2024 15:24:29 -0400 Subject: [PATCH 02/19] More work on Transform Source Scale --- .../obs/effects/transform-obs-source-scale.ts | 45 +++++++++---------- .../integrations/builtin/obs/obs-remote.ts | 29 +++++++----- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts b/src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts index 6478304ad..a5b536d61 100644 --- a/src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts +++ b/src/backend/integrations/builtin/obs/effects/transform-obs-source-scale.ts @@ -1,16 +1,16 @@ import { EffectType } from "../../../../../types/effects"; -import { OBSSource } from "../obs-remote"; +import { OBSSource, OBSTransformEaseMode, transformSourceScale } from "../obs-remote"; export const TransformSourceScaleEffectType: EffectType<{ - textSourceName: string; - textSource: "static" | "file"; + transformableSourceName: string; + isAnimated: boolean; text: string; file: string; }> = { definition: { - id: "firebot:obs-set-source-text", - name: "Set OBS Source Text", - description: "Sets the text in an OBS text source", + id: "firebot:obs-transform-source-scale", + name: "Transform OBS Source Scale", + description: "Transforms the scale of an OBS source either instantly or animated over time", icon: "fad fa-font-case", categories: ["common"] }, @@ -19,7 +19,7 @@ export const TransformSourceScaleEffectType: EffectType<{
- + {{$select.selected.name}}
@@ -32,13 +32,11 @@ export const TransformSourceScaleEffectType: EffectType<{ No sources found. {{ isObsConfigured ? "Is OBS running?" : "Have you configured the OBS integration?" }} - - - -