using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
///
/// Interface for camera presets
///
public interface IHasCodecRoomPresets
{
event EventHandler CodecRoomPresetsListHasChanged;
List NearEndPresets { get; }
List FarEndRoomPresets { get; }
void CodecRoomPresetSelect(int preset);
void CodecRoomPresetStore(int preset, string description);
}
public static class RoomPresets
{
///
/// Converts Cisco RoomPresets to generic CameraPresets
///
///
///
public static List GetGenericPresets(List presets)
{
var cameraPresets = new 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;
}
}
///
/// Represents a room preset on a video coded. Typically stores camera position(s) and video routing. Can be recalled by Far End if enabled.
///
public class CodecRoomPreset
{
[JsonProperty("id")]
public int ID { get; set; }
///
/// Used to store the name of the preset
///
[JsonProperty("description")]
public string Description { get; set; }
///
/// Indicates if the preset is defined(stored) in the codec
///
[JsonProperty("defined")]
public bool Defined { get; set; }
///
/// Indicates if the preset has the capability to be defined
///
[JsonProperty("isDefinable")]
public bool IsDefinable { get; set; }
public CodecRoomPreset(int id, string description, bool def, bool isDef)
{
ID = id;
Description = description;
Defined = def;
IsDefinable = isDef;
}
}
}