using System.Collections.Generic;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using Serilog.Events;
namespace PepperDash.Essentials.Devices.Common.Generic
{
///
/// Represents a GenericSink
///
public class GenericSink : EssentialsDevice, IRoutingSinkWithSwitchingWithInputPort
{
///
/// Initializes a new instance of the GenericSink class
///
/// The device key
/// The device name
public GenericSink(string key, string name) : base(key, name)
{
InputPorts = new RoutingPortCollection();
var inputPort = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo | eRoutingSignalType.SecondaryAudio, eRoutingPortConnectionType.Hdmi, null, this);
InputPorts.Add(inputPort);
}
///
/// Gets or sets the InputPorts
///
public RoutingPortCollection InputPorts { get; private set; }
///
/// Gets or sets the CurrentSourceInfoKey
///
public string CurrentSourceInfoKey { get; set; }
private SourceListItem _currentSource;
///
/// Gets or sets the CurrentSourceInfo
///
public SourceListItem CurrentSourceInfo
{
get => _currentSource;
set
{
if (value == _currentSource)
{
return;
}
CurrentSourceChange?.Invoke(_currentSource, ChangeType.WillChange);
_currentSource = value;
CurrentSourceChange?.Invoke(_currentSource, ChangeType.DidChange);
}
}
///
/// Gets the current input port
///
public RoutingInputPort CurrentInputPort => InputPorts[0];
///
/// Event fired when the current source changes
///
public event SourceInfoChangeHandler CurrentSourceChange;
///
public event InputChangedEventHandler InputChanged;
///
public void ExecuteSwitch(object inputSelector)
{
this.LogDebug("GenericSink Executing Switch to: {inputSelector}", inputSelector);
}
}
///
/// Represents a GenericSinkFactory
///
public class GenericSinkFactory : EssentialsDeviceFactory
{
///
/// Initializes a new instance of the GenericSinkFactory class
///
public GenericSinkFactory()
{
TypeNames = new List() { "genericsink", "genericdestination" };
}
///
/// BuildDevice method
///
///
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Sink Device");
return new GenericSink(dc.Key, dc.Name);
}
}
}