From d6a6791e7befe501f58c86b210eb417a3cc959d9 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 17 Jul 2020 13:48:03 -0600 Subject: [PATCH] getting things working --- ...ntialsDualDisplayPanelAvFunctionsDriver.cs | 80 ++++++++++-- ...entialsHuddleVtc1PanelAvFunctionsDriver.cs | 123 +++++++++--------- .../EssentialsNDisplayRoomPropertiesConfig.cs | 24 +++- .../Rooms/EssentialsRoomBase.cs | 29 ++--- .../Rooms/Types/EssentialsDualDisplayRoom.cs | 42 +++++- 5 files changed, 204 insertions(+), 94 deletions(-) diff --git a/PepperDashEssentials/UIDrivers/EssentialsDualDisplay/EssentialsDualDisplayPanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsDualDisplay/EssentialsDualDisplayPanelAvFunctionsDriver.cs index 68260f34..0369ef2a 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsDualDisplay/EssentialsDualDisplayPanelAvFunctionsDriver.cs +++ b/PepperDashEssentials/UIDrivers/EssentialsDualDisplay/EssentialsDualDisplayPanelAvFunctionsDriver.cs @@ -1,25 +1,85 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; +using System.Linq; using Crestron.SimplSharpPro; using PepperDash.Core; using PepperDash.Essentials; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.Devices.Codec; -using PepperDash.Essentials.Core.Devices.VideoCodec; -using PepperDash.Essentials.Core.PageManagers; -using PepperDash.Essentials.Core.Touchpanels.Keyboards; -using PepperDash.Essentials.UIDrivers; -using PepperDash.Essentials.UIDrivers.VC; +using PepperDash.Essentials.Core.Rooms.Config; namespace PepperDashEssentials.UIDrivers.EssentialsDualDisplay { public class EssentialsDualDisplayPanelAvFunctionsDriver : EssentialsHuddleVtc1PanelAvFunctionsDriver { + private EssentialsDualDisplayRoom _currentRoom; + + private BoolInputSig _routeToggleVisibility; + + private readonly BoolFeedback _sharingMode; + public EssentialsDualDisplayPanelAvFunctionsDriver(PanelDriverBase parent, CrestronTouchpanelPropertiesConfig config) : base(parent, config) { + _routeToggleVisibility = parent.TriList.BooleanInput[UIBoolJoin.ToggleSharingModeVisible]; + + _sharingMode = new BoolFeedback(() => _currentRoom.VideoRoutingBehavior == EVideoBehavior.Advanced); + + _sharingMode.LinkInputSig(parent.TriList.BooleanInput[UIBoolJoin.ToggleSharingModePress]); } + + #region Overrides of EssentialsHuddleVtc1PanelAvFunctionsDriver + + protected override void SetupSourceList() + { + var inCall = _currentRoom.InCallFeedback.BoolValue; + var sourceLists = ConfigReader.ConfigObject.SourceLists; + if (!sourceLists.ContainsKey(_currentRoom.SourceListKey)) + { + return; + } + + var sourceList = sourceLists[_currentRoom.SourceListKey].OrderBy(kv => kv.Value.Order); + + SourceStagingSrl.Clear(); + uint i = 1; + foreach (var src in sourceList.Where( + src => + src.Value.IncludeInSourceList && (inCall && !src.Value.DisableCodecSharing) && + (CurrentMode != UiDisplayMode.Call && !src.Value.DisableCodecSharing))) + { + var source = src.Value; + var sourceKey = src.Key; + Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", source.PreferredName, source.IncludeInSourceList, + source.DisableCodecSharing, inCall, CurrentMode); + + var srlItem = new SubpageReferenceListSourceItem(i++, SourceStagingSrl, src.Value, + b => { if (!b) UiSelectSource(sourceKey); }); + + SourceStagingSrl.AddItem(srlItem); + srlItem.RegisterForSourceChange(_currentRoom); + } + } + + private void RefreshRoom(EssentialsDualDisplayRoom room) + { + RefreshCurrentRoom(room); + + _currentRoom = room; + + _routeToggleVisibility.BoolValue = _currentRoom.RoomConfig.EnableVideoBehaviorToggle; + _sharingMode.FireUpdate(); + } + + private void UiSelectSource(string sourceKey) + { + if (_currentRoom.VideoRoutingBehavior == EVideoBehavior.Advanced) + { + _currentRoom.SelectSource(sourceKey, _currentRoom.SourceListKey); + return; + } + + _currentRoom.RunRouteAction(sourceKey); + + } + + #endregion } } \ No newline at end of file diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index 1f03001d..96af4c9b 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -67,7 +67,7 @@ namespace PepperDash.Essentials /// /// Smart Object 3200 /// - private readonly SubpageReferenceList _sourceStagingSrl; + protected readonly SubpageReferenceList SourceStagingSrl; private readonly CrestronTouchpanelPropertiesConfig _config; @@ -86,7 +86,7 @@ namespace PepperDash.Essentials /// /// The mode showing. Presentation or call. /// - private UiDisplayMode _currentMode = UiDisplayMode.Start; + protected UiDisplayMode CurrentMode = UiDisplayMode.Start; /// /// Current page manager running for a source @@ -124,7 +124,7 @@ namespace PepperDash.Essentials /// /// The Video codec driver /// - private EssentialsVideoCodecUiDriver _vcDriver; + protected EssentialsVideoCodecUiDriver VcDriver; private EssentialsHuddleVtc1Room _currentRoom; @@ -144,7 +144,7 @@ namespace PepperDash.Essentials _stagingBarInterlock = new JoinedSigInterlock(TriList); _callPagesInterlock = new JoinedSigInterlock(TriList); - _sourceStagingSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.SourceStagingSRL, 3, 3, 3); + SourceStagingSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.SourceStagingSRL, 3, 3, 3); _activityFooterSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.ActivityFooterSRL, 3, 3, 3); _callButtonSig = _activityFooterSrl.BoolInputSig(2, 1); @@ -272,7 +272,7 @@ namespace PepperDash.Essentials /// public void ActivityCallButtonPressed() { - if (_vcDriver.IsVisible) + if (VcDriver.IsVisible) { return; } @@ -286,9 +286,9 @@ namespace PepperDash.Essentials _currentSourcePageManager.Hide(); } PowerOnFromCall(); - _currentMode = UiDisplayMode.Call; + CurrentMode = UiDisplayMode.Call; SetActivityFooterFeedbacks(); - _vcDriver.Show(); + VcDriver.Show(); } /// @@ -311,7 +311,7 @@ namespace PepperDash.Essentials /// public void SetVideoCodecDriver(EssentialsVideoCodecUiDriver vcd) { - _vcDriver = vcd; + VcDriver = vcd; } /// @@ -553,7 +553,7 @@ namespace PepperDash.Essentials /// /// /// - private void HideNextMeetingPopup() + protected void HideNextMeetingPopup() { TriList.SetBool(UIBoolJoin.NextMeetingModalVisible, false); } @@ -669,9 +669,9 @@ namespace PepperDash.Essentials /// private void SetActivityFooterFeedbacks() { - _callButtonSig.BoolValue = _currentMode == UiDisplayMode.Call + _callButtonSig.BoolValue = CurrentMode == UiDisplayMode.Call && CurrentRoom.ShutdownType == eShutdownType.None; - _shareButtonSig.BoolValue = _currentMode == UiDisplayMode.Presentation + _shareButtonSig.BoolValue = CurrentMode == UiDisplayMode.Presentation && CurrentRoom.ShutdownType == eShutdownType.None; _endMeetingButtonSig.BoolValue = CurrentRoom.ShutdownType != eShutdownType.None; } @@ -679,12 +679,12 @@ namespace PepperDash.Essentials /// /// Attached to activity list share button /// - private void ActivityShareButtonPressed() + protected virtual void ActivityShareButtonPressed() { SetupSourceList(); - if (_vcDriver.IsVisible) + if (VcDriver.IsVisible) { - _vcDriver.Hide(); + VcDriver.Hide(); } HideNextMeetingPopup(); TriList.SetBool(UIBoolJoin.StartPageVisible, false); @@ -693,13 +693,10 @@ namespace PepperDash.Essentials // Run default source when room is off and share is pressed if (!CurrentRoom.OnFeedback.BoolValue) { - if (!CurrentRoom.OnFeedback.BoolValue) + // If there's no default, show UI elements + if (!CurrentRoom.RunDefaultPresentRoute()) { - // If there's no default, show UI elements - if (!CurrentRoom.RunDefaultPresentRoute()) - { - TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); - } + TriList.SetBool(UIBoolJoin.SelectASourceVisible, true); } } else // room is on show what's active or select a source if nothing is yet active @@ -714,7 +711,7 @@ namespace PepperDash.Essentials _currentSourcePageManager.Show(); } } - _currentMode = UiDisplayMode.Presentation; + CurrentMode = UiDisplayMode.Presentation; SetupSourceList(); SetActivityFooterFeedbacks(); } @@ -810,7 +807,7 @@ namespace PepperDash.Essentials private void UiSelectSource(string key) { // Run the route and when it calls back, show the source - CurrentRoom.RunRouteAction(key, () => { }); + CurrentRoom.RunRouteAction(key); } /// @@ -979,7 +976,7 @@ namespace PepperDash.Essentials /// /// Helper for property setter. Sets the panel to the given room, latching up all functionality /// - private void RefreshCurrentRoom(EssentialsHuddleVtc1Room room) + protected void RefreshCurrentRoom(EssentialsHuddleVtc1Room room) { if (_currentRoom != null) { @@ -1112,46 +1109,48 @@ namespace PepperDash.Essentials /// /// /// - private void SetupSourceList() + protected virtual void SetupSourceList() { var inCall = _currentRoom.InCallFeedback.BoolValue; var config = ConfigReader.ConfigObject.SourceLists; - if (config.ContainsKey(_currentRoom.SourceListKey)) + if (!config.ContainsKey(_currentRoom.SourceListKey)) { - var srcList = config[_currentRoom.SourceListKey].OrderBy(kv => kv.Value.Order); - - // Setup sources list - _sourceStagingSrl.Clear(); - uint i = 1; // counter for UI list - foreach (var kvp in srcList) - { - var srcConfig = kvp.Value; - Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", srcConfig.PreferredName, - srcConfig.IncludeInSourceList, - srcConfig.DisableCodecSharing, inCall, _currentMode); - // Skip sources marked as not included, and filter list of non-sharable sources when in call - // or on share screen - if (!srcConfig.IncludeInSourceList || (inCall && srcConfig.DisableCodecSharing) - || _currentMode == UiDisplayMode.Call && srcConfig.DisableCodecSharing) - { - Debug.Console(1, "Skipping {0}", srcConfig.PreferredName); - continue; - } - - var routeKey = kvp.Key; - var item = new SubpageReferenceListSourceItem(i++, _sourceStagingSrl, srcConfig, - b => - { - if (!b) - { - UiSelectSource(routeKey); - } - }); - _sourceStagingSrl.AddItem(item); // add to the SRL - item.RegisterForSourceChange(_currentRoom); - } - _sourceStagingSrl.Count = (ushort) (i - 1); + return; } + + var srcList = config[_currentRoom.SourceListKey].OrderBy(kv => kv.Value.Order); + + // Setup sources list + SourceStagingSrl.Clear(); + uint i = 1; // counter for UI list + foreach (var kvp in srcList) + { + var srcConfig = kvp.Value; + Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", srcConfig.PreferredName, + srcConfig.IncludeInSourceList, + srcConfig.DisableCodecSharing, inCall, CurrentMode); + // Skip sources marked as not included, and filter list of non-sharable sources when in call + // or on share screen + if (!srcConfig.IncludeInSourceList || (inCall && srcConfig.DisableCodecSharing) + || CurrentMode == UiDisplayMode.Call && srcConfig.DisableCodecSharing) + { + Debug.Console(1, "Skipping {0}", srcConfig.PreferredName); + continue; + } + + var routeKey = kvp.Key; + var item = new SubpageReferenceListSourceItem(i++, SourceStagingSrl, srcConfig, + b => + { + if (!b) + { + UiSelectSource(routeKey); + } + }); + SourceStagingSrl.AddItem(item); // add to the SRL + item.RegisterForSourceChange(_currentRoom); + } + SourceStagingSrl.Count = (ushort) (i - 1); } /// @@ -1286,10 +1285,10 @@ namespace PepperDash.Essentials } else { - _currentMode = UiDisplayMode.Start; - if (_vcDriver.IsVisible) + CurrentMode = UiDisplayMode.Start; + if (VcDriver.IsVisible) { - _vcDriver.Hide(); + VcDriver.Hide(); } SetupActivityFooterWhenRoomOff(); ShowLogo(); @@ -1399,7 +1398,7 @@ namespace PepperDash.Essentials { var routeInfo = CurrentRoom.CurrentSourceInfo; // This will show off popup too - if (IsVisible && !_vcDriver.IsVisible) + if (IsVisible && !VcDriver.IsVisible) { ShowCurrentSource(); } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Config/EssentialsNDisplayRoomPropertiesConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Config/EssentialsNDisplayRoomPropertiesConfig.cs index db599403..2145578b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Config/EssentialsNDisplayRoomPropertiesConfig.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Config/EssentialsNDisplayRoomPropertiesConfig.cs @@ -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 + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/EssentialsRoomBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/EssentialsRoomBase.cs index b630d5dc..43f60d86 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/EssentialsRoomBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/EssentialsRoomBase.cs @@ -474,41 +474,41 @@ namespace PepperDash.Essentials.Core /// /// /// - /// - public virtual void RunRouteAction(string routeKey) + /// + public virtual void RunRouteAction(string sourceKey) { - RunRouteAction(routeKey, String.Empty, () => { }); + RunRouteAction(sourceKey, String.Empty, () => { }); } /// /// Gets a source from config list SourceListKey and dynamically build and executes the /// route or commands /// - 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); } /// /// /// - /// + /// /// - public virtual void RunRouteAction(string routeKey, string sourceListKey) + public virtual void RunRouteAction(string sourceKey, string sourceListKey) { - RunRouteAction(routeKey, sourceListKey, () => { }); + RunRouteAction(sourceKey, sourceListKey, () => { }); } /// /// /// - /// + /// /// /// - 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 GetSourceListForKey(string routeKey, string sourceListKey) + protected Dictionary GetSourceListForKey(string routeKey, string sourceListKey) { var slKey = String.IsNullOrEmpty(sourceListKey) ? SourceListKey : sourceListKey; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Types/EssentialsDualDisplayRoom.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Types/EssentialsDualDisplayRoom.cs index e512cc32..3c28862b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Types/EssentialsDualDisplayRoom.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Rooms/Types/EssentialsDualDisplayRoom.cs @@ -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(); + RoomConfig = config.Properties.ToObject(); 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(); + } } } \ No newline at end of file