]> source.dussan.org Git - tigervnc.git/commitdiff
Support for VideoRectangleSelection client message in the server code. The message...
authorConstantin Kaplinsky <const@tightvnc.com>
Thu, 24 Apr 2008 08:44:24 +0000 (08:44 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Thu, 24 Apr 2008 08:44:24 +0000 (08:44 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2559 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/SConnection.cxx
common/rfb/SConnection.h
common/rfb/SMsgReader.cxx
common/rfb/SMsgReader.h
common/rfb/SMsgReaderV3.cxx
common/rfb/VNCSConnectionST.cxx
common/rfb/VNCServerST.cxx
common/rfb/VNCServerST.h
common/rfb/msgTypes.h
unix/x0vncserver/x0vncserver.cxx

index bede90e4786d98b82b87e74792009bc030561a91..2fde9fbbecb164f13ec626ce28a630dac9837935 100644 (file)
@@ -46,7 +46,8 @@ SConnection::SConnection(SSecurityFactory* secFact, bool reverseConnection_)
   : readyForSetColourMapEntries(false),
     is(0), os(0), reader_(0), writer_(0),
     security(0), securityFactory(secFact), state_(RFBSTATE_UNINITIALISED),
-    reverseConnection(reverseConnection_)
+    reverseConnection(reverseConnection_),
+    m_videoSelectionEnabled(false)
 {
   defaultMajorVersion = 3;
   defaultMinorVersion = 8;
@@ -76,6 +77,11 @@ void SConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
   os = os_;
 }
 
+void SConnection::setProtocolOptions(bool enableVideoSelection)
+{
+  m_videoSelectionEnabled = enableVideoSelection;
+}
+
 void SConnection::initialiseProtocol()
 {
   cp.writeVersion(os);
@@ -464,10 +470,16 @@ void SConnection::sendInteractionCaps()
   ccaps.addTightExt(msgTypeFileDeleteRequest,       "FTC_RMRQ");
   */
 
-  // Continuous updates:
   ccaps.addTightExt(msgTypeEnableContinuousUpdates, "CUC_ENCU");
 
+  if (m_videoSelectionEnabled) {
+    ccaps.addTightExt(msgTypeVideoRectangleSelection, "VRECTSEL");
+  }
+
+  //
   // Advertise all supported encoding types (except raw encoding).
+  //
+
   CapsList ecaps;
 
   // First, add true encodings.
index e41ef5fb1f43d40c04f92dc7b38467caac00271f..2540ed78693da0757ec112819aabe14984f6fae4 100644 (file)
@@ -50,6 +50,11 @@ namespace rfb {
     // (i.e. SConnection will not delete them).
     void setStreams(rdr::InStream* is, rdr::OutStream* os);
 
+    // setProtocolOptions() configures TightVNC-specific protocol options.
+    // It can be optionally called before calling initialiseProtocol().
+    // See also: VNCServerST::enableVideoSelection();
+    void setProtocolOptions(bool enableVideoSelection);
+
     // initialiseProtocol() should be called once the streams and security
     // types are set.  Subsequently, processMsg() should be called whenever
     // there is data to read on the InStream.
@@ -198,6 +203,9 @@ namespace rfb {
     SSecurityFactory* securityFactory;
     stateEnum state_;
     bool reverseConnection;
+
+    // TightVNC-specific protocol options.
+    bool m_videoSelectionEnabled;
   };
 }
 #endif
index 0e57ea76bbffb1e5854211c2a664c9784043ba80..4213e728f221c1be5d61e633e92cfaecaa721bad 100644 (file)
@@ -110,3 +110,18 @@ void SMsgReader::readEnableContinuousUpdates()
   }
 }
 
+void SMsgReader::readVideoRectangleSelection()
+{
+  (void)is->readU8();
+  int x = is->readU16();
+  int y = is->readU16();
+  int w = is->readU16();
+  int h = is->readU16();
+  bool enable = w > 0 && h > 0;
+
+  // FIXME: Use proper logger.
+  fprintf(stderr, "Ignoring VideoRectangleSelection message\n");
+
+  // FIXME: Implement VideoRectangleSelection message handling.
+}
+
index 958c03a72a36fb7509f70c065d4c906fa1a586c3..997c07bfb85e854d1bf04d73519dd2f7e38ac65c 100644 (file)
@@ -49,6 +49,7 @@ namespace rfb {
 
     // Read TightVNC-specific protocol messages.
     virtual void readEnableContinuousUpdates();
+    virtual void readVideoRectangleSelection();
 
     SMsgReader(SMsgHandler* handler, rdr::InStream* is);
 
index e9b020bb1bb614f8aa21d69765438fdd2f64270f..468d74a0494fb5669538811bb3d5952a6ccf4cb0 100644 (file)
@@ -62,6 +62,7 @@ void SMsgReaderV3::readMsg()
   case msgTypeFileDeleteRequest:        handler->processFTMsg(msgType); break;
 
   case msgTypeEnableContinuousUpdates:  readEnableContinuousUpdates(); break;
+  case msgTypeVideoRectangleSelection:  readVideoRectangleSelection(); break;
 
   default:
     fprintf(stderr, "unknown message type %d\n", msgType);
index 3929b1fbc2467042ab63f17438352fd32c4b4e30..7c922cfe444a2ecb846a18e7019dd114a2f74b64 100644 (file)
@@ -87,6 +87,7 @@ VNCSConnectionST::~VNCSConnectionST()
 bool VNCSConnectionST::init()
 {
   try {
+    setProtocolOptions(server->isVideoSelectionEnabled());
     initialiseProtocol();
   } catch (rdr::Exception& e) {
     close(e.str());
index e5354a41ab0da8ec6dd23927937dcdfa9cf85b2f..93f947cf3d74c30676ca02e3e8115a5b64311259 100644 (file)
@@ -77,7 +77,8 @@ VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_,
     securityFactory(sf ? sf : &defaultSecurityFactory),
     queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance),
     useEconomicTranslate(false),
-    lastConnectionTime(0), disableclients(false)
+    lastConnectionTime(0), disableclients(false),
+    m_videoSelectionEnabled(false)
 {
   lastUserInputTime = lastDisconnectTime = time(0);
   slog.debug("creating single-threaded server %s", name.buf);
index fad8cb930af69be468f074c37d57c52a4ee657fd..81ad4ecba8348733e419a341a4745dca2e03a2a2 100644 (file)
@@ -192,6 +192,16 @@ namespace rfb {
 
     void setFTManager(rfb::SFileTransferManager *pFTManager) { m_pFTManager = pFTManager; };
 
+    // Enable/disable support for TightVNC-specific VideoRectangleSelection
+    // client message. This is a protocol option that lets a client select a
+    // rectangle to be treated by the server as video data. Once selected, this
+    // part of the framebuffer will be sent using JpegEncoder, on each update
+    // request, as we expect that video data is changing continuously. By
+    // default, this option is disabled, as it's rather a specialized feature
+    // and video selection GUI can confuse users of the TightVNC client.
+    void enableVideoSelection(bool enable) { m_videoSelectionEnabled = enable; }
+    bool isVideoSelectionEnabled() { return m_videoSelectionEnabled; }
+
   protected:
 
     friend class VNCSConnectionST;
@@ -239,6 +249,8 @@ namespace rfb {
     time_t lastConnectionTime;
 
     bool disableclients;
+
+    bool m_videoSelectionEnabled;
   };
 
 };
index ec26adc7507f8c1cb41bedd6bb5148c21d455f2e..32b1395fdbd683c00994d50d75576937af83fbeb 100644 (file)
@@ -57,5 +57,6 @@ namespace rfb {
   const int msgTypeFileDeleteRequest = 139;
 
   const int msgTypeEnableContinuousUpdates = 150;
+  const int msgTypeVideoRectangleSelection = 151;
 }
 #endif
index 4eb6b226168fdd86abd4183149872292e9cbe847..ab93984628982c2f870672ff962bd02931e25d1d 100644 (file)
@@ -455,9 +455,11 @@ int main(int argc, char** argv)
     Geometry geo(DisplayWidth(dpy, DefaultScreen(dpy)),
                  DisplayHeight(dpy, DefaultScreen(dpy)));
     XDesktop desktop(dpy, &geo);
+
     VNCServerST server("x0vncserver", &desktop);
     QueryConnHandler qcHandler(dpy, &server);
     server.setQueryConnectionHandler(&qcHandler);
+    server.enableVideoSelection(true);
 
     TcpListener listener((int)rfbport);
     vlog.info("Listening on port %d", (int)rfbport);