Table of Contents

Method SetStreamServiceAsync

Namespace
OBSStudioClient.Model
Assembly
OBSClient.dll

SetStreamServiceAsync(string, object, CancellationToken)

Changes the stream service of OBS Studio (the profile that is current), and returns when OBS Studio has made the change.

public Task SetStreamServiceAsync(string type, object settings, CancellationToken cancellationToken = default)

Parameters

type string

The type of the service: rtmp_common for one of the services that OBS Studio knows, rtmp_custom for a server and a key that you give, or the type of a plugin.

settings object

The settings of the service: an object (for example new { server = "rtmp://live.example.com/app", key = "..." }), a dictionary, or a JsonElement. What the fields are called depends on the type. It can not be empty.

cancellationToken CancellationToken

A token that ends the wait. A change that was not sent yet is not sent.

Returns

Task

A task that completes when OBS Studio has answered that it made the change.

Remarks

When the type is the one of the service that is current, the settings that you give are laid over the ones that it holds: a field that you leave out stays as it is. Another type makes OBS Studio make a new service of that type, with the settings that you give and the defaults of the type for the rest; the settings of the old service are gone. OBS Studio saves the service to the profile at once, and does not change it while it streams.

The settings hold the stream key: do not log them. OBS Studio does not announce a change of the stream service and the model does not keep it, so the call has nothing to wait for but the answer of OBS Studio: ask what it holds with GetStreamServiceAsync(CancellationToken). See SetEnabledAsync(bool, CancellationToken) for the order of changes.

Exceptions

ArgumentNullException

settings is null.

ArgumentException

type is empty, or settings is not an object, or can not be written as JSON.

ObsNotConnectedException

There is no connection to OBS Studio. Nothing was changed.

ObsNotReadyException

OBS Studio is changing its scene collection, or did so after the call. Nothing was changed.

ObsUnknownOutcomeException

OBS Studio did not answer in time, or the connection ended: it is not known whether it made the change.

ObsResponseException

OBS Studio refused the change: it is streaming (ErrorCode is OutputRunning), the settings are empty (RequestFieldEmpty), or it has no service of that type (ResourceCreationFailed).