Class ObsClient
- Namespace
- OBSStudioClient
- Assembly
- OBSClient.dll
The OBS Studio WebSockets Client
public sealed class ObsClient : INotifyPropertyChanged, IDisposable
- Inheritance
-
ObsClient
- Implements
- Inherited Members
Remarks
Implements https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md
The events of OBS Studio and ConnectionClosed are raised by a dispatcher of the client: one at a time, in the order in which they happened, on a thread of the thread pool that is not the thread that reads from OBS Studio. A handler can therefore wait for a response to a request, but the events behind it wait while it runs, and they queue up in memory when the handlers are slower than OBS Studio is. Once Dispose() was called nothing new is started: what was waiting is dropped, and a notification that is under way stops before its next handler. A handler that is running is neither interrupted nor waited for, so it can still be running when Dispose() returns.
PropertyChanged and the statistics events (TotalBytesSentChanged and the others) are raised on the thread that causes the change, which can be the thread that reads from OBS Studio: keep those handlers short, and do not wait for a response from OBS Studio in them.
Constructors
- ObsClient(ILogger<ObsClient>?)
Creates a new instance of the ObsClient class.
Properties
- AutoReconnect
Gets or sets the value that indicates whether the ObsClient should automatically try to reconnect to OBS Studio.
- ConnectionState
Gets the current state of the connection to OBS Studio.
- MaxRequestRetries
Gets or sets the maximum number of times the ObsClient should retry a request when OBS Studio is not ready to perform the request.
- RequestRetryInterval
Gets or sets the interval, in milliseconds, the ObsClient should wait before retrying a request when OBS Studio is not ready to perform the request.
- RequestTimeout
Gets or sets the maximum amount of time, in milliseconds, the ObsClient to wait for an OBS Studio response after making a request.
- SessionBytesReceived
Gets the number of bytes received from OBS Studio in the current session.
- SessionBytesSent
Gets the number of bytes sent to OBS Studio.
- SessionMessagesReceived
Gets the number of messages received from OBS Studio in the current session.
- SessionMessagesSent
Gets the number of messages sent to OBS Studio in the current session.
- TotalBytesReceived
Gets the total number of bytes received from OBS Studio throughout the lifetime of the ObsClient.
- TotalBytesSent
Gets the number of bytes sent to OBS Studio.
- TotalMessagesReceived
Gets the total number of messages received from OBS Studio throughout the lifetime of the ObsClient.
- TotalMessagesSent
Gets the total number of messages sent to OBS Studio throughout the lifetime of the ObsClient.
Methods
- BroadcastCustomEvent(JsonElement, CancellationToken)
Broadcasts a
CustomEventto all WebSocket clients. Receivers are clients which are identified and subscribed.
- CallVendorRequest(string, string, JsonElement?, CancellationToken)
Call a request registered to a vendor.
- ConnectAsync(bool, string, string, int, EventSubscriptions, CancellationToken)
Opens the connection to OBS Studio and tries to authenticate the session.
- CreateInput(SceneRef, string, string, Dictionary<string, object>?, bool?, Guid?, CancellationToken)
Creates a new input, adding it as a scene item to the specified scene.
- CreateProfile(string, CancellationToken)
Creates a new profile, switching to it in the process.
- CreateRecordChapter(string?, CancellationToken)
Adds a new chapter marker to the file currently being recorded.
- CreateScene(string, Guid?, CancellationToken)
Creates a new scene in OBS.
- CreateSceneCollection(string, CancellationToken)
Creates a new scene collection, switching to it in the process.
- CreateSceneItem(SceneRef, SourceRef, bool?, Guid?, CancellationToken)
Creates a new scene item using a source.
- CreateSourceFilter(SourceRef, string, string, Dictionary<string, object>?, Guid?, CancellationToken)
Creates a new filter, adding it to the specified source.
- Disconnect()
Closes the connection to OBS Studio.
- DuplicateSceneItem(SceneRef, int, SceneRef?, Guid?, CancellationToken)
Duplicates a scene item, copying all transform and crop info.
- GetCanvasList(CancellationToken)
Gets an array of canvases in OBS.
- GetCurrentPreviewScene(CancellationToken)
Gets the current preview scene.
- GetCurrentProgramScene(CancellationToken)
Gets the current program scene.
- GetCurrentSceneTransition(CancellationToken)
Gets information about the current scene transition.
- GetCurrentSceneTransitionCursor(CancellationToken)
Gets the cursor position of the current scene transition.
- GetGeometry(int, int, int, int, int, bool, bool, int)
Creates a Qt Base64 encoded string with Size/Position data for a windowed projector.
- GetGroupList(CancellationToken)
Gets an array of all groups in OBS.
- GetGroupSceneItemList(SceneRef, Guid?, CancellationToken)
Basically GetSceneItemList, but for groups.
- GetHotkeyList(CancellationToken)
Gets an array of all hotkey names in OBS.
- GetInputAudioBalance(InputRef, CancellationToken)
Gets the audio balance of an input.
- GetInputAudioMonitorType(InputRef, CancellationToken)
Gets the audio monitor type of an input.
- GetInputAudioSyncOffset(InputRef, CancellationToken)
Gets the audio sync offset of an input.
- GetInputAudioTracks(InputRef, CancellationToken)
Gets the enable state of all audio tracks of an input.
- GetInputDefaultSettings(string, CancellationToken)
Gets the default settings for an input kind.
- GetInputDeinterlaceFieldOrder(InputRef, CancellationToken)
Gets the deinterlace field order of an input.
- GetInputDeinterlaceMode(InputRef, CancellationToken)
Gets the deinterlace mode of an input.
- GetInputKindList(bool?, CancellationToken)
Gets an array of all available input kinds in OBS.
- GetInputList(string?, CancellationToken)
Gets an array of all inputs in OBS.
- GetInputMute(InputRef, CancellationToken)
Gets the audio mute state of an input.
- GetInputPropertiesListPropertyItems(InputRef, string, CancellationToken)
Gets the items of a list property from an input's properties.
- GetInputSettings(InputRef, CancellationToken)
Gets the settings of an input.
- GetInputVolume(InputRef, CancellationToken)
Gets the current volume setting of an input.
- GetLastReplayBufferReplay(CancellationToken)
Gets the filename of the last replay buffer save file.
- GetMediaInputStatus(InputRef, CancellationToken)
Gets the status of a media input.
- GetMonitorList(CancellationToken)
Gets a list of connected monitors and information about them.
- GetOutputList(CancellationToken)
Gets the list of available outputs.
- GetOutputSettings(string, CancellationToken)
Gets the settings of an output.
- GetOutputStatus(string, CancellationToken)
Gets the status of an output.
- GetPersistentData(Realm, string, CancellationToken)
Gets the value of a "slot" from the selected persistent data realm.
- GetProfileList(CancellationToken)
Gets an array of all profiles.
- GetProfileParameter(string, string, CancellationToken)
Gets a parameter from the current profile's configuration.
- GetRecordDirectory(CancellationToken)
Gets the current directory that the record output is set to.
- GetRecordStatus(CancellationToken)
Gets the status of the record output.
- GetReplayBufferStatus(CancellationToken)
Gets the status of the replay buffer output.
- GetSceneCollectionList(CancellationToken)
Gets an array of all scene collections.
- GetSceneItemBlendMode(SceneRef, int, Guid?, CancellationToken)
Gets the blend mode of a scene item.
- GetSceneItemEnabled(SceneRef, int, Guid?, CancellationToken)
Gets the enable state of a scene item.
- GetSceneItemId(SceneRef, string, int?, Guid?, CancellationToken)
Searches a scene for a source, and returns its id.
- GetSceneItemIndex(SceneRef, int, Guid?, CancellationToken)
Gets the index position of a scene item in a scene.
- GetSceneItemList(SceneRef, Guid?, CancellationToken)
Gets a list of all scene items in a scene.
- GetSceneItemLocked(SceneRef, int, Guid?, CancellationToken)
Gets the lock state of a scene item.
- GetSceneItemSource(SceneRef, int, Guid?, CancellationToken)
Gets the source associated with a scene item.
- GetSceneItemTransform(SceneRef, int, Guid?, CancellationToken)
Gets the transform and crop info of a scene item.
- GetSceneList(Guid?, CancellationToken)
Gets an array of scenes in OBS.
- GetSceneSceneTransitionOverride(SceneRef, Guid?, CancellationToken)
Gets the scene transition overridden for a scene.
- GetSceneTransitionList(CancellationToken)
Gets an array of all scene transitions in OBS.
- GetSourceActive(SourceRef, Guid?, CancellationToken)
Gets the active and show state of a source.
- GetSourceFilter(SourceRef, string, Guid?, CancellationToken)
Gets the info for a specific source filter.
- GetSourceFilterDefaultSettings(string, CancellationToken)
Gets the default settings for a filter kind.
- GetSourceFilterKindList(CancellationToken)
Gets an array of all available source filter kinds.
- GetSourceFilterList(SourceRef, Guid?, CancellationToken)
Gets an array of all of a source's filters.
- GetSourceScreenshot(SourceRef, string, int?, int?, int?, Guid?, CancellationToken)
Gets a Base64-encoded screenshot of a source.
- GetSpecialInputs(CancellationToken)
Gets the names of all special inputs.
- GetStats(CancellationToken)
Gets statistics about OBS, obs-websocket, and the current session.
- GetStreamServiceSettings(CancellationToken)
Gets the current stream service settings (stream destination).
- GetStreamStatus(CancellationToken)
Gets the status of the stream output.
- GetStudioModeEnabled(CancellationToken)
Gets whether studio is enabled.
- GetTransitionKindList(CancellationToken)
Gets an array of all available transition kinds.
- GetVersion(CancellationToken)
Gets data about the current plugin and RPC version.
- GetVideoSettings(CancellationToken)
Gets the current video settings.
- GetVirtualCamStatus(CancellationToken)
Gets the status of the virtualcam output.
- OffsetMediaInputCursor(InputRef, int, CancellationToken)
Offsets the current cursor position of a media input by the specified value.
- OpenInputFiltersDialog(InputRef, CancellationToken)
Opens the filters dialog of an input.
- OpenInputInteractDialog(InputRef, CancellationToken)
Opens the interact dialog of an input.
- OpenInputPropertiesDialog(InputRef, CancellationToken)
Opens the properties dialog of an input.
- OpenSourceProjector(SourceRef, int?, string?, Guid?, CancellationToken)
Opens a projector for a source.
- OpenSourceProjectorOnMonitor(SourceRef, int, Guid?, CancellationToken)
Opens a projector for a source on a monitor.
- OpenSourceProjectorWindow(SourceRef, string, Guid?, CancellationToken)
Opens a windowed projector for a source.
- OpenVideoMixProjector(MixType, int?, string?, CancellationToken)
Opens a projector for a specific output video mix.
- OpenVideoMixProjectorOnMonitor(MixType, int, CancellationToken)
Opens a projector for a specific output video mix on a monitor.
- OpenVideoMixProjectorWindow(MixType, string, CancellationToken)
Opens a windowed projector for a specific output video mix.
- PauseRecord(CancellationToken)
Pauses the record output.
- PressInputPropertiesButton(InputRef, string, CancellationToken)
Presses a button in the properties of an input.
- ReidentifyAsync(EventSubscriptions, CancellationToken)
Sends a Reidentify request to OBS Studio, typically to subscribe to a different set of events.
- RemoveInput(InputRef, CancellationToken)
Removes an existing input.
- RemoveProfile(string, CancellationToken)
Removes a profile. If the current profile is chosen, it will change to a different profile first.
- RemoveScene(SceneRef, Guid?, CancellationToken)
Removes a scene from OBS.
- RemoveSceneItem(SceneRef, int, Guid?, CancellationToken)
Removes a scene item from a scene.
- RemoveSourceFilter(SourceRef, string, Guid?, CancellationToken)
Removes a filter from a source.
- ResumeRecord(CancellationToken)
Resumes the record output.
- SaveReplayBuffer(CancellationToken)
Saves the contents of the replay buffer output.
- SaveSourceScreenshot(SourceRef, string, string, int?, int?, int?, Guid?, CancellationToken)
Saves a screenshot of a source to the filesystem.
- SendRequestBatchAsync(RequestBatchMessage, int?, CancellationToken)
Sends a Batch Request.
- SendStreamCaption(string, CancellationToken)
Sends CEA-608 caption text over the stream output.
- SetCurrentPreviewScene(SceneRef, CancellationToken)
Sets the current preview scene.
- SetCurrentProfile(string, CancellationToken)
Switches to a profile.
- SetCurrentProgramScene(SceneRef, CancellationToken)
Sets the current program scene.
- SetCurrentSceneCollection(string, CancellationToken)
Switches to a scene collection.
- SetCurrentSceneTransition(string, CancellationToken)
Sets the current scene transition.
- SetCurrentSceneTransitionDuration(float, CancellationToken)
Sets the duration of the current scene transition, if it is not fixed.
- SetCurrentSceneTransitionSettings(Dictionary<string, object>, bool?, CancellationToken)
Sets the settings of the current scene transition.
- SetInputAudioBalance(InputRef, float, CancellationToken)
Sets the audio balance of an input.
- SetInputAudioMonitorType(InputRef, MonitorType, CancellationToken)
Sets the audio monitor type of an input.
- SetInputAudioSyncOffset(InputRef, int, CancellationToken)
Sets the audio sync offset of an input.
- SetInputAudioTracks(InputRef, AudioTracks, CancellationToken)
Sets the enable state of audio tracks of an input.
- SetInputDeinterlaceFieldOrder(InputRef, string, CancellationToken)
Sets the deinterlace field order of an input.
- SetInputDeinterlaceMode(InputRef, DeinterlaceMode, CancellationToken)
Sets the deinterlace mode of an input.
- SetInputMute(InputRef, bool, CancellationToken)
Sets the audio mute state of an input.
- SetInputName(InputRef, string, CancellationToken)
Sets the name of an input (rename).
- SetInputSettings(InputRef, Dictionary<string, object>, bool?, CancellationToken)
Sets the settings of an input.
- SetInputVolume(InputRef, float?, float?, CancellationToken)
Sets the volume setting of an input.
- SetInputVolumeDb(InputRef, float, CancellationToken)
Sets the volume setting of an input, in dB.
- SetInputVolumeMul(InputRef, float, CancellationToken)
Sets the volume setting of an input, in mul.
- SetMediaInputCursor(InputRef, int, CancellationToken)
Sets the cursor position of a media input.
- SetOutputSettings(string, Dictionary<string, object>, CancellationToken)
Sets the settings of an output.
- SetPersistentData(Realm, string, object, CancellationToken)
Sets the value of a "slot" from the selected persistent data realm.
- SetProfileParameter(string, string, string?, CancellationToken)
Sets the value of a parameter in the current profile's configuration.
- SetRecordDirectory(string, CancellationToken)
Sets the current directory that the record output writes files to.
- SetSceneItemBlendMode(SceneRef, int, BlendMode, Guid?, CancellationToken)
Sets the blend mode of a scene item.
- SetSceneItemEnabled(SceneRef, int, bool, Guid?, CancellationToken)
Sets the enable state of a scene item.
- SetSceneItemIndex(SceneRef, int, int, Guid?, CancellationToken)
Sets the index position of a scene item in a scene.
- SetSceneItemLocked(SceneRef, int, bool, Guid?, CancellationToken)
Sets the lock state of a scene item.
- SetSceneItemTransform(SceneRef, int, SceneItemTransformUpdate, Guid?, CancellationToken)
Sets the transform and crop info of a scene item.
- SetSceneName(SceneRef, string, Guid?, CancellationToken)
Sets the name of a scene (rename).
- SetSceneSceneTransitionOverride(SceneRef, string?, int?, Guid?, CancellationToken)
Sets the scene transition overridden for a scene.
- SetSourceFilterEnabled(SourceRef, string, bool, Guid?, CancellationToken)
Sets the enable state of a source filter.
- SetSourceFilterIndex(SourceRef, string, int, Guid?, CancellationToken)
Sets the index position of a filter on a source.
- SetSourceFilterName(SourceRef, string, string, Guid?, CancellationToken)
Sets the name of a source filter (rename).
- SetSourceFilterSettings(SourceRef, string, Dictionary<string, object>, bool?, Guid?, CancellationToken)
Sets the settings of a source filter.
- SetStreamServiceSettings(string, object, CancellationToken)
Sets the current stream service settings (stream destination).
- SetStudioModeEnabled(bool, CancellationToken)
Enables or disables studio mode.
- SetTBarPosition(float, bool?, CancellationToken)
Sets the position of the TBar.
- SetVideoSettings(float?, float?, int?, int?, int?, int?, CancellationToken)
Sets the current video settings.
- SplitRecordFile(CancellationToken)
Splits the current file being recorded into a new file.
- StartOutput(string, CancellationToken)
Starts an output.
- StartRecord(CancellationToken)
Starts the record output.
- StartReplayBuffer(CancellationToken)
Starts the replay buffer output.
- StartStream(CancellationToken)
Starts the stream output.
- StartVirtualCam(CancellationToken)
Starts the virtualcam output.
- StopOutput(string, CancellationToken)
Stops an output.
- StopRecord(CancellationToken)
Stops the record output.
- StopReplayBuffer(CancellationToken)
Stops the replay buffer output.
- StopStream(CancellationToken)
Stops the stream output.
- StopVirtualCam(CancellationToken)
Stops the virtualcam output.
- ToggleInputMute(InputRef, CancellationToken)
Toggles the audio mute state of an input.
- ToggleOutput(string, CancellationToken)
Toggles the status of an output.
- ToggleRecord(CancellationToken)
Toggles the status of the record output.
- ToggleRecordPause(CancellationToken)
Toggles pause on the record output.
- ToggleReplayBuffer(CancellationToken)
Toggles the state of the replay buffer output.
- ToggleStream(CancellationToken)
Toggles the status of the stream output.
- ToggleVirtualCam(CancellationToken)
Toggles the state of the virtualcam output.
- TriggerHotkeyByKeySequence(ObsKey?, KeyModifier?, CancellationToken)
Triggers a hotkey using a sequence of keys.
- TriggerHotkeyByName(string, string?, CancellationToken)
Triggers a hotkey using its name. See
GetHotkeyList.
- TriggerMediaInputAction(InputRef, ObsMediaInputAction, CancellationToken)
Triggers an action on a media input.
- TriggerStudioModeTransition(CancellationToken)
Triggers the current scene transition. Same functionality as the
Transitionbutton in studio mode.
Events
- CanvasCreated
A new canvas has been created.
- CanvasNameChanged
The name of a canvas has changed.
- CanvasRemoved
A canvas has been removed.
- ConnectionClosed
Occurs when the connection with OBS Studio is closed, for whatever reason, a call of Disconnect() included.
- CurrentPreviewSceneChanged
The current preview scene has changed.
- CurrentProfileChanged
The current profile has changed.
- CurrentProfileChanging
The current profile has begun changing.
- CurrentProgramSceneChanged
The current program scene has changed.
- CurrentSceneCollectionChanged
The current scene collection has changed. Note: If polling has been paused during
CurrentSceneCollectionChanging, this is the que to restart polling.
- CurrentSceneCollectionChanging
The current scene collection has begun changing. Note: We recommend using this event to trigger a pause of all polling requests, as performing any requests during a scene collection change is considered undefined behavior and can cause crashes!
- CurrentSceneTransitionChanged
The current scene transition has changed.
- CurrentSceneTransitionDurationChanged
The current scene transition duration has changed.
- CustomEvent
Custom event emitted by
BroadcastCustomEvent.
- ExitStarted
OBS has begun the shutdown process.
- InputActiveStateChanged
An input's active state has changed. When an input is active, it means it's being shown by the program feed.
- InputAudioBalanceChanged
The audio balance value of an input has changed.
- InputAudioMonitorTypeChanged
The monitor type of an input has changed. Available types are: -
OBS_MONITORING_TYPE_NONE-OBS_MONITORING_TYPE_MONITOR_ONLY-OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT.
- InputAudioSyncOffsetChanged
The sync offset of an input has changed.
- InputAudioTracksChanged
The audio tracks of an input have changed.
- InputCreated
An input has been created.
- InputMuteStateChanged
An input's mute state has changed.
- InputNameChanged
The name of an input has changed.
- InputRemoved
An input has been removed.
- InputSettingsChanged
An input's settings have changed (been updated). Note: On some inputs, changing values in the properties dialog will cause an immediate update. Pressing the "Cancel" button will revert the settings, resulting in another event being fired.
- InputShowStateChanged
An input's show state has changed. When an input is showing, it means it's being shown by the preview or a dialog.
- InputVolumeChanged
An input's volume level has changed.
- InputVolumeMeters
A high-volume event providing volume levels of all active inputs every 50 milliseconds.
- MediaInputActionTriggered
An action has been performed on an input.
- MediaInputPlaybackEnded
A media input has finished playing.
- MediaInputPlaybackStarted
A media input has started playing.
- ProfileListChanged
The profile list has changed.
- PropertyChanged
Occurs when an important property changes, ConnectionState for instance.
- RecordFileChanged
The record output has started writing to a new file. For example, when a file split happens.
- RecordStateChanged
The state of the record output has changed.
- ReplayBufferSaved
The replay buffer has been saved.
- ReplayBufferStateChanged
The state of the replay buffer output has changed.
- SceneCollectionListChanged
The scene collection list has changed.
- SceneCreated
A new scene has been created.
- SceneItemCreated
A scene item has been created.
- SceneItemEnableStateChanged
A scene item's enable state has changed.
- SceneItemListReindexed
A scene's item list has been reindexed.
- SceneItemLockStateChanged
A scene item's lock state has changed.
- SceneItemRemoved
A scene item has been removed. This event is not emitted when the scene the item is in is removed.
- SceneItemSelected
A scene item has been selected in the Ui.
- SceneItemTransformChanged
The transform/crop of a scene item has changed.
- SceneListChanged
The list of scenes has changed. TODO: Make OBS fire this event when scenes are reordered.
- SceneNameChanged
The name of a scene has changed.
- SceneRemoved
A scene has been removed.
- SceneTransitionEnded
A scene transition has completed fully. Note: Does not appear to trigger when the transition is interrupted by the user.
- SceneTransitionStarted
A scene transition has started.
- SceneTransitionVideoEnded
A scene transition's video has completed fully. Useful for stinger transitions to tell when the video actually ends.
SceneTransitionEndedonly signifies the cut point, not the completion of transition playback. Note: Appears to be called by every transition, regardless of relevance.
- ScreenshotSaved
A screenshot has been saved. Note: Triggered for the screenshot feature available in
Settings -> Hotkeys -> Screenshot OutputONLY. Applications usingGet/SaveSourceScreenshotshould implement aCustomEventif this kind of inter-client communication is desired.
- SessionBytesReceivedChanged
Occurs when the number of bytes received changes in the current session.
- SessionBytesSentChanged
Occurs when the number of bytes sent changes in the current session.
- SessionMessagesReceivedChanged
Occurs when the number of messages received changes in the current session.
- SessionMessagesSentChanged
Occurs when the number of messages sent changes in the current session.
- SourceFilterCreated
A filter has been added to a source.
- SourceFilterEnableStateChanged
A source filter's enable state has changed.
- SourceFilterListReindexed
A source's filter list has been reindexed.
- SourceFilterNameChanged
The name of a source filter has changed.
- SourceFilterRemoved
A filter has been removed from a source.
- SourceFilterSettingsChanged
An source filter's settings have changed (been updated).
- StreamStateChanged
The state of the stream output has changed.
- StudioModeStateChanged
Studio mode has been enabled or disabled.
- TotalBytesReceivedChanged
Occurs when the number of bytes received changes.
- TotalBytesSentChanged
Occurs when the number of bytes sent changes.
- TotalMessagesReceivedChanged
Occurs when the number of messages received changes.
- TotalMessagesSentChanged
Occurs when the number of messages sent changes.
- VendorEvent
An event has been emitted from 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.
- VirtualcamStateChanged
The state of the virtualcam output has changed.