merge cisco-spark-2, see previous commit note

This commit is contained in:
Heath Volmer
2017-09-19 17:54:21 -06:00
3 changed files with 185 additions and 19 deletions

View File

@@ -18,6 +18,8 @@ namespace PepperDash.Essentials.Devices.Common.Codec
public eCodecCallStatus Status { get; set; } public eCodecCallStatus Status { get; set; }
public string Id { get; set; } public string Id { get; set; }
public object CallMetaData { get; set; }
} }
public enum eCodecCallType public enum eCodecCallType

View File

@@ -29,6 +29,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public BoolFeedback StandbyIsOnFeedback { get; private set; } 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 CiscoOneButtonToPush CodecObtp;
private Corporate_Phone_Book PhoneBook; private Corporate_Phone_Book PhoneBook;
@@ -37,7 +43,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
private CiscoCodecStatus.RootObject CodecStatus; private CiscoCodecStatus.RootObject CodecStatus;
private CiscoCodecEvents.RootObject CodecEvent; //private CiscoCodecEvents.RootObject CodecEvent;
/// <summary> /// <summary>
/// Gets and returns the scaled volume of the codec /// Gets and returns the scaled volume of the codec
@@ -68,12 +74,42 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
protected override Func<string> SharingSourceFeedbackFunc protected override Func<string> SharingSourceFeedbackFunc
{ {
get { return () => "Fix me fuckers"; } get
{
return () => "Todo";
}
} }
protected override Func<bool> MuteFeedbackFunc 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; //private HttpsClient Client;
@@ -126,7 +162,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
CodecStatus = new CiscoCodecStatus.RootObject(); CodecStatus = new CiscoCodecStatus.RootObject();
CodecEvent = new CiscoCodecEvents.RootObject(); //CodecEvent = new CiscoCodecEvents.RootObject();
CodecStatus.Status.Audio.Volume.ValueChangedAction = VolumeLevelFeedback.FireUpdate; CodecStatus.Status.Audio.Volume.ValueChangedAction = VolumeLevelFeedback.FireUpdate;
CodecStatus.Status.Audio.VolumeMute.ValueChangedAction = MuteFeedback.FireUpdate; CodecStatus.Status.Audio.VolumeMute.ValueChangedAction = MuteFeedback.FireUpdate;
@@ -483,6 +519,38 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
if (response.IndexOf("\"Status\":{") > -1) 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); JsonConvert.PopulateObject(response, CodecStatus);
if (!SyncState.InitialStatusMessageWasReceived) if (!SyncState.InitialStatusMessageWasReceived)
@@ -508,7 +576,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
} }
else if (response.IndexOf("\"Event\":{") > -1) else if (response.IndexOf("\"Event\":{") > -1)
{ {
JsonConvert.PopulateObject(response, CodecEvent); CiscoCodecEvents.RootObject eventReceived = new CiscoCodecEvents.RootObject();
JsonConvert.PopulateObject(response, eventReceived);
EvalutateEvent(eventReceived);
} }
} }
@@ -518,6 +590,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) public override void ExecuteSwitch(object selector)
{ {
(selector as Action)(); (selector as Action)();

View File

@@ -241,21 +241,42 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public string Value { get; set; } public string Value { get; set; }
} }
public class Status2 public class Status2 : ValueProperty
{ {
public string Value { get; set; } public bool BoolValue { get; private set; }
public string Value
{
set
{
// If the incoming value is "Active" it sets the BoolValue true, otherwise sets it false
BoolValue = value == "Active";
OnValueChanged();
}
}
} }
public class SpeakerTrack public class SpeakerTrack
{ {
public Availability Availability { get; set; } public Availability Availability { get; set; }
public Status2 Status { get; set; } public Status2 Status { get; set; }
public SpeakerTrack()
{
Status = new Status2();
}
} }
public class Cameras public class Cameras
{ {
public List<Camera> Camera { get; set; } public List<Camera> Camera { get; set; }
public SpeakerTrack SpeakerTrack { get; set; } public SpeakerTrack SpeakerTrack { get; set; }
public Cameras()
{
Camera = new List<Camera>();
SpeakerTrack = new SpeakerTrack();
}
} }
public class MaxActiveCalls public class MaxActiveCalls
@@ -897,25 +918,76 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public Services Services { get; set; } public Services Services { get; set; }
} }
public class Current3 public class Current3 : ValueProperty
{ {
public string Value { get; set; } string _Value;
/// <summary>
/// Sets Value and triggers the action when set
/// </summary>
public string Value
{
get
{
return _Value;
}
set
{
_Value = value;
OnValueChanged();
}
}
/// <summary>
/// Converted value of _Value for use as feedback
/// </summary>
public int IntValue
{
get
{
if (!string.IsNullOrEmpty(_Value))
return Convert.ToInt32(_Value);
else
return 0;
}
}
} }
public class PeopleCount public class PeopleCount
{ {
public Current3 Current { get; set; } public Current3 Current { get; set; }
public PeopleCount()
{
Current = new Current3();
}
} }
public class PeoplePresence public class PeoplePresence : ValueProperty
{ {
public string Value { get; set; } public bool BoolValue { get; private set; }
public string Value
{
set
{
// If the incoming value is "Yes" it sets the BoolValue true, otherwise sets it false
BoolValue = value == "Yes";
OnValueChanged();
}
}
} }
public class RoomAnalytics public class RoomAnalytics
{ {
public PeopleCount PeopleCount { get; set; } public PeopleCount PeopleCount { get; set; }
public PeoplePresence PeoplePresence { get; set; } public PeoplePresence PeoplePresence { get; set; }
public RoomAnalytics()
{
PeopleCount = new PeopleCount();
PeoplePresence = new PeoplePresence();
}
} }
public class Authentication public class Authentication
@@ -1618,6 +1690,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
Audio = new Audio(); Audio = new Audio();
Call = new List<Call>(); Call = new List<Call>();
Standby = new Standby(); Standby = new Standby();
Cameras = new Cameras();
RoomAnalytics = new RoomAnalytics();
} }
#warning Figure out how to flag codec as InCall if Call.Count > 0 #warning Figure out how to flag codec as InCall if Call.Count > 0
} }