Class: OBSWS::Requests::Client

Inherits:
Object
  • Object
show all
Includes:
Logging, Mixin::OPCodes, Mixin::TearDown
Defined in:
lib/obsws/req.rb

Constant Summary

Constants included from Mixin::OPCodes

Mixin::OPCodes::EVENT, Mixin::OPCodes::HELLO, Mixin::OPCodes::IDENTIFIED, Mixin::OPCodes::IDENTIFY, Mixin::OPCodes::REIDENTIFY, Mixin::OPCodes::REQUEST, Mixin::OPCodes::REQUESTBATCH, Mixin::OPCodes::REQUESTBATCHRESPONSE, Mixin::OPCodes::REQUESTRESPONSE

Instance Method Summary collapse

Methods included from Mixin::TearDown

#stop_driver

Methods included from Logging

#logger

Constructor Details

#initialize(**kwargs) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/obsws/req.rb', line 8

def initialize(**kwargs)
  @base_client = Base.new(**kwargs)
  unless @base_client.identified.state == :identified
    err_msg = @base_client.identified.error_message
    logger.error(err_msg)
    raise OBSWSConnectionError.new(err_msg)
  end
  logger.info("#{self} successfully identified with server")
rescue Errno::ECONNREFUSED, WaitUtil::TimeoutError => e
  logger.error("#{e.class.name}: #{e.message}")
  raise OBSWSConnectionError.new(e.message)
else
  @base_client.updater = ->(op_code, data) {
    logger.debug("response received: #{data}")
    @response = data if op_code == Mixin::OPCodes::REQUESTRESPONSE
  }
  @response = {requestId: 0}
end

Instance Method Details

#broadcast_custom_event(data) ⇒ Object



72
73
74
# File 'lib/obsws/req.rb', line 72

def broadcast_custom_event(data)
  call(:BroadcastCustomEvent, data)
end

#call(req, data = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/obsws/req.rb', line 42

def call(req, data = nil)
  uuid = SecureRandom.uuid
  @base_client.req(uuid, req, data)
  WaitUtil.wait_for_condition(
    "reponse id to match request id",
    delay_sec: 0.001,
    timeout_sec: 3
  ) { @response[:requestId] == uuid }
  unless @response[:requestStatus][:result]
    raise OBSWSRequestError.new(@response[:requestType], @response[:requestStatus][:code], @response[:requestStatus][:comment])
  end
  @response[:responseData]
rescue OBSWSRequestError => e
  logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
  raise
rescue WaitUtil::TimeoutError => e
  logger.error(["#{e.class.name}: #{e.message}", *e.backtrace].join("\n"))
  raise OBSWSError.new([e.message, *e.backtrace].join("\n"))
end

#call_vendor_request(vendor_name, request_type, data = nil) ⇒ Object



76
77
78
79
80
81
# File 'lib/obsws/req.rb', line 76

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)
  Mixin::Response.new(resp, resp.keys)
end

#create_input(scene_name, input_name, input_kind, input_settings, scene_item_enabled) ⇒ Object



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/obsws/req.rb', line 335

def create_input(
  scene_name,
  input_name,
  input_kind,
  input_settings,
  scene_item_enabled
)
  payload = {
    sceneName: scene_name,
    inputName: input_name,
    inputKind: input_kind,
    inputSettings: input_settings,
    sceneItemEnabled: scene_item_enabled
  }
  resp = call(:CreateInput, payload)
  Mixin::Response.new(resp, resp.keys)
end

#create_profile(name) ⇒ Object



153
154
155
156
# File 'lib/obsws/req.rb', line 153

def create_profile(name)
  payload = {profileName: name}
  call(:CreateProfile, payload)
end

#create_scene(name) ⇒ Object



288
289
290
291
# File 'lib/obsws/req.rb', line 288

def create_scene(name)
  payload = {sceneName: name}
  call(:CreateScene, payload)
end

#create_scene_collection(name) ⇒ Object



138
139
140
141
# File 'lib/obsws/req.rb', line 138

def create_scene_collection(name)
  payload = {sceneCollectionName: name}
  call(:CreateSceneCollection, payload)
end

#create_scene_item(scene_name, source_name, enabled = nil) ⇒ Object



613
614
615
616
617
618
619
620
621
# File 'lib/obsws/req.rb', line 613

def create_scene_item(scene_name, source_name, enabled = nil)
  payload = {
    sceneName: scene_name,
    sourceName: source_name,
    sceneItemEnabled: enabled
  }
  resp = call(:CreateSceneItem, payload)
  Mixin::Response.new(resp, resp.keys)
end

#create_source_filter(source_name, filter_name, filter_kind, filter_settings = nil) ⇒ Object



523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/obsws/req.rb', line 523

def create_source_filter(
  source_name,
  filter_name,
  filter_kind,
  filter_settings = nil
)
  payload = {
    sourceName: source_name,
    filterName: filter_name,
    filterKind: filter_kind,
    filterSettings: filter_settings
  }
  call(:CreateSourceFilter, payload)
end

#duplicate_scene_item(scene_name, item_id, dest_scene_name = nil) ⇒ Object



628
629
630
631
632
633
634
635
636
# File 'lib/obsws/req.rb', line 628

def duplicate_scene_item(scene_name, item_id, dest_scene_name = nil)
  payload = {
    sceneName: scene_name,
    sceneItemId: item_id,
    destinationSceneName: dest_scene_name
  }
  resp = call(:DuplicateSceneItem, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_current_preview_sceneObject



278
279
280
281
# File 'lib/obsws/req.rb', line 278

def get_current_preview_scene
  resp = call(:GetCurrentPreviewScene)
  Mixin::Response.new(resp, resp.keys)
end

#get_current_program_sceneObject



268
269
270
271
# File 'lib/obsws/req.rb', line 268

def get_current_program_scene
  resp = call(:GetCurrentProgramScene)
  Mixin::Response.new(resp, resp.keys)
end

#get_current_scene_transitionObject



477
478
479
480
# File 'lib/obsws/req.rb', line 477

def get_current_scene_transition
  resp = call(:GetCurrentSceneTransition)
  Mixin::Response.new(resp, resp.keys)
end

#get_current_scene_transition_cursorObject



497
498
499
500
# File 'lib/obsws/req.rb', line 497

def get_current_scene_transition_cursor
  resp = call(:GetCurrentSceneTransitionCursor)
  Mixin::Response.new(resp, resp.keys)
end

#get_group_listObject



263
264
265
266
# File 'lib/obsws/req.rb', line 263

def get_group_list
  resp = call(:GetGroupList)
  Mixin::Response.new(resp, resp.keys)
end

#get_group_scene_item_list(name) ⇒ Object



597
598
599
600
601
# File 'lib/obsws/req.rb', line 597

def get_group_scene_item_list(name)
  payload = {sceneName: name}
  resp = call(:GetGroupSceneItemList, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_hotkey_listObject



83
84
85
86
# File 'lib/obsws/req.rb', line 83

def get_hotkey_list
  resp = call(:GetHotkeyList)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_audio_balance(name) ⇒ Object



412
413
414
415
416
# File 'lib/obsws/req.rb', line 412

def get_input_audio_balance(name)
  payload = {inputName: name}
  resp = call(:GetInputAudioBalance, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_audio_monitor_type(name) ⇒ Object



434
435
436
437
438
# File 'lib/obsws/req.rb', line 434

def get_input_audio_monitor_type(name)
  payload = {inputName: name}
  resp = call(:GetInputAudioMonitorType, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_audio_sync_offset(name) ⇒ Object



423
424
425
426
427
# File 'lib/obsws/req.rb', line 423

def get_input_audio_sync_offset(name)
  payload = {inputName: name}
  resp = call(:GetInputAudioSyncOffset, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_audio_tracks(name) ⇒ Object



445
446
447
448
449
# File 'lib/obsws/req.rb', line 445

def get_input_audio_tracks(name)
  payload = {inputName: name}
  resp = call(:GetInputAudioTracks, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_default_settings(kind) ⇒ Object



363
364
365
366
367
# File 'lib/obsws/req.rb', line 363

def get_input_default_settings(kind)
  payload = {inputKind: kind}
  resp = call(:GetInputDefaultSettings, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_kind_list(unversioned) ⇒ Object



324
325
326
327
328
# File 'lib/obsws/req.rb', line 324

def get_input_kind_list(unversioned)
  payload = {unversioned: unversioned}
  resp = call(:GetInputKindList, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_list(kind = nil) ⇒ Object



318
319
320
321
322
# File 'lib/obsws/req.rb', line 318

def get_input_list(kind = nil)
  payload = {inputKind: kind}
  resp = call(:GetInputList, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_mute(name) ⇒ Object



380
381
382
383
384
# File 'lib/obsws/req.rb', line 380

def get_input_mute(name)
  payload = {inputName: name}
  resp = call(:GetInputMute, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_properties_list_property_items(input_name, prop_name) ⇒ Object



456
457
458
459
460
# File 'lib/obsws/req.rb', line 456

def get_input_properties_list_property_items(input_name, prop_name)
  payload = {inputName: input_name, propertyName: prop_name}
  resp = call(:GetInputPropertiesListPropertyItems, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_settings(name) ⇒ Object



369
370
371
372
373
# File 'lib/obsws/req.rb', line 369

def get_input_settings(name)
  payload = {inputName: name}
  resp = call(:GetInputSettings, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_input_volume(name) ⇒ Object



397
398
399
400
401
# File 'lib/obsws/req.rb', line 397

def get_input_volume(name)
  payload = {inputName: name}
  resp = call(:GetInputVolume, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_last_replay_buffer_replayObject



753
754
755
756
# File 'lib/obsws/req.rb', line 753

def get_last_replay_buffer_replay
  resp = call(:GetLastReplayBufferReplay)
  Mixin::Response.new(resp, resp.keys)
end

#get_media_input_status(name) ⇒ Object



848
849
850
851
852
# File 'lib/obsws/req.rb', line 848

def get_media_input_status(name)
  payload = {inputName: name}
  resp = call(:GetMediaInputStatus, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_monitor_listObject



894
895
896
897
# File 'lib/obsws/req.rb', line 894

def get_monitor_list
  resp = call(:GetMonitorList)
  Mixin::Response.new(resp, resp.keys)
end

#get_output_listObject



758
759
760
761
# File 'lib/obsws/req.rb', line 758

def get_output_list
  resp = call(:GetOutputList)
  Mixin::Response.new(resp, resp.keys)
end

#get_output_settings(name) ⇒ Object



785
786
787
788
789
# File 'lib/obsws/req.rb', line 785

def get_output_settings(name)
  payload = {outputName: name}
  resp = call(:GetOutputSettings, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_output_status(name) ⇒ Object



763
764
765
766
767
# File 'lib/obsws/req.rb', line 763

def get_output_status(name)
  payload = {outputName: name}
  resp = call(:GetOutputStatus, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_persistent_data(realm, slot_name) ⇒ Object



117
118
119
120
121
# File 'lib/obsws/req.rb', line 117

def get_persistent_data(realm, slot_name)
  payload = {realm: realm, slotName: slot_name}
  resp = call(:GetPersistentData, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_profile_listObject



143
144
145
146
# File 'lib/obsws/req.rb', line 143

def get_profile_list
  resp = call(:GetProfileList)
  Mixin::Response.new(resp, resp.keys)
end

#get_profile_parameter(category, name) ⇒ Object



163
164
165
166
167
# File 'lib/obsws/req.rb', line 163

def get_profile_parameter(category, name)
  payload = {parameterCategory: category, parameterName: name}
  resp = call(:GetProfileParameter, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_record_directoryObject



215
216
217
218
# File 'lib/obsws/req.rb', line 215

def get_record_directory
  resp = call(:GetRecordDirectory)
  Mixin::Response.new(resp, resp.keys)
end

#get_record_statusObject



818
819
820
821
# File 'lib/obsws/req.rb', line 818

def get_record_status
  resp = call(:GetRecordStatus)
  Mixin::Response.new(resp, resp.keys)
end

#get_replay_buffer_statusObject



731
732
733
734
# File 'lib/obsws/req.rb', line 731

def get_replay_buffer_status
  resp = call(:GetReplayBufferStatus)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_collection_listObject



128
129
130
131
# File 'lib/obsws/req.rb', line 128

def get_scene_collection_list
  resp = call(:GetSceneCollectionList)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_item_blend_mode(scene_name, item_id) ⇒ Object



698
699
700
701
702
# File 'lib/obsws/req.rb', line 698

def get_scene_item_blend_mode(scene_name, item_id)
  payload = {sceneName: scene_name, sceneItemId: item_id}
  resp = call(:GetSceneItemBlendMode, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_item_enabled(scene_name, item_id) ⇒ Object



653
654
655
656
657
# File 'lib/obsws/req.rb', line 653

def get_scene_item_enabled(scene_name, item_id)
  payload = {sceneName: scene_name, sceneItemId: item_id}
  resp = call(:GetSceneItemEnabled, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_item_id(scene_name, source_name, offset = nil) ⇒ Object



603
604
605
606
607
608
609
610
611
# File 'lib/obsws/req.rb', line 603

def get_scene_item_id(scene_name, source_name, offset = nil)
  payload = {
    sceneName: scene_name,
    sourceName: source_name,
    searchOffset: offset
  }
  resp = call(:GetSceneItemId, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_item_index(scene_name, item_id) ⇒ Object



683
684
685
686
687
# File 'lib/obsws/req.rb', line 683

def get_scene_item_index(scene_name, item_id)
  payload = {sceneName: scene_name, sceneItemId: item_id}
  resp = call(:GetSceneItemIndex, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_item_list(name) ⇒ Object



591
592
593
594
595
# File 'lib/obsws/req.rb', line 591

def get_scene_item_list(name)
  payload = {sceneName: name}
  resp = call(:GetSceneItemList, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_item_locked(scene_name, item_id) ⇒ Object



668
669
670
671
672
# File 'lib/obsws/req.rb', line 668

def get_scene_item_locked(scene_name, item_id)
  payload = {sceneName: scene_name, sceneItemId: item_id}
  resp = call(:GetSceneItemLocked, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_item_transform(scene_name, item_id) ⇒ Object



638
639
640
641
642
# File 'lib/obsws/req.rb', line 638

def get_scene_item_transform(scene_name, item_id)
  payload = {sceneName: scene_name, sceneItemId: item_id}
  resp = call(:GetSceneItemTransform, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_listObject



258
259
260
261
# File 'lib/obsws/req.rb', line 258

def get_scene_list
  resp = call(:GetSceneList)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_scene_transition_override(name) ⇒ Object



303
304
305
306
307
# File 'lib/obsws/req.rb', line 303

def get_scene_scene_transition_override(name)
  payload = {sceneName: name}
  resp = call(:GetSceneSceneTransitionOverride, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_scene_transition_listObject



472
473
474
475
# File 'lib/obsws/req.rb', line 472

def get_scene_transition_list
  resp = call(:GetSceneTransitionList)
  Mixin::Response.new(resp, resp.keys)
end

#get_source_active(name) ⇒ Object



220
221
222
223
224
# File 'lib/obsws/req.rb', line 220

def get_source_active(name)
  payload = {sourceName: name}
  resp = call(:GetSourceActive, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_source_filter(source_name, filter_name) ⇒ Object



552
553
554
555
556
# File 'lib/obsws/req.rb', line 552

def get_source_filter(source_name, filter_name)
  payload = {sourceName: source_name, filterName: filter_name}
  resp = call(:GetSourceFilter, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_source_filter_default_settings(kind) ⇒ Object



517
518
519
520
521
# File 'lib/obsws/req.rb', line 517

def get_source_filter_default_settings(kind)
  payload = {filterKind: kind}
  resp = call(:GetSourceFilterDefaultSettings, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_source_filter_list(name) ⇒ Object



511
512
513
514
515
# File 'lib/obsws/req.rb', line 511

def get_source_filter_list(name)
  payload = {sourceName: name}
  resp = call(:GetSourceFilterList, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_source_screenshot(name, img_format, width, height, quality) ⇒ Object



226
227
228
229
230
231
232
233
234
235
236
# File 'lib/obsws/req.rb', line 226

def get_source_screenshot(name, img_format, width, height, quality)
  payload = {
    sourceName: name,
    imageFormat: img_format,
    imageWidth: width,
    imageHeight: height,
    imageCompressionQuality: quality
  }
  resp = call(:GetSourceScreenshot, payload)
  Mixin::Response.new(resp, resp.keys)
end

#get_special_inputsObject



330
331
332
333
# File 'lib/obsws/req.rb', line 330

def get_special_inputs
  resp = call(:GetSpecialInputs)
  Mixin::Response.new(resp, resp.keys)
end

#get_statsObject



67
68
69
70
# File 'lib/obsws/req.rb', line 67

def get_stats
  resp = call(:GetStats)
  Mixin::Response.new(resp, resp.keys)
end

#get_stream_service_settingsObject



202
203
204
205
# File 'lib/obsws/req.rb', line 202

def get_stream_service_settings
  resp = call(:GetStreamServiceSettings)
  Mixin::Response.new(resp, resp.keys)
end

#get_stream_statusObject



796
797
798
799
# File 'lib/obsws/req.rb', line 796

def get_stream_status
  resp = call(:GetStreamStatus)
  Mixin::Response.new(resp, resp.keys)
end

#get_studio_mode_enabledObject



869
870
871
872
# File 'lib/obsws/req.rb', line 869

def get_studio_mode_enabled
  resp = call(:GetStudioModeEnabled)
  Mixin::Response.new(resp, resp.keys)
end

#get_transition_kind_listObject



467
468
469
470
# File 'lib/obsws/req.rb', line 467

def get_transition_kind_list
  resp = call(:GetTransitionKindList)
  Mixin::Response.new(resp, resp.keys)
end

#get_versionObject



62
63
64
65
# File 'lib/obsws/req.rb', line 62

def get_version
  resp = call(:GetVersion)
  Mixin::Response.new(resp, resp.keys)
end

#get_video_settingsObject



178
179
180
181
# File 'lib/obsws/req.rb', line 178

def get_video_settings
  resp = call(:GetVideoSettings)
  Mixin::Response.new(resp, resp.keys)
end

#get_virtual_cam_statusObject



713
714
715
716
# File 'lib/obsws/req.rb', line 713

def get_virtual_cam_status
  resp = call(:GetVirtualCamStatus)
  Mixin::Response.new(resp, resp.keys)
end

#offset_media_input_cursor(name, offset) ⇒ Object



859
860
861
862
# File 'lib/obsws/req.rb', line 859

def offset_media_input_cursor(name, offset)
  payload = {inputName: name, mediaCursorOffset: offset}
  call(:OffsetMediaInputCursor, payload)
end

#open_input_filters_dialog(name) ⇒ Object



884
885
886
887
# File 'lib/obsws/req.rb', line 884

def open_input_filters_dialog(name)
  payload = {inputName: name}
  call(:OpenInputFiltersDialog, payload)
end

#open_input_interact_dialog(name) ⇒ Object



889
890
891
892
# File 'lib/obsws/req.rb', line 889

def open_input_interact_dialog(name)
  payload = {inputName: name}
  call(:OpenInputInteractDialog, payload)
end

#open_input_properties_dialog(name) ⇒ Object



879
880
881
882
# File 'lib/obsws/req.rb', line 879

def open_input_properties_dialog(name)
  payload = {inputName: name}
  call(:OpenInputPropertiesDialog, payload)
end

#pause_recordObject



840
841
842
# File 'lib/obsws/req.rb', line 840

def pause_record
  call(:PauseRecord)
end

#press_input_properties_button(input_name, prop_name) ⇒ Object



462
463
464
465
# File 'lib/obsws/req.rb', line 462

def press_input_properties_button(input_name, prop_name)
  payload = {inputName: input_name, propertyName: prop_name}
  call(:PressInputPropertiesButton, payload)
end

#remove_input(name) ⇒ Object



353
354
355
356
# File 'lib/obsws/req.rb', line 353

def remove_input(name)
  payload = {inputName: name}
  call(:RemoveInput, payload)
end

#remove_profile(name) ⇒ Object



158
159
160
161
# File 'lib/obsws/req.rb', line 158

def remove_profile(name)
  payload = {profileName: name}
  call(:RemoveProfile, payload)
end

#remove_scene(name) ⇒ Object



293
294
295
296
# File 'lib/obsws/req.rb', line 293

def remove_scene(name)
  payload = {sceneName: name}
  call(:RemoveScene, payload)
end

#remove_scene_item(scene_name, item_id) ⇒ Object



623
624
625
626
# File 'lib/obsws/req.rb', line 623

def remove_scene_item(scene_name, item_id)
  payload = {sceneName: scene_name, sceneItemId: item_id}
  call(:RemoveSceneItem, payload)
end

#remove_source_filter(source_name, filter_name) ⇒ Object



538
539
540
541
# File 'lib/obsws/req.rb', line 538

def remove_source_filter(source_name, filter_name)
  payload = {sourceName: source_name, filterName: filter_name}
  call(:RemoveSourceFilter, payload)
end

#resume_recordObject



844
845
846
# File 'lib/obsws/req.rb', line 844

def resume_record
  call(:ResumeRecord)
end

#runObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/obsws/req.rb', line 31

def run
  yield(self)
ensure
  stop_driver
  WaitUtil.wait_for_condition(
    "driver to close",
    delay_sec: 0.01,
    timeout_sec: 1
  ) { @base_client.closed }
end

#save_replay_bufferObject



749
750
751
# File 'lib/obsws/req.rb', line 749

def save_replay_buffer
  call(:SaveReplayBuffer)
end

#save_source_screenshot(name, img_format, file_path, width, height, quality) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/obsws/req.rb', line 238

def save_source_screenshot(
  name,
  img_format,
  file_path,
  width,
  height,
  quality
)
  payload = {
    sourceName: name,
    imageFormat: img_format,
    imageFilePath: file_path,
    imageWidth: width,
    imageHeight: height,
    imageCompressionQuality: quality
  }
  resp = call(:SaveSourceScreenshot, payload)
  Mixin::Response.new(resp, resp.keys)
end

#send_stream_caption(caption) ⇒ Object



814
815
816
# File 'lib/obsws/req.rb', line 814

def send_stream_caption(caption)
  call(:SendStreamCaption)
end

#set_current_preview_scene(name) ⇒ Object



283
284
285
286
# File 'lib/obsws/req.rb', line 283

def set_current_preview_scene(name)
  payload = {sceneName: name}
  call(:SetCurrentPreviewScene, payload)
end

#set_current_profile(name) ⇒ Object



148
149
150
151
# File 'lib/obsws/req.rb', line 148

def set_current_profile(name)
  payload = {profileName: name}
  call(:SetCurrentProfile, payload)
end

#set_current_program_scene(name) ⇒ Object



273
274
275
276
# File 'lib/obsws/req.rb', line 273

def set_current_program_scene(name)
  payload = {sceneName: name}
  call(:SetCurrentProgramScene, payload)
end

#set_current_scene_collection(name) ⇒ Object



133
134
135
136
# File 'lib/obsws/req.rb', line 133

def set_current_scene_collection(name)
  payload = {sceneCollectionName: name}
  call(:SetCurrentSceneCollection, payload)
end

#set_current_scene_transition(name) ⇒ Object



482
483
484
485
# File 'lib/obsws/req.rb', line 482

def set_current_scene_transition(name)
  payload = {transitionName: name}
  call(:SetCurrentSceneTransition, payload)
end

#set_current_scene_transition_duration(duration) ⇒ Object



487
488
489
490
# File 'lib/obsws/req.rb', line 487

def set_current_scene_transition_duration(duration)
  payload = {transitionDuration: duration}
  call(:SetCurrentSceneTransitionDuration, payload)
end

#set_current_scene_transition_settings(settings, overlay = nil) ⇒ Object



492
493
494
495
# File 'lib/obsws/req.rb', line 492

def set_current_scene_transition_settings(settings, overlay = nil)
  payload = {transitionSettings: settings, overlay: overlay}
  call(:SetCurrentSceneTransitionSettings, payload)
end

#set_input_audio_balance(name, balance) ⇒ Object



418
419
420
421
# File 'lib/obsws/req.rb', line 418

def set_input_audio_balance(name, balance)
  payload = {inputName: name, inputAudioBalance: balance}
  call(:SetInputAudioBalance, payload)
end

#set_input_audio_monitor_type(name, mon_type) ⇒ Object



440
441
442
443
# File 'lib/obsws/req.rb', line 440

def set_input_audio_monitor_type(name, mon_type)
  payload = {inputName: name, monitorType: mon_type}
  call(:SetInputAudioMonitorType, payload)
end

#set_input_audio_sync_offset(name, offset) ⇒ Object



429
430
431
432
# File 'lib/obsws/req.rb', line 429

def set_input_audio_sync_offset(name, offset)
  payload = {inputName: name, inputAudioSyncOffset: offset}
  call(:SetInputAudioSyncOffset, payload)
end

#set_input_audio_tracks(name, track) ⇒ Object



451
452
453
454
# File 'lib/obsws/req.rb', line 451

def set_input_audio_tracks(name, track)
  payload = {inputName: name, inputAudioTracks: track}
  call(:SetInputAudioTracks, payload)
end

#set_input_mute(name, muted) ⇒ Object



386
387
388
389
# File 'lib/obsws/req.rb', line 386

def set_input_mute(name, muted)
  payload = {inputName: name, inputMuted: muted}
  call(:SetInputMute, payload)
end

#set_input_name(old_name, new_name) ⇒ Object



358
359
360
361
# File 'lib/obsws/req.rb', line 358

def set_input_name(old_name, new_name)
  payload = {inputName: old_name, newInputName: new_name}
  call(:SetInputName, payload)
end

#set_input_settings(name, settings, overlay) ⇒ Object



375
376
377
378
# File 'lib/obsws/req.rb', line 375

def set_input_settings(name, settings, overlay)
  payload = {inputName: name, inputSettings: settings, overlay: overlay}
  call(:SetInputSettings, payload)
end

#set_input_volume(name, vol_mul = nil, vol_db = nil) ⇒ Object



403
404
405
406
407
408
409
410
# File 'lib/obsws/req.rb', line 403

def set_input_volume(name, vol_mul = nil, vol_db = nil)
  payload = {
    inputName: name,
    inputVolumeMul: vol_mul,
    inputVolumeDb: vol_db
  }
  call(:SetInputVolume, payload)
end

#set_media_input_cursor(name, cursor) ⇒ Object



854
855
856
857
# File 'lib/obsws/req.rb', line 854

def set_media_input_cursor(name, cursor)
  payload = {inputName: name, mediaCursor: cursor}
  call(:SetMediaInputCursor, payload)
end

#set_output_settings(name, settings) ⇒ Object



791
792
793
794
# File 'lib/obsws/req.rb', line 791

def set_output_settings(name, settings)
  payload = {outputName: name, outputSettings: settings}
  call(:SetOutputSettings, payload)
end

#set_persistent_data(realm, slot_name, slot_value) ⇒ Object



123
124
125
126
# File 'lib/obsws/req.rb', line 123

def set_persistent_data(realm, slot_name, slot_value)
  payload = {realm: realm, slotName: slot_name, slotValue: slot_value}
  call(:SetPersistentData, payload)
end

#set_profile_parameter(category, name, value) ⇒ Object



169
170
171
172
173
174
175
176
# File 'lib/obsws/req.rb', line 169

def set_profile_parameter(category, name, value)
  payload = {
    parameterCategory: category,
    parameterName: name,
    parameterValue: value
  }
  call(:SetProfileParameter, payload)
end

#set_scene_item_blend_mode(scene_name, item_id, blend) ⇒ Object



704
705
706
707
708
709
710
711
# File 'lib/obsws/req.rb', line 704

def set_scene_item_blend_mode(scene_name, item_id, blend)
  payload = {
    sceneName: scene_name,
    sceneItemId: item_id,
    sceneItemBlendMode: blend
  }
  call(:SetSceneItemBlendMode, payload)
end

#set_scene_item_enabled(scene_name, item_id, enabled) ⇒ Object



659
660
661
662
663
664
665
666
# File 'lib/obsws/req.rb', line 659

def set_scene_item_enabled(scene_name, item_id, enabled)
  payload = {
    sceneName: scene_name,
    sceneItemId: item_id,
    sceneItemEnabled: enabled
  }
  call(:SetSceneItemEnabled, payload)
end

#set_scene_item_index(scene_name, item_id, item_index) ⇒ Object



689
690
691
692
693
694
695
696
# File 'lib/obsws/req.rb', line 689

def set_scene_item_index(scene_name, item_id, item_index)
  payload = {
    sceneName: scene_name,
    sceneItemId: item_id,
    sceneItemIndex: item_index
  }
  call(:SetSceneItemIndex, payload)
end

#set_scene_item_locked(scene_name, item_id, locked) ⇒ Object



674
675
676
677
678
679
680
681
# File 'lib/obsws/req.rb', line 674

def set_scene_item_locked(scene_name, item_id, locked)
  payload = {
    sceneName: scene_name,
    sceneItemId: item_id,
    sceneItemLocked: locked
  }
  call(:SetSceneItemLocked, payload)
end

#set_scene_item_transform(scene_name, item_id, transform) ⇒ Object



644
645
646
647
648
649
650
651
# File 'lib/obsws/req.rb', line 644

def set_scene_item_transform(scene_name, item_id, transform)
  payload = {
    sceneName: scene_name,
    sceneItemId: item_id,
    sceneItemTransform: transform
  }
  call(:SetSceneItemTransform, payload)
end

#set_scene_name(old_name, new_name) ⇒ Object



298
299
300
301
# File 'lib/obsws/req.rb', line 298

def set_scene_name(old_name, new_name)
  payload = {sceneName: old_name, newSceneName: new_name}
  call(:SetSceneName, payload)
end

#set_scene_scene_transition_override(scene_name, tr_name, tr_duration) ⇒ Object



309
310
311
312
313
314
315
316
# File 'lib/obsws/req.rb', line 309

def set_scene_scene_transition_override(scene_name, tr_name, tr_duration)
  payload = {
    sceneName: scene_name,
    transitionName: tr_name,
    transitionDuration: tr_duration
  }
  call(:SetSceneSceneTransitionOverride, payload)
end

#set_source_filter_enabled(source_name, filter_name, enabled) ⇒ Object



582
583
584
585
586
587
588
589
# File 'lib/obsws/req.rb', line 582

def set_source_filter_enabled(source_name, filter_name, enabled)
  payload = {
    sourceName: source_name,
    filterName: filter_name,
    filterEnabled: enabled
  }
  call(:SetSourceFilterEnabled, payload)
end

#set_source_filter_index(source_name, filter_name, filter_index) ⇒ Object



558
559
560
561
562
563
564
565
# File 'lib/obsws/req.rb', line 558

def set_source_filter_index(source_name, filter_name, filter_index)
  payload = {
    sourceName: source_name,
    filterName: filter_name,
    filterIndex: filter_index
  }
  call(:SetSourceFilterIndex, payload)
end

#set_source_filter_name(source_name, old_filter_name, new_filter_name) ⇒ Object



543
544
545
546
547
548
549
550
# File 'lib/obsws/req.rb', line 543

def set_source_filter_name(source_name, old_filter_name, new_filter_name)
  payload = {
    sourceName: source_name,
    filterName: old_filter_name,
    newFilterName: new_filter_name
  }
  call(:SetSourceFilterName, payload)
end

#set_source_filter_settings(source_name, filter_name, settings, overlay = nil) ⇒ Object



567
568
569
570
571
572
573
574
575
576
577
578
579
580
# File 'lib/obsws/req.rb', line 567

def set_source_filter_settings(
  source_name,
  filter_name,
  settings,
  overlay = nil
)
  payload = {
    sourceName: source_name,
    filterName: filter_name,
    filterSettings: settings,
    overlay: overlay
  }
  call(:SetSourceFilterSettings, payload)
end

#set_stream_service_settings(ss_type, ss_settings) ⇒ Object



207
208
209
210
211
212
213
# File 'lib/obsws/req.rb', line 207

def set_stream_service_settings(ss_type, ss_settings)
  payload = {
    streamServiceType: ss_type,
    streamServiceSettings: ss_settings
  }
  call(:SetStreamServiceSettings, payload)
end

#set_studio_mode_enabled(enabled) ⇒ Object



874
875
876
877
# File 'lib/obsws/req.rb', line 874

def set_studio_mode_enabled(enabled)
  payload = {studioModeEnabled: enabled}
  call(:SetStudioModeEnabled, payload)
end

#set_t_bar_position(pos, release = nil) ⇒ Object



506
507
508
509
# File 'lib/obsws/req.rb', line 506

def set_t_bar_position(pos, release = nil)
  payload = {position: pos, release: release}
  call(:SetTBarPosition, payload)
end

#set_video_settings(numerator, denominator, base_width, base_height, out_width, out_height) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/obsws/req.rb', line 183

def set_video_settings(
  numerator,
  denominator,
  base_width,
  base_height,
  out_width,
  out_height
)
  payload = {
    fpsNumerator: numerator,
    fpsDenominator: denominator,
    baseWidth: base_width,
    baseHeight: base_height,
    outputWidth: out_width,
    outputHeight: out_height
  }
  call(:SetVideoSettings, payload)
end

#sleep(sleep_millis = nil, sleep_frames = nil) ⇒ Object



112
113
114
115
# File 'lib/obsws/req.rb', line 112

def sleep(sleep_millis = nil, sleep_frames = nil)
  payload = {sleepMillis: sleep_millis, sleepFrames: sleep_frames}
  call(:Sleep, payload)
end

#start_output(name) ⇒ Object



775
776
777
778
# File 'lib/obsws/req.rb', line 775

def start_output(name)
  payload = {outputName: name}
  call(:StartOutput, payload)
end

#start_recordObject



827
828
829
# File 'lib/obsws/req.rb', line 827

def start_record
  call(:StartRecord)
end

#start_replay_bufferObject



741
742
743
# File 'lib/obsws/req.rb', line 741

def start_replay_buffer
  call(:StartReplayBuffer)
end

#start_streamObject



806
807
808
# File 'lib/obsws/req.rb', line 806

def start_stream
  call(:StartStream)
end

#start_virtual_camObject



723
724
725
# File 'lib/obsws/req.rb', line 723

def start_virtual_cam
  call(:StartVirtualCam)
end

#stop_output(name) ⇒ Object



780
781
782
783
# File 'lib/obsws/req.rb', line 780

def stop_output(name)
  payload = {outputName: name}
  call(:StopOutput, payload)
end

#stop_recordObject



831
832
833
834
# File 'lib/obsws/req.rb', line 831

def stop_record
  resp = call(:StopRecord)
  Mixin::Response.new(resp, resp.keys)
end

#stop_replay_bufferObject



745
746
747
# File 'lib/obsws/req.rb', line 745

def stop_replay_buffer
  call(:StopReplayBuffer)
end

#stop_streamObject



810
811
812
# File 'lib/obsws/req.rb', line 810

def stop_stream
  call(:StopStream)
end

#stop_virtual_camObject



727
728
729
# File 'lib/obsws/req.rb', line 727

def stop_virtual_cam
  call(:StopVirtualCam)
end

#to_sObject



27
28
29
# File 'lib/obsws/req.rb', line 27

def to_s
  self.class.name.split("::").last(2).join("::")
end

#toggle_input_mute(name) ⇒ Object



391
392
393
394
395
# File 'lib/obsws/req.rb', line 391

def toggle_input_mute(name)
  payload = {inputName: name}
  resp = call(:ToggleInputMute, payload)
  Mixin::Response.new(resp, resp.keys)
end

#toggle_output(name) ⇒ Object



769
770
771
772
773
# File 'lib/obsws/req.rb', line 769

def toggle_output(name)
  payload = {outputName: name}
  resp = call(:ToggleOutput, payload)
  Mixin::Response.new(resp, resp.keys)
end

#toggle_recordObject



823
824
825
# File 'lib/obsws/req.rb', line 823

def toggle_record
  call(:ToggleRecord)
end

#toggle_record_pauseObject



836
837
838
# File 'lib/obsws/req.rb', line 836

def toggle_record_pause
  call(:ToggleRecordPause)
end

#toggle_replay_bufferObject



736
737
738
739
# File 'lib/obsws/req.rb', line 736

def toggle_replay_buffer
  resp = call(:ToggleReplayBuffer)
  Mixin::Response.new(resp, resp.keys)
end

#toggle_streamObject



801
802
803
804
# File 'lib/obsws/req.rb', line 801

def toggle_stream
  resp = call(:ToggleStream)
  Mixin::Response.new(resp, resp.keys)
end

#toggle_virtual_camObject



718
719
720
721
# File 'lib/obsws/req.rb', line 718

def toggle_virtual_cam
  resp = call(:ToggleVirtualCam)
  Mixin::Response.new(resp, resp.keys)
end

#trigger_hotkey_by_key_sequence(key_id, press_shift, press_ctrl, press_alt, press_cmd) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/obsws/req.rb', line 93

def trigger_hotkey_by_key_sequence(
  key_id,
  press_shift,
  press_ctrl,
  press_alt,
  press_cmd
)
  payload = {
    keyId: key_id,
    keyModifiers: {
      shift: press_shift,
      control: press_ctrl,
      alt: press_alt,
      cmd: press_cmd
    }
  }
  call(:TriggerHotkeyByKeySequence, payload)
end

#trigger_hotkey_by_name(name) ⇒ Object



88
89
90
91
# File 'lib/obsws/req.rb', line 88

def trigger_hotkey_by_name(name)
  payload = {hotkeyName: name}
  call(:TriggerHotkeyByName, payload)
end

#trigger_media_input_action(name, action) ⇒ Object



864
865
866
867
# File 'lib/obsws/req.rb', line 864

def trigger_media_input_action(name, action)
  payload = {inputName: name, mediaAction: action}
  call(:TriggerMediaInputAction, payload)
end

#trigger_studio_mode_transitionObject



502
503
504
# File 'lib/obsws/req.rb', line 502

def trigger_studio_mode_transition
  call(:TriggerStudioModeTransition)
end