Implemented new "VideoPriority" parameter. It allows to increase the priority of video data (when set to 2 or higher), or to disable video detection completely (when set to 0). The value 1 gives video area the same priority as the rest of the screen, the value 2 doubles video area priority, and so on.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2379 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx
index 5cd611b..bf13cac 100644
--- a/unix/x0vncserver/PollingManager.cxx
+++ b/unix/x0vncserver/PollingManager.cxx
@@ -39,6 +39,9 @@
   19,  3, 27, 11, 29, 13,  5, 21
 };
 
+IntParameter PollingManager::m_videoPriority("VideoPriority",
+  "Priority of sending updates for video area (0..8)", 2);
+
 //
 // Constructor.
 //
@@ -51,6 +54,7 @@
                                int offsetLeft, int offsetTop)
   : m_dpy(dpy), m_server(0), m_image(image),
     m_offsetLeft(offsetLeft), m_offsetTop(offsetTop),
+    m_numVideoPasses(0),
     m_pollingStep(0)
 {
   // Save width and height of the screen (and the image).
@@ -145,6 +149,22 @@
   if (!m_server)
     return false;
 
+  // If video data should have higher priority, and video area was
+  // detected, perform special passes to send video data only. Such
+  // "video passes" will be performed between normal polling passes.
+  // No actual polling is performed in a video pass since we know that
+  // video is changing continuously.
+  if ((int)m_videoPriority > 1 && !m_videoRect.is_empty()) {
+    if (m_numVideoPasses > 0) {
+      m_numVideoPasses--;
+      getScreenRect(m_videoRect);
+      return true;              // we've got changes
+    } else {
+      // Normal pass now, but schedule video passes for next calls.
+      m_numVideoPasses = (int)m_videoPriority - 1;
+    }
+  }
+
   // changeFlags[] array will hold boolean values corresponding to
   // each 32x32 tile. If a value is true, then we've detected a change
   // in that tile. Initially, we fill in the array with zero values.
@@ -164,7 +184,9 @@
   }
 
   // Do the work related to video area detection.
-  bool haveVideoRect = handleVideo(changeFlags);
+  bool haveVideoRect = false;
+  if ((int)m_videoPriority != 0)
+    haveVideoRect = handleVideo(changeFlags);
 
   // Inform the server about the changes.
   // FIXME: It's possible that (nTilesChanged != 0) but changeFlags[]
diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h
index 3f77081..e3a29b0 100644
--- a/unix/x0vncserver/PollingManager.h
+++ b/unix/x0vncserver/PollingManager.h
@@ -115,10 +115,13 @@
   char *m_rateMatrix;
   char *m_videoFlags;
   Rect m_videoRect;
+  int m_numVideoPasses;
 
   unsigned int m_pollingStep;
   static const int m_pollingOrder[];
 
+  static IntParameter m_videoPriority;
+
 #ifdef DEBUG
 private: