-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
5 changed files
with
182 additions
and
6 deletions.
There are no files selected for viewing
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,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace OBSWebsocketDotNet.Types | ||
{ | ||
[Flags] | ||
internal enum EventSubscription | ||
{ | ||
None = 0, | ||
General = (1 << 0), | ||
Config = (1 << 1), | ||
Scenes = (1 << 2), | ||
Inputs = (1 << 3), | ||
Transitions = (1 << 4), | ||
Filters = (1 << 5), | ||
Outputs = (1 << 6), | ||
SceneItems = (1 << 7), | ||
MediaInputs = (1 << 8), | ||
Vendors = (1 << 9), | ||
Ui = (1 << 10), | ||
All = (General | Config | Scenes | Inputs | Transitions | Filters | Outputs | SceneItems | MediaInputs | Vendors | Ui), | ||
|
||
// High volume event need separate subscription | ||
|
||
InputVolumeMeters = (1 << 16), | ||
InputActiveStateChanged = (1 << 17), | ||
InputShowStateChanged = (1 << 18), | ||
SceneItemTransformChanged = (1 << 19) | ||
} | ||
} |
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,69 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Text; | ||
|
||
namespace OBSWebsocketDotNet.Types | ||
{ | ||
public class InputVolumeMeter | ||
{ | ||
/// <summary> | ||
/// Name of the input | ||
/// </summary> | ||
[JsonProperty(PropertyName = "inputName")] | ||
public string InputName { set; get; } | ||
|
||
// Convert json Array of 3 scalars, into a struct | ||
private class ChannelLevelConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(ChannelLevel); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
if (reader.TokenType != JsonToken.StartArray) | ||
throw new ProtocolViolationException("Expected InputVolumeMeter/inputLevelsMul to be an array"); | ||
|
||
JToken token = JToken.Load(reader); | ||
var items = token.ToObject<float[]>(); | ||
|
||
if (items.Length != 3) | ||
throw new ProtocolViolationException($"Expected InputVolumeMeter/inputLevelsMul to be an 3 element array, but instead got {items.Length} element array"); | ||
|
||
ChannelLevel contentStruct; | ||
contentStruct.PeakRaw = items[0]; | ||
contentStruct.PeakWithVolume = items[1]; | ||
contentStruct.magnitudeWithVolume = items[2]; | ||
return contentStruct; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
[JsonConverter(typeof(ChannelLevelConverter))] | ||
public struct ChannelLevel | ||
{ | ||
// https://github.com/obsproject/obs-websocket/blob/f4b72b69ce7f9ec6a5fdb1b06971e00d2b091bec/src/utils/Obs_VolumeMeter.cpp#L87 | ||
|
||
|
||
public float magnitudeWithVolume; | ||
public float PeakWithVolume; | ||
public float PeakRaw; | ||
} | ||
|
||
/// <summary> | ||
/// Array of channels on this input | ||
/// </summary> | ||
[JsonProperty(PropertyName = "inputLevelsMul")] | ||
public List<ChannelLevel> InputLevels { set; get; } | ||
|
||
|
||
} | ||
} |