-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bc0a2c
commit 596c4d7
Showing
3 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using NvxEpi.Abstractions.HdmiInput; | ||
using NvxEpi.Devices; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Routing; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NvxEpi.Features.Routing | ||
{ | ||
public class NvxMatrixInput : IRoutingInputSlot | ||
{ | ||
private readonly NvxBaseDevice _device; | ||
|
||
public NvxMatrixInput(NvxBaseDevice device) | ||
{ | ||
_device = device; | ||
|
||
if(_device is IHdmiInput hdmiInput) | ||
{ | ||
foreach(var feedback in hdmiInput.Feedbacks) | ||
{ | ||
feedback.OutputChange += (o, a) => VideoSyncChanged?.Invoke(this, new EventArgs()); | ||
} | ||
} | ||
} | ||
|
||
public string TxDeviceKey => _device.Key; | ||
|
||
public int SlotNumber => _device.DeviceId; | ||
|
||
public eRoutingSignalType SupportedSignalTypes => eRoutingSignalType.AudioVideo | eRoutingSignalType.UsbInput | eRoutingSignalType.UsbOutput | eRoutingSignalType.SecondaryAudio; | ||
|
||
public string Name => _device.Name; | ||
|
||
public BoolFeedback IsOnline => _device.IsOnline; | ||
|
||
public bool VideoSyncDetected => _device is IHdmiInput inputDevice ? inputDevice.SyncDetected.Any(fb => fb.Value.BoolValue) : false; | ||
|
||
public string Key => $"{_device.Key}-matrixInput"; | ||
|
||
public event EventHandler VideoSyncChanged; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using NvxEpi.Abstractions.Stream; | ||
using NvxEpi.Devices; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Routing; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace NvxEpi.Features.Routing | ||
{ | ||
public class NvxMatrixOutput : IRoutingOutputSlot | ||
{ | ||
private readonly NvxBaseDevice _device; | ||
|
||
public NvxMatrixOutput(NvxBaseDevice device, IMatrixRouting parent) | ||
{ | ||
_device = device; | ||
|
||
_device.CurrentStreamId.OutputChange += (o, a) => | ||
{ | ||
var inputSlot = parent.InputSlots.Values.FirstOrDefault(input => input.SlotNumber == a.IntValue); | ||
|
||
SetInputRoute(eRoutingSignalType.Video, inputSlot); | ||
|
||
if (!_device.IsStreamingSecondaryAudio.BoolValue) | ||
{ | ||
SetInputRoute(eRoutingSignalType.Audio, inputSlot); | ||
} | ||
}; | ||
|
||
_device.CurrentSecondaryAudioStreamId.OutputChange += (o, a) => | ||
{ | ||
var inputSlot = parent.InputSlots.Values.FirstOrDefault(input => input.SlotNumber == a.IntValue); | ||
|
||
SetInputRoute(eRoutingSignalType.SecondaryAudio, inputSlot); | ||
}; | ||
} | ||
|
||
public string RxDeviceKey { get; set; } | ||
|
||
private readonly Dictionary<eRoutingSignalType, IRoutingInputSlot> currentRoutes = new Dictionary<eRoutingSignalType, IRoutingInputSlot> | ||
{ | ||
{eRoutingSignalType.Audio, null }, | ||
{eRoutingSignalType.Video, null }, | ||
{eRoutingSignalType.UsbInput, null }, | ||
{eRoutingSignalType.UsbOutput, null }, | ||
{eRoutingSignalType.SecondaryAudio, null }, | ||
}; | ||
|
||
public IStreamWithHardware Device => _device; | ||
|
||
private void SetInputRoute(eRoutingSignalType type, IRoutingInputSlot input) | ||
{ | ||
if (currentRoutes.ContainsKey(type)) | ||
{ | ||
currentRoutes[type] = input; | ||
|
||
OutputSlotChanged?.Invoke(this, new EventArgs()); | ||
|
||
return; | ||
} | ||
|
||
currentRoutes.Add(type, input); | ||
|
||
OutputSlotChanged?.Invoke(this, new EventArgs()); | ||
} | ||
|
||
public Dictionary<eRoutingSignalType, IRoutingInputSlot> CurrentRoutes => currentRoutes; | ||
|
||
public int SlotNumber => _device.DeviceId; | ||
|
||
public eRoutingSignalType SupportedSignalTypes => eRoutingSignalType.AudioVideo | eRoutingSignalType.UsbInput | eRoutingSignalType.UsbOutput | eRoutingSignalType.SecondaryAudio; | ||
|
||
public string Name => _device.Name; | ||
|
||
public string Key => $"{_device.Key}-matrixInput"; | ||
|
||
public event EventHandler<EventArgs> OutputSlotChanged; | ||
} | ||
} |