mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-13 11:44:54 +00:00
Merge remote-tracking branch 'origin/feature/ecs-407' into feature/cisco-spark-2
Conflicts: Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs Essentials Devices Common/Essentials Devices Common/Codec/eCodecCallStatus.cs Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs
This commit is contained in:
@@ -1,27 +1,38 @@
|
||||
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; }
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,88 +5,21 @@ using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.Codec
|
||||
|
||||
{
|
||||
public enum eCodecCallStatus
|
||||
{
|
||||
Unknown = 0,
|
||||
Idle,
|
||||
Dialing,
|
||||
Ringing,
|
||||
Connecting,
|
||||
Connected,
|
||||
Disconnecting,
|
||||
Incoming,
|
||||
OnHold,
|
||||
EarlyMedia,
|
||||
Preserved,
|
||||
RemotePreserved,
|
||||
Disconnected
|
||||
}
|
||||
|
||||
public class CodecCallStatus
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Takes the Cisco status and converts to the matching enum
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public static eCodecCallStatus ConvertToStatusEnum(string s)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case "Idle":
|
||||
{
|
||||
return eCodecCallStatus.Idle;
|
||||
}
|
||||
case "Dialling":
|
||||
{
|
||||
return eCodecCallStatus.Dialing;
|
||||
}
|
||||
case "Ringing":
|
||||
{
|
||||
return eCodecCallStatus.Ringing;
|
||||
}
|
||||
case "Connecting":
|
||||
{
|
||||
return eCodecCallStatus.Connecting;
|
||||
}
|
||||
case "Connected":
|
||||
{
|
||||
return eCodecCallStatus.Connected;
|
||||
}
|
||||
case "Disconnecting":
|
||||
{
|
||||
return eCodecCallStatus.Disconnecting;
|
||||
}
|
||||
case "Incoming":
|
||||
{
|
||||
return eCodecCallStatus.Incoming;
|
||||
}
|
||||
case "OnHold":
|
||||
{
|
||||
return eCodecCallStatus.OnHold;
|
||||
}
|
||||
case "EarlyMedia":
|
||||
{
|
||||
return eCodecCallStatus.EarlyMedia;
|
||||
}
|
||||
case "Preserved":
|
||||
{
|
||||
return eCodecCallStatus.Preserved;
|
||||
}
|
||||
case "RemotePreserved":
|
||||
{
|
||||
return eCodecCallStatus.RemotePreserved;
|
||||
}
|
||||
case "Disconnected":
|
||||
{
|
||||
return eCodecCallStatus.Disconnected;
|
||||
}
|
||||
default:
|
||||
return eCodecCallStatus.Unknown;
|
||||
}
|
||||
}
|
||||
{
|
||||
Unknown = 0,
|
||||
Connected,
|
||||
Connecting,
|
||||
Dialing,
|
||||
Disconnected,
|
||||
Disconnecting,
|
||||
EarlyMedia,
|
||||
Idle,
|
||||
Incoming,
|
||||
OnHold,
|
||||
Ringing,
|
||||
Preserved,
|
||||
RemotePreserved,
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ namespace PepperDash.Essentials.Devices.Common.Codec
|
||||
void RejectCall(CodecActiveCallItem item);
|
||||
void SendDtmf(string digit);
|
||||
|
||||
IntFeedback ActiveCallCountFeedback { get; }
|
||||
BoolFeedback IncomingCallFeedback { get; }
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
: base(key, name)
|
||||
{
|
||||
// Debug helpers
|
||||
ActiveCallCountFeedback.OutputChange += (o, a) => Debug.Console(1, this, "InCall={0}", ActiveCallCountFeedback.IntValue);
|
||||
//ActiveCallCountFeedback.OutputChange += (o, a) => Debug.Console(1, this, "InCall={0}", ActiveCallCountFeedback.IntValue);
|
||||
IncomingCallFeedback.OutputChange += (o, a) => Debug.Console(1, this, "IncomingCall={0}", _IncomingCall);
|
||||
MuteFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Mute={0}", _IsMuted);
|
||||
PrivacyModeIsOnFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Privacy={0}", _PrivacyModeIsOn);
|
||||
@@ -25,11 +25,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
VolumeLevelFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Volume={0}", _VolumeLevel);
|
||||
}
|
||||
|
||||
protected override Func<int> ActiveCallCountFeedbackFunc
|
||||
{
|
||||
get { return () => ActiveCalls.Count; }
|
||||
}
|
||||
|
||||
protected override Func<bool> IncomingCallFeedbackFunc
|
||||
{
|
||||
get { return () => _IncomingCall; }
|
||||
@@ -69,7 +64,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
var call = new CodecActiveCallItem() { Name = s, Number = s, Id = s, Status = eCodecCallStatus.Dialing };
|
||||
ActiveCalls.Add(call);
|
||||
OnCallStatusChange(eCodecCallStatus.Unknown, call.Status, call);
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
//ActiveCallCountFeedback.FireUpdate();
|
||||
// Simulate 2-second ring, then connecting, then connected
|
||||
new CTimer(o =>
|
||||
{
|
||||
@@ -86,9 +81,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
{
|
||||
Debug.Console(1, this, "EndCall");
|
||||
ActiveCalls.Remove(call);
|
||||
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
//ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,7 +96,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
ActiveCalls.Remove(call);
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
|
||||
}
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
//ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,6 +116,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
public override void RejectCall(CodecActiveCallItem call)
|
||||
{
|
||||
Debug.Console(1, this, "RejectCall");
|
||||
ActiveCalls.Remove(call);
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
|
||||
//ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,7 +256,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Incoming, call);
|
||||
_IncomingCall = true;
|
||||
IncomingCallFeedback.FireUpdate();
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -274,7 +270,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Incoming, call);
|
||||
_IncomingCall = true;
|
||||
IncomingCallFeedback.FireUpdate();
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -286,17 +281,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void ListCalls()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var c in ActiveCalls)
|
||||
sb.AppendFormat("{0} {1} -- {2}\r", c.Id, c.Number, c.Name);
|
||||
Debug.Console(1, "{0}", sb.ToString());
|
||||
}
|
||||
|
||||
#region IRoutingOutputs Members
|
||||
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts
|
||||
|
||||
@@ -35,24 +35,15 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether any call in ActiveCalls is actually "active"
|
||||
/// </summary>
|
||||
public bool IsInCall
|
||||
{
|
||||
get
|
||||
{
|
||||
return ActiveCalls.Any(c =>
|
||||
!(c.Status == eCodecCallStatus.Unknown
|
||||
|| c.Status == eCodecCallStatus.Disconnected
|
||||
|| c.Status == eCodecCallStatus.Disconnecting));
|
||||
}
|
||||
}
|
||||
/// 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; }
|
||||
//public IntFeedback ActiveCallCountFeedback { get; private set; }
|
||||
|
||||
abstract protected Func<int> ActiveCallCountFeedbackFunc { get; }
|
||||
//abstract protected Func<int> ActiveCallCountFeedbackFunc { get; }
|
||||
abstract protected Func<bool> IncomingCallFeedbackFunc { get; }
|
||||
abstract protected Func<bool> PrivacyModeIsOnFeedbackFunc { get; }
|
||||
abstract protected Func<int> VolumeLevelFeedbackFunc { get; }
|
||||
@@ -64,7 +55,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
public VideoCodecBase(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
ActiveCallCountFeedback = new IntFeedback(ActiveCallCountFeedbackFunc);
|
||||
IncomingCallFeedback = new BoolFeedback(IncomingCallFeedbackFunc);
|
||||
PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeIsOnFeedbackFunc);
|
||||
VolumeLevelFeedback = new IntFeedback(VolumeLevelFeedbackFunc);
|
||||
@@ -73,26 +63,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
|
||||
ActiveCallCountFeedback.OutputChange += new EventHandler<EventArgs>(ActiveCallCountFeedback_OutputChange);
|
||||
|
||||
ActiveCalls = new List<CodecActiveCallItem>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ActiveCallCountFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
if (UsageTracker != null)
|
||||
{
|
||||
if (IsInCall)
|
||||
UsageTracker.StartDeviceUsage();
|
||||
else
|
||||
UsageTracker.EndDeviceUsage();
|
||||
}
|
||||
}
|
||||
#region IHasDialer Members
|
||||
|
||||
public abstract void Dial(string s);
|
||||
@@ -125,19 +98,18 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
protected void SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus newStatus, CodecActiveCallItem call)
|
||||
{
|
||||
var prevStatus = call.Status;
|
||||
call.Status = newStatus;
|
||||
call.Status = newStatus;
|
||||
OnCallStatusChange(prevStatus, newStatus, call);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to notify of call status change event
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="previousStatus"></param>
|
||||
/// <param name="newStatus"></param>
|
||||
/// <param name="item"></param>
|
||||
protected void OnCallStatusChange(eCodecCallStatus previousStatus, eCodecCallStatus newStatus, CodecActiveCallItem item)
|
||||
{
|
||||
Debug.Console(1, this, "Call Status Changed from {0} to {1} on call {2}", previousStatus, newStatus, item.Id);
|
||||
{
|
||||
var handler = CallStatusChange;
|
||||
if (handler != null)
|
||||
handler(this, new CodecCallStatusItemChangeEventArgs(previousStatus, newStatus, item));
|
||||
@@ -178,6 +150,18 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user