summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@fairlystable.org>2022-11-12 16:45:05 -0800
committerJoe Rayhawk <jrayhawk@fairlystable.org>2022-11-12 16:45:05 -0800
commit0c687f34d89e69a2304aa3114a77033104e776d6 (patch)
tree0a1d4c99ad35e8572c2da2f6b94eea4e5702ad94 /src
parent5794be9dec63f7597833ca988e1237275f52a443 (diff)
downloadcrystal-obs-websocket-0c687f34d89e69a2304aa3114a77033104e776d6.tar.gz
crystal-obs-websocket-0c687f34d89e69a2304aa3114a77033104e776d6.zip
Events: fill out potential event list and note needed work
Diffstat (limited to 'src')
-rw-r--r--src/obswebsocket.cr80
1 files changed, 77 insertions, 3 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr
index 8e15911..b02abdf 100644
--- a/src/obswebsocket.cr
+++ b/src/obswebsocket.cr
@@ -37,7 +37,7 @@ module OBSWebSocket
class Server
@@reqchan = Channel( Tuple( ( Channel( JSON::Any ) | Nil ), String ) ).new
- @scenecollection = OBSWebSocket::SceneCollection.new( @@reqchan )
+ @scenecollection = OBSWebSocket::SceneCollection.new( @@reqchan, @@inputs )
@@inputs = OBSWebSocket::Inputs.new( @@reqchan )
@@scenes = OBSWebSocket::SceneList.new( @@reqchan, @@inputs )
@sources = OBSWebSocket::Sources.new( @@reqchan, @@inputs, @@scenes )
@@ -207,6 +207,7 @@ module OBSWebSocket
@connecterror = 0
self.reqchan.send( { nil, "clear queue" } )
when 5 # event
+ # FIXME: These should be switched over to Enum flags
eventsubs.each do | eventchan |
eventchan.send( json["d"] )
end
@@ -220,6 +221,30 @@ module OBSWebSocket
when "CurrentProgramSceneChanged"
edata = d["eventData"]
@@scenes.programcache( edata["sceneName"].as_s )
+ when "CurrentSceneCollectionChanging"
+ # FIXME: switch to queue in reqchan
+ @scenecollection.deletecache()
+ @@scenes.deletecache()
+ when "CurrentSceneCollectionChanged"
+ # FIXME: empty queue in reqchan
+ @scenecollection.deletecache()
+ @@scenes.deletecache()
+ edata = d["eventData"]
+ @scenecollection.currentcache( edata["sceneCollectionName"].as_s )
+ when "SceneCollectionListChanged"
+ @scenecollection.deletecache()
+ # FIXME: Save requests by using the edata here
+ when "CurrentProfileChanging"
+ when "CurrentProfileChanged"
+ when "ProfileListChanged"
+ when "SceneListChanged"
+ # FIXME
+ when "SceneCreated"
+ # FIXME
+ when "SceneRemoved"
+ # FIXME
+ when "SceneNameChanged"
+ # FIXME
when "InputCreated"
edata = d["eventData"]
@@inputs[edata["inputName"].to_s] = OBSWebSocket::Input.new( @@reqchan, edata )
@@ -229,12 +254,36 @@ module OBSWebSocket
when "InputRemoved"
edata = d["eventData"]
@@inputs.deletecache( edata["inputName"].as_s )
+ when "InputActiveStateChanged"
+ when "InputShowStateChanged"
+ when "InputMuteStateChanged"
+ when "InputVolumeChanged"
+ when "InputAudioBalanceChanged"
+ when "InputAudioSyncOffsetChanged"
+ when "InputAudioTracksChanged"
+ when "InputAudioMonitorTypeChanged"
+ when "InputVolumeMeters"
+ when "MediaInputPlaybackStarted"
+ when "MediaInputPlaybackEnded"
+ when "MediaInputActionTriggered"
+ when "CurrentSceneTransitionChanged"
+ when "CurrentSceneTransitionDurationChanged"
+ when "StudioModeStateChanged"
+ when "SceneTransitionStarted"
+ when "SceneTransitionEnded"
+ when "SceneTransitionVideoEnded"
+ when "SceneItemSelected"
+ when "SceneItemCreated"
+ # FIXME
when "SceneItemRemoved"
edata = d["eventData"]
@@scenes[edata["sceneName"].to_s].deletecache( edata["sceneItemId"].as_i64, edata["sourceName"].as_s )
when "SceneItemEnableStateChanged"
edata = d["eventData"]
@@scenes[edata["sceneName"].as_s][edata["sceneItemId"].as_i64].enabledcache( edata["sceneItemEnabled"].as_bool )
+ when "SceneItemListReindexed"
+ # FIXME
+ when "SceneItemLockStateChanged"
when "SceneItemTransformChanged"
edata = d["eventData"]
transform = edata["sceneItemTransform"]
@@ -253,6 +302,19 @@ module OBSWebSocket
else
raise SourceMissingException.new( "SourceFilterEnableStateChanged: missing source #{ edata["sourceName"].as_s}" )
end
+ when "SourceFilterListReindexed"
+ # FIXME
+ when "SourceFilterCreated"
+ # FIXME
+ when "SourceFilterRemoved"
+ # FIXME
+ when "SourceFilterNameChanged"
+ # FIXME
+ when "StreamStateChanged"
+ when "RecordStateChanged"
+ when "ReplayBufferStateChanged"
+ when "VirtualcamStateChanged"
+ when "ReplayBufferSaved"
end
end
Fiber.yield
@@ -435,7 +497,7 @@ module OBSWebSocket
@current = String.new
@list = Hash( String, OBSWebSocket::SceneList ).new
@reqchan = Channel( Tuple( Channel( JSON::Any ) | Nil, String ) ).new
- def initialize( @reqchan : Channel( Tuple( Channel( JSON::Any ) | Nil, String ) ) )
+ def initialize( @reqchan : Channel( Tuple( Channel( JSON::Any ) | Nil, String ) ), @inputs : OBSWebSocket::Inputs )
end
def populate
reschan = Channel( JSON::Any ).new
@@ -444,7 +506,7 @@ module OBSWebSocket
if ( rdata = d["responseData"]? )
@current = rdata["currentSceneCollectionName"].as_s
rdata["sceneCollections"].as_a.each{ | scenecollection |
- @list[scenecollection.as_s] = OBSWebSocket::SceneList.new( @reqchan )
+ @list[scenecollection.as_s] = OBSWebSocket::SceneList.new( @reqchan, @inputs )
}
else
raise ResponseDataMissingException.new( "#{d["requestType"].as_s} #{d["requestStatus"]["code"].as_i64}: #{d["requestStatus"]["comment"].as_s}" )
@@ -462,6 +524,12 @@ module OBSWebSocket
self.populate
end
end
+ def deletecache()
+ @current = String.new
+ @list = Hash( String, OBSWebSocket::SceneList ).new
+ end
+ def currentcache( @current : String )
+ end
end
class SceneList # Note: distinct from SceneCollection
@@ -530,6 +598,12 @@ module OBSWebSocket
@scenes.empty? && populate
return @scenes
end
+ def deletecache()
+ @scenes_by_index = Array(String).new
+ @scenes = Hash(String, OBSWebSocket::Scene).new
+ @program = String.new
+ @preview = String.new
+ end
end
class Scene