Support for video area selection (revision range 2467:2563 from branches/javaviewer-selectvideo) merged back to trunk.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2564 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/vncviewer/RfbProto.java b/java/src/com/tightvnc/vncviewer/RfbProto.java
index 89a4cae..39656fc 100644
--- a/java/src/com/tightvnc/vncviewer/RfbProto.java
+++ b/java/src/com/tightvnc/vncviewer/RfbProto.java
@@ -98,10 +98,10 @@
ClientCutText = 6;
// Non-standard client-to-server messages
- final static int
- EnableContinuousUpdates = 150;
- final static String
- SigEnableContinuousUpdates = "CUC_ENCU";
+ final static int EnableContinuousUpdates = 150;
+ final static int VideoRectangleSelection = 151;
+ final static String SigEnableContinuousUpdates = "CUC_ENCU";
+ final static String SigVideoRectangleSelection = "VRECTSEL";
// Supported encodings and pseudo-encodings
final static int
@@ -499,6 +499,9 @@
clientMsgCaps.add(EnableContinuousUpdates, TightVncVendor,
SigEnableContinuousUpdates,
"Enable/disable continuous updates");
+ clientMsgCaps.add(VideoRectangleSelection, TightVncVendor,
+ SigVideoRectangleSelection,
+ "Select a rectangle to be treated as video");
// Supported encoding types
encodingCaps.add(EncodingCopyRect, StandardVendor,
@@ -1357,6 +1360,42 @@
return continuousUpdatesActive;
}
+ /**
+ * Send a rectangle selection to be treated as video by the server (but
+ * only if VideoRectangleSelection message is supported by the server).
+ * @param rect specifies coordinates and size of the rectangule.
+ * @throws java.io.IOException
+ */
+ void trySendVideoSelection(Rectangle rect) throws IOException
+ {
+ if (!clientMsgCaps.isEnabled(VideoRectangleSelection)) {
+ System.out.println("Video area selection is not supported by the server");
+ return;
+ }
+
+ int x = rect.x;
+ int y = rect.y;
+ int w = rect.width;
+ int h = rect.height;
+
+ byte[] b = new byte[10];
+
+ b[0] = (byte) VideoRectangleSelection;
+ b[1] = (byte) 0; // reserved
+ b[2] = (byte) ((x >> 8) & 0xff);
+ b[3] = (byte) (x & 0xff);
+ b[4] = (byte) ((y >> 8) & 0xff);
+ b[5] = (byte) (y & 0xff);
+ b[6] = (byte) ((w >> 8) & 0xff);
+ b[7] = (byte) (w & 0xff);
+ b[8] = (byte) ((h >> 8) & 0xff);
+ b[9] = (byte) (h & 0xff);
+
+ os.write(b);
+
+ System.out.println("Video rectangle selection message sent");
+ }
+
//
// Compress and write the data into the recorded session file. This