Merge pull request #967 from PepperDash/feature/VideoCodec-Improvements

Feature/video codec improvements
This commit is contained in:
Andrew Welker
2022-07-19 08:33:30 -06:00
committed by GitHub
10 changed files with 158 additions and 59 deletions

View File

@@ -1576,6 +1576,36 @@ namespace PepperDash.Essentials.Core.Bridges.JoinMaps
JoinType = eJoinType.Serial JoinType = eJoinType.Serial
}); });
[JoinName("AvailableLayoutsFb")]
public JoinDataComplete AvailableLayoutsFb = new JoinDataComplete(
new JoinData
{
JoinNumber = 142,
JoinSpan = 1
},
new JoinMetadata
{
Description = "xSig of all available layouts",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Serial
});
[JoinName("SelectLayout")]
public JoinDataComplete SelectLayout = new JoinDataComplete(
new JoinData
{
JoinNumber = 142,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Select Layout by string",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Serial
});
[JoinName("CurrentParticipants")] [JoinName("CurrentParticipants")]
public JoinDataComplete CurrentParticipants = new JoinDataComplete( public JoinDataComplete CurrentParticipants = new JoinDataComplete(
new JoinData new JoinData
@@ -3014,6 +3044,35 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps
JoinType = eJoinType.Serial JoinType = eJoinType.Serial
}); });
[JoinName("AvailableLayoutsFb")]
public JoinDataComplete AvailableLayoutsFb = new JoinDataComplete(
new JoinData
{
JoinNumber = 142,
JoinSpan = 1
},
new JoinMetadata
{
Description = "xSig of all available layouts",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Serial
});
[JoinName("SelectLayout")]
public JoinDataComplete SelectLayout = new JoinDataComplete(
new JoinData
{
JoinNumber = 142,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Select Layout by string",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Serial
});
[JoinName("CurrentParticipants")] [JoinName("CurrentParticipants")]
public JoinDataComplete CurrentParticipants = new JoinDataComplete( public JoinDataComplete CurrentParticipants = new JoinDataComplete(
new JoinData new JoinData

View File

@@ -108,6 +108,7 @@
<Compile Include="Codec\eCodecCallStatus.cs" /> <Compile Include="Codec\eCodecCallStatus.cs" />
<Compile Include="Codec\eMeetingPrivacy.cs" /> <Compile Include="Codec\eMeetingPrivacy.cs" />
<Compile Include="Codec\iCodecAudio.cs" /> <Compile Include="Codec\iCodecAudio.cs" />
<Compile Include="VideoCodec\IConvertiblePreset.cs" />
<Compile Include="Codec\IHasCallHold.cs" /> <Compile Include="Codec\IHasCallHold.cs" />
<Compile Include="Codec\IHasDoNotDisturb.cs" /> <Compile Include="Codec\IHasDoNotDisturb.cs" />
<Compile Include="Codec\IHasExternalSourceSwitching.cs" /> <Compile Include="Codec\IHasExternalSourceSwitching.cs" />

View File

@@ -1023,20 +1023,25 @@ ConnectorID: {2}"
if (tempPresets.Count > 0) if (tempPresets.Count > 0)
{ {
// Create temporary list to store the existing items from the CiscoCodecStatus.RoomPreset collection // Create temporary list to store the existing items from the CiscoCodecStatus.RoomPreset collection
List<CiscoCodecStatus.RoomPreset> existingRoomPresets = new List<CiscoCodecStatus.RoomPreset>(); var existingRoomPresets = new List<IConvertiblePreset>();
// Add the existing items to the temporary list // Add the existing items to the temporary list
existingRoomPresets.AddRange(CodecStatus.Status.RoomPreset); existingRoomPresets.AddRange(CodecStatus.Status.RoomPreset);
// Populate the CodecStatus object (this will append new values to the RoomPreset collection // Populate the CodecStatus object (this will append new values to the RoomPreset collection
JsonConvert.PopulateObject(response, CodecStatus); JsonConvert.PopulateObject(response, CodecStatus);
JObject jResponse = JObject.Parse(response); var jResponse = JObject.Parse(response);
List<CiscoCodecStatus.RoomPreset> convertedRoomPresets =
existingRoomPresets.Select(a => (CiscoCodecStatus.RoomPreset) a).ToList();
IList<JToken> roomPresets = jResponse["Status"]["RoomPreset"].Children().ToList(); IList<JToken> 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. // 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 // 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) if (existingPreset != null)
{ {
Debug.Console(1, this, "Existing Room Preset with ID: {0} found. Updating.", existingPreset.id); Debug.Console(1, this, "Existing Room Preset with ID: {0} found. Updating.", existingPreset.id);
@@ -1068,7 +1073,7 @@ ConnectorID: {2}"
CodecStatus.Status.RoomPreset = existingRoomPresets; CodecStatus.Status.RoomPreset = existingRoomPresets;
// Generecise the list // Generecise the list
NearEndPresets = RoomPresets.GetGenericPresets(CodecStatus.Status.RoomPreset); NearEndPresets = existingRoomPresets.GetGenericPresets<CodecRoomPreset>();
var handler = CodecRoomPresetsListHasChanged; var handler = CodecRoomPresetsListHasChanged;
if (handler != null) if (handler != null)
@@ -2465,20 +2470,6 @@ ConnectorID: {2}"
} }
/// <summary>
/// Represents a codec command that might need to have a friendly label applied for UI feedback purposes
/// </summary>
public class CodecCommandWithLabel
{
public string Command { get; set; }
public string Label { get; set; }
public CodecCommandWithLabel(string command, string label)
{
Command = command;
Label = label;
}
}
/// <summary> /// <summary>
/// Tracks the initial sycnronization state of the codec when making a connection /// Tracks the initial sycnronization state of the codec when making a connection

View File

@@ -1,14 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Core.Presets;
using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco;
namespace PepperDash.Essentials.Devices.Common.VideoCodec namespace PepperDash.Essentials.Devices.Common.VideoCodec
{ {
@@ -33,39 +28,17 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
public static class RoomPresets public static class RoomPresets
{ {
/// <summary> /// <summary>
/// Converts Cisco RoomPresets to generic CameraPresets /// Converts non-generic RoomPresets to generic CameraPresets
/// </summary> /// </summary>
/// <param name="presets"></param> /// <param name="presets"></param>
/// <returns></returns> /// <returns></returns>
public static List<CodecRoomPreset> GetGenericPresets(List<CiscoCodecStatus.RoomPreset> presets) public static List<T> GetGenericPresets<T>(this List<IConvertiblePreset> presets)
{ {
var cameraPresets = new List<CodecRoomPreset>(); return
presets.Select(preset => preset.ConvertCodecPreset())
if (Debug.Level > 0) .Where(newPreset => newPreset != null)
{ .Cast<T>()
Debug.Console(1, "Presets List:"); .ToList();
}
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;
} }
} }

View File

@@ -9,6 +9,7 @@ using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.VideoCodec.CiscoCodec; using PepperDash.Essentials.Devices.Common.VideoCodec.CiscoCodec;
using PepperDash.Essentials.Core.Presets;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco 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 string id { get; set; }
public Defined Defined { get; set; } public Defined Defined { get; set; }
@@ -2198,7 +2199,24 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
Description = new Description2(); Description = new Description2();
Type = new Type5(); Type = new Type5();
} }
}
public PresetBase ConvertCodecPreset()
{
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 Proximity Proximity { get; set; }
public RoomAnalytics RoomAnalytics { get; set; } public RoomAnalytics RoomAnalytics { get; set; }
public List<RoomPreset> RoomPreset { get; set; } public List<IConvertiblePreset> RoomPreset { get; set; }
public SIP SIP { get; set; } public SIP SIP { get; set; }
public Security Security { get; set; } public Security Security { get; set; }
@@ -2239,7 +2257,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
Standby = new Standby(); Standby = new Standby();
Cameras = new Cameras(); Cameras = new Cameras();
RoomAnalytics = new RoomAnalytics(); RoomAnalytics = new RoomAnalytics();
RoomPreset = new List<RoomPreset>(); RoomPreset = new List<IConvertiblePreset>();
Conference = new Conference2(); Conference = new Conference2();
SystemUnit = new SystemUnit(); SystemUnit = new SystemUnit();
Video = new Video(); Video = new Video();

View File

@@ -0,0 +1,9 @@
using PepperDash.Essentials.Core.Presets;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public interface IConvertiblePreset
{
PresetBase ConvertCodecPreset();
}
}

View File

@@ -22,6 +22,26 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
void MinMaxLayoutToggle(); void MinMaxLayoutToggle();
} }
/// <summary>
/// Defines the required elements for layout control with direct layout selection
/// </summary>
public interface IHasCodecLayoutsAvailable : IHasCodecLayouts
{
event EventHandler<AvailableLayoutChangedEventArgs> AvailableLayoutsChanged;
StringFeedback AvailableLocalLayoutsFeedback { get; }
List<CodecCommandWithLabel> AvailableLocalLayouts { get; }
void LocalLayoutSet(string layout);
void LocalLayoutSet(CodecCommandWithLabel layout);
}
public class AvailableLayoutChangedEventArgs : EventArgs
{
public List<CodecCommandWithLabel> AvailableLayouts { get; set; }
}
/// <summary> /// <summary>
/// Defines the requirements for Zoom Room layout control /// Defines the requirements for Zoom Room layout control
/// </summary> /// </summary>

View File

@@ -1,5 +1,5 @@
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{ {

View File

@@ -1,4 +1,4 @@
using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{ {

View File

@@ -370,6 +370,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
LinkVideoCodecCameraLayoutsToApi(codec as IHasCodecLayouts, trilist, joinMap); LinkVideoCodecCameraLayoutsToApi(codec as IHasCodecLayouts, trilist, joinMap);
} }
if (codec is IHasCodecLayoutsAvailable)
{
LinkVideoCodecAvailableLayoutsToApi(codec as IHasCodecLayoutsAvailable, trilist, joinMap);
}
if (codec is IHasSelfviewPosition) if (codec is IHasSelfviewPosition)
{ {
LinkVideoCodecSelfviewPositionToApi(codec as IHasSelfviewPosition, trilist, joinMap); LinkVideoCodecSelfviewPositionToApi(codec as IHasSelfviewPosition, trilist, joinMap);
@@ -1471,6 +1476,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
codec.LocalLayoutFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentLayoutStringFb.JoinNumber]); codec.LocalLayoutFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentLayoutStringFb.JoinNumber]);
} }
private void LinkVideoCodecAvailableLayoutsToApi(IHasCodecLayoutsAvailable codec, BasicTriList trilist,
VideoCodecControllerJoinMap joinMap)
{
codec.AvailableLocalLayoutsFeedback.LinkInputSig(trilist.StringInput[joinMap.AvailableLayoutsFb.JoinNumber]);
trilist.SetStringSigAction(joinMap.SelectLayout.JoinNumber, codec.LocalLayoutSet);
}
private void LinkVideoCodecCameraModeToApi(IHasCameraAutoMode codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) private void LinkVideoCodecCameraModeToApi(IHasCameraAutoMode codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap)
{ {
trilist.SetSigFalseAction(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeOn); trilist.SetSigFalseAction(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeOn);
@@ -1982,4 +1995,19 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
} }
} }
} }
/// <summary>
/// Represents a codec command that might need to have a friendly label applied for UI feedback purposes
/// </summary>
public class CodecCommandWithLabel
{
public string Command { get; private set; }
public string Label { get; private set; }
public CodecCommandWithLabel(string command, string label)
{
Command = command;
Label = label;
}
}
} }