diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs index 9759cfdd..9e5ce331 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs @@ -5,12 +5,13 @@ using System.Text; using System.Text.RegularExpressions; using Crestron.SimplSharp; using Crestron.SimplSharpPro.CrestronThread; - +using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Devices.Common.Cameras; @@ -1388,6 +1389,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco SendText("xCommand Standby Deactivate"); } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + throw new NotImplementedException(); + } + /// /// Reboots the codec /// diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs index dc32ecd8..c4bfa298 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs @@ -3,9 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; - +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Devices.Common.Codec; @@ -226,6 +227,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec _StandbyIsOn = false; } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + throw new NotImplementedException(); + } + /// /// Called by routing to make it happen /// diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs index 1f8938f6..fe18e7ca 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs @@ -2,83 +2,22 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Crestron.SimplSharp; - +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Devices; using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Devices.Common; using PepperDash.Essentials.Devices.Common.Codec; +using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.Devices.Common.VideoCodec { public abstract class VideoCodecBase : ReconfigurableDevice, IRoutingInputsOutputs, - IUsageTracking, IHasDialer, IHasContentSharing, ICodecAudio, iVideoCodecInfo + IUsageTracking, IHasDialer, IHasContentSharing, ICodecAudio, iVideoCodecInfo, IBridgeAdvanced { - /// - /// Fires when the status of any active, dialing, or incoming call changes or is new - /// - public event EventHandler CallStatusChange; - - public event EventHandler IsReadyChange; - - public IBasicCommunication Communication { get; protected set; } - - #region IUsageTracking Members - - /// - /// This object can be added by outside users of this class to provide usage tracking - /// for various services - /// - public UsageTracking UsageTracker { get; set; } - - #endregion - - /// - /// An internal pseudo-source that is routable and connected to the osd input - /// - public DummyRoutingInputsDevice OsdSource { get; protected set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Returns true when any call is not in state Unknown, Disconnecting, Disconnected - /// - public bool IsInCall - { - get - { - bool value; - - if (ActiveCalls != null) - value = ActiveCalls.Any(c => c.IsActiveCall); - else - value = false; - return value; - } - } - - public BoolFeedback StandbyIsOnFeedback { get; private set; } - - abstract protected Func PrivacyModeIsOnFeedbackFunc { get; } - abstract protected Func VolumeLevelFeedbackFunc { get; } - abstract protected Func MuteFeedbackFunc { get; } - abstract protected Func StandbyIsOnFeedbackFunc { get; } - - public List ActiveCalls { get; set; } - - public VideoCodecInfo CodecInfo { get; protected set; } - - public bool ShowSelfViewByDefault { get; protected set; } - - - public bool IsReady { get; protected set; } - - public VideoCodecBase(DeviceConfig config) + protected VideoCodecBase(DeviceConfig config) : base(config) { StandbyIsOnFeedback = new BoolFeedback(StandbyIsOnFeedbackFunc); @@ -90,85 +29,45 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec InputPorts = new RoutingPortCollection(); OutputPorts = new RoutingPortCollection(); - + ActiveCalls = new List(); } - #region IHasDialer Members + public IBasicCommunication Communication { get; protected set; } - public abstract void Dial(string number); - public abstract void Dial(Meeting meeting); - public virtual void Dial(IInvitableContact contact) - { + /// + /// An internal pseudo-source that is routable and connected to the osd input + /// + public DummyRoutingInputsDevice OsdSource { get; protected set; } - } - public abstract void EndCall(CodecActiveCallItem call); - public abstract void EndAllCalls(); - public abstract void AcceptCall(CodecActiveCallItem call); - public abstract void RejectCall(CodecActiveCallItem call); - public abstract void SendDtmf(string s); + public BoolFeedback StandbyIsOnFeedback { get; private set; } - #endregion + protected abstract Func PrivacyModeIsOnFeedbackFunc { get; } + protected abstract Func VolumeLevelFeedbackFunc { get; } + protected abstract Func MuteFeedbackFunc { get; } + protected abstract Func StandbyIsOnFeedbackFunc { get; } + + public List ActiveCalls { get; set; } + + public bool ShowSelfViewByDefault { get; protected set; } + + + public bool IsReady { get; protected set; } public virtual List Feedbacks { get { return new List - { + { PrivacyModeIsOnFeedback, SharingSourceFeedback - }; + }; } } - public abstract void ExecuteSwitch(object selector); - - /// - /// Helper method to fire CallStatusChange event with old and new status - /// - protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call) - { - call.Status = newStatus; - - OnCallStatusChange(call); - - } - - /// - /// - /// - /// - /// - /// - protected void OnCallStatusChange(CodecActiveCallItem item) - { - var handler = CallStatusChange; - if (handler != null) - handler(this, new CodecCallStatusItemChangeEventArgs(item)); - - if (AutoShareContentWhileInCall) - StartSharing(); - - if (UsageTracker != null) - { - if (IsInCall && !UsageTracker.UsageTrackingStarted) - UsageTracker.StartDeviceUsage(); - else if (UsageTracker.UsageTrackingStarted && !IsInCall) - UsageTracker.EndDeviceUsage(); - } - } - - /// - /// Sets IsReady property and fires the event. Used for dependent classes to sync up their data. - /// - protected void SetIsReady() - { - IsReady = true; - var h = IsReadyChange; - if(h != null) - h(this, new EventArgs()); - } + protected abstract Func SharingSourceFeedbackFunc { get; } + protected abstract Func SharingContentIsOnFeedbackFunc { get; } #region ICodecAudio Members @@ -197,7 +96,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec #endregion - #region IHasSharing Members + #region IHasContentSharing Members public abstract void StartSharing(); public abstract void StopSharing(); @@ -207,12 +106,133 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public StringFeedback SharingSourceFeedback { get; private set; } public BoolFeedback SharingContentIsOnFeedback { get; private set; } - abstract protected Func SharingSourceFeedbackFunc { get; } - abstract protected Func SharingContentIsOnFeedbackFunc { get; } + #endregion + #region IHasDialer Members + + /// + /// Fires when the status of any active, dialing, or incoming call changes or is new + /// + public event EventHandler CallStatusChange; + + /// + /// Returns true when any call is not in state Unknown, Disconnecting, Disconnected + /// + public bool IsInCall + { + get + { + bool value; + + if (ActiveCalls != null) + { + value = ActiveCalls.Any(c => c.IsActiveCall); + } + else + { + value = false; + } + return value; + } + } + + public abstract void Dial(string number); + public abstract void EndCall(CodecActiveCallItem call); + public abstract void EndAllCalls(); + public abstract void AcceptCall(CodecActiveCallItem call); + public abstract void RejectCall(CodecActiveCallItem call); + public abstract void SendDtmf(string s); #endregion + #region IRoutingInputsOutputs Members + + public RoutingPortCollection InputPorts { get; private set; } + + public RoutingPortCollection OutputPorts { get; private set; } + + #endregion + + #region IUsageTracking Members + + /// + /// This object can be added by outside users of this class to provide usage tracking + /// for various services + /// + public UsageTracking UsageTracker { get; set; } + + #endregion + + #region iVideoCodecInfo Members + + public VideoCodecInfo CodecInfo { get; protected set; } + + #endregion + + public event EventHandler IsReadyChange; + public abstract void Dial(Meeting meeting); + + public virtual void Dial(IInvitableContact contact) + { + } + + public abstract void ExecuteSwitch(object selector); + + /// + /// Helper method to fire CallStatusChange event with old and new status + /// + protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call) + { + call.Status = newStatus; + + OnCallStatusChange(call); + } + + /// + /// + /// + /// + /// + /// + protected void OnCallStatusChange(CodecActiveCallItem item) + { + var handler = CallStatusChange; + if (handler != null) + { + handler(this, new CodecCallStatusItemChangeEventArgs(item)); + } + + if (AutoShareContentWhileInCall) + { + StartSharing(); + } + + if (UsageTracker != null) + { + if (IsInCall && !UsageTracker.UsageTrackingStarted) + { + UsageTracker.StartDeviceUsage(); + } + else if (UsageTracker.UsageTrackingStarted && !IsInCall) + { + UsageTracker.EndDeviceUsage(); + } + } + } + + /// + /// Sets IsReady property and fires the event. Used for dependent classes to sync up their data. + /// + protected void SetIsReady() + { + IsReady = true; + var h = IsReadyChange; + if (h != null) + { + h(this, new EventArgs()); + } + } + // **** DEBUGGING THINGS **** /// /// @@ -221,7 +241,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { var sb = new StringBuilder(); foreach (var c in ActiveCalls) + { sb.AppendFormat("{0} {1} -- {2} {3}\n", c.Id, c.Number, c.Name, c.Status); + } Debug.Console(1, this, "\n{0}\n", sb.ToString()); } @@ -229,6 +251,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public abstract void StandbyDeactivate(); + #region Implementation of IBridgeAdvanced + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); + + #endregion } @@ -237,11 +264,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec /// public class CodecPhonebookSyncState : IKeyed { - bool _InitialSyncComplete; + private bool _InitialSyncComplete; - public event EventHandler InitialSyncCompleted; + public CodecPhonebookSyncState(string key) + { + Key = key; - public string Key { get; private set; } + CodecDisconnected(); + } public bool InitialSyncComplete { @@ -252,7 +282,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec { var handler = InitialSyncCompleted; if (handler != null) + { handler(this, new EventArgs()); + } } _InitialSyncComplete = value; } @@ -268,12 +300,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public int NumberOfContacts { get; private set; } - public CodecPhonebookSyncState(string key) - { - Key = key; + #region IKeyed Members - CodecDisconnected(); - } + public string Key { get; private set; } + + #endregion + + public event EventHandler InitialSyncCompleted; public void InitialPhonebookFoldersReceived() { @@ -314,7 +347,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec NumberOfContactsWasReceived = false; } - void CheckSyncStatus() + private void CheckSyncStatus() { if (InitialPhonebookFoldersWasReceived && NumberOfContactsWasReceived && PhonebookRootEntriesWasRecieved) { @@ -322,7 +355,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec Debug.Console(1, this, "Initial Phonebook Sync Complete!"); } else + { InitialSyncComplete = false; + } } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs index 179b4001..d25abb22 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs @@ -4,14 +4,17 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.CrestronThread; +using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Devices.Common.Cameras; using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash_Essentials_Core.Bridges.JoinMaps; namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { @@ -218,18 +221,20 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom public void SelectCamera(string key) { - if (Cameras != null) + if (Cameras == null) { - var camera = Cameras.FirstOrDefault(c => c.Key.IndexOf(key, StringComparison.OrdinalIgnoreCase) > -1); - if (camera != null) - { - Debug.Console(1, this, "Selected Camera with key: '{0}'", camera.Key); - SelectedCamera = camera; - } - else - { - Debug.Console(1, this, "Unable to select camera with key: '{0}'", key); - } + return; + } + + var camera = Cameras.FirstOrDefault(c => c.Key.IndexOf(key, StringComparison.OrdinalIgnoreCase) > -1); + if (camera != null) + { + Debug.Console(1, this, "Selected Camera with key: '{0}'", camera.Key); + SelectedCamera = camera; + } + else + { + Debug.Console(1, this, "Unable to select camera with key: '{0}'", key); } } @@ -1394,6 +1399,32 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom // No corresponding function on device } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new VideoCodecControllerJoinMap(joinStart); + + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + + Debug.Console(1, this, "Linking to Trilist {0}", trilist.ID.ToString("X")); + + LinkCameraActions(trilist, joinMap); + } + + private void LinkCameraActions(BasicTriList trilist, VideoCodecControllerJoinMap joinMap) + { + + } + public override void ExecuteSwitch(object selector) { (selector as Action)();