class Obsctl::OBS::Client

Overview

obs-websocket 5.x client used by the server-owned OBS supervisor.

Defined in:

obsctl/obs/client.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(config : Config::Config, event_subscriptions : Int32 | Nil = nil) #

[View source]

Instance Method Detail

def audio_snapshot : Array(State::AudioState) #

Fetches only the audio input list for targeted state updates.


[View source]
def close : Nil #

Closes the WebSocket and marks this client as no longer identified.


[View source]
def connect : Nil #

Opens the WebSocket, performs Hello/Identify/Identified, and starts the reader fiber used for events and request responses.


[View source]
def connected? : Bool #

Returns true after Identify completes and the underlying socket is open.


[View source]
def current_scene : String | Nil #

Returns the current OBS program scene name when available.


[View source]
def events : Channel(Obsctl::OBS::Protocol::Event) #

Channel of parsed OBS events from opcode 5 frames.


[View source]
def input_muted(name : String) : Bool | Nil #

Returns mute state for an OBS input by exact OBS input name.


[View source]
def input_names : Array(String) #

Returns current OBS input names.


[View source]
def input_volume(name : String) : NamedTuple(mul: Float64 | Nil, db: Float64 | Nil, percent: Int32 | Nil) #

Returns OBS input volume in multiplier, dB, and user-facing percent.


[View source]
def mute(name : String, muted : Bool) : Nil #

Sets mute state for an OBS input by exact OBS input name.


[View source]
def output_state : State::OutputState #

[View source]
def pause_record : Nil #

[View source]
def profiles : NamedTuple(current: String | Nil, names: Array(String)) #

[View source]
def record_status : State::RecordStatus #

Returns the full record status, including pause state and timecode.


[View source]
def request(request_type : String, data : JSON::Any | Nil = nil) : Protocol::Response #

Sends a typed obs-websocket request frame and waits for the matching request ID response or timeout.


[View source]
def resume_record : Nil #

[View source]
def scene_collections : NamedTuple(current: String | Nil, names: Array(String)) #

[View source]
def scene_names : Array(String) #

Returns the current OBS scene names in OBS order.


[View source]
def scene_snapshot : NamedTuple(current_scene: String | Nil, scenes: Array(State::SceneState)) #

Fetches only the scene list and current scene for targeted state updates.


[View source]
def set_profile(name : String) : Nil #

[View source]
def set_scene(name : String) : Nil #

Changes the current OBS program scene by exact OBS scene name.


[View source]
def set_scene_collection(name : String) : Nil #

[View source]
def set_volume(name : String, percent : Int32) : Nil #

Sets OBS input volume using a user-facing 0-100 percentage.


[View source]
def snapshot : State::ObsSnapshot #

Fetches a full state snapshot for publication to local IPC clients.


[View source]
def start_record : Nil #

Starts recording. OBS returns no data, so the caller re-reads status.


[View source]
def stats : State::ObsStats #

[View source]
def stop_record : String | Nil #

Stops recording and returns the written file path when OBS reports one.


[View source]
def telemetry_sample : TelemetrySample #

Fetches the performance and output counters used by the daemon's periodic telemetry poller. OBS exposes bytes rather than bitrate, so the supervisor derives kbit/s from consecutive samples.


[View source]
def terminal_error : Domain::ConnectionFailed | Nil #

Returns the safe terminal connection error that closed this client.


[View source]
def toggle_mute(name : String) : Nil #

Toggles mute state for an OBS input by exact OBS input name.


[View source]
def toggle_record : Bool | Nil #

[View source]
def toggle_stream : Bool | Nil #

[View source]
def version : JSON::Any #

Fetches OBS and obs-websocket version metadata.


[View source]
def wait_for_close(timeout : Time::Span) : Domain::ConnectionFailed | Nil #

Waits for the WebSocket reader to observe a terminal close or protocol error, returning the same sanitized error exposed by #terminal_error.


[View source]