[ekiga] GUDev: made the video input implementation better



commit f54a5e803af5d11c4a5afa0b9bd699d842f02b58
Author: Julien Puydt <jpuydt free fr>
Date:   Tue Mar 4 13:03:07 2014 +0100

    GUDev: made the video input implementation better

 .../components/hal-gudev/hal-gudev-monitor.cpp     |   41 ++++++++++++++++---
 .../components/hal-gudev/hal-gudev-monitor.h       |   19 ++++-----
 2 files changed, 42 insertions(+), 18 deletions(-)
---
diff --git a/lib/engine/components/hal-gudev/hal-gudev-monitor.cpp 
b/lib/engine/components/hal-gudev/hal-gudev-monitor.cpp
index 084e670..94dc256 100644
--- a/lib/engine/components/hal-gudev/hal-gudev-monitor.cpp
+++ b/lib/engine/components/hal-gudev/hal-gudev-monitor.cpp
@@ -37,11 +37,34 @@
 
 #include "hal-gudev-monitor.h"
 
+#define DEBUG 1
+
+#if DEBUG
+static void
+print_gudev_device (GUdevDevice* device)
+{
+  g_print ("GUdevDevice:\n");
+  g_print ("\tname: %s\n", g_udev_device_get_name (device));
+  g_print ("\tfile: %s\n", g_udev_device_get_device_file (device));
+
+  g_print ("\tproperties:\n");
+  const gchar* const *keys = g_udev_device_get_property_keys (device);
+  for (int num = 0;
+       keys[num] != NULL;
+       num++) {
+
+    const gchar* key = keys[num];
+    const gchar* val = g_udev_device_get_property (device, key);
+    g_print ("\t\t%s -> %s\n", key, val);
+  }
+}
+#endif
+
 void
-videoinput_uevent_handler_cb (G_GNUC_UNUSED GUdevClient* client,
-                             const gchar* action,
-                             GUdevDevice* device,
-                             GUDevMonitor* monitor)
+gudev_monitor_videoinput_uevent_handler (G_GNUC_UNUSED GUdevClient* client,
+                                        const gchar* action,
+                                        GUdevDevice* device,
+                                        GUDevMonitor* monitor)
 {
   if (g_str_equal ("remove", action)) {
 
@@ -49,7 +72,7 @@ videoinput_uevent_handler_cb (G_GNUC_UNUSED GUdevClient* client,
   }
   if (g_str_equal ("add", action)) {
 
-    monitor->videoinput_added (device);
+    monitor->videoinput_add (device);
   }
 }
 
@@ -58,7 +81,7 @@ GUDevMonitor::GUDevMonitor ()
   const gchar* videoinput_subsystems[] = {"video4linux", NULL};
   videoinput = g_udev_client_new (videoinput_subsystems);
   g_signal_connect (G_OBJECT (videoinput), "uevent",
-                   G_CALLBACK (videoinput_uevent_handler_cb), this);
+                   G_CALLBACK (gudev_monitor_videoinput_uevent_handler), this);
 }
 
 GUDevMonitor::~GUDevMonitor ()
@@ -67,8 +90,12 @@ GUDevMonitor::~GUDevMonitor ()
 }
 
 void
-GUDevMonitor::videoinput_added (GUdevDevice* device)
+GUDevMonitor::videoinput_add (GUdevDevice* device)
 {
+#if DEBUG
+  g_print ("%s\n", __PRETTY_FUNCTION__);
+  print_gudev_device (device);
+#endif
   gint v4l_version = 0;
 
   // first check the api version
diff --git a/lib/engine/components/hal-gudev/hal-gudev-monitor.h 
b/lib/engine/components/hal-gudev/hal-gudev-monitor.h
index 72b8723..ac0db1d 100644
--- a/lib/engine/components/hal-gudev/hal-gudev-monitor.h
+++ b/lib/engine/components/hal-gudev/hal-gudev-monitor.h
@@ -56,26 +56,23 @@ public:
   { return "gudev"; }
 
   const std::string get_description () const
-  { return "\tComponent monitoring devices using GUDev"; }
+  { return "\tComponent monitoring Video4Linux devices using GUDev"; }
 
 private:
 
-  // video input part of the api
-
-  friend void videoinput_uevent_handler_cb (GUdevClient* client,
-                                           const gchar* action,
-                                           GUdevDevice* device,
-                                           GUDevMonitor* monitor);
-  void videoinput_added (GUdevDevice* device);
-  void videoinput_remove (GUdevDevice* device);
-  typedef struct VideoInputDevice {
+  typedef struct {
     std::string framework;
     std::string name;
     int caps;
   } VideoInputDevice;
+  friend void gudev_monitor_videoinput_uevent_handler (GUdevClient* client,
+                                                      const gchar* action,
+                                                      GUdevDevice* device,
+                                                      GUDevMonitor* monitor);
+  void videoinput_add (GUdevDevice* device);
+  void videoinput_remove (GUdevDevice* device);
   std::vector<VideoInputDevice> videoinput_devices;
   GUdevClient* videoinput;
-  
 };
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]