Removes essentials-framework as a submodule and brings the files back into the main repo

This commit is contained in:
Neil Dorin
2019-07-09 17:21:53 -06:00
parent 2cd68d40dc
commit 48c6bb78bc
362 changed files with 54624 additions and 5 deletions

View File

@@ -0,0 +1,379 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class CiscoCodecBookings
{
public class TotalRows
{
public string Value { get; set; }
}
public class ResultInfo
{
public TotalRows TotalRows { get; set; }
}
public class LastUpdated
{
string _value;
public DateTime Value {
get
{
DateTime _valueDateTime;
try
{
_valueDateTime = DateTime.Parse(_value);
return _valueDateTime;
}
catch
{
return new DateTime();
}
}
set
{
_value = value.ToString();
}
}
}
public class Id
{
public string Value { get; set; }
}
public class Title
{
public string Value { get; set; }
}
public class Agenda
{
public string Value { get; set; }
}
public class Privacy
{
public string Value { get; set; }
}
public class FirstName
{
public string Value { get; set; }
}
public class LastName
{
public string Value { get; set; }
}
public class Email
{
public string Value { get; set; }
}
public class Id2
{
public string Value { get; set; }
}
public class Organizer
{
public FirstName FirstName { get; set; }
public LastName LastName { get; set; }
public Email Email { get; set; }
public Id2 Id { get; set; }
public Organizer()
{
FirstName = new FirstName();
LastName = new LastName();
Email = new Email();
}
}
public class StartTime
{
public DateTime Value { get; set; }
}
public class StartTimeBuffer
{
public string Value { get; set; }
}
public class EndTime
{
public DateTime Value { get; set; }
}
public class EndTimeBuffer
{
public string Value { get; set; }
}
public class Time
{
public StartTime StartTime { get; set; }
public StartTimeBuffer StartTimeBuffer { get; set; }
public EndTime EndTime { get; set; }
public EndTimeBuffer EndTimeBuffer { get; set; }
public Time()
{
StartTime = new StartTime();
EndTime = new EndTime();
}
}
public class MaximumMeetingExtension
{
public string Value { get; set; }
}
public class MeetingExtensionAvailability
{
public string Value { get; set; }
}
public class BookingStatus
{
public string Value { get; set; }
}
public class BookingStatusMessage
{
public string Value { get; set; }
}
public class Enabled
{
public string Value { get; set; }
}
public class Url
{
public string Value { get; set; }
}
public class MeetingNumber
{
public string Value { get; set; }
}
public class Password
{
public string Value { get; set; }
}
public class HostKey
{
public string Value { get; set; }
}
public class DialInNumbers
{
}
public class Webex
{
public Enabled Enabled { get; set; }
public Url Url { get; set; }
public MeetingNumber MeetingNumber { get; set; }
public Password Password { get; set; }
public HostKey HostKey { get; set; }
public DialInNumbers DialInNumbers { get; set; }
}
public class Encryption
{
public string Value { get; set; }
}
public class Role
{
public string Value { get; set; }
}
public class Recording
{
public string Value { get; set; }
}
public class Number
{
public string Value { get; set; }
}
public class Protocol
{
public string Value { get; set; }
}
public class CallRate
{
public string Value { get; set; }
}
public class CallType
{
public string Value { get; set; }
}
public class Call
{
public string id { get; set; }
public Number Number { get; set; }
public Protocol Protocol { get; set; }
public CallRate CallRate { get; set; }
public CallType CallType { get; set; }
}
public class Calls
{
public List<Call> Call {get; set;}
}
public class ConnectMode
{
public string Value { get; set; }
}
public class DialInfo
{
public Calls Calls { get; set; }
public ConnectMode ConnectMode { get; set; }
public DialInfo()
{
Calls = new Calls();
ConnectMode = new ConnectMode();
}
}
public class Booking
{
public string id { get; set; }
public Id Id { get; set; }
public Title Title { get; set; }
public Agenda Agenda { get; set; }
public Privacy Privacy { get; set; }
public Organizer Organizer { get; set; }
public Time Time { get; set; }
public MaximumMeetingExtension MaximumMeetingExtension { get; set; }
public MeetingExtensionAvailability MeetingExtensionAvailability { get; set; }
public BookingStatus BookingStatus { get; set; }
public BookingStatusMessage BookingStatusMessage { get; set; }
public Webex Webex { get; set; }
public Encryption Encryption { get; set; }
public Role Role { get; set; }
public Recording Recording { get; set; }
public DialInfo DialInfo { get; set; }
public Booking()
{
Time = new Time();
Id = new Id();
Organizer = new Organizer();
Title = new Title();
Agenda = new Agenda();
Privacy = new Privacy();
DialInfo = new DialInfo();
}
}
public class BookingsListResult
{
public string status { get; set; }
public ResultInfo ResultInfo { get; set; }
//public LastUpdated LastUpdated { get; set; }
public List<Booking> Booking { get; set; }
}
public class CommandResponse
{
public BookingsListResult BookingsListResult { get; set; }
}
public class RootObject
{
public CommandResponse CommandResponse { get; set; }
}
/// <summary>
/// Extracts the necessary meeting values from the Cisco bookings response ans converts them to the generic class
/// </summary>
/// <param name="bookings"></param>
/// <returns></returns>
public static List<Meeting> GetGenericMeetingsFromBookingResult(List<Booking> bookings)
{
var meetings = new List<Meeting>();
if (Debug.Level > 0)
{
Debug.Console(1, "Meetings List:\n");
}
foreach(Booking b in bookings)
{
var meeting = new Meeting();
if(b.Id != null)
meeting.Id = b.Id.Value;
if(b.Organizer != null)
meeting.Organizer = string.Format("{0}, {1}", b.Organizer.LastName.Value, b.Organizer.FirstName.Value);
if(b.Title != null)
meeting.Title = b.Title.Value;
if(b.Agenda != null)
meeting.Agenda = b.Agenda.Value;
if(b.Time != null)
meeting.StartTime = b.Time.StartTime.Value;
meeting.EndTime = b.Time.EndTime.Value;
if(b.Privacy != null)
meeting.Privacy = CodecCallPrivacy.ConvertToDirectionEnum(b.Privacy.Value);
//#warning Update this ConnectMode conversion after testing onsite. Expected value is "OBTP", but in PD NYC Test scenarios, "Manual" is being returned for OBTP meetings
if (b.DialInfo.ConnectMode != null)
if (b.DialInfo.ConnectMode.Value.ToLower() == "obtp" || b.DialInfo.ConnectMode.Value.ToLower() == "manual")
meeting.IsOneButtonToPushMeeting = true;
if (b.DialInfo.Calls.Call != null)
{
foreach (Call c in b.DialInfo.Calls.Call)
{
meeting.Calls.Add(new PepperDash.Essentials.Devices.Common.Codec.Call()
{
Number = c.Number.Value,
Protocol = c.Protocol.Value,
CallRate = c.CallRate.Value,
CallType = c.CallType.Value
});
}
}
meetings.Add(meeting);
if(Debug.Level > 0)
{
Debug.Console(1, "Title: {0}, ID: {1}, Organizer: {2}, Agenda: {3}", meeting.Title, meeting.Id, meeting.Organizer, meeting.Agenda);
Debug.Console(1, " Start Time: {0}, End Time: {1}, Duration: {2}", meeting.StartTime, meeting.EndTime, meeting.Duration);
Debug.Console(1, " Joinable: {0}\n", meeting.Joinable);
}
}
meetings.OrderBy(m => m.StartTime);
return meetings;
}
}
}

View File

@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class CiscoCallHistory
{
public class CallbackNumber
{
public string Value { get; set; }
}
public class DisplayName
{
public string Value { get; set; }
}
public class LastOccurrenceStartTime
{
public DateTime Value { get; set; }
}
public class LastOccurrenceDaysAgo
{
public string Value { get; set; }
}
public class LastOccurrenceHistoryId
{
public string Value { get; set; }
}
public class OccurrenceType
{
public string Value { get; set; }
}
public class IsAcknowledged
{
public string Value { get; set; }
}
public class OccurrenceCount
{
public string Value { get; set; }
}
public class Entry
{
public string id { get; set; }
public CallbackNumber CallbackNumber { get; set; }
public DisplayName DisplayName { get; set; }
public LastOccurrenceStartTime LastOccurrenceStartTime { get; set; }
public LastOccurrenceDaysAgo LastOccurrenceDaysAgo { get; set; }
public LastOccurrenceHistoryId LastOccurrenceHistoryId { get; set; }
public OccurrenceType OccurrenceType { get; set; }
public IsAcknowledged IsAcknowledged { get; set; }
public OccurrenceCount OccurrenceCount { get; set; }
}
public class Offset
{
public string Value { get; set; }
}
public class Limit
{
public string Value { get; set; }
}
public class ResultInfo
{
public Offset Offset { get; set; }
public Limit Limit { get; set; }
}
public class CallHistoryRecentsResult
{
public string status { get; set; }
public List<Entry> Entry { get; set; }
public ResultInfo ResultInfo { get; set; }
}
public class CommandResponse
{
public CallHistoryRecentsResult CallHistoryRecentsResult { get; set; }
}
public class RootObject
{
public CommandResponse CommandResponse { get; set; }
}
}
}

View File

@@ -0,0 +1,312 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Devices.Common.Cameras;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
public class CiscoFarEndCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera
{
protected CiscoSparkCodec ParentCodec { get; private set; }
protected string CallId {
get
{
return (ParentCodec as CiscoSparkCodec).GetCallId();
}
}
public CiscoFarEndCamera(string key, string name, CiscoSparkCodec codec)
: base(key, name)
{
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom;
ParentCodec = codec;
}
#region IHasCameraPtzControl Members
public void PositionHome()
{
// Not supported on far end camera
}
#endregion
#region IHasCameraPanControl Members
public void PanLeft()
{
ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Move Value: Left CallId: {0}", CallId));
}
public void PanRight()
{
ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Move Value: Right CallId: {0}", CallId));
}
public void PanStop()
{
Stop();
}
#endregion
#region IHasCameraTiltControl Members
public void TiltDown()
{
ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Move Value: Down CallId: {0}", CallId));
}
public void TiltUp()
{
ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Move Value: Up CallId: {0}", CallId));
}
public void TiltStop()
{
Stop();
}
#endregion
#region IHasCameraZoomControl Members
public void ZoomIn()
{
ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomIn CallId: {0}", CallId));
}
public void ZoomOut()
{
ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomOut CallId: {0}", CallId));
}
public void ZoomStop()
{
Stop();
}
#endregion
void Stop()
{
ParentCodec.SendText(string.Format("xCommand Call FarEndControl Camera Stop CallId: {0}", CallId));
}
}
public class CiscoSparkCamera : CameraBase, IHasCameraPtzControl, IHasCameraFocusControl
{
/// <summary>
/// The codec this camera belongs to
/// </summary>
protected CiscoSparkCodec ParentCodec { get; private set; }
/// <summary>
/// The ID of the camera on the codec
/// </summary>
protected uint CameraId { get; private set; }
/// <summary>
/// Valid range 1-15
/// </summary>
protected uint PanSpeed { get; private set; }
/// <summary>
/// Valid range 1-15
/// </summary>
protected uint TiltSpeed { get; private set; }
/// <summary>
/// Valid range 1-15
/// </summary>
protected uint ZoomSpeed { get; private set; }
private bool isPanning;
private bool isTilting;
private bool isZooming;
private bool isFocusing;
private bool isMoving
{
get
{
return isPanning || isTilting || isZooming || isFocusing;
}
}
public CiscoSparkCamera(string key, string name, CiscoSparkCodec codec, uint id)
: base(key, name)
{
// Default to all capabilties
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;
ParentCodec = codec;
CameraId = id;
// Set default speeds
PanSpeed = 7;
TiltSpeed = 7;
ZoomSpeed = 7;
}
// Takes a string from the camera capabilities value and converts from "ptzf" to enum bitmask
public void SetCapabilites(string capabilites)
{
var c = capabilites.ToLower();
if (c.Contains("p"))
Capabilities = Capabilities | eCameraCapabilities.Pan;
if (c.Contains("t"))
Capabilities = Capabilities | eCameraCapabilities.Tilt;
if (c.Contains("z"))
Capabilities = Capabilities | eCameraCapabilities.Zoom;
if (c.Contains("f"))
Capabilities = Capabilities | eCameraCapabilities.Focus;
}
#region IHasCameraPtzControl Members
public void PositionHome()
{
// Not supported on Internal Spark Camera
}
#endregion
#region IHasCameraPanControl Members
public void PanLeft()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Pan: Left PanSpeed: {1}", CameraId, PanSpeed));
isPanning = true;
}
}
public void PanRight()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Pan: Right PanSpeed: {1}", CameraId, PanSpeed));
isPanning = true;
}
}
public void PanStop()
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Pan: Stop", CameraId));
isPanning = false;
}
#endregion
#region IHasCameraTiltControl Members
public void TiltDown()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Tilt: Down TiltSpeed: {1}", CameraId, TiltSpeed));
isTilting = true;
}
}
public void TiltUp()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Tilt: Up TiltSpeed: {1}", CameraId, TiltSpeed));
isTilting = true;
}
}
public void TiltStop()
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Tilt: Stop", CameraId));
isTilting = false;
}
#endregion
#region IHasCameraZoomControl Members
public void ZoomIn()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Zoom: In ZoomSpeed: {1}", CameraId, ZoomSpeed));
isZooming = true;
}
}
public void ZoomOut()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Zoom: Out ZoomSpeed: {1}", CameraId, ZoomSpeed));
isZooming = true;
}
}
public void ZoomStop()
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Zoom: Stop", CameraId));
isZooming = false;
}
#endregion
#region IHasCameraFocusControl Members
public void FocusNear()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Focus: Near", CameraId));
isFocusing = true;
}
}
public void FocusFar()
{
if (!isMoving)
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Focus: Far", CameraId));
isFocusing = true;
}
}
public void FocusStop()
{
ParentCodec.SendText(string.Format("xCommand Camera Ramp CameraId: {0} Focus: Stop", CameraId));
isFocusing = false;
}
public void TriggerAutoFocus()
{
ParentCodec.SendText(string.Format("xCommand Camera TriggerAutofocus CameraId: {0}", CameraId));
}
#endregion
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public class CiscoSparkCodecPropertiesConfig
{
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public List<CodecActiveCallItem> Favorites { get; set; }
/// <summary>
/// Valid values: "Local" or "Corporate"
/// </summary>
public string PhonebookMode { get; set; }
public bool ShowSelfViewByDefault { get; set; }
public SharingProperties Sharing { get; set; }
}
public class SharingProperties
{
public bool AutoShareContentWhileInCall { get; set; }
}
}

View File

@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Net.Http;
using PepperDash.Core;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
public class HttpApiServer
{
public static Dictionary<string, string> ExtensionContentTypes;
public event EventHandler<OnHttpRequestArgs> ApiRequest;
public Crestron.SimplSharp.Net.Http.HttpServer HttpServer { get; private set; }
public string HtmlRoot { get; set; }
/// <summary>
/// SIMPL+ can only execute the default constructor. If you have variables that require initialization, please
/// use an Initialize method
/// </summary>
public HttpApiServer()
{
ExtensionContentTypes = new Dictionary<string, string>
{
{ ".css", "text/css" },
{ ".htm", "text/html" },
{ ".html", "text/html" },
{ ".jpg", "image/jpeg" },
{ ".jpeg", "image/jpeg" },
{ ".js", "application/javascript" },
{ ".json", "application/json" },
{ ".xml", "text/xml" },
{ ".map", "application/x-navimap" },
{ ".pdf", "application.pdf" },
{ ".png", "image/png" },
{ ".txt", "text/plain" },
};
HtmlRoot = @"\HTML";
}
public void Start(int port)
{
// TEMP - this should be inserted by configuring class
HttpServer = new Crestron.SimplSharp.Net.Http.HttpServer();
HttpServer.ServerName = "Cisco API Server";
HttpServer.KeepAlive = true;
HttpServer.Port = port;
HttpServer.OnHttpRequest += Server_Request;
HttpServer.Open();
CrestronEnvironment.ProgramStatusEventHandler += (a) =>
{
if (a == eProgramStatusEventType.Stopping)
{
HttpServer.Close();
Debug.Console(1, "Shutting down HTTP Server on port {0}", HttpServer.Port);
}
};
}
void Server_Request(object sender, OnHttpRequestArgs args)
{
if (args.Request.Header.RequestType == "OPTIONS")
{
Debug.Console(2, "Asking for OPTIONS");
args.Response.Header.SetHeaderValue("Access-Control-Allow-Origin", "*");
args.Response.Header.SetHeaderValue("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS");
return;
}
string path = Uri.UnescapeDataString(args.Request.Path);
var host = args.Request.DataConnection.RemoteEndPointAddress;
//string authToken;
Debug.Console(2, "HTTP Request: {2}: Path='{0}' ?'{1}'", path, args.Request.QueryString, host);
// ----------------------------------- ADD AUTH HERE
if (path.StartsWith("/cisco/api"))
{
var handler = ApiRequest;
if (ApiRequest != null)
ApiRequest(this, args);
}
}
public static string GetContentType(string extension)
{
string type;
if (ExtensionContentTypes.ContainsKey(extension))
type = ExtensionContentTypes[extension];
else
type = "text/plain";
return type;
}
}
}

View File

@@ -0,0 +1,397 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
public class CiscoCodecPhonebook
{
public class Offset
{
public string Value { get; set; }
}
public class Limit
{
public string Value { get; set; }
}
public class TotalRows
{
public string Value { get; set; }
}
public class ResultInfo
{
public Offset Offset { get; set; }
public Limit Limit { get; set; }
public TotalRows TotalRows { get; set; }
}
public class LocalId
{
public string Value { get; set; }
}
public class FolderId
{
public string Value { get; set; }
}
public class ParentFolderId
{
public string Value { get; set; }
}
public class Name
{
public string Value { get; set; }
}
public class Folder
{
public string id { get; set; }
public LocalId LocalId { get; set; }
public FolderId FolderId { get; set; }
public Name Name { get; set; }
public ParentFolderId ParentFolderId { get; set; }
}
public class Name2
{
public string Value { get; set; }
}
public class ContactId
{
public string Value { get; set; }
}
public class FolderId2
{
public string Value { get; set; }
}
public class Title
{
public string Value { get; set; }
}
public class ContactMethodId
{
public string Value { get; set; }
}
public class Number
{
public string Value { get; set; }
}
public class Device
{
public string Value { get; set; }
}
public class CallType
{
public string Value { get; set; }
}
public class ContactMethod
{
public string id { get; set; }
public ContactMethodId ContactMethodId { get; set; }
public Number Number { get; set; }
public Device Device { get; set; }
public CallType CallType { get; set; }
public ContactMethod()
{
ContactMethodId = new ContactMethodId();
Number = new Number();
Device = new Device();
CallType = new CallType();
}
}
public class Contact
{
public string id { get; set; }
public Name2 Name { get; set; }
public ContactId ContactId { get; set; }
public FolderId2 FolderId { get; set; }
public Title Title { get; set; }
public List<ContactMethod> ContactMethod { get; set; }
public Contact()
{
Name = new Name2();
ContactId = new ContactId();
FolderId = new FolderId2();
Title = new Title();
ContactMethod = new List<ContactMethod>();
}
}
public class PhonebookSearchResult
{
public string status { get; set; }
public ResultInfo ResultInfo { get; set; }
public List<Folder> Folder { get; set; }
public List<Contact> Contact { get; set; }
public PhonebookSearchResult()
{
Folder = new List<Folder>();
Contact = new List<Contact>();
ResultInfo = new ResultInfo();
}
}
public class CommandResponse
{
public PhonebookSearchResult PhonebookSearchResult { get; set; }
}
public class RootObject
{
public CommandResponse CommandResponse { get; set; }
}
/// <summary>
/// Extracts the folders with no ParentFolder and returns them sorted alphabetically
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
public static List<DirectoryItem> GetRootFoldersFromSearchResult(PhonebookSearchResult result)
{
var rootFolders = new List<DirectoryItem>();
if (result.Folder.Count == 0)
{
return null;
}
else if (result.Folder.Count > 0)
{
if (Debug.Level > 0)
Debug.Console(1, "Phonebook Folders:\n");
foreach (Folder f in result.Folder)
{
var folder = new DirectoryFolder();
folder.Name = f.Name.Value;
folder.FolderId = f.FolderId.Value;
if (f.ParentFolderId == null)
rootFolders.Add(folder);
if (Debug.Level > 0)
Debug.Console(1, "+ {0}", folder.Name);
}
}
rootFolders.OrderBy(f => f.Name);
return rootFolders;
}
/// <summary>
/// Extracts the contacts with no FolderId and returns them sorted alphabetically
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
public static List<DirectoryItem> GetRootContactsFromSearchResult(PhonebookSearchResult result)
{
var rootContacts = new List<DirectoryItem>();
if (result.Contact.Count == 0)
{
return null;
}
else if (result.Contact.Count > 0)
{
if (Debug.Level > 0)
Debug.Console(1, "Root Contacts:\n");
foreach (Contact c in result.Contact)
{
var contact = new DirectoryContact();
if (string.IsNullOrEmpty(c.FolderId.Value))
{
contact.Name = c.Name.Value;
contact.ContactId = c.ContactId.Value;
if(!string.IsNullOrEmpty(c.Title.Value))
contact.Title = c.Title.Value;
if (Debug.Level > 0)
Debug.Console(1, "{0}\nContact Methods:", contact.Name);
foreach (ContactMethod m in c.ContactMethod)
{
var tempContactMethod = new PepperDash.Essentials.Devices.Common.Codec.ContactMethod();
eContactMethodCallType callType = eContactMethodCallType.Unknown;
if (!string.IsNullOrEmpty(m.CallType.Value))
{
if (!string.IsNullOrEmpty(m.CallType.Value))
{
if (m.CallType.Value.ToLower() == "audio")
callType = eContactMethodCallType.Audio;
else if (m.CallType.Value.ToLower() == "video")
callType = eContactMethodCallType.Video;
tempContactMethod.CallType = callType;
}
}
eContactMethodDevice device = eContactMethodDevice.Unknown;
if (!string.IsNullOrEmpty(m.Device.Value))
{
if (m.Device.Value.ToLower() == "mobile")
device = eContactMethodDevice.Mobile;
else if (m.Device.Value.ToLower() == "telephone")
device = eContactMethodDevice.Telephone;
else if (m.Device.Value.ToLower() == "video")
device = eContactMethodDevice.Video;
else if (m.Device.Value.ToLower() == "other")
device = eContactMethodDevice.Other;
tempContactMethod.Device = device;
}
if (Debug.Level > 0)
Debug.Console(1, "Number: {0}", m.Number.Value);
tempContactMethod.Number = m.Number.Value;
tempContactMethod.ContactMethodId = m.ContactMethodId.Value;
contact.ContactMethods.Add(tempContactMethod);
}
rootContacts.Add(contact);
}
}
}
rootContacts.OrderBy(f => f.Name);
return rootContacts;
}
/// <summary>
/// Converts data returned from a cisco codec to the generic Directory format.
/// </summary>
/// <param name="result"></param>
/// <param name="resultFolder"></param>
/// <returns></returns>
public static CodecDirectory ConvertCiscoPhonebookToGeneric(PhonebookSearchResult result)
{
var directory = new Codec.CodecDirectory();
var folders = new List<Codec.DirectoryItem>();
var contacts = new List<Codec.DirectoryItem>();
try
{
if (result.Folder.Count > 0)
{
foreach (Folder f in result.Folder)
{
var folder = new DirectoryFolder();
folder.Name = f.Name.Value;
folder.FolderId = f.FolderId.Value;
if (f.ParentFolderId != null)
{
folder.ParentFolderId = f.ParentFolderId.Value;
}
folders.Add(folder);
}
folders.OrderBy(f => f.Name);
directory.AddFoldersToDirectory(folders);
}
if (result.Contact.Count > 0)
{
foreach (Contact c in result.Contact)
{
var contact = new DirectoryContact();
contact.Name = c.Name.Value;
contact.ContactId = c.ContactId.Value;
if (!string.IsNullOrEmpty(c.Title.Value))
contact.Title = c.Title.Value;
if (c.FolderId != null)
{
contact.FolderId = c.FolderId.Value;
}
foreach (ContactMethod m in c.ContactMethod)
{
eContactMethodCallType callType = eContactMethodCallType.Unknown;
if (!string.IsNullOrEmpty(m.CallType.Value))
{
if (m.CallType.Value.ToLower() == "audio")
callType = eContactMethodCallType.Audio;
else if (m.CallType.Value.ToLower() == "video")
callType = eContactMethodCallType.Video;
}
eContactMethodDevice device = eContactMethodDevice.Unknown;
if (!string.IsNullOrEmpty(m.Device.Value))
{
if (m.Device.Value.ToLower() == "mobile")
device = eContactMethodDevice.Mobile;
else if (m.Device.Value.ToLower() == "telephone")
device = eContactMethodDevice.Telephone;
else if (m.Device.Value.ToLower() == "video")
device = eContactMethodDevice.Video;
else if (m.Device.Value.ToLower() == "other")
device = eContactMethodDevice.Other;
}
contact.ContactMethods.Add(new PepperDash.Essentials.Devices.Common.Codec.ContactMethod()
{
Number = m.Number.Value,
ContactMethodId = m.ContactMethodId.Value,
CallType = callType,
Device = device
});
}
contacts.Add(contact);
}
contacts.OrderBy(c => c.Name);
directory.AddContactsToDirectory(contacts);
}
}
catch (Exception e)
{
Debug.Console(1, "Error converting Cisco Phonebook results to generic: {0}", e);
}
return directory;
}
}
}

View File

@@ -0,0 +1,100 @@
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
{
/// <summary>
/// Interface for camera presets
/// </summary>
public interface IHasCodecRoomPresets
{
event EventHandler<EventArgs> CodecRoomPresetsListHasChanged;
List<CodecRoomPreset> NearEndPresets { get; }
List<CodecRoomPreset> FarEndRoomPresets { get; }
void CodecRoomPresetSelect(int preset);
void CodecRoomPresetStore(int preset, string description);
}
public static class RoomPresets
{
/// <summary>
/// Converts Cisco RoomPresets to generic CameraPresets
/// </summary>
/// <param name="presets"></param>
/// <returns></returns>
public static List<CodecRoomPreset> GetGenericPresets(List<CiscoCodecStatus.RoomPreset> presets)
{
var cameraPresets = new List<CodecRoomPreset>();
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;
}
}
/// <summary>
/// Represents a room preset on a video coded. Typically stores camera position(s) and video routing. Can be recalled by Far End if enabled.
/// </summary>
public class CodecRoomPreset
{
[JsonProperty("id")]
public int ID { get; set; }
/// <summary>
/// Used to store the name of the preset
/// </summary>
[JsonProperty("description")]
public string Description { get; set; }
/// <summary>
/// Indicates if the preset is defined(stored) in the codec
/// </summary>
[JsonProperty("defined")]
public bool Defined { get; set; }
/// <summary>
/// Indicates if the preset has the capability to be defined
/// </summary>
[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;
}
}
}

View File

@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
/// <summary>
/// This class exists to capture serialized data sent back by a Cisco codec in JSON output mode
/// </summary>
public class CiscoCodecEvents
{
public class CauseValue
{
public string id { get; set; }
public string Value { get; set; }
}
public class CauseType
{
public string id { get; set; }
public string Value { get; set; }
}
public class CauseString
{
public string id { get; set; }
public string Value { get; set; }
}
public class OrigCallDirection
{
public string id { get; set; }
public string Value { get; set; }
}
public class RemoteURI
{
public string id { get; set; }
public string Value { get; set; }
}
public class DisplayName
{
public string id { get; set; }
public string Value { get; set; }
}
public class CallId
{
public string id { get; set; }
public string Value { get; set; }
}
public class CauseCode
{
public string id { get; set; }
public string Value { get; set; }
}
public class CauseOrigin
{
public string id { get; set; }
public string Value { get; set; }
}
public class Protocol
{
public string id { get; set; }
public string Value { get; set; }
}
public class Duration
{
public string id { get; set; }
public string Value { get; set; }
}
public class CallType
{
public string id { get; set; }
public string Value { get; set; }
}
public class CallRate
{
public string id { get; set; }
public string Value { get; set; }
}
public class Encryption
{
public string id { get; set; }
public string Value { get; set; }
}
public class RequestedURI
{
public string id { get; set; }
public string Value { get; set; }
}
public class PeopleCountAverage
{
public string id { get; set; }
public string Value { get; set; }
}
public class CallDisconnect
{
public string id { get; set; }
public CauseValue CauseValue { get; set; }
public CauseType CauseType { get; set; }
public CauseString CauseString { get; set; }
public OrigCallDirection OrigCallDirection { get; set; }
public RemoteURI RemoteURI { get; set; }
public DisplayName DisplayName { get; set; }
public CallId CallId { get; set; }
public CauseCode CauseCode { get; set; }
public CauseOrigin CauseOrigin { get; set; }
public Protocol Protocol { get; set; }
public Duration Duration { get; set; }
public CallType CallType { get; set; }
public CallRate CallRate { get; set; }
public Encryption Encryption { get; set; }
public RequestedURI RequestedURI { get; set; }
public PeopleCountAverage PeopleCountAverage { get; set; }
}
public class Event
{
public CallDisconnect CallDisconnect { get; set; }
}
public class RootObject
{
public Event Event { get; set; }
}
}
}