diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj
index fe4d5f61..547e8711 100644
--- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj
+++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj
@@ -108,6 +108,7 @@
+
diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs
index c9e584d3..581e34e5 100644
--- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs
+++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs
@@ -1023,20 +1023,25 @@ ConnectorID: {2}"
if (tempPresets.Count > 0)
{
// Create temporary list to store the existing items from the CiscoCodecStatus.RoomPreset collection
- List existingRoomPresets = new List();
+ var existingRoomPresets = new List();
// Add the existing items to the temporary list
existingRoomPresets.AddRange(CodecStatus.Status.RoomPreset);
// Populate the CodecStatus object (this will append new values to the RoomPreset collection
JsonConvert.PopulateObject(response, CodecStatus);
- JObject jResponse = JObject.Parse(response);
+ var jResponse = JObject.Parse(response);
+
+ List convertedRoomPresets =
+ existingRoomPresets.Select(a => (CiscoCodecStatus.RoomPreset) a).ToList();
IList roomPresets = jResponse["Status"]["RoomPreset"].Children().ToList();
// Iterate the new items in this response agains the temporary list. Overwrite any existing items and add new ones.
- foreach (var preset in tempPresets)
+ foreach (var camPreset in tempPresets)
{
+ var preset = camPreset as CiscoCodecStatus.RoomPreset;
+ if (preset == null) continue;
// First fine the existing preset that matches the id
- var existingPreset = existingRoomPresets.FirstOrDefault(p => p.id.Equals(preset.id));
+ var existingPreset = convertedRoomPresets.FirstOrDefault(p => p.id.Equals(preset.id));
if (existingPreset != null)
{
Debug.Console(1, this, "Existing Room Preset with ID: {0} found. Updating.", existingPreset.id);
@@ -1068,7 +1073,7 @@ ConnectorID: {2}"
CodecStatus.Status.RoomPreset = existingRoomPresets;
// Generecise the list
- NearEndPresets = RoomPresets.GetGenericPresets(CodecStatus.Status.RoomPreset);
+ NearEndPresets = RoomPresets.GetGenericPresets(existingRoomPresets).Select(a =>(CodecRoomPreset)a).ToList();
var handler = CodecRoomPresetsListHasChanged;
if (handler != null)
diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs
index b6327d52..1cf9acdf 100644
--- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs
+++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using Crestron.SimplSharp;
-
-using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.Presets;
-using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
@@ -33,39 +28,19 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
public static class RoomPresets
{
///
- /// Converts Cisco RoomPresets to generic CameraPresets
+ /// Converts non-generic RoomPresets to generic CameraPresets
///
///
///
- public static List GetGenericPresets(List presets)
+ public static List GetGenericPresets(List presets)
{
- var cameraPresets = new List();
+ Debug.Console(2, "Presets List:");
- if (Debug.Level > 0)
- {
- Debug.Console(1, "Presets List:");
- }
- foreach (CiscoCodecStatus.RoomPreset preset in presets)
- {
- try
- {
- var cameraPreset = new CodecRoomPreset(UInt16.Parse(preset.id), preset.Description.Value, preset.Defined.BoolValue, true);
-
- cameraPresets.Add(cameraPreset);
-
- if (Debug.Level > 0)
- {
- Debug.Console(1, "Added Preset ID: {0}, Description: {1}, IsDefined: {2}, isDefinable: {3}", cameraPreset.ID, cameraPreset.Description, cameraPreset.Defined, cameraPreset.IsDefinable);
- }
- }
- catch (Exception e)
- {
- Debug.Console(2, "Unable to convert preset: {0}. Error: {1}", preset.id, e);
- }
- }
-
- return cameraPresets;
+ return
+ presets.Select(preset => preset.ReturnConvertedCodecPreset())
+ .Where(newPreset => newPreset != null)
+ .ToList();
}
}
diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs
index 5bde30ff..2c84cba8 100644
--- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs
+++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/xStatus.cs
@@ -9,6 +9,7 @@ using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.VideoCodec.CiscoCodec;
+using PepperDash.Essentials.Core.Presets;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
@@ -2185,7 +2186,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
}
}
- public class RoomPreset
+ public class RoomPreset : IConvertiblePreset
{
public string id { get; set; }
public Defined Defined { get; set; }
@@ -2198,7 +2199,24 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
Description = new Description2();
Type = new Type5();
}
- }
+
+ public PresetBase ReturnConvertedCodecPreset()
+ {
+ try
+ {
+ var preset = new CodecRoomPreset(UInt16.Parse(id), Description.Value, Defined.BoolValue, true);
+
+ Debug.Console(2, "Preset ID {0} Converted from Cisco Codec Preset to Essentials Preset");
+
+ return preset;
+ }
+ catch (Exception e)
+ {
+ Debug.Console(2, "Unable to convert preset: {0}. Error: {1}", id, e);
+ return null;
+ }
+ }
+}
@@ -2222,7 +2240,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public Proximity Proximity { get; set; }
public RoomAnalytics RoomAnalytics { get; set; }
- public List RoomPreset { get; set; }
+ public List RoomPreset { get; set; }
public SIP SIP { get; set; }
public Security Security { get; set; }
@@ -2239,7 +2257,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
Standby = new Standby();
Cameras = new Cameras();
RoomAnalytics = new RoomAnalytics();
- RoomPreset = new List();
+ RoomPreset = new List();
Conference = new Conference2();
SystemUnit = new SystemUnit();
Video = new Video();
diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/IConvertiblePreset.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/IConvertiblePreset.cs
new file mode 100644
index 00000000..7c3695aa
--- /dev/null
+++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/IConvertiblePreset.cs
@@ -0,0 +1,9 @@
+using PepperDash.Essentials.Core.Presets;
+
+namespace PepperDash.Essentials.Devices.Common.VideoCodec
+{
+ public interface IConvertiblePreset
+ {
+ PresetBase ReturnConvertedCodecPreset();
+ }
+}
\ No newline at end of file