-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,707 additions
and
1,227 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
Revelator.io24.Api/Configuration/ServiceProviderExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Revelator.io24.Api.Models; | ||
using Revelator.io24.Api.Services; | ||
|
||
namespace Revelator.io24.Api.Configuration | ||
{ | ||
public static class ServiceProviderExtension | ||
{ | ||
public static void AddRevelatorAPI(this IServiceCollection serviceCollection) | ||
{ | ||
//Services: | ||
serviceCollection.AddSingleton<BroadcastService>(); | ||
serviceCollection.AddSingleton<CommunicationService>(); | ||
serviceCollection.AddSingleton<MonitorService>(); | ||
|
||
//Models: | ||
serviceCollection.AddSingleton<RoutingModel>(); | ||
serviceCollection.AddSingleton<MicrophoneModel>(); | ||
serviceCollection.AddSingleton<FatChannelMonitorModel>(); | ||
serviceCollection.AddSingleton<ValuesMonitorModel>(); | ||
|
||
//API: | ||
serviceCollection.AddSingleton<RoutingTable>(); | ||
serviceCollection.AddSingleton<Microphones>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
namespace Revelator.io24.Api.Enums | ||
using System.ComponentModel; | ||
|
||
namespace Revelator.io24.Api.Enums | ||
{ | ||
//TODO: This can be changed to Output. | ||
public enum Headphones : ushort | ||
{ | ||
//Route: "global/phonesSrc" | ||
Unknown = ushort.MaxValue, | ||
//TODO: Not ushort, but uint (should add 2 zero bytes): | ||
|
||
[Description("Main")] | ||
Main = 0, // 0: 0x00, 0x00, 0x00, 0x00, 0.0f | ||
|
||
[Description("Stream Mix A")] | ||
MixA = 16128, //16128: 0x00, 0x00, 0x00, 0x3F, 0.5f | ||
|
||
[Description("Stream Mix B")] | ||
MixB = 16256 //16256: 0x00, 0x00, 0x80, 0x3F, 1.0f | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Revelator.io24.Api.Enums | ||
{ | ||
public enum Value | ||
{ | ||
On, | ||
Off, | ||
Toggle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System.Text; | ||
using System.Text.Json; | ||
|
||
namespace Revelator.io24.Api.Messages | ||
{ | ||
public class TcpMessageWriter | ||
{ | ||
private readonly ushort _deviceId; | ||
|
||
public TcpMessageWriter(ushort deviceId) | ||
{ | ||
_deviceId = deviceId; | ||
} | ||
|
||
public byte[] CreateClientInfoMessage() | ||
{ | ||
var data = CreateHeader(_deviceId); | ||
|
||
var json = JsonSerializer.Serialize(new | ||
{ | ||
id = "Subscribe", | ||
clientName = "UC-Surface", | ||
clientInternalName = "ucremoteapp", | ||
clientType = "CustomAPI", | ||
clientDescription = "CustomAPI for Revelator io24", | ||
clientIdentifier = "661b1ece-b4d3-44b3-913c-d12964456f0b", | ||
clientOptions = "perm users", | ||
clientEncoding = 23117 | ||
}); | ||
|
||
//JsonLength [12..16]: | ||
data.AddRange(BitConverter.GetBytes(json.Length)); | ||
|
||
//Json [16..] | ||
data.AddRange(Encoding.ASCII.GetBytes(json)); | ||
|
||
return Create(data, "JM"); | ||
} | ||
|
||
public byte[] CreateKeepAliveMessage() | ||
{ | ||
var data = CreateHeader(_deviceId); | ||
|
||
return Create(data, "KA"); | ||
} | ||
|
||
public byte[] CreateWelcomeMessage(ushort monitorPort) | ||
{ | ||
var data = CreateHeader(_deviceId); | ||
|
||
//Port [12..14]: | ||
data.AddRange(BitConverter.GetBytes(monitorPort)); | ||
|
||
return Create(data, "UM"); | ||
} | ||
|
||
public byte[] CreateRouteUpdate(string route, float value) | ||
{ | ||
var data = CreateHeader(_deviceId); | ||
|
||
//Text [12..x]: | ||
data.AddRange(Encoding.ASCII.GetBytes(route)); | ||
|
||
//Empty [0..3]: | ||
data.AddRange(new byte[] { 0x00, 0x00, 0x00 }); | ||
|
||
//State [x+3..x+7]: | ||
data.AddRange(BitConverter.GetBytes(value)); | ||
|
||
return Create(data, "PV"); | ||
} | ||
|
||
private static byte[] Create(List<byte> data, string messageType) | ||
{ | ||
//Length [4..6]: | ||
var length = (ushort)(data.Count - 6); | ||
var lengthBytes = BitConverter.GetBytes(length); | ||
data[4] = lengthBytes[0]; | ||
data[5] = lengthBytes[1]; | ||
|
||
//MessageType [6..8]: | ||
var messageTypeBytes = Encoding.ASCII.GetBytes(messageType); | ||
if (messageTypeBytes.Length != 2) | ||
throw new InvalidOperationException("Messagetype must be two bytes."); | ||
|
||
data[6] = messageTypeBytes[0]; | ||
data[7] = messageTypeBytes[1]; | ||
|
||
return data.ToArray(); | ||
} | ||
|
||
private static List<byte> CreateHeader(ushort deviceId) | ||
{ | ||
var data = new List<byte>(); | ||
|
||
//Header [0..4]: | ||
data.AddRange(Encoding.ASCII.GetBytes("UC")); | ||
data.AddRange(BitConverter.GetBytes((ushort)256)); | ||
|
||
//Length [4..6] (placeholder): | ||
data.AddRange(new byte[] { 0x00, 0x00 }); | ||
|
||
//MessageType [6..8] (placeholder): | ||
data.AddRange(new byte[] { 0x00, 0x00 }); | ||
|
||
//From [8..10]: | ||
data.AddRange(BitConverter.GetBytes((ushort)104)); | ||
|
||
//To [10..12]: | ||
data.AddRange(BitConverter.GetBytes(deviceId)); | ||
|
||
return data; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.