Started working on property feedback mechansism to trigger codec feedbacks automatically when feedback values are deserialized

This commit is contained in:
Neil Dorin
2017-09-14 10:21:29 -06:00
parent a9424cde22
commit 1ad1c5404f
4 changed files with 162 additions and 14 deletions

View File

@@ -33,6 +33,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
private CiscoCodecStatus.RootObject CodecStatus; private CiscoCodecStatus.RootObject CodecStatus;
protected override Func<int> VolumeLevelFeedbackFunc
{
get
{
return () => CodecStatus.Status.Audio.Volume.IntValue;
}
}
//private HttpsClient Client; //private HttpsClient Client;
//private HttpApiServer Server; //private HttpApiServer Server;
@@ -83,6 +91,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
CodecStatus = new CiscoCodecStatus.RootObject(); CodecStatus = new CiscoCodecStatus.RootObject();
CodecStatus.Status.Audio.Volume.ValueChangedAction = VolumeLevelFeedback.FireUpdate;
//Client = new HttpsClient(); //Client = new HttpsClient();
//Server = new HttpApiServer(); //Server = new HttpApiServer();
@@ -162,7 +172,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
SyncState.CodecDisconnected(); SyncState.CodecDisconnected();
} }
/// <summary>
/// Gathers responses from the codec (including the delimiter. Responses are checked to see if they contain JSON data and if so, the data is collected until a complete JSON
/// message is received before forwarding the message to be deserialized.
/// </summary>
/// <param name="dev"></param>
/// <param name="args"></param>
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args) void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
{ {
if (Debug.Level == 1) if (Debug.Level == 1)
@@ -215,7 +230,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
SendText("xStatus"); SendText("xStatus");
break; break;
} }
case "xFeedback Register": case "xFeedback register":
{ {
SyncState.FeedbackRegistered(); SyncState.FeedbackRegistered();
break; break;
@@ -473,12 +488,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public override void Dial(string s) public override void Dial(string s)
{ {
SendText(string.Format("xCommand Dial Number: {0}", s));
} }
public override void EndCall() public override void EndCall()
{ {
//SendText(string.Format("xCommand Accept CallId: {0}", CodecStatus.Status.));
} }
public override void AcceptCall() public override void AcceptCall()

View File

@@ -9,6 +9,22 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{ {
public class CiscoCodecStatus public class CiscoCodecStatus
{ {
// Helper Classes for Proerties
public abstract class ValueProperty
{
/// <summary>
/// Triggered when Value is set
/// </summary>
public Action ValueChangedAction { get; set; }
protected void OnValueChanged()
{
var a = ValueChangedAction;
if (a != null)
a();
}
}
public class ConnectionStatus public class ConnectionStatus
{ {
@@ -31,9 +47,19 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public Connectors Connectors { get; set; } public Connectors Connectors { get; set; }
} }
public class Mute public class Mute : ValueProperty
{ {
public string Value { get; set; } public bool BoolValue { get; private set; }
public string Value
{
set
{
// If the incoming value is "On" it sets the BoolValue true, otherwise sets it false
BoolValue = value == "On";
OnValueChanged();
}
}
} }
public class Microphones public class Microphones
@@ -68,23 +94,68 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public Connectors2 Connectors { get; set; } public Connectors2 Connectors { get; set; }
} }
public class Volume public class Volume : 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 VolumeMute public class VolumeMute : ValueProperty
{ {
public string Value { get; set; } public bool BoolValue { get; private set; }
public string Value
{
set
{
// If the incoming value is "On" it sets the BoolValue true, otherwise sets it false
BoolValue = value == "On";
OnValueChanged();
}
}
} }
public class Audio public class Audio
{ {
public Input Input { get; set; } public Input Input { get; set; }
public Microphones Microphones { get; set; } public Microphones Microphones { get; set; } // Can we have this setter fire the update on the CiscoCodec feedback?
public Output Output { get; set; } public Output Output { get; set; }
public Volume Volume { get; set; } public Volume Volume { get; set; }
public VolumeMute VolumeMute { get; set; } public VolumeMute VolumeMute { get; set; }
public Audio()
{
Volume = new Volume();
}
} }
public class Id public class Id
@@ -1438,11 +1509,21 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public Time Time { get; set; } public Time Time { get; set; }
public UserInterface UserInterface { get; set; } public UserInterface UserInterface { get; set; }
public Video Video { get; set; } public Video Video { get; set; }
public Status()
{
Audio = new Audio();
}
} }
public class RootObject public class RootObject
{ {
public Status Status { get; set; } public Status Status { get; set; }
public RootObject()
{
Status = new Status();
}
} }
} }
} }

View File

@@ -47,6 +47,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
} }
bool _PrivacyModeIsOn; bool _PrivacyModeIsOn;
protected override Func<int> VolumeLevelFeedbackFunc
{
get { throw new NotImplementedException(); }
}
/// <summary> /// <summary>
/// Dials, yo! /// Dials, yo!
/// </summary> /// </summary>

View File

@@ -9,7 +9,7 @@ using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec namespace PepperDash.Essentials.Devices.Common.VideoCodec
{ {
public abstract class VideoCodecBase : Device, IRoutingSinkWithSwitching, IUsageTracking, IHasDialer, IHasSharing //, ICodecAudio public abstract class VideoCodecBase : Device, IRoutingSinkWithSwitching, IUsageTracking, IHasDialer, IHasSharing, IBasicVolumeWithFeedback //, ICodecAudio
{ {
#region IUsageTracking Members #region IUsageTracking Members
@@ -32,6 +32,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
abstract protected Func<bool> ReceiveMuteFeedbackFunc { get; } abstract protected Func<bool> ReceiveMuteFeedbackFunc { get; }
abstract protected Func<bool> PrivacyModeFeedbackFunc { get; } abstract protected Func<bool> PrivacyModeFeedbackFunc { get; }
abstract protected Func<int> VolumeLevelFeedbackFunc { get; }
public VideoCodecBase(string key, string name) public VideoCodecBase(string key, string name)
: base(key, name) : base(key, name)
{ {
@@ -41,6 +43,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
TransmitMuteIsOnFeedback = new BoolFeedback(TransmitMuteFeedbackFunc); TransmitMuteIsOnFeedback = new BoolFeedback(TransmitMuteFeedbackFunc);
PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeFeedbackFunc); PrivacyModeIsOnFeedback = new BoolFeedback(PrivacyModeFeedbackFunc);
VolumeLevelFeedback = new IntFeedback(VolumeLevelFeedbackFunc);
InputPorts = new RoutingPortCollection<RoutingInputPort>(); InputPorts = new RoutingPortCollection<RoutingInputPort>();
InCallFeedback.OutputChange += new EventHandler<EventArgs>(InCallFeedback_OutputChange); InCallFeedback.OutputChange += new EventHandler<EventArgs>(InCallFeedback_OutputChange);
@@ -114,5 +118,47 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
public StringFeedback SharingSourceFeedback { get; private set; } public StringFeedback SharingSourceFeedback { get; private set; }
#endregion #endregion
#region IBasicVolumeWithFeedback Members
public BoolFeedback MuteFeedback { get; private set; }
public void MuteOff()
{
}
public void MuteOn()
{
}
public void SetVolume(ushort level)
{
}
public IntFeedback VolumeLevelFeedback { get; private set; }
#endregion
#region IBasicVolumeControls Members
public void MuteToggle()
{
}
public void VolumeDown(bool pressRelease)
{
}
public void VolumeUp(bool pressRelease)
{
}
#endregion
} }
} }