Merge pull request #221 from PepperDash/feature/releaseAndMakeRoute-nullEx

Change ReleaseAndMakeRoute to use IRoutingSinkNoSwitching instead of IRoutingInputs
This commit is contained in:
Andrew Welker
2020-05-28 18:32:15 -06:00
committed by GitHub
5 changed files with 127 additions and 112 deletions

View File

@@ -555,7 +555,7 @@ namespace PepperDash.Essentials
/// <returns></returns> /// <returns></returns>
bool DoRoute(SourceRouteListItem route, SourceListItem sourceItem, string sourceItemKey) bool DoRoute(SourceRouteListItem route, SourceListItem sourceItem, string sourceItemKey)
{ {
IRoutingSinkNoSwitching dest = null; IRoutingSink dest = null;
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
dest = DefaultAudioDevice as IRoutingSinkNoSwitching; dest = DefaultAudioDevice as IRoutingSinkNoSwitching;

View File

@@ -71,7 +71,7 @@ namespace PepperDash.Essentials
public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; } public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; }
public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; } public IRoutingSink DefaultAudioDevice { get; private set; }
public IBasicVolumeControls DefaultVolumeControls { get; private set; } public IBasicVolumeControls DefaultVolumeControls { get; private set; }
public bool ExcludeFromGlobalFunctions { get; set; } public bool ExcludeFromGlobalFunctions { get; set; }
@@ -471,14 +471,14 @@ namespace PepperDash.Essentials
/// <returns></returns> /// <returns></returns>
bool DoRoute(SourceRouteListItem route) bool DoRoute(SourceRouteListItem route)
{ {
IRoutingSinkNoSwitching dest = null; IRoutingSink dest = null;
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
dest = DefaultAudioDevice; dest = DefaultAudioDevice;
else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
dest = DefaultDisplay; dest = DefaultDisplay;
else else
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching; dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink;
if (dest == null) if (dest == null)
{ {

View File

@@ -590,7 +590,7 @@ namespace PepperDash.Essentials
/// <returns></returns> /// <returns></returns>
bool DoRoute(SourceRouteListItem route) bool DoRoute(SourceRouteListItem route)
{ {
IRoutingSinkNoSwitching dest = null; IRoutingSink dest = null;
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
dest = DefaultAudioDevice as IRoutingSinkNoSwitching; dest = DefaultAudioDevice as IRoutingSinkNoSwitching;

View File

@@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Core
/// and then attempts a new Route and if sucessful, stores that RouteDescriptor /// and then attempts a new Route and if sucessful, stores that RouteDescriptor
/// in RouteDescriptorCollection.DefaultCollection /// in RouteDescriptorCollection.DefaultCollection
/// </summary> /// </summary>
public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) public static void ReleaseAndMakeRoute(this IRoutingSink destination, IRoutingOutputs source, eRoutingSignalType signalType)
{ {
destination.ReleaseRoute(); destination.ReleaseRoute();
@@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core
/// RouteDescriptorCollection.DefaultCollection /// RouteDescriptorCollection.DefaultCollection
/// </summary> /// </summary>
/// <param name="destination"></param> /// <param name="destination"></param>
public static void ReleaseRoute(this IRoutingInputs destination) public static void ReleaseRoute(this IRoutingSink destination)
{ {
var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination); var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination);
if (current != null) if (current != null)
@@ -56,7 +56,7 @@ namespace PepperDash.Essentials.Core
/// of an audio/video route are discovered a route descriptor is returned. If no route is /// of an audio/video route are discovered a route descriptor is returned. If no route is
/// discovered, then null is returned /// discovered, then null is returned
/// </summary> /// </summary>
public static RouteDescriptor GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) public static RouteDescriptor GetRouteToSource(this IRoutingSink destination, IRoutingOutputs source, eRoutingSignalType signalType)
{ {
var routeDescr = new RouteDescriptor(source, destination, signalType); var routeDescr = new RouteDescriptor(source, destination, signalType);
// if it's a single signal type, find the route // if it's a single signal type, find the route
@@ -265,8 +265,14 @@ namespace PepperDash.Essentials.Core
foreach (var route in Routes) foreach (var route in Routes)
{ {
Debug.Console(2, "ExecuteRoutes: {0}", route.ToString()); Debug.Console(2, "ExecuteRoutes: {0}", route.ToString());
if (route.SwitchingDevice is IRoutingSinkWithSwitching) if (route.SwitchingDevice is IRoutingSink)
(route.SwitchingDevice as IRoutingSinkWithSwitching).ExecuteSwitch(route.InputPort.Selector); {
var device = route.SwitchingDevice as IRoutingSinkWithSwitching;
if (device == null)
continue;
device.ExecuteSwitch(route.InputPort.Selector);
}
else if (route.SwitchingDevice is IRouting) else if (route.SwitchingDevice is IRouting)
{ {
(route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType); (route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType);

View File

@@ -51,7 +51,16 @@ namespace PepperDash.Essentials.Core
/// <summary> /// <summary>
/// For fixed-source endpoint devices /// For fixed-source endpoint devices
/// </summary> /// </summary>
public interface IRoutingSinkNoSwitching : IRoutingInputs, IHasCurrentSourceInfoChange public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange
{
}
/// <summary>
/// For fixed-source endpoint devices
/// </summary>
[Obsolete]
public interface IRoutingSinkNoSwitching : IRoutingSink
{ {
} }
@@ -59,7 +68,7 @@ namespace PepperDash.Essentials.Core
/// <summary> /// <summary>
/// Endpoint device like a display, that selects inputs /// Endpoint device like a display, that selects inputs
/// </summary> /// </summary>
public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching, IHasCurrentSourceInfoChange public interface IRoutingSinkWithSwitching : IRoutingSink
{ {
//void ClearRoute(); //void ClearRoute();
void ExecuteSwitch(object inputSelector); void ExecuteSwitch(object inputSelector);