Updates to call status tracking and Call History. Added CiscoCodecPropertiesConfig class

This commit is contained in:
Neil Dorin
2017-09-21 18:00:43 -06:00
parent 3b3ea98dea
commit 1d46f8520d
12 changed files with 1191 additions and 1194 deletions

View File

@@ -1,38 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public class CodecActiveCallItem
{
public string Name { get; set; }
public string Number { get; set; }
public eCodecCallType Type { get; set; }
public eCodecCallStatus Status { get; set; }
public string Id { get; set; }
public object CallMetaData { get; set; }
/// <summary>
/// Returns true when this call is any status other than
/// Unknown, Disconnected, Disconnecting
/// </summary>
public bool IsActiveCall
{
get
{
return !(Status == eCodecCallStatus.Disconnected
|| Status == eCodecCallStatus.Disconnecting
|| Status == eCodecCallStatus.Unknown);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public class CodecActiveCallItem
{
public string Name { get; set; }
public string Number { get; set; }
public eCodecCallType Type { get; set; }
public eCodecCallStatus Status { get; set; }
public eCodecCallDirection Direction { get; set; }
public string Id { get; set; }
//public object CallMetaData { get; set; }
/// <summary>
/// Returns true when this call is any status other than
/// Unknown, Disconnected, Disconnecting
/// </summary>
public bool IsActiveCall
{
get
{
return !(Status == eCodecCallStatus.Disconnected
|| Status == eCodecCallStatus.Disconnecting
|| Status == eCodecCallStatus.Unknown);
}
}
}
}

View File

@@ -1,25 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eCodecCallStatus
{
Unknown = 0,
Connected,
Connecting,
Dialing,
Disconnected,
Disconnecting,
EarlyMedia,
Idle,
Incoming,
OnHold,
Ringing,
Preserved,
RemotePreserved,
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eCodecCallStatus
{
Unknown = 0,
Connected,
Connecting,
Dialing,
Disconnected,
Disconnecting,
EarlyMedia,
Idle,
Incoming,
OnHold,
Ringing,
Preserved,
RemotePreserved,
}
public class CodecCallStatus
{
/// <summary>
/// Takes the Cisco call type and converts to the matching enum
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static eCodecCallStatus ConvertToStatusEnum(string s)
{
switch (s)
{
case "Connected":
{
return eCodecCallStatus.Connected;
}
case "Connecting":
{
return eCodecCallStatus.Connecting;
}
case "Dialling":
{
return eCodecCallStatus.Dialing;
}
case "Disconnected":
{
return eCodecCallStatus.Disconnected;
}
case "Disconnecting":
{
return eCodecCallStatus.Disconnecting;
}
case "EarlyMedia":
{
return eCodecCallStatus.EarlyMedia;
}
case "Idle":
{
return eCodecCallStatus.Idle;
}
case "Incoming":
{
return eCodecCallStatus.Incoming;
}
case "OnHold":
{
return eCodecCallStatus.OnHold;
}
case "Ringing":
{
return eCodecCallStatus.Ringing;
}
case "Preserved":
{
return eCodecCallStatus.Preserved;
}
case "RemotePreserved":
{
return eCodecCallStatus.RemotePreserved;
}
default:
return eCodecCallStatus.Unknown;
}
}
}
}

View File

@@ -1,22 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eCodecCallType
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eCodecCallType
{
Unknown = 0,
Audio,
Video,
AudioCanEscalate,
ForwardAllCall
}
public class CodecCallType
}
public class CodecCallType
{
/// <summary>
@@ -48,7 +48,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec
return eCodecCallType.Unknown;
}
}
}
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public interface iHasCallFavorites
{
CodecCallFavorites CallFavorites { get; }
}
/// <summary>
/// Represents favorites entries for a codec device
/// </summary>
public class CodecCallFavorites
{
public List<CodecActiveCallItem> Favorites { get; set; }
public CodecCallFavorites()
{
Favorites = new List<CodecActiveCallItem>();
}
}
}

View File

@@ -4,15 +4,15 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public interface IHasCallHistory
{
event EventHandler<EventArgs> RecentCallsListHasChanged;
CodecCallHistory CallHistory { get; }
List<CallHistory.CallHistoryEntry> RecentCalls { get; }
void RemoveEntry(CallHistory.CallHistoryEntry entry);
void RemoveCallHistoryEntry(CodecCallHistory.CallHistoryEntry entry);
}
public enum eCodecOccurrenctType
@@ -23,8 +23,54 @@ namespace PepperDash.Essentials.Devices.Common.Codec
NoAnswer
}
public class CallHistory
/// <summary>
/// Represents the recent call history for a codec device
/// </summary>
public class CodecCallHistory
{
event EventHandler<EventArgs> RecentCallsListHasChanged;
public List<CallHistoryEntry> RecentCalls { get; private set; }
/// <summary>
/// Item that gets added to the list when there are no recent calls in history
/// </summary>
CallHistoryEntry ListEmptyEntry;
public CodecCallHistory()
{
ListEmptyEntry = new CallHistoryEntry() { Name = "No Recent Calls" };
RecentCalls = new List<CallHistoryEntry>();
RecentCalls.Add(ListEmptyEntry);
}
void OnRecentCallsListChange()
{
var handler = RecentCallsListHasChanged;
if (handler != null)
{
handler(this, new EventArgs());
if (Debug.Level == 1)
{
Debug.Console(1, "RecentCalls:\n");
foreach (CodecCallHistory.CallHistoryEntry entry in RecentCalls)
{
Debug.Console(1, "\nName: {0}\nNumber: {1}\nStartTime: {2}\nType: {3}\n", entry.Name, entry.Number, entry.StartTime.ToString(), entry.OccurenceType);
}
}
}
}
public void RemoveEntry(CallHistoryEntry entry)
{
RecentCalls.Remove(entry);
OnRecentCallsListChange();
}
/// <summary>
/// Generic call history entry, not device specific
@@ -41,7 +87,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec
/// </summary>
/// <param name="entries"></param>
/// <returns></returns>
public static List<CallHistoryEntry> ConvertCiscoCallHistoryToGeneric(List<CiscoCallHistory.Entry> entries)
public void ConvertCiscoCallHistoryToGeneric(List<CiscoCallHistory.Entry> entries)
{
var genericEntries = new List<CallHistoryEntry>();
@@ -57,15 +103,19 @@ namespace PepperDash.Essentials.Devices.Common.Codec
});
}
return genericEntries;
// Check if list is empty and if so, add an item to display No Recent Calls
if(genericEntries.Count == 0)
genericEntries.Add(ListEmptyEntry);
RecentCalls = genericEntries;
OnRecentCallsListChange();
}
/// <summary>
/// Takes the Cisco occurence type and converts it to the matching enum
/// </summary>
/// <param name="s"></para
public static eCodecOccurrenctType ConvertToOccurenceTypeEnum(string s)
public eCodecOccurrenctType ConvertToOccurenceTypeEnum(string s)
{
switch (s)
{
@@ -89,9 +139,6 @@ namespace PepperDash.Essentials.Devices.Common.Codec
}
public class CiscoCallHistory
{

View File

@@ -1,28 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
/// <summary>
/// Requirements for a device that has dialing capabilities
/// </summary>
public interface IHasDialer
{
// Add requirements for Dialer functionality
void Dial(string number);
void EndCall(CodecActiveCallItem activeCall);
void EndAllCalls();
void AcceptCall(CodecActiveCallItem item);
void RejectCall(CodecActiveCallItem item);
void SendDtmf(string digit);
BoolFeedback IncomingCallFeedback { get; }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
/// <summary>
/// Requirements for a device that has dialing capabilities
/// </summary>
public interface IHasDialer
{
// Add requirements for Dialer functionality
void Dial(string number);
void EndCall(CodecActiveCallItem activeCall);
void EndAllCalls();
void AcceptCall(CodecActiveCallItem item);
void RejectCall(CodecActiveCallItem item);
void SendDtmf(string digit);
BoolFeedback IncomingCallFeedback { get; }
}
@@ -35,5 +35,5 @@ namespace PepperDash.Essentials.Devices.Common.Codec
{
// Upcoming Meeting warning event
}
}
}

View File

@@ -107,6 +107,7 @@
<Compile Include="Codec\eCodecCallType.cs" />
<Compile Include="Codec\eCodecCallStatus.cs" />
<Compile Include="Codec\iCodecAudio.cs" />
<Compile Include="Codec\iHasCallFavorites.cs" />
<Compile Include="Codec\iHasCallHistory.cs" />
<Compile Include="Codec\iHasDialer.cs" />
<Compile Include="Crestron\Gateways\CenRfgwController.cs" />
@@ -134,6 +135,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Streaming\Roku.cs" />
<Compile Include="VideoCodec\CiscoCodec\CiscoCodec.cs" />
<Compile Include="VideoCodec\CiscoCodec\CiscoCodecPropertiesConfig.cs" />
<Compile Include="VideoCodec\CiscoCodec\xConfiguration.cs" />
<Compile Include="VideoCodec\CiscoCodec\xEvent.cs" />
<Compile Include="VideoCodec\CiscoCodec\HttpApiServer.cs" />

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public class CiscoCodecPropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
//public ControlPropertiesConfig Control { get; set; }
public List<CodecActiveCallItem> Favorites { get; set; }
/// <summary>
/// Valid values: "Local" or "Corporate"
/// </summary>
public string PhonebookMode { get; set; }
}
}

View File

@@ -1682,6 +1682,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public Duration Duration { get; set; }
public Encryption Encryption { get; set; }
public FacilityServiceId FacilityServiceId { get; set; }
public string ghost { get; set; }
public HoldReason HoldReason { get; set; }
public PlacedOnHold PlacedOnHold { get; set; }
public Protocol Protocol { get; set; }

View File

@@ -1,186 +1,187 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public abstract class VideoCodecBase : Device, IRoutingSinkWithSwitching, IUsageTracking, IHasDialer, IHasSharing, ICodecAudio
{
/// <summary>
/// Fires when the status of any active, dialing, or incoming call changes or is new
/// </summary>
public event EventHandler<CodecCallStatusItemChangeEventArgs> CallStatusChange;
#region IUsageTracking Members
/// <summary>
/// This object can be added by outside users of this class to provide usage tracking
/// for various services
/// </summary>
public UsageTracking UsageTracker { get; set; }
#endregion
#region IRoutingInputs Members
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
#endregion
/// <summary>
/// Returns true when any call is not in state Unknown, Disconnecting, Disconnected
/// </summary>
public bool IsInCall { get { return ActiveCalls.Any(c => c.IsActiveCall); } }
public BoolFeedback IncomingCallFeedback { get; private set; }
//public IntFeedback ActiveCallCountFeedback { get; private set; }
//abstract protected Func<int> ActiveCallCountFeedbackFunc { get; }
abstract protected Func<bool> IncomingCallFeedbackFunc { get; }
abstract protected Func<bool> PrivacyModeIsOnFeedbackFunc { get; }
abstract protected Func<int> VolumeLevelFeedbackFunc { get; }
abstract protected Func<bool> MuteFeedbackFunc { get; }
abstract protected Func<string> SharingSourceFeedbackFunc { get; }
public List<CodecActiveCallItem> ActiveCalls { get; set; }
public VideoCodecBase(string key, string name)
: base(key, name)
{
IncomingCallFeedback = new BoolFeedback(IncomingCallFeedbackFunc);
PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeIsOnFeedbackFunc);
VolumeLevelFeedback = new IntFeedback(VolumeLevelFeedbackFunc);
MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
SharingSourceFeedback = new StringFeedback(SharingSourceFeedbackFunc);
InputPorts = new RoutingPortCollection<RoutingInputPort>();
ActiveCalls = new List<CodecActiveCallItem>();
}
#region IHasDialer Members
public abstract void Dial(string s);
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
public virtual List<Feedback> Feedbacks
{
get
{
return new List<Feedback>
{
IncomingCallFeedback,
PrivacyModeIsOnFeedback,
SharingSourceFeedback
};
}
}
public abstract void ExecuteSwitch(object selector);
/// <summary>
/// Helper method to fire CallStatusChange event with old and new status
/// </summary>
protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call)
{
var prevStatus = call.Status;
call.Status = newStatus;
OnCallStatusChange(prevStatus, newStatus, call);
}
/// <summary>
///
/// </summary>
/// <param name="previousStatus"></param>
/// <param name="newStatus"></param>
/// <param name="item"></param>
protected void OnCallStatusChange(eCodecCallStatus previousStatus, eCodecCallStatus newStatus, CodecActiveCallItem item)
{
var handler = CallStatusChange;
if (handler != null)
handler(this, new CodecCallStatusItemChangeEventArgs(previousStatus, newStatus, item));
}
#region ICodecAudio Members
public abstract void PrivacyModeOn();
public abstract void PrivacyModeOff();
public abstract void PrivacyModeToggle();
public BoolFeedback PrivacyModeIsOnFeedback { get; private set; }
public BoolFeedback MuteFeedback { get; private set; }
public abstract void MuteOff();
public abstract void MuteOn();
public abstract void SetVolume(ushort level);
public IntFeedback VolumeLevelFeedback { get; private set; }
public abstract void MuteToggle();
public abstract void VolumeDown(bool pressRelease);
public abstract void VolumeUp(bool pressRelease);
#endregion
#region IHasSharing Members
public abstract void StartSharing();
public abstract void StopSharing();
public StringFeedback SharingSourceFeedback { get; private set; }
#endregion
// **** DEBUGGING THINGS ****
/// <summary>
///
/// </summary>
public virtual void ListCalls()
{
var sb = new StringBuilder();
foreach (var c in ActiveCalls)
sb.AppendFormat("{0} {1} -- {2} {3}\r", c.Id, c.Number, c.Name, c.Status);
Debug.Console(1, "{0}", sb.ToString());
}
}
/// <summary>
///
/// </summary>
public class CodecCallStatusItemChangeEventArgs : EventArgs
{
public CodecActiveCallItem CallItem { get; private set; }
public eCodecCallStatus PreviousStatus { get; private set; }
public eCodecCallStatus NewStatus { get; private set; }
public CodecCallStatusItemChangeEventArgs(eCodecCallStatus previousStatus,
eCodecCallStatus newStatus, CodecActiveCallItem item)
{
PreviousStatus = previousStatus;
NewStatus = newStatus;
CallItem = item;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public abstract class VideoCodecBase : Device, IRoutingSinkWithSwitching, IUsageTracking, IHasDialer, IHasSharing, ICodecAudio
{
/// <summary>
/// Fires when the status of any active, dialing, or incoming call changes or is new
/// </summary>
public event EventHandler<CodecCallStatusItemChangeEventArgs> CallStatusChange;
#region IUsageTracking Members
/// <summary>
/// This object can be added by outside users of this class to provide usage tracking
/// for various services
/// </summary>
public UsageTracking UsageTracker { get; set; }
#endregion
#region IRoutingInputs Members
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
#endregion
/// <summary>
/// Returns true when any call is not in state Unknown, Disconnecting, Disconnected
/// </summary>
public bool IsInCall { get { return ActiveCalls.Any(c => c.IsActiveCall); } }
public BoolFeedback IncomingCallFeedback { get; private set; }
//public IntFeedback ActiveCallCountFeedback { get; private set; }
//abstract protected Func<int> ActiveCallCountFeedbackFunc { get; }
abstract protected Func<bool> IncomingCallFeedbackFunc { get; }
abstract protected Func<bool> PrivacyModeIsOnFeedbackFunc { get; }
abstract protected Func<int> VolumeLevelFeedbackFunc { get; }
abstract protected Func<bool> MuteFeedbackFunc { get; }
abstract protected Func<string> SharingSourceFeedbackFunc { get; }
public List<CodecActiveCallItem> ActiveCalls { get; set; }
public VideoCodecBase(string key, string name)
: base(key, name)
{
IncomingCallFeedback = new BoolFeedback(IncomingCallFeedbackFunc);
PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeIsOnFeedbackFunc);
VolumeLevelFeedback = new IntFeedback(VolumeLevelFeedbackFunc);
MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
SharingSourceFeedback = new StringFeedback(SharingSourceFeedbackFunc);
InputPorts = new RoutingPortCollection<RoutingInputPort>();
ActiveCalls = new List<CodecActiveCallItem>();
}
#region IHasDialer Members
public abstract void Dial(string s);
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
public virtual List<Feedback> Feedbacks
{
get
{
return new List<Feedback>
{
IncomingCallFeedback,
PrivacyModeIsOnFeedback,
SharingSourceFeedback
};
}
}
public abstract void ExecuteSwitch(object selector);
/// <summary>
/// Helper method to fire CallStatusChange event with old and new status
/// </summary>
protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call)
{
var prevStatus = call.Status;
call.Status = newStatus;
OnCallStatusChange(prevStatus, newStatus, call);
}
/// <summary>
///
/// </summary>
/// <param name="previousStatus"></param>
/// <param name="newStatus"></param>
/// <param name="item"></param>
protected void OnCallStatusChange(eCodecCallStatus previousStatus, eCodecCallStatus newStatus, CodecActiveCallItem item)
{
var handler = CallStatusChange;
if (handler != null)
handler(this, new CodecCallStatusItemChangeEventArgs(previousStatus, newStatus, item));
}
#region ICodecAudio Members
public abstract void PrivacyModeOn();
public abstract void PrivacyModeOff();
public abstract void PrivacyModeToggle();
public BoolFeedback PrivacyModeIsOnFeedback { get; private set; }
public BoolFeedback MuteFeedback { get; private set; }
public abstract void MuteOff();
public abstract void MuteOn();
public abstract void SetVolume(ushort level);
public IntFeedback VolumeLevelFeedback { get; private set; }
public abstract void MuteToggle();
public abstract void VolumeDown(bool pressRelease);
public abstract void VolumeUp(bool pressRelease);
#endregion
#region IHasSharing Members
public abstract void StartSharing();
public abstract void StopSharing();
public StringFeedback SharingSourceFeedback { get; private set; }
#endregion
// **** DEBUGGING THINGS ****
/// <summary>
///
/// </summary>
public virtual void ListCalls()
{
Debug.Console(1, this, "Active Calls List:\n");
var sb = new StringBuilder();
foreach (var c in ActiveCalls)
sb.AppendFormat("{0} {1} -- {2} {3}\r", c.Id, c.Number, c.Name, c.Status);
Debug.Console(1, this, "{0}", sb.ToString());
}
}
/// <summary>
///
/// </summary>
public class CodecCallStatusItemChangeEventArgs : EventArgs
{
public CodecActiveCallItem CallItem { get; private set; }
public eCodecCallStatus PreviousStatus { get; private set; }
public eCodecCallStatus NewStatus { get; private set; }
public CodecCallStatusItemChangeEventArgs(eCodecCallStatus previousStatus,
eCodecCallStatus newStatus, CodecActiveCallItem item)
{
PreviousStatus = previousStatus;
NewStatus = newStatus;
CallItem = item;
}
}
}

View File

@@ -132,8 +132,14 @@ namespace PepperDash.Essentials
{
GenericSshClient TestCodecClient = new GenericSshClient("TestCodec-1--SshClient", "10.11.50.135", 22, "crestron", "2H3Zu&OvgXp6");
var props = new PepperDash.Essentials.Devices.Common.Codec.CiscoCodecPropertiesConfig();
props.PhonebookMode = "Local";
props.Favorites = new System.Collections.Generic.List<PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem>();
props.Favorites.Add(new PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem() { Name = "NYU Cisco Webex", Number = "10.11.50.211" });
PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.CiscoCodec TestCodec =
new PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.CiscoCodec("TestCodec-1", "Cisco Spark Room Kit", TestCodecClient, 8080);
new PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.CiscoCodec("TestCodec-1", "Cisco Spark Room Kit", TestCodecClient, props);
TestCodec.CommDebuggingIsOn = true;