diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index ae420105..83916856 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -98,12 +98,12 @@ False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll False False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll False @@ -113,7 +113,7 @@ False - ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe False @@ -158,6 +158,7 @@ + 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 2f834c36..179b4001 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,45 +4,102 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.CrestronThread; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; - using PepperDash.Core; using PepperDash.Essentials.Core; 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.Devices.Common.VideoCodec; namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { - public class ZoomRoom : VideoCodecBase, IHasCodecSelfView, IHasDirectory, ICommunicationMonitor, IRouting, IHasScheduleAwareness, IHasCodecCameras + public class ZoomRoom : VideoCodecBase, IHasCodecSelfView, IHasDirectory, ICommunicationMonitor, IRouting, + IHasScheduleAwareness, IHasCodecCameras { + private readonly CrestronQueue ReceiveQueue; + + private readonly Thread ReceiveThread; + + private readonly ZoomRoomSyncState SyncState; + public bool CommDebuggingIsOn; + private uint DefaultMeetingDurationMin = 30; + private string Delimiter = "\x0D\x0A"; + private uint JsonCurlyBraceCounter = 0; + private bool JsonFeedbackMessageIsIncoming; + private StringBuilder JsonMessage; + private int PreviousVolumeLevel = 0; + private CameraBase _selectedCamera; + + public ZoomRoom(DeviceConfig config, IBasicCommunication comm) + : base(config) + { + var props = JsonConvert.DeserializeObject(config.Properties.ToString()); + + // The queue that will collect the repsonses in the order they are received + ReceiveQueue = new CrestronQueue(25); + + // The thread responsible for dequeuing and processing the messages + ReceiveThread = new Thread((o) => ProcessQueue(), null); + ReceiveThread.Priority = Thread.eThreadPriority.MediumPriority; + + Communication = comm; + + if (props.CommunicationMonitorProperties != null) + { + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, + props.CommunicationMonitorProperties); + } + else + { + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, + "zStatus SystemUnit\r"); + } + + DeviceManager.AddDevice(CommunicationMonitor); + + Status = new ZoomRoomStatus(); + + Configuration = new ZoomRoomConfiguration(); + + CodecInfo = new ZoomRoomInfo(Status, Configuration); + + SyncState = new ZoomRoomSyncState(Key + "--Sync", this); + + SyncState.InitialSyncCompleted += new EventHandler(SyncState_InitialSyncCompleted); + + PhonebookSyncState = new CodecPhonebookSyncState(Key + "--PhonebookSync"); + + PortGather = new CommunicationGather(Communication, "\x0A"); + PortGather.IncludeDelimiter = true; + PortGather.LineReceived += this.Port_LineReceived; + + CodecOsdIn = new RoutingInputPort(RoutingPortNames.CodecOsd, + eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, new Action(StopSharing), this); + + Output1 = new RoutingOutputPort(RoutingPortNames.AnyVideoOut, + eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + SelfviewIsOnFeedback = new BoolFeedback(SelfViewIsOnFeedbackFunc); + + CodecSchedule = new CodecScheduleAwareness(); + + SetUpFeedbackActions(); + + Cameras = new List(); + + SetUpDirectory(); + } + public CommunicationGather PortGather { get; private set; } - public StatusMonitorBase CommunicationMonitor { get; private set; } - - private CrestronQueue ReceiveQueue; - - private Thread ReceiveThread; - - string Delimiter = "\x0D\x0A"; - - private ZoomRoomSyncState SyncState; - public ZoomRoomStatus Status { get; private set; } public ZoomRoomConfiguration Configuration { get; private set; } - private StringBuilder JsonMessage; - - private bool JsonFeedbackMessageIsIncoming; - private uint JsonCurlyBraceCounter = 0; - - public bool CommDebuggingIsOn; - //CTimer LoginMessageReceivedTimer; //CTimer RetryConnectionTimer; @@ -59,50 +116,32 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom protected override Func PrivacyModeIsOnFeedbackFunc { - get - { - return () => Configuration.Call.Microphone.Mute; - } + get { return () => Configuration.Call.Microphone.Mute; } } protected override Func StandbyIsOnFeedbackFunc { - get - { - return () => false; - } + get { return () => false; } } protected override Func SharingSourceFeedbackFunc { - get - { - return () => Status.Sharing.dispState; - } + get { return () => Status.Sharing.dispState; } } protected override Func SharingContentIsOnFeedbackFunc { - get - { - return () => Status.Call.Sharing.IsSharing; - } + get { return () => Status.Call.Sharing.IsSharing; } } protected Func FarEndIsSharingContentFeedbackFunc { - get - { - return () => false; - } + get { return () => false; } } protected override Func MuteFeedbackFunc { - get - { - return () => Configuration.Audio.Output.Volume == 0; - } + get { return () => Configuration.Audio.Output.Volume == 0; } } //protected Func RoomIsOccupiedFeedbackFunc @@ -123,103 +162,214 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom protected Func SelfViewIsOnFeedbackFunc { - get - { - return () => !Configuration.Video.HideConfSelfVideo; - } + get { return () => !Configuration.Video.HideConfSelfVideo; } } protected Func SelfviewPipPositionFeedbackFunc { - get - { - return () => ""; - } + get { return () => ""; } } protected Func LocalLayoutFeedbackFunc { - get - { - return () => ""; - } + get { return () => ""; } } protected Func LocalLayoutIsProminentFeedbackFunc { - get - { - return () => false; - } + get { return () => false; } } public RoutingInputPort CodecOsdIn { get; private set; } public RoutingOutputPort Output1 { get; private set; } - uint DefaultMeetingDurationMin = 30; + #region ICommunicationMonitor Members - int PreviousVolumeLevel = 0; + public StatusMonitorBase CommunicationMonitor { get; private set; } - public ZoomRoom(DeviceConfig config, IBasicCommunication comm) - : base(config) + #endregion + + #region IHasCodecCameras Members + + public event EventHandler CameraSelected; + + public List Cameras { get; private set; } + + public CameraBase SelectedCamera { - var props = JsonConvert.DeserializeObject(config.Properties.ToString()); - - // The queue that will collect the repsonses in the order they are received - ReceiveQueue = new CrestronQueue(25); - - // The thread responsible for dequeuing and processing the messages - ReceiveThread = new Thread((o) => ProcessQueue(), null); - ReceiveThread.Priority = Thread.eThreadPriority.MediumPriority; - - Communication = comm; - - if (props.CommunicationMonitorProperties != null) + get { return _selectedCamera; } + private set { - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties); + _selectedCamera = value; + SelectedCameraFeedback.FireUpdate(); + ControllingFarEndCameraFeedback.FireUpdate(); + + var handler = CameraSelected; + if (handler != null) + { + handler(this, new CameraSelectedEventArgs(SelectedCamera)); + } + } + } + + + public StringFeedback SelectedCameraFeedback { get; private set; } + + public void SelectCamera(string key) + { + 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); + } + } + } + + public CameraBase FarEndCamera { get; private set; } + + public BoolFeedback ControllingFarEndCameraFeedback { get; private set; } + + #endregion + + #region IHasCodecSelfView Members + + public BoolFeedback SelfviewIsOnFeedback { get; private set; } + + public void SelfViewModeOn() + { + SendText("zConfiguration Video hide_conf_self_video: off"); + } + + public void SelfViewModeOff() + { + SendText("zConfiguration Video hide_conf_self_video: on"); + } + + public void SelfViewModeToggle() + { + if (SelfviewIsOnFeedback.BoolValue) + { + SelfViewModeOff(); } else { - CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "zStatus SystemUnit\r"); + SelfViewModeOn(); } - - DeviceManager.AddDevice(CommunicationMonitor); - - Status = new ZoomRoomStatus(); - - Configuration = new ZoomRoomConfiguration(); - - CodecInfo = new ZoomRoomInfo(Status, Configuration); - - SyncState = new ZoomRoomSyncState(Key + "--Sync", this); - - SyncState.InitialSyncCompleted += new EventHandler(SyncState_InitialSyncCompleted); - - PhonebookSyncState = new CodecPhonebookSyncState(Key + "--PhonebookSync"); - - PortGather = new CommunicationGather(Communication, "\x0A"); - PortGather.IncludeDelimiter = true; - PortGather.LineReceived += this.Port_LineReceived; - - CodecOsdIn = new RoutingInputPort(RoutingPortNames.CodecOsd, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, new Action(StopSharing), this); - - Output1 = new RoutingOutputPort(RoutingPortNames.AnyVideoOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - SelfviewIsOnFeedback = new BoolFeedback(SelfViewIsOnFeedbackFunc); - - CodecSchedule = new CodecScheduleAwareness(); - - SetUpFeedbackActions(); - - Cameras = new List(); - - SetUpDirectory(); } - void SyncState_InitialSyncCompleted(object sender, EventArgs e) + #endregion + + #region IHasDirectory Members + + public event EventHandler DirectoryResultReturned; + public CodecDirectory DirectoryRoot { get; private set; } + + public CodecDirectory CurrentDirectoryResult + { + get + { + if (DirectoryBrowseHistory.Count > 0) + { + return DirectoryBrowseHistory[DirectoryBrowseHistory.Count - 1]; + } + else + { + return DirectoryRoot; + } + } + } + + public CodecPhonebookSyncState PhonebookSyncState { get; private set; } + + public void SearchDirectory(string searchString) + { + var directoryResults = new CodecDirectory(); + + directoryResults.AddContactsToDirectory( + DirectoryRoot.CurrentDirectoryResults.FindAll( + c => c.Name.IndexOf(searchString, 0, StringComparison.OrdinalIgnoreCase) > -1)); + + DirectoryBrowseHistory.Add(directoryResults); + + OnDirectoryResultReturned(directoryResults); + } + + public void GetDirectoryFolderContents(string folderId) + { + var directoryResults = new CodecDirectory(); + + directoryResults.ResultsFolderId = folderId; + directoryResults.AddContactsToDirectory( + DirectoryRoot.CurrentDirectoryResults.FindAll(c => c.FolderId.Equals(folderId))); + + DirectoryBrowseHistory.Add(directoryResults); + + OnDirectoryResultReturned(directoryResults); + } + + public void SetCurrentDirectoryToRoot() + { + DirectoryBrowseHistory.Clear(); + + OnDirectoryResultReturned(DirectoryRoot); + } + + public void GetDirectoryParentFolderContents() + { + var currentDirectory = new CodecDirectory(); + + if (DirectoryBrowseHistory.Count > 0) + { + var lastItemIndex = DirectoryBrowseHistory.Count - 1; + var parentDirectoryContents = DirectoryBrowseHistory[lastItemIndex]; + + DirectoryBrowseHistory.Remove(DirectoryBrowseHistory[lastItemIndex]); + + currentDirectory = parentDirectoryContents; + } + else + { + currentDirectory = DirectoryRoot; + } + + OnDirectoryResultReturned(currentDirectory); + } + + public BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; private set; } + + public List DirectoryBrowseHistory { get; private set; } + + #endregion + + #region IHasScheduleAwareness Members + + public CodecScheduleAwareness CodecSchedule { get; private set; } + + public void GetSchedule() + { + GetBookings(); + } + + #endregion + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + ExecuteSwitch(inputSelector); + } + + #endregion + + private void SyncState_InitialSyncCompleted(object sender, EventArgs e) { SetUpRouting(); @@ -230,7 +380,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// /// Subscribes to the PropertyChanged events on the state objects and fires the corresponding feedbacks. /// - void SetUpFeedbackActions() + private void SetUpFeedbackActions() { Configuration.Audio.Output.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler( (o, a) => @@ -264,7 +414,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { if (a.PropertyName == "SelectedId") { - SelectCamera(Configuration.Video.Camera.SelectedId); // this will in turn fire the affected feedbacks + SelectCamera(Configuration.Video.Camera.SelectedId); + // this will in turn fire the affected feedbacks } }); @@ -291,7 +442,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom }); } - void SetUpDirectory() + private void SetUpDirectory() { DirectoryRoot = new CodecDirectory(); @@ -302,7 +453,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); } - void SetUpRouting() + private void SetUpRouting() { // Set up input ports CreateOsdSource(); @@ -316,7 +467,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// Creates the fake OSD source, and connects it's AudioVideo output to the CodecOsdIn input /// to enable routing /// - void CreateOsdSource() + private void CreateOsdSource() { OsdSource = new DummyRoutingInputsDevice(Key + "[osd]"); DeviceManager.AddDevice(OsdSource); @@ -332,9 +483,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// public override bool CustomActivate() { - CrestronConsole.AddNewConsoleCommand(SetCommDebug, "SetCodecCommDebug", "0 for Off, 1 for on", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand((s) => SendText("zCommand Phonebook List Offset: 0 Limit: 512"), "GetZoomRoomContacts", "Triggers a refresh of the codec phonebook", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand((s) => GetBookings(), "GetZoomRoomBookings", "Triggers a refresh of the booking data for today", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(SetCommDebug, "SetCodecCommDebug", "0 for Off, 1 for on", + ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand((s) => SendText("zCommand Phonebook List Offset: 0 Limit: 512"), + "GetZoomRoomContacts", "Triggers a refresh of the codec phonebook", + ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand((s) => GetBookings(), "GetZoomRoomBookings", + "Triggers a refresh of the booking data for today", ConsoleAccessLevelEnum.AccessOperator); var socket = Communication as ISocketStatus; if (socket != null) @@ -366,12 +521,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom } } - void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) + private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { Debug.Console(1, this, "Socket status change {0}", e.Client.ClientStatus); if (e.Client.IsConnected) { - } else { @@ -383,7 +537,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom public void SendText(string command) { if (CommDebuggingIsOn) + { Debug.Console(1, this, "Sending: '{0}'", command); + } Communication.SendText(command + Delimiter); } @@ -393,7 +549,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// /// /// - void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) + private void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) { //if (CommDebuggingIsOn) // Debug.Console(1, this, "Gathered: '{0}'", args.Text); @@ -412,7 +568,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// Runs in it's own thread to dequeue messages in the order they were received to be processed /// /// - object ProcessQueue() + private object ProcessQueue() { try { @@ -435,7 +591,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// /// Queues the initial queries to be sent upon connection /// - void SetUpSyncQueries() + private void SetUpSyncQueries() { // zStatus SyncState.AddQueryToQueue("zStatus Call Status"); @@ -488,41 +644,51 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// Processes messages as they are dequeued /// /// - void ProcessMessage(string message) - { + private void ProcessMessage(string message) + { // Counts the curly braces - if(message.Contains('{')) + if (message.Contains('{')) + { JsonCurlyBraceCounter++; + } if (message.Contains('}')) + { JsonCurlyBraceCounter--; + } Debug.Console(2, this, "JSON Curly Brace Count: {0}", JsonCurlyBraceCounter); - if (!JsonFeedbackMessageIsIncoming && message.Trim('\x20') == "{" + Delimiter) // Check for the beginning of a new JSON message + if (!JsonFeedbackMessageIsIncoming && message.Trim('\x20') == "{" + Delimiter) + // Check for the beginning of a new JSON message { JsonFeedbackMessageIsIncoming = true; - JsonCurlyBraceCounter = 1; // reset the counter for each new message + JsonCurlyBraceCounter = 1; // reset the counter for each new message JsonMessage = new StringBuilder(); JsonMessage.Append(message); if (CommDebuggingIsOn) + { Debug.Console(2, this, "Incoming JSON message..."); + } return; } - else if (JsonFeedbackMessageIsIncoming && message.Trim('\x20') == "}" + Delimiter) // Check for the end of a JSON message + else if (JsonFeedbackMessageIsIncoming && message.Trim('\x20') == "}" + Delimiter) + // Check for the end of a JSON message { JsonMessage.Append(message); - if(JsonCurlyBraceCounter == 0) + if (JsonCurlyBraceCounter == 0) { JsonFeedbackMessageIsIncoming = false; if (CommDebuggingIsOn) + { Debug.Console(2, this, "Complete JSON Received:\n{0}", JsonMessage.ToString()); + } // Forward the complete message to be deserialized DeserializeResponse(JsonMessage.ToString()); @@ -543,36 +709,38 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom } if (CommDebuggingIsOn) + { Debug.Console(1, this, "Non-JSON response: '{0}'", message); + } - JsonCurlyBraceCounter = 0; // reset on non-JSON response + JsonCurlyBraceCounter = 0; // reset on non-JSON response if (!SyncState.InitialSyncComplete) { switch (message.Trim().ToLower()) // remove the whitespace { case "*r login successful": + { + SyncState.LoginMessageReceived(); + + // Fire up a thread to send the intial commands. + CrestronInvoke.BeginInvoke((o) => { - SyncState.LoginMessageReceived(); + Thread.Sleep(100); + // disable echo of commands + SendText("echo off"); + Thread.Sleep(100); + // set feedback exclusions + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/info/callin_country_list"); + Thread.Sleep(100); + SendText("zFeedback Register Op: ex Path: /Event/InfoResult/info/callout_country_list"); + Thread.Sleep(100); + // switch to json format + SendText("format json"); + }); - // Fire up a thread to send the intial commands. - CrestronInvoke.BeginInvoke((o) => - { - Thread.Sleep(100); - // disable echo of commands - SendText("echo off"); - Thread.Sleep(100); - // set feedback exclusions - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/info/callin_country_list"); - Thread.Sleep(100); - SendText("zFeedback Register Op: ex Path: /Event/InfoResult/info/callout_country_list"); - Thread.Sleep(100); - // switch to json format - SendText("format json"); - }); - - break; - } + break; + } } } } @@ -581,18 +749,22 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// Deserializes a JSON formatted response /// /// - void DeserializeResponse(string response) + private void DeserializeResponse(string response) { try { var trimmedResponse = response.Trim(); if (trimmedResponse.Length <= 0) + { return; + } var message = JObject.Parse(trimmedResponse); - eZoomRoomResponseType eType = (eZoomRoomResponseType)Enum.Parse(typeof(eZoomRoomResponseType), message["type"].Value(), true); + eZoomRoomResponseType eType = + (eZoomRoomResponseType) + Enum.Parse(typeof (eZoomRoomResponseType), message["type"].Value(), true); var topKey = message["topKey"].Value(); @@ -603,385 +775,413 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom switch (eType) { case eZoomRoomResponseType.zConfiguration: + { + switch (topKey.ToLower()) { - switch (topKey.ToLower()) + case "call": { - case "call": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Call); + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Call); - break; - } - case "audio": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Audio); - - break; - } - case "video": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Video); - - break; - } - case "client": - { - JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Client); - - break; - } - default: - { - break; - } + break; + } + case "audio": + { + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Audio); + + break; + } + case "video": + { + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Video); + + break; + } + case "client": + { + JsonConvert.PopulateObject(responseObj.ToString(), Configuration.Client); + + break; + } + default: + { + break; } - break; } + break; + } case eZoomRoomResponseType.zCommand: + { + switch (topKey.ToLower()) { - switch (topKey.ToLower()) + case "phonebooklistresult": { - case "phonebooklistresult": + JsonConvert.PopulateObject(responseObj.ToString(), Status.Phonebook); + + if (!PhonebookSyncState.InitialSyncComplete) + { + PhonebookSyncState.InitialPhonebookFoldersReceived(); + PhonebookSyncState.PhonebookRootEntriesReceived(); + PhonebookSyncState.SetPhonebookHasFolders(false); + PhonebookSyncState.SetNumberOfContacts(Status.Phonebook.Contacts.Count); + } + + var directoryResults = new CodecDirectory(); + + directoryResults = + zStatus.Phonebook.ConvertZoomContactsToGeneric(Status.Phonebook.Contacts); + + DirectoryRoot = directoryResults; + + OnDirectoryResultReturned(directoryResults); + + break; + } + case "listparticipantsresult": + { + Debug.Console(1, this, "JTokenType: {0}", responseObj.Type); + + if (responseObj.Type == JTokenType.Array) + { + // if the type is array this must be the complete list + Status.Call.Participants = + JsonConvert.DeserializeObject>( + responseObj.ToString()); + } + else if (responseObj.Type == JTokenType.Object) + { + // this is a single participant event notification + + var participant = + JsonConvert.DeserializeObject(responseObj.ToString()); + + if (participant != null) { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Phonebook); - - if(!PhonebookSyncState.InitialSyncComplete) + if (participant.Event == "ZRCUserChangedEventLeftMeeting" || + participant.Event == "ZRCUserChangedEventUserInfoUpdated") { - PhonebookSyncState.InitialPhonebookFoldersReceived(); - PhonebookSyncState.PhonebookRootEntriesReceived(); - PhonebookSyncState.SetPhonebookHasFolders(false); - PhonebookSyncState.SetNumberOfContacts(Status.Phonebook.Contacts.Count); - } + var existingParticipant = + Status.Call.Participants.FirstOrDefault( + p => p.UserId.Equals(participant.UserId)); - var directoryResults = new CodecDirectory(); - - directoryResults = zStatus.Phonebook.ConvertZoomContactsToGeneric(Status.Phonebook.Contacts); - - DirectoryRoot = directoryResults; - - OnDirectoryResultReturned(directoryResults); - - break; - } - case "listparticipantsresult": - { - Debug.Console(1, this, "JTokenType: {0}", responseObj.Type); - - if (responseObj.Type == JTokenType.Array) - { - // if the type is array this must be the complete list - Status.Call.Participants = JsonConvert.DeserializeObject>(responseObj.ToString()); - } - else if (responseObj.Type == JTokenType.Object) - { - // this is a single participant event notification - - var participant = JsonConvert.DeserializeObject(responseObj.ToString()); - - if (participant != null) + if (existingParticipant != null) { - if (participant.Event == "ZRCUserChangedEventLeftMeeting" || participant.Event == "ZRCUserChangedEventUserInfoUpdated") + if (participant.Event == "ZRCUserChangedEventLeftMeeting") { - var existingParticipant = Status.Call.Participants.FirstOrDefault(p => p.UserId.Equals(participant.UserId)); - - if (existingParticipant != null) - { - if (participant.Event == "ZRCUserChangedEventLeftMeeting") - { - // Remove participant - Status.Call.Participants.Remove(existingParticipant); - } - else if (participant.Event == "ZRCUserChangedEventUserInfoUpdated") - { - // Update participant - JsonConvert.PopulateObject(responseObj.ToString(), existingParticipant); - } - } + // Remove participant + Status.Call.Participants.Remove(existingParticipant); } - else if(participant.Event == "ZRCUserChangedEventJoinedMeeting") + else if (participant.Event == "ZRCUserChangedEventUserInfoUpdated") { - Status.Call.Participants.Add(participant); + // Update participant + JsonConvert.PopulateObject(responseObj.ToString(), + existingParticipant); } } } - - PrintCurrentCallParticipants(); - - break; - } - default: - { - break; + else if (participant.Event == "ZRCUserChangedEventJoinedMeeting") + { + Status.Call.Participants.Add(participant); + } } + } + + PrintCurrentCallParticipants(); + + break; + } + default: + { + break; } - break; } + break; + } case eZoomRoomResponseType.zEvent: + { + switch (topKey.ToLower()) { - switch (topKey.ToLower()) + case "phonebook": { - case "phonebook": + if (responseObj["Updated Contact"] != null) + { + var updatedContact = + JsonConvert.DeserializeObject( + responseObj["Updated Contact"].ToString()); + + var existingContact = + Status.Phonebook.Contacts.FirstOrDefault(c => c.Jid.Equals(updatedContact.Jid)); + + if (existingContact != null) { - if (responseObj["Updated Contact"] != null) - { - var updatedContact = JsonConvert.DeserializeObject(responseObj["Updated Contact"].ToString()); - - var existingContact = Status.Phonebook.Contacts.FirstOrDefault(c => c.Jid.Equals(updatedContact.Jid)); - - if (existingContact != null) - { - // Update existing contact - JsonConvert.PopulateObject(responseObj["Updated Contact"].ToString(), existingContact); - } - } - else if (responseObj["Added Contact"] != null) - { - var newContact = JsonConvert.DeserializeObject(responseObj["Updated Contact"].ToString()); - - // Add a new contact - Status.Phonebook.Contacts.Add(newContact); - } - - break; + // Update existing contact + JsonConvert.PopulateObject(responseObj["Updated Contact"].ToString(), + existingContact); } - case "bookingslistresult": - { - if (!SyncState.InitialSyncComplete) - SyncState.LastQueryResponseReceived(); + } + else if (responseObj["Added Contact"] != null) + { + var newContact = + JsonConvert.DeserializeObject( + responseObj["Updated Contact"].ToString()); - var codecBookings = new List(); + // Add a new contact + Status.Phonebook.Contacts.Add(newContact); + } - codecBookings = JsonConvert.DeserializeObject < List>(responseObj.ToString()); - - if (codecBookings != null && codecBookings.Count > 0) - { - CodecSchedule.Meetings = zCommand.GetGenericMeetingsFromBookingResult(codecBookings); - } - - break; - } - case "bookings": - { - // Bookings have been updated, trigger a query to retreive the new bookings - if (responseObj["Updated"] != null) - GetBookings(); - - break; - } - case "sharingstate": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.Sharing); - - break; - } - case "incomingcallindication": - { - var incomingCall = JsonConvert.DeserializeObject(responseObj.ToString()); - - if (incomingCall != null) - { - var newCall = new CodecActiveCallItem(); - - newCall.Direction = eCodecCallDirection.Incoming; - newCall.Status = eCodecCallStatus.Ringing; - newCall.Type = eCodecCallType.Unknown; - newCall.Name = incomingCall.callerName; - newCall.Id = incomingCall.callerJID; - - ActiveCalls.Add(newCall); - - OnCallStatusChange(newCall); - } - - break; - } - case "treatedincomingcallindication": - { - var incomingCall = JsonConvert.DeserializeObject(responseObj.ToString()); - - if (incomingCall != null) - { - var existingCall = ActiveCalls.FirstOrDefault(c => c.Id.Equals(incomingCall.callerJID)); - - if (existingCall != null) - { - if (!incomingCall.accepted) - { - existingCall.Status = eCodecCallStatus.Disconnected; - } - else - { - existingCall.Status = eCodecCallStatus.Connecting; - } - - OnCallStatusChange(existingCall); - } - - UpdateCallStatus(); - } - - break; - } - case "calldisconnect": - { - var disconnectEvent = JsonConvert.DeserializeObject(responseObj.ToString()); - - if (disconnectEvent.Successful) - { - if (ActiveCalls.Count > 0) - { - var activeCall = ActiveCalls.FirstOrDefault(c => c.IsActiveCall); - - if (activeCall != null) - { - activeCall.Status = eCodecCallStatus.Disconnected; - - OnCallStatusChange(activeCall); - } - } - } - - UpdateCallStatus(); - break; - } - case "callconnecterror": - { - UpdateCallStatus(); - break; - } - case "videounmuterequest": - { - // TODO: notify room of a request to unmute video - break; - } - case "meetingneedspassword": - { - // TODO: notify user to enter a password - break; - } - case "needwaitforhost": - { - var needWait = JsonConvert.DeserializeObject(responseObj.ToString()); - - if (needWait.Wait) - { - // TODO: notify user to wait for host - } - - break; - } - case "openvideofailforhoststop": - { - // TODO: notify user that host has disabled unmuting video - break; - } - case "updatedcallrecordinfo": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.CallRecordInfo); - - break; - } - default: - { - break; - } + break; + } + case "bookingslistresult": + { + if (!SyncState.InitialSyncComplete) + { + SyncState.LastQueryResponseReceived(); + } + + var codecBookings = new List(); + + codecBookings = + JsonConvert.DeserializeObject>( + responseObj.ToString()); + + if (codecBookings != null && codecBookings.Count > 0) + { + CodecSchedule.Meetings = zCommand.GetGenericMeetingsFromBookingResult(codecBookings); + } + + break; + } + case "bookings": + { + // Bookings have been updated, trigger a query to retreive the new bookings + if (responseObj["Updated"] != null) + { + GetBookings(); + } + + break; + } + case "sharingstate": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.Sharing); + + break; + } + case "incomingcallindication": + { + var incomingCall = + JsonConvert.DeserializeObject(responseObj.ToString()); + + if (incomingCall != null) + { + var newCall = new CodecActiveCallItem(); + + newCall.Direction = eCodecCallDirection.Incoming; + newCall.Status = eCodecCallStatus.Ringing; + newCall.Type = eCodecCallType.Unknown; + newCall.Name = incomingCall.callerName; + newCall.Id = incomingCall.callerJID; + + ActiveCalls.Add(newCall); + + OnCallStatusChange(newCall); + } + + break; + } + case "treatedincomingcallindication": + { + var incomingCall = + JsonConvert.DeserializeObject(responseObj.ToString()); + + if (incomingCall != null) + { + var existingCall = + ActiveCalls.FirstOrDefault(c => c.Id.Equals(incomingCall.callerJID)); + + if (existingCall != null) + { + if (!incomingCall.accepted) + { + existingCall.Status = eCodecCallStatus.Disconnected; + } + else + { + existingCall.Status = eCodecCallStatus.Connecting; + } + + OnCallStatusChange(existingCall); + } + + UpdateCallStatus(); + } + + break; + } + case "calldisconnect": + { + var disconnectEvent = + JsonConvert.DeserializeObject(responseObj.ToString()); + + if (disconnectEvent.Successful) + { + if (ActiveCalls.Count > 0) + { + var activeCall = ActiveCalls.FirstOrDefault(c => c.IsActiveCall); + + if (activeCall != null) + { + activeCall.Status = eCodecCallStatus.Disconnected; + + OnCallStatusChange(activeCall); + } + } + } + + UpdateCallStatus(); + break; + } + case "callconnecterror": + { + UpdateCallStatus(); + break; + } + case "videounmuterequest": + { + // TODO: notify room of a request to unmute video + break; + } + case "meetingneedspassword": + { + // TODO: notify user to enter a password + break; + } + case "needwaitforhost": + { + var needWait = + JsonConvert.DeserializeObject(responseObj.ToString()); + + if (needWait.Wait) + { + // TODO: notify user to wait for host + } + + break; + } + case "openvideofailforhoststop": + { + // TODO: notify user that host has disabled unmuting video + break; + } + case "updatedcallrecordinfo": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Call.CallRecordInfo); + + break; + } + default: + { + break; } - break; } + break; + } case eZoomRoomResponseType.zStatus: + { + switch (topKey.ToLower()) { - switch (topKey.ToLower()) + case "login": { - case "login": - { - SyncState.LoginMessageReceived(); + SyncState.LoginMessageReceived(); - if (!SyncState.InitialQueryMessagesWereSent) - SetUpSyncQueries(); + if (!SyncState.InitialQueryMessagesWereSent) + { + SetUpSyncQueries(); + } - JsonConvert.PopulateObject(responseObj.ToString(), Status.Login); + JsonConvert.PopulateObject(responseObj.ToString(), Status.Login); - break; - } - case "systemunit": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.SystemUnit); - - break; - } - case "call": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Call); - - UpdateCallStatus(); - - break; - } - case "capabilities": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Capabilities); - break; - } - case "sharing": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Sharing); - - break; - } - case "numberofscreens": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.NumberOfScreens); - break; - } - case "video": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Video); - break; - } - case "camerashare": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.CameraShare); - break; - } - case "layout": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Layout); - break; - } - case "audio input line": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioInputs); - break; - } - case "audio output line": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioOuputs); - break; - } - case "video camera line": - { - JsonConvert.PopulateObject(responseObj.ToString(), Status.Cameras); - - if(!SyncState.CamerasHaveBeenSetUp) - SetUpCameras(); - - break; - } - default: - { - break; - } + break; } + case "systemunit": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.SystemUnit); - break; + break; + } + case "call": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Call); + + UpdateCallStatus(); + + break; + } + case "capabilities": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Capabilities); + break; + } + case "sharing": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Sharing); + + break; + } + case "numberofscreens": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.NumberOfScreens); + break; + } + case "video": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Video); + break; + } + case "camerashare": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.CameraShare); + break; + } + case "layout": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Layout); + break; + } + case "audio input line": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioInputs); + break; + } + case "audio output line": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.AudioOuputs); + break; + } + case "video camera line": + { + JsonConvert.PopulateObject(responseObj.ToString(), Status.Cameras); + + if (!SyncState.CamerasHaveBeenSetUp) + { + SetUpCameras(); + } + + break; + } + default: + { + break; + } } + + break; + } default: - { - Debug.Console(1, "Unknown Response Type:"); - break; - } + { + Debug.Console(1, "Unknown Response Type:"); + break; + } } - } catch (Exception ex) { @@ -996,7 +1196,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom Debug.Console(1, this, "****************************Call Participants***************************"); foreach (var participant in Status.Call.Participants) { - Debug.Console(1, this, "Name: {0} Audio: {1} IsHost: {2}", participant.UserName, participant.AudioStatusState, participant.IsHost); + Debug.Console(1, this, "Name: {0} Audio: {1} IsHost: {2}", participant.UserName, + participant.AudioStatusState, participant.IsHost); } Debug.Console(1, this, "************************************************************************"); } @@ -1005,7 +1206,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// /// Retrieves bookings list /// - void GetBookings() + private void GetBookings() { SendText("zCommand Bookings List"); } @@ -1014,7 +1215,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// /// Updates the current call status /// - void UpdateCallStatus() + private void UpdateCallStatus() { zStatus.eCallStatus callStatus; @@ -1031,7 +1232,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom if (ActiveCalls.Count == 0) { - if(callStatus == zStatus.eCallStatus.CONNECTING_MEETING) + if (callStatus == zStatus.eCallStatus.CONNECTING_MEETING) { var newCall = new CodecActiveCallItem(); @@ -1057,7 +1258,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom OnCallStatusChange(existingCall); } - } Debug.Console(1, this, "****************************Active Calls*********************************"); @@ -1067,7 +1267,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { var call = ActiveCalls[i]; - Debug.Console(1, this, + Debug.Console(1, this, @"Name: {0} ID: {1} IsActive: {2} @@ -1082,7 +1282,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom } Debug.Console(1, this, "**************************************************************************"); - } public override void StartSharing() @@ -1111,19 +1310,23 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom public override void PrivacyModeToggle() { if (PrivacyModeIsOnFeedback.BoolValue) + { PrivacyModeOff(); + } else + { PrivacyModeOn(); + } } public override void MuteOff() { - SetVolume((ushort)PreviousVolumeLevel); + SetVolume((ushort) PreviousVolumeLevel); } public override void MuteOn() { - PreviousVolumeLevel = Configuration.Audio.Output.Volume; // Store the previous level for recall + PreviousVolumeLevel = Configuration.Audio.Output.Volume; // Store the previous level for recall SetVolume(0); } @@ -1131,9 +1334,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom public override void MuteToggle() { if (MuteFeedback.BoolValue) + { MuteOff(); + } else + { MuteOn(); + } } /// @@ -1169,7 +1376,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// public void VolumeSetToDefault() { - } /// @@ -1193,20 +1399,19 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom (selector as Action)(); } - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - ExecuteSwitch(inputSelector); - } - public override void AcceptCall(CodecActiveCallItem call) { - var incomingCall = ActiveCalls.FirstOrDefault(c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); + var incomingCall = + ActiveCalls.FirstOrDefault( + c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); SendText(string.Format("zCommand Call Accept callerJID: {0}", incomingCall.Id)); } public override void RejectCall(CodecActiveCallItem call) { - var incomingCall = ActiveCalls.FirstOrDefault(c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); + var incomingCall = + ActiveCalls.FirstOrDefault( + c => c.Status.Equals(eCodecCallStatus.Ringing) && c.Direction.Equals(eCodecCallDirection.Incoming)); SendText(string.Format("zCommand Call Reject callerJID: {0}", incomingCall.Id)); } @@ -1234,9 +1439,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom Debug.Console(1, this, "Attempting to Dial (Invite): {0}", ic.Name); if (!IsInCall) - SendText(string.Format("zCommand Invite Duration: {0} user: {1}", DefaultMeetingDurationMin, ic.ContactId)); + { + SendText(string.Format("zCommand Invite Duration: {0} user: {1}", DefaultMeetingDurationMin, + ic.ContactId)); + } else + { SendText(string.Format("zCommand Call invite user: {0}", ic.ContactId)); + } } } @@ -1255,39 +1465,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom throw new NotImplementedException(); } - - #region IHasCodecSelfView Members - - public BoolFeedback SelfviewIsOnFeedback { get; private set; } - - public void SelfViewModeOn() - { - SendText("zConfiguration Video hide_conf_self_video: off"); - } - - public void SelfViewModeOff() - { - SendText("zConfiguration Video hide_conf_self_video: on"); - } - - public void SelfViewModeToggle() - { - if (SelfviewIsOnFeedback.BoolValue) - SelfViewModeOff(); - else - SelfViewModeOn(); - } - - #endregion - - #region IHasDirectory Members - - public event EventHandler DirectoryResultReturned; - /// Call when directory results are updated /// /// - void OnDirectoryResultReturned(CodecDirectory result) + private void OnDirectoryResultReturned(CodecDirectory result) { CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); @@ -1305,94 +1486,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom //PrintDirectory(result); } - public CodecDirectory DirectoryRoot { get; private set; } - - public CodecDirectory CurrentDirectoryResult - { - get - { - if (DirectoryBrowseHistory.Count > 0) - return DirectoryBrowseHistory[DirectoryBrowseHistory.Count - 1]; - else - return DirectoryRoot; - } - } - - public CodecPhonebookSyncState PhonebookSyncState { get; private set; } - - public void SearchDirectory(string searchString) - { - var directoryResults = new CodecDirectory(); - - directoryResults.AddContactsToDirectory(DirectoryRoot.CurrentDirectoryResults.FindAll(c => c.Name.IndexOf(searchString, 0, StringComparison.OrdinalIgnoreCase) > -1)); - - DirectoryBrowseHistory.Add(directoryResults); - - OnDirectoryResultReturned(directoryResults); - } - - public void GetDirectoryFolderContents(string folderId) - { - var directoryResults = new CodecDirectory(); - - directoryResults.ResultsFolderId = folderId; - directoryResults.AddContactsToDirectory(DirectoryRoot.CurrentDirectoryResults.FindAll(c => c.FolderId.Equals(folderId))); - - DirectoryBrowseHistory.Add(directoryResults); - - OnDirectoryResultReturned(directoryResults); - } - - public void SetCurrentDirectoryToRoot() - { - DirectoryBrowseHistory.Clear(); - - OnDirectoryResultReturned(DirectoryRoot); - } - - public void GetDirectoryParentFolderContents() - { - var currentDirectory = new CodecDirectory(); - - if (DirectoryBrowseHistory.Count > 0) - { - var lastItemIndex = DirectoryBrowseHistory.Count - 1; - var parentDirectoryContents = DirectoryBrowseHistory[lastItemIndex]; - - DirectoryBrowseHistory.Remove(DirectoryBrowseHistory[lastItemIndex]); - - currentDirectory = parentDirectoryContents; - - } - else - { - currentDirectory = DirectoryRoot; - } - - OnDirectoryResultReturned(currentDirectory); - } - - public BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; private set; } - - public List DirectoryBrowseHistory { get; private set; } - - #endregion - - #region IHasScheduleAwareness Members - - public CodecScheduleAwareness CodecSchedule { get; private set; } - - public void GetSchedule() - { - GetBookings(); - } - - #endregion - /// /// Builds the cameras List by using the Zoom Room zStatus.Cameras data. Could later be modified to build from config data /// - void SetUpCameras() + private void SetUpCameras() { SelectedCameraFeedback = new StringFeedback(() => Configuration.Video.Camera.SelectedId); @@ -1405,11 +1502,15 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom Cameras.Add(camera); if (cam.Selected) - SelectedCamera = camera; + { + SelectedCamera = camera; + } } if (IsInCall) + { UpdateFarEndCameras(); + } SyncState.CamerasSetUp(); } @@ -1417,66 +1518,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// /// Dynamically creates far end cameras for call participants who have far end control enabled. /// - void UpdateFarEndCameras() + private void UpdateFarEndCameras() { // TODO: set up far end cameras for the current call } - - #region IHasCameras Members - - public event EventHandler CameraSelected; - - public List Cameras { get; private set; } - - private CameraBase _selectedCamera; - - public CameraBase SelectedCamera - { - get - { - return _selectedCamera; - } - private set - { - _selectedCamera = value; - SelectedCameraFeedback.FireUpdate(); - ControllingFarEndCameraFeedback.FireUpdate(); - - var handler = CameraSelected; - if (handler != null) - { - handler(this, new CameraSelectedEventArgs(SelectedCamera)); - } - } - } - - - public StringFeedback SelectedCameraFeedback { get; private set; } - - public void SelectCamera(string key) - { - 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); - } - } - - #endregion - - #region IHasFarEndCameraControl Members - - public CameraBase FarEndCamera { get; private set; } - - public BoolFeedback ControllingFarEndCameraFeedback { get; private set; } - - #endregion } /// @@ -1484,15 +1529,18 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// public class ZoomRoomInfo : VideoCodecInfo { + public ZoomRoomInfo(ZoomRoomStatus status, ZoomRoomConfiguration configuration) + { + Status = status; + Configuration = configuration; + } + public ZoomRoomStatus Status { get; private set; } public ZoomRoomConfiguration Configuration { get; private set; } public override bool AutoAnswerEnabled { - get - { - return Status.SystemUnit.RoomInfo.AutoAnswerIsEnabled; - } + get { return Status.SystemUnit.RoomInfo.AutoAnswerIsEnabled; } } public override string E164Alias @@ -1500,9 +1548,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom get { if (!string.IsNullOrEmpty(Status.SystemUnit.MeetingNumber)) + { return Status.SystemUnit.MeetingNumber; + } else + { return string.Empty; + } } } @@ -1511,9 +1563,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom get { if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.h323_address)) + { return Status.Call.Info.meeting_list_item.third_party.h323_address; + } else + { return string.Empty; + } } } @@ -1522,9 +1578,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom get { if (!string.IsNullOrEmpty(Status.SystemUnit.RoomInfo.AccountEmail)) + { return Status.SystemUnit.RoomInfo.AccountEmail; + } else + { return string.Empty; + } } } @@ -1538,9 +1598,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom get { if (!string.IsNullOrEmpty(Status.Call.Info.dialIn)) + { return Status.Call.Info.dialIn; + } else + { return string.Empty; + } } } @@ -1549,17 +1613,15 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom get { if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.sip_address)) + { return Status.Call.Info.meeting_list_item.third_party.sip_address; + } else + { return string.Empty; + } } } - - public ZoomRoomInfo(ZoomRoomStatus status, ZoomRoomConfiguration configuration) - { - Status = status; - Configuration = configuration; - } } /// @@ -1567,15 +1629,17 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom /// public class ZoomRoomSyncState : IKeyed { - bool _InitialSyncComplete; + private readonly ZoomRoom Parent; + private readonly CrestronQueue SyncQueries; + private bool _InitialSyncComplete; - public event EventHandler InitialSyncCompleted; - - private CrestronQueue SyncQueries; - - private ZoomRoom Parent; - - public string Key { get; private set; } + public ZoomRoomSyncState(string key, ZoomRoom parent) + { + Parent = parent; + Key = key; + SyncQueries = new CrestronQueue(50); + CodecDisconnected(); + } public bool InitialSyncComplete { @@ -1586,7 +1650,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { var handler = InitialSyncCompleted; if (handler != null) + { handler(this, new EventArgs()); + } } _InitialSyncComplete = value; } @@ -1598,28 +1664,28 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom public bool LastQueryResponseWasReceived { get; private set; } - public bool CamerasHaveBeenSetUp { get; private set;} + public bool CamerasHaveBeenSetUp { get; private set; } - public ZoomRoomSyncState(string key, ZoomRoom parent) - { - Parent = parent; - Key = key; - SyncQueries = new CrestronQueue(50); - CodecDisconnected(); - } + #region IKeyed Members + + public string Key { get; private set; } + + #endregion + + public event EventHandler InitialSyncCompleted; public void StartSync() { DequeueQueries(); } - void DequeueQueries() + private void DequeueQueries() { while (!SyncQueries.IsEmpty) { var query = SyncQueries.Dequeue(); - Parent.SendText(query); + Parent.SendText(query); } InitialQueryMessagesSent(); @@ -1668,15 +1734,18 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom InitialSyncComplete = false; } - void CheckSyncStatus() + private void CheckSyncStatus() { - if (LoginMessageWasReceived && InitialQueryMessagesWereSent && LastQueryResponseWasReceived && CamerasHaveBeenSetUp) + if (LoginMessageWasReceived && InitialQueryMessagesWereSent && LastQueryResponseWasReceived && + CamerasHaveBeenSetUp) { InitialSyncComplete = true; Debug.Console(1, this, "Initial Codec Sync Complete!"); } else + { InitialSyncComplete = false; + } } } @@ -1684,15 +1753,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { public ZoomRoomFactory() { - TypeNames = new List() { "zoomroom" }; + TypeNames = new List() {"zoomroom"}; } public override EssentialsDevice BuildDevice(DeviceConfig dc) { Debug.Console(1, "Factory Attempting to create new ZoomRoom Device"); var comm = CommFactory.CreateCommForDevice(dc); - return new VideoCodec.ZoomRoom.ZoomRoom(dc, comm); + return new ZoomRoom(dc, comm); } } - } \ No newline at end of file