diff options
author | Manuel Bentele | 2021-08-11 12:13:34 +0200 |
---|---|---|
committer | Manuel Bentele | 2021-08-11 12:13:34 +0200 |
commit | a01e54ea3bcfe23ed35089b3cfcc6bf654e6000d (patch) | |
tree | 7cf50efe12f0576b9f175df9a80671c5b22256eb | |
parent | Add unit tests for Libvirt mediated device addresses (diff) | |
download | master-sync-shared-a01e54ea3bcfe23ed35089b3cfcc6bf654e6000d.tar.gz master-sync-shared-a01e54ea3bcfe23ed35089b3cfcc6bf654e6000d.tar.xz master-sync-shared-a01e54ea3bcfe23ed35089b3cfcc6bf654e6000d.zip |
Add compression and listen types to Libvirt graphics devices
-rw-r--r-- | src/main/java/org/openslx/libvirt/domain/device/Graphics.java | 75 | ||||
-rw-r--r-- | src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java | 177 |
2 files changed, 251 insertions, 1 deletions
diff --git a/src/main/java/org/openslx/libvirt/domain/device/Graphics.java b/src/main/java/org/openslx/libvirt/domain/device/Graphics.java index 02c8b01..2b839c7 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/Graphics.java +++ b/src/main/java/org/openslx/libvirt/domain/device/Graphics.java @@ -29,6 +29,27 @@ public class Graphics extends Device } /** + * Returns the listen type of the graphics device. + * + * @return listen type of the graphics device. + */ + public ListenType getListenType() + { + final String listenType = this.getXmlElementAttributeValue( "listen", "type" ); + return ListenType.fromString( listenType ); + } + + /** + * Sets the listen type for the graphics device. + * + * @param type listen type for the graphics device. + */ + public void setListenType( ListenType type ) + { + this.setXmlElementAttributeValue( "listen", "type", type.toString() ); + } + + /** * Creates a non-existent graphics device as Libvirt XML device element. * * @param graphics graphics device that is created. @@ -78,6 +99,60 @@ public class Graphics extends Device } /** + * Listen type of graphics device. + * + * @author Manuel Bentele + * @version 1.0 + */ + enum ListenType + { + // @formatter:off + NONE ( "none" ), + ADDRESS( "address" ), + NETWORK( "network" ), + SOCKET ( "socket" ); + // @formatter:on + + /** + * Name of graphics device listen type. + */ + private String type = null; + + /** + * Creates graphics device listen type. + * + * @param type valid name of the graphics device listen type in a Libvirt domain XML document. + */ + ListenType( String type ) + { + this.type = type; + } + + @Override + public String toString() + { + return this.type; + } + + /** + * Creates graphics device listen type from its name with error check. + * + * @param type name of the graphics device listen type in a Libvirt domain XML document. + * @return valid graphics device listen type. + */ + public static ListenType fromString( String type ) + { + for ( ListenType t : ListenType.values() ) { + if ( t.type.equalsIgnoreCase( type ) ) { + return t; + } + } + + return null; + } + } + + /** * Type of graphics device. * * @author Manuel Bentele diff --git a/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java b/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java index 4d06f78..2b5a12c 100644 --- a/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java +++ b/src/main/java/org/openslx/libvirt/domain/device/GraphicsSpice.java @@ -32,7 +32,7 @@ public class GraphicsSpice extends Graphics /** * Returns the state whether OpenGL hardware acceleration is enabled or not. * - * @return tate whether OpenGL hardware acceleration is enabled or not. + * @return state whether OpenGL hardware acceleration is enabled or not. */ public boolean isOpenGlEnabled() { @@ -50,6 +50,68 @@ public class GraphicsSpice extends Graphics } /** + * Returns the image compression type. + * + * @return image compression type. + */ + public ImageCompression getImageCompression() + { + final String imageCompression = this.getXmlElementAttributeValue( "image", "compression" ); + return ImageCompression.fromString( imageCompression ); + } + + /** + * Sets the image compression type. + * + * @param type image compression type. + */ + public void setImageCompression( ImageCompression type ) + { + this.setXmlElementAttributeValue( "image", "compression", type.toString() ); + } + + /** + * Checks if audio playback compression is enabled or not. + * + * @return state whether audio playback compression is enabled or not. + */ + public boolean isPlaybackCompressionOn() + { + return this.getXmlElementAttributeValueAsBool( "playback", "compression" ); + } + + /** + * Sets the state whether audio playback compression is enabled or not. + * + * @param enabled state whether audio playback compression is enabled or not. + */ + public void setPlaybackCompression( boolean enabled ) + { + this.setXmlElementAttributeValueOnOff( "playback", "compression", enabled ); + } + + /** + * Returns the streaming mode. + * + * @return streaming mode type. + */ + public StreamingMode getStreamingMode() + { + final String streamingMode = this.getXmlElementAttributeValue( "streaming", "mode" ); + return StreamingMode.fromString( streamingMode ); + } + + /** + * Sets the streaming mode. + * + * @param type streaming mode type. + */ + public void setStreamingMode( StreamingMode type ) + { + this.setXmlElementAttributeValue( "streaming", "mode", type.toString() ); + } + + /** * Creates a non-existent graphics SPICE device as Libvirt XML device element. * * @param xmlNode Libvirt XML node of the Libvirt XML device that is created. @@ -71,4 +133,117 @@ public class GraphicsSpice extends Graphics { return new GraphicsSpice( xmlNode ); } + + /** + * Image compression type of graphics device. + * + * @author Manuel Bentele + * @version 1.0 + */ + enum ImageCompression + { + // @formatter:off + AUTO_GLZ( "auto_glz" ), + AUTO_LZ ( "auto_lz" ), + QUIC ( "quic" ), + GLZ ( "glz" ), + LZ ( "lz" ), + OFF ( "off" ); + // @formatter:on + + /** + * Name of graphics device image compression type. + */ + private String type = null; + + /** + * Creates graphics device image compression type. + * + * @param type valid name of the graphics device image compression type in a Libvirt domain + * XML document. + */ + ImageCompression( String type ) + { + this.type = type; + } + + @Override + public String toString() + { + return this.type; + } + + /** + * Creates graphics device image compression type from its name with error check. + * + * @param type name of the graphics device image compression type in a Libvirt domain XML + * document. + * @return valid graphics device image compression type. + */ + public static ImageCompression fromString( String type ) + { + for ( ImageCompression t : ImageCompression.values() ) { + if ( t.type.equalsIgnoreCase( type ) ) { + return t; + } + } + + return null; + } + } + + /** + * Streaming mode type of graphics device. + * + * @author Manuel Bentele + * @version 1.0 + */ + enum StreamingMode + { + // @formatter:off + ALL ( "all" ), + FILTER( "filter" ), + OFF ( "off" ); + // @formatter:on + + /** + * Name of graphics device image compression type. + */ + private String type = null; + + /** + * Creates graphics device streaming mode type. + * + * @param type valid name of the graphics device streaming mode type in a Libvirt domain XML + * document. + */ + StreamingMode( String type ) + { + this.type = type; + } + + @Override + public String toString() + { + return this.type; + } + + /** + * Creates graphics device streaming mode type from its name with error check. + * + * @param type name of the graphics device streaming mode type in a Libvirt domain XML + * document. + * @return valid graphics device streaming mode type. + */ + public static StreamingMode fromString( String type ) + { + for ( StreamingMode t : StreamingMode.values() ) { + if ( t.type.equalsIgnoreCase( type ) ) { + return t; + } + } + + return null; + } + } } |