mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +00:00
Adds receive queue and thread to CiscoSparkCodec class and sets receive thread priority for ZoomRoom
This commit is contained in:
@@ -4,6 +4,8 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro.CrestronThread;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
@@ -30,6 +32,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
|
|
||||||
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
||||||
|
|
||||||
|
private CrestronQueue<string> ReceiveQueue;
|
||||||
|
|
||||||
|
private Thread ReceiveThread;
|
||||||
|
|
||||||
public BoolFeedback PresentationViewMaximizedFeedback { get; private set; }
|
public BoolFeedback PresentationViewMaximizedFeedback { get; private set; }
|
||||||
|
|
||||||
string CurrentPresentationView;
|
string CurrentPresentationView;
|
||||||
@@ -259,7 +265,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
|
|
||||||
string PhonebookMode = "Local"; // Default to Local
|
string PhonebookMode = "Local"; // Default to Local
|
||||||
|
|
||||||
int PhonebookResultsLimit = 255; // Could be set later by config.
|
uint PhonebookResultsLimit = 255; // Could be set later by config.
|
||||||
|
|
||||||
CTimer LoginMessageReceivedTimer;
|
CTimer LoginMessageReceivedTimer;
|
||||||
CTimer RetryConnectionTimer;
|
CTimer RetryConnectionTimer;
|
||||||
@@ -281,10 +287,22 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
public CiscoSparkCodec(DeviceConfig config, IBasicCommunication comm)
|
public CiscoSparkCodec(DeviceConfig config, IBasicCommunication comm)
|
||||||
: base(config)
|
: base(config)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var props = JsonConvert.DeserializeObject<Codec.CiscoSparkCodecPropertiesConfig>(config.Properties.ToString());
|
var props = JsonConvert.DeserializeObject<Codec.CiscoSparkCodecPropertiesConfig>(config.Properties.ToString());
|
||||||
|
|
||||||
|
// Use the configured phonebook results limit if present
|
||||||
|
if (props.PhonebookResultsLimit > 0)
|
||||||
|
{
|
||||||
|
PhonebookResultsLimit = props.PhonebookResultsLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The queue that will collect the repsonses in the order they are received
|
||||||
|
ReceiveQueue = new CrestronQueue<string>(25);
|
||||||
|
|
||||||
|
// The thread responsible for dequeuing and processing the messages
|
||||||
|
ReceiveThread = new Thread((o) => ProcessQueue(), null);
|
||||||
|
ReceiveThread.Priority = Thread.eThreadPriority.MediumPriority;
|
||||||
|
|
||||||
|
|
||||||
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
|
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
|
||||||
PeopleCountFeedback = new IntFeedback(PeopleCountFeedbackFunc);
|
PeopleCountFeedback = new IntFeedback(PeopleCountFeedbackFunc);
|
||||||
CameraAutoModeIsOnFeedback = new BoolFeedback(SpeakerTrackIsOnFeedbackFunc);
|
CameraAutoModeIsOnFeedback = new BoolFeedback(SpeakerTrackIsOnFeedbackFunc);
|
||||||
@@ -382,6 +400,29 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
CreateOsdSource();
|
CreateOsdSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs in it's own thread to dequeue messages in the order they were received to be processed
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
object ProcessQueue()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var message = ReceiveQueue.Dequeue();
|
||||||
|
|
||||||
|
DeserializeResponse(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Error Processing Queue: {0}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the fake OSD source, and connects it's AudioVideo output to the CodecOsdIn input
|
/// Creates the fake OSD source, and connects it's AudioVideo output to the CodecOsdIn input
|
||||||
@@ -542,8 +583,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
if (CommDebuggingIsOn)
|
if (CommDebuggingIsOn)
|
||||||
Debug.Console(1, this, "Complete JSON Received:\n{0}", JsonMessage.ToString());
|
Debug.Console(1, this, "Complete JSON Received:\n{0}", JsonMessage.ToString());
|
||||||
|
|
||||||
// Forward the complete message to be deserialized
|
// Enqueue the complete message to be deserialized
|
||||||
DeserializeResponse(JsonMessage.ToString());
|
|
||||||
|
ReceiveQueue.Enqueue(JsonMessage.ToString());
|
||||||
|
//DeserializeResponse(JsonMessage.ToString());
|
||||||
|
|
||||||
|
if (ReceiveThread.ThreadState != Thread.eThreadStates.ThreadRunning)
|
||||||
|
ReceiveThread.Start();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,27 +7,41 @@ using Crestron.SimplSharp;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.Codec
|
namespace PepperDash.Essentials.Devices.Common.Codec
|
||||||
{
|
{
|
||||||
public class CiscoSparkCodecPropertiesConfig
|
public class CiscoSparkCodecPropertiesConfig
|
||||||
{
|
{
|
||||||
|
[JsonProperty("communicationMonitorProperties")]
|
||||||
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
|
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("favorites")]
|
||||||
public List<CodecActiveCallItem> Favorites { get; set; }
|
public List<CodecActiveCallItem> Favorites { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Valid values: "Local" or "Corporate"
|
/// Valid values: "Local" or "Corporate"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("phonebookMode")]
|
||||||
public string PhonebookMode { get; set; }
|
public string PhonebookMode { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("showSelfViewByDefault")]
|
||||||
public bool ShowSelfViewByDefault { get; set; }
|
public bool ShowSelfViewByDefault { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("sharing")]
|
||||||
public SharingProperties Sharing { get; set; }
|
public SharingProperties Sharing { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optionsal property to set the limit of any phonebook queries for directory or searching
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("phonebookResultsLimit")]
|
||||||
|
public uint PhonebookResultsLimit { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SharingProperties
|
public class SharingProperties
|
||||||
{
|
{
|
||||||
|
[JsonProperty("autoShareContentWhileInCall")]
|
||||||
public bool AutoShareContentWhileInCall { get; set; }
|
public bool AutoShareContentWhileInCall { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro.CrestronThread;
|
using Crestron.SimplSharpPro.CrestronThread;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
@@ -13,7 +14,6 @@ using PepperDash.Essentials.Core.Config;
|
|||||||
using PepperDash.Essentials.Core.Routing;
|
using PepperDash.Essentials.Core.Routing;
|
||||||
using PepperDash.Essentials.Devices.Common.Cameras;
|
using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
using PepperDash.Essentials.Devices.Common.Codec;
|
using PepperDash.Essentials.Devices.Common.Codec;
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
||||||
@@ -171,6 +171,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
|
|
||||||
// The thread responsible for dequeuing and processing the messages
|
// The thread responsible for dequeuing and processing the messages
|
||||||
ReceiveThread = new Thread((o) => ProcessQueue(), null);
|
ReceiveThread = new Thread((o) => ProcessQueue(), null);
|
||||||
|
ReceiveThread.Priority = Thread.eThreadPriority.MediumPriority;
|
||||||
|
|
||||||
Communication = comm;
|
Communication = comm;
|
||||||
|
|
||||||
@@ -401,7 +402,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
|
|
||||||
// If the receive thread has for some reason stopped, this will restart it
|
// If the receive thread has for some reason stopped, this will restart it
|
||||||
if (ReceiveThread.ThreadState != Thread.eThreadStates.ThreadRunning)
|
if (ReceiveThread.ThreadState != Thread.eThreadStates.ThreadRunning)
|
||||||
|
{
|
||||||
ReceiveThread.Start();
|
ReceiveThread.Start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user