Merge pull request #613 from PepperDash/bugfix/implement-genericqueue-for-ciscosparkcodec

Bugfix/implement genericqueue for ciscosparkcodec
This commit is contained in:
Neil Dorin
2021-02-16 16:17:22 -07:00
committed by GitHub

View File

@@ -18,6 +18,7 @@ using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Devices.Common.Cameras;
using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.VideoCodec;
using PepperDash_Essentials_Core.Queues;
using PepperDash_Essentials_Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
@@ -38,9 +39,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public StatusMonitorBase CommunicationMonitor { get; private set; }
private CrestronQueue<string> ReceiveQueue;
private Thread ReceiveThread;
private GenericQueue ReceiveQueue;
public BoolFeedback PresentationViewMaximizedFeedback { get; private set; }
@@ -302,12 +301,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
}
// 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;
ReceiveQueue = new GenericQueue(this.Key + "-rxQueue", 25);
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
PeopleCountFeedback = new IntFeedback(PeopleCountFeedbackFunc);
@@ -421,29 +415,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
_brandingUrl = props.UiBranding.BrandingUrl;
}
/// 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>
/// Creates the fake OSD source, and connects it's AudioVideo output to the CodecOsdIn input
/// to enable routing
@@ -687,11 +658,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
// Enqueue the complete message to be deserialized
ReceiveQueue.Enqueue(JsonMessage.ToString());
//DeserializeResponse(JsonMessage.ToString());
if (ReceiveThread.ThreadState != Thread.eThreadStates.ThreadRunning)
ReceiveThread.Start();
ReceiveQueue.Enqueue(new ProcessStringMessage(JsonMessage.ToString(), DeserializeResponse));
return;
}
@@ -1481,7 +1448,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
throw new NotImplementedException();
LinkVideoCodecToApi(this, trilist, joinStart, joinMapKey, bridge);
}
/// <summary>