From f6cd2b57c1b8c51e163765f9acaafcd8ab351461 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 19 Mar 2024 15:53:04 -0500 Subject: [PATCH] feat: add GenericSink --- .../Generic/GenericSink.cs | 62 +++++++++++++++++++ .../Generic/GenericSource.cs | 1 - 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs diff --git a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs new file mode 100644 index 00000000..50a65272 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSink.cs @@ -0,0 +1,62 @@ +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Routing; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PepperDash.Essentials.Devices.Common.Generic +{ + public class GenericSink : EssentialsDevice, IRoutingSink + { + public GenericSink(string key, string name) : base(key, name) + { + InputPorts = new RoutingPortCollection(); + + var inputPort = new RoutingInputPort($"{Key}-{RoutingPortNames.AnyVideoIn}", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null, this); + + InputPorts.Add(inputPort); + + } + + public RoutingPortCollection InputPorts { get; private set; } + + public string CurrentSourceInfoKey { get; set; } + + private SourceListItem _currentSource; + public SourceListItem CurrentSourceInfo { + get => _currentSource; + set { + if(value == _currentSource) + { + return; + } + + CurrentSourceChange?.Invoke(_currentSource, ChangeType.WillChange); + + _currentSource = value; + + CurrentSourceChange?.Invoke(_currentSource, ChangeType.DidChange); + } + } + + public event SourceInfoChangeHandler CurrentSourceChange; + } + + public class GenericSinkFactory : EssentialsDeviceFactory + { + public GenericSinkFactory() + { + TypeNames = new List() { "genericsink", "genericdestination" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Source Device"); + return new GenericSource(dc.Key, dc.Name); + } + } +} diff --git a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs index 697639e5..f3aa2df4 100644 --- a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs +++ b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs @@ -54,5 +54,4 @@ namespace PepperDash.Essentials.Devices.Common return new GenericSource(dc.Key, dc.Name); } } - } \ No newline at end of file