mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
Moved some enums into separate files; modifying simulation methods on MockVC; Added Connecting state to eCodecStatus; ...
This commit is contained in:
@@ -21,14 +21,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec
|
||||
|
||||
public object CallMetaData { get; set; }
|
||||
}
|
||||
|
||||
public enum eCodecCallType
|
||||
{
|
||||
Unknown = 0, Audio, Video
|
||||
}
|
||||
|
||||
public enum eCodecCallStatus
|
||||
{
|
||||
Unknown = 0, Dialing, Connected, Incoming, OnHold, Disconnected
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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; }
|
||||
|
||||
<<<<<<< HEAD:Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs
|
||||
public eCodecCallType Type { get; set; }
|
||||
|
||||
public eCodecCallStatus Status { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
=======
|
||||
public eCodecCallType Type { get; set; }
|
||||
|
||||
public eCodecCallStatus Status { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public object CallMetaData { get; set; }
|
||||
>>>>>>> origin/feature/cisco-spark-2:Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs
|
||||
}
|
||||
|
||||
public enum eCodecCallType
|
||||
{
|
||||
Unknown = 0, Audio, Video
|
||||
<<<<<<< HEAD:Essentials Devices Common/Essentials Devices Common/Codec/CodecActiveCallItem.cs
|
||||
}
|
||||
|
||||
public enum eCodecCallStatus
|
||||
{
|
||||
Unknown = 0, Dialing, Connected, Incoming, OnHold, Disconnected
|
||||
=======
|
||||
}
|
||||
|
||||
public enum eCodecCallStatus
|
||||
{
|
||||
Unknown = 0, Dialing, Connected, Incoming, OnHold, Disconnected
|
||||
>>>>>>> origin/feature/cisco-spark-2:Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
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, Dialing, Connected, Connecting, Incoming, OnHold, Disconnected
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,8 @@
|
||||
<Reference Include="System.Data" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Codec\eCodecCallType.cs" />
|
||||
<Compile Include="Codec\eCodecCallStatus.cs" />
|
||||
<Compile Include="Codec\iCodecAudio.cs" />
|
||||
<Compile Include="Codec\iHasDialer.cs" />
|
||||
<Compile Include="Crestron\Gateways\CenRfgwController.cs" />
|
||||
|
||||
@@ -13,6 +13,7 @@ using Cisco_SX80_Corporate_Phone_Book;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using PepperDash.Essentials.Devices.Common.Codec;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
{
|
||||
@@ -28,6 +29,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
public BoolFeedback StandbyIsOnFeedback { get; private set; }
|
||||
|
||||
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
|
||||
|
||||
public BoolFeedback PeopleCountFeedback { get; private set; }
|
||||
|
||||
public BoolFeedback SpeakerTrackIsOnFeedback { get; private set; }
|
||||
|
||||
private CiscoOneButtonToPush CodecObtp;
|
||||
|
||||
private Corporate_Phone_Book PhoneBook;
|
||||
@@ -36,7 +43,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
private CiscoCodecStatus.RootObject CodecStatus;
|
||||
|
||||
<<<<<<< HEAD
|
||||
private CiscoCodecEvents.RootObject CodecEvent;
|
||||
=======
|
||||
//private CiscoCodecEvents.RootObject CodecEvent;
|
||||
>>>>>>> origin/feature/cisco-spark-2
|
||||
|
||||
/// <summary>
|
||||
/// Gets and returns the scaled volume of the codec
|
||||
@@ -67,12 +78,42 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
protected override Func<string> SharingSourceFeedbackFunc
|
||||
{
|
||||
get { return () => "Fix me fuckers"; }
|
||||
get
|
||||
{
|
||||
return () => "Todo";
|
||||
}
|
||||
}
|
||||
|
||||
protected override Func<bool> MuteFeedbackFunc
|
||||
{
|
||||
get { return () => false; }
|
||||
get
|
||||
{
|
||||
return () => CodecStatus.Status.Audio.VolumeMute.BoolValue;
|
||||
}
|
||||
}
|
||||
|
||||
protected Func<bool> RoomIsOccupiedFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => CodecStatus.Status.RoomAnalytics.PeoplePresence.BoolValue;
|
||||
}
|
||||
}
|
||||
|
||||
protected Func<int> PeopleCountFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => CodecStatus.Status.RoomAnalytics.PeopleCount.Current.IntValue;
|
||||
}
|
||||
}
|
||||
|
||||
protected Func<bool> SpeakerTrackIsOnFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => CodecStatus.Status.Cameras.SpeakerTrack.Status.BoolValue;
|
||||
}
|
||||
}
|
||||
|
||||
//private HttpsClient Client;
|
||||
@@ -125,7 +166,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
CodecStatus = new CiscoCodecStatus.RootObject();
|
||||
|
||||
CodecEvent = new CiscoCodecEvents.RootObject();
|
||||
//CodecEvent = new CiscoCodecEvents.RootObject();
|
||||
|
||||
CodecStatus.Status.Audio.Volume.ValueChangedAction = VolumeLevelFeedback.FireUpdate;
|
||||
CodecStatus.Status.Audio.VolumeMute.ValueChangedAction = MuteFeedback.FireUpdate;
|
||||
@@ -482,6 +523,38 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
|
||||
if (response.IndexOf("\"Status\":{") > -1)
|
||||
{
|
||||
// Check to see if this is a call status message received after the initial status message
|
||||
if(SyncState.InitialStatusMessageWasReceived && response.IndexOf("\"Call\":{") > -1)
|
||||
{
|
||||
CiscoCodecStatus.RootObject callStatus = new CiscoCodecStatus.RootObject();
|
||||
|
||||
JsonConvert.PopulateObject(response, callStatus);
|
||||
|
||||
// Iterate through the call objects in the response
|
||||
foreach (CiscoCodecStatus.Call call in callStatus.Status.Call)
|
||||
{
|
||||
// Look for a matching call id in the existing status structure
|
||||
var existingCall = CodecStatus.Status.Call.FirstOrDefault(c => c.id.Equals(call.id));
|
||||
|
||||
if (existingCall != null)
|
||||
{
|
||||
// If an existing call object is found with a matching ID, populate the existing call with the new data.
|
||||
// (must reserialize the object so that we can use PopulateObject() to overlay the new or updated properties on the existing object)
|
||||
JsonConvert.PopulateObject(JsonConvert.SerializeObject(call), existingCall);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the call
|
||||
callStatus.Status.Call.Add(call);
|
||||
|
||||
// Add a call to the ActiveCalls List
|
||||
//ActiveCalls.Add(new CodecActiveCallItem() { Id = call.id, Status = call.Status.Value, Name = call.DisplayName.Value, Number = call.RemoteNumber.Value, Type = call.Status.Value.ToString()
|
||||
}
|
||||
|
||||
// Handle call.status to determine if we need to fire an event notifying of an incoming call or a call disconnect
|
||||
}
|
||||
}
|
||||
|
||||
JsonConvert.PopulateObject(response, CodecStatus);
|
||||
|
||||
if (!SyncState.InitialStatusMessageWasReceived)
|
||||
@@ -507,7 +580,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
}
|
||||
else if (response.IndexOf("\"Event\":{") > -1)
|
||||
{
|
||||
JsonConvert.PopulateObject(response, CodecEvent);
|
||||
CiscoCodecEvents.RootObject eventReceived = new CiscoCodecEvents.RootObject();
|
||||
|
||||
JsonConvert.PopulateObject(response, eventReceived);
|
||||
|
||||
EvalutateEvent(eventReceived);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -517,6 +594,24 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates an event received from the codec
|
||||
/// </summary>
|
||||
/// <param name="eventReceived"></param>
|
||||
void EvalutateEvent(CiscoCodecEvents.RootObject eventReceived)
|
||||
{
|
||||
if (eventReceived.Event.CallDisconnect != null)
|
||||
{
|
||||
var tempCall = CodecStatus.Status.Call.FirstOrDefault(c => c.id.Equals(eventReceived.Event.CallDisconnect.CallId));
|
||||
|
||||
if(tempCall != null)
|
||||
{
|
||||
CodecStatus.Status.Call.Remove(tempCall);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecuteSwitch(object selector)
|
||||
{
|
||||
(selector as Action)();
|
||||
@@ -551,11 +646,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
SendText(string.Format("xCommand Dial BookingId: {0}", s));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public override void EndCall(string s)
|
||||
{
|
||||
SendText(string.Format("xCommand Call Disconnect CallId: {0}", GetCallId()));
|
||||
=======
|
||||
public override void EndCall(CodecActiveCallItem activeCall)
|
||||
{
|
||||
SendText(string.Format("xCommand Call Disconnect CallId: {0}", activeCall.Id));
|
||||
@@ -567,15 +657,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||
{
|
||||
SendText(string.Format("xCommand Call Disconnect CallId: {0}", activeCall.Id));
|
||||
}
|
||||
>>>>>>> origin/feature/cisco-spark-2
|
||||
}
|
||||
|
||||
public override void AcceptCall()
|
||||
public override void AcceptCall(CodecActiveCallItem item)
|
||||
{
|
||||
SendText("xCommand Call Accept");
|
||||
}
|
||||
|
||||
public override void RejectCall()
|
||||
public override void RejectCall(CodecActiveCallItem item)
|
||||
{
|
||||
SendText("xCommand Call Reject");
|
||||
}
|
||||
|
||||
@@ -66,30 +66,28 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
public override void Dial(string s)
|
||||
{
|
||||
Debug.Console(1, this, "Dial: {0}", s);
|
||||
var item = new CodecActiveCallItem() { Name = s, Number = s, Id = s, Status = eCodecCallStatus.Dialing };
|
||||
ActiveCalls.Add(item);
|
||||
OnCallStatusChange(eCodecCallStatus.Unknown, item.Status, item);
|
||||
var call = new CodecActiveCallItem() { Name = s, Number = s, Id = s, Status = eCodecCallStatus.Dialing };
|
||||
ActiveCalls.Add(call);
|
||||
OnCallStatusChange(eCodecCallStatus.Unknown, call.Status, call);
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
// Simulate 2-second ring
|
||||
// Simulate 2-second ring, then connecting, then connected
|
||||
new CTimer(o =>
|
||||
{
|
||||
var prevStatus = item.Status;
|
||||
item.Status = eCodecCallStatus.Connected;
|
||||
item.Type = eCodecCallType.Video;
|
||||
OnCallStatusChange(prevStatus, item.Status, item);
|
||||
call.Type = eCodecCallType.Video;
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call);
|
||||
new CTimer(oo => SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connected, call), 1000);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override void EndCall(CodecActiveCallItem activeCall)
|
||||
public override void EndCall(CodecActiveCallItem call)
|
||||
{
|
||||
Debug.Console(1, this, "EndCall");
|
||||
ActiveCalls.Remove(activeCall);
|
||||
var prevStatus = activeCall.Status;
|
||||
activeCall.Status = eCodecCallStatus.Disconnected;
|
||||
OnCallStatusChange(prevStatus, activeCall.Status, activeCall);
|
||||
ActiveCalls.Remove(call);
|
||||
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
@@ -99,23 +97,29 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
public override void EndAllCalls()
|
||||
{
|
||||
Debug.Console(1, this, "EndAllCalls");
|
||||
ActiveCalls.Clear();
|
||||
foreach (var call in ActiveCalls)
|
||||
{
|
||||
ActiveCalls.Remove(call);
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Disconnected, call);
|
||||
}
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For a call from the test methods below
|
||||
/// </summary>
|
||||
public override void AcceptCall(CodecActiveCallItem item)
|
||||
public override void AcceptCall(CodecActiveCallItem call)
|
||||
{
|
||||
Debug.Console(1, this, "AcceptCall");
|
||||
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call);
|
||||
new CTimer(o => SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connected, call), 1000);
|
||||
// should already be in active list
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For a call from the test methods below
|
||||
/// </summary>
|
||||
public override void RejectCall(CodecActiveCallItem item)
|
||||
public override void RejectCall(CodecActiveCallItem call)
|
||||
{
|
||||
Debug.Console(1, this, "RejectCall");
|
||||
}
|
||||
@@ -247,16 +251,32 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public void TestIncomingCall(string url)
|
||||
public void TestIncomingVideoCall(string url)
|
||||
{
|
||||
Debug.Console(1, this, "TestIncomingCall from {0}", url);
|
||||
var item = new CodecActiveCallItem() { Name = url, Id = url, Number = url, Status = eCodecCallStatus.Incoming, Type= eCodecCallType.Unknown };
|
||||
ActiveCalls.Add(item);
|
||||
Debug.Console(1, this, "TestIncomingVideoCall from {0}", url);
|
||||
var call = new CodecActiveCallItem() { Name = url, Id = url, Number = url, Type= eCodecCallType.Video };
|
||||
ActiveCalls.Add(call);
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Incoming, call);
|
||||
_IncomingCall = true;
|
||||
IncomingCallFeedback.FireUpdate();
|
||||
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public void TestIncomingAudioCall(string url)
|
||||
{
|
||||
Debug.Console(1, this, "TestIncomingAudioCall from {0}", url);
|
||||
var call = new CodecActiveCallItem() { Name = url, Id = url, Number = url, Type = eCodecCallType.Audio };
|
||||
ActiveCalls.Add(call);
|
||||
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Incoming, call);
|
||||
_IncomingCall = true;
|
||||
IncomingCallFeedback.FireUpdate();
|
||||
ActiveCallCountFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -266,6 +286,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void ListCalls()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
@@ -278,7 +301,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get { return new RoutingPortCollection<RoutingOutputPort>(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -87,11 +87,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
#region IHasDialer Members
|
||||
|
||||
public abstract void Dial(string s);
|
||||
public void EndCall(object activeCall)
|
||||
{
|
||||
|
||||
}
|
||||
public abstract void EndCall(CodecActiveCallItem activeCall);
|
||||
public abstract void EndCall(CodecActiveCallItem call);
|
||||
public abstract void EndAllCalls();
|
||||
public abstract void AcceptCall(CodecActiveCallItem call);
|
||||
public abstract void RejectCall(CodecActiveCallItem call);
|
||||
@@ -114,6 +110,16 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
||||
|
||||
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>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user