This patch adds support for X11 screen sharing in the VideoInput class.
The expected string device to instanciate a new video input for X11 is
the standard display name (usually the content of $DISPLAY), optionally
following by a space and a video size. For instance:

    ":0.0" or ":0.0 1024x768"

Refs: #40806
---
 daemon/src/video/video_input.cpp | 28 +++++++++++++++++++++++++++-
 daemon/src/video/video_input.h   |  1 +
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/daemon/src/video/video_input.cpp b/daemon/src/video/video_input.cpp
index 1089534..b8394a1 100644
--- a/daemon/src/video/video_input.cpp
+++ b/daemon/src/video/video_input.cpp
@@ -56,7 +56,14 @@ VideoInput::VideoInput(const std::string& device) :
     , framerate_()
     , video_size_()
 {
-    initCamera(device);
+    /* TODO better check for the X11 display name */
+    if (device.find(':') != std::string::npos) {
+        DEBUG("Init screen display %s\n", device.c_str());
+        initX11(device);
+    } else {
+        DEBUG("Init camera %s\n", device.c_str());
+        initCamera(device);
+    }
 
     start();
 }
@@ -80,6 +87,25 @@ void VideoInput::initCamera(std::string device)
     video_size_ = map["video_size"];
 }
 
+void VideoInput::initX11(std::string device)
+{
+    size_t space = device.find(' ');
+
+    if (space != std::string::npos) {
+        video_size_ = device.substr(space + 1);
+        input_ = device.erase(space);
+    } else {
+        input_ = device;
+        video_size_ = "vga";
+    }
+
+    format_ = "x11grab";
+    framerate_ = "25";
+    mirror_ = false;
+
+    DEBUG("X11 display name %s (%s)", input_.c_str(), video_size_.c_str());
+}
+
 bool VideoInput::setup()
 {
     decoder_ = new VideoDecoder();
diff --git a/daemon/src/video/video_input.h b/daemon/src/video/video_input.h
index 3d8b048..cb7bea7 100644
--- a/daemon/src/video/video_input.h
+++ b/daemon/src/video/video_input.h
@@ -74,6 +74,7 @@ private:
     std::string video_size_;
 
     void initCamera(std::string device);
+    void initX11(std::string device);
 
     // as SFLThread
     bool setup();
-- 
1.8.5.4

_______________________________________________
SFLphone mailing list
[email protected]
http://lists.savoirfairelinux.net/mailman/listinfo/sflphone

Reply via email to