From 4b4bf1a1c8297454e2316a9450282c5ab7e30808 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 8 Sep 2017 15:00:16 -0600 Subject: [PATCH] Working HTTP Server and Client communicating with codec. Need to fix issue with deserializing configuration.xml upon connection (null ref exception). --- .../Constants/CommonCues.cs | 242 +++++++++--------- .../Devices/IHasDialer.cs | 3 + .../Devices/IVolumeAndAudioInterfaces.cs | 194 +++++++------- .../VC/Cisco/CiscoCodec.cs | 237 ++++++++++++++++- .../VC/Cisco/HttpApiServer.cs | 25 +- .../VC/VideoCodecBase.cs | 6 + .../PepperDashEssentials/ControlSystem.cs | 4 +- 7 files changed, 460 insertions(+), 251 deletions(-) diff --git a/Essentials Core/PepperDashEssentialsBase/Constants/CommonCues.cs b/Essentials Core/PepperDashEssentialsBase/Constants/CommonCues.cs index 0948816c..fd8465b4 100644 --- a/Essentials Core/PepperDashEssentialsBase/Constants/CommonCues.cs +++ b/Essentials Core/PepperDashEssentialsBase/Constants/CommonCues.cs @@ -1,127 +1,127 @@ -using Crestron.SimplSharpPro; - -namespace PepperDash.Essentials.Core -{ - public static class CommonBoolCue - { - public static readonly Cue Power = new Cue("Power", 101, eCueType.Bool); - public static readonly Cue PowerOn = new Cue("PowerOn", 102, eCueType.Bool); - public static readonly Cue PowerOff = new Cue("PowerOff", 103, eCueType.Bool); - - public static readonly Cue HasPowerFeedback = new Cue("HasPowerFeedback", 101, eCueType.Bool); - public static readonly Cue PowerOnFeedback = new Cue("PowerOnFeedback", 102, eCueType.Bool); - public static readonly Cue IsOnlineFeedback = new Cue("IsOnlineFeedback", 104, eCueType.Bool); - public static readonly Cue IsWarmingUp = new Cue("IsWarmingUp", 105, eCueType.Bool); - public static readonly Cue IsCoolingDown = new Cue("IsCoolingDown", 106, eCueType.Bool); - - public static readonly Cue Dash = new Cue("Dash", 109, eCueType.Bool); - public static readonly Cue Digit0 = new Cue("Digit0", 110, eCueType.Bool); - public static readonly Cue Digit1 = new Cue("Digit1", 111, eCueType.Bool); - public static readonly Cue Digit2 = new Cue("Digit2", 112, eCueType.Bool); - public static readonly Cue Digit3 = new Cue("Digit3", 113, eCueType.Bool); - public static readonly Cue Digit4 = new Cue("Digit4", 114, eCueType.Bool); - public static readonly Cue Digit5 = new Cue("Digit5", 115, eCueType.Bool); - public static readonly Cue Digit6 = new Cue("Digit6", 116, eCueType.Bool); - public static readonly Cue Digit7 = new Cue("Digit7", 117, eCueType.Bool); - public static readonly Cue Digit8 = new Cue("Digit8", 118, eCueType.Bool); - public static readonly Cue Digit9 = new Cue("Digit9", 119, eCueType.Bool); - public static readonly Cue KeypadMisc1 = new Cue("KeypadMisc1", 120, eCueType.Bool); - public static readonly Cue KeypadMisc2 = new Cue("KeypadMisc2", 121, eCueType.Bool); - - public static readonly Cue NumericEnter = new Cue("Enter", 122, eCueType.Bool); - public static readonly Cue ChannelUp = new Cue("ChannelUp", 123, eCueType.Bool); - public static readonly Cue ChannelDown = new Cue("ChannelDown", 124, eCueType.Bool); - public static readonly Cue Last = new Cue("Last", 125, eCueType.Bool); - public static readonly Cue OpenClose = new Cue("OpenClose", 126, eCueType.Bool); - public static readonly Cue Subtitle = new Cue("Subtitle", 127, eCueType.Bool); - public static readonly Cue Audio = new Cue("Audio", 128, eCueType.Bool); - public static readonly Cue Info = new Cue("Info", 129, eCueType.Bool); - public static readonly Cue Menu = new Cue("Menu", 130, eCueType.Bool); - public static readonly Cue DeviceMenu = new Cue("DeviceMenu", 131, eCueType.Bool); - public static readonly Cue Return = new Cue("Return", 132, eCueType.Bool); - public static readonly Cue Back = new Cue("Back", 133, eCueType.Bool); - public static readonly Cue Exit = new Cue("Exit", 134, eCueType.Bool); - public static readonly Cue Clear = new Cue("Clear", 135, eCueType.Bool); - public static readonly Cue List = new Cue("List", 136, eCueType.Bool); - public static readonly Cue Guide = new Cue("Guide", 137, eCueType.Bool); - public static readonly Cue Am = new Cue("Am", 136, eCueType.Bool); - public static readonly Cue Fm = new Cue("Fm", 137, eCueType.Bool); - public static readonly Cue Up = new Cue("Up", 138, eCueType.Bool); - public static readonly Cue Down = new Cue("Down", 139, eCueType.Bool); - public static readonly Cue Left = new Cue("Left", 140, eCueType.Bool); - public static readonly Cue Right = new Cue("Right", 141, eCueType.Bool); - public static readonly Cue Select = new Cue("Select", 142, eCueType.Bool); - public static readonly Cue SmartApps = new Cue("SmartApps", 143, eCueType.Bool); - public static readonly Cue Dvr = new Cue("Dvr", 144, eCueType.Bool); - - public static readonly Cue Play = new Cue("Play", 145, eCueType.Bool); - public static readonly Cue Pause = new Cue("Pause", 146, eCueType.Bool); - public static readonly Cue Stop = new Cue("Stop", 147, eCueType.Bool); - public static readonly Cue ChapNext = new Cue("ChapNext", 148, eCueType.Bool); - public static readonly Cue ChapPrevious = new Cue("ChapPrevious", 149, eCueType.Bool); - public static readonly Cue Rewind = new Cue("Rewind", 150, eCueType.Bool); - public static readonly Cue Ffwd = new Cue("Ffwd", 151, eCueType.Bool); - public static readonly Cue Replay = new Cue("Replay", 152, eCueType.Bool); - public static readonly Cue Advance = new Cue("Advance", 153, eCueType.Bool); - public static readonly Cue Record = new Cue("Record", 154, eCueType.Bool); - public static readonly Cue Red = new Cue("Red", 155, eCueType.Bool); - public static readonly Cue Green = new Cue("Green", 156, eCueType.Bool); - public static readonly Cue Yellow = new Cue("Yellow", 157, eCueType.Bool); - public static readonly Cue Blue = new Cue("Blue", 158, eCueType.Bool); - public static readonly Cue Home = new Cue("Home", 159, eCueType.Bool); - public static readonly Cue PopUp = new Cue("PopUp", 160, eCueType.Bool); - public static readonly Cue PageUp = new Cue("PageUp", 161, eCueType.Bool); - public static readonly Cue PageDown = new Cue("PageDown", 162, eCueType.Bool); - public static readonly Cue Search = new Cue("Search", 163, eCueType.Bool); - public static readonly Cue Setup = new Cue("Setup", 164, eCueType.Bool); - public static readonly Cue RStep = new Cue("RStep", 165, eCueType.Bool); - public static readonly Cue FStep = new Cue("FStep", 166, eCueType.Bool); - +using Crestron.SimplSharpPro; + +namespace PepperDash.Essentials.Core +{ + public static class CommonBoolCue + { + public static readonly Cue Power = new Cue("Power", 101, eCueType.Bool); + public static readonly Cue PowerOn = new Cue("PowerOn", 102, eCueType.Bool); + public static readonly Cue PowerOff = new Cue("PowerOff", 103, eCueType.Bool); + + public static readonly Cue HasPowerFeedback = new Cue("HasPowerFeedback", 101, eCueType.Bool); + public static readonly Cue PowerOnFeedback = new Cue("PowerOnFeedback", 102, eCueType.Bool); + public static readonly Cue IsOnlineFeedback = new Cue("IsOnlineFeedback", 104, eCueType.Bool); + public static readonly Cue IsWarmingUp = new Cue("IsWarmingUp", 105, eCueType.Bool); + public static readonly Cue IsCoolingDown = new Cue("IsCoolingDown", 106, eCueType.Bool); + + public static readonly Cue Dash = new Cue("Dash", 109, eCueType.Bool); + public static readonly Cue Digit0 = new Cue("Digit0", 110, eCueType.Bool); + public static readonly Cue Digit1 = new Cue("Digit1", 111, eCueType.Bool); + public static readonly Cue Digit2 = new Cue("Digit2", 112, eCueType.Bool); + public static readonly Cue Digit3 = new Cue("Digit3", 113, eCueType.Bool); + public static readonly Cue Digit4 = new Cue("Digit4", 114, eCueType.Bool); + public static readonly Cue Digit5 = new Cue("Digit5", 115, eCueType.Bool); + public static readonly Cue Digit6 = new Cue("Digit6", 116, eCueType.Bool); + public static readonly Cue Digit7 = new Cue("Digit7", 117, eCueType.Bool); + public static readonly Cue Digit8 = new Cue("Digit8", 118, eCueType.Bool); + public static readonly Cue Digit9 = new Cue("Digit9", 119, eCueType.Bool); + public static readonly Cue KeypadMisc1 = new Cue("KeypadMisc1", 120, eCueType.Bool); + public static readonly Cue KeypadMisc2 = new Cue("KeypadMisc2", 121, eCueType.Bool); + + public static readonly Cue NumericEnter = new Cue("Enter", 122, eCueType.Bool); + public static readonly Cue ChannelUp = new Cue("ChannelUp", 123, eCueType.Bool); + public static readonly Cue ChannelDown = new Cue("ChannelDown", 124, eCueType.Bool); + public static readonly Cue Last = new Cue("Last", 125, eCueType.Bool); + public static readonly Cue OpenClose = new Cue("OpenClose", 126, eCueType.Bool); + public static readonly Cue Subtitle = new Cue("Subtitle", 127, eCueType.Bool); + public static readonly Cue Audio = new Cue("Audio", 128, eCueType.Bool); + public static readonly Cue Info = new Cue("Info", 129, eCueType.Bool); + public static readonly Cue Menu = new Cue("Menu", 130, eCueType.Bool); + public static readonly Cue DeviceMenu = new Cue("DeviceMenu", 131, eCueType.Bool); + public static readonly Cue Return = new Cue("Return", 132, eCueType.Bool); + public static readonly Cue Back = new Cue("Back", 133, eCueType.Bool); + public static readonly Cue Exit = new Cue("Exit", 134, eCueType.Bool); + public static readonly Cue Clear = new Cue("Clear", 135, eCueType.Bool); + public static readonly Cue List = new Cue("List", 136, eCueType.Bool); + public static readonly Cue Guide = new Cue("Guide", 137, eCueType.Bool); + public static readonly Cue Am = new Cue("Am", 136, eCueType.Bool); + public static readonly Cue Fm = new Cue("Fm", 137, eCueType.Bool); + public static readonly Cue Up = new Cue("Up", 138, eCueType.Bool); + public static readonly Cue Down = new Cue("Down", 139, eCueType.Bool); + public static readonly Cue Left = new Cue("Left", 140, eCueType.Bool); + public static readonly Cue Right = new Cue("Right", 141, eCueType.Bool); + public static readonly Cue Select = new Cue("Select", 142, eCueType.Bool); + public static readonly Cue SmartApps = new Cue("SmartApps", 143, eCueType.Bool); + public static readonly Cue Dvr = new Cue("Dvr", 144, eCueType.Bool); + + public static readonly Cue Play = new Cue("Play", 145, eCueType.Bool); + public static readonly Cue Pause = new Cue("Pause", 146, eCueType.Bool); + public static readonly Cue Stop = new Cue("Stop", 147, eCueType.Bool); + public static readonly Cue ChapNext = new Cue("ChapNext", 148, eCueType.Bool); + public static readonly Cue ChapPrevious = new Cue("ChapPrevious", 149, eCueType.Bool); + public static readonly Cue Rewind = new Cue("Rewind", 150, eCueType.Bool); + public static readonly Cue Ffwd = new Cue("Ffwd", 151, eCueType.Bool); + public static readonly Cue Replay = new Cue("Replay", 152, eCueType.Bool); + public static readonly Cue Advance = new Cue("Advance", 153, eCueType.Bool); + public static readonly Cue Record = new Cue("Record", 154, eCueType.Bool); + public static readonly Cue Red = new Cue("Red", 155, eCueType.Bool); + public static readonly Cue Green = new Cue("Green", 156, eCueType.Bool); + public static readonly Cue Yellow = new Cue("Yellow", 157, eCueType.Bool); + public static readonly Cue Blue = new Cue("Blue", 158, eCueType.Bool); + public static readonly Cue Home = new Cue("Home", 159, eCueType.Bool); + public static readonly Cue PopUp = new Cue("PopUp", 160, eCueType.Bool); + public static readonly Cue PageUp = new Cue("PageUp", 161, eCueType.Bool); + public static readonly Cue PageDown = new Cue("PageDown", 162, eCueType.Bool); + public static readonly Cue Search = new Cue("Search", 163, eCueType.Bool); + public static readonly Cue Setup = new Cue("Setup", 164, eCueType.Bool); + public static readonly Cue RStep = new Cue("RStep", 165, eCueType.Bool); + public static readonly Cue FStep = new Cue("FStep", 166, eCueType.Bool); + public static readonly Cue IsConnected = new Cue("IsConnected", 281, eCueType.Bool); - public static readonly Cue IsOk = new Cue("IsOk", 282, eCueType.Bool); - public static readonly Cue InWarning = new Cue("InWarning", 283, eCueType.Bool); - public static readonly Cue InError = new Cue("InError", 284, eCueType.Bool); + public static readonly Cue IsOk = new Cue("IsOk", 282, eCueType.Bool); + public static readonly Cue InWarning = new Cue("InWarning", 283, eCueType.Bool); + public static readonly Cue InError = new Cue("InError", 284, eCueType.Bool); public static readonly Cue StatusUnknown = new Cue("StatusUnknown", 285, eCueType.Bool); - - public static readonly Cue VolumeUp = new Cue("VolumeUp", 401, eCueType.Bool); - public static readonly Cue VolumeDown = new Cue("VolumeDown", 402, eCueType.Bool); - public static readonly Cue MuteOn = new Cue("MuteOn", 403, eCueType.Bool); - public static readonly Cue MuteOff = new Cue("MuteOff", 404, eCueType.Bool); - public static readonly Cue MuteToggle = new Cue("MuteToggle", 405, eCueType.Bool); - public static readonly Cue ShowVolumeButtons = new Cue("ShowVolumeButtons", 406, eCueType.Bool); - public static readonly Cue ShowVolumeSlider = new Cue("ShowVolumeSlider", 407, eCueType.Bool); - - public static readonly Cue Hdmi1 = new Cue("Hdmi1", 451, eCueType.Bool); - public static readonly Cue Hdmi2 = new Cue("Hdmi2", 452, eCueType.Bool); - public static readonly Cue Hdmi3 = new Cue("Hdmi3", 453, eCueType.Bool); - public static readonly Cue Hdmi4 = new Cue("Hdmi4", 454, eCueType.Bool); - public static readonly Cue Hdmi5 = new Cue("Hdmi5", 455, eCueType.Bool); - public static readonly Cue Hdmi6 = new Cue("Hdmi6", 456, eCueType.Bool); - public static readonly Cue DisplayPort1 = new Cue("DisplayPort1", 457, eCueType.Bool); - public static readonly Cue DisplayPort2 = new Cue("DisplayPort2", 458, eCueType.Bool); - public static readonly Cue Dvi1 = new Cue("Dvi1", 459, eCueType.Bool); - public static readonly Cue Dvi2 = new Cue("Dvi2", 460, eCueType.Bool); - public static readonly Cue Video1 = new Cue("Video1", 461, eCueType.Bool); - public static readonly Cue Video2 = new Cue("Video2", 462, eCueType.Bool); - public static readonly Cue Component1 = new Cue("Component1", 463, eCueType.Bool); - public static readonly Cue Component2 = new Cue("Component2", 464, eCueType.Bool); - public static readonly Cue Vga1 = new Cue("Vga1", 465, eCueType.Bool); - public static readonly Cue Vga2 = new Cue("Vga2", 466, eCueType.Bool); - public static readonly Cue Rgb1 = new Cue("Rgb1", 467, eCueType.Bool); - public static readonly Cue Rgb2 = new Cue("Rgb2", 468, eCueType.Bool); + + public static readonly Cue VolumeUp = new Cue("VolumeUp", 401, eCueType.Bool); + public static readonly Cue VolumeDown = new Cue("VolumeDown", 402, eCueType.Bool); + public static readonly Cue MuteOn = new Cue("MuteOn", 403, eCueType.Bool); + public static readonly Cue MuteOff = new Cue("MuteOff", 404, eCueType.Bool); + public static readonly Cue MuteToggle = new Cue("MuteToggle", 405, eCueType.Bool); + public static readonly Cue ShowVolumeButtons = new Cue("ShowVolumeButtons", 406, eCueType.Bool); + public static readonly Cue ShowVolumeSlider = new Cue("ShowVolumeSlider", 407, eCueType.Bool); + + public static readonly Cue Hdmi1 = new Cue("Hdmi1", 451, eCueType.Bool); + public static readonly Cue Hdmi2 = new Cue("Hdmi2", 452, eCueType.Bool); + public static readonly Cue Hdmi3 = new Cue("Hdmi3", 453, eCueType.Bool); + public static readonly Cue Hdmi4 = new Cue("Hdmi4", 454, eCueType.Bool); + public static readonly Cue Hdmi5 = new Cue("Hdmi5", 455, eCueType.Bool); + public static readonly Cue Hdmi6 = new Cue("Hdmi6", 456, eCueType.Bool); + public static readonly Cue DisplayPort1 = new Cue("DisplayPort1", 457, eCueType.Bool); + public static readonly Cue DisplayPort2 = new Cue("DisplayPort2", 458, eCueType.Bool); + public static readonly Cue Dvi1 = new Cue("Dvi1", 459, eCueType.Bool); + public static readonly Cue Dvi2 = new Cue("Dvi2", 460, eCueType.Bool); + public static readonly Cue Video1 = new Cue("Video1", 461, eCueType.Bool); + public static readonly Cue Video2 = new Cue("Video2", 462, eCueType.Bool); + public static readonly Cue Component1 = new Cue("Component1", 463, eCueType.Bool); + public static readonly Cue Component2 = new Cue("Component2", 464, eCueType.Bool); + public static readonly Cue Vga1 = new Cue("Vga1", 465, eCueType.Bool); + public static readonly Cue Vga2 = new Cue("Vga2", 466, eCueType.Bool); + public static readonly Cue Rgb1 = new Cue("Rgb1", 467, eCueType.Bool); + public static readonly Cue Rgb2 = new Cue("Rgb2", 468, eCueType.Bool); public static readonly Cue Antenna = new Cue("Antenna", 469, eCueType.Bool); public static readonly Cue InCall = new Cue("InCall", 501, eCueType.Bool); - } - - public static class CommonIntCue - { - public static readonly Cue MainVolumeLevel = new Cue("MainVolumeLevel", 401, eCueType.Int); - public static readonly Cue MainVolumeLevelFeedback = new Cue("MainVolumeLevelFeedback", 401, eCueType.Int); - } - - public static class CommonStringCue - { - public static readonly Cue IpConnectionsText = new Cue("IpConnectionsText", 9999, eCueType.String); - } + } + + public static class CommonIntCue + { + public static readonly Cue MainVolumeLevel = new Cue("MainVolumeLevel", 401, eCueType.Int); + public static readonly Cue MainVolumeLevelFeedback = new Cue("MainVolumeLevelFeedback", 401, eCueType.Int); + } + + public static class CommonStringCue + { + public static readonly Cue IpConnectionsText = new Cue("IpConnectionsText", 9999, eCueType.String); + } } \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/Devices/IHasDialer.cs b/Essentials Core/PepperDashEssentialsBase/Devices/IHasDialer.cs index ecb0863c..f9e03548 100644 --- a/Essentials Core/PepperDashEssentialsBase/Devices/IHasDialer.cs +++ b/Essentials Core/PepperDashEssentialsBase/Devices/IHasDialer.cs @@ -15,8 +15,11 @@ namespace PepperDash.Essentials.Core void Dial(); void EndCall(); + void AcceptCall(); + void RejectCall(); BoolFeedback InCallFeedback { get; } + BoolFeedback IncomingCallFeedback { get; } } } \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs b/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs index 42ebc248..9990b2ed 100644 --- a/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs +++ b/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs @@ -1,71 +1,71 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Core -{ - /// - /// Defines minimal volume control methods - /// - public interface IBasicVolumeControls - { - void VolumeUp(bool pressRelease); - void VolumeDown(bool pressRelease); - void MuteToggle(); - } - - /// - /// Adds feedback and direct volume level set to IBasicVolumeControls - /// - public interface IBasicVolumeWithFeedback : IBasicVolumeControls - { - void SetVolume(ushort level); - void MuteOn(); - void MuteOff(); - IntFeedback VolumeLevelFeedback { get; } - BoolFeedback MuteFeedback { get; } - } - - - /// - /// - /// - public interface IFullAudioSettings : IBasicVolumeWithFeedback - { - void SetBalance(ushort level); - void BalanceLeft(bool pressRelease); - void BalanceRight(bool pressRelease); - - void SetBass(ushort level); - void BassUp(bool pressRelease); - void BassDown(bool pressRelease); - - void SetTreble(ushort level); - void TrebleUp(bool pressRelease); - void TrebleDown(bool pressRelease); - - bool hasMaxVolume { get; } - void SetMaxVolume(ushort level); - void MaxVolumeUp(bool pressRelease); - void MaxVolumeDown(bool pressRelease); - - bool hasDefaultVolume { get; } - void SetDefaultVolume(ushort level); - void DefaultVolumeUp(bool pressRelease); - void DefaultVolumeDown(bool pressRelease); - - void LoudnessToggle(); - void MonoToggle(); - - BoolFeedback LoudnessFeedback { get; } - BoolFeedback MonoFeedback { get; } - IntFeedback BalanceFeedback { get; } - IntFeedback BassFeedback { get; } - IntFeedback TrebleFeedback { get; } - IntFeedback MaxVolumeFeedback { get; } - IntFeedback DefaultVolumeFeedback { get; } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines minimal volume control methods + /// + public interface IBasicVolumeControls + { + void VolumeUp(bool pressRelease); + void VolumeDown(bool pressRelease); + void MuteToggle(); + } + + /// + /// Adds feedback and direct volume level set to IBasicVolumeControls + /// + public interface IBasicVolumeWithFeedback : IBasicVolumeControls + { + void SetVolume(ushort level); + void MuteOn(); + void MuteOff(); + IntFeedback VolumeLevelFeedback { get; } + BoolFeedback MuteFeedback { get; } + } + + + /// + /// + /// + public interface IFullAudioSettings : IBasicVolumeWithFeedback + { + void SetBalance(ushort level); + void BalanceLeft(bool pressRelease); + void BalanceRight(bool pressRelease); + + void SetBass(ushort level); + void BassUp(bool pressRelease); + void BassDown(bool pressRelease); + + void SetTreble(ushort level); + void TrebleUp(bool pressRelease); + void TrebleDown(bool pressRelease); + + bool hasMaxVolume { get; } + void SetMaxVolume(ushort level); + void MaxVolumeUp(bool pressRelease); + void MaxVolumeDown(bool pressRelease); + + bool hasDefaultVolume { get; } + void SetDefaultVolume(ushort level); + void DefaultVolumeUp(bool pressRelease); + void DefaultVolumeDown(bool pressRelease); + + void LoudnessToggle(); + void MonoToggle(); + + BoolFeedback LoudnessFeedback { get; } + BoolFeedback MonoFeedback { get; } + IntFeedback BalanceFeedback { get; } + IntFeedback BassFeedback { get; } + IntFeedback TrebleFeedback { get; } + IntFeedback MaxVolumeFeedback { get; } + IntFeedback DefaultVolumeFeedback { get; } } /// @@ -95,33 +95,33 @@ namespace PepperDash.Essentials.Core void PrivacyModeOff(); void PrivacyModeToggle(); BoolFeedback PrivacyModeIsOnFeedback { get; } - } - - - - /// - /// A class that implements this, contains a reference to an IBasicVolumeControls device. - /// For example, speakers attached to an audio zone. The speakers can provide reference - /// to their linked volume control. - /// - public interface IHasVolumeDevice - { - IBasicVolumeControls VolumeDevice { get; } - } - - /// - /// Identifies a device that contains audio zones - /// - public interface IAudioZones : IRouting - { - Dictionary Zone { get; } - } - - /// - /// Defines minimum functionality for an audio zone - /// - public interface IAudioZone : IBasicVolumeWithFeedback - { - void SelectInput(ushort input); - } + } + + + + /// + /// A class that implements this, contains a reference to an IBasicVolumeControls device. + /// For example, speakers attached to an audio zone. The speakers can provide reference + /// to their linked volume control. + /// + public interface IHasVolumeDevice + { + IBasicVolumeControls VolumeDevice { get; } + } + + /// + /// Identifies a device that contains audio zones + /// + public interface IAudioZones : IRouting + { + Dictionary Zone { get; } + } + + /// + /// Defines minimum functionality for an audio zone + /// + public interface IAudioZone : IBasicVolumeWithFeedback + { + void SelectInput(ushort input); + } } \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/VC/Cisco/CiscoCodec.cs b/Essentials Devices Common/Essentials Devices Common/VC/Cisco/CiscoCodec.cs index 982865cd..8c0b59b0 100644 --- a/Essentials Devices Common/Essentials Devices Common/VC/Cisco/CiscoCodec.cs +++ b/Essentials Devices Common/Essentials Devices Common/VC/Cisco/CiscoCodec.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; -using Crestron.SimplSharp.Net.Https; +using Crestron.SimplSharp.Net.Http; +using Crestron.SimplSharp.CrestronXml; +using Crestron.SimplSharp.CrestronXml.Serialization; using Newtonsoft.Json; using Cisco_One_Button_To_Push; using Cisco_SX80_Corporate_Phone_Book; @@ -13,6 +15,8 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Devices.VideoCodec.Cisco { + enum eCommandType { SessionStart, SessionEnd, Command, GetStatus, GetConfiguration }; + public class CiscoCodec : VideoCodecBase { public IBasicCommunication Communication { get; private set; } @@ -23,49 +27,254 @@ namespace PepperDash.Essentials.Devices.VideoCodec.Cisco private Corporate_Phone_Book PhoneBook; - private HttpsClient Client; + private CiscoCodecConfiguration.Configuration CodecConfiguration; + + private CiscoCodecStatus.Status CodecStatus; + + private HttpClient Client; private HttpApiServer Server; + private int ServerPort; + + private string CodecUrl; + + private string HttpSessionId; + + private string FeedbackRegistrationExpression; + // Constructor for IBasicCommunication - public CiscoCodec(string key, string name, IBasicCommunication comm) + public CiscoCodec(string key, string name, IBasicCommunication comm, int serverPort) : base(key, name) { Communication = comm; Communication.TextReceived += new EventHandler(Communication_TextReceived); + ServerPort = serverPort; + CodecObtp = new CiscoOneButtonToPush(); PhoneBook = new Corporate_Phone_Book(); - Client = new HttpsClient(); + CodecConfiguration = new CiscoCodecConfiguration.Configuration(); + + CodecStatus = new CiscoCodecStatus.Status(); + + Client = new HttpClient(); Server = new HttpApiServer(); } + + /// + /// Starts the HTTP feedback server and syncronizes state of codec + /// + /// public override bool CustomActivate() { Debug.Console(1, this, "Starting Cisco API Server"); - Server.Start(8080); + Server.Start(ServerPort); Server.ApiRequest += new EventHandler(Server_ApiRequest); + CodecUrl = string.Format("http://{0}", (Communication as GenericSshClient).Hostname); + CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 2000, 120000, 300000, "xStatus SystemUnit Software Version\r"); DeviceManager.AddDevice(CommunicationMonitor); - CodecObtp.Initialize(); + Client = new HttpClient(); - CodecObtp.GetMeetings(); + Client.Verbose = true; + Client.KeepAlive = true; + + + // Temp feedback registration + + FeedbackRegistrationExpression = + "1" + + string.Format("http://{0}:{1}/cisco/api", CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0), ServerPort) + + "JSON" + + "/Configuration" + + "/Event/CallDisconnect" + + "/Status/Call" + + "" + + "" + + ""; + + StartHttpsSession(); + + //CodecObtp.Initialize(); + + //CodecObtp.GetMeetings(); + + PhoneBook.DownloadPhoneBook(Corporate_Phone_Book.ePhoneBookLocation.Corporate); return base.CustomActivate(); } + private void StartHttpsSession() + { + SendHttpCommand("", eCommandType.SessionStart); + } + + private void EndHttpsSession() + { + SendHttpCommand("", eCommandType.SessionEnd); + } + + private void SendHttpCommand(string command, eCommandType commandType) + { + HttpClientRequest request = new HttpClientRequest(); + + string urlSuffix = null; + + Client.UserName = null; + Client.Password = null; + + request.RequestType = RequestType.Post; + + if(!string.IsNullOrEmpty(HttpSessionId)) + request.Header.SetHeaderValue("Cookie", HttpSessionId); + + switch (commandType) + { + case eCommandType.Command: + { + urlSuffix = "/putxml"; + request.ContentString = command; + request.Header.SetHeaderValue("Content-Type", "text/xml"); + break; + } + case eCommandType.SessionStart: + { + + urlSuffix = "/xmlapi/session/begin"; + + Client.UserName = (Communication as GenericSshClient).Username; + Client.Password = (Communication as GenericSshClient).Password; + + break; + } + case eCommandType.SessionEnd: + { + urlSuffix = "/xmlapi/session/end"; + request.Header.SetHeaderValue("Cookie", HttpSessionId); + break; + } + case eCommandType.GetStatus: + { + request.RequestType = RequestType.Get; + urlSuffix = "/status.xml"; + break; + } + case eCommandType.GetConfiguration: + { + request.RequestType = RequestType.Get; + urlSuffix = "/configuration.xml"; + break; + } + } + + var requestUrl = CodecUrl + urlSuffix; + request.Header.RequestVersion = "HTTP/1.1"; + request.Url.Parse(requestUrl); + + Debug.Console(1, this, "Sending HTTP request to Cisco Codec at {0}\nHeader:\n{1}\nContent:\n{2}", requestUrl, request.Header, request.ContentString); + + Client.DispatchAsync(request, PostConnectionCallback); + } + + void PostConnectionCallback(HttpClientResponse resp, HTTP_CALLBACK_ERROR err) + { + try + { + if (resp != null) + { + if (resp.Code == 200) + { + Debug.Console(1, this, "Http Post to Cisco Codec Successful. Code: {0}\nContent: {1}", resp.Code, resp.ContentString); + + if (resp.ContentString.IndexOf("") > 1) + { + // Get the initial configruation for sync purposes + SendHttpCommand("", eCommandType.GetConfiguration); + + // Get the initial status for sync purposes + SendHttpCommand("", eCommandType.GetStatus); + } + else + { + try + { + if (resp.ContentString.IndexOf("") > -1) + { + CodecConfiguration = CrestronXMLSerialization.DeSerializeObject(resp.ContentString); + + Debug.Console(1, this, "Product Name: {0} Software Version: {1} ApiVersion: {2}", CodecConfiguration.Product, CodecConfiguration.Version, CodecConfiguration.ApiVersion); + } + else if (resp.ContentString.IndexOf("") > -1) + { + CodecStatus = CrestronXMLSerialization.DeSerializeObject(resp.ContentString); + + Debug.Console(1, this, "Product Name: {0} Software Version: {1} ApiVersion: {2} Volume: {3}", CodecStatus.Product, CodecStatus.Version, CodecStatus.ApiVersion, CodecStatus.Audio.Volume); + } + } + catch (Exception ex) + { + Debug.Console(1, this, "Error Deserializing feedback from codec: {0}", ex); + } + } + } + else if (resp.Code == 204) + { + Debug.Console(1, this, "Response Code: {0}\nHeader:\n{1}Content:\n{1}", resp.Code, resp.Header, resp.ContentString); + + HttpSessionId = resp.Header.GetHeaderValue("Set-Cookie"); + //var chunks = HttpSessionId.Split(';'); + //HttpSessionId = chunks[0]; + //HttpSessionId = HttpSessionId.Substring(HttpSessionId.IndexOf("=") + 1); + + + // Register for feedbacks once we have a valid session + SendHttpCommand(FeedbackRegistrationExpression, eCommandType.Command); + } + else + { + Debug.Console(1, this, "Response Code: {0}\nHeader:\n{1}Content:\n{1}Err:\n{2}", resp.Code, resp.Header, resp.ContentString, err); + } + } + else + Debug.Console(1, this, "Null response received from server"); + } + catch (Exception e) + { + Debug.Console(1, this, "Error Initializing HTTPS Client: {0}", e); + } + } + void Server_ApiRequest(object sender, Crestron.SimplSharp.Net.Http.OnHttpRequestArgs e) { Debug.Console(1, this, "Api Reqeust from Codec: {0}", e.Request.ContentString); e.Response.Code = 200; - e.Response.ContentString = "HelloWorld"; + e.Response.ContentString = "OK"; + + try + { + // Serializer settings. We want to ignore null values and mising members + JsonSerializerSettings settings = new JsonSerializerSettings(); + settings.NullValueHandling = NullValueHandling.Ignore; + settings.MissingMemberHandling = MissingMemberHandling.Ignore; + + if (e.Request.ContentString.IndexOf("\"Configuration\":{") > -1) + CodecConfiguration = JsonConvert.DeserializeObject(e.Request.ContentString, settings); + else if (e.Request.ContentString.IndexOf("\"Status\":{") > -1) + CodecStatus = JsonConvert.DeserializeObject(e.Request.ContentString, settings); + } + catch (Exception ex) + { + Debug.Console(1, this, "Error Deserializing feedback from codec: {0}", ex); + } } void Communication_TextReceived(object sender, GenericCommMethodReceiveTextArgs e) @@ -80,6 +289,8 @@ namespace PepperDash.Essentials.Devices.VideoCodec.Cisco protected override Func InCallFeedbackFunc { get { return () => false; } } + protected override Func IncomingCallFeedbackFunc { get { return () => false; } } + protected override Func TransmitMuteFeedbackFunc { get { return () => false; } } protected override Func ReceiveMuteFeedbackFunc { get { return () => false; } } @@ -96,6 +307,16 @@ namespace PepperDash.Essentials.Devices.VideoCodec.Cisco } + public override void AcceptCall() + { + + } + + public override void RejectCall() + { + + } + public override void ReceiveMuteOff() { diff --git a/Essentials Devices Common/Essentials Devices Common/VC/Cisco/HttpApiServer.cs b/Essentials Devices Common/Essentials Devices Common/VC/Cisco/HttpApiServer.cs index 7af43195..4f5f3fd5 100644 --- a/Essentials Devices Common/Essentials Devices Common/VC/Cisco/HttpApiServer.cs +++ b/Essentials Devices Common/Essentials Devices Common/VC/Cisco/HttpApiServer.cs @@ -61,7 +61,7 @@ namespace PepperDash.Essentials.Devices.VideoCodec.Cisco if (a == eProgramStatusEventType.Stopping) { HttpServer.Close(); - Debug.Console(1, "Shutting down HTTP, port {0}", HttpServer.Port); + Debug.Console(1, "Shutting down HTTP Server on port {0}", HttpServer.Port); } }; } @@ -78,7 +78,7 @@ namespace PepperDash.Essentials.Devices.VideoCodec.Cisco string path = Uri.UnescapeDataString(args.Request.Path); var host = args.Request.DataConnection.RemoteEndPointAddress; - string authToken; + //string authToken; Debug.Console(2, "HTTP Request: {2}: Path='{0}' ?'{1}'", path, args.Request.QueryString, host); @@ -89,27 +89,6 @@ namespace PepperDash.Essentials.Devices.VideoCodec.Cisco if (ApiRequest != null) ApiRequest(this, args); } - // Basic file handling - else - { - // Default path - //if (path.EndsWith("/")) path = path + "index.html"; - //if (string.IsNullOrEmpty(Path.GetExtension(path))) path = path + "/index.html"; - - //string filePath = path.Replace('/', '\\'); - //string localPath = string.Format(@"{0}{1}", HtmlRoot, filePath); - //if (File.Exists(localPath)) - //{ - // args.Response.Header.ContentType = GetContentType(new FileInfo(localPath).Extension); - // args.Response.ContentStream = new FileStream(localPath, FileMode.Open, FileAccess.Read); - // //args.Response.CloseStream = true; - //} - //else - //{ - // args.Response.ContentString = string.Format("Not found: '{0}'", filePath); - // args.Response.Code = 404; - //} - } } public static string GetContentType(string extension) diff --git a/Essentials Devices Common/Essentials Devices Common/VC/VideoCodecBase.cs b/Essentials Devices Common/Essentials Devices Common/VC/VideoCodecBase.cs index 6bd4c548..c0eddc21 100644 --- a/Essentials Devices Common/Essentials Devices Common/VC/VideoCodecBase.cs +++ b/Essentials Devices Common/Essentials Devices Common/VC/VideoCodecBase.cs @@ -24,8 +24,10 @@ namespace PepperDash.Essentials.Devices.VideoCodec #endregion public BoolFeedback InCallFeedback { get; protected set; } + public BoolFeedback IncomingCallFeedback { get; protected set; } abstract protected Func InCallFeedbackFunc { get; } + abstract protected Func IncomingCallFeedbackFunc { get; } abstract protected Func TransmitMuteFeedbackFunc { get; } abstract protected Func ReceiveMuteFeedbackFunc { get; } abstract protected Func PrivacyModeFeedbackFunc { get; } @@ -34,6 +36,7 @@ namespace PepperDash.Essentials.Devices.VideoCodec : base(key, name) { InCallFeedback = new BoolFeedback(InCallFeedbackFunc); + IncomingCallFeedback = new BoolFeedback(IncomingCallFeedbackFunc); ReceiveMuteIsOnFeedback = new BoolFeedback(ReceiveMuteFeedbackFunc); TransmitMuteIsOnFeedback = new BoolFeedback(TransmitMuteFeedbackFunc); PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeFeedbackFunc); @@ -56,6 +59,8 @@ namespace PepperDash.Essentials.Devices.VideoCodec public abstract void Dial(); public abstract void EndCall(); + public abstract void AcceptCall(); + public abstract void RejectCall(); public virtual List Feedbacks { @@ -64,6 +69,7 @@ namespace PepperDash.Essentials.Devices.VideoCodec return new List { InCallFeedback, + IncomingCallFeedback, ReceiveMuteIsOnFeedback, TransmitMuteIsOnFeedback, PrivacyModeIsOnFeedback diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 7255b0df..a3550de1 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -59,10 +59,10 @@ namespace PepperDash.Essentials // CODEC TESTING - GenericSshClient TestCodecClient = new GenericSshClient("TestCodec-1--SshClient", "10.11.50.135", 22, "admin", ""); + GenericSshClient TestCodecClient = new GenericSshClient("TestCodec-1--SshClient", "10.11.50.135", 22, "crestron", "e##3nti@ls"); PepperDash.Essentials.Devices.VideoCodec.Cisco.CiscoCodec TestCodec = - new PepperDash.Essentials.Devices.VideoCodec.Cisco.CiscoCodec("TestCodec-1", "Cisco Spark Room Kit", TestCodecClient); + new PepperDash.Essentials.Devices.VideoCodec.Cisco.CiscoCodec("TestCodec-1", "Cisco Spark Room Kit", TestCodecClient, 8080); TestCodec.CustomActivate();