mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2025-04-03 20:03:46 +01:00
Compare commits
8 Commits
799ae52b02
...
856b7b5a5b
Author | SHA1 | Date | |
---|---|---|---|
856b7b5a5b | |||
af85d8b9ab | |||
5f08b97759 | |||
73ae24eb4b | |||
153f35e742 | |||
17dcaa18d8 | |||
955b00571a | |||
d9b054b108 |
9
.gitignore
vendored
9
.gitignore
vendored
@ -46,7 +46,8 @@ build-iPhoneSimulator/
|
||||
# for a library or gem, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# Gemfile.lock
|
||||
# .ruby-version
|
||||
.ruby-version
|
||||
.ruby_version
|
||||
# .ruby-gemset
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
@ -56,6 +57,8 @@ build-iPhoneSimulator/
|
||||
# .rubocop-https?--*
|
||||
|
||||
# config
|
||||
obs.toml
|
||||
obs.yml
|
||||
# quick test
|
||||
quick.rb
|
||||
quick.rb
|
||||
|
||||
.vscode/
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"singleQuote": false,
|
||||
"tabWidth": 2
|
||||
}
|
46
Gemfile.lock
46
Gemfile.lock
@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
obsws (0.1.3)
|
||||
obsws (0.2.0)
|
||||
observer (~> 0.1.1)
|
||||
waitutil (~> 0.2.1)
|
||||
websocket-driver (~> 0.7.5)
|
||||
@ -9,10 +9,50 @@ PATH
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
ast (2.4.2)
|
||||
json (2.6.3)
|
||||
language_server-protocol (3.17.0.3)
|
||||
lint_roller (1.1.0)
|
||||
minitest (5.16.3)
|
||||
observer (0.1.1)
|
||||
perfect_toml (0.9.0)
|
||||
parallel (1.23.0)
|
||||
parser (3.2.2.3)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
racc (1.7.1)
|
||||
rainbow (3.1.1)
|
||||
rake (11.3.0)
|
||||
regexp_parser (2.8.1)
|
||||
rexml (3.2.5)
|
||||
rubocop (1.52.1)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.2.2.3)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.28.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.29.0)
|
||||
parser (>= 3.2.1.0)
|
||||
rubocop-performance (1.18.0)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
ruby-progressbar (1.13.0)
|
||||
standard (1.30.1)
|
||||
language_server-protocol (~> 3.17.0.2)
|
||||
lint_roller (~> 1.0)
|
||||
rubocop (~> 1.52.0)
|
||||
standard-custom (~> 1.0.0)
|
||||
standard-performance (~> 1.1.0)
|
||||
standard-custom (1.0.2)
|
||||
lint_roller (~> 1.0)
|
||||
rubocop (~> 1.50)
|
||||
standard-performance (1.1.2)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop-performance (~> 1.18.0)
|
||||
unicode-display_width (2.4.2)
|
||||
waitutil (0.2.1)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
@ -24,8 +64,8 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
minitest (~> 5.16, >= 5.16.3)
|
||||
obsws!
|
||||
perfect_toml (~> 0.9.0)
|
||||
rake (~> 11.2, >= 11.2.2)
|
||||
standard (~> 1.30)
|
||||
|
||||
BUNDLED WITH
|
||||
2.3.22
|
||||
|
29
README.md
29
README.md
@ -1,15 +1,15 @@
|
||||
[](https://badge.fury.io/rb/obsws)
|
||||
[](https://github.com/onyx-and-iris/obsws-ruby/blob/dev/LICENSE)
|
||||
[](https://github.com/prettier/plugin-ruby)
|
||||
[](https://github.com/standardrb/standard)
|
||||
|
||||
# A Ruby wrapper around OBS Studio WebSocket v5.0
|
||||
|
||||
## Requirements
|
||||
|
||||
- [OBS Studio](https://obsproject.com/)
|
||||
- [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0)
|
||||
- With the release of OBS Studio version 28, Websocket plugin is included by default. But it should be manually installed for earlier versions of OBS.
|
||||
- Ruby 3.0 or greater
|
||||
- [OBS Studio](https://obsproject.com/)
|
||||
- [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0)
|
||||
- With the release of OBS Studio version 28, Websocket plugin is included by default. But it should be manually installed for earlier versions of OBS.
|
||||
- Ruby 3.0 or greater
|
||||
|
||||
## Installation
|
||||
|
||||
@ -34,17 +34,12 @@ pass `host`, `port` and `password` as keyword arguments.
|
||||
require "obsws"
|
||||
|
||||
def main
|
||||
r_client =
|
||||
OBSWS::Requests::Client.new(
|
||||
host: "localhost",
|
||||
port: 4455,
|
||||
password: "strongpassword"
|
||||
)
|
||||
|
||||
r_client.run do
|
||||
# Toggle the mute state of your Mic input
|
||||
r_client.toggle_input_mute("Mic/Aux")
|
||||
end
|
||||
OBSWS::Requests::Client
|
||||
.new(host: "localhost", port: 4455, password: "strongpassword")
|
||||
.run do |client|
|
||||
# Toggle the mute state of your Mic input
|
||||
client.toggle_input_mute("Mic/Aux")
|
||||
end
|
||||
end
|
||||
|
||||
main if $0 == __FILE__
|
||||
@ -140,4 +135,4 @@ bundle exec rake -v
|
||||
|
||||
For the full documentation:
|
||||
|
||||
- [OBS Websocket SDK](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#obs-websocket-501-protocol)
|
||||
- [OBS Websocket SDK](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#obs-websocket-501-protocol)
|
||||
|
2
Rakefile
2
Rakefile
@ -1,6 +1,6 @@
|
||||
require "minitest/test_task"
|
||||
|
||||
HERE = File.expand_path File.dirname(__FILE__)
|
||||
HERE = __dir__
|
||||
|
||||
Minitest::TestTask.create(:test) do |t|
|
||||
t.libs << "test"
|
||||
|
@ -5,5 +5,3 @@ source "https://rubygems.org"
|
||||
# gem "rails"
|
||||
|
||||
gem "obsws", path: "../.."
|
||||
|
||||
gem "perfect_toml", "~> 0.9.0"
|
||||
|
@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: ../..
|
||||
specs:
|
||||
obsws (0.1.0)
|
||||
obsws (0.1.3)
|
||||
observer (~> 0.1.1)
|
||||
waitutil (~> 0.2.1)
|
||||
websocket-driver (~> 0.7.5)
|
||||
@ -10,7 +10,6 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
observer (0.1.1)
|
||||
perfect_toml (0.9.0)
|
||||
waitutil (0.2.1)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
@ -21,7 +20,6 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
obsws!
|
||||
perfect_toml (~> 0.9.0)
|
||||
|
||||
BUNDLED WITH
|
||||
2.3.22
|
||||
|
@ -1,9 +1,9 @@
|
||||
require "obsws"
|
||||
require "perfect_toml"
|
||||
require "yaml"
|
||||
|
||||
OBSWS::LOGGER.info!
|
||||
|
||||
class Observer
|
||||
class Main
|
||||
attr_reader :running
|
||||
|
||||
def initialize(**kwargs)
|
||||
@ -15,6 +15,10 @@ class Observer
|
||||
@running = true
|
||||
end
|
||||
|
||||
def run
|
||||
sleep(0.1) while running
|
||||
end
|
||||
|
||||
def info
|
||||
resp = @r_client.get_version
|
||||
[
|
||||
@ -45,14 +49,8 @@ class Observer
|
||||
end
|
||||
end
|
||||
|
||||
def conn_from_toml
|
||||
PerfectTOML.load_file("obs.toml", symbolize_names: true)[:connection]
|
||||
def conn_from_yaml
|
||||
YAML.load_file("obs.yml", symbolize_names: true)[:connection]
|
||||
end
|
||||
|
||||
def main
|
||||
o = Observer.new(**conn_from_toml)
|
||||
|
||||
sleep(0.1) while o.running
|
||||
end
|
||||
|
||||
main if $0 == __FILE__
|
||||
Main.new(**conn_from_yaml).run if $0 == __FILE__
|
||||
|
7
examples/levels/Gemfile
Normal file
7
examples/levels/Gemfile
Normal file
@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
# gem "rails"
|
||||
|
||||
gem "obsws", path: "../.."
|
25
examples/levels/Gemfile.lock
Normal file
25
examples/levels/Gemfile.lock
Normal file
@ -0,0 +1,25 @@
|
||||
PATH
|
||||
remote: ../..
|
||||
specs:
|
||||
obsws (0.1.3)
|
||||
observer (~> 0.1.1)
|
||||
waitutil (~> 0.2.1)
|
||||
websocket-driver (~> 0.7.5)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
observer (0.1.1)
|
||||
waitutil (0.2.1)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
|
||||
PLATFORMS
|
||||
x64-mingw-ucrt
|
||||
|
||||
DEPENDENCIES
|
||||
obsws!
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.15
|
@ -1,5 +1,5 @@
|
||||
require "obsws"
|
||||
require "perfect_toml"
|
||||
require "yaml"
|
||||
|
||||
OBSWS::LOGGER.info!
|
||||
DEVICE = "Desktop Audio"
|
||||
@ -10,44 +10,39 @@ module LevelTypes
|
||||
PREFADER = 2
|
||||
end
|
||||
|
||||
class Observer
|
||||
attr_reader :running
|
||||
|
||||
class Main
|
||||
def initialize(**kwargs)
|
||||
kwargs[:subs] = OBSWS::Events::SUBS::LOW_VOLUME | OBSWS::Events::SUBS::INPUTVOLUMEMETERS
|
||||
@e_client = OBSWS::Events::Client.new(**kwargs)
|
||||
subs = OBSWS::Events::SUBS::LOW_VOLUME | OBSWS::Events::SUBS::INPUTVOLUMEMETERS
|
||||
@e_client = OBSWS::Events::Client.new(subs:, **kwargs)
|
||||
@e_client.add_observer(self)
|
||||
end
|
||||
|
||||
|
||||
def run
|
||||
puts "press <Enter> to quit"
|
||||
exit if gets.chomp.empty?
|
||||
end
|
||||
|
||||
def on_input_mute_state_changed(data)
|
||||
"""An input's mute state has changed."""
|
||||
if data.input_name == DEVICE
|
||||
puts "#{DEVICE} mute toggled"
|
||||
end
|
||||
end
|
||||
|
||||
def on_input_volume_meters(data)
|
||||
def fget(x) = x > 0 ? (20 * Math.log(x, 10)).round(1) : -200.0
|
||||
fget = ->(x) { (x > 0) ? (20 * Math.log(x, 10)).round(1) : -200.0 }
|
||||
|
||||
data.inputs.each do |d|
|
||||
name = d[:inputName]
|
||||
if name == DEVICE && !d[:inputLevelsMul].empty?
|
||||
left, right = d[:inputLevelsMul]
|
||||
puts "#{name} [L: #{fget(left[LevelTypes::POSTFADER])}, R: #{fget(right[LevelTypes::POSTFADER])}]"
|
||||
puts "#{name} [L: #{fget.call(left[LevelTypes::POSTFADER])}, R: #{fget.call(right[LevelTypes::POSTFADER])}]"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def conn_from_toml
|
||||
PerfectTOML.load_file("obs.toml", symbolize_names: true)[:connection]
|
||||
def conn_from_yaml
|
||||
YAML.load_file("obs.yml", symbolize_names: true)[:connection]
|
||||
end
|
||||
|
||||
def main
|
||||
o = Observer.new(**conn_from_toml)
|
||||
|
||||
puts "press <Enter> to quit"
|
||||
loop { exit if gets.chomp.empty? }
|
||||
end
|
||||
|
||||
main if $0 == __FILE__
|
||||
Main.new(**conn_from_yaml).run if $0 == __FILE__
|
||||
|
@ -5,5 +5,3 @@ source "https://rubygems.org"
|
||||
# gem "rails"
|
||||
|
||||
gem "obsws", path: "../.."
|
||||
|
||||
gem "perfect_toml", "~> 0.9.0"
|
||||
|
@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: ../..
|
||||
specs:
|
||||
obsws (0.1.0)
|
||||
obsws (0.1.3)
|
||||
observer (~> 0.1.1)
|
||||
waitutil (~> 0.2.1)
|
||||
websocket-driver (~> 0.7.5)
|
||||
@ -10,7 +10,6 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
observer (0.1.1)
|
||||
perfect_toml (0.9.0)
|
||||
waitutil (0.2.1)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
@ -21,7 +20,6 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
obsws!
|
||||
perfect_toml (~> 0.9.0)
|
||||
|
||||
BUNDLED WITH
|
||||
2.3.22
|
||||
|
@ -1,19 +1,18 @@
|
||||
require "obsws"
|
||||
require "perfect_toml"
|
||||
require "yaml"
|
||||
|
||||
OBSWS::LOGGER.info!
|
||||
|
||||
def conn_from_toml
|
||||
PerfectTOML.load_file("obs.toml", symbolize_names: true)[:connection]
|
||||
def conn_from_yaml
|
||||
YAML.load_file("obs.yml", symbolize_names: true)[:connection]
|
||||
end
|
||||
|
||||
def main
|
||||
r_client = OBSWS::Requests::Client.new(**conn_from_toml)
|
||||
r_client.run do
|
||||
resp = r_client.get_scene_list
|
||||
resp.scenes.reverse.each do |s|
|
||||
puts "Switching to scene #{s[:sceneName]}"
|
||||
r_client.set_current_program_scene(s[:sceneName])
|
||||
OBSWS::Requests::Client.new(**conn_from_yaml).run do |client|
|
||||
resp = client.get_scene_list
|
||||
resp.scenes.reverse_each do |scene|
|
||||
puts "Switching to scene #{scene[:sceneName]}"
|
||||
client.set_current_program_scene(scene[:sceneName])
|
||||
sleep(0.5)
|
||||
end
|
||||
end
|
||||
|
@ -20,7 +20,7 @@ module OBSWS
|
||||
UI = 1 << 10
|
||||
|
||||
LOW_VOLUME = GENERAL | CONFIG | SCENES | INPUTS | TRANSITIONS | FILTERS | OUTPUTS |
|
||||
SCENEITEMS | MEDIAINPUTS | VENDORS | UI
|
||||
SCENEITEMS | MEDIAINPUTS | VENDORS | UI
|
||||
|
||||
INPUTVOLUMEMETERS = 1 << 16
|
||||
INPUTACTIVESTATECHANGED = 1 << 17
|
||||
@ -28,7 +28,7 @@ module OBSWS
|
||||
SCENEITEMTRANSFORMCHANGED = 1 << 19
|
||||
|
||||
HIGH_VOLUME = INPUTVOLUMEMETERS | INPUTACTIVESTATECHANGED | INPUTSHOWSTATECHANGED |
|
||||
SCENEITEMTRANSFORMCHANGED
|
||||
SCENEITEMTRANSFORMCHANGED
|
||||
|
||||
ALL = LOW_VOLUME | HIGH_VOLUME
|
||||
end
|
||||
@ -74,7 +74,7 @@ module OBSWS
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{self.class.name.split("::").last(2).join("::")}"
|
||||
self.class.name.split("::").last(2).join("::")
|
||||
end
|
||||
|
||||
def update(op_code, data)
|
||||
|
418
lib/obsws/req.rb
418
lib/obsws/req.rb
@ -16,15 +16,15 @@ module OBSWS
|
||||
@base_client = Base.new(**kwargs)
|
||||
LOGGER.info("#{self} succesfully identified with server")
|
||||
@base_client.add_observer(self)
|
||||
@response = { requestId: 0 }
|
||||
@response = {requestId: 0}
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{self.class.name.split("::").last(2).join("::")}"
|
||||
self.class.name.split("::").last(2).join("::")
|
||||
end
|
||||
|
||||
def run
|
||||
yield
|
||||
yield(self)
|
||||
ensure
|
||||
close
|
||||
WaitUtil.wait_for_condition(
|
||||
@ -63,34 +63,34 @@ module OBSWS
|
||||
end
|
||||
|
||||
def get_version
|
||||
resp = call("GetVersion")
|
||||
resp = call(:GetVersion)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_stats
|
||||
resp = call("GetStats")
|
||||
resp = call(:GetStats)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def broadcast_custom_event(data)
|
||||
call("BroadcastCustomEvent", data)
|
||||
call(:BroadcastCustomEvent, data)
|
||||
end
|
||||
|
||||
def call_vendor_request(name, type_, data = nil)
|
||||
payload = { vendorName: name, requestType: type_ }
|
||||
def call_vendor_request(vendor_name, request_type, data = nil)
|
||||
payload = {vendorName: vendor_name, requestType: request_type}
|
||||
payload[:requestData] = data if data
|
||||
resp = call("CallVendorRequest", payload)
|
||||
resp = call(:CallVendorRequest, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_hotkey_list
|
||||
resp = call("GetHotkeyList")
|
||||
resp = call(:GetHotkeyList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def trigger_hotkey_by_name(name)
|
||||
payload = { hotkeyName: name }
|
||||
call("TriggerHotkeyByName", payload)
|
||||
payload = {hotkeyName: name}
|
||||
call(:TriggerHotkeyByName, payload)
|
||||
end
|
||||
|
||||
def trigger_hotkey_by_key_sequence(
|
||||
@ -109,63 +109,63 @@ module OBSWS
|
||||
cmd: press_cmd
|
||||
}
|
||||
}
|
||||
call("TriggerHotkeyByKeySequence", payload)
|
||||
call(:TriggerHotkeyByKeySequence, payload)
|
||||
end
|
||||
|
||||
def sleep(sleep_millis = nil, sleep_frames = nil)
|
||||
payload = { sleepMillis: sleep_millis, sleepFrames: sleep_frames }
|
||||
call("Sleep", payload)
|
||||
payload = {sleepMillis: sleep_millis, sleepFrames: sleep_frames}
|
||||
call(:Sleep, payload)
|
||||
end
|
||||
|
||||
def get_persistent_data(realm, slot_name)
|
||||
payload = { realm: realm, slotName: slot_name }
|
||||
resp = call("GetPersistentData", payload)
|
||||
payload = {realm: realm, slotName: slot_name}
|
||||
resp = call(:GetPersistentData, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_persistent_data(realm, slot_name, slot_value)
|
||||
payload = { realm: realm, slotName: slot_name, slotValue: slot_value }
|
||||
call("SetPersistentData", payload)
|
||||
payload = {realm: realm, slotName: slot_name, slotValue: slot_value}
|
||||
call(:SetPersistentData, payload)
|
||||
end
|
||||
|
||||
def get_scene_collection_list
|
||||
resp = call("GetSceneCollectionList")
|
||||
resp = call(:GetSceneCollectionList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_current_scene_collection(name)
|
||||
payload = { sceneCollectionName: name }
|
||||
call("SetCurrentSceneCollection", payload)
|
||||
payload = {sceneCollectionName: name}
|
||||
call(:SetCurrentSceneCollection, payload)
|
||||
end
|
||||
|
||||
def create_scene_collection(name)
|
||||
payload = { sceneCollectionName: name }
|
||||
call("CreateSceneCollection", payload)
|
||||
payload = {sceneCollectionName: name}
|
||||
call(:CreateSceneCollection, payload)
|
||||
end
|
||||
|
||||
def get_profile_list
|
||||
resp = call("GetProfileList")
|
||||
resp = call(:GetProfileList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_current_profile(name)
|
||||
payload = { profileName: name }
|
||||
call("SetCurrentProfile", payload)
|
||||
payload = {profileName: name}
|
||||
call(:SetCurrentProfile, payload)
|
||||
end
|
||||
|
||||
def create_profile(name)
|
||||
payload = { profileName: name }
|
||||
call("CreateProfile", payload)
|
||||
payload = {profileName: name}
|
||||
call(:CreateProfile, payload)
|
||||
end
|
||||
|
||||
def remove_profile(name)
|
||||
payload = { profileName: name }
|
||||
call("RemoveProfile", payload)
|
||||
payload = {profileName: name}
|
||||
call(:RemoveProfile, payload)
|
||||
end
|
||||
|
||||
def get_profile_parameter(category, name)
|
||||
payload = { parameterCategory: category, parameterName: name }
|
||||
resp = call("GetProfileParameter", payload)
|
||||
payload = {parameterCategory: category, parameterName: name}
|
||||
resp = call(:GetProfileParameter, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -175,11 +175,11 @@ module OBSWS
|
||||
parameterName: name,
|
||||
parameterValue: value
|
||||
}
|
||||
call("SetProfileParameter", payload)
|
||||
call(:SetProfileParameter, payload)
|
||||
end
|
||||
|
||||
def get_video_settings
|
||||
resp = call("GetVideoSettings")
|
||||
resp = call(:GetVideoSettings)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -199,11 +199,11 @@ module OBSWS
|
||||
outputWidth: out_width,
|
||||
outputHeight: out_height
|
||||
}
|
||||
call("SetVideoSettings", payload)
|
||||
call(:SetVideoSettings, payload)
|
||||
end
|
||||
|
||||
def get_stream_service_settings
|
||||
resp = call("GetStreamServiceSettings")
|
||||
resp = call(:GetStreamServiceSettings)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -212,17 +212,17 @@ module OBSWS
|
||||
streamServiceType: ss_type,
|
||||
streamServiceSettings: ss_settings
|
||||
}
|
||||
call("SetStreamServiceSettings", payload)
|
||||
call(:SetStreamServiceSettings, payload)
|
||||
end
|
||||
|
||||
def get_record_directory
|
||||
resp = call("GetRecordDirectory")
|
||||
resp = call(:GetRecordDirectory)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_source_active(name)
|
||||
payload = { sourceName: name }
|
||||
resp = call("GetSourceActive", payload)
|
||||
payload = {sourceName: name}
|
||||
resp = call(:GetSourceActive, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -234,7 +234,7 @@ module OBSWS
|
||||
imageHeight: height,
|
||||
imageCompressionQuality: quality
|
||||
}
|
||||
resp = call("GetSourceScreenshot", payload)
|
||||
resp = call(:GetSourceScreenshot, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -254,58 +254,58 @@ module OBSWS
|
||||
imageHeight: height,
|
||||
imageCompressionQuality: quality
|
||||
}
|
||||
resp = call("SaveSourceScreenshot", payload)
|
||||
resp = call(:SaveSourceScreenshot, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_scene_list
|
||||
resp = call("GetSceneList")
|
||||
resp = call(:GetSceneList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_group_list
|
||||
resp = call("GetGroupList")
|
||||
resp = call(:GetGroupList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_current_program_scene
|
||||
resp = call("GetCurrentProgramScene")
|
||||
resp = call(:GetCurrentProgramScene)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_current_program_scene(name)
|
||||
payload = { sceneName: name }
|
||||
call("SetCurrentProgramScene", payload)
|
||||
payload = {sceneName: name}
|
||||
call(:SetCurrentProgramScene, payload)
|
||||
end
|
||||
|
||||
def get_current_preview_scene
|
||||
resp = call("GetCurrentPreviewScene")
|
||||
resp = call(:GetCurrentPreviewScene)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_current_preview_scene(name)
|
||||
payload = { sceneName: name }
|
||||
call("SetCurrentPreviewScene", payload)
|
||||
payload = {sceneName: name}
|
||||
call(:SetCurrentPreviewScene, payload)
|
||||
end
|
||||
|
||||
def create_scene(name)
|
||||
payload = { sceneName: name }
|
||||
call("CreateScene", payload)
|
||||
payload = {sceneName: name}
|
||||
call(:CreateScene, payload)
|
||||
end
|
||||
|
||||
def remove_scene(name)
|
||||
payload = { sceneName: name }
|
||||
call("RemoveScene", payload)
|
||||
payload = {sceneName: name}
|
||||
call(:RemoveScene, payload)
|
||||
end
|
||||
|
||||
def set_scene_name(old_name, new_name)
|
||||
payload = { sceneName: old_name, newSceneName: new_name }
|
||||
call("SetSceneName", payload)
|
||||
payload = {sceneName: old_name, newSceneName: new_name}
|
||||
call(:SetSceneName, payload)
|
||||
end
|
||||
|
||||
def get_scene_scene_transition_override(name)
|
||||
payload = { sceneName: name }
|
||||
resp = call("GetSceneSceneTransitionOverride", payload)
|
||||
payload = {sceneName: name}
|
||||
resp = call(:GetSceneSceneTransitionOverride, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -315,23 +315,23 @@ module OBSWS
|
||||
transitionName: tr_name,
|
||||
transitionDuration: tr_duration
|
||||
}
|
||||
call("SetSceneSceneTransitionOverride", payload)
|
||||
call(:SetSceneSceneTransitionOverride, payload)
|
||||
end
|
||||
|
||||
def get_input_list(kind = nil)
|
||||
payload = { inputKind: kind }
|
||||
resp = call("GetInputList", payload)
|
||||
payload = {inputKind: kind}
|
||||
resp = call(:GetInputList, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_input_kind_list(unversioned)
|
||||
payload = { unversioned: unversioned }
|
||||
resp = call("GetInputKindList", payload)
|
||||
payload = {unversioned: unversioned}
|
||||
resp = call(:GetInputKindList, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_special_inputs
|
||||
resp = call("GetSpecialInputs")
|
||||
resp = call(:GetSpecialInputs)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -349,57 +349,57 @@ module OBSWS
|
||||
inputSettings: input_settings,
|
||||
sceneItemEnabled: scene_item_enabled
|
||||
}
|
||||
resp = call("CreateInput", payload)
|
||||
resp = call(:CreateInput, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def remove_input(name)
|
||||
payload = { inputName: name }
|
||||
call("RemoveInput", payload)
|
||||
payload = {inputName: name}
|
||||
call(:RemoveInput, payload)
|
||||
end
|
||||
|
||||
def set_input_name(old_name, new_name)
|
||||
payload = { inputName: old_name, newInputName: new_name }
|
||||
call("SetInputName", payload)
|
||||
payload = {inputName: old_name, newInputName: new_name}
|
||||
call(:SetInputName, payload)
|
||||
end
|
||||
|
||||
def get_input_default_settings(kind)
|
||||
payload = { inputKind: kind }
|
||||
resp = call("GetInputDefaultSettings", payload)
|
||||
payload = {inputKind: kind}
|
||||
resp = call(:GetInputDefaultSettings, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_input_settings(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetInputSettings", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetInputSettings, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_input_settings(name, settings, overlay)
|
||||
payload = { inputName: name, inputSettings: settings, overlay: overlay }
|
||||
call("SetInputSettings", payload)
|
||||
payload = {inputName: name, inputSettings: settings, overlay: overlay}
|
||||
call(:SetInputSettings, payload)
|
||||
end
|
||||
|
||||
def get_input_mute(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetInputMute", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetInputMute, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_input_mute(name, muted)
|
||||
payload = { inputName: name, inputMuted: muted }
|
||||
call("SetInputMute", payload)
|
||||
payload = {inputName: name, inputMuted: muted}
|
||||
call(:SetInputMute, payload)
|
||||
end
|
||||
|
||||
def toggle_input_mute(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("ToggleInputMute", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:ToggleInputMute, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_input_volume(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetInputVolume", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetInputVolume, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -409,117 +409,117 @@ module OBSWS
|
||||
inputVolumeMul: vol_mul,
|
||||
inputVolumeDb: vol_db
|
||||
}
|
||||
call("SetInputVolume", payload)
|
||||
call(:SetInputVolume, payload)
|
||||
end
|
||||
|
||||
def get_input_audio_balance(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetInputAudioBalance", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetInputAudioBalance, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_input_audio_balance(name, balance)
|
||||
payload = { inputName: name, inputAudioBalance: balance }
|
||||
call("SetInputAudioBalance", payload)
|
||||
payload = {inputName: name, inputAudioBalance: balance}
|
||||
call(:SetInputAudioBalance, payload)
|
||||
end
|
||||
|
||||
def get_input_audio_sync_offset(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetInputAudioSyncOffset", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetInputAudioSyncOffset, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_input_audio_sync_offset(name, offset)
|
||||
payload = { inputName: name, inputAudioSyncOffset: offset }
|
||||
call("SetInputAudioSyncOffset", payload)
|
||||
payload = {inputName: name, inputAudioSyncOffset: offset}
|
||||
call(:SetInputAudioSyncOffset, payload)
|
||||
end
|
||||
|
||||
def get_input_audio_monitor_type(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetInputAudioMonitorType", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetInputAudioMonitorType, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_input_audio_monitor_type(name, mon_type)
|
||||
payload = { inputName: name, monitorType: mon_type }
|
||||
call("SetInputAudioMonitorType", payload)
|
||||
payload = {inputName: name, monitorType: mon_type}
|
||||
call(:SetInputAudioMonitorType, payload)
|
||||
end
|
||||
|
||||
def get_input_audio_tracks(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetInputAudioTracks", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetInputAudioTracks, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_input_audio_tracks(name, track)
|
||||
payload = { inputName: name, inputAudioTracks: track }
|
||||
call("SetInputAudioTracks", payload)
|
||||
payload = {inputName: name, inputAudioTracks: track}
|
||||
call(:SetInputAudioTracks, payload)
|
||||
end
|
||||
|
||||
def get_input_properties_list_property_items(input_name, prop_name)
|
||||
payload = { inputName: input_name, propertyName: prop_name }
|
||||
resp = call("GetInputPropertiesListPropertyItems", payload)
|
||||
payload = {inputName: input_name, propertyName: prop_name}
|
||||
resp = call(:GetInputPropertiesListPropertyItems, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def press_input_properties_button(input_name, prop_name)
|
||||
payload = { inputName: input_name, propertyName: prop_name }
|
||||
call("PressInputPropertiesButton", payload)
|
||||
payload = {inputName: input_name, propertyName: prop_name}
|
||||
call(:PressInputPropertiesButton, payload)
|
||||
end
|
||||
|
||||
def get_transition_kind_list
|
||||
resp = call("GetTransitionKindList")
|
||||
resp = call(:GetTransitionKindList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_scene_transition_list
|
||||
resp = call("GetSceneTransitionList")
|
||||
resp = call(:GetSceneTransitionList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_current_scene_transition
|
||||
resp = call("GetCurrentSceneTransition")
|
||||
resp = call(:GetCurrentSceneTransition)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_current_scene_transition(name)
|
||||
payload = { transitionName: name }
|
||||
call("SetCurrentSceneTransition", payload)
|
||||
payload = {transitionName: name}
|
||||
call(:SetCurrentSceneTransition, payload)
|
||||
end
|
||||
|
||||
def set_current_scene_transition_duration(duration)
|
||||
payload = { transitionDuration: duration }
|
||||
call("SetCurrentSceneTransitionDuration", payload)
|
||||
payload = {transitionDuration: duration}
|
||||
call(:SetCurrentSceneTransitionDuration, payload)
|
||||
end
|
||||
|
||||
def set_current_scene_transition_settings(settings, overlay = nil)
|
||||
payload = { transitionSettings: settings, overlay: overlay }
|
||||
call("SetCurrentSceneTransitionSettings", payload)
|
||||
payload = {transitionSettings: settings, overlay: overlay}
|
||||
call(:SetCurrentSceneTransitionSettings, payload)
|
||||
end
|
||||
|
||||
def get_current_scene_transition_cursor
|
||||
resp = call("GetCurrentSceneTransitionCursor")
|
||||
resp = call(:GetCurrentSceneTransitionCursor)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def trigger_studio_mode_transition
|
||||
call("TriggerStudioModeTransition")
|
||||
call(:TriggerStudioModeTransition)
|
||||
end
|
||||
|
||||
def set_t_bar_position(pos, release = nil)
|
||||
payload = { position: pos, release: release }
|
||||
call("SetTBarPosition", payload)
|
||||
payload = {position: pos, release: release}
|
||||
call(:SetTBarPosition, payload)
|
||||
end
|
||||
|
||||
def get_source_filter_list(name)
|
||||
payload = { sourceName: name }
|
||||
resp = call("GetSourceFilterList", payload)
|
||||
payload = {sourceName: name}
|
||||
resp = call(:GetSourceFilterList, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_source_filter_default_settings(kind)
|
||||
payload = { filterKind: kind }
|
||||
resp = call("GetSourceFilterDefaultSettings", payload)
|
||||
payload = {filterKind: kind}
|
||||
resp = call(:GetSourceFilterDefaultSettings, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -535,12 +535,12 @@ module OBSWS
|
||||
filterKind: filter_kind,
|
||||
filterSettings: filter_settings
|
||||
}
|
||||
call("CreateSourceFilter", payload)
|
||||
call(:CreateSourceFilter, payload)
|
||||
end
|
||||
|
||||
def remove_source_filter(source_name, filter_name)
|
||||
payload = { sourceName: source_name, filterName: filter_name }
|
||||
call("RemoveSourceFilter", payload)
|
||||
payload = {sourceName: source_name, filterName: filter_name}
|
||||
call(:RemoveSourceFilter, payload)
|
||||
end
|
||||
|
||||
def set_source_filter_name(source_name, old_filter_name, new_filter_name)
|
||||
@ -549,12 +549,12 @@ module OBSWS
|
||||
filterName: old_filter_name,
|
||||
newFilterName: new_filter_name
|
||||
}
|
||||
call("SetSourceFilterName", payload)
|
||||
call(:SetSourceFilterName, payload)
|
||||
end
|
||||
|
||||
def get_source_filter(source_name, filter_name)
|
||||
payload = { sourceName: source_name, filterName: filter_name }
|
||||
resp = call("GetSourceFilter", payload)
|
||||
payload = {sourceName: source_name, filterName: filter_name}
|
||||
resp = call(:GetSourceFilter, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -564,7 +564,7 @@ module OBSWS
|
||||
filterName: filter_name,
|
||||
filterIndex: filter_index
|
||||
}
|
||||
call("SetSourceFilterIndex", payload)
|
||||
call(:SetSourceFilterIndex, payload)
|
||||
end
|
||||
|
||||
def set_source_filter_settings(
|
||||
@ -579,7 +579,7 @@ module OBSWS
|
||||
filterSettings: settings,
|
||||
overlay: overlay
|
||||
}
|
||||
call("SetSourceFilterSettings", payload)
|
||||
call(:SetSourceFilterSettings, payload)
|
||||
end
|
||||
|
||||
def set_source_filter_enabled(source_name, filter_name, enabled)
|
||||
@ -588,18 +588,18 @@ module OBSWS
|
||||
filterName: filter_name,
|
||||
filterEnabled: enabled
|
||||
}
|
||||
call("SetSourceFilterEnabled", payload)
|
||||
call(:SetSourceFilterEnabled, payload)
|
||||
end
|
||||
|
||||
def get_scene_item_list(name)
|
||||
payload = { sceneName: name }
|
||||
resp = call("GetSceneItemList", payload)
|
||||
payload = {sceneName: name}
|
||||
resp = call(:GetSceneItemList, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_group_scene_item_list(name)
|
||||
payload = { sceneName: name }
|
||||
resp = call("GetGroupSceneItemList", payload)
|
||||
payload = {sceneName: name}
|
||||
resp = call(:GetGroupSceneItemList, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -609,7 +609,7 @@ module OBSWS
|
||||
sourceName: source_name,
|
||||
searchOffset: offset
|
||||
}
|
||||
resp = call("GetSceneItemId", payload)
|
||||
resp = call(:GetSceneItemId, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -619,13 +619,13 @@ module OBSWS
|
||||
sourceName: source_name,
|
||||
sceneItemEnabled: enabled
|
||||
}
|
||||
resp = call("CreateSceneItem", payload)
|
||||
resp = call(:CreateSceneItem, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def remove_scene_item(scene_name, item_id)
|
||||
payload = { sceneName: scene_name, sceneItemId: item_id }
|
||||
call("RemoveSceneItem", payload)
|
||||
payload = {sceneName: scene_name, sceneItemId: item_id}
|
||||
call(:RemoveSceneItem, payload)
|
||||
end
|
||||
|
||||
def duplicate_scene_item(scene_name, item_id, dest_scene_name = nil)
|
||||
@ -634,13 +634,13 @@ module OBSWS
|
||||
sceneItemId: item_id,
|
||||
destinationSceneName: dest_scene_name
|
||||
}
|
||||
resp = call("DuplicateSceneItem", payload)
|
||||
resp = call(:DuplicateSceneItem, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_scene_item_transform(scene_name, item_id)
|
||||
payload = { sceneName: scene_name, sceneItemId: item_id }
|
||||
resp = call("GetSceneItemTransform", payload)
|
||||
payload = {sceneName: scene_name, sceneItemId: item_id}
|
||||
resp = call(:GetSceneItemTransform, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -650,12 +650,12 @@ module OBSWS
|
||||
sceneItemId: item_id,
|
||||
sceneItemTransform: transform
|
||||
}
|
||||
call("SetSceneItemTransform", payload)
|
||||
call(:SetSceneItemTransform, payload)
|
||||
end
|
||||
|
||||
def get_scene_item_enabled(scene_name, item_id)
|
||||
payload = { sceneName: scene_name, sceneItemId: item_id }
|
||||
resp = call("GetSceneItemEnabled", payload)
|
||||
payload = {sceneName: scene_name, sceneItemId: item_id}
|
||||
resp = call(:GetSceneItemEnabled, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -665,12 +665,12 @@ module OBSWS
|
||||
sceneItemId: item_id,
|
||||
sceneItemEnabled: enabled
|
||||
}
|
||||
call("SetSceneItemEnabled", payload)
|
||||
call(:SetSceneItemEnabled, payload)
|
||||
end
|
||||
|
||||
def get_scene_item_locked(scene_name, item_id)
|
||||
payload = { sceneName: scene_name, sceneItemId: item_id }
|
||||
resp = call("GetSceneItemLocked", payload)
|
||||
payload = {sceneName: scene_name, sceneItemId: item_id}
|
||||
resp = call(:GetSceneItemLocked, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -680,12 +680,12 @@ module OBSWS
|
||||
sceneItemId: item_id,
|
||||
sceneItemLocked: locked
|
||||
}
|
||||
call("SetSceneItemLocked", payload)
|
||||
call(:SetSceneItemLocked, payload)
|
||||
end
|
||||
|
||||
def get_scene_item_index(scene_name, item_id)
|
||||
payload = { sceneName: scene_name, sceneItemId: item_id }
|
||||
resp = call("GetSceneItemIndex", payload)
|
||||
payload = {sceneName: scene_name, sceneItemId: item_id}
|
||||
resp = call(:GetSceneItemIndex, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -693,14 +693,14 @@ module OBSWS
|
||||
payload = {
|
||||
sceneName: scene_name,
|
||||
sceneItemId: item_id,
|
||||
sceneItemLocked: item_index
|
||||
sceneItemIndex: item_index
|
||||
}
|
||||
call("SetSceneItemIndex", payload)
|
||||
call(:SetSceneItemIndex, payload)
|
||||
end
|
||||
|
||||
def get_scene_item_blend_mode(scene_name, item_id)
|
||||
payload = { sceneName: scene_name, sceneItemId: item_id }
|
||||
resp = call("GetSceneItemBlendMode", payload)
|
||||
payload = {sceneName: scene_name, sceneItemId: item_id}
|
||||
resp = call(:GetSceneItemBlendMode, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
@ -710,192 +710,192 @@ module OBSWS
|
||||
sceneItemId: item_id,
|
||||
sceneItemBlendMode: blend
|
||||
}
|
||||
call("SetSceneItemBlendMode", payload)
|
||||
call(:SetSceneItemBlendMode, payload)
|
||||
end
|
||||
|
||||
def get_virtual_cam_status
|
||||
resp = call("GetVirtualCamStatus")
|
||||
resp = call(:GetVirtualCamStatus)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def toggle_virtual_cam
|
||||
resp = call("ToggleVirtualCam")
|
||||
resp = call(:ToggleVirtualCam)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def start_virtual_cam
|
||||
call("StartVirtualCam")
|
||||
call(:StartVirtualCam)
|
||||
end
|
||||
|
||||
def stop_virtual_cam
|
||||
call("StopVirtualCam")
|
||||
call(:StopVirtualCam)
|
||||
end
|
||||
|
||||
def get_replay_buffer_status
|
||||
resp = call("GetReplayBufferStatus")
|
||||
resp = call(:GetReplayBufferStatus)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def toggle_replay_buffer
|
||||
resp = call("ToggleReplayBuffer")
|
||||
resp = call(:ToggleReplayBuffer)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def start_replay_buffer
|
||||
call("StartReplayBuffer")
|
||||
call(:StartReplayBuffer)
|
||||
end
|
||||
|
||||
def stop_replay_buffer
|
||||
call("StopReplayBuffer")
|
||||
call(:StopReplayBuffer)
|
||||
end
|
||||
|
||||
def save_replay_buffer
|
||||
call("SaveReplayBuffer")
|
||||
call(:SaveReplayBuffer)
|
||||
end
|
||||
|
||||
def get_last_replay_buffer_replay
|
||||
resp = call("GetLastReplayBufferReplay")
|
||||
resp = call(:GetLastReplayBufferReplay)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_output_list
|
||||
resp = call("GetOutputList")
|
||||
resp = call(:GetOutputList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def get_output_status(name)
|
||||
payload = { outputName: name }
|
||||
resp = call("GetOutputStatus", payload)
|
||||
payload = {outputName: name}
|
||||
resp = call(:GetOutputStatus, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def toggle_output(name)
|
||||
payload = { outputName: name }
|
||||
resp = call("ToggleOutput", payload)
|
||||
payload = {outputName: name}
|
||||
resp = call(:ToggleOutput, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def start_output(name)
|
||||
payload = { outputName: name }
|
||||
call("StartOutput", payload)
|
||||
payload = {outputName: name}
|
||||
call(:StartOutput, payload)
|
||||
end
|
||||
|
||||
def stop_output(name)
|
||||
payload = { outputName: name }
|
||||
call("StopOutput", payload)
|
||||
payload = {outputName: name}
|
||||
call(:StopOutput, payload)
|
||||
end
|
||||
|
||||
def get_output_settings(name)
|
||||
payload = { outputName: name }
|
||||
resp = call("GetOutputSettings", payload)
|
||||
payload = {outputName: name}
|
||||
resp = call(:GetOutputSettings, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_output_settings(name, settings)
|
||||
payload = { outputName: name, outputSettings: settings }
|
||||
call("SetOutputSettings", payload)
|
||||
payload = {outputName: name, outputSettings: settings}
|
||||
call(:SetOutputSettings, payload)
|
||||
end
|
||||
|
||||
def get_stream_status
|
||||
resp = call("GetStreamStatus")
|
||||
resp = call(:GetStreamStatus)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def toggle_stream
|
||||
resp = call("ToggleStream")
|
||||
resp = call(:ToggleStream)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def start_stream
|
||||
call("StartStream")
|
||||
call(:StartStream)
|
||||
end
|
||||
|
||||
def stop_stream
|
||||
call("StopStream")
|
||||
call(:StopStream)
|
||||
end
|
||||
|
||||
def send_stream_caption(caption)
|
||||
call("SendStreamCaption")
|
||||
call(:SendStreamCaption)
|
||||
end
|
||||
|
||||
def get_record_status
|
||||
resp = call("GetRecordStatus")
|
||||
resp = call(:GetRecordStatus)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def toggle_record
|
||||
call("ToggleRecord")
|
||||
call(:ToggleRecord)
|
||||
end
|
||||
|
||||
def start_record
|
||||
call("StartRecord")
|
||||
call(:StartRecord)
|
||||
end
|
||||
|
||||
def stop_record
|
||||
resp = call("StopRecord")
|
||||
resp = call(:StopRecord)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def toggle_record_pause
|
||||
call("ToggleRecordPause")
|
||||
call(:ToggleRecordPause)
|
||||
end
|
||||
|
||||
def pause_record
|
||||
call("PauseRecord")
|
||||
call(:PauseRecord)
|
||||
end
|
||||
|
||||
def resume_record
|
||||
call("ResumeRecord")
|
||||
call(:ResumeRecord)
|
||||
end
|
||||
|
||||
def get_media_input_status(name)
|
||||
payload = { inputName: name }
|
||||
resp = call("GetMediaInputStatus", payload)
|
||||
payload = {inputName: name}
|
||||
resp = call(:GetMediaInputStatus, payload)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_media_input_cursor(name, cursor)
|
||||
payload = { inputName: name, mediaCursor: cursor }
|
||||
call("SetMediaInputCursor", payload)
|
||||
payload = {inputName: name, mediaCursor: cursor}
|
||||
call(:SetMediaInputCursor, payload)
|
||||
end
|
||||
|
||||
def offset_media_input_cursor(name, offset)
|
||||
payload = { inputName: name, mediaCursorOffset: offset }
|
||||
call("OffsetMediaInputCursor", payload)
|
||||
payload = {inputName: name, mediaCursorOffset: offset}
|
||||
call(:OffsetMediaInputCursor, payload)
|
||||
end
|
||||
|
||||
def trigger_media_input_action(name, action)
|
||||
payload = { inputName: name, mediaAction: action }
|
||||
call("TriggerMediaInputAction", payload)
|
||||
payload = {inputName: name, mediaAction: action}
|
||||
call(:TriggerMediaInputAction, payload)
|
||||
end
|
||||
|
||||
def get_studio_mode_enabled
|
||||
resp = call("GetStudioModeEnabled")
|
||||
resp = call(:GetStudioModeEnabled)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
|
||||
def set_studio_mode_enabled(enabled)
|
||||
payload = { studioModeEnabled: enabled }
|
||||
call("SetStudioModeEnabled", payload)
|
||||
payload = {studioModeEnabled: enabled}
|
||||
call(:SetStudioModeEnabled, payload)
|
||||
end
|
||||
|
||||
def open_input_properties_dialog(name)
|
||||
payload = { inputName: name }
|
||||
call("OpenInputPropertiesDialog", payload)
|
||||
payload = {inputName: name}
|
||||
call(:OpenInputPropertiesDialog, payload)
|
||||
end
|
||||
|
||||
def open_input_filters_dialog(name)
|
||||
payload = { inputName: name }
|
||||
call("OpenInputFiltersDialog", payload)
|
||||
payload = {inputName: name}
|
||||
call(:OpenInputFiltersDialog, payload)
|
||||
end
|
||||
|
||||
def open_input_interact_dialog(name)
|
||||
payload = { inputName: name }
|
||||
call("OpenInputInteractDialog", payload)
|
||||
payload = {inputName: name}
|
||||
call(:OpenInputInteractDialog, payload)
|
||||
end
|
||||
|
||||
def get_monitor_list
|
||||
resp = call("GetMonitorList")
|
||||
resp = call(:GetMonitorList)
|
||||
Mixin::Response.new(resp, resp.keys)
|
||||
end
|
||||
end
|
||||
|
@ -7,11 +7,11 @@ module OBSWS
|
||||
end
|
||||
|
||||
def minor
|
||||
1
|
||||
2
|
||||
end
|
||||
|
||||
def patch
|
||||
3
|
||||
0
|
||||
end
|
||||
|
||||
def to_a
|
||||
@ -22,4 +22,6 @@ module OBSWS
|
||||
to_a.join(".")
|
||||
end
|
||||
end
|
||||
|
||||
VERSION = Version.to_s
|
||||
end
|
||||
|
11
main.rb
11
main.rb
@ -1,17 +1,14 @@
|
||||
require_relative "lib/obsws"
|
||||
|
||||
def main
|
||||
r_client =
|
||||
OBSWS::Requests::Client.new(
|
||||
host: "localhost",
|
||||
port: 4455,
|
||||
password: "strongpassword"
|
||||
)
|
||||
|
||||
r_client.run do
|
||||
# Toggle the mute state of your Mic input
|
||||
r_client.toggle_input_mute("Mic/Aux")
|
||||
end
|
||||
).run do |client|
|
||||
# Toggle the mute state of your Mic input
|
||||
client.toggle_input_mute("Mic/Aux")
|
||||
end
|
||||
end
|
||||
|
||||
main if $0 == __FILE__
|
||||
|
@ -1,10 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path("lib/obsws/version", __dir__)
|
||||
lib = File.expand_path("./lib")
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "obsws"
|
||||
spec.version = OBSWS::Version
|
||||
spec.version = OBSWS::VERSION
|
||||
spec.summary = "OBS Websocket v5 wrapper"
|
||||
spec.description = "A Ruby wrapper around OBS Websocket v5"
|
||||
spec.authors = ["onyx_online"]
|
||||
@ -16,11 +16,11 @@ Gem::Specification.new do |spec|
|
||||
spec.add_runtime_dependency "observer", "~> 0.1.1"
|
||||
spec.add_runtime_dependency "websocket-driver", "~> 0.7.5"
|
||||
spec.add_runtime_dependency "waitutil", "~> 0.2.1"
|
||||
spec.add_development_dependency "perfect_toml", "~> 0.9.0"
|
||||
spec.add_development_dependency "standard", "~> 1.30"
|
||||
spec.add_development_dependency "minitest", "~> 5.16", ">= 5.16.3"
|
||||
spec.add_development_dependency "rake", "~> 11.2", ">= 11.2.2"
|
||||
spec.required_ruby_version = ">= 3.0"
|
||||
spec.metadata = {
|
||||
"source_code_uri" => "https://github.com/onyx-and-iris/obsws.git"
|
||||
"source_code_uri" => "https://github.com/onyx-and-iris/obsws-ruby"
|
||||
}
|
||||
end
|
||||
|
@ -1,17 +1,21 @@
|
||||
require "minitest"
|
||||
require "minitest/autorun"
|
||||
require "perfect_toml"
|
||||
require "yaml"
|
||||
|
||||
require_relative "../lib/obsws"
|
||||
|
||||
class OBSWSTest < Minitest::Test
|
||||
def self.before_run
|
||||
conn = PerfectTOML.load_file("obs.toml", symbolize_names: true)[:connection]
|
||||
@@r_client = OBSWS::Requests::Client.new(**conn)
|
||||
class << self
|
||||
attr_reader :r_client
|
||||
end
|
||||
|
||||
@@r_client.create_scene("START_TEST")
|
||||
@@r_client.create_scene("BRB_TEST")
|
||||
@@r_client.create_scene("END_TEST")
|
||||
def self.before_run
|
||||
conn = YAML.load_file("obs.yml", symbolize_names: true)[:connection]
|
||||
@r_client = OBSWS::Requests::Client.new(**conn)
|
||||
|
||||
r_client.create_scene("START_TEST")
|
||||
r_client.create_scene("BRB_TEST")
|
||||
r_client.create_scene("END_TEST")
|
||||
end
|
||||
|
||||
before_run
|
||||
@ -23,9 +27,9 @@ class OBSWSTest < Minitest::Test
|
||||
end
|
||||
|
||||
Minitest.after_run do
|
||||
@@r_client.remove_scene("START_TEST")
|
||||
@@r_client.remove_scene("BRB_TEST")
|
||||
@@r_client.remove_scene("END_TEST")
|
||||
@@r_client.close
|
||||
r_client.remove_scene("START_TEST")
|
||||
r_client.remove_scene("BRB_TEST")
|
||||
r_client.remove_scene("END_TEST")
|
||||
r_client.close
|
||||
end
|
||||
end
|
||||
|
@ -2,16 +2,16 @@ require_relative "../minitest_helper"
|
||||
|
||||
class AttrsTest < OBSWSTest
|
||||
def test_get_version_attrs
|
||||
resp = @@r_client.get_version
|
||||
resp = OBSWSTest.r_client.get_version
|
||||
assert resp.attrs ==
|
||||
%w[
|
||||
available_requests
|
||||
obs_version
|
||||
obs_web_socket_version
|
||||
platform
|
||||
platform_description
|
||||
rpc_version
|
||||
supported_image_formats
|
||||
]
|
||||
%w[
|
||||
available_requests
|
||||
obs_version
|
||||
obs_web_socket_version
|
||||
platform
|
||||
platform_description
|
||||
rpc_version
|
||||
supported_image_formats
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -2,21 +2,21 @@ require_relative "../minitest_helper"
|
||||
|
||||
class RequestTest < OBSWSTest
|
||||
def test_it_checks_obs_major_version
|
||||
resp = @@r_client.get_version
|
||||
resp = OBSWSTest.r_client.get_version
|
||||
ver = resp.obs_version.split(".").map(&:to_i)
|
||||
assert ver[0] >= 28
|
||||
end
|
||||
|
||||
def test_it_checks_ws_major_version
|
||||
resp = @@r_client.get_version
|
||||
resp = OBSWSTest.r_client.get_version
|
||||
ver = resp.obs_web_socket_version.split(".").map(&:to_i)
|
||||
assert ver[0] >= 5
|
||||
end
|
||||
|
||||
def test_it_sets_and_gets_current_program_scene
|
||||
%w[START_TEST BRB_TEST END_TEST].each do |s|
|
||||
@@r_client.set_current_program_scene(s)
|
||||
resp = @@r_client.get_current_program_scene
|
||||
OBSWSTest.r_client.set_current_program_scene(s)
|
||||
resp = OBSWSTest.r_client.get_current_program_scene
|
||||
assert resp.current_program_scene_name == s
|
||||
end
|
||||
end
|
||||
@ -26,13 +26,13 @@ class RequestTest < OBSWSTest
|
||||
server: "rtmp://addressofrtmpserver",
|
||||
key: "live_myvery_secretkey"
|
||||
}
|
||||
@@r_client.set_stream_service_settings("rtmp_common", settings)
|
||||
resp = @@r_client.get_stream_service_settings
|
||||
OBSWSTest.r_client.set_stream_service_settings("rtmp_common", settings)
|
||||
resp = OBSWSTest.r_client.get_stream_service_settings
|
||||
assert resp.stream_service_type == "rtmp_common"
|
||||
assert resp.stream_service_settings ==
|
||||
{
|
||||
server: "rtmp://addressofrtmpserver",
|
||||
key: "live_myvery_secretkey"
|
||||
}
|
||||
{
|
||||
server: "rtmp://addressofrtmpserver",
|
||||
key: "live_myvery_secretkey"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user