ekiga r6007 - in trunk: . lib/engine/hal/dbus lib/engine/hal/skel
- From: mschneid svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r6007 - in trunk: . lib/engine/hal/dbus lib/engine/hal/skel
- Date: Fri, 29 Feb 2008 21:07:14 +0000 (GMT)
Author: mschneid
Date: Fri Feb 29 21:07:14 2008
New Revision: 6007
URL: http://svn.gnome.org/viewvc/ekiga?rev=6007&view=rev
Log:
Mostly finish dbus hal implementation. Can detect ALSA, V4L, OSS
device additions and removals. Also detects interfaces going up
and down.
Added:
trunk/lib/engine/hal/dbus/hal-v4l-helper.c
trunk/lib/engine/hal/dbus/hal-v4l-helper.h
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/lib/engine/hal/dbus/Makefile.am
trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
trunk/lib/engine/hal/dbus/hal-manager-dbus.h
trunk/lib/engine/hal/skel/hal-core.cpp
trunk/lib/engine/hal/skel/hal-core.h
trunk/lib/engine/hal/skel/hal-manager.h
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Feb 29 21:07:14 2008
@@ -458,6 +458,21 @@
dnl ###############################
+dnl V4L headers
+dnl These are only necessary until HAL has a decent V4L support...
+dnl ###############################
+
+V4L="disabled"
+if test "x${win32}" != "x1"; then
+ AC_CHECK_HEADER(linux/videodev.h, V4L="enabled")
+
+ if test "x${V4L}" != "xdisabled"; then
+ AC_DEFINE(HAVE_V4L,1,[V4L support])
+ fi
+ AM_CONDITIONAL(HAVE_V4L, test "x${V4L}" != "xdisabled")
+fi
+
+dnl ###############################
dnl Avahi / mDNS Support
dnl ###############################
AVAHI="disabled"
Modified: trunk/lib/engine/hal/dbus/Makefile.am
==============================================================================
--- trunk/lib/engine/hal/dbus/Makefile.am (original)
+++ trunk/lib/engine/hal/dbus/Makefile.am Fri Feb 29 21:07:14 2008
@@ -20,6 +20,12 @@
$(hal_dir)/hal-marshal.h \
$(hal_dir)/hal-marshal.c
+if HAVE_V4L
+libgmhal_dbus_la_SOURCES += \
+ $(hal_dir)/hal-v4l-helper.h \
+ $(hal_dir)/hal-v4l-helper.c
+endif
+
# forces the HAVE :
BUILT_SOURCES = hal-marshal.h hal-marshal.c
Modified: trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
==============================================================================
--- trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp (original)
+++ trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp Fri Feb 29 21:07:14 2008
@@ -36,10 +36,17 @@
#include "hal-manager-dbus.h"
#include "hal-marshal.h"
+#include "config.h"
#include <dbus/dbus-glib-lowlevel.h>
#include <glib.h>
+#ifdef HAVE_V4L
+extern "C" {
+#include "hal-v4l-helper.h"
+}
+#endif /* HAVE_V4L */
+
//FIXME: for tracing
#include "ptbuildopts.h"
#include "ptlib.h"
@@ -48,6 +55,7 @@
: core (_core), runtime (*(dynamic_cast<Ekiga::Runtime *> (_core.get ("runtime"))))
{
PTRACE(4, "HalManager_dbus\tInitialising HAL Manager");
+
GError *error = NULL;
bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (error != NULL) {
@@ -56,14 +64,12 @@
return;
}
dbus_connection_setup_with_g_main (dbus_g_connection_get_connection (bus), g_main_context_default());
-
+
+ // Hardware Abstraction Layer registration for callbacks
hal_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
"org.freedesktop.Hal.Manager");
- //FIXME: Is this necessary?
-// dbus_g_object_register_marshaller(gm_hal_dbus_marshal_VOID__STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
-
dbus_g_proxy_add_signal(hal_proxy, "DeviceRemoved", G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(hal_proxy, "DeviceRemoved", G_CALLBACK(&device_removed_cb_proxy), this, NULL);
@@ -72,15 +78,21 @@
populate_devices_list();
+ // NetworkManager registration for callbacks
nm_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager");
dbus_g_proxy_add_signal(nm_proxy, "DeviceNoLongerActive", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(nm_proxy, "DeviceNoLongerActive", G_CALLBACK(&device_no_longer_active_cb_proxy), this, NULL);
+ dbus_g_proxy_connect_signal(nm_proxy, "DeviceNoLongerActive", G_CALLBACK(&interface_no_longer_active_cb_proxy), this, NULL);
dbus_g_proxy_add_signal(nm_proxy, "DeviceNowActive", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal(nm_proxy, "DeviceNowActive", G_CALLBACK(&device_now_active_cb_proxy), this, NULL);
+ dbus_g_proxy_connect_signal(nm_proxy, "DeviceNowActive", G_CALLBACK(&interface_now_active_cb_proxy), this, NULL);
+
+ dbus_g_proxy_add_signal(nm_proxy, "DeviceIP4AddressChange", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(nm_proxy, "DeviceIP4AddressChange", G_CALLBACK(&interface_ip4_address_change_cb_proxy), this, NULL);
+
+ populate_interfaces_list();
dbus_g_connection_flush (bus);
}
@@ -104,16 +116,22 @@
hal_manager_dbus->device_removed_cb(device);
}
-void HalManager_dbus::device_now_active_cb_proxy (DBusGProxy */*object*/, const char *device, gpointer user_data)
+void HalManager_dbus::interface_now_active_cb_proxy (DBusGProxy */*object*/, const char *interface, gpointer user_data)
+{
+ HalManager_dbus* hal_manager_dbus = reinterpret_cast<HalManager_dbus *> (user_data);
+ hal_manager_dbus->interface_now_active_cb(interface);
+}
+
+void HalManager_dbus::interface_no_longer_active_cb_proxy (DBusGProxy */*object*/, const char *interface, gpointer user_data)
{
HalManager_dbus* hal_manager_dbus = reinterpret_cast<HalManager_dbus *> (user_data);
- hal_manager_dbus->device_now_active_cb(device);
+ hal_manager_dbus->interface_no_longer_active_cb(interface);
}
-void HalManager_dbus::device_no_longer_active_cb_proxy (DBusGProxy */*object*/, const char *device, gpointer user_data)
+void HalManager_dbus::interface_ip4_address_change_cb_proxy (DBusGProxy */*object*/, const char *interface, gpointer user_data)
{
HalManager_dbus* hal_manager_dbus = reinterpret_cast<HalManager_dbus *> (user_data);
- hal_manager_dbus->device_no_longer_active_cb(device);
+ hal_manager_dbus->interface_ip4_address_change_cb(interface);
}
void HalManager_dbus::device_added_cb (const char *device)
@@ -121,42 +139,28 @@
std::string type, name;
HalDevice hal_device;
hal_device.key = device;
- get_device_type_name(device, hal_device);
+
+ if (!get_device_type_name(device, hal_device))
+ return;
+
hal_devices.push_back(hal_device);
- PTRACE(4, "HalManager_dbus\tAdded device " << hal_device.category << "," << hal_device.name << "," << hal_device.type);
+ PTRACE(4, "HalManager_dbus\tAdded device " << hal_device.category << "," << hal_device.name << "," << hal_device.type << " Video Capabilities: " << hal_device.video_capabilities);
if (hal_device.category == "alsa") {
if (hal_device.type == "capturing") {
- Ekiga::HalAudioInputDevice audio_input_device;
- audio_input_device.category = hal_device.category;
- audio_input_device.name = hal_device.name;
- audio_input_device_added.emit(audio_input_device);
+ audio_input_device_added.emit(hal_device.category, hal_device.name);
}
else if (hal_device.type == "playback") {
- Ekiga::HalAudioOutputDevice audio_output_device;
- audio_output_device.category = hal_device.category;
- audio_output_device.name = hal_device.name;
- audio_output_device_added.emit(audio_output_device);
+ audio_output_device_added.emit(hal_device.category, hal_device.name);
}
}
else if (hal_device.category == "oss") {
- Ekiga::HalAudioInputDevice audio_input_device;
- Ekiga::HalAudioOutputDevice audio_output_device;
-
- audio_input_device.category = hal_device.category;
- audio_input_device.name = hal_device.name;
- audio_output_device.category = hal_device.category;
- audio_output_device.name = hal_device.name;
-
- audio_input_device_added.emit(audio_input_device);
- audio_output_device_added.emit(audio_output_device);
+ audio_input_device_added.emit(hal_device.category, hal_device.name);
+ audio_output_device_added.emit(hal_device.category, hal_device.name);
}
else if (hal_device.category == "video4linux") {
- Ekiga::HalVideoInputDevice video_input_device;
- video_input_device.category = hal_device.category;
- video_input_device.name = hal_device.name;
- video_input_device_added.emit(video_input_device);
+ video_input_device_added.emit(hal_device.category, hal_device.name, hal_device.video_capabilities);
}
}
@@ -175,19 +179,67 @@
}
if (found) {
- PTRACE(4, "HalManager_dbus\tRemoved device " << iter->category << "," << iter->name << "," << iter->type);
+ PTRACE(4, "HalManager_dbus\tRemoved device " << iter->category << "," << iter->name << "," << iter->type << " Video Capabilities: " << iter->video_capabilities);
+
+ if (iter->category == "alsa") {
+
+ if (iter->type == "capturing") {
+ audio_input_device_removed.emit(iter->category, iter->name);
+ }
+ else if (iter->type == "playback") {
+ audio_output_device_removed.emit(iter->category, iter->name);
+ }
+ }
+ else if (iter->category == "oss") {
+ audio_input_device_removed.emit(iter->category, iter->name);
+ audio_output_device_removed.emit(iter->category, iter->name);
+ }
+ else if (iter->category == "video4linux") {
+ video_input_device_removed.emit(iter->category, iter->name, iter->video_capabilities);
+ }
+
+
hal_devices.erase(iter);
}
}
-void HalManager_dbus::device_now_active_cb (const char *device)
+void HalManager_dbus::interface_now_active_cb (const char *interface)
{
- PTRACE(4, "HalManager_dbus\tActivated network device " << device);
+ NmInterface nm_interface;
+
+ nm_interface.key = interface;
+ get_interface_name_ip (interface, nm_interface);
+
+ nm_interfaces.push_back(nm_interface);
+
+ PTRACE(4, "HalManager_dbus\tActivated network device " << nm_interface.name << "/"<< nm_interface.ip4_address);
+ network_interface_up.emit(nm_interface.name, nm_interface.ip4_address);
}
-void HalManager_dbus::device_no_longer_active_cb (const char *device)
+void HalManager_dbus::interface_no_longer_active_cb (const char *interface)
{
- PTRACE(4, "HalManager_dbus\tDeactivated network device " << device);
+ bool found = false;
+ std::vector<NmInterface>::iterator iter;
+
+ for (iter = nm_interfaces.begin ();
+ iter != nm_interfaces.end () ;
+ iter++)
+ if (iter->key == interface) {
+ found = true;
+ break;
+ }
+
+ if (found) {
+ PTRACE(4, "HalManager_dbus\tDeactivated network interface " << iter->name << "/" << iter->ip4_address);
+ network_interface_down.emit(iter->name, iter->ip4_address);
+ nm_interfaces.erase(iter);
+ }
+}
+
+void HalManager_dbus::interface_ip4_address_change_cb (const char *interface)
+{
+ PTRACE(4, "HalManager_dbus\tDetected IPv4 address change on network interface " << interface);
+ //signal
}
void HalManager_dbus::get_string_property(DBusGProxy *proxy, const char * property, std::string & value)
@@ -206,53 +258,139 @@
g_free (c_value);
}
-void HalManager_dbus::get_device_type_name (const char * device, HalDevice & hal_device)
+bool HalManager_dbus::get_device_type_name (const char * device, HalDevice & hal_device)
{
DBusGProxy * device_proxy = NULL;
- DBusGProxy * parent_proxy = NULL;
+ bool ret = false;
+
device_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.Hal",
device,
"org.freedesktop.Hal.Device");
get_string_property(device_proxy, "info.category", hal_device.category);
+ hal_device.video_capabilities = 0;
+
if (hal_device.category == "alsa") {
get_string_property(device_proxy, "alsa.card_id", hal_device.name);
get_string_property(device_proxy, "alsa.type", hal_device.type);
+ ret = true;
}
else if (hal_device.category == "oss") {
get_string_property(device_proxy, "oss.card_id", hal_device.name);
- hal_device.type = "";
+ hal_device.type = "";
+ ret = true;
}
else if (hal_device.category == "video4linux") {
- std::string parent;
- get_string_property(device_proxy, "info.parent", parent);
- parent_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.Hal",
- parent.c_str(),
- "org.freedesktop.Hal.Device");
-
- get_string_property(parent_proxy, "info.product", hal_device.name);
- hal_device.type = "";
- g_object_unref(parent_proxy);
- }
- else {
- get_string_property(device_proxy, "info.product", hal_device.name);
- hal_device.type = "";
+#ifdef HAVE_V4L
+ std::string device_dir;
+ char* v4l1_name;
+ char* v4l2_name;
+ int supported_versions;
+
+ get_string_property(device_proxy, "video4linux.device", device_dir);
+
+ if (device_dir != "") {
+ supported_versions = v4l_get_device_names ((const char*) device_dir.c_str(), &v4l1_name, &v4l2_name);
+
+ if (supported_versions == 0) {
+ PTRACE(1, "HalManager_dbus\tNo supported V4L version detected for device " << device_dir);
+ hal_device.name = device_dir;
+ hal_device.type = "";
+ }
+ else if (supported_versions == -1) {
+ PTRACE(1, "HalManager_dbus\tCould not open device " << device_dir);
+ hal_device.name = device_dir;
+ hal_device.type = "";
+ }
+ else {
+ if (supported_versions && 1) {
+ PTRACE(4, "HalManager_dbus\tDetected V4L capabilities on " << device_dir << " name: " << v4l1_name);
+ hal_device.name = v4l1_name;
+ hal_device.type = "capturing";
+ hal_device.video_capabilities |= V4L_VERSION_1;
+ }
+ if (supported_versions && 2) {
+ PTRACE(4, "HalManager_dbus\tDetected V4L2 capabilities on " << device_dir << " name: " << v4l2_name);
+ hal_device.name = v4l2_name;
+ hal_device.type = "capturing";
+ hal_device.video_capabilities |= V4L_VERSION_2;
+ }
+ ret = true;
+ }
+
+ v4l_free_device_name(&v4l1_name);
+ v4l_free_device_name(&v4l2_name);
+ }
+#endif /* HAVE_V4L */
}
g_object_unref(device_proxy);
+ return ret;
}
-void HalManager_dbus::populate_devices_list ()
+void HalManager_dbus::get_interface_name_ip (const char * interface, NmInterface & nm_interface)
{
+
+ DBusGProxy * interface_proxy = NULL;
GError *error = NULL;
+ gchar* c_value = NULL;
+ unsigned address = NULL;
+ gboolean active = FALSE;
+
+ interface_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.NetworkManager",
+ interface,
+ "org.freedesktop.NetworkManager.Properties");
+ nm_interface.key = interface;
- PTRACE(4, "HalManager_dbus\tPopulating device list");
+
+// getName
+ dbus_g_proxy_call (interface_proxy, "getName", &error, G_TYPE_INVALID, G_TYPE_STRING, &c_value, G_TYPE_INVALID);
+
+ if (error != NULL)
+ g_error_free(error);
+ else
+ if (c_value)
+ nm_interface.name = c_value;
+
+ g_free (c_value);
+
+// getIP4Address
+ dbus_g_proxy_call (interface_proxy, "getIP4Address", &error, G_TYPE_INVALID, G_TYPE_UINT, &address, G_TYPE_INVALID);
+
+ if (error != NULL)
+ g_error_free(error);
+ else {
+ gchar* c_address = g_strdup_printf ( "%d.%d.%d.%d", (address >> 0) & 0xff,
+ (address >> 8) & 0xff,
+ (address >> 16) & 0xff,
+ (address >> 24) & 0xff);
+ nm_interface.ip4_address = c_address;
+ g_free (c_address);
+ }
+
+// getLinkActive
+ dbus_g_proxy_call (interface_proxy, "getLinkActive", &error, G_TYPE_INVALID, G_TYPE_BOOLEAN, &active, G_TYPE_INVALID);
+
+ if (error != NULL)
+ g_error_free(error);
+ else
+ nm_interface.active = active;
+
+ g_object_unref(interface_proxy);
+}
+
+void HalManager_dbus::populate_devices_list ()
+{
+ GError *error = NULL;
char **device_list;
char **device_list_ptr;
HalDevice hal_device;
+ PTRACE(4, "HalManager_dbus\tPopulating device list");
+
dbus_g_proxy_call (hal_proxy, "GetAllDevices", &error, G_TYPE_INVALID, G_TYPE_STRV, &device_list, G_TYPE_INVALID);
+
if (error != NULL) {
PTRACE(1, "HalManager_dbus\tPopulating full device list failed - " << error->message);
g_error_free(error);
@@ -264,10 +402,43 @@
if (hal_device.key != "/org/freedesktop/Hal/devices/computer") {
get_device_type_name(*device_list_ptr, hal_device);
- hal_devices.push_back(hal_device);
+ if ( (hal_device.category == "alsa") ||
+ (hal_device.category == "oss") ||
+ (hal_device.category == "video4linux") )
+ hal_devices.push_back(hal_device);
}
}
g_strfreev(device_list);
+
PTRACE(4, "HalManager_dbus\tPopulated device list with " << hal_devices.size() << " devices");
-}
\ No newline at end of file
+}
+
+void HalManager_dbus::populate_interfaces_list ()
+{
+ GError *error = NULL;
+ GPtrArray *interface_list;
+ NmInterface nm_interface;
+
+ PTRACE(4, "HalManager_dbus\tPopulating interface list");
+
+ dbus_g_proxy_call (nm_proxy, "getDevices", &error, G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_PROXY), &interface_list, G_TYPE_INVALID);
+
+ if (error != NULL) {
+ PTRACE(1, "HalManager_dbus\tPopulating full interface list failed - " << error->message);
+ g_error_free(error);
+ return;
+ }
+
+ unsigned i;
+ for (i = 0; i < interface_list->len; i++) {
+
+ get_interface_name_ip (dbus_g_proxy_get_path ((DBusGProxy*)g_ptr_array_index (interface_list, i)), nm_interface);
+ nm_interfaces.push_back(nm_interface);
+ }
+
+ g_ptr_array_free (interface_list, TRUE);
+
+ PTRACE(4, "HalManager_dbus\tPopulated interface list with " << nm_interfaces.size() << " devices");
+}
Modified: trunk/lib/engine/hal/dbus/hal-manager-dbus.h
==============================================================================
--- trunk/lib/engine/hal/dbus/hal-manager-dbus.h (original)
+++ trunk/lib/engine/hal/dbus/hal-manager-dbus.h Fri Feb 29 21:07:14 2008
@@ -59,6 +59,14 @@
std::string category;
std::string name;
std::string type;
+ unsigned video_capabilities;
+ };
+
+ typedef struct NmInterface {
+ std::string key;
+ std::string name;
+ std::string ip4_address;
+ bool active;
};
class HalManager_dbus
@@ -85,19 +93,26 @@
static void device_added_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
static void device_removed_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
- static void device_no_longer_active_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
- static void device_now_active_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
+ static void interface_no_longer_active_cb_proxy (DBusGProxy *object, const char *interface, gpointer user_data);
+ static void interface_now_active_cb_proxy (DBusGProxy *object, const char *interface, gpointer user_data);
+ static void interface_ip4_address_change_cb_proxy (DBusGProxy *object, const char *interface, gpointer user_data);
void device_added_cb (const char *device);
void device_removed_cb (const char *device);
- void device_now_active_cb (const char *device);
- void device_no_longer_active_cb (const char *device);
+ void interface_now_active_cb (const char *interface);
+ void interface_no_longer_active_cb (const char *interface);
+ void interface_ip4_address_change_cb (const char *interface);
protected:
void populate_devices_list();
- void get_device_type_name (const char * device, HalDevice & hal_device);
+ void populate_interfaces_list ();
+
+ bool get_device_type_name (const char * device, HalDevice & hal_device);
+ void get_interface_name_ip (const char * interface, NmInterface & nm_interface);
+
void get_string_property (DBusGProxy *proxy, const char * property, std::string & value);
+
Ekiga::ServiceCore & core;
Ekiga::Runtime & runtime;
@@ -106,6 +121,7 @@
DBusGProxy * nm_proxy;
std::vector <HalDevice> hal_devices;
+ std::vector <NmInterface> nm_interfaces;
};
/**
Added: trunk/lib/engine/hal/dbus/hal-v4l-helper.c
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/hal-v4l-helper.c Fri Feb 29 21:07:14 2008
@@ -0,0 +1,87 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ * hal-v4l-helper.c - description
+ * ------------------------------------------
+ * begin : written in 2008 by Matthias Schneider
+ * copyright : (c) 2008 by Matthias Schneider
+ * description : Used to detect the names and supported V4L
+ * interfaces of a new video4linux device (this
+ * should really be in HALd itself.
+ *
+ */
+
+#include <fcntl.h> // for open()
+#include <unistd.h> // for read(), write(), close()
+#include <sys/ioctl.h> // for ioctl()
+#include <stdlib.h> // for free(), malloc()
+#include <string.h> // for strlen()
+#include <stdio.h>
+#include <linux/videodev.h>
+
+int v4l_get_device_names (const char* device, char** v4l1_name, char** v4l2_name) {
+ int fp;
+ unsigned ret = 0; // Device not valid
+
+ *v4l1_name = NULL;
+ *v4l2_name = NULL;
+
+ if((fp = open(device, O_RDONLY)) == 0) {
+ return -1; // Unable to open device
+ }
+
+ struct video_capability v4l1_caps;
+ if (ioctl(fp, VIDIOCGCAP, &v4l1_caps) >= 0 && (v4l1_caps.type & VID_TYPE_CAPTURE) != 0) {
+ ret |= 1;
+ *v4l1_name = (char*) malloc (strlen(v4l1_caps.name) + 1);
+ strcpy (*v4l1_name, v4l1_caps.name);
+ }
+
+ struct v4l2_capability v4l2_caps;
+ if ( (ioctl(fp, VIDIOC_QUERYCAP, &v4l2_caps) >= 0) &&
+ (v4l2_caps.capabilities & V4L2_CAP_VIDEO_CAPTURE) ) {
+ ret |= 2;
+ *v4l2_name = (char*) malloc (strlen((const char*) v4l2_caps.card) + 1);
+ strcpy (*v4l2_name, (const char*) v4l2_caps.card);
+ }
+
+ if (fp > 0)
+ close(fp);
+
+ return ret;
+}
+
+void v4l_free_device_name (char** name)
+{
+ if (*name)
+ free (*name);
+
+ *name = NULL;
+}
+
Added: trunk/lib/engine/hal/dbus/hal-v4l-helper.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/hal-v4l-helper.h Fri Feb 29 21:07:14 2008
@@ -0,0 +1,46 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ * hal-v4l-helper.h - description
+ * ------------------------------------------
+ * begin : written in 2008 by Matthias Schneider
+ * copyright : (c) 2008 by Matthias Schneider
+ * description : Used to detect the names and supported V4L
+ * interfaces of a new video4linux device (this
+ * should really be in HALd itself.
+ *
+ */
+
+#ifndef __HAL_V4L_HELPER_H__
+#define __HAL_V4L_HELPER_H__
+
+int v4l_get_device_names (const char* device, char** v4l1_name, char** v4l2_name);
+void v4l_free_device_name (char** name);
+
+#endif
Modified: trunk/lib/engine/hal/skel/hal-core.cpp
==============================================================================
--- trunk/lib/engine/hal/skel/hal-core.cpp (original)
+++ trunk/lib/engine/hal/skel/hal-core.cpp Fri Feb 29 21:07:14 2008
@@ -59,17 +59,17 @@
managers.insert (&manager);
manager_added.emit (manager);
- manager.video_input_device_added.connect (sigc::mem_fun (this, &HalCore::on_video_input_device_added));
- manager.video_input_device_removed.connect (sigc::mem_fun (this, &HalCore::on_video_input_device_removed));
+ manager.video_input_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_video_input_device_added), &manager));
+ manager.video_input_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_video_input_device_removed), &manager));
- manager.audio_input_device_added.connect (sigc::mem_fun (this, &HalCore::on_audio_input_device_added));
- manager.audio_input_device_removed.connect (sigc::mem_fun (this, &HalCore::on_audio_input_device_removed));
+ manager.audio_input_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_input_device_added), &manager));
+ manager.audio_input_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_input_device_removed), &manager));
- manager.audio_output_device_added.connect (sigc::mem_fun (this, &HalCore::on_audio_output_device_added));
- manager.audio_output_device_removed.connect (sigc::mem_fun (this, &HalCore::on_audio_output_device_removed));
+ manager.audio_output_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_output_device_added), &manager));
+ manager.audio_output_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_output_device_removed), &manager));
- manager.network_interface_up.connect (sigc::mem_fun (this, &HalCore::on_network_interface_up));
- manager.network_interface_down.connect (sigc::mem_fun (this, &HalCore::on_network_interface_down));
+ manager.network_interface_up.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_network_interface_up), &manager));
+ manager.network_interface_down.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_network_interface_down), &manager));
}
@@ -83,34 +83,34 @@
go_on = visitor (*(*iter));
}
-void HalCore::on_video_input_device_added (HalVideoInputDevice & video_input_device) {
- video_input_device_added.emit (video_input_device);
+void HalCore::on_video_input_device_added (std::string & source, std::string & device, unsigned capabilities, HalManager* manager) {
+ video_input_device_added.emit (source, device, capabilities, manager);
}
-void HalCore::on_video_input_device_removed (HalVideoInputDevice & video_input_device) {
- video_input_device_removed.emit (video_input_device);
+void HalCore::on_video_input_device_removed (std::string & source, std::string & device, unsigned capabilities, HalManager* manager) {
+ video_input_device_removed.emit (source, device, capabilities, manager);
}
-void HalCore::on_audio_input_device_added (HalAudioInputDevice & audio_input_device) {
- audio_input_device_added.emit (audio_input_device);
+void HalCore::on_audio_input_device_added (std::string & source, std::string & device, HalManager* manager) {
+ audio_input_device_added.emit (source, device, manager);
}
-void HalCore::on_audio_input_device_removed (HalAudioInputDevice & audio_input_device) {
- audio_input_device_removed.emit (audio_input_device);
+void HalCore::on_audio_input_device_removed (std::string & source, std::string & device, HalManager* manager) {
+ audio_input_device_removed.emit (source, device, manager);
}
-void HalCore::on_audio_output_device_added (HalAudioOutputDevice & audio_output_device) {
- audio_output_device_added.emit (audio_output_device);
+void HalCore::on_audio_output_device_added (std::string & sink, std::string & device, HalManager* manager) {
+ audio_output_device_added.emit (sink, device, manager);
}
-void HalCore::on_audio_output_device_removed (HalAudioOutputDevice & audio_output_device) {
- audio_output_device_removed.emit (audio_output_device);
+void HalCore::on_audio_output_device_removed (std::string & sink, std::string & device, HalManager* manager) {
+ audio_output_device_removed.emit (sink, device, manager);
}
-void HalCore::on_network_interface_up (HalNetworkInterface & network_interface) {
- network_interface_up.emit (network_interface);
+void HalCore::on_network_interface_up (std::string & interface, std::string & ip4_address, HalManager* manager) {
+ network_interface_up.emit (interface, ip4_address, manager);
}
-void HalCore::on_network_interface_down (HalNetworkInterface & network_interface) {
- network_interface_down.emit (network_interface);
+void HalCore::on_network_interface_down (std::string & interface, std::string & ip4_address, HalManager* manager) {
+ network_interface_down.emit (interface,ip4_address, manager);
}
Modified: trunk/lib/engine/hal/skel/hal-core.h
==============================================================================
--- trunk/lib/engine/hal/skel/hal-core.h (original)
+++ trunk/lib/engine/hal/skel/hal-core.h Fri Feb 29 21:07:14 2008
@@ -44,6 +44,9 @@
#include <set>
#include <map>
+#define V4L_VERSION_1 (1<<0)
+#define V4L_VERSION_2 (1<<1)
+
namespace Ekiga
{
/**
@@ -53,25 +56,6 @@
class HalManager;
- typedef struct HalVideoInputDevice {
- std::string category;
- std::string name;
- };
-
- typedef struct HalAudioInputDevice {
- std::string category;
- std::string name;
- };
-
- typedef struct HalAudioOutputDevice {
- std::string category;
- std::string name;
- };
-
- typedef struct HalNetworkInterface {
- std::string name;
- };
-
/** Core object for hal support
*/
class HalCore
@@ -121,31 +105,31 @@
/** See hal-manager.h for the API
*/
- sigc::signal<void, HalVideoInputDevice &> video_input_device_added;
- sigc::signal<void, HalVideoInputDevice &> video_input_device_removed;
+ sigc::signal<void, std::string &, std::string &, unsigned, HalManager*> video_input_device_added;
+ sigc::signal<void, std::string &, std::string &, unsigned, HalManager*> video_input_device_removed;
- sigc::signal<void, HalAudioInputDevice &> audio_input_device_added;
- sigc::signal<void, HalAudioInputDevice &> audio_input_device_removed;
+ sigc::signal<void, std::string &, std::string &, HalManager*> audio_input_device_added;
+ sigc::signal<void, std::string &, std::string &, HalManager*> audio_input_device_removed;
- sigc::signal<void, HalAudioOutputDevice &> audio_output_device_added;
- sigc::signal<void, HalAudioOutputDevice &> audio_output_device_removed;
+ sigc::signal<void, std::string &, std::string &, HalManager*> audio_output_device_added;
+ sigc::signal<void, std::string &, std::string &, HalManager*> audio_output_device_removed;
- sigc::signal<void, HalNetworkInterface &> network_interface_up;
- sigc::signal<void, HalNetworkInterface &> network_interface_down;
+ sigc::signal<void, std::string &, std::string &, HalManager*> network_interface_up;
+ sigc::signal<void, std::string &, std::string &, HalManager*> network_interface_down;
private:
- void on_video_input_device_added (HalVideoInputDevice & video_input_device);
- void on_video_input_device_removed (HalVideoInputDevice & video_input_device);
+ void on_video_input_device_added (std::string & source, std::string & device, unsigned capabilities, HalManager* manager);
+ void on_video_input_device_removed (std::string & source, std::string & device, unsigned capabilities, HalManager* manager);
- void on_audio_input_device_added (HalAudioInputDevice & audio_input_device);
- void on_audio_input_device_removed (HalAudioInputDevice & audio_input_device);
+ void on_audio_input_device_added (std::string & source, std::string & device, HalManager* manager);
+ void on_audio_input_device_removed (std::string & source, std::string & device, HalManager* manager);
- void on_audio_output_device_added (HalAudioOutputDevice & audio_output_device);
- void on_audio_output_device_removed (HalAudioOutputDevice & audio_output_device);
+ void on_audio_output_device_added (std::string & sink, std::string & device, HalManager* manager);
+ void on_audio_output_device_removed (std::string & sink, std::string & device, HalManager* manager);
- void on_network_interface_up (HalNetworkInterface & network_interface);
- void on_network_interface_down (HalNetworkInterface & network_interface);
+ void on_network_interface_up (std::string & interface, std::string & ip4_address, HalManager* manager);
+ void on_network_interface_down (std::string & interface, std::string & ip4_address, HalManager* manager);
std::set<HalManager *> managers;
Modified: trunk/lib/engine/hal/skel/hal-manager.h
==============================================================================
--- trunk/lib/engine/hal/skel/hal-manager.h (original)
+++ trunk/lib/engine/hal/skel/hal-manager.h Fri Feb 29 21:07:14 2008
@@ -71,17 +71,17 @@
* @return true if a Ekiga::Call could be created
*/
- sigc::signal<void, HalVideoInputDevice &> video_input_device_added;
- sigc::signal<void, HalVideoInputDevice &> video_input_device_removed;
+ sigc::signal<void, std::string&, std::string&, unsigned> video_input_device_added;
+ sigc::signal<void, std::string&, std::string&, unsigned> video_input_device_removed;
- sigc::signal<void, HalAudioInputDevice &> audio_input_device_added;
- sigc::signal<void, HalAudioInputDevice &> audio_input_device_removed;
+ sigc::signal<void, std::string&, std::string&> audio_input_device_added;
+ sigc::signal<void, std::string&, std::string&> audio_input_device_removed;
- sigc::signal<void, HalAudioOutputDevice &> audio_output_device_added;
- sigc::signal<void, HalAudioOutputDevice &> audio_output_device_removed;
+ sigc::signal<void, std::string&, std::string&> audio_output_device_added;
+ sigc::signal<void, std::string&, std::string&> audio_output_device_removed;
- sigc::signal<void, HalNetworkInterface &> network_interface_up;
- sigc::signal<void, HalNetworkInterface &> network_interface_down;
+ sigc::signal<void, std::string&, std::string&> network_interface_up;
+ sigc::signal<void, std::string&, std::string&> network_interface_down;
protected:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]