diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs index 621ad8a4..819eb47a 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs @@ -26,7 +26,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public StatusMonitorBase CommunicationMonitor { get; private set; } - 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; @@ -36,7 +42,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco private CiscoCodecStatus.RootObject CodecStatus; - private CiscoCodecEvents.RootObject CodecEvent; + //private CiscoCodecEvents.RootObject CodecEvent; /// /// Gets and returns the scaled volume of the codec @@ -67,12 +73,42 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco protected override Func SharingSourceFeedbackFunc { - get { return () => "Fix me fuckers"; } + get + { + return () => "Todo"; + } } protected override Func MuteFeedbackFunc { - get { return () => false; } + get + { + return () => CodecStatus.Status.Audio.VolumeMute.BoolValue; + } + } + + protected Func RoomIsOccupiedFeedbackFunc + { + get + { + return () => CodecStatus.Status.RoomAnalytics.PeoplePresence.BoolValue; + } + } + + protected Func PeopleCountFeedbackFunc + { + get + { + return () => CodecStatus.Status.RoomAnalytics.PeopleCount.Current.IntValue; + } + } + + protected Func SpeakerTrackIsOnFeedbackFunc + { + get + { + return () => CodecStatus.Status.Cameras.SpeakerTrack.Status.BoolValue; + } } //private HttpsClient Client; @@ -125,7 +161,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 +518,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) @@ -506,8 +574,12 @@ 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); } } @@ -515,6 +587,24 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { Debug.Console(1, this, "Error Deserializing feedback from codec: {0}", ex); } + } + + /// + /// Evaluates an event received from the codec + /// + /// + 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) diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs index d376dfed..60516378 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs @@ -241,21 +241,42 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public string Value { get; set; } } - public class Status2 - { - public string Value { get; set; } + public class Status2 : ValueProperty + { + 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 Availability Availability { get; set; } - public Status2 Status { get; set; } + public Status2 Status { get; set; } + + public SpeakerTrack() + { + Status = new Status2(); + } } public class Cameras { public List Camera { get; set; } - public SpeakerTrack SpeakerTrack { get; set; } + public SpeakerTrack SpeakerTrack { get; set; } + + public Cameras() + { + Camera = new List(); + SpeakerTrack = new SpeakerTrack(); + } } public class MaxActiveCalls @@ -897,25 +918,76 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Services Services { get; set; } } - public class Current3 - { - public string Value { get; set; } + public class Current3 : ValueProperty + { + string _Value; + + /// + /// Sets Value and triggers the action when set + /// + public string Value + { + get + { + return _Value; + } + set + { + _Value = value; + OnValueChanged(); + } + } + + /// + /// Converted value of _Value for use as feedback + /// + public int IntValue + { + get + { + if (!string.IsNullOrEmpty(_Value)) + return Convert.ToInt32(_Value); + else + return 0; + } + } } public class PeopleCount { - public Current3 Current { get; set; } + public Current3 Current { get; set; } + + public PeopleCount() + { + Current = new Current3(); + } } - public class PeoplePresence - { - public string Value { get; set; } + public class PeoplePresence : ValueProperty + { + 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 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 @@ -1617,7 +1689,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { Audio = new Audio(); Call = new List(); - 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 } diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs index 0ab4d7ac..100b4faf 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CodecActiveCallItem.cs @@ -17,16 +17,18 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec public eCodecCallStatus Status { get; set; } - public string Id { get; set; } + public string Id { get; set; } + + public object CallMetaData { get; set; } } public enum eCodecCallType { - None, Audio, Video + Unknown = 0, Audio, Video } public enum eCodecCallStatus { - Dialing, Established, Incoming + Unknown = 0, Dialing, Connected, Incoming, OnHold, Disconnected } } \ No newline at end of file