Skip to content

Commit

Permalink
Undo model object changes for a new PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Ryland committed Oct 19, 2024
1 parent a1b90a9 commit bb73e78
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 96 deletions.
70 changes: 4 additions & 66 deletions obs-websocket-dotnet/Types/MediaInputStatus.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace OBSWebsocketDotNet.Types
Expand All @@ -13,34 +12,19 @@ public class MediaInputStatus
/// State of the media input
/// </summary>
[JsonProperty(PropertyName = "mediaState")]
public string StateString { get; set; }

/// <summary>
/// State of the media input
/// </summary>
public MediaState? State
{
get
{
if (!Enum.TryParse(StateString, out MediaState state))
{
return null;
}
return state;
}
}
public string State { get; set; }

/// <summary>
/// Total duration of the playing media in milliseconds. `null` if not playing
/// </summary>
[JsonProperty(PropertyName = "mediaDuration")]
public long? Duration { get; set; }
public int? Duration { get; set; }

/// <summary>
/// Position of the cursor in milliseconds. `null` if not playing
/// </summary>
[JsonProperty(PropertyName = "mediaCursor")]
public long? Cursor { get; set; }
public int? Cursor { get; set; }

/// <summary>
/// Instantiate from JObject
Expand All @@ -56,50 +40,4 @@ public MediaInputStatus(JObject body)
/// </summary>
public MediaInputStatus() { }
}

/// <summary>
/// Enum representing the state of a media input
/// </summary>
public enum MediaState
{
/// <summary>
/// No media is loaded
/// </summary>
OBS_MEDIA_STATE_NONE,

/// <summary>
/// Media is playing
/// </summary>
OBS_MEDIA_STATE_PLAYING,

/// <summary>
/// Media is opening
/// </summary>
OBS_MEDIA_STATE_OPENING,

/// <summary>
/// Media is buffering
/// </summary>
OBS_MEDIA_STATE_BUFFERING,

/// <summary>
/// Media is playing but is paused
/// </summary>
OBS_MEDIA_STATE_PAUSED,

/// <summary>
/// Media is stopped
/// </summary>
OBS_MEDIA_STATE_STOPPED,

/// <summary>
/// Media is ended
/// </summary>
OBS_MEDIA_STATE_ENDED,

/// <summary>
/// Media has errored
/// </summary>
OBS_MEDIA_STATE_ERROR
}
}
12 changes: 6 additions & 6 deletions obs-websocket-dotnet/Types/OBSVideoSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ public class ObsVideoSettings
/// Numerator of the fractional FPS value
/// </summary>
[JsonProperty(PropertyName = "fpsNumerator")]
public double FpsNumerator { set; get; }
public double FpsNumerator { internal set; get; }

/// <summary>
/// Denominator of the fractional FPS value
/// </summary>
[JsonProperty(PropertyName = "fpsDenominator")]
public double FpsDenominator { set; get; }
public double FpsDenominator { internal set; get; }

/// <summary>
/// Base (canvas) width
/// </summary>
[JsonProperty(PropertyName = "baseWidth")]
public int BaseWidth { set; get; }
public int BaseWidth { internal set; get; }

/// <summary>
/// Base (canvas) height
/// </summary>
[JsonProperty(PropertyName = "baseHeight")]
public int BaseHeight { set; get; }
public int BaseHeight { internal set; get; }

/// <summary>
/// Width of the output resolution in pixels
/// </summary>
[JsonProperty(PropertyName = "outputWidth")]
public int OutputWidth { set; get; }
public int OutputWidth { internal set; get; }

/// <summary>
/// Height of the output resolution in pixels
/// </summary>
[JsonProperty(PropertyName = "outputHeight")]
public int OutputHeight { set; get; }
public int OutputHeight { internal set; get; }
}
}
24 changes: 21 additions & 3 deletions obs-websocket-dotnet/Types/OutputStateChanged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,29 @@ public OutputState State {
return state.Value;
}

if (!Enum.TryParse(StateStr, ignoreCase: true, out OutputState stateTmp))
switch (StateStr)
{
throw new ArgumentOutOfRangeException($"Couldn't parse '{StateStr}' as {nameof(OutputState)}");
case "OBS_WEBSOCKET_OUTPUT_STARTING":
state = OutputState.OBS_WEBSOCKET_OUTPUT_STARTING;
break;
case "OBS_WEBSOCKET_OUTPUT_STARTED":
state = OutputState.OBS_WEBSOCKET_OUTPUT_STARTED;
break;
case "OBS_WEBSOCKET_OUTPUT_STOPPING":
state = OutputState.OBS_WEBSOCKET_OUTPUT_STOPPING;
break;
case "OBS_WEBSOCKET_OUTPUT_STOPPED":
state = OutputState.OBS_WEBSOCKET_OUTPUT_STOPPED;
break;
case "OBS_WEBSOCKET_OUTPUT_PAUSED":
state = OutputState.OBS_WEBSOCKET_OUTPUT_PAUSED;
break;
case "OBS_WEBSOCKET_OUTPUT_RESUMED":
state = OutputState.OBS_WEBSOCKET_OUTPUT_RESUMED;
break;
default:
throw new ArgumentOutOfRangeException();
}
state = stateTmp;

return state.Value;
}
Expand Down
22 changes: 1 addition & 21 deletions obs-websocket-dotnet/Types/StreamingServiceSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace OBSWebsocketDotNet.Types
{
Expand Down Expand Up @@ -38,23 +36,5 @@ public class StreamingServiceSettings
/// </summary>
[JsonProperty(PropertyName = "password")]
public string Password { set; get; }

/// <summary>
/// The service being used to stream
/// </summary>
[JsonProperty(PropertyName = "service")]
public string Service { get; set; }

/// <summary>
/// The protocol to use for the stream
/// </summary>
[JsonProperty(PropertyName = "protocol")]
public string Protocol { get; set; }

/// <summary>
/// Other values not covered by the class
/// </summary>
[JsonExtensionData]
public Dictionary<string, JToken> OtherValues { get; set; }
}
}

0 comments on commit bb73e78

Please sign in to comment.