diff options
author | Joe Rayhawk <jrayhawk@fairlystable.org> | 2022-10-29 16:22:19 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@fairlystable.org> | 2022-10-29 16:22:19 -0700 |
commit | 139d4bda3444725e4ef13993be2163e5ffc17f23 (patch) | |
tree | a9f2eb1bfde98ff72ed459b7f2a09923bff1de53 | |
parent | 0a35d33f974f0d1f81e6d4cc2d718a5ef81237b0 (diff) | |
download | crystal-obs-websocket-139d4bda3444725e4ef13993be2163e5ffc17f23.tar.gz crystal-obs-websocket-139d4bda3444725e4ef13993be2163e5ffc17f23.zip |
Cache last known real SceneItemTransform
This can be used to derive a useful sourceHeight and sourceWidth
on sources that initialize at 0.
-rw-r--r-- | src/obswebsocket.cr | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr index 3978b47..f8e7e3e 100644 --- a/src/obswebsocket.cr +++ b/src/obswebsocket.cr @@ -40,7 +40,7 @@ module OBSWebSocket @scenecollection = OBSWebSocket::SceneCollection.new( @@reqchan ) @@inputs = OBSWebSocket::Inputs.new( @@reqchan ) @@scenes = OBSWebSocket::SceneList.new( @@reqchan, @@inputs ) - @sources = OBSWebSocket::Sources.new( @@inputs, @@scenes ) + @sources = OBSWebSocket::Sources.new( @@reqchan, @@inputs, @@scenes ) @outputs = OBSWebSocket::Outputs.new( @@reqchan ) @video = OBSWebSocket::VideoSettings.new( @@reqchan ) @stats = OBSWebSocket::Stats.new( @@reqchan ) @@ -702,7 +702,8 @@ module OBSWebSocket class Sources getter scenes : OBSWebSocket::SceneList getter inputs : OBSWebSocket::Inputs - def initialize( @inputs : OBSWebSocket::Inputs, @scenes : OBSWebSocket::SceneList ) + @last_known_real_transform = Hash( String, OBSWebSocket::SceneItemTransform ).new + def initialize( @reqchan : Channel( Tuple( Channel( JSON::Any ) | Nil, String ) ), @inputs : OBSWebSocket::Inputs, @scenes : OBSWebSocket::SceneList ) end def []?( index : String ) : OBSWebSocket::Scene | OBSWebSocket::Input | Nil if @inputs[index]? @@ -716,6 +717,15 @@ module OBSWebSocket def to_h() : Hash( String, OBSWebSocket::Scene | OBSWebSocket::Input ) return @inputs.to_h.merge( @scenes.to_h ) end + def last_known_real_transform_add( sourcename : String, transform : JSON::Any ) + @last_known_real_transform[ sourcename ] = OBSWebSocket::SceneItemTransform.new( @reqchan, transform, sourcename, 0.to_i64 ) + end + def last_known_real_transform( sourcename : String ) : OBSWebSocket::SceneItemTransform + @last_known_real_transform[ sourcename ] + end + def last_known_real_transform?( sourcename : String ) : OBSWebSocket::SceneItemTransform | Nil + @last_known_real_transform[ sourcename ]? + end end class Inputs |