obsws 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 459330fa7270cc31f26449b15ceb03e53130a7499f3272a9a9d17d8ac7de0b7f
4
- data.tar.gz: 46897d76b4c62720f776aabb2fea69d47fadc9a0c1d1b0041d090738e2a9c394
3
+ metadata.gz: 3ac01e29c9776d0288fc46118847ca4054596a940173b68aec224fb888a7d6ed
4
+ data.tar.gz: baef83a80ef328743d2579a74d31d7e9b6bc46203f6a5e0af4072dfa08a26ed7
5
5
  SHA512:
6
- metadata.gz: a9bf8c54c209f1b18422babb02fcc631f773e0a5d46c9b8af49ba1a6e5e3077de1b89e1ce57cbc36fb5e868c41503a57d49292cc5bcb970c39127493bb1be3b5
7
- data.tar.gz: 5959a9b71dceaf3af1fdbe624828e22631e45c8845e2ce232e9083565b9d62aa294690212ecc8b35f56083bb39eed94c346acf787f854414af072edbf3c9b2c8
6
+ metadata.gz: 71f5a718e0dfaec48b05f4f8a1e49637f0d60a20f56d8870987588cfe4ae1938b67d04043fae20cc612d1f61d8d48b22cff3a908ffe045fb0b1bbf432736f00a
7
+ data.tar.gz: 7a95faceaa4022bab0c8045b7068bca4ceee6a86a4e21c303e34a589cbc80d45b358ba2f12a365c8c45abed5c2eae4a5b49ae4ea97ac45c06bcf743ab8a796a4
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/obsws.svg)](https://badge.fury.io/rb/obsws)
2
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/voicemeeter-api-ruby/blob/dev/LICENSE)
2
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/obsws-ruby/blob/dev/LICENSE)
3
3
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/plugin-ruby)
4
4
 
5
5
  # A Ruby wrapper around OBS Studio WebSocket v5.0
@@ -11,6 +11,19 @@
11
11
  - 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.
12
12
  - Ruby 3.0 or greater
13
13
 
14
+ ## Installation
15
+
16
+ ### Bundler
17
+
18
+ ```
19
+ bundle add 'obsws'
20
+ bundle install
21
+ ```
22
+
23
+ ### Gem
24
+
25
+ `gem install 'obsws'`
26
+
14
27
  ## `Use`
15
28
 
16
29
  #### Example `main.rb`
data/lib/obsws/base.rb CHANGED
@@ -74,7 +74,8 @@ module OBSWS
74
74
  )
75
75
  end
76
76
 
77
- def authenticate(auth = nil)
77
+ def identify(auth)
78
+ LOGGER.info("initiating authentication") if auth
78
79
  payload = {
79
80
  op: Mixin::OPCodes::IDENTIFY,
80
81
  d: {
@@ -89,14 +90,8 @@ module OBSWS
89
90
  def msg_handler(data)
90
91
  case data[:op]
91
92
  when Mixin::OPCodes::HELLO
92
- if data[:d].key? :authentication
93
- LOGGER.debug("initiating authentication")
94
- else
95
- LOGGER.debug("authentication disabled... skipping.")
96
- end
97
- authenticate(data[:d][:authentication])
93
+ identify(data[:d][:authentication])
98
94
  when Mixin::OPCodes::IDENTIFIED
99
- LOGGER.debug("client succesfully identified with server")
100
95
  @identified = true
101
96
  when Mixin::OPCodes::EVENT, Mixin::OPCodes::REQUESTRESPONSE
102
97
  changed
data/lib/obsws/event.rb CHANGED
@@ -7,38 +7,30 @@ module OBSWS
7
7
  module Events
8
8
  module SUBS
9
9
  NONE = 0
10
- GENERAL = (1 << 0)
11
- CONFIG = (1 << 1)
12
- SCENES = (1 << 2)
13
- INPUTS = (1 << 3)
14
- TRANSITIONS = (1 << 4)
15
- FILTERS = (1 << 5)
16
- OUTPUTS = (1 << 6)
17
- SCENEITEMS = (1 << 7)
18
- MEDIAINPUTS = (1 << 8)
19
- VENDORS = (1 << 9)
20
- UI = (1 << 10)
10
+ GENERAL = 1 << 0
11
+ CONFIG = 1 << 1
12
+ SCENES = 1 << 2
13
+ INPUTS = 1 << 3
14
+ TRANSITIONS = 1 << 4
15
+ FILTERS = 1 << 5
16
+ OUTPUTS = 1 << 6
17
+ SCENEITEMS = 1 << 7
18
+ MEDIAINPUTS = 1 << 8
19
+ VENDORS = 1 << 9
20
+ UI = 1 << 10
21
21
 
22
- def low_volume
23
- GENERAL | CONFIG | SCENES | INPUTS | TRANSITIONS | FILTERS | OUTPUTS |
22
+ LOW_VOLUME = GENERAL | CONFIG | SCENES | INPUTS | TRANSITIONS | FILTERS | OUTPUTS |
24
23
  SCENEITEMS | MEDIAINPUTS | VENDORS | UI
25
- end
26
24
 
27
- INPUTVOLUMEMETERS = (1 << 16)
28
- INPUTACTIVESTATECHANGED = (1 << 17)
29
- INPUTSHOWSTATECHANGED = (1 << 18)
30
- SCENEITEMTRANSFORMCHANGED = (1 << 19)
25
+ INPUTVOLUMEMETERS = 1 << 16
26
+ INPUTACTIVESTATECHANGED = 1 << 17
27
+ INPUTSHOWSTATECHANGED = 1 << 18
28
+ SCENEITEMTRANSFORMCHANGED = 1 << 19
31
29
 
32
- def high_volume
33
- INPUTVOLUMEMETERS | INPUTACTIVESTATECHANGED | INPUTSHOWSTATECHANGED |
30
+ HIGH_VOLUME = INPUTVOLUMEMETERS | INPUTACTIVESTATECHANGED | INPUTSHOWSTATECHANGED |
34
31
  SCENEITEMTRANSFORMCHANGED
35
- end
36
-
37
- def all
38
- low_volume | high_volume
39
- end
40
32
 
41
- module_function :low_volume, :high_volume, :all
33
+ ALL = LOW_VOLUME | HIGH_VOLUME
42
34
  end
43
35
 
44
36
  module Callbacks
@@ -75,11 +67,16 @@ module OBSWS
75
67
  include Mixin::OPCodes
76
68
 
77
69
  def initialize(**kwargs)
78
- kwargs[:subs] = SUBS.low_volume
70
+ kwargs[:subs] ||= SUBS::LOW_VOLUME
79
71
  @base_client = Base.new(**kwargs)
72
+ LOGGER.info("#{self} succesfully identified with server")
80
73
  @base_client.add_observer(self)
81
74
  end
82
75
 
76
+ def to_s
77
+ "#{self.class.name.split("::").last(2).join("::")}"
78
+ end
79
+
83
80
  def update(op_code, data)
84
81
  if op_code == Mixin::OPCodes::EVENT
85
82
  event = data[:eventType]
data/lib/obsws/mixin.rb CHANGED
@@ -5,7 +5,7 @@ module OBSWS
5
5
  module Meta
6
6
  include Util
7
7
 
8
- def make_response_methods(*params)
8
+ def make_field_methods(*params)
9
9
  params.each do |param|
10
10
  define_singleton_method(param.to_s.to_snake) { @resp[param] }
11
11
  end
@@ -18,7 +18,7 @@ module OBSWS
18
18
  def initialize(resp, fields)
19
19
  @resp = resp
20
20
  @fields = fields
21
- self.make_response_methods *fields
21
+ self.make_field_methods *fields
22
22
  end
23
23
 
24
24
  def empty? = @fields.empty?
data/lib/obsws/req.rb CHANGED
@@ -14,10 +14,15 @@ module OBSWS
14
14
 
15
15
  def initialize(**kwargs)
16
16
  @base_client = Base.new(**kwargs)
17
+ LOGGER.info("#{self} succesfully identified with server")
17
18
  @base_client.add_observer(self)
18
19
  @response = { requestId: 0 }
19
20
  end
20
21
 
22
+ def to_s
23
+ "#{self.class.name.split("::").last(2).join("::")}"
24
+ end
25
+
21
26
  def run
22
27
  yield
23
28
  ensure
@@ -72,7 +77,10 @@ module OBSWS
72
77
  end
73
78
 
74
79
  def call_vendor_request(name, type_, data = nil)
75
- call(requestType, requestData)
80
+ payload = { vendorName: name, requestType: type_ }
81
+ payload[:requestData] = data if data
82
+ resp = call("CallVendorRequest", payload)
83
+ Mixin::Response.new(resp, resp.keys)
76
84
  end
77
85
 
78
86
  def get_hotkey_list
@@ -256,7 +264,7 @@ module OBSWS
256
264
  end
257
265
 
258
266
  def get_group_list
259
- resp = call("GetSceneList")
267
+ resp = call("GetGroupList")
260
268
  Mixin::Response.new(resp, resp.keys)
261
269
  end
262
270
 
@@ -324,6 +332,7 @@ module OBSWS
324
332
 
325
333
  def get_special_inputs
326
334
  resp = call("GetSpecialInputs")
335
+ Mixin::Response.new(resp, resp.keys)
327
336
  end
328
337
 
329
338
  def create_input(
@@ -341,6 +350,7 @@ module OBSWS
341
350
  sceneItemEnabled: scene_item_enabled
342
351
  }
343
352
  resp = call("CreateInput", payload)
353
+ Mixin::Response.new(resp, resp.keys)
344
354
  end
345
355
 
346
356
  def remove_input(name)
@@ -823,6 +833,7 @@ module OBSWS
823
833
 
824
834
  def stop_record
825
835
  resp = call("StopRecord")
836
+ Mixin::Response.new(resp, resp.keys)
826
837
  end
827
838
 
828
839
  def toggle_record_pause
data/lib/obsws/version.rb CHANGED
@@ -7,11 +7,11 @@ module OBSWS
7
7
  end
8
8
 
9
9
  def minor
10
- 0
10
+ 1
11
11
  end
12
12
 
13
13
  def patch
14
- 3
14
+ 1
15
15
  end
16
16
 
17
17
  def to_a
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obsws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - onyx_online
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-23 00:00:00.000000000 Z
11
+ date: 2022-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: observer