mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-27 03:14:57 +00:00
111 lines
3.5 KiB
C#
111 lines
3.5 KiB
C#
using Newtonsoft.Json;
|
|
using PepperDash.Core;
|
|
using PepperDash.Essentials.Core;
|
|
using PepperDash.Essentials.Core.Config;
|
|
using Serilog.Events;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PepperDash.Essentials.Devices.Common.SoftCodec
|
|
{
|
|
public class GenericSoftCodec : EssentialsDevice, IRoutingSource, IRoutingSink
|
|
{
|
|
public GenericSoftCodec(string key, string name, GenericSoftCodecProperties props) : base(key, name)
|
|
{
|
|
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
|
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
|
|
|
for(var i = 1; i <= props.OutputCount; i++)
|
|
{
|
|
var outputPort = new RoutingOutputPort($"{Key}-output{i}", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null, this);
|
|
|
|
OutputPorts.Add(outputPort);
|
|
}
|
|
|
|
for(var i = 1; i<= props.ContentInputCount; i++)
|
|
{
|
|
var inputPort = new RoutingInputPort($"{Key}-contentInput{i}", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null, this);
|
|
|
|
InputPorts.Add(inputPort);
|
|
}
|
|
|
|
if (!props.HasCameraInputs)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for(var i = 1; i <=props.CameraInputCount; i++)
|
|
{
|
|
var cameraPort = new RoutingInputPort($"{Key}-cameraInput{i}", eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null, this);
|
|
|
|
InputPorts.Add(cameraPort);
|
|
}
|
|
}
|
|
|
|
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
|
|
|
|
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
|
public string CurrentSourceInfoKey { get ; set; }
|
|
public SourceListItem CurrentSourceInfo
|
|
{
|
|
get
|
|
{
|
|
return _CurrentSourceInfo;
|
|
}
|
|
set
|
|
{
|
|
if (value == _CurrentSourceInfo) return;
|
|
|
|
var handler = CurrentSourceChange;
|
|
|
|
if (handler != null)
|
|
handler(_CurrentSourceInfo, ChangeType.WillChange);
|
|
|
|
_CurrentSourceInfo = value;
|
|
|
|
if (handler != null)
|
|
handler(_CurrentSourceInfo, ChangeType.DidChange);
|
|
}
|
|
}
|
|
|
|
SourceListItem _CurrentSourceInfo;
|
|
|
|
public event SourceInfoChangeHandler CurrentSourceChange;
|
|
}
|
|
|
|
public class GenericSoftCodecProperties
|
|
{
|
|
[JsonProperty("hasCameraInputs")]
|
|
public bool HasCameraInputs { get; set; }
|
|
|
|
[JsonProperty("cameraInputCount")]
|
|
public int CameraInputCount { get; set; }
|
|
|
|
[JsonProperty("contentInputCount")]
|
|
public int ContentInputCount { get; set; }
|
|
|
|
[JsonProperty("contentOutputCount")]
|
|
public int OutputCount { get; set; }
|
|
}
|
|
|
|
public class GenericSoftCodecFactory: EssentialsDeviceFactory<GenericSoftCodec>
|
|
{
|
|
public GenericSoftCodecFactory()
|
|
{
|
|
TypeNames = new List<string> { "genericsoftcodec" };
|
|
}
|
|
|
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
|
{
|
|
Debug.LogMessage(LogEventLevel.Debug, "Attempting to create new Generic SoftCodec Device");
|
|
|
|
var props = dc.Properties.ToObject<GenericSoftCodecProperties>();
|
|
|
|
return new GenericSoftCodec(dc.Key, dc.Name, props);
|
|
}
|
|
}
|
|
}
|