getting things working

This commit is contained in:
Andrew Welker
2020-07-17 13:48:03 -06:00
parent aede5355b7
commit d6a6791e7b
5 changed files with 204 additions and 94 deletions

View File

@@ -1,4 +1,5 @@
using PepperDash.Core;
using Newtonsoft.Json.Converters;
using PepperDash.Core;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core.Rooms.Config
@@ -9,11 +10,15 @@ namespace PepperDash.Essentials.Core.Rooms.Config
public class EssentialsNDisplayRoomPropertiesConfig : EssentialsHuddleVtc1PropertiesConfig
{
[JsonProperty("defaultAudioBehavior")]
public string DefaultAudioBehavior { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public EAudioBehavior DefaultAudioBehavior { get; set; }
[JsonProperty("defaultVideoBehavior")]
public string DefaultVideoBehavior { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public EVideoBehavior DefaultVideoBehavior { get; set; }
[JsonProperty("destinationListKey")]
public string DestinationListKey { get; set; }
[JsonProperty("enableVideoBehaviorToggle")]
public bool EnableVideoBehaviorToggle { get; set; }
}
public class DisplayItem : IKeyName
@@ -21,4 +26,17 @@ namespace PepperDash.Essentials.Core.Rooms.Config
public string Key { get; set; }
public string Name { get; set; }
}
public enum EVideoBehavior
{
Basic,
Advanced
}
public enum EAudioBehavior
{
AudioFollowVideo,
ChooseAudioFromDisplay,
AudioFollowVideoWithDeroute
}
}

View File

@@ -474,41 +474,41 @@ namespace PepperDash.Essentials.Core
/// <summary>
///
/// </summary>
/// <param name="routeKey"></param>
public virtual void RunRouteAction(string routeKey)
/// <param name="sourceKey"></param>
public virtual void RunRouteAction(string sourceKey)
{
RunRouteAction(routeKey, String.Empty, () => { });
RunRouteAction(sourceKey, String.Empty, () => { });
}
/// <summary>
/// Gets a source from config list SourceListKey and dynamically build and executes the
/// route or commands
/// </summary>
public virtual void RunRouteAction(string routeKey, Action successCallback)
public virtual void RunRouteAction(string sourceKey, Action successCallback)
{
RunRouteAction(routeKey, String.Empty, successCallback);
RunRouteAction(sourceKey, String.Empty, successCallback);
}
/// <summary>
///
/// </summary>
/// <param name="routeKey"></param>
/// <param name="sourceKey"></param>
/// <param name="sourceListKey"></param>
public virtual void RunRouteAction(string routeKey, string sourceListKey)
public virtual void RunRouteAction(string sourceKey, string sourceListKey)
{
RunRouteAction(routeKey, sourceListKey, () => { });
RunRouteAction(sourceKey, sourceListKey, () => { });
}
/// <summary>
///
/// </summary>
/// <param name="routeKey"></param>
/// <param name="sourceKey"></param>
/// <param name="sourceListKey"></param>
/// <param name="successCallback"></param>
public virtual void RunRouteAction(string routeKey, string sourceListKey, Action successCallback)
public virtual void RunRouteAction(string sourceKey, string sourceListKey, Action successCallback)
{
var routeObject =
new {RouteKey = routeKey, SourceListKey = sourceListKey, SuccessCallback = successCallback};
new {RouteKey = sourceKey, SourceListKey = sourceListKey, SuccessCallback = successCallback};
CrestronInvoke.BeginInvoke(RunRouteAction, routeObject); // end of BeginInvoke
}
@@ -572,14 +572,13 @@ namespace PepperDash.Essentials.Core
SetVolumeControl(item);
// store the name and UI info for routes
CurrentSourceInfoKey = routeObj.RouteKey;
if (item.SourceKey == "$off")
{
CurrentSourceInfoKey = routeObj.RouteKey;
CurrentSourceInfo = null;
}
else if (item.SourceKey != null)
{
CurrentSourceInfoKey = routeObj.RouteKey;
CurrentSourceInfo = item;
}
@@ -657,7 +656,7 @@ namespace PepperDash.Essentials.Core
return dest;
}
private void SetVolumeControl(SourceListItem item)
protected void SetVolumeControl(SourceListItem item)
{
IBasicVolumeControls volDev = null;
// Handle special cases for volume control
@@ -730,7 +729,7 @@ namespace PepperDash.Essentials.Core
}
}
private Dictionary<string, SourceListItem> GetSourceListForKey(string routeKey, string sourceListKey)
protected Dictionary<string, SourceListItem> GetSourceListForKey(string routeKey, string sourceListKey)
{
var slKey = String.IsNullOrEmpty(sourceListKey) ? SourceListKey : sourceListKey;

View File

@@ -15,13 +15,16 @@ namespace PepperDash.Essentials
private const string LeftDestinationKey = "leftDisplay";
private const string RightDestinationKey = "rightDisplay";
private readonly EssentialsDualDisplayRoomPropertiesConfig _config;
public EssentialsDualDisplayRoomPropertiesConfig RoomConfig { get; private set; }
public EAudioBehavior AudioRoutingBehavior { get; set; }
public EVideoBehavior VideoRoutingBehavior { get; set; }
private string _destinationListKey;
public EssentialsDualDisplayRoom(DeviceConfig config) : base(config)
{
_config = config.Properties.ToObject<EssentialsDualDisplayRoomPropertiesConfig>();
RoomConfig = config.Properties.ToObject<EssentialsDualDisplayRoomPropertiesConfig>();
Initialize();
}
@@ -40,9 +43,12 @@ namespace PepperDash.Essentials
{
try
{
_destinationListKey = String.IsNullOrEmpty(_config.DestinationListKey)
_destinationListKey = String.IsNullOrEmpty(RoomConfig.DestinationListKey)
? DefaultDestinationListKey
: _config.DestinationListKey;
: RoomConfig.DestinationListKey;
AudioRoutingBehavior = RoomConfig.DefaultAudioBehavior;
VideoRoutingBehavior = RoomConfig.DefaultVideoBehavior;
InitializeDestinations();
}
@@ -192,5 +198,33 @@ namespace PepperDash.Essentials
DoRoute(routeItem);
}
public void SelectSource(string sourceKey, string sourceListKey)
{
var srcList = GetSourceListForKey(sourceKey, sourceListKey);
var src = srcList[sourceKey];
if (src.SourceKey != "roomoff")
{
LastSourceKey = sourceKey;
}
else
{
CurrentSourceInfoKey = null;
}
SetVolumeControl(src);
if (src.SourceKey == "$off")
{
CurrentSourceInfo = null;
} else if (src.SourceKey != null)
{
CurrentSourceInfo = src;
}
OnFeedback.FireUpdate();
}
}
}