Compare commits

...

3 Commits

Author SHA1 Message Date
Andrew Welker
69e83735b8 feat: update PD Core 2024-03-20 10:35:03 -05:00
Andrew Welker
e12f9f0afd feat: add generic soft codec device 2024-03-19 16:11:58 -05:00
Andrew Welker
f6cd2b57c1 feat: add GenericSink 2024-03-19 15:53:04 -05:00
6 changed files with 145 additions and 4 deletions

View File

@@ -23,7 +23,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-392" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-393" />
</ItemGroup>
<ItemGroup>
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />

View File

@@ -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<RoutingInputPort>();
var inputPort = new RoutingInputPort($"{Key}-{RoutingPortNames.AnyVideoIn}", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null, this);
InputPorts.Add(inputPort);
}
public RoutingPortCollection<RoutingInputPort> 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<GenericSink>
{
public GenericSinkFactory()
{
TypeNames = new List<string>() { "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);
}
}
}

View File

@@ -54,5 +54,4 @@ namespace PepperDash.Essentials.Devices.Common
return new GenericSource(dc.Key, dc.Name);
}
}
}

View File

@@ -27,6 +27,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-392" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-393" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,80 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
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, IRoutingInputsOutputs
{
public GenericSoftCodec(string key, string name, GenericSoftCodecProperties props) : base(key, name)
{
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 => throw new NotImplementedException();
public RoutingPortCollection<RoutingOutputPort> OutputPorts => throw new NotImplementedException();
}
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.Console(1, "Attempting to create new Generic SoftCodec Device");
var props = dc.Properties.ToObject<GenericSoftCodecProperties>();
return new GenericSoftCodec(dc.Key, dc.Name, props);
}
}
}

View File

@@ -47,7 +47,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.20.42" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-392" />
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-393" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />