diff --git a/ObsWebSocket.Codegen.Tasks/Generation/Emitter.BatchBuilder.cs b/ObsWebSocket.Codegen.Tasks/Generation/Emitter.BatchBuilder.cs index fd613c1..f2e91df 100644 --- a/ObsWebSocket.Codegen.Tasks/Generation/Emitter.BatchBuilder.cs +++ b/ObsWebSocket.Codegen.Tasks/Generation/Emitter.BatchBuilder.cs @@ -6,13 +6,14 @@ namespace ObsWebSocket.Codegen.Tasks.Generation; /// -/// Emitter logic for the typed batch builder, which pairs each request type string with the -/// request data record the protocol defines for it. +/// Emitter logic for the typed batch builder. Requests are grouped by protocol category, and each +/// returns a reference carrying its response type so a result can be read without restating +/// either its position or its type. /// internal static partial class Emitter { /// - /// Generates one builder method per protocol request. + /// Generates the category groups and their request methods. /// /// The source production context. /// The parsed protocol definition. @@ -26,93 +27,172 @@ ProtocolDefinition protocol return; } - StringBuilder builder = BuildSourceHeader("// Helper: typed batch builder methods"); + StringBuilder builder = BuildSourceHeader("// Helper: typed batch builder groups"); builder.AppendLine("using System;"); builder.AppendLine($"using {GeneratedRequestsNamespace};"); + builder.AppendLine($"using {GeneratedResponsesNamespace};"); builder.AppendLine(); builder.AppendLine($"namespace {ExtensionsNamespace};"); builder.AppendLine(); + + List<(string Category, string GroupName)> groups = []; + foreach ( + IGrouping group in protocol + .Requests.GroupBy(r => r.Category ?? "general", StringComparer.OrdinalIgnoreCase) + .OrderBy(g => g.Key, StringComparer.Ordinal) + ) + { + string groupName = ToGroupName(group.Key); + groups.Add((group.Key, groupName)); + + builder.AppendLine("/// "); + builder.AppendLine( + $"/// Batch requests in the {System.Security.SecurityElement.Escape(group.Key)} category." + ); + builder.AppendLine("/// "); + builder.AppendLine("/// The batch being built."); + builder.AppendLine( + $"public readonly struct {groupName}BatchGroup(ObsBatchBuilder builder)" + ); + builder.AppendLine("{"); + + foreach (RequestDefinition request in group) + { + EmitBatchRequestMethod(context, builder, request); + } + + builder.AppendLine("}"); + builder.AppendLine(); + } + builder.AppendLine("public sealed partial class ObsBatchBuilder"); builder.AppendLine("{"); + foreach ((string category, string groupName) in groups) + { + builder.AppendLine(" /// "); + builder.AppendLine( + $" /// Requests in the {System.Security.SecurityElement.Escape(category)} category." + ); + builder.AppendLine(" /// "); + builder.AppendLine($" public {groupName}BatchGroup {groupName} => new(this);"); + builder.AppendLine(); + } + + builder.AppendLine("}"); + + context.AddSource( + "ObsBatchBuilder.Requests.g.cs", + SourceText.From(builder.ToString(), Encoding.UTF8) + ); + } - foreach (RequestDefinition request in protocol.Requests) + /// + /// Emits one request method, returning a reference to its eventual result. + /// + private static void EmitBatchRequestMethod( + SourceProductionContext context, + StringBuilder builder, + RequestDefinition request + ) + { + try { - try + string requestType = request.RequestType; + string methodName = SanitizeIdentifier(requestType); + if (string.IsNullOrEmpty(methodName)) { - string requestType = request.RequestType; - string methodName = SanitizeIdentifier(requestType); - if (string.IsNullOrEmpty(methodName)) - { - continue; - } + return; + } - bool hasData = request.RequestFields?.Count > 0; + bool hasData = request.RequestFields?.Count > 0; + bool hasResponse = request.ResponseFields?.Count > 0; - builder.AppendLine(" /// "); + string returnType = hasResponse + ? $"BatchRef<{GeneratedResponsesNamespace}.{methodName}ResponseData>" + : "BatchRef"; + + builder.AppendLine(" /// "); + builder.AppendLine($" /// Adds a {requestType} request to the batch."); + if (!string.IsNullOrWhiteSpace(request.Description)) + { builder.AppendLine( - $" /// Appends a {requestType} request to the batch." + $" /// {FlattenBatchDescription(request.Description)}" ); - if (!string.IsNullOrWhiteSpace(request.Description)) - { - builder.AppendLine( - $" /// {FlattenDescription(request.Description)}" - ); - } - - builder.AppendLine(" /// "); - builder.AppendLine(" /// The same builder, for chaining."); - if (request.Deprecated) - { - builder.AppendLine( - $" [System.Obsolete(\"Deprecated in OBS Websocket version {request.InitialVersion}\")]" - ); - } - - if (hasData) - { - string dataTypeName = - $"{GeneratedRequestsNamespace}.{methodName}RequestData"; - builder.AppendLine( - $" /// The payload for this request." - ); - builder.AppendLine( - $" public ObsBatchBuilder {methodName}({dataTypeName} requestData)" - ); - builder.AppendLine(" {"); - builder.AppendLine(" ArgumentNullException.ThrowIfNull(requestData);"); - builder.AppendLine( - $" return Add(\"{requestType}\", requestData);" - ); - builder.AppendLine(" }"); - } - else - { - builder.AppendLine( - $" public ObsBatchBuilder {methodName}() => Add(\"{requestType}\", null);" - ); - } - - builder.AppendLine(); } - catch (Exception ex) + + builder.AppendLine(" /// "); + if (hasData) { - context.ReportDiagnostic( - Diagnostic.Create( - Diagnostics.IdentifierGenerationError, - Location.None, - request.RequestType, - $"Generating batch builder method for {request.RequestType}", - ex.Message - ) + builder.AppendLine( + " /// The payload for this request." ); } - } - builder.AppendLine("}"); + builder.AppendLine( + " /// A reference used to read this request's result." + ); + if (request.Deprecated) + { + builder.AppendLine( + $" [System.Obsolete(\"Request '{requestType}' is deprecated since OBS Websocket version {request.InitialVersion}\")]" + ); + } - context.AddSource( - "ObsBatchBuilder.Requests.g.cs", - SourceText.From(builder.ToString(), Encoding.UTF8) - ); + if (hasData) + { + string dataTypeName = $"{GeneratedRequestsNamespace}.{methodName}RequestData"; + builder.AppendLine( + $" public {returnType} {methodName}({dataTypeName} requestData)" + ); + builder.AppendLine(" {"); + builder.AppendLine(" ArgumentNullException.ThrowIfNull(requestData);"); + builder.AppendLine( + $" return new(builder.AddRequest(\"{requestType}\", requestData));" + ); + builder.AppendLine(" }"); + } + else + { + builder.AppendLine( + $" public {returnType} {methodName}() => new(builder.AddRequest(\"{requestType}\", null));" + ); + } + + builder.AppendLine(); + } + catch (Exception ex) + { + context.ReportDiagnostic( + Diagnostic.Create( + Diagnostics.IdentifierGenerationError, + Location.None, + request.RequestType, + $"Generating batch builder method for {request.RequestType}", + ex.Message + ) + ); + } } + + /// + /// Converts a protocol category such as scene items into a PascalCase group name. + /// + private static string ToGroupName(string category) => + string.Concat( + category + .Split([' ', '-', '_'], StringSplitOptions.RemoveEmptyEntries) + .Select(part => + part.Length == 0 + ? part + : char.ToUpperInvariant(part[0]) + part.Substring(1).ToLowerInvariant() + ) + ); + + /// + /// Flattens a protocol description onto a single line for a doc comment. + /// + private static string FlattenBatchDescription(string description) => + System.Security.SecurityElement.Escape( + System.Text.RegularExpressions.Regex.Replace(description, @"\s+", " ").Trim() + ) ?? string.Empty; } diff --git a/ObsWebSocket.Codegen.Tasks/Generation/Emitter.DtoGeneration.cs b/ObsWebSocket.Codegen.Tasks/Generation/Emitter.DtoGeneration.cs index 6b9d948..03adcbd 100644 --- a/ObsWebSocket.Codegen.Tasks/Generation/Emitter.DtoGeneration.cs +++ b/ObsWebSocket.Codegen.Tasks/Generation/Emitter.DtoGeneration.cs @@ -490,6 +490,19 @@ ProtocolDefinition protocol else // Response, Event, Nested { isConsideredRequired = !typeIsInherentlyNullable && !csharpType.EndsWith("?"); + + // Some fields are only ever null in a particular state, which the protocol + // records in the description rather than in valueOptional. Deserializing + // those into a non-nullable value type fails outright when it happens. + if ( + isConsideredRequired + && isValueType + && DescriptionAllowsNull(associatedFieldDef.ValueDescription) + ) + { + isConsideredRequired = false; + } + if (csharpType.StartsWith("List<") || csharpType.StartsWith("Dictionary<")) { isConsideredRequired = false; @@ -716,4 +729,12 @@ out bool isRootOfNested || f.ValueName.EndsWith("." + objectNode.Name) ); } + /// + /// Reports whether a field's description says it can be null, which the protocol states in + /// prose for fields it does not otherwise mark optional. + /// + private static bool DescriptionAllowsNull(string? description) => + !string.IsNullOrEmpty(description) + && description.IndexOf("null", StringComparison.OrdinalIgnoreCase) >= 0; + } diff --git a/ObsWebSocket.Codegen.Tasks/Generation/Emitter.cs b/ObsWebSocket.Codegen.Tasks/Generation/Emitter.cs index 168f8f3..dc4c3a9 100644 --- a/ObsWebSocket.Codegen.Tasks/Generation/Emitter.cs +++ b/ObsWebSocket.Codegen.Tasks/Generation/Emitter.cs @@ -697,36 +697,73 @@ ProtocolDefinition protocol builder.AppendLine(); builder.AppendLine($"namespace {ExtensionsNamespace};"); builder.AppendLine(); + List<(string Category, string GroupName)> groups = []; + foreach ( + IGrouping group in protocol + .Requests.GroupBy(r => r.Category ?? "general", StringComparer.OrdinalIgnoreCase) + .OrderBy(g => g.Key, StringComparer.Ordinal) + ) + { + string groupName = ToGroupName(group.Key); + groups.Add((group.Key, groupName)); + + builder.AppendLine("/// "); + builder.AppendLine( + $"/// Requests in the {System.Security.SecurityElement.Escape(group.Key)} category." + ); + builder.AppendLine("/// "); + builder.AppendLine("/// The client these requests are sent on."); + builder.AppendLine( + $"public readonly partial struct {groupName}RequestGroup(ObsWebSocketClient client)" + ); + builder.AppendLine("{"); + + foreach (RequestDefinition reqDef in group) + { + try + { + GenerateSingleExtensionMethod(builder, reqDef); + builder.AppendLine(); + } + catch (Exception ex) + { + context.ReportDiagnostic( + Diagnostic.Create( + Diagnostics.IdentifierGenerationError, + Location.None, + reqDef.RequestType, + $"Extension method for {reqDef.RequestType}", + ex.Message + ) + ); + } + } + + builder.AppendLine("}"); + builder.AppendLine(); + } + builder.AppendLine("/// "); - builder.AppendLine( - "/// Provides strongly-typed extension methods for the ," - ); - builder.AppendLine( - "/// corresponding to the requests defined in the OBS WebSocket v5 protocol." - ); + builder.AppendLine("/// Exposes the request categories defined by the OBS WebSocket protocol."); builder.AppendLine("/// "); - builder.AppendLine("public static partial class ObsWebSocketClientExtensions"); + builder.AppendLine("public static class ObsWebSocketClientExtensions"); builder.AppendLine("{"); - foreach (RequestDefinition reqDef in protocol.Requests) + foreach ((string category, string groupName) in groups) { - try - { - GenerateSingleExtensionMethod(builder, reqDef); - builder.AppendLine(); - } - catch (Exception ex) - { - context.ReportDiagnostic( - Diagnostic.Create( - Diagnostics.IdentifierGenerationError, - Location.None, - reqDef.RequestType, - $"Extension method for {reqDef.RequestType}", - ex.Message - ) - ); - } + builder.AppendLine(" extension(ObsWebSocketClient client)"); + builder.AppendLine(" {"); + builder.AppendLine(" /// "); + builder.AppendLine( + $" /// Requests in the {System.Security.SecurityElement.Escape(category)} category." + ); + builder.AppendLine(" /// "); + builder.AppendLine( + $" public {groupName}RequestGroup {groupName} => new(client);" + ); + builder.AppendLine(" }"); + builder.AppendLine(); } + builder.AppendLine("}"); context.AddSource( "ObsWebSocketClient.Extensions.g.cs", @@ -775,9 +812,6 @@ RequestDefinition reqDef builder.AppendLine(" /// "); AppendMultiLineXmlDoc(builder, reqDef.Description, " ///"); builder.AppendLine(" /// "); - builder.AppendLine( - $" /// The instance." - ); if (hasRequestData) { builder.AppendLine( @@ -843,7 +877,7 @@ RequestDefinition reqDef } builder.AppendLine( - $" public static async {returnType} {methodName}(this ObsWebSocketClient client, {parameterList})" + $" public async {returnType} {methodName}({parameterList})" ); builder.AppendLine(" {"); // Method Body diff --git a/ObsWebSocket.Core/BatchRef.cs b/ObsWebSocket.Core/BatchRef.cs new file mode 100644 index 0000000..cad2fb4 --- /dev/null +++ b/ObsWebSocket.Core/BatchRef.cs @@ -0,0 +1,133 @@ +using ObsWebSocket.Core.Protocol; + +namespace ObsWebSocket.Core; + +/// +/// Identifies a request within a batch, without a response type. +/// +/// Position of the request in the batch. +public readonly record struct BatchRef(int Index); + +/// +/// Identifies a request within a batch, carrying the type of its response. +/// +/// The response record this request produces. +/// Position of the request in the batch. +public readonly record struct BatchRef(int Index) + where TResponse : class +{ + /// Drops the response type, leaving a plain reference. + /// The reference to convert. + public static implicit operator BatchRef(BatchRef reference) => + new(reference.Index); + + /// Drops the response type, leaving a plain reference. + public BatchRef ToBatchRef() => new(Index); +} + +/// +/// The results of a batch call, addressable by the references the builder handed out. +/// +/// +/// Indexing by a ties a result to the request that produced it +/// and to that request's response type, so neither the position nor the type has to be restated +/// at the call site. +/// +public sealed class BatchResults : IReadOnlyList> +{ + private readonly IReadOnlyList> _results; + + private readonly bool _payloadsTrustworthy; + + /// Initializes results from the payloads OBS returned. + /// The results, in submission order. + /// + /// Whether each result's data belongs to the request it is attached to. False for parallel + /// execution, where OBS pairs every result with another request's response. + /// + public BatchResults( + IReadOnlyList> results, + bool payloadsTrustworthy = true + ) + { + ArgumentNullException.ThrowIfNull(results); + _results = results; + _payloadsTrustworthy = payloadsTrustworthy; + } + + /// Number of results returned. + /// + /// Fewer than the number of requests sent when OBS stopped early on a failure. + /// + public int Count => _results.Count; + + /// The raw results, in submission order. + public IReadOnlyList> Raw => _results; + + /// Gets the result for a request by position. + /// Position of the request in the batch. + public RequestResponsePayload this[int index] => _results[index]; + + /// Gets the result for a request that returns no data. + /// The reference the builder returned. + /// Thrown if the batch stopped before this request ran. + public RequestResponsePayload this[BatchRef reference] => Require(reference.Index); + + /// Gets the typed response for a request. + /// The response record for that request, inferred from the reference. + /// The reference the builder returned. + /// Thrown if the batch stopped before this request ran. + /// Thrown if OBS rejected that request. + public TResponse Get(BatchRef reference) + where TResponse : class => Require(reference.Index).GetRequiredData(); + + /// + /// Reads a typed response, reporting whether it was available rather than throwing. + /// + /// The response record for that request. + /// The reference the builder returned. + /// The response data, when one was returned. + public bool TryGet(BatchRef reference, out TResponse? data) + where TResponse : class + { + if (!_payloadsTrustworthy || reference.Index >= _results.Count) + { + data = null; + return false; + } + + return _results[reference.Index].TryGetData(out data); + } + + /// + public IEnumerator> GetEnumerator() => _results.GetEnumerator(); + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => + GetEnumerator(); + + /// Returns whether every request in the batch succeeded. + public bool AllSucceeded() => _results.All(r => r.RequestStatus.Result); + + /// Returns the results OBS reported as failed. + public IEnumerable> GetFailures() => + _results.Where(r => !r.RequestStatus.Result); + + private RequestResponsePayload Require(int index) + { + if (!_payloadsTrustworthy) + { + throw new ObsWebSocketException( + "OBS pairs each result with another request's response data when a batch runs with RequestBatchExecutionType.Parallel, so reading one by reference would return the wrong request's data. Its own response is already mis-paired, so this cannot be corrected here. Use a serial execution type, or read Raw and accept that the payloads are unreliable." + ); + } + + return RequireCore(index); + } + + private RequestResponsePayload RequireCore(int index) => + index < _results.Count + ? _results[index] + : throw new ObsWebSocketException( + $"The batch returned {_results.Count} result(s), so the request at position {index} never ran. This happens when haltOnFailure stopped the batch early." + ); +} diff --git a/ObsWebSocket.Core/BatchResultExtensions.cs b/ObsWebSocket.Core/BatchResultExtensions.cs index 74eec25..4712509 100644 --- a/ObsWebSocket.Core/BatchResultExtensions.cs +++ b/ObsWebSocket.Core/BatchResultExtensions.cs @@ -73,10 +73,16 @@ public static class BatchResultExtensions try { +#if NET11_0_OR_GREATER + return element.Deserialize( + ObsWebSocketJsonContext.Default.Options.GetTypeInfo() + ); +#else return element.Deserialize( (System.Text.Json.Serialization.Metadata.JsonTypeInfo) ObsWebSocketJsonContext.Default.Options.GetTypeInfo(typeof(TResponse)) ); +#endif } catch (Exception ex) when (ex is JsonException or InvalidOperationException or NotSupportedException) { diff --git a/ObsWebSocket.Core/Generated/Client/ObsBatchBuilder.Requests.g.cs b/ObsWebSocket.Core/Generated/Client/ObsBatchBuilder.Requests.g.cs index d311df2..baf345d 100644 --- a/ObsWebSocket.Core/Generated/Client/ObsBatchBuilder.Requests.g.cs +++ b/ObsWebSocket.Core/Generated/Client/ObsBatchBuilder.Requests.g.cs @@ -1,1556 +1,1739 @@ // -// Helper: typed batch builder methods +// Helper: typed batch builder groups #nullable enable using System; using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; namespace ObsWebSocket.Core; -public sealed partial class ObsBatchBuilder +/// +/// Batch requests in the canvases category. +/// +/// The batch being built. +public readonly struct CanvasesBatchGroup(ObsBatchBuilder builder) { /// - /// Appends a GetCanvasList request to the batch. + /// Adds a GetCanvasList request to the batch. /// Gets an array of canvases in OBS. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetCanvasList() => Add("GetCanvasList", null); + /// A reference used to read this request's result. + public BatchRef GetCanvasList() => new(builder.AddRequest("GetCanvasList", null)); + +} +/// +/// Batch requests in the config category. +/// +/// The batch being built. +public readonly struct ConfigBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetPersistentData request to the batch. + /// Adds a GetPersistentData request to the batch. /// Gets the value of a "slot" from the selected persistent data realm. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetPersistentData(ObsWebSocket.Core.Protocol.Requests.GetPersistentDataRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetPersistentData(ObsWebSocket.Core.Protocol.Requests.GetPersistentDataRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetPersistentData", requestData); + return new(builder.AddRequest("GetPersistentData", requestData)); } /// - /// Appends a SetPersistentData request to the batch. + /// Adds a SetPersistentData request to the batch. /// Sets the value of a "slot" from the selected persistent data realm. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetPersistentData(ObsWebSocket.Core.Protocol.Requests.SetPersistentDataRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetPersistentData(ObsWebSocket.Core.Protocol.Requests.SetPersistentDataRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetPersistentData", requestData); + return new(builder.AddRequest("SetPersistentData", requestData)); } /// - /// Appends a GetSceneCollectionList request to the batch. + /// Adds a GetSceneCollectionList request to the batch. /// Gets an array of all scene collections /// - /// The same builder, for chaining. - public ObsBatchBuilder GetSceneCollectionList() => Add("GetSceneCollectionList", null); + /// A reference used to read this request's result. + public BatchRef GetSceneCollectionList() => new(builder.AddRequest("GetSceneCollectionList", null)); /// - /// Appends a SetCurrentSceneCollection request to the batch. + /// Adds a SetCurrentSceneCollection request to the batch. /// Switches to a scene collection. Note: This will block until the collection has finished changing. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetCurrentSceneCollection(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneCollectionRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetCurrentSceneCollection(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneCollectionRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetCurrentSceneCollection", requestData); + return new(builder.AddRequest("SetCurrentSceneCollection", requestData)); } /// - /// Appends a CreateSceneCollection request to the batch. + /// Adds a CreateSceneCollection request to the batch. /// Creates a new scene collection, switching to it in the process. Note: This will block until the collection has finished changing. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CreateSceneCollection(ObsWebSocket.Core.Protocol.Requests.CreateSceneCollectionRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CreateSceneCollection(ObsWebSocket.Core.Protocol.Requests.CreateSceneCollectionRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CreateSceneCollection", requestData); + return new(builder.AddRequest("CreateSceneCollection", requestData)); } /// - /// Appends a GetProfileList request to the batch. + /// Adds a GetProfileList request to the batch. /// Gets an array of all profiles /// - /// The same builder, for chaining. - public ObsBatchBuilder GetProfileList() => Add("GetProfileList", null); + /// A reference used to read this request's result. + public BatchRef GetProfileList() => new(builder.AddRequest("GetProfileList", null)); /// - /// Appends a SetCurrentProfile request to the batch. + /// Adds a SetCurrentProfile request to the batch. /// Switches to a profile. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetCurrentProfile(ObsWebSocket.Core.Protocol.Requests.SetCurrentProfileRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetCurrentProfile(ObsWebSocket.Core.Protocol.Requests.SetCurrentProfileRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetCurrentProfile", requestData); + return new(builder.AddRequest("SetCurrentProfile", requestData)); } /// - /// Appends a CreateProfile request to the batch. + /// Adds a CreateProfile request to the batch. /// Creates a new profile, switching to it in the process /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CreateProfile(ObsWebSocket.Core.Protocol.Requests.CreateProfileRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CreateProfile(ObsWebSocket.Core.Protocol.Requests.CreateProfileRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CreateProfile", requestData); + return new(builder.AddRequest("CreateProfile", requestData)); } /// - /// Appends a RemoveProfile request to the batch. + /// Adds a RemoveProfile request to the batch. /// Removes a profile. If the current profile is chosen, it will change to a different profile first. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder RemoveProfile(ObsWebSocket.Core.Protocol.Requests.RemoveProfileRequestData requestData) + /// A reference used to read this request's result. + public BatchRef RemoveProfile(ObsWebSocket.Core.Protocol.Requests.RemoveProfileRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("RemoveProfile", requestData); + return new(builder.AddRequest("RemoveProfile", requestData)); } /// - /// Appends a GetProfileParameter request to the batch. + /// Adds a GetProfileParameter request to the batch. /// Gets a parameter from the current profile's configuration. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetProfileParameter(ObsWebSocket.Core.Protocol.Requests.GetProfileParameterRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetProfileParameter(ObsWebSocket.Core.Protocol.Requests.GetProfileParameterRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetProfileParameter", requestData); + return new(builder.AddRequest("GetProfileParameter", requestData)); } /// - /// Appends a SetProfileParameter request to the batch. + /// Adds a SetProfileParameter request to the batch. /// Sets the value of a parameter in the current profile's configuration. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetProfileParameter(ObsWebSocket.Core.Protocol.Requests.SetProfileParameterRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetProfileParameter(ObsWebSocket.Core.Protocol.Requests.SetProfileParameterRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetProfileParameter", requestData); + return new(builder.AddRequest("SetProfileParameter", requestData)); } /// - /// Appends a GetVideoSettings request to the batch. + /// Adds a GetVideoSettings request to the batch. /// Gets the current video settings. Note: To get the true FPS value, divide the FPS numerator by the FPS denominator. Example: `60000/1001` /// - /// The same builder, for chaining. - public ObsBatchBuilder GetVideoSettings() => Add("GetVideoSettings", null); + /// A reference used to read this request's result. + public BatchRef GetVideoSettings() => new(builder.AddRequest("GetVideoSettings", null)); /// - /// Appends a SetVideoSettings request to the batch. + /// Adds a SetVideoSettings request to the batch. /// Sets the current video settings. Note: Fields must be specified in pairs. For example, you cannot set only `baseWidth` without needing to specify `baseHeight`. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetVideoSettings(ObsWebSocket.Core.Protocol.Requests.SetVideoSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetVideoSettings(ObsWebSocket.Core.Protocol.Requests.SetVideoSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetVideoSettings", requestData); + return new(builder.AddRequest("SetVideoSettings", requestData)); } /// - /// Appends a GetStreamServiceSettings request to the batch. + /// Adds a GetStreamServiceSettings request to the batch. /// Gets the current stream service settings (stream destination). /// - /// The same builder, for chaining. - public ObsBatchBuilder GetStreamServiceSettings() => Add("GetStreamServiceSettings", null); + /// A reference used to read this request's result. + public BatchRef GetStreamServiceSettings() => new(builder.AddRequest("GetStreamServiceSettings", null)); /// - /// Appends a SetStreamServiceSettings request to the batch. + /// Adds a SetStreamServiceSettings request to the batch. /// Sets the current stream service settings (stream destination). Note: Simple RTMP settings can be set with type `rtmp_custom` and the settings fields `server` and `key`. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetStreamServiceSettings(ObsWebSocket.Core.Protocol.Requests.SetStreamServiceSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetStreamServiceSettings(ObsWebSocket.Core.Protocol.Requests.SetStreamServiceSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetStreamServiceSettings", requestData); + return new(builder.AddRequest("SetStreamServiceSettings", requestData)); } /// - /// Appends a GetRecordDirectory request to the batch. + /// Adds a GetRecordDirectory request to the batch. /// Gets the current directory that the record output is set to. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetRecordDirectory() => Add("GetRecordDirectory", null); + /// A reference used to read this request's result. + public BatchRef GetRecordDirectory() => new(builder.AddRequest("GetRecordDirectory", null)); /// - /// Appends a SetRecordDirectory request to the batch. + /// Adds a SetRecordDirectory request to the batch. /// Sets the current directory that the record output writes files to. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetRecordDirectory(ObsWebSocket.Core.Protocol.Requests.SetRecordDirectoryRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetRecordDirectory(ObsWebSocket.Core.Protocol.Requests.SetRecordDirectoryRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetRecordDirectory", requestData); + return new(builder.AddRequest("SetRecordDirectory", requestData)); } +} + +/// +/// Batch requests in the filters category. +/// +/// The batch being built. +public readonly struct FiltersBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetSourceFilterKindList request to the batch. + /// Adds a GetSourceFilterKindList request to the batch. /// Gets an array of all available source filter kinds. Similar to `GetInputKindList` /// - /// The same builder, for chaining. - public ObsBatchBuilder GetSourceFilterKindList() => Add("GetSourceFilterKindList", null); + /// A reference used to read this request's result. + public BatchRef GetSourceFilterKindList() => new(builder.AddRequest("GetSourceFilterKindList", null)); /// - /// Appends a GetSourceFilterList request to the batch. + /// Adds a GetSourceFilterList request to the batch. /// Gets an array of all of a source's filters. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSourceFilterList(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterListRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSourceFilterList(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterListRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSourceFilterList", requestData); + return new(builder.AddRequest("GetSourceFilterList", requestData)); } /// - /// Appends a GetSourceFilterDefaultSettings request to the batch. + /// Adds a GetSourceFilterDefaultSettings request to the batch. /// Gets the default settings for a filter kind. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSourceFilterDefaultSettings(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterDefaultSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSourceFilterDefaultSettings(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterDefaultSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSourceFilterDefaultSettings", requestData); + return new(builder.AddRequest("GetSourceFilterDefaultSettings", requestData)); } /// - /// Appends a CreateSourceFilter request to the batch. + /// Adds a CreateSourceFilter request to the batch. /// Creates a new filter, adding it to the specified source. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CreateSourceFilter(ObsWebSocket.Core.Protocol.Requests.CreateSourceFilterRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CreateSourceFilter(ObsWebSocket.Core.Protocol.Requests.CreateSourceFilterRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CreateSourceFilter", requestData); + return new(builder.AddRequest("CreateSourceFilter", requestData)); } /// - /// Appends a RemoveSourceFilter request to the batch. + /// Adds a RemoveSourceFilter request to the batch. /// Removes a filter from a source. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder RemoveSourceFilter(ObsWebSocket.Core.Protocol.Requests.RemoveSourceFilterRequestData requestData) + /// A reference used to read this request's result. + public BatchRef RemoveSourceFilter(ObsWebSocket.Core.Protocol.Requests.RemoveSourceFilterRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("RemoveSourceFilter", requestData); + return new(builder.AddRequest("RemoveSourceFilter", requestData)); } /// - /// Appends a SetSourceFilterName request to the batch. + /// Adds a SetSourceFilterName request to the batch. /// Sets the name of a source filter (rename). /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSourceFilterName(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterNameRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSourceFilterName(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterNameRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSourceFilterName", requestData); + return new(builder.AddRequest("SetSourceFilterName", requestData)); } /// - /// Appends a GetSourceFilter request to the batch. + /// Adds a GetSourceFilter request to the batch. /// Gets the info for a specific source filter. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSourceFilter(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSourceFilter(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSourceFilter", requestData); + return new(builder.AddRequest("GetSourceFilter", requestData)); } /// - /// Appends a SetSourceFilterIndex request to the batch. + /// Adds a SetSourceFilterIndex request to the batch. /// Sets the index position of a filter on a source. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSourceFilterIndex(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterIndexRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSourceFilterIndex(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterIndexRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSourceFilterIndex", requestData); + return new(builder.AddRequest("SetSourceFilterIndex", requestData)); } /// - /// Appends a SetSourceFilterSettings request to the batch. + /// Adds a SetSourceFilterSettings request to the batch. /// Sets the settings of a source filter. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSourceFilterSettings(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSourceFilterSettings(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSourceFilterSettings", requestData); + return new(builder.AddRequest("SetSourceFilterSettings", requestData)); } /// - /// Appends a SetSourceFilterEnabled request to the batch. + /// Adds a SetSourceFilterEnabled request to the batch. /// Sets the enable state of a source filter. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSourceFilterEnabled(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterEnabledRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSourceFilterEnabled(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterEnabledRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSourceFilterEnabled", requestData); + return new(builder.AddRequest("SetSourceFilterEnabled", requestData)); } +} + +/// +/// Batch requests in the general category. +/// +/// The batch being built. +public readonly struct GeneralBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetVersion request to the batch. + /// Adds a GetVersion request to the batch. /// Gets data about the current plugin and RPC version. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetVersion() => Add("GetVersion", null); + /// A reference used to read this request's result. + public BatchRef GetVersion() => new(builder.AddRequest("GetVersion", null)); /// - /// Appends a GetStats request to the batch. + /// Adds a GetStats request to the batch. /// Gets statistics about OBS, obs-websocket, and the current session. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetStats() => Add("GetStats", null); + /// A reference used to read this request's result. + public BatchRef GetStats() => new(builder.AddRequest("GetStats", null)); /// - /// Appends a BroadcastCustomEvent request to the batch. + /// Adds a BroadcastCustomEvent request to the batch. /// Broadcasts a `CustomEvent` to all WebSocket clients. Receivers are clients which are identified and subscribed. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder BroadcastCustomEvent(ObsWebSocket.Core.Protocol.Requests.BroadcastCustomEventRequestData requestData) + /// A reference used to read this request's result. + public BatchRef BroadcastCustomEvent(ObsWebSocket.Core.Protocol.Requests.BroadcastCustomEventRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("BroadcastCustomEvent", requestData); + return new(builder.AddRequest("BroadcastCustomEvent", requestData)); } /// - /// Appends a CallVendorRequest request to the batch. + /// Adds a CallVendorRequest request to the batch. /// Call a request registered to a vendor. A vendor is a unique name registered by a third-party plugin or script, which allows for custom requests and events to be added to obs-websocket. If a plugin or script implements vendor requests or events, documentation is expected to be provided with them. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CallVendorRequest(ObsWebSocket.Core.Protocol.Requests.CallVendorRequestRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CallVendorRequest(ObsWebSocket.Core.Protocol.Requests.CallVendorRequestRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CallVendorRequest", requestData); + return new(builder.AddRequest("CallVendorRequest", requestData)); } /// - /// Appends a GetHotkeyList request to the batch. + /// Adds a GetHotkeyList request to the batch. /// Gets an array of all hotkey names in OBS. Note: Hotkey functionality in obs-websocket comes as-is, and we do not guarantee support if things are broken. In 9/10 usages of hotkey requests, there exists a better, more reliable method via other requests. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetHotkeyList() => Add("GetHotkeyList", null); + /// A reference used to read this request's result. + public BatchRef GetHotkeyList() => new(builder.AddRequest("GetHotkeyList", null)); /// - /// Appends a TriggerHotkeyByName request to the batch. + /// Adds a TriggerHotkeyByName request to the batch. /// Triggers a hotkey using its name. See `GetHotkeyList`. Note: Hotkey functionality in obs-websocket comes as-is, and we do not guarantee support if things are broken. In 9/10 usages of hotkey requests, there exists a better, more reliable method via other requests. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder TriggerHotkeyByName(ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByNameRequestData requestData) + /// A reference used to read this request's result. + public BatchRef TriggerHotkeyByName(ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByNameRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("TriggerHotkeyByName", requestData); + return new(builder.AddRequest("TriggerHotkeyByName", requestData)); } /// - /// Appends a TriggerHotkeyByKeySequence request to the batch. + /// Adds a TriggerHotkeyByKeySequence request to the batch. /// Triggers a hotkey using a sequence of keys. Note: Hotkey functionality in obs-websocket comes as-is, and we do not guarantee support if things are broken. In 9/10 usages of hotkey requests, there exists a better, more reliable method via other requests. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder TriggerHotkeyByKeySequence(ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByKeySequenceRequestData requestData) + /// A reference used to read this request's result. + public BatchRef TriggerHotkeyByKeySequence(ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByKeySequenceRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("TriggerHotkeyByKeySequence", requestData); + return new(builder.AddRequest("TriggerHotkeyByKeySequence", requestData)); } /// - /// Appends a Sleep request to the batch. + /// Adds a Sleep request to the batch. /// Sleeps for a time duration or number of frames. Only available in request batches with types `SERIAL_REALTIME` or `SERIAL_FRAME`. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder Sleep(ObsWebSocket.Core.Protocol.Requests.SleepRequestData requestData) + /// A reference used to read this request's result. + public BatchRef Sleep(ObsWebSocket.Core.Protocol.Requests.SleepRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("Sleep", requestData); + return new(builder.AddRequest("Sleep", requestData)); } +} + +/// +/// Batch requests in the inputs category. +/// +/// The batch being built. +public readonly struct InputsBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetInputList request to the batch. + /// Adds a GetInputList request to the batch. /// Gets an array of all inputs in OBS. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputList(ObsWebSocket.Core.Protocol.Requests.GetInputListRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputList(ObsWebSocket.Core.Protocol.Requests.GetInputListRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputList", requestData); + return new(builder.AddRequest("GetInputList", requestData)); } /// - /// Appends a GetInputKindList request to the batch. + /// Adds a GetInputKindList request to the batch. /// Gets an array of all available input kinds in OBS. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputKindList(ObsWebSocket.Core.Protocol.Requests.GetInputKindListRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputKindList(ObsWebSocket.Core.Protocol.Requests.GetInputKindListRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputKindList", requestData); + return new(builder.AddRequest("GetInputKindList", requestData)); } /// - /// Appends a GetSpecialInputs request to the batch. + /// Adds a GetSpecialInputs request to the batch. /// Gets the names of all special inputs. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetSpecialInputs() => Add("GetSpecialInputs", null); + /// A reference used to read this request's result. + public BatchRef GetSpecialInputs() => new(builder.AddRequest("GetSpecialInputs", null)); /// - /// Appends a CreateInput request to the batch. + /// Adds a CreateInput request to the batch. /// Creates a new input, adding it as a scene item to the specified scene. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CreateInput(ObsWebSocket.Core.Protocol.Requests.CreateInputRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CreateInput(ObsWebSocket.Core.Protocol.Requests.CreateInputRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CreateInput", requestData); + return new(builder.AddRequest("CreateInput", requestData)); } /// - /// Appends a RemoveInput request to the batch. + /// Adds a RemoveInput request to the batch. /// Removes an existing input. Note: Will immediately remove all associated scene items. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder RemoveInput(ObsWebSocket.Core.Protocol.Requests.RemoveInputRequestData requestData) + /// A reference used to read this request's result. + public BatchRef RemoveInput(ObsWebSocket.Core.Protocol.Requests.RemoveInputRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("RemoveInput", requestData); + return new(builder.AddRequest("RemoveInput", requestData)); } /// - /// Appends a SetInputName request to the batch. + /// Adds a SetInputName request to the batch. /// Sets the name of an input (rename). /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputName(ObsWebSocket.Core.Protocol.Requests.SetInputNameRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputName(ObsWebSocket.Core.Protocol.Requests.SetInputNameRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputName", requestData); + return new(builder.AddRequest("SetInputName", requestData)); } /// - /// Appends a GetInputDefaultSettings request to the batch. + /// Adds a GetInputDefaultSettings request to the batch. /// Gets the default settings for an input kind. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputDefaultSettings(ObsWebSocket.Core.Protocol.Requests.GetInputDefaultSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputDefaultSettings(ObsWebSocket.Core.Protocol.Requests.GetInputDefaultSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputDefaultSettings", requestData); + return new(builder.AddRequest("GetInputDefaultSettings", requestData)); } /// - /// Appends a GetInputSettings request to the batch. + /// Adds a GetInputSettings request to the batch. /// Gets the settings of an input. Note: Does not include defaults. To create the entire settings object, overlay `inputSettings` over the `defaultInputSettings` provided by `GetInputDefaultSettings`. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputSettings(ObsWebSocket.Core.Protocol.Requests.GetInputSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputSettings(ObsWebSocket.Core.Protocol.Requests.GetInputSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputSettings", requestData); + return new(builder.AddRequest("GetInputSettings", requestData)); } /// - /// Appends a SetInputSettings request to the batch. + /// Adds a SetInputSettings request to the batch. /// Sets the settings of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputSettings(ObsWebSocket.Core.Protocol.Requests.SetInputSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputSettings(ObsWebSocket.Core.Protocol.Requests.SetInputSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputSettings", requestData); + return new(builder.AddRequest("SetInputSettings", requestData)); } /// - /// Appends a GetInputMute request to the batch. + /// Adds a GetInputMute request to the batch. /// Gets the audio mute state of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputMute(ObsWebSocket.Core.Protocol.Requests.GetInputMuteRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputMute(ObsWebSocket.Core.Protocol.Requests.GetInputMuteRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputMute", requestData); + return new(builder.AddRequest("GetInputMute", requestData)); } /// - /// Appends a SetInputMute request to the batch. + /// Adds a SetInputMute request to the batch. /// Sets the audio mute state of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputMute(ObsWebSocket.Core.Protocol.Requests.SetInputMuteRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputMute(ObsWebSocket.Core.Protocol.Requests.SetInputMuteRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputMute", requestData); + return new(builder.AddRequest("SetInputMute", requestData)); } /// - /// Appends a ToggleInputMute request to the batch. + /// Adds a ToggleInputMute request to the batch. /// Toggles the audio mute state of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder ToggleInputMute(ObsWebSocket.Core.Protocol.Requests.ToggleInputMuteRequestData requestData) + /// A reference used to read this request's result. + public BatchRef ToggleInputMute(ObsWebSocket.Core.Protocol.Requests.ToggleInputMuteRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("ToggleInputMute", requestData); + return new(builder.AddRequest("ToggleInputMute", requestData)); } /// - /// Appends a GetInputVolume request to the batch. + /// Adds a GetInputVolume request to the batch. /// Gets the current volume setting of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputVolume(ObsWebSocket.Core.Protocol.Requests.GetInputVolumeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputVolume(ObsWebSocket.Core.Protocol.Requests.GetInputVolumeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputVolume", requestData); + return new(builder.AddRequest("GetInputVolume", requestData)); } /// - /// Appends a SetInputVolume request to the batch. + /// Adds a SetInputVolume request to the batch. /// Sets the volume setting of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputVolume(ObsWebSocket.Core.Protocol.Requests.SetInputVolumeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputVolume(ObsWebSocket.Core.Protocol.Requests.SetInputVolumeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputVolume", requestData); + return new(builder.AddRequest("SetInputVolume", requestData)); } /// - /// Appends a GetInputAudioBalance request to the batch. + /// Adds a GetInputAudioBalance request to the batch. /// Gets the audio balance of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputAudioBalance(ObsWebSocket.Core.Protocol.Requests.GetInputAudioBalanceRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputAudioBalance(ObsWebSocket.Core.Protocol.Requests.GetInputAudioBalanceRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputAudioBalance", requestData); + return new(builder.AddRequest("GetInputAudioBalance", requestData)); } /// - /// Appends a SetInputAudioBalance request to the batch. + /// Adds a SetInputAudioBalance request to the batch. /// Sets the audio balance of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputAudioBalance(ObsWebSocket.Core.Protocol.Requests.SetInputAudioBalanceRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputAudioBalance(ObsWebSocket.Core.Protocol.Requests.SetInputAudioBalanceRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputAudioBalance", requestData); + return new(builder.AddRequest("SetInputAudioBalance", requestData)); } /// - /// Appends a GetInputAudioSyncOffset request to the batch. + /// Adds a GetInputAudioSyncOffset request to the batch. /// Gets the audio sync offset of an input. Note: The audio sync offset can be negative too! /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputAudioSyncOffset(ObsWebSocket.Core.Protocol.Requests.GetInputAudioSyncOffsetRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputAudioSyncOffset(ObsWebSocket.Core.Protocol.Requests.GetInputAudioSyncOffsetRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputAudioSyncOffset", requestData); + return new(builder.AddRequest("GetInputAudioSyncOffset", requestData)); } /// - /// Appends a SetInputAudioSyncOffset request to the batch. + /// Adds a SetInputAudioSyncOffset request to the batch. /// Sets the audio sync offset of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputAudioSyncOffset(ObsWebSocket.Core.Protocol.Requests.SetInputAudioSyncOffsetRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputAudioSyncOffset(ObsWebSocket.Core.Protocol.Requests.SetInputAudioSyncOffsetRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputAudioSyncOffset", requestData); + return new(builder.AddRequest("SetInputAudioSyncOffset", requestData)); } /// - /// Appends a GetInputAudioMonitorType request to the batch. + /// Adds a GetInputAudioMonitorType request to the batch. /// Gets the audio monitor type of an input. The available audio monitor types are: - `OBS_MONITORING_TYPE_NONE` - `OBS_MONITORING_TYPE_MONITOR_ONLY` - `OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT` /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputAudioMonitorType(ObsWebSocket.Core.Protocol.Requests.GetInputAudioMonitorTypeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputAudioMonitorType(ObsWebSocket.Core.Protocol.Requests.GetInputAudioMonitorTypeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputAudioMonitorType", requestData); + return new(builder.AddRequest("GetInputAudioMonitorType", requestData)); } /// - /// Appends a SetInputAudioMonitorType request to the batch. + /// Adds a SetInputAudioMonitorType request to the batch. /// Sets the audio monitor type of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputAudioMonitorType(ObsWebSocket.Core.Protocol.Requests.SetInputAudioMonitorTypeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputAudioMonitorType(ObsWebSocket.Core.Protocol.Requests.SetInputAudioMonitorTypeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputAudioMonitorType", requestData); + return new(builder.AddRequest("SetInputAudioMonitorType", requestData)); } /// - /// Appends a GetInputAudioTracks request to the batch. + /// Adds a GetInputAudioTracks request to the batch. /// Gets the enable state of all audio tracks of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputAudioTracks(ObsWebSocket.Core.Protocol.Requests.GetInputAudioTracksRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputAudioTracks(ObsWebSocket.Core.Protocol.Requests.GetInputAudioTracksRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputAudioTracks", requestData); + return new(builder.AddRequest("GetInputAudioTracks", requestData)); } /// - /// Appends a SetInputAudioTracks request to the batch. + /// Adds a SetInputAudioTracks request to the batch. /// Sets the enable state of audio tracks of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputAudioTracks(ObsWebSocket.Core.Protocol.Requests.SetInputAudioTracksRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputAudioTracks(ObsWebSocket.Core.Protocol.Requests.SetInputAudioTracksRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputAudioTracks", requestData); + return new(builder.AddRequest("SetInputAudioTracks", requestData)); } /// - /// Appends a GetInputDeinterlaceMode request to the batch. + /// Adds a GetInputDeinterlaceMode request to the batch. /// Gets the deinterlace mode of an input. Deinterlace Modes: - `OBS_DEINTERLACE_MODE_DISABLE` - `OBS_DEINTERLACE_MODE_DISCARD` - `OBS_DEINTERLACE_MODE_RETRO` - `OBS_DEINTERLACE_MODE_BLEND` - `OBS_DEINTERLACE_MODE_BLEND_2X` - `OBS_DEINTERLACE_MODE_LINEAR` - `OBS_DEINTERLACE_MODE_LINEAR_2X` - `OBS_DEINTERLACE_MODE_YADIF` - `OBS_DEINTERLACE_MODE_YADIF_2X` Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputDeinterlaceMode(ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceModeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputDeinterlaceMode(ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceModeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputDeinterlaceMode", requestData); + return new(builder.AddRequest("GetInputDeinterlaceMode", requestData)); } /// - /// Appends a SetInputDeinterlaceMode request to the batch. + /// Adds a SetInputDeinterlaceMode request to the batch. /// Sets the deinterlace mode of an input. Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputDeinterlaceMode(ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceModeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputDeinterlaceMode(ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceModeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputDeinterlaceMode", requestData); + return new(builder.AddRequest("SetInputDeinterlaceMode", requestData)); } /// - /// Appends a GetInputDeinterlaceFieldOrder request to the batch. + /// Adds a GetInputDeinterlaceFieldOrder request to the batch. /// Gets the deinterlace field order of an input. Deinterlace Field Orders: - `OBS_DEINTERLACE_FIELD_ORDER_TOP` - `OBS_DEINTERLACE_FIELD_ORDER_BOTTOM` Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputDeinterlaceFieldOrder(ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceFieldOrderRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputDeinterlaceFieldOrder(ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceFieldOrderRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputDeinterlaceFieldOrder", requestData); + return new(builder.AddRequest("GetInputDeinterlaceFieldOrder", requestData)); } /// - /// Appends a SetInputDeinterlaceFieldOrder request to the batch. + /// Adds a SetInputDeinterlaceFieldOrder request to the batch. /// Sets the deinterlace field order of an input. Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetInputDeinterlaceFieldOrder(ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceFieldOrderRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetInputDeinterlaceFieldOrder(ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceFieldOrderRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetInputDeinterlaceFieldOrder", requestData); + return new(builder.AddRequest("SetInputDeinterlaceFieldOrder", requestData)); } /// - /// Appends a GetInputPropertiesListPropertyItems request to the batch. + /// Adds a GetInputPropertiesListPropertyItems request to the batch. /// Gets the items of a list property from an input's properties. Note: Use this in cases where an input provides a dynamic, selectable list of items. For example, display capture, where it provides a list of available displays. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetInputPropertiesListPropertyItems(ObsWebSocket.Core.Protocol.Requests.GetInputPropertiesListPropertyItemsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetInputPropertiesListPropertyItems(ObsWebSocket.Core.Protocol.Requests.GetInputPropertiesListPropertyItemsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetInputPropertiesListPropertyItems", requestData); + return new(builder.AddRequest("GetInputPropertiesListPropertyItems", requestData)); } /// - /// Appends a PressInputPropertiesButton request to the batch. + /// Adds a PressInputPropertiesButton request to the batch. /// Presses a button in the properties of an input. Some known `propertyName` values are: - `refreshnocache` - Browser source reload button Note: Use this in cases where there is a button in the properties of an input that cannot be accessed in any other way. For example, browser sources, where there is a refresh button. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder PressInputPropertiesButton(ObsWebSocket.Core.Protocol.Requests.PressInputPropertiesButtonRequestData requestData) + /// A reference used to read this request's result. + public BatchRef PressInputPropertiesButton(ObsWebSocket.Core.Protocol.Requests.PressInputPropertiesButtonRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("PressInputPropertiesButton", requestData); + return new(builder.AddRequest("PressInputPropertiesButton", requestData)); } +} + +/// +/// Batch requests in the media inputs category. +/// +/// The batch being built. +public readonly struct MediaInputsBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetMediaInputStatus request to the batch. + /// Adds a GetMediaInputStatus request to the batch. /// Gets the status of a media input. Media States: - `OBS_MEDIA_STATE_NONE` - `OBS_MEDIA_STATE_PLAYING` - `OBS_MEDIA_STATE_OPENING` - `OBS_MEDIA_STATE_BUFFERING` - `OBS_MEDIA_STATE_PAUSED` - `OBS_MEDIA_STATE_STOPPED` - `OBS_MEDIA_STATE_ENDED` - `OBS_MEDIA_STATE_ERROR` /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetMediaInputStatus(ObsWebSocket.Core.Protocol.Requests.GetMediaInputStatusRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetMediaInputStatus(ObsWebSocket.Core.Protocol.Requests.GetMediaInputStatusRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetMediaInputStatus", requestData); + return new(builder.AddRequest("GetMediaInputStatus", requestData)); } /// - /// Appends a SetMediaInputCursor request to the batch. + /// Adds a SetMediaInputCursor request to the batch. /// Sets the cursor position of a media input. This request does not perform bounds checking of the cursor position. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetMediaInputCursor(ObsWebSocket.Core.Protocol.Requests.SetMediaInputCursorRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetMediaInputCursor(ObsWebSocket.Core.Protocol.Requests.SetMediaInputCursorRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetMediaInputCursor", requestData); + return new(builder.AddRequest("SetMediaInputCursor", requestData)); } /// - /// Appends a OffsetMediaInputCursor request to the batch. + /// Adds a OffsetMediaInputCursor request to the batch. /// Offsets the current cursor position of a media input by the specified value. This request does not perform bounds checking of the cursor position. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder OffsetMediaInputCursor(ObsWebSocket.Core.Protocol.Requests.OffsetMediaInputCursorRequestData requestData) + /// A reference used to read this request's result. + public BatchRef OffsetMediaInputCursor(ObsWebSocket.Core.Protocol.Requests.OffsetMediaInputCursorRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("OffsetMediaInputCursor", requestData); + return new(builder.AddRequest("OffsetMediaInputCursor", requestData)); } /// - /// Appends a TriggerMediaInputAction request to the batch. + /// Adds a TriggerMediaInputAction request to the batch. /// Triggers an action on a media input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder TriggerMediaInputAction(ObsWebSocket.Core.Protocol.Requests.TriggerMediaInputActionRequestData requestData) + /// A reference used to read this request's result. + public BatchRef TriggerMediaInputAction(ObsWebSocket.Core.Protocol.Requests.TriggerMediaInputActionRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("TriggerMediaInputAction", requestData); + return new(builder.AddRequest("TriggerMediaInputAction", requestData)); } +} + +/// +/// Batch requests in the outputs category. +/// +/// The batch being built. +public readonly struct OutputsBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetVirtualCamStatus request to the batch. + /// Adds a GetVirtualCamStatus request to the batch. /// Gets the status of the virtualcam output. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetVirtualCamStatus() => Add("GetVirtualCamStatus", null); + /// A reference used to read this request's result. + public BatchRef GetVirtualCamStatus() => new(builder.AddRequest("GetVirtualCamStatus", null)); /// - /// Appends a ToggleVirtualCam request to the batch. + /// Adds a ToggleVirtualCam request to the batch. /// Toggles the state of the virtualcam output. /// - /// The same builder, for chaining. - public ObsBatchBuilder ToggleVirtualCam() => Add("ToggleVirtualCam", null); + /// A reference used to read this request's result. + public BatchRef ToggleVirtualCam() => new(builder.AddRequest("ToggleVirtualCam", null)); /// - /// Appends a StartVirtualCam request to the batch. + /// Adds a StartVirtualCam request to the batch. /// Starts the virtualcam output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StartVirtualCam() => Add("StartVirtualCam", null); + /// A reference used to read this request's result. + public BatchRef StartVirtualCam() => new(builder.AddRequest("StartVirtualCam", null)); /// - /// Appends a StopVirtualCam request to the batch. + /// Adds a StopVirtualCam request to the batch. /// Stops the virtualcam output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StopVirtualCam() => Add("StopVirtualCam", null); + /// A reference used to read this request's result. + public BatchRef StopVirtualCam() => new(builder.AddRequest("StopVirtualCam", null)); /// - /// Appends a GetReplayBufferStatus request to the batch. + /// Adds a GetReplayBufferStatus request to the batch. /// Gets the status of the replay buffer output. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetReplayBufferStatus() => Add("GetReplayBufferStatus", null); + /// A reference used to read this request's result. + public BatchRef GetReplayBufferStatus() => new(builder.AddRequest("GetReplayBufferStatus", null)); /// - /// Appends a ToggleReplayBuffer request to the batch. + /// Adds a ToggleReplayBuffer request to the batch. /// Toggles the state of the replay buffer output. /// - /// The same builder, for chaining. - public ObsBatchBuilder ToggleReplayBuffer() => Add("ToggleReplayBuffer", null); + /// A reference used to read this request's result. + public BatchRef ToggleReplayBuffer() => new(builder.AddRequest("ToggleReplayBuffer", null)); /// - /// Appends a StartReplayBuffer request to the batch. + /// Adds a StartReplayBuffer request to the batch. /// Starts the replay buffer output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StartReplayBuffer() => Add("StartReplayBuffer", null); + /// A reference used to read this request's result. + public BatchRef StartReplayBuffer() => new(builder.AddRequest("StartReplayBuffer", null)); /// - /// Appends a StopReplayBuffer request to the batch. + /// Adds a StopReplayBuffer request to the batch. /// Stops the replay buffer output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StopReplayBuffer() => Add("StopReplayBuffer", null); + /// A reference used to read this request's result. + public BatchRef StopReplayBuffer() => new(builder.AddRequest("StopReplayBuffer", null)); /// - /// Appends a SaveReplayBuffer request to the batch. + /// Adds a SaveReplayBuffer request to the batch. /// Saves the contents of the replay buffer output. /// - /// The same builder, for chaining. - public ObsBatchBuilder SaveReplayBuffer() => Add("SaveReplayBuffer", null); + /// A reference used to read this request's result. + public BatchRef SaveReplayBuffer() => new(builder.AddRequest("SaveReplayBuffer", null)); /// - /// Appends a GetLastReplayBufferReplay request to the batch. + /// Adds a GetLastReplayBufferReplay request to the batch. /// Gets the filename of the last replay buffer save file. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetLastReplayBufferReplay() => Add("GetLastReplayBufferReplay", null); + /// A reference used to read this request's result. + public BatchRef GetLastReplayBufferReplay() => new(builder.AddRequest("GetLastReplayBufferReplay", null)); /// - /// Appends a GetOutputList request to the batch. + /// Adds a GetOutputList request to the batch. /// Gets the list of available outputs. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetOutputList() => Add("GetOutputList", null); + /// A reference used to read this request's result. + public BatchRef GetOutputList() => new(builder.AddRequest("GetOutputList", null)); /// - /// Appends a GetOutputStatus request to the batch. + /// Adds a GetOutputStatus request to the batch. /// Gets the status of an output. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetOutputStatus(ObsWebSocket.Core.Protocol.Requests.GetOutputStatusRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetOutputStatus(ObsWebSocket.Core.Protocol.Requests.GetOutputStatusRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetOutputStatus", requestData); + return new(builder.AddRequest("GetOutputStatus", requestData)); } /// - /// Appends a ToggleOutput request to the batch. + /// Adds a ToggleOutput request to the batch. /// Toggles the status of an output. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder ToggleOutput(ObsWebSocket.Core.Protocol.Requests.ToggleOutputRequestData requestData) + /// A reference used to read this request's result. + public BatchRef ToggleOutput(ObsWebSocket.Core.Protocol.Requests.ToggleOutputRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("ToggleOutput", requestData); + return new(builder.AddRequest("ToggleOutput", requestData)); } /// - /// Appends a StartOutput request to the batch. + /// Adds a StartOutput request to the batch. /// Starts an output. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder StartOutput(ObsWebSocket.Core.Protocol.Requests.StartOutputRequestData requestData) + /// A reference used to read this request's result. + public BatchRef StartOutput(ObsWebSocket.Core.Protocol.Requests.StartOutputRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("StartOutput", requestData); + return new(builder.AddRequest("StartOutput", requestData)); } /// - /// Appends a StopOutput request to the batch. + /// Adds a StopOutput request to the batch. /// Stops an output. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder StopOutput(ObsWebSocket.Core.Protocol.Requests.StopOutputRequestData requestData) + /// A reference used to read this request's result. + public BatchRef StopOutput(ObsWebSocket.Core.Protocol.Requests.StopOutputRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("StopOutput", requestData); + return new(builder.AddRequest("StopOutput", requestData)); } /// - /// Appends a GetOutputSettings request to the batch. + /// Adds a GetOutputSettings request to the batch. /// Gets the settings of an output. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetOutputSettings(ObsWebSocket.Core.Protocol.Requests.GetOutputSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetOutputSettings(ObsWebSocket.Core.Protocol.Requests.GetOutputSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetOutputSettings", requestData); + return new(builder.AddRequest("GetOutputSettings", requestData)); } /// - /// Appends a SetOutputSettings request to the batch. + /// Adds a SetOutputSettings request to the batch. /// Sets the settings of an output. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetOutputSettings(ObsWebSocket.Core.Protocol.Requests.SetOutputSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetOutputSettings(ObsWebSocket.Core.Protocol.Requests.SetOutputSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetOutputSettings", requestData); + return new(builder.AddRequest("SetOutputSettings", requestData)); } +} + +/// +/// Batch requests in the record category. +/// +/// The batch being built. +public readonly struct RecordBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetRecordStatus request to the batch. + /// Adds a GetRecordStatus request to the batch. /// Gets the status of the record output. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetRecordStatus() => Add("GetRecordStatus", null); + /// A reference used to read this request's result. + public BatchRef GetRecordStatus() => new(builder.AddRequest("GetRecordStatus", null)); /// - /// Appends a ToggleRecord request to the batch. + /// Adds a ToggleRecord request to the batch. /// Toggles the status of the record output. /// - /// The same builder, for chaining. - public ObsBatchBuilder ToggleRecord() => Add("ToggleRecord", null); + /// A reference used to read this request's result. + public BatchRef ToggleRecord() => new(builder.AddRequest("ToggleRecord", null)); /// - /// Appends a StartRecord request to the batch. + /// Adds a StartRecord request to the batch. /// Starts the record output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StartRecord() => Add("StartRecord", null); + /// A reference used to read this request's result. + public BatchRef StartRecord() => new(builder.AddRequest("StartRecord", null)); /// - /// Appends a StopRecord request to the batch. + /// Adds a StopRecord request to the batch. /// Stops the record output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StopRecord() => Add("StopRecord", null); + /// A reference used to read this request's result. + public BatchRef StopRecord() => new(builder.AddRequest("StopRecord", null)); /// - /// Appends a ToggleRecordPause request to the batch. + /// Adds a ToggleRecordPause request to the batch. /// Toggles pause on the record output. /// - /// The same builder, for chaining. - public ObsBatchBuilder ToggleRecordPause() => Add("ToggleRecordPause", null); + /// A reference used to read this request's result. + public BatchRef ToggleRecordPause() => new(builder.AddRequest("ToggleRecordPause", null)); /// - /// Appends a PauseRecord request to the batch. + /// Adds a PauseRecord request to the batch. /// Pauses the record output. /// - /// The same builder, for chaining. - public ObsBatchBuilder PauseRecord() => Add("PauseRecord", null); + /// A reference used to read this request's result. + public BatchRef PauseRecord() => new(builder.AddRequest("PauseRecord", null)); /// - /// Appends a ResumeRecord request to the batch. + /// Adds a ResumeRecord request to the batch. /// Resumes the record output. /// - /// The same builder, for chaining. - public ObsBatchBuilder ResumeRecord() => Add("ResumeRecord", null); + /// A reference used to read this request's result. + public BatchRef ResumeRecord() => new(builder.AddRequest("ResumeRecord", null)); /// - /// Appends a SplitRecordFile request to the batch. + /// Adds a SplitRecordFile request to the batch. /// Splits the current file being recorded into a new file. /// - /// The same builder, for chaining. - public ObsBatchBuilder SplitRecordFile() => Add("SplitRecordFile", null); + /// A reference used to read this request's result. + public BatchRef SplitRecordFile() => new(builder.AddRequest("SplitRecordFile", null)); /// - /// Appends a CreateRecordChapter request to the batch. + /// Adds a CreateRecordChapter request to the batch. /// Adds a new chapter marker to the file currently being recorded. Note: As of OBS 30.2.0, the only file format supporting this feature is Hybrid MP4. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CreateRecordChapter(ObsWebSocket.Core.Protocol.Requests.CreateRecordChapterRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CreateRecordChapter(ObsWebSocket.Core.Protocol.Requests.CreateRecordChapterRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CreateRecordChapter", requestData); + return new(builder.AddRequest("CreateRecordChapter", requestData)); } +} + +/// +/// Batch requests in the scene items category. +/// +/// The batch being built. +public readonly struct SceneItemsBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetSceneItemList request to the batch. + /// Adds a GetSceneItemList request to the batch. /// Gets a list of all scene items in a scene. Scenes only /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemList(ObsWebSocket.Core.Protocol.Requests.GetSceneItemListRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemList(ObsWebSocket.Core.Protocol.Requests.GetSceneItemListRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemList", requestData); + return new(builder.AddRequest("GetSceneItemList", requestData)); } /// - /// Appends a GetGroupSceneItemList request to the batch. + /// Adds a GetGroupSceneItemList request to the batch. /// Basically GetSceneItemList, but for groups. Using groups at all in OBS is discouraged, as they are very broken under the hood. Please use nested scenes instead. Groups only /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetGroupSceneItemList(ObsWebSocket.Core.Protocol.Requests.GetGroupSceneItemListRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetGroupSceneItemList(ObsWebSocket.Core.Protocol.Requests.GetGroupSceneItemListRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetGroupSceneItemList", requestData); + return new(builder.AddRequest("GetGroupSceneItemList", requestData)); } /// - /// Appends a GetSceneItemId request to the batch. + /// Adds a GetSceneItemId request to the batch. /// Searches a scene for a source, and returns its id. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemId(ObsWebSocket.Core.Protocol.Requests.GetSceneItemIdRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemId(ObsWebSocket.Core.Protocol.Requests.GetSceneItemIdRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemId", requestData); + return new(builder.AddRequest("GetSceneItemId", requestData)); } /// - /// Appends a GetSceneItemSource request to the batch. + /// Adds a GetSceneItemSource request to the batch. /// Gets the source associated with a scene item. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemSource(ObsWebSocket.Core.Protocol.Requests.GetSceneItemSourceRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemSource(ObsWebSocket.Core.Protocol.Requests.GetSceneItemSourceRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemSource", requestData); + return new(builder.AddRequest("GetSceneItemSource", requestData)); } /// - /// Appends a CreateSceneItem request to the batch. + /// Adds a CreateSceneItem request to the batch. /// Creates a new scene item using a source. Scenes only /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CreateSceneItem(ObsWebSocket.Core.Protocol.Requests.CreateSceneItemRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CreateSceneItem(ObsWebSocket.Core.Protocol.Requests.CreateSceneItemRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CreateSceneItem", requestData); + return new(builder.AddRequest("CreateSceneItem", requestData)); } /// - /// Appends a RemoveSceneItem request to the batch. + /// Adds a RemoveSceneItem request to the batch. /// Removes a scene item from a scene. Scenes only /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder RemoveSceneItem(ObsWebSocket.Core.Protocol.Requests.RemoveSceneItemRequestData requestData) + /// A reference used to read this request's result. + public BatchRef RemoveSceneItem(ObsWebSocket.Core.Protocol.Requests.RemoveSceneItemRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("RemoveSceneItem", requestData); + return new(builder.AddRequest("RemoveSceneItem", requestData)); } /// - /// Appends a DuplicateSceneItem request to the batch. + /// Adds a DuplicateSceneItem request to the batch. /// Duplicates a scene item, copying all transform and crop info. Scenes only /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder DuplicateSceneItem(ObsWebSocket.Core.Protocol.Requests.DuplicateSceneItemRequestData requestData) + /// A reference used to read this request's result. + public BatchRef DuplicateSceneItem(ObsWebSocket.Core.Protocol.Requests.DuplicateSceneItemRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("DuplicateSceneItem", requestData); + return new(builder.AddRequest("DuplicateSceneItem", requestData)); } /// - /// Appends a GetSceneItemTransform request to the batch. + /// Adds a GetSceneItemTransform request to the batch. /// Gets the transform and crop info of a scene item. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemTransform(ObsWebSocket.Core.Protocol.Requests.GetSceneItemTransformRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemTransform(ObsWebSocket.Core.Protocol.Requests.GetSceneItemTransformRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemTransform", requestData); + return new(builder.AddRequest("GetSceneItemTransform", requestData)); } /// - /// Appends a SetSceneItemTransform request to the batch. + /// Adds a SetSceneItemTransform request to the batch. /// Sets the transform and crop info of a scene item. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSceneItemTransform(ObsWebSocket.Core.Protocol.Requests.SetSceneItemTransformRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSceneItemTransform(ObsWebSocket.Core.Protocol.Requests.SetSceneItemTransformRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSceneItemTransform", requestData); + return new(builder.AddRequest("SetSceneItemTransform", requestData)); } /// - /// Appends a GetSceneItemEnabled request to the batch. + /// Adds a GetSceneItemEnabled request to the batch. /// Gets the enable state of a scene item. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemEnabled(ObsWebSocket.Core.Protocol.Requests.GetSceneItemEnabledRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemEnabled(ObsWebSocket.Core.Protocol.Requests.GetSceneItemEnabledRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemEnabled", requestData); + return new(builder.AddRequest("GetSceneItemEnabled", requestData)); } /// - /// Appends a SetSceneItemEnabled request to the batch. + /// Adds a SetSceneItemEnabled request to the batch. /// Sets the enable state of a scene item. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSceneItemEnabled(ObsWebSocket.Core.Protocol.Requests.SetSceneItemEnabledRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSceneItemEnabled(ObsWebSocket.Core.Protocol.Requests.SetSceneItemEnabledRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSceneItemEnabled", requestData); + return new(builder.AddRequest("SetSceneItemEnabled", requestData)); } /// - /// Appends a GetSceneItemLocked request to the batch. + /// Adds a GetSceneItemLocked request to the batch. /// Gets the lock state of a scene item. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemLocked(ObsWebSocket.Core.Protocol.Requests.GetSceneItemLockedRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemLocked(ObsWebSocket.Core.Protocol.Requests.GetSceneItemLockedRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemLocked", requestData); + return new(builder.AddRequest("GetSceneItemLocked", requestData)); } /// - /// Appends a SetSceneItemLocked request to the batch. + /// Adds a SetSceneItemLocked request to the batch. /// Sets the lock state of a scene item. Scenes and Group /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSceneItemLocked(ObsWebSocket.Core.Protocol.Requests.SetSceneItemLockedRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSceneItemLocked(ObsWebSocket.Core.Protocol.Requests.SetSceneItemLockedRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSceneItemLocked", requestData); + return new(builder.AddRequest("SetSceneItemLocked", requestData)); } /// - /// Appends a GetSceneItemIndex request to the batch. + /// Adds a GetSceneItemIndex request to the batch. /// Gets the index position of a scene item in a scene. An index of 0 is at the bottom of the source list in the UI. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemIndex(ObsWebSocket.Core.Protocol.Requests.GetSceneItemIndexRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemIndex(ObsWebSocket.Core.Protocol.Requests.GetSceneItemIndexRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemIndex", requestData); + return new(builder.AddRequest("GetSceneItemIndex", requestData)); } /// - /// Appends a SetSceneItemIndex request to the batch. + /// Adds a SetSceneItemIndex request to the batch. /// Sets the index position of a scene item in a scene. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSceneItemIndex(ObsWebSocket.Core.Protocol.Requests.SetSceneItemIndexRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSceneItemIndex(ObsWebSocket.Core.Protocol.Requests.SetSceneItemIndexRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSceneItemIndex", requestData); + return new(builder.AddRequest("SetSceneItemIndex", requestData)); } /// - /// Appends a GetSceneItemBlendMode request to the batch. + /// Adds a GetSceneItemBlendMode request to the batch. /// Gets the blend mode of a scene item. Blend modes: - `OBS_BLEND_NORMAL` - `OBS_BLEND_ADDITIVE` - `OBS_BLEND_SUBTRACT` - `OBS_BLEND_SCREEN` - `OBS_BLEND_MULTIPLY` - `OBS_BLEND_LIGHTEN` - `OBS_BLEND_DARKEN` Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneItemBlendMode(ObsWebSocket.Core.Protocol.Requests.GetSceneItemBlendModeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneItemBlendMode(ObsWebSocket.Core.Protocol.Requests.GetSceneItemBlendModeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneItemBlendMode", requestData); + return new(builder.AddRequest("GetSceneItemBlendMode", requestData)); } /// - /// Appends a SetSceneItemBlendMode request to the batch. + /// Adds a SetSceneItemBlendMode request to the batch. /// Sets the blend mode of a scene item. Scenes and Groups /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSceneItemBlendMode(ObsWebSocket.Core.Protocol.Requests.SetSceneItemBlendModeRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSceneItemBlendMode(ObsWebSocket.Core.Protocol.Requests.SetSceneItemBlendModeRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSceneItemBlendMode", requestData); + return new(builder.AddRequest("SetSceneItemBlendMode", requestData)); } +} + +/// +/// Batch requests in the scenes category. +/// +/// The batch being built. +public readonly struct ScenesBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetSceneList request to the batch. + /// Adds a GetSceneList request to the batch. /// Gets an array of scenes in OBS. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneList(ObsWebSocket.Core.Protocol.Requests.GetSceneListRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneList(ObsWebSocket.Core.Protocol.Requests.GetSceneListRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneList", requestData); + return new(builder.AddRequest("GetSceneList", requestData)); } /// - /// Appends a GetGroupList request to the batch. + /// Adds a GetGroupList request to the batch. /// Gets an array of all groups in OBS. Groups in OBS are actually scenes, but renamed and modified. In obs-websocket, we treat them as scenes where we can. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetGroupList() => Add("GetGroupList", null); + /// A reference used to read this request's result. + public BatchRef GetGroupList() => new(builder.AddRequest("GetGroupList", null)); /// - /// Appends a GetCurrentProgramScene request to the batch. + /// Adds a GetCurrentProgramScene request to the batch. /// Gets the current program scene. Note 1: This request is slated to have the `currentProgram`-prefixed fields removed from in an upcoming RPC version. Note 2: Canvases do not have any concept of a program or preview scene, so this request does not support canvases. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetCurrentProgramScene() => Add("GetCurrentProgramScene", null); + /// A reference used to read this request's result. + public BatchRef GetCurrentProgramScene() => new(builder.AddRequest("GetCurrentProgramScene", null)); /// - /// Appends a SetCurrentProgramScene request to the batch. + /// Adds a SetCurrentProgramScene request to the batch. /// Sets the current program scene. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetCurrentProgramScene(ObsWebSocket.Core.Protocol.Requests.SetCurrentProgramSceneRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetCurrentProgramScene(ObsWebSocket.Core.Protocol.Requests.SetCurrentProgramSceneRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetCurrentProgramScene", requestData); + return new(builder.AddRequest("SetCurrentProgramScene", requestData)); } /// - /// Appends a GetCurrentPreviewScene request to the batch. + /// Adds a GetCurrentPreviewScene request to the batch. /// Gets the current preview scene. Only available when studio mode is enabled. Note: This request is slated to have the `currentPreview`-prefixed fields removed from in an upcoming RPC version. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetCurrentPreviewScene() => Add("GetCurrentPreviewScene", null); + /// A reference used to read this request's result. + public BatchRef GetCurrentPreviewScene() => new(builder.AddRequest("GetCurrentPreviewScene", null)); /// - /// Appends a SetCurrentPreviewScene request to the batch. + /// Adds a SetCurrentPreviewScene request to the batch. /// Sets the current preview scene. Only available when studio mode is enabled. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetCurrentPreviewScene(ObsWebSocket.Core.Protocol.Requests.SetCurrentPreviewSceneRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetCurrentPreviewScene(ObsWebSocket.Core.Protocol.Requests.SetCurrentPreviewSceneRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetCurrentPreviewScene", requestData); + return new(builder.AddRequest("SetCurrentPreviewScene", requestData)); } /// - /// Appends a CreateScene request to the batch. + /// Adds a CreateScene request to the batch. /// Creates a new scene in OBS. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder CreateScene(ObsWebSocket.Core.Protocol.Requests.CreateSceneRequestData requestData) + /// A reference used to read this request's result. + public BatchRef CreateScene(ObsWebSocket.Core.Protocol.Requests.CreateSceneRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("CreateScene", requestData); + return new(builder.AddRequest("CreateScene", requestData)); } /// - /// Appends a RemoveScene request to the batch. + /// Adds a RemoveScene request to the batch. /// Removes a scene from OBS. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder RemoveScene(ObsWebSocket.Core.Protocol.Requests.RemoveSceneRequestData requestData) + /// A reference used to read this request's result. + public BatchRef RemoveScene(ObsWebSocket.Core.Protocol.Requests.RemoveSceneRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("RemoveScene", requestData); + return new(builder.AddRequest("RemoveScene", requestData)); } /// - /// Appends a SetSceneName request to the batch. + /// Adds a SetSceneName request to the batch. /// Sets the name of a scene (rename). /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSceneName(ObsWebSocket.Core.Protocol.Requests.SetSceneNameRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSceneName(ObsWebSocket.Core.Protocol.Requests.SetSceneNameRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSceneName", requestData); + return new(builder.AddRequest("SetSceneName", requestData)); } /// - /// Appends a GetSceneSceneTransitionOverride request to the batch. + /// Adds a GetSceneSceneTransitionOverride request to the batch. /// Gets the scene transition overridden for a scene. Note: A transition UUID response field is not currently able to be implemented as of 2024-1-18. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSceneSceneTransitionOverride(ObsWebSocket.Core.Protocol.Requests.GetSceneSceneTransitionOverrideRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSceneSceneTransitionOverride(ObsWebSocket.Core.Protocol.Requests.GetSceneSceneTransitionOverrideRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSceneSceneTransitionOverride", requestData); + return new(builder.AddRequest("GetSceneSceneTransitionOverride", requestData)); } /// - /// Appends a SetSceneSceneTransitionOverride request to the batch. + /// Adds a SetSceneSceneTransitionOverride request to the batch. /// Sets the scene transition overridden for a scene. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetSceneSceneTransitionOverride(ObsWebSocket.Core.Protocol.Requests.SetSceneSceneTransitionOverrideRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetSceneSceneTransitionOverride(ObsWebSocket.Core.Protocol.Requests.SetSceneSceneTransitionOverrideRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetSceneSceneTransitionOverride", requestData); + return new(builder.AddRequest("SetSceneSceneTransitionOverride", requestData)); } +} + +/// +/// Batch requests in the sources category. +/// +/// The batch being built. +public readonly struct SourcesBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetSourceActive request to the batch. + /// Adds a GetSourceActive request to the batch. /// Gets the active and show state of a source. **Compatible with inputs and scenes.** /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSourceActive(ObsWebSocket.Core.Protocol.Requests.GetSourceActiveRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSourceActive(ObsWebSocket.Core.Protocol.Requests.GetSourceActiveRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSourceActive", requestData); + return new(builder.AddRequest("GetSourceActive", requestData)); } /// - /// Appends a GetSourceScreenshot request to the batch. + /// Adds a GetSourceScreenshot request to the batch. /// Gets a Base64-encoded screenshot of a source. The `imageWidth` and `imageHeight` parameters are treated as "scale to inner", meaning the smallest ratio will be used and the aspect ratio of the original resolution is kept. If `imageWidth` and `imageHeight` are not specified, the compressed image will use the full resolution of the source. **Compatible with inputs and scenes.** /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder GetSourceScreenshot(ObsWebSocket.Core.Protocol.Requests.GetSourceScreenshotRequestData requestData) + /// A reference used to read this request's result. + public BatchRef GetSourceScreenshot(ObsWebSocket.Core.Protocol.Requests.GetSourceScreenshotRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("GetSourceScreenshot", requestData); + return new(builder.AddRequest("GetSourceScreenshot", requestData)); } /// - /// Appends a SaveSourceScreenshot request to the batch. + /// Adds a SaveSourceScreenshot request to the batch. /// Saves a screenshot of a source to the filesystem. The `imageWidth` and `imageHeight` parameters are treated as "scale to inner", meaning the smallest ratio will be used and the aspect ratio of the original resolution is kept. If `imageWidth` and `imageHeight` are not specified, the compressed image will use the full resolution of the source. **Compatible with inputs and scenes.** /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SaveSourceScreenshot(ObsWebSocket.Core.Protocol.Requests.SaveSourceScreenshotRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SaveSourceScreenshot(ObsWebSocket.Core.Protocol.Requests.SaveSourceScreenshotRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SaveSourceScreenshot", requestData); + return new(builder.AddRequest("SaveSourceScreenshot", requestData)); } +} + +/// +/// Batch requests in the stream category. +/// +/// The batch being built. +public readonly struct StreamBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetStreamStatus request to the batch. + /// Adds a GetStreamStatus request to the batch. /// Gets the status of the stream output. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetStreamStatus() => Add("GetStreamStatus", null); + /// A reference used to read this request's result. + public BatchRef GetStreamStatus() => new(builder.AddRequest("GetStreamStatus", null)); /// - /// Appends a ToggleStream request to the batch. + /// Adds a ToggleStream request to the batch. /// Toggles the status of the stream output. /// - /// The same builder, for chaining. - public ObsBatchBuilder ToggleStream() => Add("ToggleStream", null); + /// A reference used to read this request's result. + public BatchRef ToggleStream() => new(builder.AddRequest("ToggleStream", null)); /// - /// Appends a StartStream request to the batch. + /// Adds a StartStream request to the batch. /// Starts the stream output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StartStream() => Add("StartStream", null); + /// A reference used to read this request's result. + public BatchRef StartStream() => new(builder.AddRequest("StartStream", null)); /// - /// Appends a StopStream request to the batch. + /// Adds a StopStream request to the batch. /// Stops the stream output. /// - /// The same builder, for chaining. - public ObsBatchBuilder StopStream() => Add("StopStream", null); + /// A reference used to read this request's result. + public BatchRef StopStream() => new(builder.AddRequest("StopStream", null)); /// - /// Appends a SendStreamCaption request to the batch. + /// Adds a SendStreamCaption request to the batch. /// Sends CEA-608 caption text over the stream output. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SendStreamCaption(ObsWebSocket.Core.Protocol.Requests.SendStreamCaptionRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SendStreamCaption(ObsWebSocket.Core.Protocol.Requests.SendStreamCaptionRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SendStreamCaption", requestData); + return new(builder.AddRequest("SendStreamCaption", requestData)); } +} + +/// +/// Batch requests in the transitions category. +/// +/// The batch being built. +public readonly struct TransitionsBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetTransitionKindList request to the batch. + /// Adds a GetTransitionKindList request to the batch. /// Gets an array of all available transition kinds. Similar to `GetInputKindList` /// - /// The same builder, for chaining. - public ObsBatchBuilder GetTransitionKindList() => Add("GetTransitionKindList", null); + /// A reference used to read this request's result. + public BatchRef GetTransitionKindList() => new(builder.AddRequest("GetTransitionKindList", null)); /// - /// Appends a GetSceneTransitionList request to the batch. + /// Adds a GetSceneTransitionList request to the batch. /// Gets an array of all scene transitions in OBS. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetSceneTransitionList() => Add("GetSceneTransitionList", null); + /// A reference used to read this request's result. + public BatchRef GetSceneTransitionList() => new(builder.AddRequest("GetSceneTransitionList", null)); /// - /// Appends a GetCurrentSceneTransition request to the batch. + /// Adds a GetCurrentSceneTransition request to the batch. /// Gets information about the current scene transition. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetCurrentSceneTransition() => Add("GetCurrentSceneTransition", null); + /// A reference used to read this request's result. + public BatchRef GetCurrentSceneTransition() => new(builder.AddRequest("GetCurrentSceneTransition", null)); /// - /// Appends a SetCurrentSceneTransition request to the batch. + /// Adds a SetCurrentSceneTransition request to the batch. /// Sets the current scene transition. Small note: While the namespace of scene transitions is generally unique, that uniqueness is not a guarantee as it is with other resources like inputs. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetCurrentSceneTransition(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetCurrentSceneTransition(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetCurrentSceneTransition", requestData); + return new(builder.AddRequest("SetCurrentSceneTransition", requestData)); } /// - /// Appends a SetCurrentSceneTransitionDuration request to the batch. + /// Adds a SetCurrentSceneTransitionDuration request to the batch. /// Sets the duration of the current scene transition, if it is not fixed. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetCurrentSceneTransitionDuration(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionDurationRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetCurrentSceneTransitionDuration(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionDurationRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetCurrentSceneTransitionDuration", requestData); + return new(builder.AddRequest("SetCurrentSceneTransitionDuration", requestData)); } /// - /// Appends a SetCurrentSceneTransitionSettings request to the batch. + /// Adds a SetCurrentSceneTransitionSettings request to the batch. /// Sets the settings of the current scene transition. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetCurrentSceneTransitionSettings(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionSettingsRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetCurrentSceneTransitionSettings(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionSettingsRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetCurrentSceneTransitionSettings", requestData); + return new(builder.AddRequest("SetCurrentSceneTransitionSettings", requestData)); } /// - /// Appends a GetCurrentSceneTransitionCursor request to the batch. + /// Adds a GetCurrentSceneTransitionCursor request to the batch. /// Gets the cursor position of the current scene transition. Note: `transitionCursor` will return 1.0 when the transition is inactive. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetCurrentSceneTransitionCursor() => Add("GetCurrentSceneTransitionCursor", null); + /// A reference used to read this request's result. + public BatchRef GetCurrentSceneTransitionCursor() => new(builder.AddRequest("GetCurrentSceneTransitionCursor", null)); /// - /// Appends a TriggerStudioModeTransition request to the batch. + /// Adds a TriggerStudioModeTransition request to the batch. /// Triggers the current scene transition. Same functionality as the `Transition` button in studio mode. /// - /// The same builder, for chaining. - public ObsBatchBuilder TriggerStudioModeTransition() => Add("TriggerStudioModeTransition", null); + /// A reference used to read this request's result. + public BatchRef TriggerStudioModeTransition() => new(builder.AddRequest("TriggerStudioModeTransition", null)); /// - /// Appends a SetTBarPosition request to the batch. + /// Adds a SetTBarPosition request to the batch. /// Sets the position of the TBar. **Very important note**: This will be deprecated and replaced in a future version of obs-websocket. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetTBarPosition(ObsWebSocket.Core.Protocol.Requests.SetTBarPositionRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetTBarPosition(ObsWebSocket.Core.Protocol.Requests.SetTBarPositionRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetTBarPosition", requestData); + return new(builder.AddRequest("SetTBarPosition", requestData)); } +} + +/// +/// Batch requests in the ui category. +/// +/// The batch being built. +public readonly struct UiBatchGroup(ObsBatchBuilder builder) +{ /// - /// Appends a GetStudioModeEnabled request to the batch. + /// Adds a GetStudioModeEnabled request to the batch. /// Gets whether studio is enabled. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetStudioModeEnabled() => Add("GetStudioModeEnabled", null); + /// A reference used to read this request's result. + public BatchRef GetStudioModeEnabled() => new(builder.AddRequest("GetStudioModeEnabled", null)); /// - /// Appends a SetStudioModeEnabled request to the batch. + /// Adds a SetStudioModeEnabled request to the batch. /// Enables or disables studio mode /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder SetStudioModeEnabled(ObsWebSocket.Core.Protocol.Requests.SetStudioModeEnabledRequestData requestData) + /// A reference used to read this request's result. + public BatchRef SetStudioModeEnabled(ObsWebSocket.Core.Protocol.Requests.SetStudioModeEnabledRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("SetStudioModeEnabled", requestData); + return new(builder.AddRequest("SetStudioModeEnabled", requestData)); } /// - /// Appends a OpenInputPropertiesDialog request to the batch. + /// Adds a OpenInputPropertiesDialog request to the batch. /// Opens the properties dialog of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder OpenInputPropertiesDialog(ObsWebSocket.Core.Protocol.Requests.OpenInputPropertiesDialogRequestData requestData) + /// A reference used to read this request's result. + public BatchRef OpenInputPropertiesDialog(ObsWebSocket.Core.Protocol.Requests.OpenInputPropertiesDialogRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("OpenInputPropertiesDialog", requestData); + return new(builder.AddRequest("OpenInputPropertiesDialog", requestData)); } /// - /// Appends a OpenInputFiltersDialog request to the batch. + /// Adds a OpenInputFiltersDialog request to the batch. /// Opens the filters dialog of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder OpenInputFiltersDialog(ObsWebSocket.Core.Protocol.Requests.OpenInputFiltersDialogRequestData requestData) + /// A reference used to read this request's result. + public BatchRef OpenInputFiltersDialog(ObsWebSocket.Core.Protocol.Requests.OpenInputFiltersDialogRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("OpenInputFiltersDialog", requestData); + return new(builder.AddRequest("OpenInputFiltersDialog", requestData)); } /// - /// Appends a OpenInputInteractDialog request to the batch. + /// Adds a OpenInputInteractDialog request to the batch. /// Opens the interact dialog of an input. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder OpenInputInteractDialog(ObsWebSocket.Core.Protocol.Requests.OpenInputInteractDialogRequestData requestData) + /// A reference used to read this request's result. + public BatchRef OpenInputInteractDialog(ObsWebSocket.Core.Protocol.Requests.OpenInputInteractDialogRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("OpenInputInteractDialog", requestData); + return new(builder.AddRequest("OpenInputInteractDialog", requestData)); } /// - /// Appends a GetMonitorList request to the batch. + /// Adds a GetMonitorList request to the batch. /// Gets a list of connected monitors and information about them. /// - /// The same builder, for chaining. - public ObsBatchBuilder GetMonitorList() => Add("GetMonitorList", null); + /// A reference used to read this request's result. + public BatchRef GetMonitorList() => new(builder.AddRequest("GetMonitorList", null)); /// - /// Appends a OpenVideoMixProjector request to the batch. + /// Adds a OpenVideoMixProjector request to the batch. /// Opens a projector for a specific output video mix. Mix types: - `OBS_WEBSOCKET_VIDEO_MIX_TYPE_PREVIEW` - `OBS_WEBSOCKET_VIDEO_MIX_TYPE_PROGRAM` - `OBS_WEBSOCKET_VIDEO_MIX_TYPE_MULTIVIEW` Note: This request serves to provide feature parity with 4.x. It is very likely to be changed/deprecated in a future release. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder OpenVideoMixProjector(ObsWebSocket.Core.Protocol.Requests.OpenVideoMixProjectorRequestData requestData) + /// A reference used to read this request's result. + public BatchRef OpenVideoMixProjector(ObsWebSocket.Core.Protocol.Requests.OpenVideoMixProjectorRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("OpenVideoMixProjector", requestData); + return new(builder.AddRequest("OpenVideoMixProjector", requestData)); } /// - /// Appends a OpenSourceProjector request to the batch. + /// Adds a OpenSourceProjector request to the batch. /// Opens a projector for a source. Note: This request serves to provide feature parity with 4.x. It is very likely to be changed/deprecated in a future release. /// - /// The same builder, for chaining. /// The payload for this request. - public ObsBatchBuilder OpenSourceProjector(ObsWebSocket.Core.Protocol.Requests.OpenSourceProjectorRequestData requestData) + /// A reference used to read this request's result. + public BatchRef OpenSourceProjector(ObsWebSocket.Core.Protocol.Requests.OpenSourceProjectorRequestData requestData) { ArgumentNullException.ThrowIfNull(requestData); - return Add("OpenSourceProjector", requestData); + return new(builder.AddRequest("OpenSourceProjector", requestData)); } } + +public sealed partial class ObsBatchBuilder +{ + /// + /// Requests in the canvases category. + /// + public CanvasesBatchGroup Canvases => new(this); + + /// + /// Requests in the config category. + /// + public ConfigBatchGroup Config => new(this); + + /// + /// Requests in the filters category. + /// + public FiltersBatchGroup Filters => new(this); + + /// + /// Requests in the general category. + /// + public GeneralBatchGroup General => new(this); + + /// + /// Requests in the inputs category. + /// + public InputsBatchGroup Inputs => new(this); + + /// + /// Requests in the media inputs category. + /// + public MediaInputsBatchGroup MediaInputs => new(this); + + /// + /// Requests in the outputs category. + /// + public OutputsBatchGroup Outputs => new(this); + + /// + /// Requests in the record category. + /// + public RecordBatchGroup Record => new(this); + + /// + /// Requests in the scene items category. + /// + public SceneItemsBatchGroup SceneItems => new(this); + + /// + /// Requests in the scenes category. + /// + public ScenesBatchGroup Scenes => new(this); + + /// + /// Requests in the sources category. + /// + public SourcesBatchGroup Sources => new(this); + + /// + /// Requests in the stream category. + /// + public StreamBatchGroup Stream => new(this); + + /// + /// Requests in the transitions category. + /// + public TransitionsBatchGroup Transitions => new(this); + + /// + /// Requests in the ui category. + /// + public UiBatchGroup Ui => new(this); + +} diff --git a/ObsWebSocket.Core/Generated/Client/ObsWebSocketClient.Extensions.g.cs b/ObsWebSocket.Core/Generated/Client/ObsWebSocketClient.Extensions.g.cs index dddae70..fe45c15 100644 --- a/ObsWebSocket.Core/Generated/Client/ObsWebSocketClient.Extensions.g.cs +++ b/ObsWebSocket.Core/Generated/Client/ObsWebSocketClient.Extensions.g.cs @@ -14,15 +14,14 @@ namespace ObsWebSocket.Core; /// -/// Provides strongly-typed extension methods for the , -/// corresponding to the requests defined in the OBS WebSocket v5 protocol. +/// Requests in the canvases category. /// -public static partial class ObsWebSocketClientExtensions +/// The client these requests are sent on. +public readonly partial struct CanvasesRequestGroup(ObsWebSocketClient client) { /// /// Gets an array of canvases in OBS. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -33,15 +32,22 @@ public static partial class ObsWebSocketClientExtensions /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetCanvasListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetCanvasListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetCanvasList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the config category. +/// +/// The client these requests are sent on. +public readonly partial struct ConfigRequestGroup(ObsWebSocketClient client) +{ /// /// Gets the value of a "slot" from the selected persistent data realm. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -53,7 +59,7 @@ public static partial class ObsWebSocketClientExtensions /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetPersistentDataAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetPersistentDataRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetPersistentDataAsync(ObsWebSocket.Core.Protocol.Requests.GetPersistentDataRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetPersistentData", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -61,7 +67,6 @@ public static partial class ObsWebSocketClientExtensions /// /// Sets the value of a "slot" from the selected persistent data realm. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -73,7 +78,7 @@ public static partial class ObsWebSocketClientExtensions /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetPersistentDataAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetPersistentDataRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetPersistentDataAsync(ObsWebSocket.Core.Protocol.Requests.SetPersistentDataRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetPersistentData", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -81,7 +86,6 @@ public static async Task SetPersistentDataAsync(this ObsWebSocketClient client, /// /// Gets an array of all scene collections /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -92,7 +96,7 @@ public static async Task SetPersistentDataAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneCollectionListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetSceneCollectionListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneCollectionList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -102,7 +106,6 @@ public static async Task SetPersistentDataAsync(this ObsWebSocketClient client, /// /// Note: This will block until the collection has finished changing. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -114,7 +117,7 @@ public static async Task SetPersistentDataAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetCurrentSceneCollectionAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneCollectionRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetCurrentSceneCollectionAsync(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneCollectionRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetCurrentSceneCollection", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -124,7 +127,6 @@ public static async Task SetCurrentSceneCollectionAsync(this ObsWebSocketClient /// /// Note: This will block until the collection has finished changing. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -136,7 +138,7 @@ public static async Task SetCurrentSceneCollectionAsync(this ObsWebSocketClient /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CreateSceneCollectionAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CreateSceneCollectionRequestData requestData, CancellationToken cancellationToken = default) + public async Task CreateSceneCollectionAsync(ObsWebSocket.Core.Protocol.Requests.CreateSceneCollectionRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("CreateSceneCollection", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -144,7 +146,6 @@ public static async Task CreateSceneCollectionAsync(this ObsWebSocketClient clie /// /// Gets an array of all profiles /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -155,7 +156,7 @@ public static async Task CreateSceneCollectionAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetProfileListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetProfileListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetProfileList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -163,7 +164,6 @@ public static async Task CreateSceneCollectionAsync(this ObsWebSocketClient clie /// /// Switches to a profile. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -175,7 +175,7 @@ public static async Task CreateSceneCollectionAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetCurrentProfileAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetCurrentProfileRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetCurrentProfileAsync(ObsWebSocket.Core.Protocol.Requests.SetCurrentProfileRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetCurrentProfile", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -183,7 +183,6 @@ public static async Task SetCurrentProfileAsync(this ObsWebSocketClient client, /// /// Creates a new profile, switching to it in the process /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -195,7 +194,7 @@ public static async Task SetCurrentProfileAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CreateProfileAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CreateProfileRequestData requestData, CancellationToken cancellationToken = default) + public async Task CreateProfileAsync(ObsWebSocket.Core.Protocol.Requests.CreateProfileRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("CreateProfile", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -203,7 +202,6 @@ public static async Task CreateProfileAsync(this ObsWebSocketClient client, ObsW /// /// Removes a profile. If the current profile is chosen, it will change to a different profile first. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -215,7 +213,7 @@ public static async Task CreateProfileAsync(this ObsWebSocketClient client, ObsW /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task RemoveProfileAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.RemoveProfileRequestData requestData, CancellationToken cancellationToken = default) + public async Task RemoveProfileAsync(ObsWebSocket.Core.Protocol.Requests.RemoveProfileRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("RemoveProfile", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -223,7 +221,6 @@ public static async Task RemoveProfileAsync(this ObsWebSocketClient client, ObsW /// /// Gets a parameter from the current profile's configuration. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -235,7 +232,7 @@ public static async Task RemoveProfileAsync(this ObsWebSocketClient client, ObsW /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetProfileParameterAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetProfileParameterRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetProfileParameterAsync(ObsWebSocket.Core.Protocol.Requests.GetProfileParameterRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetProfileParameter", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -243,7 +240,6 @@ public static async Task RemoveProfileAsync(this ObsWebSocketClient client, ObsW /// /// Sets the value of a parameter in the current profile's configuration. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -255,7 +251,7 @@ public static async Task RemoveProfileAsync(this ObsWebSocketClient client, ObsW /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetProfileParameterAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetProfileParameterRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetProfileParameterAsync(ObsWebSocket.Core.Protocol.Requests.SetProfileParameterRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetProfileParameter", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -265,7 +261,6 @@ public static async Task SetProfileParameterAsync(this ObsWebSocketClient client /// /// Note: To get the true FPS value, divide the FPS numerator by the FPS denominator. Example: `60000/1001` /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -276,7 +271,7 @@ public static async Task SetProfileParameterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetVideoSettingsAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetVideoSettingsAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetVideoSettings", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -286,7 +281,6 @@ public static async Task SetProfileParameterAsync(this ObsWebSocketClient client /// /// Note: Fields must be specified in pairs. For example, you cannot set only `baseWidth` without needing to specify `baseHeight`. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -298,7 +292,7 @@ public static async Task SetProfileParameterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetVideoSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetVideoSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetVideoSettingsAsync(ObsWebSocket.Core.Protocol.Requests.SetVideoSettingsRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetVideoSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -306,7 +300,6 @@ public static async Task SetVideoSettingsAsync(this ObsWebSocketClient client, O /// /// Gets the current stream service settings (stream destination). /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -317,7 +310,7 @@ public static async Task SetVideoSettingsAsync(this ObsWebSocketClient client, O /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetStreamServiceSettingsAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetStreamServiceSettingsAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetStreamServiceSettings", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -327,7 +320,6 @@ public static async Task SetVideoSettingsAsync(this ObsWebSocketClient client, O /// /// Note: Simple RTMP settings can be set with type `rtmp_custom` and the settings fields `server` and `key`. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -339,7 +331,7 @@ public static async Task SetVideoSettingsAsync(this ObsWebSocketClient client, O /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetStreamServiceSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetStreamServiceSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetStreamServiceSettingsAsync(ObsWebSocket.Core.Protocol.Requests.SetStreamServiceSettingsRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetStreamServiceSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -347,7 +339,6 @@ public static async Task SetStreamServiceSettingsAsync(this ObsWebSocketClient c /// /// Gets the current directory that the record output is set to. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -358,7 +349,7 @@ public static async Task SetStreamServiceSettingsAsync(this ObsWebSocketClient c /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetRecordDirectoryAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetRecordDirectoryAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetRecordDirectory", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -366,7 +357,6 @@ public static async Task SetStreamServiceSettingsAsync(this ObsWebSocketClient c /// /// Sets the current directory that the record output writes files to. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -378,17 +368,24 @@ public static async Task SetStreamServiceSettingsAsync(this ObsWebSocketClient c /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetRecordDirectoryRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetRecordDirectoryAsync(ObsWebSocket.Core.Protocol.Requests.SetRecordDirectoryRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetRecordDirectory", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the filters category. +/// +/// The client these requests are sent on. +public readonly partial struct FiltersRequestGroup(ObsWebSocketClient client) +{ /// /// Gets an array of all available source filter kinds. /// /// Similar to `GetInputKindList` /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -399,7 +396,7 @@ public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSourceFilterKindListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetSourceFilterKindListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSourceFilterKindList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -407,7 +404,6 @@ public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, /// /// Gets an array of all of a source's filters. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -419,7 +415,7 @@ public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSourceFilterListAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSourceFilterListRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSourceFilterListAsync(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterListRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSourceFilterList", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -427,7 +423,6 @@ public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, /// /// Gets the default settings for a filter kind. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -439,7 +434,7 @@ public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSourceFilterDefaultSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSourceFilterDefaultSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSourceFilterDefaultSettingsAsync(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterDefaultSettingsRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSourceFilterDefaultSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -447,7 +442,6 @@ public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, /// /// Creates a new filter, adding it to the specified source. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -459,7 +453,7 @@ public static async Task SetRecordDirectoryAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CreateSourceFilterAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CreateSourceFilterRequestData requestData, CancellationToken cancellationToken = default) + public async Task CreateSourceFilterAsync(ObsWebSocket.Core.Protocol.Requests.CreateSourceFilterRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("CreateSourceFilter", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -467,7 +461,6 @@ public static async Task CreateSourceFilterAsync(this ObsWebSocketClient client, /// /// Removes a filter from a source. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -479,7 +472,7 @@ public static async Task CreateSourceFilterAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task RemoveSourceFilterAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.RemoveSourceFilterRequestData requestData, CancellationToken cancellationToken = default) + public async Task RemoveSourceFilterAsync(ObsWebSocket.Core.Protocol.Requests.RemoveSourceFilterRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("RemoveSourceFilter", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -487,7 +480,6 @@ public static async Task RemoveSourceFilterAsync(this ObsWebSocketClient client, /// /// Sets the name of a source filter (rename). /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -499,7 +491,7 @@ public static async Task RemoveSourceFilterAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSourceFilterNameAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSourceFilterNameRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSourceFilterNameAsync(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterNameRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSourceFilterName", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -507,7 +499,6 @@ public static async Task SetSourceFilterNameAsync(this ObsWebSocketClient client /// /// Gets the info for a specific source filter. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -519,7 +510,7 @@ public static async Task SetSourceFilterNameAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSourceFilterAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSourceFilterRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSourceFilterAsync(ObsWebSocket.Core.Protocol.Requests.GetSourceFilterRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSourceFilter", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -527,7 +518,6 @@ public static async Task SetSourceFilterNameAsync(this ObsWebSocketClient client /// /// Sets the index position of a filter on a source. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -539,7 +529,7 @@ public static async Task SetSourceFilterNameAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSourceFilterIndexAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSourceFilterIndexRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSourceFilterIndexAsync(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterIndexRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSourceFilterIndex", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -547,7 +537,6 @@ public static async Task SetSourceFilterIndexAsync(this ObsWebSocketClient clien /// /// Sets the settings of a source filter. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -559,7 +548,7 @@ public static async Task SetSourceFilterIndexAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSourceFilterSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSourceFilterSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSourceFilterSettingsAsync(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterSettingsRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSourceFilterSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -567,7 +556,6 @@ public static async Task SetSourceFilterSettingsAsync(this ObsWebSocketClient cl /// /// Sets the enable state of a source filter. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -579,15 +567,22 @@ public static async Task SetSourceFilterSettingsAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSourceFilterEnabledAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSourceFilterEnabledRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSourceFilterEnabledAsync(ObsWebSocket.Core.Protocol.Requests.SetSourceFilterEnabledRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSourceFilterEnabled", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the general category. +/// +/// The client these requests are sent on. +public readonly partial struct GeneralRequestGroup(ObsWebSocketClient client) +{ /// /// Gets data about the current plugin and RPC version. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -598,7 +593,7 @@ public static async Task SetSourceFilterEnabledAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetVersionAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetVersionAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetVersion", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -606,7 +601,6 @@ public static async Task SetSourceFilterEnabledAsync(this ObsWebSocketClient cli /// /// Gets statistics about OBS, obs-websocket, and the current session. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -617,7 +611,7 @@ public static async Task SetSourceFilterEnabledAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetStatsAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetStatsAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetStats", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -625,7 +619,6 @@ public static async Task SetSourceFilterEnabledAsync(this ObsWebSocketClient cli /// /// Broadcasts a `CustomEvent` to all WebSocket clients. Receivers are clients which are identified and subscribed. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -637,7 +630,7 @@ public static async Task SetSourceFilterEnabledAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task BroadcastCustomEventAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.BroadcastCustomEventRequestData requestData, CancellationToken cancellationToken = default) + public async Task BroadcastCustomEventAsync(ObsWebSocket.Core.Protocol.Requests.BroadcastCustomEventRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("BroadcastCustomEvent", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -648,7 +641,6 @@ public static async Task BroadcastCustomEventAsync(this ObsWebSocketClient clien /// A vendor is a unique name registered by a third-party plugin or script, which allows for custom requests and events to be added to obs-websocket. /// If a plugin or script implements vendor requests or events, documentation is expected to be provided with them. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -660,7 +652,7 @@ public static async Task BroadcastCustomEventAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CallVendorRequestAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CallVendorRequestRequestData requestData, CancellationToken cancellationToken = default) + public async Task CallVendorRequestAsync(ObsWebSocket.Core.Protocol.Requests.CallVendorRequestRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("CallVendorRequest", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -670,7 +662,6 @@ public static async Task BroadcastCustomEventAsync(this ObsWebSocketClient clien /// /// Note: Hotkey functionality in obs-websocket comes as-is, and we do not guarantee support if things are broken. In 9/10 usages of hotkey requests, there exists a better, more reliable method via other requests. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -681,7 +672,7 @@ public static async Task BroadcastCustomEventAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetHotkeyListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetHotkeyListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetHotkeyList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -691,7 +682,6 @@ public static async Task BroadcastCustomEventAsync(this ObsWebSocketClient clien /// /// Note: Hotkey functionality in obs-websocket comes as-is, and we do not guarantee support if things are broken. In 9/10 usages of hotkey requests, there exists a better, more reliable method via other requests. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -703,7 +693,7 @@ public static async Task BroadcastCustomEventAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task TriggerHotkeyByNameAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByNameRequestData requestData, CancellationToken cancellationToken = default) + public async Task TriggerHotkeyByNameAsync(ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByNameRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("TriggerHotkeyByName", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -713,7 +703,6 @@ public static async Task TriggerHotkeyByNameAsync(this ObsWebSocketClient client /// /// Note: Hotkey functionality in obs-websocket comes as-is, and we do not guarantee support if things are broken. In 9/10 usages of hotkey requests, there exists a better, more reliable method via other requests. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -725,7 +714,7 @@ public static async Task TriggerHotkeyByNameAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task TriggerHotkeyByKeySequenceAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByKeySequenceRequestData requestData, CancellationToken cancellationToken = default) + public async Task TriggerHotkeyByKeySequenceAsync(ObsWebSocket.Core.Protocol.Requests.TriggerHotkeyByKeySequenceRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("TriggerHotkeyByKeySequence", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -733,7 +722,6 @@ public static async Task TriggerHotkeyByKeySequenceAsync(this ObsWebSocketClient /// /// Sleeps for a time duration or number of frames. Only available in request batches with types `SERIAL_REALTIME` or `SERIAL_FRAME`. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -745,15 +733,22 @@ public static async Task TriggerHotkeyByKeySequenceAsync(this ObsWebSocketClient /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SleepRequestData requestData, CancellationToken cancellationToken = default) + public async Task SleepAsync(ObsWebSocket.Core.Protocol.Requests.SleepRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("Sleep", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the inputs category. +/// +/// The client these requests are sent on. +public readonly partial struct InputsRequestGroup(ObsWebSocketClient client) +{ /// /// Gets an array of all inputs in OBS. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -765,7 +760,7 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputListAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputListRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputListAsync(ObsWebSocket.Core.Protocol.Requests.GetInputListRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputList", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -773,7 +768,6 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// /// Gets an array of all available input kinds in OBS. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -785,7 +779,7 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputKindListAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputKindListRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputKindListAsync(ObsWebSocket.Core.Protocol.Requests.GetInputKindListRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputKindList", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -793,7 +787,6 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// /// Gets the names of all special inputs. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -804,7 +797,7 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSpecialInputsAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetSpecialInputsAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSpecialInputs", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -812,7 +805,6 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// /// Creates a new input, adding it as a scene item to the specified scene. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -824,7 +816,7 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CreateInputAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CreateInputRequestData requestData, CancellationToken cancellationToken = default) + public async Task CreateInputAsync(ObsWebSocket.Core.Protocol.Requests.CreateInputRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("CreateInput", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -834,7 +826,6 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// /// Note: Will immediately remove all associated scene items. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -846,7 +837,7 @@ public static async Task SleepAsync(this ObsWebSocketClient client, ObsWebSocket /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task RemoveInputAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.RemoveInputRequestData requestData, CancellationToken cancellationToken = default) + public async Task RemoveInputAsync(ObsWebSocket.Core.Protocol.Requests.RemoveInputRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("RemoveInput", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -854,7 +845,6 @@ public static async Task RemoveInputAsync(this ObsWebSocketClient client, ObsWeb /// /// Sets the name of an input (rename). /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -866,7 +856,7 @@ public static async Task RemoveInputAsync(this ObsWebSocketClient client, ObsWeb /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputNameAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputNameRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputNameAsync(ObsWebSocket.Core.Protocol.Requests.SetInputNameRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputName", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -874,7 +864,6 @@ public static async Task SetInputNameAsync(this ObsWebSocketClient client, ObsWe /// /// Gets the default settings for an input kind. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -886,7 +875,7 @@ public static async Task SetInputNameAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputDefaultSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputDefaultSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputDefaultSettingsAsync(ObsWebSocket.Core.Protocol.Requests.GetInputDefaultSettingsRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputDefaultSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -896,7 +885,6 @@ public static async Task SetInputNameAsync(this ObsWebSocketClient client, ObsWe /// /// Note: Does not include defaults. To create the entire settings object, overlay `inputSettings` over the `defaultInputSettings` provided by `GetInputDefaultSettings`. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -908,7 +896,7 @@ public static async Task SetInputNameAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputSettingsAsync(ObsWebSocket.Core.Protocol.Requests.GetInputSettingsRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -916,7 +904,6 @@ public static async Task SetInputNameAsync(this ObsWebSocketClient client, ObsWe /// /// Sets the settings of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -928,7 +915,7 @@ public static async Task SetInputNameAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputSettingsAsync(ObsWebSocket.Core.Protocol.Requests.SetInputSettingsRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -936,7 +923,6 @@ public static async Task SetInputSettingsAsync(this ObsWebSocketClient client, O /// /// Gets the audio mute state of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -948,7 +934,7 @@ public static async Task SetInputSettingsAsync(this ObsWebSocketClient client, O /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputMuteAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputMuteRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputMuteAsync(ObsWebSocket.Core.Protocol.Requests.GetInputMuteRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputMute", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -956,7 +942,6 @@ public static async Task SetInputSettingsAsync(this ObsWebSocketClient client, O /// /// Sets the audio mute state of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -968,7 +953,7 @@ public static async Task SetInputSettingsAsync(this ObsWebSocketClient client, O /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputMuteAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputMuteRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputMuteAsync(ObsWebSocket.Core.Protocol.Requests.SetInputMuteRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputMute", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -976,7 +961,6 @@ public static async Task SetInputMuteAsync(this ObsWebSocketClient client, ObsWe /// /// Toggles the audio mute state of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -988,7 +972,7 @@ public static async Task SetInputMuteAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ToggleInputMuteAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.ToggleInputMuteRequestData requestData, CancellationToken cancellationToken = default) + public async Task ToggleInputMuteAsync(ObsWebSocket.Core.Protocol.Requests.ToggleInputMuteRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("ToggleInputMute", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -996,7 +980,6 @@ public static async Task SetInputMuteAsync(this ObsWebSocketClient client, ObsWe /// /// Gets the current volume setting of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1008,7 +991,7 @@ public static async Task SetInputMuteAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputVolumeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputVolumeRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputVolumeAsync(ObsWebSocket.Core.Protocol.Requests.GetInputVolumeRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputVolume", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1016,7 +999,6 @@ public static async Task SetInputMuteAsync(this ObsWebSocketClient client, ObsWe /// /// Sets the volume setting of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1028,7 +1010,7 @@ public static async Task SetInputMuteAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputVolumeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputVolumeRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputVolumeAsync(ObsWebSocket.Core.Protocol.Requests.SetInputVolumeRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputVolume", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1036,7 +1018,6 @@ public static async Task SetInputVolumeAsync(this ObsWebSocketClient client, Obs /// /// Gets the audio balance of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1048,7 +1029,7 @@ public static async Task SetInputVolumeAsync(this ObsWebSocketClient client, Obs /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputAudioBalanceAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputAudioBalanceRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputAudioBalanceAsync(ObsWebSocket.Core.Protocol.Requests.GetInputAudioBalanceRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputAudioBalance", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1056,7 +1037,6 @@ public static async Task SetInputVolumeAsync(this ObsWebSocketClient client, Obs /// /// Sets the audio balance of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1068,7 +1048,7 @@ public static async Task SetInputVolumeAsync(this ObsWebSocketClient client, Obs /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputAudioBalanceAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputAudioBalanceRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputAudioBalanceAsync(ObsWebSocket.Core.Protocol.Requests.SetInputAudioBalanceRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputAudioBalance", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1078,7 +1058,6 @@ public static async Task SetInputAudioBalanceAsync(this ObsWebSocketClient clien /// /// Note: The audio sync offset can be negative too! /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1090,7 +1069,7 @@ public static async Task SetInputAudioBalanceAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputAudioSyncOffsetAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputAudioSyncOffsetRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputAudioSyncOffsetAsync(ObsWebSocket.Core.Protocol.Requests.GetInputAudioSyncOffsetRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputAudioSyncOffset", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1098,7 +1077,6 @@ public static async Task SetInputAudioBalanceAsync(this ObsWebSocketClient clien /// /// Sets the audio sync offset of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1110,7 +1088,7 @@ public static async Task SetInputAudioBalanceAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputAudioSyncOffsetAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputAudioSyncOffsetRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputAudioSyncOffsetAsync(ObsWebSocket.Core.Protocol.Requests.SetInputAudioSyncOffsetRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputAudioSyncOffset", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1124,7 +1102,6 @@ public static async Task SetInputAudioSyncOffsetAsync(this ObsWebSocketClient cl /// - `OBS_MONITORING_TYPE_MONITOR_ONLY` /// - `OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT` /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1136,7 +1113,7 @@ public static async Task SetInputAudioSyncOffsetAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputAudioMonitorTypeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputAudioMonitorTypeRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputAudioMonitorTypeAsync(ObsWebSocket.Core.Protocol.Requests.GetInputAudioMonitorTypeRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputAudioMonitorType", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1144,7 +1121,6 @@ public static async Task SetInputAudioSyncOffsetAsync(this ObsWebSocketClient cl /// /// Sets the audio monitor type of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1156,7 +1132,7 @@ public static async Task SetInputAudioSyncOffsetAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputAudioMonitorTypeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputAudioMonitorTypeRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputAudioMonitorTypeAsync(ObsWebSocket.Core.Protocol.Requests.SetInputAudioMonitorTypeRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputAudioMonitorType", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1164,7 +1140,6 @@ public static async Task SetInputAudioMonitorTypeAsync(this ObsWebSocketClient c /// /// Gets the enable state of all audio tracks of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1176,7 +1151,7 @@ public static async Task SetInputAudioMonitorTypeAsync(this ObsWebSocketClient c /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputAudioTracksAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputAudioTracksRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputAudioTracksAsync(ObsWebSocket.Core.Protocol.Requests.GetInputAudioTracksRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputAudioTracks", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1184,7 +1159,6 @@ public static async Task SetInputAudioMonitorTypeAsync(this ObsWebSocketClient c /// /// Sets the enable state of audio tracks of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1196,7 +1170,7 @@ public static async Task SetInputAudioMonitorTypeAsync(this ObsWebSocketClient c /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputAudioTracksAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputAudioTracksRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputAudioTracksAsync(ObsWebSocket.Core.Protocol.Requests.SetInputAudioTracksRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputAudioTracks", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1218,7 +1192,6 @@ public static async Task SetInputAudioTracksAsync(this ObsWebSocketClient client /// /// Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1230,7 +1203,7 @@ public static async Task SetInputAudioTracksAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputDeinterlaceModeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceModeRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputDeinterlaceModeAsync(ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceModeRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputDeinterlaceMode", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1240,7 +1213,6 @@ public static async Task SetInputAudioTracksAsync(this ObsWebSocketClient client /// /// Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1252,7 +1224,7 @@ public static async Task SetInputAudioTracksAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputDeinterlaceModeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceModeRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputDeinterlaceModeAsync(ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceModeRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputDeinterlaceMode", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1267,7 +1239,6 @@ public static async Task SetInputDeinterlaceModeAsync(this ObsWebSocketClient cl /// /// Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1279,7 +1250,7 @@ public static async Task SetInputDeinterlaceModeAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputDeinterlaceFieldOrderAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceFieldOrderRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputDeinterlaceFieldOrderAsync(ObsWebSocket.Core.Protocol.Requests.GetInputDeinterlaceFieldOrderRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputDeinterlaceFieldOrder", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1289,7 +1260,6 @@ public static async Task SetInputDeinterlaceModeAsync(this ObsWebSocketClient cl /// /// Note: Deinterlacing functionality is restricted to async inputs only. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1301,7 +1271,7 @@ public static async Task SetInputDeinterlaceModeAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetInputDeinterlaceFieldOrderAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceFieldOrderRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetInputDeinterlaceFieldOrderAsync(ObsWebSocket.Core.Protocol.Requests.SetInputDeinterlaceFieldOrderRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetInputDeinterlaceFieldOrder", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1311,7 +1281,6 @@ public static async Task SetInputDeinterlaceFieldOrderAsync(this ObsWebSocketCli /// /// Note: Use this in cases where an input provides a dynamic, selectable list of items. For example, display capture, where it provides a list of available displays. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1323,7 +1292,7 @@ public static async Task SetInputDeinterlaceFieldOrderAsync(this ObsWebSocketCli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetInputPropertiesListPropertyItemsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetInputPropertiesListPropertyItemsRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetInputPropertiesListPropertyItemsAsync(ObsWebSocket.Core.Protocol.Requests.GetInputPropertiesListPropertyItemsRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetInputPropertiesListPropertyItems", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1337,7 +1306,6 @@ public static async Task SetInputDeinterlaceFieldOrderAsync(this ObsWebSocketCli /// /// Note: Use this in cases where there is a button in the properties of an input that cannot be accessed in any other way. For example, browser sources, where there is a refresh button. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1349,11 +1317,19 @@ public static async Task SetInputDeinterlaceFieldOrderAsync(this ObsWebSocketCli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task PressInputPropertiesButtonAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.PressInputPropertiesButtonRequestData requestData, CancellationToken cancellationToken = default) + public async Task PressInputPropertiesButtonAsync(ObsWebSocket.Core.Protocol.Requests.PressInputPropertiesButtonRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("PressInputPropertiesButton", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the media inputs category. +/// +/// The client these requests are sent on. +public readonly partial struct MediaInputsRequestGroup(ObsWebSocketClient client) +{ /// /// Gets the status of a media input. /// @@ -1368,7 +1344,6 @@ public static async Task PressInputPropertiesButtonAsync(this ObsWebSocketClient /// - `OBS_MEDIA_STATE_ENDED` /// - `OBS_MEDIA_STATE_ERROR` /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1380,7 +1355,7 @@ public static async Task PressInputPropertiesButtonAsync(this ObsWebSocketClient /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetMediaInputStatusAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetMediaInputStatusRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetMediaInputStatusAsync(ObsWebSocket.Core.Protocol.Requests.GetMediaInputStatusRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetMediaInputStatus", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1390,7 +1365,6 @@ public static async Task PressInputPropertiesButtonAsync(this ObsWebSocketClient /// /// This request does not perform bounds checking of the cursor position. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1402,7 +1376,7 @@ public static async Task PressInputPropertiesButtonAsync(this ObsWebSocketClient /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetMediaInputCursorAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetMediaInputCursorRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetMediaInputCursorAsync(ObsWebSocket.Core.Protocol.Requests.SetMediaInputCursorRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetMediaInputCursor", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1412,7 +1386,6 @@ public static async Task SetMediaInputCursorAsync(this ObsWebSocketClient client /// /// This request does not perform bounds checking of the cursor position. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1424,7 +1397,7 @@ public static async Task SetMediaInputCursorAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task OffsetMediaInputCursorAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.OffsetMediaInputCursorRequestData requestData, CancellationToken cancellationToken = default) + public async Task OffsetMediaInputCursorAsync(ObsWebSocket.Core.Protocol.Requests.OffsetMediaInputCursorRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("OffsetMediaInputCursor", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1432,7 +1405,6 @@ public static async Task OffsetMediaInputCursorAsync(this ObsWebSocketClient cli /// /// Triggers an action on a media input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1444,15 +1416,22 @@ public static async Task OffsetMediaInputCursorAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task TriggerMediaInputActionAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.TriggerMediaInputActionRequestData requestData, CancellationToken cancellationToken = default) + public async Task TriggerMediaInputActionAsync(ObsWebSocket.Core.Protocol.Requests.TriggerMediaInputActionRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("TriggerMediaInputAction", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the outputs category. +/// +/// The client these requests are sent on. +public readonly partial struct OutputsRequestGroup(ObsWebSocketClient client) +{ /// /// Gets the status of the virtualcam output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1463,7 +1442,7 @@ public static async Task TriggerMediaInputActionAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetVirtualCamStatusAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetVirtualCamStatusAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetVirtualCamStatus", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1471,7 +1450,6 @@ public static async Task TriggerMediaInputActionAsync(this ObsWebSocketClient cl /// /// Toggles the state of the virtualcam output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1482,7 +1460,7 @@ public static async Task TriggerMediaInputActionAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ToggleVirtualCamAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task ToggleVirtualCamAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("ToggleVirtualCam", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1490,7 +1468,6 @@ public static async Task TriggerMediaInputActionAsync(this ObsWebSocketClient cl /// /// Starts the virtualcam output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1501,7 +1478,7 @@ public static async Task TriggerMediaInputActionAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StartVirtualCamAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StartVirtualCamAsync(CancellationToken cancellationToken = default) { await client.CallAsync("StartVirtualCam", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1509,7 +1486,6 @@ public static async Task StartVirtualCamAsync(this ObsWebSocketClient client, Ca /// /// Stops the virtualcam output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1520,7 +1496,7 @@ public static async Task StartVirtualCamAsync(this ObsWebSocketClient client, Ca /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StopVirtualCamAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StopVirtualCamAsync(CancellationToken cancellationToken = default) { await client.CallAsync("StopVirtualCam", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1528,7 +1504,6 @@ public static async Task StopVirtualCamAsync(this ObsWebSocketClient client, Can /// /// Gets the status of the replay buffer output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1539,7 +1514,7 @@ public static async Task StopVirtualCamAsync(this ObsWebSocketClient client, Can /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetReplayBufferStatusAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetReplayBufferStatusAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetReplayBufferStatus", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1547,7 +1522,6 @@ public static async Task StopVirtualCamAsync(this ObsWebSocketClient client, Can /// /// Toggles the state of the replay buffer output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1558,7 +1532,7 @@ public static async Task StopVirtualCamAsync(this ObsWebSocketClient client, Can /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ToggleReplayBufferAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task ToggleReplayBufferAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("ToggleReplayBuffer", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1566,7 +1540,6 @@ public static async Task StopVirtualCamAsync(this ObsWebSocketClient client, Can /// /// Starts the replay buffer output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1577,7 +1550,7 @@ public static async Task StopVirtualCamAsync(this ObsWebSocketClient client, Can /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StartReplayBufferAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StartReplayBufferAsync(CancellationToken cancellationToken = default) { await client.CallAsync("StartReplayBuffer", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1585,7 +1558,6 @@ public static async Task StartReplayBufferAsync(this ObsWebSocketClient client, /// /// Stops the replay buffer output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1596,7 +1568,7 @@ public static async Task StartReplayBufferAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StopReplayBufferAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StopReplayBufferAsync(CancellationToken cancellationToken = default) { await client.CallAsync("StopReplayBuffer", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1604,7 +1576,6 @@ public static async Task StopReplayBufferAsync(this ObsWebSocketClient client, C /// /// Saves the contents of the replay buffer output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1615,7 +1586,7 @@ public static async Task StopReplayBufferAsync(this ObsWebSocketClient client, C /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task SaveReplayBufferAsync(CancellationToken cancellationToken = default) { await client.CallAsync("SaveReplayBuffer", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1623,7 +1594,6 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// /// Gets the filename of the last replay buffer save file. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1634,7 +1604,7 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetLastReplayBufferReplayAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetLastReplayBufferReplayAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetLastReplayBufferReplay", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1642,7 +1612,6 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// /// Gets the list of available outputs. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1653,7 +1622,7 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetOutputListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetOutputListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetOutputList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1661,7 +1630,6 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// /// Gets the status of an output. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1673,7 +1641,7 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetOutputStatusAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetOutputStatusRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetOutputStatusAsync(ObsWebSocket.Core.Protocol.Requests.GetOutputStatusRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetOutputStatus", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1681,7 +1649,6 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// /// Toggles the status of an output. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1693,7 +1660,7 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ToggleOutputAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.ToggleOutputRequestData requestData, CancellationToken cancellationToken = default) + public async Task ToggleOutputAsync(ObsWebSocket.Core.Protocol.Requests.ToggleOutputRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("ToggleOutput", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1701,7 +1668,6 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// /// Starts an output. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1713,7 +1679,7 @@ public static async Task SaveReplayBufferAsync(this ObsWebSocketClient client, C /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StartOutputAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.StartOutputRequestData requestData, CancellationToken cancellationToken = default) + public async Task StartOutputAsync(ObsWebSocket.Core.Protocol.Requests.StartOutputRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("StartOutput", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1721,7 +1687,6 @@ public static async Task StartOutputAsync(this ObsWebSocketClient client, ObsWeb /// /// Stops an output. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1733,7 +1698,7 @@ public static async Task StartOutputAsync(this ObsWebSocketClient client, ObsWeb /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StopOutputAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.StopOutputRequestData requestData, CancellationToken cancellationToken = default) + public async Task StopOutputAsync(ObsWebSocket.Core.Protocol.Requests.StopOutputRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("StopOutput", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1741,7 +1706,6 @@ public static async Task StopOutputAsync(this ObsWebSocketClient client, ObsWebS /// /// Gets the settings of an output. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1753,7 +1717,7 @@ public static async Task StopOutputAsync(this ObsWebSocketClient client, ObsWebS /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetOutputSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetOutputSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetOutputSettingsAsync(ObsWebSocket.Core.Protocol.Requests.GetOutputSettingsRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetOutputSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1761,7 +1725,6 @@ public static async Task StopOutputAsync(this ObsWebSocketClient client, ObsWebS /// /// Sets the settings of an output. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1773,15 +1736,22 @@ public static async Task StopOutputAsync(this ObsWebSocketClient client, ObsWebS /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetOutputSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetOutputSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetOutputSettingsAsync(ObsWebSocket.Core.Protocol.Requests.SetOutputSettingsRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetOutputSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the record category. +/// +/// The client these requests are sent on. +public readonly partial struct RecordRequestGroup(ObsWebSocketClient client) +{ /// /// Gets the status of the record output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1792,7 +1762,7 @@ public static async Task SetOutputSettingsAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetRecordStatusAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetRecordStatusAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetRecordStatus", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1800,7 +1770,6 @@ public static async Task SetOutputSettingsAsync(this ObsWebSocketClient client, /// /// Toggles the status of the record output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1811,7 +1780,7 @@ public static async Task SetOutputSettingsAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ToggleRecordAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task ToggleRecordAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("ToggleRecord", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1819,7 +1788,6 @@ public static async Task SetOutputSettingsAsync(this ObsWebSocketClient client, /// /// Starts the record output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1830,7 +1798,7 @@ public static async Task SetOutputSettingsAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StartRecordAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StartRecordAsync(CancellationToken cancellationToken = default) { await client.CallAsync("StartRecord", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1838,7 +1806,6 @@ public static async Task StartRecordAsync(this ObsWebSocketClient client, Cancel /// /// Stops the record output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -1849,7 +1816,7 @@ public static async Task StartRecordAsync(this ObsWebSocketClient client, Cancel /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StopRecordAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StopRecordAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("StopRecord", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1857,7 +1824,6 @@ public static async Task StartRecordAsync(this ObsWebSocketClient client, Cancel /// /// Toggles pause on the record output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1868,7 +1834,7 @@ public static async Task StartRecordAsync(this ObsWebSocketClient client, Cancel /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ToggleRecordPauseAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task ToggleRecordPauseAsync(CancellationToken cancellationToken = default) { await client.CallAsync("ToggleRecordPause", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1876,7 +1842,6 @@ public static async Task ToggleRecordPauseAsync(this ObsWebSocketClient client, /// /// Pauses the record output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1887,7 +1852,7 @@ public static async Task ToggleRecordPauseAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task PauseRecordAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task PauseRecordAsync(CancellationToken cancellationToken = default) { await client.CallAsync("PauseRecord", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1895,7 +1860,6 @@ public static async Task PauseRecordAsync(this ObsWebSocketClient client, Cancel /// /// Resumes the record output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1906,7 +1870,7 @@ public static async Task PauseRecordAsync(this ObsWebSocketClient client, Cancel /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ResumeRecordAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task ResumeRecordAsync(CancellationToken cancellationToken = default) { await client.CallAsync("ResumeRecord", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1914,7 +1878,6 @@ public static async Task ResumeRecordAsync(this ObsWebSocketClient client, Cance /// /// Splits the current file being recorded into a new file. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -1925,7 +1888,7 @@ public static async Task ResumeRecordAsync(this ObsWebSocketClient client, Cance /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SplitRecordFileAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task SplitRecordFileAsync(CancellationToken cancellationToken = default) { await client.CallAsync("SplitRecordFile", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1935,7 +1898,6 @@ public static async Task SplitRecordFileAsync(this ObsWebSocketClient client, Ca /// /// Note: As of OBS 30.2.0, the only file format supporting this feature is Hybrid MP4. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -1947,17 +1909,24 @@ public static async Task SplitRecordFileAsync(this ObsWebSocketClient client, Ca /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CreateRecordChapterRequestData requestData, CancellationToken cancellationToken = default) + public async Task CreateRecordChapterAsync(ObsWebSocket.Core.Protocol.Requests.CreateRecordChapterRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("CreateRecordChapter", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the scene items category. +/// +/// The client these requests are sent on. +public readonly partial struct SceneItemsRequestGroup(ObsWebSocketClient client) +{ /// /// Gets a list of all scene items in a scene. /// /// Scenes only /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1969,7 +1938,7 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemListAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemListRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemListAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemListRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemList", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -1981,7 +1950,6 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// /// Groups only /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -1993,7 +1961,7 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetGroupSceneItemListAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetGroupSceneItemListRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetGroupSceneItemListAsync(ObsWebSocket.Core.Protocol.Requests.GetGroupSceneItemListRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetGroupSceneItemList", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2003,7 +1971,6 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2015,7 +1982,7 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemIdAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemIdRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemIdAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemIdRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemId", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2023,7 +1990,6 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// /// Gets the source associated with a scene item. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2035,7 +2001,7 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemSourceAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemSourceRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemSourceAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemSourceRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemSource", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2045,7 +2011,6 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// /// Scenes only /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2057,7 +2022,7 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CreateSceneItemAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CreateSceneItemRequestData requestData, CancellationToken cancellationToken = default) + public async Task CreateSceneItemAsync(ObsWebSocket.Core.Protocol.Requests.CreateSceneItemRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("CreateSceneItem", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2067,7 +2032,6 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// /// Scenes only /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2079,7 +2043,7 @@ public static async Task CreateRecordChapterAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task RemoveSceneItemAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.RemoveSceneItemRequestData requestData, CancellationToken cancellationToken = default) + public async Task RemoveSceneItemAsync(ObsWebSocket.Core.Protocol.Requests.RemoveSceneItemRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("RemoveSceneItem", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2089,7 +2053,6 @@ public static async Task RemoveSceneItemAsync(this ObsWebSocketClient client, Ob /// /// Scenes only /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2101,7 +2064,7 @@ public static async Task RemoveSceneItemAsync(this ObsWebSocketClient client, Ob /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task DuplicateSceneItemAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.DuplicateSceneItemRequestData requestData, CancellationToken cancellationToken = default) + public async Task DuplicateSceneItemAsync(ObsWebSocket.Core.Protocol.Requests.DuplicateSceneItemRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("DuplicateSceneItem", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2111,7 +2074,6 @@ public static async Task RemoveSceneItemAsync(this ObsWebSocketClient client, Ob /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2123,7 +2085,7 @@ public static async Task RemoveSceneItemAsync(this ObsWebSocketClient client, Ob /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemTransformAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemTransformRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemTransformAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemTransformRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemTransform", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2131,7 +2093,6 @@ public static async Task RemoveSceneItemAsync(this ObsWebSocketClient client, Ob /// /// Sets the transform and crop info of a scene item. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2143,7 +2104,7 @@ public static async Task RemoveSceneItemAsync(this ObsWebSocketClient client, Ob /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSceneItemTransformAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSceneItemTransformRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSceneItemTransformAsync(ObsWebSocket.Core.Protocol.Requests.SetSceneItemTransformRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSceneItemTransform", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2153,7 +2114,6 @@ public static async Task SetSceneItemTransformAsync(this ObsWebSocketClient clie /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2165,7 +2125,7 @@ public static async Task SetSceneItemTransformAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemEnabledAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemEnabledRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemEnabledAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemEnabledRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemEnabled", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2175,7 +2135,6 @@ public static async Task SetSceneItemTransformAsync(this ObsWebSocketClient clie /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2187,7 +2146,7 @@ public static async Task SetSceneItemTransformAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSceneItemEnabledAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSceneItemEnabledRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSceneItemEnabledAsync(ObsWebSocket.Core.Protocol.Requests.SetSceneItemEnabledRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSceneItemEnabled", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2197,7 +2156,6 @@ public static async Task SetSceneItemEnabledAsync(this ObsWebSocketClient client /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2209,7 +2167,7 @@ public static async Task SetSceneItemEnabledAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemLockedAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemLockedRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemLockedAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemLockedRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemLocked", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2219,7 +2177,6 @@ public static async Task SetSceneItemEnabledAsync(this ObsWebSocketClient client /// /// Scenes and Group /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2231,7 +2188,7 @@ public static async Task SetSceneItemEnabledAsync(this ObsWebSocketClient client /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSceneItemLockedAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSceneItemLockedRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSceneItemLockedAsync(ObsWebSocket.Core.Protocol.Requests.SetSceneItemLockedRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSceneItemLocked", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2243,7 +2200,6 @@ public static async Task SetSceneItemLockedAsync(this ObsWebSocketClient client, /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2255,7 +2211,7 @@ public static async Task SetSceneItemLockedAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemIndexAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemIndexRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemIndexAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemIndexRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemIndex", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2265,7 +2221,6 @@ public static async Task SetSceneItemLockedAsync(this ObsWebSocketClient client, /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2277,7 +2232,7 @@ public static async Task SetSceneItemLockedAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSceneItemIndexAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSceneItemIndexRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSceneItemIndexAsync(ObsWebSocket.Core.Protocol.Requests.SetSceneItemIndexRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSceneItemIndex", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2297,7 +2252,6 @@ public static async Task SetSceneItemIndexAsync(this ObsWebSocketClient client, /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2309,7 +2263,7 @@ public static async Task SetSceneItemIndexAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneItemBlendModeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneItemBlendModeRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneItemBlendModeAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneItemBlendModeRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneItemBlendMode", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2319,7 +2273,6 @@ public static async Task SetSceneItemIndexAsync(this ObsWebSocketClient client, /// /// Scenes and Groups /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2331,15 +2284,22 @@ public static async Task SetSceneItemIndexAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSceneItemBlendModeRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSceneItemBlendModeAsync(ObsWebSocket.Core.Protocol.Requests.SetSceneItemBlendModeRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSceneItemBlendMode", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the scenes category. +/// +/// The client these requests are sent on. +public readonly partial struct ScenesRequestGroup(ObsWebSocketClient client) +{ /// /// Gets an array of scenes in OBS. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2351,7 +2311,7 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneListAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneListRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneListAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneListRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneList", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2361,7 +2321,6 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie /// /// Groups in OBS are actually scenes, but renamed and modified. In obs-websocket, we treat them as scenes where we can. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2372,7 +2331,7 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetGroupListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetGroupListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetGroupList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2384,7 +2343,6 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie /// /// Note 2: Canvases do not have any concept of a program or preview scene, so this request does not support canvases. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2395,7 +2353,7 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetCurrentProgramSceneAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetCurrentProgramSceneAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetCurrentProgramScene", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2403,7 +2361,6 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie /// /// Sets the current program scene. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2415,7 +2372,7 @@ public static async Task SetSceneItemBlendModeAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetCurrentProgramSceneAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetCurrentProgramSceneRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetCurrentProgramSceneAsync(ObsWebSocket.Core.Protocol.Requests.SetCurrentProgramSceneRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetCurrentProgramScene", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2427,7 +2384,6 @@ public static async Task SetCurrentProgramSceneAsync(this ObsWebSocketClient cli /// /// Note: This request is slated to have the `currentPreview`-prefixed fields removed from in an upcoming RPC version. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2438,7 +2394,7 @@ public static async Task SetCurrentProgramSceneAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetCurrentPreviewSceneAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetCurrentPreviewSceneAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetCurrentPreviewScene", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2448,7 +2404,6 @@ public static async Task SetCurrentProgramSceneAsync(this ObsWebSocketClient cli /// /// Only available when studio mode is enabled. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2460,7 +2415,7 @@ public static async Task SetCurrentProgramSceneAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetCurrentPreviewSceneAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetCurrentPreviewSceneRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetCurrentPreviewSceneAsync(ObsWebSocket.Core.Protocol.Requests.SetCurrentPreviewSceneRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetCurrentPreviewScene", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2468,7 +2423,6 @@ public static async Task SetCurrentPreviewSceneAsync(this ObsWebSocketClient cli /// /// Creates a new scene in OBS. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2480,7 +2434,7 @@ public static async Task SetCurrentPreviewSceneAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task CreateSceneAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.CreateSceneRequestData requestData, CancellationToken cancellationToken = default) + public async Task CreateSceneAsync(ObsWebSocket.Core.Protocol.Requests.CreateSceneRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("CreateScene", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2488,7 +2442,6 @@ public static async Task SetCurrentPreviewSceneAsync(this ObsWebSocketClient cli /// /// Removes a scene from OBS. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2500,7 +2453,7 @@ public static async Task SetCurrentPreviewSceneAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task RemoveSceneAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.RemoveSceneRequestData requestData, CancellationToken cancellationToken = default) + public async Task RemoveSceneAsync(ObsWebSocket.Core.Protocol.Requests.RemoveSceneRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("RemoveScene", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2508,7 +2461,6 @@ public static async Task RemoveSceneAsync(this ObsWebSocketClient client, ObsWeb /// /// Sets the name of a scene (rename). /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2520,7 +2472,7 @@ public static async Task RemoveSceneAsync(this ObsWebSocketClient client, ObsWeb /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSceneNameAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSceneNameRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSceneNameAsync(ObsWebSocket.Core.Protocol.Requests.SetSceneNameRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSceneName", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2530,7 +2482,6 @@ public static async Task SetSceneNameAsync(this ObsWebSocketClient client, ObsWe /// /// Note: A transition UUID response field is not currently able to be implemented as of 2024-1-18. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2542,7 +2493,7 @@ public static async Task SetSceneNameAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneSceneTransitionOverrideAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSceneSceneTransitionOverrideRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSceneSceneTransitionOverrideAsync(ObsWebSocket.Core.Protocol.Requests.GetSceneSceneTransitionOverrideRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneSceneTransitionOverride", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2550,7 +2501,6 @@ public static async Task SetSceneNameAsync(this ObsWebSocketClient client, ObsWe /// /// Sets the scene transition overridden for a scene. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2562,17 +2512,24 @@ public static async Task SetSceneNameAsync(this ObsWebSocketClient client, ObsWe /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetSceneSceneTransitionOverrideAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetSceneSceneTransitionOverrideRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetSceneSceneTransitionOverrideAsync(ObsWebSocket.Core.Protocol.Requests.SetSceneSceneTransitionOverrideRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetSceneSceneTransitionOverride", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the sources category. +/// +/// The client these requests are sent on. +public readonly partial struct SourcesRequestGroup(ObsWebSocketClient client) +{ /// /// Gets the active and show state of a source. /// /// **Compatible with inputs and scenes.** /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2584,7 +2541,7 @@ public static async Task SetSceneSceneTransitionOverrideAsync(this ObsWebSocketC /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSourceActiveAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSourceActiveRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSourceActiveAsync(ObsWebSocket.Core.Protocol.Requests.GetSourceActiveRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSourceActive", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2597,7 +2554,6 @@ public static async Task SetSceneSceneTransitionOverrideAsync(this ObsWebSocketC /// /// **Compatible with inputs and scenes.** /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. @@ -2609,7 +2565,7 @@ public static async Task SetSceneSceneTransitionOverrideAsync(this ObsWebSocketC /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSourceScreenshotAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.GetSourceScreenshotRequestData requestData, CancellationToken cancellationToken = default) + public async Task GetSourceScreenshotAsync(ObsWebSocket.Core.Protocol.Requests.GetSourceScreenshotRequestData requestData, CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSourceScreenshot", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2622,7 +2578,6 @@ public static async Task SetSceneSceneTransitionOverrideAsync(this ObsWebSocketC /// /// **Compatible with inputs and scenes.** /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2634,15 +2589,22 @@ public static async Task SetSceneSceneTransitionOverrideAsync(this ObsWebSocketC /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SaveSourceScreenshotAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SaveSourceScreenshotRequestData requestData, CancellationToken cancellationToken = default) + public async Task SaveSourceScreenshotAsync(ObsWebSocket.Core.Protocol.Requests.SaveSourceScreenshotRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SaveSourceScreenshot", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the stream category. +/// +/// The client these requests are sent on. +public readonly partial struct StreamRequestGroup(ObsWebSocketClient client) +{ /// /// Gets the status of the stream output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2653,7 +2615,7 @@ public static async Task SaveSourceScreenshotAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetStreamStatusAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetStreamStatusAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetStreamStatus", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2661,7 +2623,6 @@ public static async Task SaveSourceScreenshotAsync(this ObsWebSocketClient clien /// /// Toggles the status of the stream output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2672,7 +2633,7 @@ public static async Task SaveSourceScreenshotAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task ToggleStreamAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task ToggleStreamAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("ToggleStream", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2680,7 +2641,6 @@ public static async Task SaveSourceScreenshotAsync(this ObsWebSocketClient clien /// /// Starts the stream output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -2691,7 +2651,7 @@ public static async Task SaveSourceScreenshotAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StartStreamAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StartStreamAsync(CancellationToken cancellationToken = default) { await client.CallAsync("StartStream", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2699,7 +2659,6 @@ public static async Task StartStreamAsync(this ObsWebSocketClient client, Cancel /// /// Stops the stream output. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -2710,7 +2669,7 @@ public static async Task StartStreamAsync(this ObsWebSocketClient client, Cancel /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task StopStreamAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task StopStreamAsync(CancellationToken cancellationToken = default) { await client.CallAsync("StopStream", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2718,7 +2677,6 @@ public static async Task StopStreamAsync(this ObsWebSocketClient client, Cancell /// /// Sends CEA-608 caption text over the stream output. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2730,17 +2688,24 @@ public static async Task StopStreamAsync(this ObsWebSocketClient client, Cancell /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SendStreamCaptionRequestData requestData, CancellationToken cancellationToken = default) + public async Task SendStreamCaptionAsync(ObsWebSocket.Core.Protocol.Requests.SendStreamCaptionRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SendStreamCaption", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the transitions category. +/// +/// The client these requests are sent on. +public readonly partial struct TransitionsRequestGroup(ObsWebSocketClient client) +{ /// /// Gets an array of all available transition kinds. /// /// Similar to `GetInputKindList` /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2751,7 +2716,7 @@ public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetTransitionKindListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetTransitionKindListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetTransitionKindList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2759,7 +2724,6 @@ public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, /// /// Gets an array of all scene transitions in OBS. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2770,7 +2734,7 @@ public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetSceneTransitionListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetSceneTransitionListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetSceneTransitionList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2778,7 +2742,6 @@ public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, /// /// Gets information about the current scene transition. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2789,7 +2752,7 @@ public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetCurrentSceneTransitionAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetCurrentSceneTransitionAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetCurrentSceneTransition", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2799,7 +2762,6 @@ public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, /// /// Small note: While the namespace of scene transitions is generally unique, that uniqueness is not a guarantee as it is with other resources like inputs. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2811,7 +2773,7 @@ public static async Task SendStreamCaptionAsync(this ObsWebSocketClient client, /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetCurrentSceneTransitionAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetCurrentSceneTransitionAsync(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetCurrentSceneTransition", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2819,7 +2781,6 @@ public static async Task SetCurrentSceneTransitionAsync(this ObsWebSocketClient /// /// Sets the duration of the current scene transition, if it is not fixed. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2831,7 +2792,7 @@ public static async Task SetCurrentSceneTransitionAsync(this ObsWebSocketClient /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetCurrentSceneTransitionDurationAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionDurationRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetCurrentSceneTransitionDurationAsync(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionDurationRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetCurrentSceneTransitionDuration", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2839,7 +2800,6 @@ public static async Task SetCurrentSceneTransitionDurationAsync(this ObsWebSocke /// /// Sets the settings of the current scene transition. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2851,7 +2811,7 @@ public static async Task SetCurrentSceneTransitionDurationAsync(this ObsWebSocke /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetCurrentSceneTransitionSettingsAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionSettingsRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetCurrentSceneTransitionSettingsAsync(ObsWebSocket.Core.Protocol.Requests.SetCurrentSceneTransitionSettingsRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetCurrentSceneTransitionSettings", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2861,7 +2821,6 @@ public static async Task SetCurrentSceneTransitionSettingsAsync(this ObsWebSocke /// /// Note: `transitionCursor` will return 1.0 when the transition is inactive. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2872,7 +2831,7 @@ public static async Task SetCurrentSceneTransitionSettingsAsync(this ObsWebSocke /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetCurrentSceneTransitionCursorAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetCurrentSceneTransitionCursorAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetCurrentSceneTransitionCursor", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2880,7 +2839,6 @@ public static async Task SetCurrentSceneTransitionSettingsAsync(this ObsWebSocke /// /// Triggers the current scene transition. Same functionality as the `Transition` button in studio mode. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. /// @@ -2891,7 +2849,7 @@ public static async Task SetCurrentSceneTransitionSettingsAsync(this ObsWebSocke /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task TriggerStudioModeTransitionAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task TriggerStudioModeTransitionAsync(CancellationToken cancellationToken = default) { await client.CallAsync("TriggerStudioModeTransition", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2901,7 +2859,6 @@ public static async Task TriggerStudioModeTransitionAsync(this ObsWebSocketClien /// /// **Very important note**: This will be deprecated and replaced in a future version of obs-websocket. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2913,15 +2870,22 @@ public static async Task TriggerStudioModeTransitionAsync(this ObsWebSocketClien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetTBarPositionAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetTBarPositionRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetTBarPositionAsync(ObsWebSocket.Core.Protocol.Requests.SetTBarPositionRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetTBarPosition", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } +} + +/// +/// Requests in the ui category. +/// +/// The client these requests are sent on. +public readonly partial struct UiRequestGroup(ObsWebSocketClient client) +{ /// /// Gets whether studio is enabled. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -2932,7 +2896,7 @@ public static async Task SetTBarPositionAsync(this ObsWebSocketClient client, Ob /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetStudioModeEnabledAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetStudioModeEnabledAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetStudioModeEnabled", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2940,7 +2904,6 @@ public static async Task SetTBarPositionAsync(this ObsWebSocketClient client, Ob /// /// Enables or disables studio mode /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2952,7 +2915,7 @@ public static async Task SetTBarPositionAsync(this ObsWebSocketClient client, Ob /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task SetStudioModeEnabledAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.SetStudioModeEnabledRequestData requestData, CancellationToken cancellationToken = default) + public async Task SetStudioModeEnabledAsync(ObsWebSocket.Core.Protocol.Requests.SetStudioModeEnabledRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("SetStudioModeEnabled", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2960,7 +2923,6 @@ public static async Task SetStudioModeEnabledAsync(this ObsWebSocketClient clien /// /// Opens the properties dialog of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2972,7 +2934,7 @@ public static async Task SetStudioModeEnabledAsync(this ObsWebSocketClient clien /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task OpenInputPropertiesDialogAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.OpenInputPropertiesDialogRequestData requestData, CancellationToken cancellationToken = default) + public async Task OpenInputPropertiesDialogAsync(ObsWebSocket.Core.Protocol.Requests.OpenInputPropertiesDialogRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("OpenInputPropertiesDialog", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -2980,7 +2942,6 @@ public static async Task OpenInputPropertiesDialogAsync(this ObsWebSocketClient /// /// Opens the filters dialog of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -2992,7 +2953,7 @@ public static async Task OpenInputPropertiesDialogAsync(this ObsWebSocketClient /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task OpenInputFiltersDialogAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.OpenInputFiltersDialogRequestData requestData, CancellationToken cancellationToken = default) + public async Task OpenInputFiltersDialogAsync(ObsWebSocket.Core.Protocol.Requests.OpenInputFiltersDialogRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("OpenInputFiltersDialog", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -3000,7 +2961,6 @@ public static async Task OpenInputFiltersDialogAsync(this ObsWebSocketClient cli /// /// Opens the interact dialog of an input. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -3012,7 +2972,7 @@ public static async Task OpenInputFiltersDialogAsync(this ObsWebSocketClient cli /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task OpenInputInteractDialogAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.OpenInputInteractDialogRequestData requestData, CancellationToken cancellationToken = default) + public async Task OpenInputInteractDialogAsync(ObsWebSocket.Core.Protocol.Requests.OpenInputInteractDialogRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("OpenInputInteractDialog", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -3020,7 +2980,6 @@ public static async Task OpenInputInteractDialogAsync(this ObsWebSocketClient cl /// /// Gets a list of connected monitors and information about them. /// - /// The instance. /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Yields the response data. /// @@ -3031,7 +2990,7 @@ public static async Task OpenInputInteractDialogAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task GetMonitorListAsync(this ObsWebSocketClient client, CancellationToken cancellationToken = default) + public async Task GetMonitorListAsync(CancellationToken cancellationToken = default) { return await client.CallRequiredAsync("GetMonitorList", null, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -3047,7 +3006,6 @@ public static async Task OpenInputInteractDialogAsync(this ObsWebSocketClient cl /// /// Note: This request serves to provide feature parity with 4.x. It is very likely to be changed/deprecated in a future release. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -3059,7 +3017,7 @@ public static async Task OpenInputInteractDialogAsync(this ObsWebSocketClient cl /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task OpenVideoMixProjectorAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.OpenVideoMixProjectorRequestData requestData, CancellationToken cancellationToken = default) + public async Task OpenVideoMixProjectorAsync(ObsWebSocket.Core.Protocol.Requests.OpenVideoMixProjectorRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("OpenVideoMixProjector", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } @@ -3069,7 +3027,6 @@ public static async Task OpenVideoMixProjectorAsync(this ObsWebSocketClient clie /// /// Note: This request serves to provide feature parity with 4.x. It is very likely to be changed/deprecated in a future release. /// - /// The instance. /// The data required for the request (). /// A token to cancel the asynchronous operation. /// A task representing the asynchronous operation. Completes when the request is processed successfully by the server. @@ -3081,9 +3038,128 @@ public static async Task OpenVideoMixProjectorAsync(this ObsWebSocketClient clie /// Thrown if the request fails on the OBS side. /// Thrown if the client is not connected. /// Thrown if cancelled. - public static async Task OpenSourceProjectorAsync(this ObsWebSocketClient client, ObsWebSocket.Core.Protocol.Requests.OpenSourceProjectorRequestData requestData, CancellationToken cancellationToken = default) + public async Task OpenSourceProjectorAsync(ObsWebSocket.Core.Protocol.Requests.OpenSourceProjectorRequestData requestData, CancellationToken cancellationToken = default) { await client.CallAsync("OpenSourceProjector", requestData, cancellationToken: cancellationToken).ConfigureAwait(false); } } + +/// +/// Exposes the request categories defined by the OBS WebSocket protocol. +/// +public static class ObsWebSocketClientExtensions +{ + extension(ObsWebSocketClient client) + { + /// + /// Requests in the canvases category. + /// + public CanvasesRequestGroup Canvases => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the config category. + /// + public ConfigRequestGroup Config => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the filters category. + /// + public FiltersRequestGroup Filters => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the general category. + /// + public GeneralRequestGroup General => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the inputs category. + /// + public InputsRequestGroup Inputs => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the media inputs category. + /// + public MediaInputsRequestGroup MediaInputs => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the outputs category. + /// + public OutputsRequestGroup Outputs => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the record category. + /// + public RecordRequestGroup Record => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the scene items category. + /// + public SceneItemsRequestGroup SceneItems => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the scenes category. + /// + public ScenesRequestGroup Scenes => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the sources category. + /// + public SourcesRequestGroup Sources => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the stream category. + /// + public StreamRequestGroup Stream => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the transitions category. + /// + public TransitionsRequestGroup Transitions => new(client); + } + + extension(ObsWebSocketClient client) + { + /// + /// Requests in the ui category. + /// + public UiRequestGroup Ui => new(client); + } + +} diff --git a/ObsWebSocket.Core/Generated/Protocol/Responses/GetCurrentSceneTransition.Response.g.cs b/ObsWebSocket.Core/Generated/Protocol/Responses/GetCurrentSceneTransition.Response.g.cs index 7cf5a18..cc42520 100644 --- a/ObsWebSocket.Core/Generated/Protocol/Responses/GetCurrentSceneTransition.Response.g.cs +++ b/ObsWebSocket.Core/Generated/Protocol/Responses/GetCurrentSceneTransition.Response.g.cs @@ -36,7 +36,7 @@ public sealed partial record GetCurrentSceneTransitionResponseData /// [JsonPropertyName("transitionDuration")] [Key("transitionDuration")] - public required double TransitionDuration { get; init; } + public double? TransitionDuration { get; init; } /// /// Whether the transition uses a fixed (unconfigurable) duration @@ -82,7 +82,7 @@ public GetCurrentSceneTransitionResponseData() { } /// Parameters are ordered with required properties first, then optional properties (with defaults). Follows protocol definition order where possible. /// [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public GetCurrentSceneTransitionResponseData(bool transitionFixed, double transitionDuration, bool transitionConfigurable, string? transitionName = null, string? transitionUuid = null, string? transitionKind = null, System.Text.Json.JsonElement? transitionSettings = null) + public GetCurrentSceneTransitionResponseData(bool transitionFixed, bool transitionConfigurable, string? transitionName = null, string? transitionUuid = null, string? transitionKind = null, double? transitionDuration = null, System.Text.Json.JsonElement? transitionSettings = null) { this.TransitionName = transitionName; this.TransitionUuid = transitionUuid; diff --git a/ObsWebSocket.Core/Generated/Protocol/Responses/GetMediaInputStatus.Response.g.cs b/ObsWebSocket.Core/Generated/Protocol/Responses/GetMediaInputStatus.Response.g.cs index 34446d7..ff95718 100644 --- a/ObsWebSocket.Core/Generated/Protocol/Responses/GetMediaInputStatus.Response.g.cs +++ b/ObsWebSocket.Core/Generated/Protocol/Responses/GetMediaInputStatus.Response.g.cs @@ -40,14 +40,14 @@ public sealed partial record GetMediaInputStatusResponseData /// [JsonPropertyName("mediaCursor")] [Key("mediaCursor")] - public required double MediaCursor { get; init; } + public double? MediaCursor { get; init; } /// /// Total duration of the playing media in milliseconds. `null` if not playing /// [JsonPropertyName("mediaDuration")] [Key("mediaDuration")] - public required double MediaDuration { get; init; } + public double? MediaDuration { get; init; } /// /// State of the media input @@ -64,8 +64,7 @@ public GetMediaInputStatusResponseData() { } /// Initializes a new instance with all properties specified. /// Parameters are ordered with required properties first, then optional properties (with defaults). Follows protocol definition order where possible. /// - [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public GetMediaInputStatusResponseData(double mediaDuration, double mediaCursor, string? mediaState = null) + public GetMediaInputStatusResponseData(string? mediaState = null, double? mediaDuration = null, double? mediaCursor = null) { this.MediaState = mediaState; this.MediaDuration = mediaDuration; diff --git a/ObsWebSocket.Core/Generated/Protocol/Responses/GetSceneSceneTransitionOverride.Response.g.cs b/ObsWebSocket.Core/Generated/Protocol/Responses/GetSceneSceneTransitionOverride.Response.g.cs index 53c3681..ca5f955 100644 --- a/ObsWebSocket.Core/Generated/Protocol/Responses/GetSceneSceneTransitionOverride.Response.g.cs +++ b/ObsWebSocket.Core/Generated/Protocol/Responses/GetSceneSceneTransitionOverride.Response.g.cs @@ -31,7 +31,7 @@ public sealed partial record GetSceneSceneTransitionOverrideResponseData /// [JsonPropertyName("transitionDuration")] [Key("transitionDuration")] - public required double TransitionDuration { get; init; } + public double? TransitionDuration { get; init; } /// /// Name of the overridden scene transition, else `null` @@ -48,8 +48,7 @@ public GetSceneSceneTransitionOverrideResponseData() { } /// Initializes a new instance with all properties specified. /// Parameters are ordered with required properties first, then optional properties (with defaults). Follows protocol definition order where possible. /// - [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public GetSceneSceneTransitionOverrideResponseData(double transitionDuration, string? transitionName = null) + public GetSceneSceneTransitionOverrideResponseData(string? transitionName = null, double? transitionDuration = null) { this.TransitionName = transitionName; this.TransitionDuration = transitionDuration; diff --git a/ObsWebSocket.Core/Groups/ConfigRequestGroup.cs b/ObsWebSocket.Core/Groups/ConfigRequestGroup.cs new file mode 100644 index 0000000..d210228 --- /dev/null +++ b/ObsWebSocket.Core/Groups/ConfigRequestGroup.cs @@ -0,0 +1,235 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Config category, alongside its generated requests. +/// +public readonly partial struct ConfigRequestGroup +{ + /// + /// Gets the current stream service settings as a strongly-typed object. The service type string is discarded. + /// + /// The C# type to deserialize stream service settings into. + /// The for . + /// A token to cancel the operation. + /// The deserialized stream service settings, or if no settings are present. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task GetStreamServiceSettingsAsync(JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + GetStreamServiceSettingsResponseData? response = await client + .Config.GetStreamServiceSettingsAsync(cancellationToken: cancellationToken) + .ConfigureAwait(false); + + return response?.StreamServiceSettings is not { } element ? null : JsonSerializer.Deserialize(element, typeInfo); + } + + /// + /// Gets the current stream service settings as a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the stream service settings. Must be a library-registered settings type. + /// A token to cancel the operation. + /// The deserialized stream service settings, or if no settings are present. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task GetStreamServiceSettingsAsync(CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Config.GetStreamServiceSettingsAsync(typeInfo, cancellationToken); + } + + /// + /// Sets the current stream service settings from a strongly-typed object. + /// + /// The C# type representing the stream service settings. + /// The stream service type identifier (e.g., "rtmp_custom", "rtmp_common"). + /// The settings to apply. + /// The for . + /// A token to cancel the operation. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task SetStreamServiceSettingsAsync(string streamServiceType, + T settings, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(streamServiceType); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + JsonElement settingsElement = JsonSerializer.SerializeToElement(settings, typeInfo); + + await client + .Config.SetStreamServiceSettingsAsync(new SetStreamServiceSettingsRequestData( + streamServiceType: streamServiceType, + streamServiceSettings: settingsElement + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Sets the current stream service settings from a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the stream service settings. Must be a library-registered settings type. + /// The stream service type identifier (e.g., "rtmp_custom", "rtmp_common"). + /// The settings to apply. + /// A token to cancel the operation. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task SetStreamServiceSettingsAsync(string streamServiceType, + T settings, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Config.SetStreamServiceSettingsAsync(streamServiceType, settings, typeInfo, cancellationToken); + } + + /// + /// Ensures the specified Scene Collection is currently active. If not, attempts to switch to it. + /// + /// The name of the desired scene collection. + /// A token to cancel the operation. + /// True if the target scene collection is active after the call; false if the switch failed (e.g., not found). + /// Thrown for unexpected OBS errors during the process. + /// Thrown if the client is not connected. + public async Task EnsureSceneCollectionActiveAsync(string targetSceneCollectionName, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(targetSceneCollectionName); + client.EnsureConnected(); + + GetSceneCollectionListResponseData? currentResponse = await client + .Config.GetSceneCollectionListAsync(cancellationToken: cancellationToken) + .ConfigureAwait(false); + + if ( + string.Equals( + currentResponse?.CurrentSceneCollectionName, + targetSceneCollectionName, + StringComparison.Ordinal + ) + ) + { + return true; // Already active + } + + // Need to switch + try + { + await client + .Config.SetCurrentSceneCollectionAsync( + new SetCurrentSceneCollectionRequestData(sceneCollectionName: targetSceneCollectionName), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + return true; // Switch command sent successfully + } + catch (ObsWebSocketException ex) + when (ex.Message.Contains("NotFound", StringComparison.OrdinalIgnoreCase) + || // General not found + ex.Message.Contains( + $"code {(int)Core.Protocol.Generated.RequestStatus.ResourceNotFound}:", + StringComparison.Ordinal + ) + || // Specific code + ex.Message.Contains("InvalidParameter", StringComparison.OrdinalIgnoreCase) // Might be InvalidParameter if name doesn't exist + ) + { + client._logger.LogWarning( + "Failed to set scene collection to '{TargetName}': Not found or invalid.", + targetSceneCollectionName + ); + return false; // Switch failed because target doesn't exist + } + // Let other exceptions propagate + } + + /// + /// Ensures the specified Profile is currently active. If not, attempts to switch to it. + /// + /// The name of the desired profile. + /// A token to cancel the operation. + /// True if the target profile is active after the call; false if the switch failed (e.g., not found). + /// Thrown for unexpected OBS errors during the process. + /// Thrown if the client is not connected. + public async Task EnsureProfileActiveAsync(string targetProfileName, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(targetProfileName); + client.EnsureConnected(); + + GetProfileListResponseData? currentResponse = await client + .Config.GetProfileListAsync(cancellationToken: cancellationToken) + .ConfigureAwait(false); + + if ( + string.Equals( + currentResponse?.CurrentProfileName, + targetProfileName, + StringComparison.Ordinal + ) + ) + { + return true; // Already active + } + + // Need to switch + try + { + await client + .Config.SetCurrentProfileAsync( + new SetCurrentProfileRequestData(profileName: targetProfileName), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + return true; // Switch command sent successfully + } + catch (ObsWebSocketException ex) + when (ex.Message.Contains("NotFound", StringComparison.OrdinalIgnoreCase) + || // General not found + ex.Message.Contains( + $"code {(int)Core.Protocol.Generated.RequestStatus.ResourceNotFound}:", + StringComparison.Ordinal + ) + || // Specific code + ex.Message.Contains("InvalidParameter", StringComparison.OrdinalIgnoreCase) // Might be InvalidParameter if name doesn't exist + ) + { + client._logger.LogWarning( + "Failed to set profile to '{TargetName}': Not found or invalid.", + targetProfileName + ); + return false; // Switch failed because target doesn't exist + } + // Let other exceptions propagate + } +} diff --git a/ObsWebSocket.Core/Groups/FiltersRequestGroup.cs b/ObsWebSocket.Core/Groups/FiltersRequestGroup.cs new file mode 100644 index 0000000..7ee21ad --- /dev/null +++ b/ObsWebSocket.Core/Groups/FiltersRequestGroup.cs @@ -0,0 +1,308 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Filters category, alongside its generated requests. +/// +public readonly partial struct FiltersRequestGroup +{ + /// + /// Retrieves the settings for a specific filter on a source and deserializes them using an explicit . + /// Suitable for both library-defined and consumer-defined settings types. + /// + /// The C# type to deserialize the filter settings into. + /// The name of the source. + /// The name of the filter. + /// The JSON type metadata for . + /// A token to cancel the operation. + /// The deserialized settings, or null if the source/filter is not found or deserialization fails. + /// Thrown for OBS errors other than 'ResourceNotFound'. + /// Thrown if the client is not connected. + public async Task GetSourceFilterSettingsAsync(string sourceName, + string filterName, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(sourceName); + ArgumentException.ThrowIfNullOrEmpty(filterName); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + GetSourceFilterResponseData? filterInfo; + try + { + filterInfo = await client + .Filters.GetSourceFilterAsync( + new GetSourceFilterRequestData(sourceName: sourceName, filterName: filterName), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + catch (ObsWebSocketException ex) + when (ex.Message.Contains("NotFound", StringComparison.OrdinalIgnoreCase) + || ex.Message.Contains( + $"code {(int)Core.Protocol.Generated.RequestStatus.ResourceNotFound}:", + StringComparison.Ordinal + ) + ) + { + return null; + } + + if (filterInfo?.FilterSettings == null) + { + return null; + } + + try + { + return filterInfo.FilterSettings.Value.Deserialize(typeInfo); + } + catch (JsonException jsonEx) + { + client._logger.LogError( + jsonEx, + "Failed to deserialize filter settings for '{FilterName}' on '{SourceName}' to type {TypeName}.", + filterName, + sourceName, + typeof(T).Name + ); + return null; + } + } + + /// + /// Retrieves the settings for a specific filter on a source. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type to deserialize the filter settings into. Must be a library-registered settings type. + /// The name of the source. + /// The name of the filter. + /// A token to cancel the operation. + /// The deserialized settings, or null if the source/filter is not found or deserialization fails. + /// Thrown for OBS errors other than 'ResourceNotFound'. + /// Thrown if the client is not connected. + public Task GetSourceFilterSettingsAsync(string sourceName, + string filterName, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Filters.GetSourceFilterSettingsAsync(sourceName, filterName, typeInfo, cancellationToken); + } + + /// + /// Sets the settings for a specific filter on a source using a strongly-typed settings object and an explicit . + /// Suitable for both library-defined and consumer-defined settings types. + /// + /// The C# type representing the filter settings. + /// The name of the source. + /// The name of the filter. + /// The settings object to apply. + /// The JSON type metadata for . + /// True (default) to merge settings; false to reset to defaults and then apply. + /// A token to cancel the operation. + /// Thrown if OBS fails or serialization fails. + /// Thrown if the client is not connected. + public async Task SetSourceFilterSettingsAsync(string sourceName, + string filterName, + T settings, + JsonTypeInfo typeInfo, + bool overlay = true, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(sourceName); + ArgumentException.ThrowIfNullOrEmpty(filterName); + ArgumentNullException.ThrowIfNull(settings); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + JsonElement settingsElement; + try + { + settingsElement = JsonSerializer.SerializeToElement(settings, typeInfo); + } + catch (JsonException jsonEx) + { + throw new ObsWebSocketException( + $"Failed to serialize settings object of type '{typeof(T).Name}' for filter '{filterName}'.", + jsonEx + ); + } + + await client + .Filters.SetSourceFilterSettingsAsync(new SetSourceFilterSettingsRequestData( + filterSettings: settingsElement, + sourceName: sourceName, + filterName: filterName, + overlay: overlay + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Sets the settings for a specific filter on a source using a strongly-typed settings object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the filter settings. Must be a library-registered settings type. + /// The name of the source. + /// The name of the filter. + /// The settings object to apply. + /// True (default) to merge settings; false to reset to defaults and then apply. + /// A token to cancel the operation. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task SetSourceFilterSettingsAsync(string sourceName, + string filterName, + T settings, + bool overlay = true, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Filters.SetSourceFilterSettingsAsync(sourceName, filterName, settings, typeInfo, overlay, cancellationToken); + } + + /// + /// Creates a new filter on a source with strongly-typed settings and an explicit . + /// Suitable for both library-defined and consumer-defined settings types. + /// + /// The C# type representing the filter settings. + /// The name of the source to add the filter to. + /// The name for the new filter. + /// The kind of filter to create (e.g., "gain_filter"). + /// The initial settings for the filter. + /// The JSON type metadata for . + /// A token to cancel the operation. + /// Thrown if OBS fails or serialization fails. + /// Thrown if the client is not connected. + public async Task CreateSourceFilterAsync(string sourceName, + string filterName, + string filterKind, + T settings, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(sourceName); + ArgumentException.ThrowIfNullOrEmpty(filterName); + ArgumentException.ThrowIfNullOrEmpty(filterKind); + ArgumentNullException.ThrowIfNull(settings); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + JsonElement settingsElement; + try + { + settingsElement = JsonSerializer.SerializeToElement(settings, typeInfo); + } + catch (JsonException jsonEx) + { + throw new ObsWebSocketException( + $"Failed to serialize settings object of type '{typeof(T).Name}' for filter '{filterName}'.", + jsonEx + ); + } + + await client + .Filters.CreateSourceFilterAsync(new CreateSourceFilterRequestData( + filterName: filterName, + filterKind: filterKind, + sourceName: sourceName, + filterSettings: settingsElement + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Creates a new filter on a source with strongly-typed settings. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the filter settings. Must be a library-registered settings type. + /// The name of the source to add the filter to. + /// The name for the new filter. + /// The kind of filter to create (e.g., "gain_filter"). + /// The initial settings for the filter. + /// A token to cancel the operation. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task CreateSourceFilterAsync(string sourceName, + string filterName, + string filterKind, + T settings, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Filters.CreateSourceFilterAsync(sourceName, filterName, filterKind, settings, typeInfo, cancellationToken); + } + + /// + /// Gets the default settings for a source filter kind as a strongly-typed object. + /// + /// The C# type to deserialize default filter settings into. + /// The identifier of the filter kind (e.g., "gain_filter"). + /// The for . + /// A token to cancel the operation. + /// The deserialized default settings, or if no settings are present. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task GetSourceFilterDefaultSettingsAsync(string filterKind, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(filterKind); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + GetSourceFilterDefaultSettingsResponseData? response = await client + .Filters.GetSourceFilterDefaultSettingsAsync(new GetSourceFilterDefaultSettingsRequestData(filterKind: filterKind), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + + return response?.DefaultFilterSettings is not { } element ? null : JsonSerializer.Deserialize(element, typeInfo); + } + + /// + /// Gets the default settings for a source filter kind as a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the default filter settings. Must be a library-registered settings type. + /// The identifier of the filter kind (e.g., "gain_filter"). + /// A token to cancel the operation. + /// The deserialized default settings, or if no settings are present. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task GetSourceFilterDefaultSettingsAsync(string filterKind, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Filters.GetSourceFilterDefaultSettingsAsync(filterKind, typeInfo, cancellationToken); + } +} diff --git a/ObsWebSocket.Core/Groups/GeneralRequestGroup.cs b/ObsWebSocket.Core/Groups/GeneralRequestGroup.cs new file mode 100644 index 0000000..acec06f --- /dev/null +++ b/ObsWebSocket.Core/Groups/GeneralRequestGroup.cs @@ -0,0 +1,43 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the General category, alongside its generated requests. +/// +public readonly partial struct GeneralRequestGroup +{ + /// + /// Triggers an OBS hotkey by its canonical name (e.g., "OBSWebSocket.StartStream"). + /// + /// The canonical name of the hotkey. + /// A token to cancel the operation. + /// Thrown if OBS fails to trigger the hotkey (e.g., hotkey not found). + /// Thrown if the client is not connected. + public async Task TriggerHotkeyAsync(string hotkeyName, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(hotkeyName); + client.EnsureConnected(); + + await client + .General.TriggerHotkeyByNameAsync( + new TriggerHotkeyByNameRequestData(hotkeyName: hotkeyName), // contextName defaults to null/Any + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } +} diff --git a/ObsWebSocket.Core/Groups/InputsRequestGroup.cs b/ObsWebSocket.Core/Groups/InputsRequestGroup.cs new file mode 100644 index 0000000..75e543e --- /dev/null +++ b/ObsWebSocket.Core/Groups/InputsRequestGroup.cs @@ -0,0 +1,445 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Inputs category, alongside its generated requests. +/// +public readonly partial struct InputsRequestGroup +{ + /// + /// Sets the text content of a Text (GDI+, Freetype 2, Pango) source. + /// + /// The name of the Text source input. + /// The text content to set. + /// A token to cancel the operation. + /// Thrown if OBS fails to set the text (e.g., input not found, not a text source). + /// Thrown if the client is not connected. + public async Task SetInputTextAsync(string inputName, + string text, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(inputName); + ArgumentNullException.ThrowIfNull(text); // Allow empty string, but not null + client.EnsureConnected(); + + await client + .Inputs.SetInputSettingsAsync(inputName: inputName, + settings: new TextGdiPlusInputSettings(Text: text), + overlay: true, + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + // Let ObsWebSocketException from the underlying call propagate + } + + /// + /// Sets the mute state for multiple audio inputs using a single batch request. + /// + /// An enumerable of tuples, where each tuple contains the input name (string) and desired mute state (bool: true=muted, false=unmuted). + /// A token to cancel the operation. + /// A Task representing the completion of the batch request submission. Inspect logs for individual item failures. + /// Thrown if the batch request itself fails (e.g., timeout). + /// Thrown if the client is not connected. + /// Thrown if inputMutes is null. + public async Task SetInputMutesAsync(IEnumerable<(string InputName, bool IsMuted)> inputMutes, + CancellationToken cancellationToken = default + ) + { + ArgumentNullException.ThrowIfNull(inputMutes); + client.EnsureConnected(); + + List batchItems = + [ + .. inputMutes.Select(im => new BatchRequestItem( + RequestType: "SetInputMute", + RequestData: new SetInputMuteRequestData( + inputName: im.InputName, + inputMuted: im.IsMuted + ) + )), + ]; + + if (batchItems.Count == 0) + { + client._logger.LogDebug("SetInputMutesAsync called with empty list, nothing to do."); + return; // Nothing to send + } + + // Send batch, don't halt on failure + List> results = await client + .CallBatchAsync( + requests: batchItems, + haltOnFailure: false, + executionType: RequestBatchExecutionType.SerialRealtime, // Appropriate for simple state changes + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + + // Optional: Log failures from results + foreach (RequestResponsePayload result in results) + { + if (!result.RequestStatus.Result) + { + // Attempt to find original input name (requires parsing RequestId or matching RequestData - complex) + // For now, log the failed request type and ID + client._logger.LogWarning( + "Failed batch item in SetInputMutesAsync: RequestType={ReqType}, RequestId={ReqId}, Code={Code}, Comment={Comment}", + result.RequestType, + result.RequestId, + result.RequestStatus.Code, + result.RequestStatus.Comment ?? "N/A" + ); + } + } + } + + /// + /// Retrieves and deserializes the settings for an input using an explicit . + /// Suitable for both library-defined and consumer-defined settings types. + /// + /// The C# type to deserialize the input settings into. + /// The name of the input. + /// The JSON type metadata for . + /// A token to cancel the operation. + /// The deserialized settings, or null if the input is not found or deserialization fails. + /// Thrown for unexpected OBS errors. + /// Thrown if the client is not connected. + public async Task GetInputSettingsAsync(string inputName, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(inputName); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + GetInputSettingsResponseData? response; + try + { + response = await client + .Inputs.GetInputSettingsAsync(new GetInputSettingsRequestData(inputName: inputName), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + catch (ObsWebSocketException ex) + when (ex.Message.Contains("NotFound", StringComparison.OrdinalIgnoreCase) + || ex.Message.Contains( + $"code {(int)Core.Protocol.Generated.RequestStatus.ResourceNotFound}:", + StringComparison.Ordinal + ) + ) + { + return null; + } + + if (response?.InputSettings == null) + { + return null; + } + + try + { + return response.InputSettings.Value.Deserialize(typeInfo); + } + catch (JsonException jsonEx) + { + client._logger.LogError( + jsonEx, + "Failed to deserialize input settings for '{InputName}' to type {TypeName}.", + inputName, + typeof(T).Name + ); + return null; + } + } + + /// + /// Retrieves and deserializes the settings for an input. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type to deserialize the input settings into. Must be a library-registered settings type. + /// The name of the input. + /// A token to cancel the operation. + /// The deserialized settings, or null if the input is not found or deserialization fails. + /// Thrown if the type is not registered or OBS returns an error. + /// Thrown if the client is not connected. + public Task GetInputSettingsAsync(string inputName, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Inputs.GetInputSettingsAsync(inputName, typeInfo, cancellationToken); + } + + /// + /// Sets the settings of an input using a strongly-typed settings object and an explicit . + /// Suitable for both library-defined and consumer-defined settings types. + /// + /// The C# type representing the input settings. + /// The name of the input. + /// The settings object to apply. + /// The JSON type metadata for . + /// True (default) to merge settings; false to reset to defaults and then apply. + /// A token to cancel the operation. + /// Thrown if OBS fails or serialization fails. + /// Thrown if the client is not connected. + public async Task SetInputSettingsAsync(string inputName, + T settings, + JsonTypeInfo typeInfo, + bool overlay = true, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(inputName); + ArgumentNullException.ThrowIfNull(settings); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + JsonElement settingsElement; + try + { + settingsElement = JsonSerializer.SerializeToElement(settings, typeInfo); + } + catch (JsonException jsonEx) + { + throw new ObsWebSocketException( + $"Failed to serialize settings object of type '{typeof(T).Name}' for input '{inputName}'.", + jsonEx + ); + } + + await client + .Inputs.SetInputSettingsAsync(new SetInputSettingsRequestData( + inputSettings: settingsElement, + inputName: inputName, + overlay: overlay + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Sets the settings of an input using a strongly-typed settings object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the input settings. Must be a library-registered settings type. + /// The name of the input. + /// The settings object to apply. + /// True (default) to merge settings; false to reset to defaults and then apply. + /// A token to cancel the operation. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task SetInputSettingsAsync(string inputName, + T settings, + bool overlay = true, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Inputs.SetInputSettingsAsync(inputName, settings, typeInfo, overlay, cancellationToken); + } + + /// + /// Creates a new input with strongly-typed settings and an explicit . + /// Suitable for both library-defined and consumer-defined settings types. + /// + /// The C# type representing the input settings. + /// The kind of input to create (e.g., "browser_source"). + /// The name for the new input. + /// The settings for the new input. + /// The JSON type metadata for . + /// Optional: the name of the scene to add the input to. + /// Optional: the UUID of the scene to add the input to. + /// Optional: initial enabled state of the resulting scene item. + /// A token to cancel the operation. + /// The response data containing the new scene item ID, or null on failure. + /// Thrown if OBS fails or serialization fails. + /// Thrown if the client is not connected. + public async Task CreateInputAsync(string inputKind, + string inputName, + T settings, + JsonTypeInfo typeInfo, + string? sceneName = null, + string? sceneUuid = null, + bool? sceneItemEnabled = null, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(inputKind); + ArgumentException.ThrowIfNullOrEmpty(inputName); + ArgumentNullException.ThrowIfNull(settings); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + JsonElement settingsElement; + try + { + settingsElement = JsonSerializer.SerializeToElement(settings, typeInfo); + } + catch (JsonException jsonEx) + { + throw new ObsWebSocketException( + $"Failed to serialize settings object of type '{typeof(T).Name}' for input '{inputName}'.", + jsonEx + ); + } + + return await client + .Inputs.CreateInputAsync(new CreateInputRequestData( + inputName: inputName, + inputKind: inputKind, + sceneName: sceneName, + sceneUuid: sceneUuid, + inputSettings: settingsElement, + sceneItemEnabled: sceneItemEnabled + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Creates a new input with strongly-typed settings. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the input settings. Must be a library-registered settings type. + /// The kind of input to create (e.g., "browser_source"). + /// The name for the new input. + /// The settings for the new input. + /// Optional: the name of the scene to add the input to. + /// Optional: the UUID of the scene to add the input to. + /// Optional: initial enabled state of the resulting scene item. + /// A token to cancel the operation. + /// The response data containing the new scene item ID, or null on failure. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task CreateInputAsync(string inputKind, + string inputName, + T settings, + string? sceneName = null, + string? sceneUuid = null, + bool? sceneItemEnabled = null, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Inputs.CreateInputAsync(inputKind, inputName, settings, typeInfo, sceneName, sceneUuid, sceneItemEnabled, cancellationToken); + } + + /// + /// Gets the default settings for an input kind as a strongly-typed object. + /// + /// The C# type to deserialize default input settings into. + /// The identifier of the input kind (e.g., "browser_source"). + /// The for . + /// A token to cancel the operation. + /// The deserialized default settings, or if no settings are present. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task GetInputDefaultSettingsAsync(string inputKind, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(inputKind); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + GetInputDefaultSettingsResponseData? response = await client + .Inputs.GetInputDefaultSettingsAsync(new GetInputDefaultSettingsRequestData(inputKind: inputKind), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + + return response?.DefaultInputSettings is not { } element ? null : JsonSerializer.Deserialize(element, typeInfo); + } + + /// + /// Gets the default settings for an input kind as a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the default input settings. Must be a library-registered settings type. + /// The identifier of the input kind (e.g., "browser_source"). + /// A token to cancel the operation. + /// The deserialized default settings, or if no settings are present. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task GetInputDefaultSettingsAsync(string inputKind, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Inputs.GetInputDefaultSettingsAsync(inputKind, typeInfo, cancellationToken); + } + + /// + /// Sets an input's volume in decibels. The underlying request accepts either decibels or + /// a multiplier and fails when given neither. + /// + /// The name of the input. + /// The desired volume in dB. OBS accepts -100 through 26. + /// A token to cancel the operation. + /// Thrown if OBS rejects the request. + /// Thrown if the client is not connected. + public async Task SetInputVolumeDbAsync( + string inputName, + double volumeDb, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(inputName); + client.EnsureConnected(); + + await client + .Inputs.SetInputVolumeAsync( + new SetInputVolumeRequestData { InputName = inputName, InputVolumeDb = volumeDb }, + cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Sets an input's volume as a linear multiplier, where 1.0 is unity gain. + /// + /// The name of the input. + /// The desired volume multiplier. OBS accepts 0 through 20. + /// A token to cancel the operation. + /// Thrown if OBS rejects the request. + /// Thrown if the client is not connected. + public async Task SetInputVolumeMulAsync( + string inputName, + double volumeMul, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(inputName); + client.EnsureConnected(); + + await client + .Inputs.SetInputVolumeAsync( + new SetInputVolumeRequestData { InputName = inputName, InputVolumeMul = volumeMul }, + cancellationToken + ) + .ConfigureAwait(false); + } +} diff --git a/ObsWebSocket.Core/Groups/MediaInputsRequestGroup.cs b/ObsWebSocket.Core/Groups/MediaInputsRequestGroup.cs new file mode 100644 index 0000000..4d52298 --- /dev/null +++ b/ObsWebSocket.Core/Groups/MediaInputsRequestGroup.cs @@ -0,0 +1,75 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the MediaInputs category, alongside its generated requests. +/// +public readonly partial struct MediaInputsRequestGroup +{ + /// + /// Triggers a media action on an input using the typed enum + /// rather than a protocol string constant. + /// + /// The name of the media input. + /// The transport action to perform. + /// A token to cancel the operation. + /// Thrown if OBS rejects the request. + /// Thrown if the client is not connected. + public async Task TriggerMediaActionAsync( + string inputName, + MediaInputAction action, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(inputName); + client.EnsureConnected(); + + await client + .MediaInputs.TriggerMediaInputActionAsync( + new TriggerMediaInputActionRequestData + { + InputName = inputName, + MediaAction = action.ToWireValue(), + }, + cancellationToken + ) + .ConfigureAwait(false); + } + + /// Plays a media input. + public Task PlayMediaAsync( + string inputName, + CancellationToken cancellationToken = default + ) => client.MediaInputs.TriggerMediaActionAsync(inputName, MediaInputAction.Play, cancellationToken); + + /// Pauses a media input. + public Task PauseMediaAsync( + string inputName, + CancellationToken cancellationToken = default + ) => client.MediaInputs.TriggerMediaActionAsync(inputName, MediaInputAction.Pause, cancellationToken); + + /// Stops a media input. + public Task StopMediaAsync( + string inputName, + CancellationToken cancellationToken = default + ) => client.MediaInputs.TriggerMediaActionAsync(inputName, MediaInputAction.Stop, cancellationToken); + + /// Restarts a media input from the beginning. + public Task RestartMediaAsync( + string inputName, + CancellationToken cancellationToken = default + ) => client.MediaInputs.TriggerMediaActionAsync(inputName, MediaInputAction.Restart, cancellationToken); +} diff --git a/ObsWebSocket.Core/Groups/OutputsRequestGroup.cs b/ObsWebSocket.Core/Groups/OutputsRequestGroup.cs new file mode 100644 index 0000000..a4f3ec5 --- /dev/null +++ b/ObsWebSocket.Core/Groups/OutputsRequestGroup.cs @@ -0,0 +1,184 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Outputs category, alongside its generated requests. +/// +public readonly partial struct OutputsRequestGroup +{ + /// + /// Gets the settings for an output as a strongly-typed object. + /// + /// The C# type to deserialize output settings into. + /// The name of the output. + /// The for . + /// A token to cancel the operation. + /// The deserialized output settings, or if no settings are present. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task GetOutputSettingsAsync(string outputName, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(outputName); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + GetOutputSettingsResponseData? response = await client + .Outputs.GetOutputSettingsAsync(new GetOutputSettingsRequestData(outputName: outputName), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + + return response?.OutputSettings is not { } element ? null : JsonSerializer.Deserialize(element, typeInfo); + } + + /// + /// Gets the settings for an output as a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the output settings. Must be a library-registered settings type. + /// The name of the output. + /// A token to cancel the operation. + /// The deserialized output settings, or if no settings are present. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task GetOutputSettingsAsync(string outputName, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Outputs.GetOutputSettingsAsync(outputName, typeInfo, cancellationToken); + } + + /// + /// Sets the settings for an output from a strongly-typed object. + /// + /// The C# type representing the output settings. + /// The name of the output. + /// The settings to apply. + /// The for . + /// A token to cancel the operation. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task SetOutputSettingsAsync(string outputName, + T settings, + JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentException.ThrowIfNullOrEmpty(outputName); + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + JsonElement settingsElement = JsonSerializer.SerializeToElement(settings, typeInfo); + + await client + .Outputs.SetOutputSettingsAsync(new SetOutputSettingsRequestData( + outputName: outputName, + outputSettings: settingsElement + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Sets the settings for an output from a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the output settings. Must be a library-registered settings type. + /// The name of the output. + /// The settings to apply. + /// A token to cancel the operation. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task SetOutputSettingsAsync(string outputName, + T settings, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Outputs.SetOutputSettingsAsync(outputName, settings, typeInfo, cancellationToken); + } + + /// + /// Returns if the OBS virtual camera output is currently active. + /// + /// A token to cancel the operation. + /// Thrown if the client is not connected. + public async Task IsVirtualCamActiveAsync(CancellationToken cancellationToken = default) + { + client.EnsureConnected(); + GetVirtualCamStatusResponseData? status = await client + .Outputs.GetVirtualCamStatusAsync(cancellationToken) + .ConfigureAwait(false); + return status?.OutputActive ?? false; + } + + /// + /// Starts or stops the virtual camera and waits until the + /// confirms the desired state, + /// or until elapses. + /// + /// to start the virtual camera; to stop it. + /// + /// Maximum time to wait for the state-change event. + /// Defaults to 10 seconds. + /// + /// A token to cancel the operation. + /// + /// The final OutputActive state reported by the event, + /// or if the timeout elapsed before the event arrived. + /// + /// Thrown if the client is not connected. + public async Task SetVirtualCamActiveAndWaitAsync(bool activate, + TimeSpan? timeout = null, + CancellationToken cancellationToken = default) + { + client.EnsureConnected(); + + TimeSpan effectiveTimeout = timeout ?? TimeSpan.FromSeconds(10); + + // Set up the wait before issuing the command to avoid missing the event. + Task waitTask = client.WaitForEventAsync( + predicate: _ => true, + timeout: effectiveTimeout, + cancellationToken: cancellationToken); + + if (activate) + { + await client.Outputs.StartVirtualCamAsync(cancellationToken).ConfigureAwait(false); + } + else + { + await client.Outputs.StopVirtualCamAsync(cancellationToken).ConfigureAwait(false); + } + + try + { + VirtualcamStateChangedEventArgs ev = await waitTask.ConfigureAwait(false); + return ev.EventData.OutputActive; + } + catch (TimeoutException) + { + return null; + } + } +} diff --git a/ObsWebSocket.Core/Groups/RecordRequestGroup.cs b/ObsWebSocket.Core/Groups/RecordRequestGroup.cs new file mode 100644 index 0000000..f4bada8 --- /dev/null +++ b/ObsWebSocket.Core/Groups/RecordRequestGroup.cs @@ -0,0 +1,84 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Record category, alongside its generated requests. +/// +public readonly partial struct RecordRequestGroup +{ + private static readonly TimeSpan s_defaultOutputTimeout = TimeSpan.FromSeconds(10); + + /// + /// Starts or stops recording and waits for OBS to confirm the state change. + /// + /// to start recording; to stop it. + /// Maximum time to wait for the state-change event. Defaults to 10 seconds. + /// A token to cancel the operation. + /// + /// The state reported by the event, or if the timeout elapsed first. + /// + /// Thrown if the client is not connected. + public async Task SetRecordActiveAndWaitAsync( + bool activate, + TimeSpan? timeout = null, + CancellationToken cancellationToken = default + ) + { + client.EnsureConnected(); + + // Set up the wait before issuing the command to avoid missing the event. + Task waitTask = client.WaitForEventAsync( + predicate: _ => true, + timeout: timeout ?? s_defaultOutputTimeout, + cancellationToken: cancellationToken + ); + + if (activate) + { + await client.Record.StartRecordAsync(cancellationToken).ConfigureAwait(false); + } + else + { + _ = await client.Record.StopRecordAsync(cancellationToken).ConfigureAwait(false); + } + + try + { + RecordStateChangedEventArgs ev = await waitTask.ConfigureAwait(false); + return OutputStateExtensions.FromWireValue(ev.EventData.OutputState); + } + catch (TimeoutException) + { + return null; + } + } + + /// + /// Returns whether recording is currently active. + /// + /// A token to cancel the operation. + /// Thrown if the client is not connected. + public async Task IsRecordActiveAsync( + CancellationToken cancellationToken = default + ) + { + client.EnsureConnected(); + GetRecordStatusResponseData? status = await client + .Record.GetRecordStatusAsync(cancellationToken) + .ConfigureAwait(false); + return status?.OutputActive ?? false; + } +} diff --git a/ObsWebSocket.Core/Groups/SceneItemsRequestGroup.cs b/ObsWebSocket.Core/Groups/SceneItemsRequestGroup.cs new file mode 100644 index 0000000..51e0a28 --- /dev/null +++ b/ObsWebSocket.Core/Groups/SceneItemsRequestGroup.cs @@ -0,0 +1,213 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the SceneItems category, alongside its generated requests. +/// +public readonly partial struct SceneItemsRequestGroup +{ + /// + /// Sets or toggles the enabled (visibility) state of a scene item, identified by its numeric ID. + /// + /// The name of the scene containing the item. + /// The numeric ID of the scene item. + /// The desired state (true=enabled, false=disabled). If null, the state will be toggled. + /// A token to cancel the operation. + /// The final enabled state of the scene item after the operation. + /// Thrown if OBS fails the operation (e.g., scene/item not found). + /// Thrown if the client is not connected. + public async Task SetSceneItemEnabledAsync(string sceneName, + double sceneItemId, // Use double as sceneItemId is Number in protocol + bool? isEnabled = null, // If null, toggles; otherwise sets to the specified state + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sceneName); + client.EnsureConnected(); + + bool targetState; + if (isEnabled.HasValue) + { + targetState = isEnabled.Value; + } + else + { + // Need to get current state to toggle + GetSceneItemEnabledResponseData currentStateResponse = + await client + .SceneItems.GetSceneItemEnabledAsync( + new GetSceneItemEnabledRequestData(sceneItemId: sceneItemId, sceneName: sceneName), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false) + ?? throw new ObsWebSocketException( + $"Failed to get current enabled state for item ID {sceneItemId} in scene '{sceneName}'." + ); + targetState = !currentStateResponse.SceneItemEnabled; + } + + await client + .SceneItems.SetSceneItemEnabledAsync(new SetSceneItemEnabledRequestData( + sceneItemId: sceneItemId, + sceneItemEnabled: targetState, + sceneName: sceneName + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + + return targetState; + } + + /// + /// Sets or toggles the enabled (visibility) state of a scene item, identified by its source name within a scene. + /// + /// The name of the scene containing the item. + /// The name of the source corresponding to the scene item. + /// The desired state (true=enabled, false=disabled). If null, the state will be toggled. + /// A token to cancel the operation. + /// The final enabled state of the scene item after the operation. + /// Thrown if OBS fails the operation (e.g., scene/item not found). + /// Thrown if the client is not connected. + /// Thrown if the source name is not found within the specified scene. + public async Task SetSceneItemEnabledAsync(string sceneName, + string sourceName, + bool? isEnabled = null, // If null, toggles; otherwise sets to the specified state + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sceneName); + ArgumentException.ThrowIfNullOrEmpty(sourceName); + client.EnsureConnected(); + + double? sceneItemId = await client + .SceneItems.FindSceneItemIdAsync(sceneName, sourceName, cancellationToken) + .ConfigureAwait(false); + + return sceneItemId.HasValue + ? await client + .SceneItems.SetSceneItemEnabledAsync(sceneName, + sceneItemId.Value, + isEnabled, + cancellationToken + ) + .ConfigureAwait(false) + : throw new SceneItemNotFoundException( + $"Source '{sourceName}' not found in scene '{sceneName}'. Cannot set enabled state." + ); + } + + /// + /// Attempts to get the numeric ID of a scene item within a specific scene. + /// Returns null if the scene or source is not found. + /// + /// The name of the scene to search within. + /// The name of the source corresponding to the scene item. + /// A token to cancel the operation. + /// A Task resulting in the nullable scene item ID (double?). Returns null if the item or scene is not found. + /// Thrown for OBS errors other than 'ResourceNotFound'. + /// Thrown if the client is not connected. + [Obsolete("Renamed to FindSceneItemIdAsync. Async methods cannot use the out-parameter Try pattern, so the Try prefix was misleading. This forwarder will be removed in a future release.")] + public Task TryGetSceneItemIdAsync(string sceneName, + string sourceName, + CancellationToken cancellationToken = default + ) => client.SceneItems.FindSceneItemIdAsync(sceneName, sourceName, cancellationToken); + + /// + /// Returns the scene item id for a source within a scene, or when the + /// scene does not contain it. + /// + /// The name of the scene to search. + /// The name of the source to locate. + /// A token to cancel the operation. + /// The scene item id, or if the source is not in the scene. + /// Thrown if the client is not connected. + public async Task FindSceneItemIdAsync(string sceneName, + string sourceName, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sceneName); + ArgumentException.ThrowIfNullOrEmpty(sourceName); + client.EnsureConnected(); + + try + { + GetSceneItemIdResponseData? response = await client + .SceneItems.GetSceneItemIdAsync( + new GetSceneItemIdRequestData(sourceName: sourceName, sceneName: sceneName), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + + // If response is not null, return the ID. The underlying GetSceneItemIdAsync + // should guarantee the response isn't null on success. + return response?.SceneItemId; + } + catch (ObsWebSocketException ex) + when (ex.Message.Contains("NotFound", StringComparison.OrdinalIgnoreCase) + || // General not found + ex.Message.Contains( + $"code {(int)Core.Protocol.Generated.RequestStatus.ResourceNotFound}:", + StringComparison.Ordinal + ) // Specific code check + ) + { + // Item or scene not found, which is the expected 'failure' for a 'TryGet' pattern + return null; + } + // Let other ObsWebSocketExceptions or different exception types propagate + } + + /// + /// Sets or toggles a scene item's enabled state using an integer item id. + /// + /// The name of the scene containing the item. + /// The numeric id of the scene item. + /// The desired state, or to toggle. + /// A token to cancel the operation. + /// The resulting enabled state. + public Task SetSceneItemEnabledAsync( + string sceneName, + int sceneItemId, + bool? isEnabled = null, + CancellationToken cancellationToken = default + ) => + client.SceneItems.SetSceneItemEnabledAsync(sceneName, + (double)sceneItemId, + isEnabled, + cancellationToken + ); + + /// + /// Returns the scene item id for a source within a scene as an , or + /// when the scene does not contain it. + /// + /// The name of the scene to search. + /// The name of the source to locate. + /// A token to cancel the operation. + public async Task FindSceneItemIdInt32Async( + string sceneName, + string sourceName, + CancellationToken cancellationToken = default + ) + { + double? id = await client + .SceneItems.FindSceneItemIdAsync(sceneName, sourceName, cancellationToken) + .ConfigureAwait(false); + return id is null ? null : checked((int)id.Value); + } +} diff --git a/ObsWebSocket.Core/Groups/ScenesRequestGroup.cs b/ObsWebSocket.Core/Groups/ScenesRequestGroup.cs new file mode 100644 index 0000000..810f940 --- /dev/null +++ b/ObsWebSocket.Core/Groups/ScenesRequestGroup.cs @@ -0,0 +1,284 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Scenes category, alongside its generated requests. +/// +public readonly partial struct ScenesRequestGroup +{ + /// + /// Switches the active Program or Preview scene, optionally setting a specific transition and duration beforehand. + /// Does not restore the previously active transition. + /// + /// The name of the scene to switch to. + /// Optional: The name of the transition to use. + /// Optional: The duration for the transition (in milliseconds). Requires transitionName to be set. + /// If true (default), switches the Program scene. If false, switches the Preview scene (requires Studio Mode). + /// A token to cancel the operation. + /// Thrown if OBS fails to perform any step (e.g., scene/transition not found). + /// Thrown if the client is not connected. + public async Task SwitchSceneAsync(string sceneName, + string? transitionName = null, + int? transitionDurationMs = null, + bool switchToProgram = true, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sceneName); // Throws if not connected + client.EnsureConnected(); + + // Set transition if specified + if (!string.IsNullOrEmpty(transitionName)) + { + await client + .Transitions.SetCurrentSceneTransitionAsync( + new SetCurrentSceneTransitionRequestData(transitionName: transitionName), + cancellationToken + ) + .ConfigureAwait(false); + + // Set duration only if transition was also set + if (transitionDurationMs.HasValue) + { + await client + .Transitions.SetCurrentSceneTransitionDurationAsync( + new SetCurrentSceneTransitionDurationRequestData( + transitionDurationMs.Value + ), + cancellationToken + ) + .ConfigureAwait(false); + } + } + else if (transitionDurationMs.HasValue) + { + // Optionally log a warning if duration is set without transition name, as it might be ignored by OBS. + // OBS behavior might vary here, but typically duration applies to the *current* transition. + // For clarity, we only explicitly set duration if a transition name is also given. + // Consider if setting duration alone should be allowed or throw an ArgumentException. + } + + // Perform the scene switch + if (switchToProgram) + { + await client + .Scenes.SetCurrentProgramSceneAsync( + new SetCurrentProgramSceneRequestData(sceneName: sceneName), + cancellationToken + ) + .ConfigureAwait(false); + } + else + { + await client + .Scenes.SetCurrentPreviewSceneAsync( + new SetCurrentPreviewSceneRequestData(sceneName: sceneName), + cancellationToken + ) + .ConfigureAwait(false); + } + } + + /// + /// Switches the active Program or Preview scene using an optional transition, + /// and waits for the corresponding scene change event before returning. + /// + /// The name of the scene to switch to. + /// Optional: The name of the transition to use. Applicable only when switching the Program scene. + /// Optional: The duration for the transition (in milliseconds). Requires transitionName to be set. Applicable only when switching the Program scene. + /// If true (default), switches the Program scene and waits for the scene change. If false, switches the Preview scene (requires Studio Mode) and waits for the preview scene change. + /// Optional: Maximum time to wait for the completion event after triggering the switch. Defaults based on client configuration. + /// A token to cancel the operation. + /// Thrown if OBS fails to perform the switch or if the underlying wait fails unexpectedly. + /// Thrown if the expected event confirming the switch completion is not received within the timeout period. + /// Thrown if the client is not connected, or if trying to switch Preview scene when Studio Mode is disabled. + /// Thrown if the operation is canceled via the cancellationToken. + public async Task SwitchSceneAndWaitAsync(string sceneName, + string? transitionName = null, + int? transitionDurationMs = null, + bool switchToProgram = true, + TimeSpan? timeout = null, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sceneName); + client.EnsureConnected(); // Ensure client is connected + + // Determine default timeout if not provided + int baseWaitMs = + transitionDurationMs.HasValue && transitionDurationMs > 0 && switchToProgram + ? transitionDurationMs.Value + 2000 // Add a 2-second buffer if transition likely + : client._options.Value.RequestTimeoutMs + 2000; // Or default request timeout + buffer + TimeSpan effectiveTimeout = timeout ?? TimeSpan.FromMilliseconds(baseWaitMs); + + // --- Corrected Event Waiting Setup --- + // We need separate task variables because Task is not covariant. + Task? programWaitTask = null; + Task? previewWaitTask = null; + string eventDescription; + + if (switchToProgram) + { + eventDescription = $"CurrentProgramSceneChanged to '{sceneName}'"; + // Start the wait BEFORE triggering the action. + programWaitTask = client.WaitForEventAsync( + predicate: args => args.EventData.SceneName == sceneName, + timeout: effectiveTimeout, + cancellationToken: cancellationToken + ); + } + else + { + eventDescription = $"CurrentPreviewSceneChanged to '{sceneName}'"; + // Start the wait BEFORE triggering the action. + previewWaitTask = client.WaitForEventAsync( + predicate: args => args.EventData.SceneName == sceneName, + timeout: effectiveTimeout, + cancellationToken: cancellationToken + ); + } + // --------------------------------------- + + try + { + // Trigger the scene switch using the non-waiting helper + // This call happens *after* WaitForEventAsync has set up its subscription + await client + .Scenes.SwitchSceneAsync( + sceneName: sceneName, + transitionName: switchToProgram ? transitionName : null, + transitionDurationMs: switchToProgram ? transitionDurationMs : null, + switchToProgram: switchToProgram, + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + + client._logger.LogDebug( + "Switch triggered for '{SceneName}', waiting for {EventDescription}...", + sceneName, + eventDescription + ); + + if (programWaitTask is not null) + { + _ = await programWaitTask.ConfigureAwait(false); + } + else if (previewWaitTask is not null) + { + _ = await previewWaitTask.ConfigureAwait(false); + } + else + { + throw new InvalidOperationException("Internal error: No wait task was assigned."); + } + + client._logger.LogInformation( + "Successfully switched and confirmed {EventDescription}.", + eventDescription + ); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + client._logger.LogInformation( + "SwitchSceneAndWaitAsync operation was canceled externally for scene '{SceneName}'.", + sceneName + ); + throw; // Re-throw cancellation + } + catch (Exception ex) + { + client._logger.LogError( + ex, + "Error during SwitchSceneAndWaitAsync for scene '{SceneName}'.", + sceneName + ); + throw; + } + // The finally block within WaitForEventAsync handles unsubscribing the temporary event handler. + } + + /// + /// Checks whether a scene with the given name exists. + /// + /// The scene name to look for. + /// A token to cancel the operation. + /// Thrown if the client is not connected. + public async Task SceneExistsAsync( + string sceneName, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sceneName); + client.EnsureConnected(); + + GetSceneListResponseData? scenes = await client + .Scenes.GetSceneListAsync(new GetSceneListRequestData(), cancellationToken) + .ConfigureAwait(false); + + return scenes?.Scenes?.Any(s => + string.Equals(s.SceneName, sceneName, StringComparison.Ordinal) + ) ?? false; + } + + /// Switches the Program scene. + /// The scene to switch to. + /// Optional transition to use for this switch only. + /// Optional transition duration for this switch only. + /// A token to cancel the operation. + public Task SwitchProgramSceneAsync( + string sceneName, + string? transitionName = null, + int? transitionDurationMs = null, + CancellationToken cancellationToken = default + ) => + client.Scenes.SwitchSceneAsync( + sceneName, + transitionName, + transitionDurationMs, + switchToProgram: true, + cancellationToken + ); + + /// Switches the Preview scene. Requires Studio Mode. + /// The scene to switch to. + /// A token to cancel the operation. + public Task SwitchPreviewSceneAsync( + string sceneName, + CancellationToken cancellationToken = default + ) => + client.Scenes.SwitchSceneAsync( + sceneName, + switchToProgram: false, + cancellationToken: cancellationToken + ); + + /// Switches the Program scene and waits for OBS to confirm it. + /// The scene to switch to. + /// How long to wait for confirmation. + /// A token to cancel the operation. + /// Thrown if the confirmation does not arrive in time. + public Task SwitchProgramSceneAndWaitAsync( + string sceneName, + TimeSpan? timeout = null, + CancellationToken cancellationToken = default + ) => + client.Scenes.SwitchSceneAndWaitAsync( + sceneName, + switchToProgram: true, + timeout: timeout, + cancellationToken: cancellationToken + ); +} diff --git a/ObsWebSocket.Core/Groups/SourcesRequestGroup.cs b/ObsWebSocket.Core/Groups/SourcesRequestGroup.cs new file mode 100644 index 0000000..60b4b37 --- /dev/null +++ b/ObsWebSocket.Core/Groups/SourcesRequestGroup.cs @@ -0,0 +1,255 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Sources category, alongside its generated requests. +/// +public readonly partial struct SourcesRequestGroup +{ + /// + /// Checks if an input or scene source with the given name exists in OBS. + /// + /// The name of the input or scene to check. + /// A token to cancel the operation. + /// True if a source (input or scene) with the specified name exists, false otherwise. + /// Thrown if an unexpected error occurs during API calls. + /// Thrown if the client is not connected. + public async Task SourceExistsAsync(string sourceName, + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sourceName); + client.EnsureConnected(); + + try + { + // Check inputs first + GetInputListResponseData? inputListResponse = await client + .Inputs.GetInputListAsync( + new GetInputListRequestData(), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + if ( + inputListResponse?.Inputs?.Any(i => + string.Equals(i.InputName, sourceName, StringComparison.Ordinal) + ) ?? false + ) + { + return true; + } + + // Check scenes if not found in inputs + ObsWebSocket.Core.Protocol.Responses.GetSceneListResponseData? sceneListResponse = + await client + .Scenes.GetSceneListAsync(new(), cancellationToken: cancellationToken) + .ConfigureAwait(false); + return sceneListResponse?.Scenes?.Any(s => + string.Equals(s.SceneName, sourceName, StringComparison.Ordinal) + ) ?? false; + } + catch (ObsWebSocketException ex) + { + // Log the specific OBS error but return false as the source effectively doesn't exist or couldn't be verified + client._logger.LogWarning( + ex, + "OBS error while checking if source '{SourceName}' exists. Assuming it doesn't.", + sourceName + ); + return false; + } + // Let other exceptions (like InvalidOperationException for disconnect) propagate + } + + /// + /// Gets a screenshot of a source and returns it as a byte array. + /// + /// The name of the source (input or scene). + /// The desired image format (e.g., "png", "jpg", "bmp"). Use GetVersion for supported formats. + /// Optional width to scale the screenshot to. + /// Optional height to scale the screenshot to. + /// Optional compression quality (0-100 for formats like jpg, -1 for default). + /// A token to cancel the operation. + /// A byte array containing the image data, or null if the source was not found or an error occurred. + /// Thrown for OBS errors other than 'ResourceNotFound' or Base64 decoding errors. + /// Thrown if the client is not connected. + public async Task GetSourceScreenshotBytesAsync(string sourceName, + string imageFormat = "png", // Common default + int? width = null, + int? height = null, + int? compressionQuality = -1, // Use -1 for OBS default quality + CancellationToken cancellationToken = default + ) + { + ArgumentException.ThrowIfNullOrEmpty(sourceName); + ArgumentException.ThrowIfNullOrEmpty(imageFormat); + client.EnsureConnected(); + + GetSourceScreenshotResponseData? response; + try + { + response = await client + .Sources.GetSourceScreenshotAsync( + new GetSourceScreenshotRequestData( + sourceName: sourceName, + imageFormat: imageFormat, + imageWidth: width, + imageHeight: height, + imageCompressionQuality: compressionQuality + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + catch (ObsWebSocketException ex) + when (ex.Message.Contains("NotFound", StringComparison.OrdinalIgnoreCase) + || ex.Message.Contains( + $"code {(int)Core.Protocol.Generated.RequestStatus.ResourceNotFound}:", + StringComparison.Ordinal + ) + ) + { + client._logger.LogWarning( + "Source '{SourceName}' not found for screenshot.", + sourceName + ); + return null; + } + // Let other exceptions propagate + + if (string.IsNullOrEmpty(response?.ImageData)) + { + client._logger.LogWarning( + "Received null or empty image data for screenshot of '{SourceName}'.", + sourceName + ); + return null; + } + + try + { + return Convert.FromBase64String(response.ImageData); + } + catch (FormatException formatEx) + { + client._logger.LogError( + formatEx, + "Failed to decode Base64 image data for screenshot of '{SourceName}'.", + sourceName + ); + // Wrap in ObsWebSocketException? Or just return null? Returning null seems reasonable for a helper. + return null; + } + } + + /// + /// Captures a screenshot of the named source and returns the raw image bytes. + /// The parameter can be used to identify the source + /// unambiguously when multiple sources share the same display name. + /// + /// The name of the source or scene to capture. + /// Image format: "png", "jpg", or "bmp". + /// Optional output width. uses the source width. + /// Optional output height. uses the source height. + /// + /// JPEG compression quality 0–100 (-1 uses the OBS default). + /// Ignored for lossless formats. + /// + /// + /// Optional source UUID for unambiguous identification. + /// When the lookup is by alone. + /// + /// A token to cancel the operation. + /// The decoded image bytes, or an empty array if OBS returned no data. + /// Thrown if OBS rejects the request. + /// Thrown if the client is not connected. + public async Task GetSourceScreenshotOnCanvasBytesAsync(string sourceName, + string imageFormat = "png", + int? width = null, + int? height = null, + int compressionQuality = -1, + string? sourceUuid = null, + CancellationToken cancellationToken = default) + { + ArgumentException.ThrowIfNullOrEmpty(sourceName); + client.EnsureConnected(); + + GetSourceScreenshotResponseData? response = await client.Sources.GetSourceScreenshotAsync( + new GetSourceScreenshotRequestData( + imageFormat: imageFormat, + sourceName: sourceName, + sourceUuid: sourceUuid, + imageWidth: width, + imageHeight: height, + imageCompressionQuality: compressionQuality + ), + cancellationToken).ConfigureAwait(false); + + string? b64 = response?.ImageData; + if (string.IsNullOrEmpty(b64)) + { + return []; + } + + int commaIdx = b64.IndexOf(',', StringComparison.Ordinal); + string base64 = commaIdx >= 0 ? b64[(commaIdx + 1)..] : b64; + return Convert.FromBase64String(base64); + } + + /// + /// Saves a screenshot of the named source directly to a file on the OBS host machine. + /// The parameter can be used to identify the source + /// unambiguously when multiple sources share the same display name. + /// + /// The name of the source or scene to capture. + /// Absolute path on the OBS host where the image will be saved. + /// Image format: "png", "jpg", or "bmp". + /// Optional output width. uses the source width. + /// Optional output height. uses the source height. + /// JPEG compression quality 0–100 (-1 uses the OBS default). + /// + /// Optional source UUID for unambiguous identification. + /// When the lookup is by alone. + /// + /// A token to cancel the operation. + /// Thrown if OBS rejects the request. + /// Thrown if the client is not connected. + public async Task SaveSourceScreenshotToFileAsync(string sourceName, + string filePath, + string imageFormat = "png", + int? width = null, + int? height = null, + int compressionQuality = -1, + string? sourceUuid = null, + CancellationToken cancellationToken = default) + { + ArgumentException.ThrowIfNullOrEmpty(sourceName); + ArgumentException.ThrowIfNullOrEmpty(filePath); + client.EnsureConnected(); + + await client.Sources.SaveSourceScreenshotAsync( + new SaveSourceScreenshotRequestData( + imageFormat: imageFormat, + imageFilePath: filePath, + sourceName: sourceName, + sourceUuid: sourceUuid, + imageWidth: width, + imageHeight: height, + imageCompressionQuality: compressionQuality + ), + cancellationToken).ConfigureAwait(false); + } +} diff --git a/ObsWebSocket.Core/Groups/StreamRequestGroup.cs b/ObsWebSocket.Core/Groups/StreamRequestGroup.cs new file mode 100644 index 0000000..435b82c --- /dev/null +++ b/ObsWebSocket.Core/Groups/StreamRequestGroup.cs @@ -0,0 +1,83 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Stream category, alongside its generated requests. +/// +public readonly partial struct StreamRequestGroup +{ + private static readonly TimeSpan s_defaultOutputTimeout = TimeSpan.FromSeconds(10); + + /// + /// Starts or stops streaming and waits for OBS to confirm the state change. + /// + /// to start streaming; to stop it. + /// Maximum time to wait for the state-change event. Defaults to 10 seconds. + /// A token to cancel the operation. + /// + /// The state reported by the event, or if the timeout elapsed first. + /// + /// Thrown if the client is not connected. + public async Task SetStreamActiveAndWaitAsync( + bool activate, + TimeSpan? timeout = null, + CancellationToken cancellationToken = default + ) + { + client.EnsureConnected(); + + Task waitTask = client.WaitForEventAsync( + predicate: _ => true, + timeout: timeout ?? s_defaultOutputTimeout, + cancellationToken: cancellationToken + ); + + if (activate) + { + await client.Stream.StartStreamAsync(cancellationToken).ConfigureAwait(false); + } + else + { + await client.Stream.StopStreamAsync(cancellationToken).ConfigureAwait(false); + } + + try + { + StreamStateChangedEventArgs ev = await waitTask.ConfigureAwait(false); + return OutputStateExtensions.FromWireValue(ev.EventData.OutputState); + } + catch (TimeoutException) + { + return null; + } + } + + /// + /// Returns whether streaming is currently active. + /// + /// A token to cancel the operation. + /// Thrown if the client is not connected. + public async Task IsStreamActiveAsync( + CancellationToken cancellationToken = default + ) + { + client.EnsureConnected(); + GetStreamStatusResponseData? status = await client + .Stream.GetStreamStatusAsync(cancellationToken) + .ConfigureAwait(false); + return status?.OutputActive ?? false; + } +} diff --git a/ObsWebSocket.Core/Groups/TransitionsRequestGroup.cs b/ObsWebSocket.Core/Groups/TransitionsRequestGroup.cs new file mode 100644 index 0000000..0338422 --- /dev/null +++ b/ObsWebSocket.Core/Groups/TransitionsRequestGroup.cs @@ -0,0 +1,112 @@ +using Microsoft.Extensions.Logging; +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; +using ObsWebSocket.Core.Events; +using ObsWebSocket.Core.Events.Generated; +using ObsWebSocket.Core.Protocol; +using ObsWebSocket.Core.Protocol.Common; +using ObsWebSocket.Core.Networking; +using ObsWebSocket.Core.Protocol.Common.FilterSettings; +using ObsWebSocket.Core.Protocol.Common.InputSettings; +using ObsWebSocket.Core.Protocol.Generated; +using ObsWebSocket.Core.Protocol.Requests; +using ObsWebSocket.Core.Protocol.Responses; + +namespace ObsWebSocket.Core; + +/// +/// Conveniences for the Transitions category, alongside its generated requests. +/// +public readonly partial struct TransitionsRequestGroup +{ + /// + /// Gets the settings for the current scene transition as a strongly-typed object. + /// + /// The C# type to deserialize transition settings into. + /// The for . + /// A token to cancel the operation. + /// The deserialized transition settings, or if no settings are present. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task GetCurrentSceneTransitionSettingsAsync(JsonTypeInfo typeInfo, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + GetCurrentSceneTransitionResponseData? response = await client + .Transitions.GetCurrentSceneTransitionAsync(cancellationToken: cancellationToken) + .ConfigureAwait(false); + + return response?.TransitionSettings is not { } element ? null : JsonSerializer.Deserialize(element, typeInfo); + } + + /// + /// Gets the settings for the current scene transition as a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the transition settings. Must be a library-registered settings type. + /// A token to cancel the operation. + /// The deserialized transition settings, or if no settings are present. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task GetCurrentSceneTransitionSettingsAsync(CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Transitions.GetCurrentSceneTransitionSettingsAsync(typeInfo, cancellationToken); + } + + /// + /// Sets the settings for the current scene transition from a strongly-typed object. + /// + /// The C# type representing the transition settings. + /// The settings to apply. + /// The for . + /// If , the provided settings are overlaid on top of the existing settings. Defaults to . + /// A token to cancel the operation. + /// Thrown if OBS returns an error or serialization fails. + /// Thrown if the client is not connected. + public async Task SetCurrentSceneTransitionSettingsAsync(T settings, + JsonTypeInfo typeInfo, + bool? overlay = true, + CancellationToken cancellationToken = default + ) + where T : class + { + ArgumentNullException.ThrowIfNull(typeInfo); + client.EnsureConnected(); + + JsonElement settingsElement = JsonSerializer.SerializeToElement(settings, typeInfo); + + await client + .Transitions.SetCurrentSceneTransitionSettingsAsync(new SetCurrentSceneTransitionSettingsRequestData( + transitionSettings: settingsElement, + overlay: overlay + ), + cancellationToken: cancellationToken + ) + .ConfigureAwait(false); + } + + /// + /// Sets the settings for the current scene transition from a strongly-typed object. The type must be registered in ObsWebSocketJsonContext. + /// + /// The C# type representing the transition settings. Must be a library-registered settings type. + /// The settings to apply. + /// If , the provided settings are overlaid on top of the existing settings. Defaults to . + /// A token to cancel the operation. + /// Thrown if the type is not registered, OBS returns an error, or serialization fails. + /// Thrown if the client is not connected. + public Task SetCurrentSceneTransitionSettingsAsync(T settings, + bool? overlay = true, + CancellationToken cancellationToken = default + ) + where T : class + { + JsonTypeInfo typeInfo = ObsWebSocketClientHelpers.GetRegisteredTypeInfo(); + return client.Transitions.SetCurrentSceneTransitionSettingsAsync(settings, typeInfo, overlay, cancellationToken); + } +} diff --git a/ObsWebSocket.Core/ObsBatchBuilder.cs b/ObsWebSocket.Core/ObsBatchBuilder.cs index 7840b62..fd3713e 100644 --- a/ObsWebSocket.Core/ObsBatchBuilder.cs +++ b/ObsWebSocket.Core/ObsBatchBuilder.cs @@ -1,3 +1,4 @@ +using System.Runtime.CompilerServices; using System.Text.Json; using System.Text.Json.Serialization.Metadata; using ObsWebSocket.Core.Protocol; @@ -12,6 +13,7 @@ namespace ObsWebSocket.Core; /// The generated methods are conveniences over . Anything they do /// not cover can still be added with , and /// still accepts a plain list. +/// Not thread safe. Build a batch on one thread, or give each thread its own builder. /// public sealed partial class ObsBatchBuilder { @@ -29,11 +31,11 @@ public sealed partial class ObsBatchBuilder /// /// The item to append. /// The same builder, for chaining. - public ObsBatchBuilder Add(BatchRequestItem item) + public BatchRef Add(BatchRequestItem item) { ArgumentNullException.ThrowIfNull(item); _items.Add(item); - return this; + return new BatchRef(_items.Count - 1); } /// @@ -42,11 +44,12 @@ public ObsBatchBuilder Add(BatchRequestItem item) /// The OBS request type string. /// The request payload, or when it takes none. /// The same builder, for chaining. - public ObsBatchBuilder Add(string requestType, object? requestData = null) + [OverloadResolutionPriority(1)] + public BatchRef Add(string requestType, object? requestData = null) { ArgumentException.ThrowIfNullOrEmpty(requestType); _items.Add(new BatchRequestItem(requestType, requestData)); - return this; + return new BatchRef(_items.Count - 1); } /// @@ -58,7 +61,7 @@ public ObsBatchBuilder Add(string requestType, object? requestData = null) /// The request payload. /// Serialization metadata for . /// The same builder, for chaining. - public ObsBatchBuilder Add(string requestType, T requestData, JsonTypeInfo typeInfo) + public BatchRef Add(string requestType, T requestData, JsonTypeInfo typeInfo) where T : class { ArgumentException.ThrowIfNullOrEmpty(requestType); @@ -71,11 +74,26 @@ public ObsBatchBuilder Add(string requestType, T requestData, JsonTypeInfo JsonSerializer.SerializeToElement(requestData, typeInfo) ) ); - return this; + return new BatchRef(_items.Count - 1); + } + + /// + /// Appends a request and returns its position, which the generated group methods wrap in a + /// . + /// + /// The OBS request type string. + /// The request payload, or . + /// The position of the appended request. + internal int AddRequest(string requestType, object? requestData) + { + ArgumentException.ThrowIfNullOrEmpty(requestType); + _items.Add(new BatchRequestItem(requestType, requestData)); + return _items.Count - 1; } /// /// Returns the accumulated items as the list takes. /// public List Build() => [.. _items]; + } diff --git a/ObsWebSocket.Core/ObsWebSocket.Core.csproj b/ObsWebSocket.Core/ObsWebSocket.Core.csproj index 4cd0a12..f3cb954 100644 --- a/ObsWebSocket.Core/ObsWebSocket.Core.csproj +++ b/ObsWebSocket.Core/ObsWebSocket.Core.csproj @@ -1,15 +1,4 @@  - - - $(NoWarn);LOGGEN036 - -