Refactored for source change handler updates

This commit is contained in:
Neil Dorin
2019-11-08 12:30:49 -07:00
parent c22e95cad2
commit 3560880e50
19 changed files with 178 additions and 73 deletions

View File

@@ -334,7 +334,7 @@ namespace PepperDash.Essentials
} }
void Room_CurrentSingleSourceChange(EssentialsRoomBase room, PepperDash.Essentials.Core.SourceListItem info, ChangeType type) void Room_CurrentSingleSourceChange(PepperDash.Essentials.Core.SourceListItem info, ChangeType type)
{ {
/* Example message /* Example message
* { * {
@@ -395,11 +395,14 @@ namespace PepperDash.Essentials
if (dev is ITransport) if (dev is ITransport)
(dev as ITransport).LinkActions(Parent); (dev as ITransport).LinkActions(Parent);
var srcRm = room as IHasCurrentSourceInfoChange; var srcRm = Room as IHasCurrentSourceInfoChange;
PostStatusMessage(new if (srcRm != null)
{ {
selectedSourceKey = srcRm.CurrentSourceInfoKey PostStatusMessage(new
}); {
selectedSourceKey = srcRm.CurrentSourceInfoKey
});
}
} }
} }
} }

View File

@@ -12,6 +12,32 @@ namespace PepperDash.Essentials
{ {
public class Amplifier : Device, IRoutingSinkNoSwitching public class Amplifier : Device, IRoutingSinkNoSwitching
{ {
public event SourceInfoChangeHandler CurrentSourceChange;
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 RoutingInputPort AudioIn { get; private set; } public RoutingInputPort AudioIn { get; private set; }
public Amplifier(string key, string name) public Amplifier(string key, string name)

View File

@@ -11,7 +11,5 @@ namespace PepperDash.Essentials.Room.Config
public class EssentialsDualDisplayRoomPropertiesConfig : EssentialsNDisplayRoomPropertiesConfig public class EssentialsDualDisplayRoomPropertiesConfig : EssentialsNDisplayRoomPropertiesConfig
{ {
public const string LeftDisplayId = "leftDisplay";
public const string RightDisplayId = "rightDisplay";
} }
} }

View File

@@ -4,6 +4,9 @@ using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace PepperDash.Essentials.Room.Config namespace PepperDash.Essentials.Room.Config
@@ -18,13 +21,19 @@ namespace PepperDash.Essentials.Room.Config
[JsonProperty("defaultVideoBehavior")] [JsonProperty("defaultVideoBehavior")]
public string DefaultVideoBehavior { get; set; } public string DefaultVideoBehavior { get; set; }
[JsonProperty("displays")] [JsonProperty("displays")]
public Dictionary<string, string> Displays { get; set; } public Dictionary<eSourceListItemDestinationTypes, DisplayItem> Displays { get; set; }
public EssentialsNDisplayRoomPropertiesConfig() public EssentialsNDisplayRoomPropertiesConfig()
{ {
Displays = new Dictionary<string, string>(); Displays = new Dictionary<eSourceListItemDestinationTypes, DisplayItem>();
} }
} }
public class DisplayItem : IKeyName
{
public string Key { get; set; }
public string Name { get; set; }
}
} }

View File

@@ -44,8 +44,8 @@ namespace PepperDash.Essentials.Room.Types
/// </summary> /// </summary>
public BoolFeedback IsSharingFeedback { get; private set; } public BoolFeedback IsSharingFeedback { get; private set; }
IRoutingSinkWithSwitching LeftDisplay { get; private set; } public IRoutingSinkWithSwitching LeftDisplay { get; private set; }
IRoutingSinkWithSwitching RightDisplay { get; private set; } public IRoutingSinkWithSwitching RightDisplay { get; private set; }
protected override Func<bool> OnFeedbackFunc protected override Func<bool> OnFeedbackFunc
@@ -171,19 +171,25 @@ namespace PepperDash.Essentials.Room.Types
PropertiesConfig = JsonConvert.DeserializeObject<EssentialsDualDisplayRoomPropertiesConfig> PropertiesConfig = JsonConvert.DeserializeObject<EssentialsDualDisplayRoomPropertiesConfig>
(config.Properties.ToString()); (config.Properties.ToString());
var leftDispKey = PropertiesConfig.Displays[EssentialsDualDisplayRoomPropertiesConfig.LeftDisplayId]; var leftDisp = PropertiesConfig.Displays[eSourceListItemDestinationTypes.leftDisplay];
if (leftDisp != null)
{
if (!string.IsNullOrEmpty(leftDispKey)) if (!string.IsNullOrEmpty(leftDisp.Key))
LeftDisplay = DeviceManager.GetDeviceForKey(leftDispKey) as IRoutingSinkWithSwitching; LeftDisplay = DeviceManager.GetDeviceForKey(leftDisp.Key) as IRoutingSinkWithSwitching;
else else
Debug.Console(0, this, "Unable to get LeftDisplay for Room"); Debug.Console(0, this, "Unable to get LeftDisplay for Room");
}
var rightDispKey = PropertiesConfig.Displays[EssentialsDualDisplayRoomPropertiesConfig.RightDisplayId]; var rightDisp = PropertiesConfig.Displays[eSourceListItemDestinationTypes.rightDisplay];
if (rightDisp != null)
{
if (!string.IsNullOrEmpty(rightDispKey)) if (!string.IsNullOrEmpty(rightDisp.Key))
LeftDisplay = DeviceManager.GetDeviceForKey(rightDispKey) as IRoutingSinkWithSwitching; LeftDisplay = DeviceManager.GetDeviceForKey(rightDisp.Key) as IRoutingSinkWithSwitching;
else else
Debug.Console(0, this, "Unable to get LeftDisplay for Room"); Debug.Console(0, this, "Unable to get LeftDisplay for Room");
}
VideoCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.VideoCodecKey) as VideoCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.VideoCodecKey) as
PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase; PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase;
@@ -428,12 +434,12 @@ namespace PepperDash.Essentials.Room.Types
LastSourceKey = routeKey; LastSourceKey = routeKey;
} }
else //else
CurrentSourceInfoKey = null; // CurrentSourceInfoKey = null;
// hand off the individual routes to this helper // hand off the individual routes to this helper
foreach (var route in item.RouteList) foreach (var route in item.RouteList)
DoRouteItem(route); DoRouteItem(route, item, routeKey);
// Start usage timer on routed source // Start usage timer on routed source
var usageNewSource = item.SourceDevice as IUsageTracking; var usageNewSource = item.SourceDevice as IUsageTracking;
@@ -451,8 +457,7 @@ namespace PepperDash.Essentials.Room.Types
if (string.IsNullOrEmpty(item.VolumeControlKey) if (string.IsNullOrEmpty(item.VolumeControlKey)
|| item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase)) || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase))
volDev = DefaultVolumeControls; volDev = DefaultVolumeControls;
else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
volDev = DefaultDisplay as IBasicVolumeControls;
// Or a specific device, probably rarely used. // Or a specific device, probably rarely used.
else else
{ {
@@ -489,14 +494,17 @@ namespace PepperDash.Essentials.Room.Types
// store the name and UI info for routes // store the name and UI info for routes
if (item.SourceKey == "$off") if (item.SourceKey == "$off")
{ {
CurrentSourceInfoKey = routeKey; LeftDisplay.CurrentSourceInfoKey = routeKey;
CurrentSourceInfo = null; LeftDisplay.CurrentSourceInfo = null;
} RightDisplay.CurrentSourceInfoKey = routeKey;
else if (item.SourceKey != null) RightDisplay.CurrentSourceInfo = null;
{
CurrentSourceInfoKey = routeKey;
CurrentSourceInfo = item;
} }
//else if (item.SourceKey != null)
//{
// if(item.RouteList
// CurrentSourceInfoKey = routeKey;
// CurrentSourceInfo = item;
//}
OnFeedback.FireUpdate(); OnFeedback.FireUpdate();
@@ -518,7 +526,7 @@ namespace PepperDash.Essentials.Room.Types
/// ///
/// </summary> /// </summary>
/// <param name="route"></param> /// <param name="route"></param>
void DoRouteItem(SourceRouteListItem route) void DoRouteItem(SourceRouteListItem route, SourceListItem sourceItem, string sourceItemKey)
{ {
// if there is a $defaultAll on route, run two separate // if there is a $defaultAll on route, run two separate
if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase))
@@ -530,10 +538,10 @@ namespace PepperDash.Essentials.Room.Types
SourceKey = route.SourceKey, SourceKey = route.SourceKey,
Type = eRoutingSignalType.Video Type = eRoutingSignalType.Video
}; };
DoRoute(tempVideo); DoRoute(tempVideo, sourceItem, sourceItemKey);
} }
else else
DoRoute(route); DoRoute(route, sourceItem, sourceItemKey);
} }
/// <summary> /// <summary>
@@ -541,14 +549,16 @@ namespace PepperDash.Essentials.Room.Types
/// </summary> /// </summary>
/// <param name="route"></param> /// <param name="route"></param>
/// <returns></returns> /// <returns></returns>
bool DoRoute(SourceRouteListItem route) bool DoRoute(SourceRouteListItem route, SourceListItem sourceItem, string sourceItemKey)
{ {
IRoutingSinkNoSwitching dest = null; IRoutingSinkNoSwitching dest = null;
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
dest = DefaultAudioDevice as IRoutingSinkNoSwitching; dest = DefaultAudioDevice as IRoutingSinkNoSwitching;
else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) else if (route.DestinationKey.Equals(LeftDisplay.Key, StringComparison.OrdinalIgnoreCase))
dest = DefaultDisplay; dest = LeftDisplay;
else if (route.DestinationKey.Equals(RightDisplay.Key, StringComparison.OrdinalIgnoreCase))
dest = RightDisplay;
else else
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching; dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
@@ -561,6 +571,9 @@ namespace PepperDash.Essentials.Room.Types
if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase)) if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
{ {
dest.ReleaseRoute(); dest.ReleaseRoute();
if (dest is IPower) if (dest is IPower)
(dest as IPower).PowerOff(); (dest as IPower).PowerOff();
} }
@@ -573,6 +586,9 @@ namespace PepperDash.Essentials.Room.Types
return false; return false;
} }
dest.ReleaseAndMakeRoute(source, route.Type); dest.ReleaseAndMakeRoute(source, route.Type);
dest.CurrentSourceInfoKey = sourceItemKey;
dest.CurrentSourceInfo = sourceItem;
} }
return true; return true;
} }

View File

@@ -119,7 +119,7 @@ namespace PepperDash.Essentials
public SourceListItem CurrentSourceInfo public SourceListItem CurrentSourceInfo
{ {
get { return _CurrentSourceInfo; } get { return _CurrentSourceInfo; }
private set set
{ {
if (value == _CurrentSourceInfo) return; if (value == _CurrentSourceInfo) return;
@@ -129,7 +129,7 @@ namespace PepperDash.Essentials
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control"); (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control");
if (handler != null) if (handler != null)
handler(this, _CurrentSourceInfo, ChangeType.WillChange); handler(_CurrentSourceInfo, ChangeType.WillChange);
_CurrentSourceInfo = value; _CurrentSourceInfo = value;
@@ -137,12 +137,12 @@ namespace PepperDash.Essentials
if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control"); (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control");
if (handler != null) if (handler != null)
handler(this, _CurrentSourceInfo, ChangeType.DidChange); handler( _CurrentSourceInfo, ChangeType.DidChange);
} }
} }
SourceListItem _CurrentSourceInfo; SourceListItem _CurrentSourceInfo;
public string CurrentSourceInfoKey { get; private set; } public string CurrentSourceInfoKey { get; set; }
public EssentialsHuddleSpaceRoom(DeviceConfig config) public EssentialsHuddleSpaceRoom(DeviceConfig config)
: base(config) : base(config)

View File

@@ -157,7 +157,7 @@ namespace PepperDash.Essentials
public SourceListItem CurrentSourceInfo public SourceListItem CurrentSourceInfo
{ {
get { return _CurrentSourceInfo; } get { return _CurrentSourceInfo; }
private set set
{ {
if (value == _CurrentSourceInfo) return; if (value == _CurrentSourceInfo) return;
@@ -167,7 +167,7 @@ namespace PepperDash.Essentials
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control"); (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control");
if (handler != null) if (handler != null)
handler(this, _CurrentSourceInfo, ChangeType.WillChange); handler(_CurrentSourceInfo, ChangeType.WillChange);
_CurrentSourceInfo = value; _CurrentSourceInfo = value;
@@ -175,12 +175,12 @@ namespace PepperDash.Essentials
if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control"); (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control");
if (handler != null) if (handler != null)
handler(this, _CurrentSourceInfo, ChangeType.DidChange); handler(_CurrentSourceInfo, ChangeType.DidChange);
} }
} }
SourceListItem _CurrentSourceInfo; SourceListItem _CurrentSourceInfo;
public string CurrentSourceInfoKey { get; private set; } public string CurrentSourceInfoKey { get; set; }
/// <summary> /// <summary>
/// "codecOsd" /// "codecOsd"

View File

@@ -21,22 +21,13 @@ namespace PepperDash.Essentials.Room.Types
{ {
//public event SourceInfoChangeHandler CurrentSingleSourceChange; //public event SourceInfoChangeHandler CurrentSingleSourceChange;
public Dictionary<string, IRoutingSinkWithSwitching> Displays { get; protected set; }
public EssentialsNDisplayRoomBase(DeviceConfig config) public EssentialsNDisplayRoomBase(DeviceConfig config)
: base (config) : base (config)
{ {
Displays = new Dictionary<string, IRoutingSinkWithSwitching>();
var propertiesConfig = JsonConvert.DeserializeObject<EssentialsNDisplayRoomPropertiesConfig>(config.Properties.ToString()); var propertiesConfig = JsonConvert.DeserializeObject<EssentialsNDisplayRoomPropertiesConfig>(config.Properties.ToString());
foreach (var display in propertiesConfig.Displays)
{
var displayDevice = DeviceManager.GetDeviceForKey(display.Value) as IRoutingSinkWithSwitching;
if (displayDevice != null)
Displays.Add(display.Key, displayDevice);
}
} }
} }
} }

View File

@@ -29,7 +29,7 @@ namespace PepperDash.Essentials
room.CurrentSourceChange += room_CurrentSourceInfoChange; room.CurrentSourceChange += room_CurrentSourceInfoChange;
} }
void room_CurrentSourceInfoChange(EssentialsRoomBase room, SourceListItem info, ChangeType type) void room_CurrentSourceInfoChange(SourceListItem info, ChangeType type)
{ {
if (type == ChangeType.WillChange && info == SourceItem) if (type == ChangeType.WillChange && info == SourceItem)
ClearFeedback(); ClearFeedback();

View File

@@ -1064,8 +1064,7 @@ namespace PepperDash.Essentials
/// <summary> /// <summary>
/// Handles source change /// Handles source change
/// </summary> /// </summary>
void CurrentRoom_SourceInfoChange(EssentialsRoomBase room, void CurrentRoom_SourceInfoChange(SourceListItem info, ChangeType change)
SourceListItem info, ChangeType change)
{ {
if (change == ChangeType.WillChange) if (change == ChangeType.WillChange)
DisconnectSource(info); DisconnectSource(info);

View File

@@ -1050,7 +1050,7 @@ namespace PepperDash.Essentials
/// <param name="room"></param> /// <param name="room"></param>
/// <param name="info"></param> /// <param name="info"></param>
/// <param name="type"></param> /// <param name="type"></param>
void CurrentRoom_CurrentSingleSourceChange(EssentialsRoomBase room, SourceListItem info, ChangeType type) void CurrentRoom_CurrentSingleSourceChange(SourceListItem info, ChangeType type)
{ {
if (_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && _CurrentRoom.CurrentSourceInfo != null) if (_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && _CurrentRoom.CurrentSourceInfo != null)
TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = _CurrentRoom.CurrentSourceInfo.PreferredName; TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = _CurrentRoom.CurrentSourceInfo.PreferredName;
@@ -1363,8 +1363,7 @@ namespace PepperDash.Essentials
/// <summary> /// <summary>
/// Handles source change /// Handles source change
/// </summary> /// </summary>
void CurrentRoom_SourceInfoChange(EssentialsRoomBase room, void CurrentRoom_SourceInfoChange(SourceListItem info, ChangeType change)
SourceListItem info, ChangeType change)
{ {
if (change == ChangeType.WillChange) if (change == ChangeType.WillChange)
DisconnectSource(info); DisconnectSource(info);

View File

@@ -68,7 +68,7 @@ namespace PepperDash.Essentials
parent.SetItemButtonAction(index, buttonAction); parent.SetItemButtonAction(index, buttonAction);
} }
void room_CurrentSourceInfoChange(EssentialsRoomBase room, SourceListItem info, ChangeType type) void room_CurrentSourceInfoChange(SourceListItem info, ChangeType type)
{ {
UpdateItem(info); UpdateItem(info);
} }

View File

@@ -95,6 +95,9 @@ namespace PepperDash.Essentials.Core
[JsonProperty("disableRoutedSharing")] [JsonProperty("disableRoutedSharing")]
public bool DisableRoutedSharing { get; set; } public bool DisableRoutedSharing { get; set; }
[JsonProperty("destinations")]
public List<eSourceListItemDestinationTypes> Destinations { get; set; }
public SourceListItem() public SourceListItem()
{ {
Icon = "Blank"; Icon = "Blank";
@@ -112,4 +115,16 @@ namespace PepperDash.Essentials.Core
[JsonProperty("type")] [JsonProperty("type")]
public eRoutingSignalType Type { get; set; } public eRoutingSignalType Type { get; set; }
} }
/// <summary>
/// Defines the valid destination types for SourceListItems in a room
/// </summary>
public enum eSourceListItemDestinationTypes
{
defaultDisplay,
leftDisplay,
rightDisplay,
programAudio,
codecContent
}
} }

View File

@@ -12,7 +12,7 @@ using PepperDash.Essentials.Core.Routing;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IPower, IWarmingCooling, IRoutingSinkWithSwitching public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IPower, IWarmingCooling
{ {
public IrOutputPortController IrPort { get; private set; } public IrOutputPortController IrPort { get; private set; }
public ushort IrPulseTime { get; set; } public ushort IrPulseTime { get; set; }

View File

@@ -20,8 +20,29 @@ namespace PepperDash.Essentials.Core
{ {
public event SourceInfoChangeHandler CurrentSourceChange; public event SourceInfoChangeHandler CurrentSourceChange;
public string CurrentSourceInfoKey { get; protected set; } public string CurrentSourceInfoKey { get; set; }
public SourceListItem CurrentSourceInfo { get; protected 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 BoolFeedback PowerIsOnFeedback { get; protected set; } public BoolFeedback PowerIsOnFeedback { get; protected set; }
public BoolFeedback IsCoolingDownFeedback { get; protected set; } public BoolFeedback IsCoolingDownFeedback { get; protected set; }

View File

@@ -1387,7 +1387,7 @@ namespace PepperDash.Essentials.Core.Fusion
/// <summary> /// <summary>
/// Event handler for when room source changes /// Event handler for when room source changes
/// </summary> /// </summary>
protected void Room_CurrentSourceInfoChange(EssentialsRoomBase room, SourceListItem info, ChangeType type) protected void Room_CurrentSourceInfoChange(SourceListItem info, ChangeType type)
{ {
// Handle null. Nothing to do when switching from or to null // Handle null. Nothing to do when switching from or to null
if (info == null || info.SourceDevice == null) if (info == null || info.SourceDevice == null)
@@ -1403,7 +1403,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
if (SourceToFeedbackSigs.ContainsKey(dev)) if (SourceToFeedbackSigs.ContainsKey(dev))
SourceToFeedbackSigs[dev].BoolValue = true; SourceToFeedbackSigs[dev].BoolValue = true;
var name = (room == null ? "" : room.Name); //var name = (room == null ? "" : room.Name);
CurrentRoomSourceNameSig.InputSig.StringValue = info.SourceDevice.Name; CurrentRoomSourceNameSig.InputSig.StringValue = info.SourceDevice.Name;
} }
} }

View File

@@ -30,6 +30,8 @@ namespace PepperDash.Essentials.Core
void RunRouteAction(string routeKey); void RunRouteAction(string routeKey);
void RunRouteAction(string routeKey, Action successCallback); void RunRouteAction(string routeKey, Action successCallback);
} }
/// <summary> /// <summary>

View File

@@ -15,7 +15,7 @@ namespace PepperDash.Essentials.Core
/// <summary> /// <summary>
/// The handler type for a Room's SourceInfoChange /// The handler type for a Room's SourceInfoChange
/// </summary> /// </summary>
public delegate void SourceInfoChangeHandler(EssentialsRoomBase room, SourceListItem info, ChangeType type); public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type);
//******************************************************************************************* //*******************************************************************************************
@@ -26,8 +26,8 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public interface IHasCurrentSourceInfoChange public interface IHasCurrentSourceInfoChange
{ {
string CurrentSourceInfoKey { get; } string CurrentSourceInfoKey { get; set; }
SourceListItem CurrentSourceInfo { get; } SourceListItem CurrentSourceInfo { get; set; }
event SourceInfoChangeHandler CurrentSourceChange; event SourceInfoChangeHandler CurrentSourceChange;
} }
@@ -52,7 +52,7 @@ namespace PepperDash.Essentials.Core
/// <summary> /// <summary>
/// For fixed-source endpoint devices /// For fixed-source endpoint devices
/// </summary> /// </summary>
public interface IRoutingSinkNoSwitching : IRoutingInputs public interface IRoutingSinkNoSwitching : IRoutingInputs, IHasCurrentSourceInfoChange
{ {
} }

View File

@@ -15,6 +15,32 @@ namespace PepperDash.Essentials.Devices.Common
/// </summary> /// </summary>
public class GenericAudioOut : Device, IRoutingSinkNoSwitching public class GenericAudioOut : Device, IRoutingSinkNoSwitching
{ {
public event SourceInfoChangeHandler CurrentSourceChange;
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 RoutingInputPort AnyAudioIn { get; private set; } public RoutingInputPort AnyAudioIn { get; private set; }
public GenericAudioOut(string key, string name) public GenericAudioOut(string key, string name)