Skip to content

Commit

Permalink
walked back changes to OBTP xSig
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Payne committed Oct 19, 2022
1 parent c140620 commit 966385a
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 62 deletions.
38 changes: 38 additions & 0 deletions src/CiscoCodecRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace epi_videoCodec_ciscoExtended
{

public class CiscoCodecJsonRpc
{
[JsonProperty("jsonrpc")]
public string JsonRpc { get; private set; }

[JsonProperty("id")]
public int Id { get; private set; }

[JsonProperty("method")]
public string Method { get; private set; }

[JsonProperty("params")]
public JToken Params { get; private set; }

public CiscoCodecJsonRpc(string method, JToken parameters)
{
JsonRpc = "2.0";
Method = method;
Params = parameters;
}

public void SetId(int id)
{
Id = id;
}
}
}
79 changes: 17 additions & 62 deletions src/CiscoRoomOsCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public enum eCameraTrackingCapabilities




public class CiscoCodec : VideoCodecBase, IHasCallHistory, IHasCallFavorites, IHasDirectory,
IHasScheduleAwareness, IOccupancyStatusProvider, IHasCodecLayoutsAvailable, IHasCodecSelfView,
ICommunicationMonitor, IRouting, IHasCodecCameras, IHasCameraAutoMode, IHasCodecRoomPresets,
Expand Down Expand Up @@ -842,8 +843,8 @@ private void CiscoCodec_CallStatusChange(object sender, CodecCallStatusItemChang
private string UpdateActiveMeetingXSig(Meeting currentMeeting)
{
//const int _meetingsToDisplay = 3;
const int maxDigitals = 4;
const int maxStrings = 14;
const int maxDigitals = 3;
const int maxStrings = 8;
const int offset = maxDigitals + maxStrings;
const int digitalIndex = maxStrings; //15
const int stringIndex = 0;
Expand Down Expand Up @@ -871,7 +872,6 @@ private string UpdateActiveMeetingXSig(Meeting currentMeeting)
* IsJoinable - 1
* IsDialable - 2
* IsAvailable - 3
* Following Meeting Present - 4
*
* Serials
* Organizer - 1
Expand All @@ -882,24 +882,12 @@ private string UpdateActiveMeetingXSig(Meeting currentMeeting)
* End Time - 6
* OrganizerId - 7
* Active "StartTime - EndTime" - 8
* TimeRemaining Text - 9
* TimeRemaining MinutesRemaining Text - 10
* TimeRemaining MinutesRemaining Analog - 11
* TimeToFollowingMeeting Text - 12
* TimeToFollowingMeeting Minutes Analog - 13
* TimeOfFollowingMeeting - 14
*/
try
{
if (meeting != null)
{
var timeRemaining = meeting.StartTime - DateTime.Now;
var timeRemaingToNext = nextMeeting != null
? (nextMeeting.StartTime - DateTime.Now).ToString()
: "None Scheduled";
//digitals
if (!nextMeetingOnly)
{
tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, meeting.Joinable);
tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, meeting.Id != "0");
tokenArray[digitalIndex + 2] = new XSigDigitalToken(digitalIndex + 3, true);
Expand All @@ -919,47 +907,7 @@ private string UpdateActiveMeetingXSig(Meeting currentMeeting)
tokenArray[stringIndex + 7] = new XSigSerialToken(stringIndex + 8, String.Format("{0} - {1}",
meeting.StartTime.ToString(_timeFormatSpecifier, Global.Culture),
meeting.EndTime.ToString(_timeFormatSpecifier, Global.Culture)));
tokenArray[stringIndex + 8] = new XSigSerialToken(stringIndex + 9, String.Format("{0}",
timeRemaining.ToString()));
tokenArray[stringIndex + 9] = new XSigSerialToken(stringIndex + 10, String.Format("{0}",
timeRemaining.Minutes.ToString(CultureInfo.InvariantCulture)));
tokenArray[stringIndex + 10] = new XSigAnalogToken(stringIndex + 11,
(ushort)timeRemaining.Minutes);

}
else
{
tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, false);
tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, false);
tokenArray[digitalIndex + 2] = new XSigDigitalToken(digitalIndex + 3, false);


tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, String.Empty);
tokenArray[stringIndex + 1] = new XSigSerialToken(stringIndex + 2, String.Empty);
tokenArray[stringIndex + 2] = new XSigSerialToken(stringIndex + 3,
String.Empty);
tokenArray[stringIndex + 3] = new XSigSerialToken(stringIndex + 4, String.Empty);
tokenArray[stringIndex + 4] = new XSigSerialToken(stringIndex + 5, String.Empty);
tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, String.Empty);
tokenArray[stringIndex + 6] = new XSigSerialToken(stringIndex + 7, String.Empty);
tokenArray[stringIndex + 7] = new XSigSerialToken(stringIndex + 8, String.Empty);
tokenArray[stringIndex + 8] = new XSigSerialToken(stringIndex + 9, String.Empty);
tokenArray[stringIndex + 9] = new XSigSerialToken(stringIndex + 10, String.Empty);
tokenArray[stringIndex + 10] = new XSigAnalogToken(stringIndex + 11,
0);

}

//These are constant, no matter what!
tokenArray[digitalIndex + 3] = new XSigDigitalToken(digitalIndex + 4, nextMeeting != null);
tokenArray[stringIndex + 11] = new XSigSerialToken(stringIndex + 12,
timeRemaingToNext);
tokenArray[stringIndex + 12] = new XSigAnalogToken(stringIndex + 13,
nextMeeting != null ? (ushort)(nextMeeting.StartTime - DateTime.Now).Minutes : (ushort)0);
tokenArray[stringIndex + 13] = new XSigSerialToken(stringIndex + 14,
nextMeeting != null
? nextMeeting.StartTime.ToString(_timeFormatSpecifier, Global.Culture)
: "None Scheduled");
}

else
Expand All @@ -982,12 +930,6 @@ private string UpdateActiveMeetingXSig(Meeting currentMeeting)
tokenArray[stringIndex + 5] = new XSigSerialToken(stringIndex + 6, String.Empty);
tokenArray[stringIndex + 6] = new XSigSerialToken(stringIndex + 7, String.Empty);
tokenArray[stringIndex + 7] = new XSigSerialToken(stringIndex + 8, String.Empty);
tokenArray[stringIndex + 8] = new XSigSerialToken(stringIndex + 9, String.Empty);
tokenArray[stringIndex + 9] = new XSigSerialToken(stringIndex + 10, String.Empty);
tokenArray[stringIndex + 10] = new XSigAnalogToken(stringIndex + 11, 0);
tokenArray[stringIndex + 11] = new XSigSerialToken(stringIndex + 12, String.Empty);
tokenArray[stringIndex + 12] = new XSigAnalogToken(stringIndex + 13, 0);
tokenArray[stringIndex + 13] = new XSigSerialToken(stringIndex + 14, String.Empty);

}

Expand Down Expand Up @@ -1985,7 +1927,6 @@ private void ParseCallObjectList(ICollection<CiscoCodecStatus.Call> calls, IColl

if (tempActiveCall.Status == eCodecCallStatus.Connected)
{

GetCallHistory();
}

Expand Down Expand Up @@ -5260,6 +5201,20 @@ public CiscoCodecInfo(CiscoCodec codec)

}

public static class ExtensionsMethods
{
public static string EncodeBase64(this string plainText)
{
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
return Convert.ToBase64String(plainTextBytes);
}

public static string DecodeBase64(this string encodedText)
{
var encodedTextBytes = Encoding.UTF8.GetBytes(encodedText);
return Convert.ToString(encodedTextBytes);
}
}

}

Expand Down
72 changes: 72 additions & 0 deletions src/CiscoWebsocketClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronWebSocketClient;
using Crestron.SimplSharp.Net;
using Crestron.SimplSharp.Net.Http;
using Crestron.SimplSharp.Net.Https;
using Crestron.SimplSharpPro.DM.Endpoints;
using PepperDash.Core;
using RequestType = Crestron.SimplSharp.Net.Https.RequestType;

namespace epi_videoCodec_ciscoExtended
{
public class CiscoWebsocketClient : IKeyed
{
public int IdTracker { get; private set; }
private readonly HttpsClient _client;
public string Key { get; private set; }
private readonly CrestronQueue<Action> _requestQueue = new CrestronQueue<Action>(20);
private readonly ControlPropertiesConfig _config;

public CiscoWebsocketClient(string key, ControlPropertiesConfig controlConfig)
{
if (string.IsNullOrEmpty(key) || controlConfig == null)
{
Debug.Console(0, "WebSocketClient key or Host is null or empty - failed to instantiate websocket client" );
return;
}
_config = controlConfig;

if (string.IsNullOrEmpty(controlConfig.TcpSshProperties.Username) ||
string.IsNullOrEmpty(controlConfig.TcpSshProperties.Password))
{
Debug.Console(0, "WebsocketClient has no login information - failed to instantiate websocked client");
return;
}

Key = string.Format("{0}-{1}-websocket", key, _config.Method).ToLower();

_client = new HttpsClient
{
IncludeHeaders = true,
};
}

/*
public void SendRequest(CiscoCodecJsonRpc data)
{
var request = new HttpsClientRequest
{
RequestType = RequestType.Get,
Url = new UrlParser(string.Format("wss://{0}/ws", _config.TcpSshProperties.Address)),
};
request.KeepAlive = true;
request.Header.SetHeaderValue("Authorization", String.Format("Basic {0}",
String.Format("{0}:{1}", _config.TcpSshProperties.Username, _config.TcpSshProperties.Password)
.EncodeBase64()));
request.Header.SetHeaderValue("Connection", "Upgrader");
request.Header.SetHeaderValue("Upgrade", "websocket");
request.Header.
}
* */
}





}
2 changes: 2 additions & 0 deletions src/epi-videoCodec-ciscoExtended.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@
<Compile Include="CiscoCodecJoinMap.cs" />
<Compile Include="CiscoCodecPhonebookDataClasses.cs" />
<Compile Include="CiscoCamera.cs" />
<Compile Include="CiscoCodecRequest.cs" />
<Compile Include="CiscoRoomOsCodec.cs" />
<Compile Include="CiscoCodecConfig.cs" />
<Compile Include="CiscoWebsocketClient.cs" />
<Compile Include="CodecSyncState.cs" />
<Compile Include="HttpApiServerExtended.cs" />
<Compile Include="IHasCiscoCodecLayouts.cs" />
Expand Down

0 comments on commit 966385a

Please sign in to comment.