Skip to content

Commit

Permalink
feat: add IHdmiInput MC messenger
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-welker committed Mar 26, 2024
1 parent 361bf40 commit 1628303
Show file tree
Hide file tree
Showing 14 changed files with 600 additions and 25 deletions.
10 changes: 8 additions & 2 deletions src/NvxEpi/Abstractions/HdmiInput/IHdmiInput.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Crestron.SimplSharp;
using NvxEpi.Abstractions.Hardware;
using PepperDash.Essentials.Core;

namespace NvxEpi.Abstractions.HdmiInput
Expand All @@ -8,6 +7,13 @@ public interface IHdmiInput : INvxDeviceWithHardware
{
ReadOnlyDictionary<uint, IntFeedback> HdcpCapability { get; }
ReadOnlyDictionary<uint, BoolFeedback> SyncDetected { get; }
ReadOnlyDictionary<uint, StringFeedback> CurrentResolution { get; }
ReadOnlyDictionary<uint, StringFeedback> CurrentResolution { get; }
ReadOnlyDictionary<uint, IntFeedback> AudioChannels { get; }

ReadOnlyDictionary<uint, StringFeedback> AudioFormat { get; }

ReadOnlyDictionary<uint, StringFeedback> ColorSpace { get; }

ReadOnlyDictionary<uint, StringFeedback> HdrType { get; }
}
}
9 changes: 9 additions & 0 deletions src/NvxEpi/Devices/Nvx35x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public override bool CustomActivate()
// ReSharper disable once ObjectCreationAsStatement
new AutomaticInputRouter(_hdmiInput);

AddMcMessengers();
return result;
}

Expand Down Expand Up @@ -217,5 +218,13 @@ public StringFeedback UsbLocalId
{
get { return _usbStream.UsbLocalId; }
}

public ReadOnlyDictionary<uint, IntFeedback> AudioChannels { get { return _hdmiInput.AudioChannels; } }

public ReadOnlyDictionary<uint, StringFeedback> AudioFormat { get { return _hdmiInput.AudioFormat; } }

public ReadOnlyDictionary<uint, StringFeedback> ColorSpace { get { return _hdmiInput.ColorSpace; } }

public ReadOnlyDictionary<uint, StringFeedback> HdrType { get { return _hdmiInput.HdrType; } }
}
}
15 changes: 15 additions & 0 deletions src/NvxEpi/Devices/Nvx36X.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
Expand All @@ -13,13 +14,15 @@
using NvxEpi.Features.Hdmi.Input;
using NvxEpi.Features.Hdmi.Output;
using NvxEpi.Features.Streams.Usb;
using NvxEpi.McMessengers;
using NvxEpi.Services.Bridge;
using NvxEpi.Services.InputPorts;
using NvxEpi.Services.InputSwitching;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using Feedback = PepperDash.Essentials.Core.Feedback;

namespace NvxEpi.Devices
Expand Down Expand Up @@ -65,6 +68,8 @@ public override bool CustomActivate()
// ReSharper disable once ObjectCreationAsStatement
new AutomaticInputRouter(_hdmiInput);

AddMcMessengers();

return result;
}
catch (Exception ex)
Expand Down Expand Up @@ -161,6 +166,14 @@ public ReadOnlyDictionary<uint, StringFeedback> CurrentResolution
get { return _hdmiInput.CurrentResolution; }
}

public ReadOnlyDictionary<uint, IntFeedback> AudioChannels { get { return _hdmiInput.AudioChannels; } }

public ReadOnlyDictionary<uint, StringFeedback> AudioFormat { get { return _hdmiInput.AudioFormat; } }

public ReadOnlyDictionary<uint, StringFeedback> ColorSpace { get { return _hdmiInput.ColorSpace; } }

public ReadOnlyDictionary<uint, StringFeedback> HdrType { get { return _hdmiInput.HdrType; } }

public IntFeedback VideowallMode
{
get { return _hdmiOutput.VideowallMode; }
Expand Down Expand Up @@ -259,5 +272,7 @@ public BoolFeedback MuteFeedback
{
get { return _audio.MuteFeedback; }
}


}
}
32 changes: 31 additions & 1 deletion src/NvxEpi/Devices/NvxBaseDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
using PepperDash.Essentials.Core.DeviceInfo;
using PepperDash.Essentials.Core.Queues;
using PepperDash.Essentials.Core.Config;
using NvxEpi.McMessengers;
using NvxEpi.Abstractions.HdmiInput;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Core;


namespace NvxEpi.Devices
{
Expand Down Expand Up @@ -98,6 +103,7 @@ private void SetDeviceName()

public override bool CustomActivate()
{
Debug.Console(1, this, "Activating...");
DeviceMode = DeviceModeFeedback.GetFeedback(Hardware);

Feedbacks.AddRange(new Feedback[]
Expand Down Expand Up @@ -130,10 +136,34 @@ public override bool CustomActivate()
Hardware.Control.ServerUrl.StringValue = String.Empty;
Hardware.Control.ServerUrl.StringValue = DefaultMulticastRoute;


return base.CustomActivate();
}

protected void AddMcMessengers()
{
#if SERIES4
var mc = DeviceManager.AllDevices.OfType<IMobileControl>().FirstOrDefault();

if (mc == null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, "Mobile Control not found");
return;
}

if (!(this is IHdmiInput hdmiInputDevice))
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, this, "{key:l} does NOT implement IHdmiIInput interface");
return;
}

Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, this, "Generating HDMI Input messenger for {key:l}", Key);

var hdmiInputMessenger = new IHdmiInputMessenger($"{Key}-hdmiInputMessenger", $"/device/{Key}", hdmiInputDevice);

mc.AddDeviceMessenger(hdmiInputMessenger);
#endif
}

public StringFeedback CurrentAudioInput
{
get { return _audioSwitcher.CurrentAudioInput; }
Expand Down
29 changes: 29 additions & 0 deletions src/NvxEpi/Devices/NvxE3X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public override bool CustomActivate()
Hardware = hardware;
_hdmiInput = new HdmiInput1(this);

AddMcMessengers();
return base.CustomActivate();
}

Expand Down Expand Up @@ -88,6 +89,34 @@ public ReadOnlyDictionary<uint, StringFeedback> CurrentResolution
get { return _hdmiInput.CurrentResolution; }
}

public ReadOnlyDictionary<uint, IntFeedback> AudioChannels {
get
{
return _hdmiInput.AudioChannels;
}
}

public ReadOnlyDictionary<uint, StringFeedback> AudioFormat {
get
{
return _hdmiInput.AudioFormat;
}
}

public ReadOnlyDictionary<uint, StringFeedback> ColorSpace {
get
{
return _hdmiInput.ColorSpace;
}
}

public ReadOnlyDictionary<uint, StringFeedback> HdrType {
get
{
return _hdmiInput.HdrType;
}
}

public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
{
try
Expand Down
2 changes: 2 additions & 0 deletions src/NvxEpi/Devices/NvxMockDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ private void BuildInputPorts()
public override bool CustomActivate()
{
Feedbacks.ToList().ForEach(x => x.FireUpdate());


return base.CustomActivate();
}

Expand Down
3 changes: 2 additions & 1 deletion src/NvxEpi/Extensions/HdmiInputExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
using Crestron.SimplSharpPro.DM.Endpoints;
using Crestron.SimplSharpPro.DM.Streaming;
using NvxEpi.Abstractions.HdmiInput;
using Org.BouncyCastle.Crypto.Prng;
using PepperDash.Core;

namespace NvxEpi.Extensions
{
public static class HdmiInputExtensions
{
{
public static void SetHdmi1HdcpCapability(this IHdmiInput device, ushort capability)
{
try
Expand Down
40 changes: 31 additions & 9 deletions src/NvxEpi/Features/Hdmi/Input/HdmiInput1.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,59 @@
using Crestron.SimplSharpPro.DM.Streaming;
using NvxEpi.Abstractions;
using NvxEpi.Services.Feedback;
using PepperDash.Essentials.Core;

namespace NvxEpi.Features.Hdmi.Input
{
public class HdmiInput1 : HdmiInputBase
{
private const uint InputNumber = 1;

public HdmiInput1(INvxDeviceWithHardware device)
: base(device)
{

var capability = (device.Hardware is DmNvxE760x)
? DmHdcpCapabilityValueFeedback.GetFeedback(device.Hardware)
: Hdmi1HdcpCapabilityValueFeedback.GetFeedback(device.Hardware);
: HdmiHdcpCapabilityValueFeedback.GetFeedback(device.Hardware, InputNumber);

_capability.Add(1, capability);
_capability.Add(InputNumber, capability);

var sync = (device.Hardware is DmNvxE760x)
? DmSyncDetectedFeedback.GetFeedback(device.Hardware)
: Hdmi1SyncDetectedFeedback.GetFeedback(device.Hardware);
: HdmiSyncDetectedFeedback.GetFeedback(device.Hardware, InputNumber);

_sync.Add(InputNumber, sync);

var inputResolution = HdmiCurrentResolutionFeedback.GetFeedback(device.Hardware, InputNumber);

_currentResolution.Add(InputNumber, inputResolution);

var capabilityString = HdmiHdcpCapabilityFeedback.GetFeedback(device.Hardware, InputNumber);

var audioChannels = HdmiAudioChannelsFeedback.GetFeedback(device.Hardware, InputNumber);

_audioChannels.Add(InputNumber, audioChannels);

var audioFormat = HdmiAudioFormatFeedback.GetFeedback(device.Hardware, InputNumber);

_audioFormat.Add(InputNumber, audioFormat);

var colorSpace = HdmiColorSpaceFeedback.GetFeedback(device.Hardware, InputNumber);

_sync.Add(1, sync);
_colorSpace.Add(InputNumber, colorSpace);

//TODO
var inputResolution = new StringFeedback(() => string.Empty);
_currentResolution.Add(1, inputResolution);
var hdrType = HdmiHdrTypeFeedback.GetFeedback(device.Hardware, InputNumber);

var capabilityString = Hdmi1HdcpCapabilityFeedback.GetFeedback(device.Hardware);
_hdrType.Add(InputNumber, hdrType);

Feedbacks.Add(capability);
Feedbacks.Add(sync);
Feedbacks.Add(inputResolution);
Feedbacks.Add(capabilityString);
Feedbacks.Add(audioChannels);
Feedbacks.Add(audioFormat);
Feedbacks.Add(colorSpace);
Feedbacks.Add(hdrType);
}
}
}
52 changes: 42 additions & 10 deletions src/NvxEpi/Features/Hdmi/Input/HdmiInput2.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,61 @@
using NvxEpi.Abstractions;
using Crestron.SimplSharpPro.DM;
using Crestron.SimplSharpPro.DM.Streaming;
using NvxEpi.Abstractions;
using NvxEpi.Services.Feedback;
using PepperDash.Essentials.Core;

namespace NvxEpi.Features.Hdmi.Input
{
public class HdmiInput2 : HdmiInput1
{
public HdmiInput2(INvxDeviceWithHardware device) : base(device)
private const uint InputNumber = 2;

public HdmiInput2(INvxDeviceWithHardware device)
: base(device)
{
var capability = Hdmi2HdcpCapabilityValueFeedback.GetFeedback(device.Hardware);
_capability.Add(2, capability);

var sync = Hdmi2SyncDetectedFeedback.GetFeedback(device.Hardware);
_sync.Add(2, sync);
var capability = (device.Hardware is DmNvxE760x)
? DmHdcpCapabilityValueFeedback.GetFeedback(device.Hardware)
: HdmiHdcpCapabilityValueFeedback.GetFeedback(device.Hardware, InputNumber);

_capability.Add(InputNumber, capability);

var sync = (device.Hardware is DmNvxE760x)
? DmSyncDetectedFeedback.GetFeedback(device.Hardware)
: HdmiSyncDetectedFeedback.GetFeedback(device.Hardware, InputNumber);

_sync.Add(InputNumber, sync);

var inputResolution = HdmiCurrentResolutionFeedback.GetFeedback(device.Hardware, InputNumber);

_currentResolution.Add(InputNumber, inputResolution);

var capabilityString = HdmiHdcpCapabilityFeedback.GetFeedback(device.Hardware, InputNumber);

var audioChannels = HdmiAudioChannelsFeedback.GetFeedback(device.Hardware, InputNumber);

_audioChannels.Add(InputNumber, audioChannels);

var audioFormat = HdmiAudioFormatFeedback.GetFeedback(device.Hardware, InputNumber);

_audioFormat.Add(InputNumber, audioFormat);

var colorSpace = HdmiColorSpaceFeedback.GetFeedback(device.Hardware, InputNumber);

_colorSpace.Add(InputNumber, colorSpace);

//TODO
var inputResolution = new StringFeedback(() => string.Empty);
_currentResolution.Add(2, inputResolution);
var hdrType = HdmiHdrTypeFeedback.GetFeedback(device.Hardware, InputNumber);

var capabilityString = Hdmi2HdcpCapabilityFeedback.GetFeedback(device.Hardware);
_hdrType.Add(InputNumber, hdrType);

Feedbacks.Add(capability);
Feedbacks.Add(sync);
Feedbacks.Add(inputResolution);
Feedbacks.Add(capabilityString);
Feedbacks.Add(audioChannels);
Feedbacks.Add(audioFormat);
Feedbacks.Add(colorSpace);
Feedbacks.Add(hdrType);
}
}
}
18 changes: 18 additions & 0 deletions src/NvxEpi/Features/Hdmi/Input/HdmiInputBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public abstract class HdmiInputBase : IHdmiInput
protected readonly Dictionary<uint, IntFeedback> _capability = new Dictionary<uint, IntFeedback>();
protected readonly Dictionary<uint, BoolFeedback> _sync = new Dictionary<uint, BoolFeedback>();
protected readonly Dictionary<uint, StringFeedback> _currentResolution = new Dictionary<uint, StringFeedback>();
protected readonly Dictionary<uint, IntFeedback> _audioChannels = new Dictionary<uint, IntFeedback>();
protected readonly Dictionary<uint, StringFeedback> _audioFormat = new Dictionary<uint, StringFeedback>();
protected readonly Dictionary<uint, StringFeedback> _colorSpace = new Dictionary<uint, StringFeedback>();
protected readonly Dictionary<uint, StringFeedback> _hdrType = new Dictionary<uint, StringFeedback>();

private readonly INvxDeviceWithHardware _device;

Expand Down Expand Up @@ -84,5 +88,19 @@ public ReadOnlyDictionary<uint, StringFeedback> CurrentResolution
{
get { return new ReadOnlyDictionary<uint, StringFeedback>(_currentResolution); }
}

public ReadOnlyDictionary<uint, IntFeedback> AudioChannels
{
get { return new ReadOnlyDictionary<uint, IntFeedback>(_audioChannels); }
}

public ReadOnlyDictionary<uint, StringFeedback> AudioFormat
{
get { return new ReadOnlyDictionary<uint, StringFeedback>(_audioFormat); }
}

public ReadOnlyDictionary<uint, StringFeedback> ColorSpace { get { return new ReadOnlyDictionary<uint, StringFeedback>(_colorSpace); } }

public ReadOnlyDictionary<uint, StringFeedback> HdrType { get { return new ReadOnlyDictionary<uint, StringFeedback>(_hdrType); } }
}
}
Loading

0 comments on commit 1628303

Please sign in to comment.