[ekiga] Notifications: Added VideoInputDevice detection.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Notifications: Added VideoInputDevice detection.
- Date: Sat, 12 May 2012 16:03:47 +0000 (UTC)
commit 3a5541314338cfca139f1478eff6be3693dcce2b
Author: Damien Sandras <dsandras beip be>
Date: Sat May 12 17:15:07 2012 +0200
Notifications: Added VideoInputDevice detection.
Changing the video input device when a new device is added or a
device removal happens is now done through Notifications.
Handle the case where the added/removed device is
the prefered one or not.
This allows the main window to get rid of those signals.
lib/engine/engine.cpp | 2 +-
lib/engine/videoinput/videoinput-core.cpp | 30 ++++++++++++++++++++++---
lib/engine/videoinput/videoinput-core.h | 7 +++++-
src/gui/main_window.cpp | 33 -----------------------------
4 files changed, 33 insertions(+), 39 deletions(-)
---
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index d228ff2..2a76662 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -113,7 +113,7 @@ engine_init (Ekiga::ServiceCorePtr service_core,
boost::shared_ptr<Ekiga::CallCore> call_core (new Ekiga::CallCore);
boost::shared_ptr<Ekiga::ChatCore> chat_core (new Ekiga::ChatCore);
boost::shared_ptr<Ekiga::VideoOutputCore> videooutput_core (new Ekiga::VideoOutputCore);
- boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core (new Ekiga::VideoInputCore (videooutput_core));
+ boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core (new Ekiga::VideoInputCore ((*service_core.get ()), videooutput_core));
boost::shared_ptr<Ekiga::AudioOutputCore> audiooutput_core (new Ekiga::AudioOutputCore);
boost::shared_ptr<Ekiga::AudioInputCore> audioinput_core (new Ekiga::AudioInputCore);
boost::shared_ptr<Ekiga::HalCore> hal_core (new Ekiga::HalCore);
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index 090b19b..b499b32 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -37,11 +37,15 @@
#include <iostream>
#include <sstream>
+#include <glib/gi18n.h>
+
#include "config.h"
#include "videoinput-core.h"
#include "videoinput-manager.h"
+#define VIDEO_DEVICES_KEY "/apps/" PACKAGE_NAME "/devices/video/"
+
using namespace Ekiga;
VideoInputCore::VideoPreviewManager::VideoPreviewManager (VideoInputCore& _videoinput_core, boost::shared_ptr<VideoOutputCore> _videooutput_core)
@@ -119,8 +123,9 @@ void VideoInputCore::VideoPreviewManager::Main ()
}
}
-VideoInputCore::VideoInputCore (boost::shared_ptr<VideoOutputCore> _videooutput_core)
-: preview_manager(*this, _videooutput_core)
+VideoInputCore::VideoInputCore (Ekiga::ServiceCore & _core,
+ boost::shared_ptr<VideoOutputCore> _videooutput_core)
+: core(_core), preview_manager(*this, _videooutput_core)
{
PWaitAndSignal m_var(core_mutex);
PWaitAndSignal m_set(settings_mutex);
@@ -147,6 +152,7 @@ VideoInputCore::VideoInputCore (boost::shared_ptr<VideoOutputCore> _videooutput_
current_manager = NULL;
videoinput_core_conf_bridge = NULL;
+ notification_core = core.get<Ekiga::NotificationCore> ("notification-core");
}
VideoInputCore::~VideoInputCore ()
@@ -231,8 +237,16 @@ void VideoInputCore::add_device (const std::string & source, const std::string &
iter++) {
if ((*iter)->has_device (source, device_name, capabilities, device)) {
- if ( desired_device == device )
+ if ( desired_device == device ) {
internal_set_device(device, current_channel, current_format);
+ boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info, _("New device detected"), device.GetString ()));
+ notification_core->push_notification (notif);
+ }
+ else {
+
+ boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info, _("New device detected"), device.GetString (), _("Use it"), boost::bind (&VideoInputCore::on_set_device, (VideoInputCore*) this, device)));
+ notification_core->push_notification (notif);
+ }
device_added(device, desired_device == device);
}
@@ -259,6 +273,9 @@ void VideoInputCore::remove_device (const std::string & source, const std::strin
}
device_removed(device, current_device == device);
+
+ boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Info, _("Device removed"), device.GetString ()));
+ notification_core->push_notification (notif);
}
}
}
@@ -421,8 +438,13 @@ void VideoInputCore::set_contrast (unsigned contrast)
desired_settings.contrast = contrast;
}
+void VideoInputCore::on_set_device (const VideoInputDevice & device)
+{
+ gm_conf_set_string (VIDEO_DEVICES_KEY "input_device", device.GetString ().c_str ());
+}
+
void VideoInputCore::on_device_opened (VideoInputDevice device,
- VideoInputSettings settings,
+ VideoInputSettings settings,
VideoInputManager *manager)
{
device_opened (*manager, device, settings);
diff --git a/lib/engine/videoinput/videoinput-core.h b/lib/engine/videoinput/videoinput-core.h
index 02f9972..41f895d 100644
--- a/lib/engine/videoinput/videoinput-core.h
+++ b/lib/engine/videoinput/videoinput-core.h
@@ -41,6 +41,7 @@
#include "runtime.h"
#include "videooutput-core.h"
#include "hal-core.h"
+#include "notification-core.h"
#include "videoinput-manager.h"
#include "videoinput-gmconf-bridge.h"
@@ -105,7 +106,8 @@ namespace Ekiga
* @param _runtime reference to Ekiga runtime.
* @param _videooutput_core reference ot the video output core.
*/
- VideoInputCore (boost::shared_ptr<VideoOutputCore> _videooutput_core);
+ VideoInputCore (Ekiga::ServiceCore & core,
+ boost::shared_ptr<VideoOutputCore> _videooutput_core);
/** The destructor
*/
@@ -294,6 +296,7 @@ namespace Ekiga
boost::signal2<void, VideoInputDevice, bool> device_removed;
private:
+ void on_set_device (const VideoInputDevice & device);
void on_device_opened (VideoInputDevice device,
VideoInputSettings settings,
VideoInputManager *manager);
@@ -434,8 +437,10 @@ private:
PMutex core_mutex;
PMutex settings_mutex;
+ Ekiga::ServiceCore & core;
VideoPreviewManager preview_manager;
VideoInputCoreConfBridge* videoinput_core_conf_bridge;
+ boost::shared_ptr<Ekiga::NotificationCore> notification_core;
};
/**
* @}
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index 4fb0419..d4a9d96 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -766,31 +766,6 @@ static bool on_handle_errors (std::string error,
* Display Engine Callbacks
*/
void
-on_videoinput_device_added_cb (const Ekiga::VideoInputDevice & device, bool is_desired, gpointer self)
-{
- EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
- gchar *message;
-
- /* Translators: This is a hotplug status */
- message = g_strdup_printf (_("Added video input device %s"),
- device.GetString().c_str ());
- ekiga_main_window_flash_message (mw, "%s", message);
- g_free (message);
- if (!is_desired && mw->priv->calling_state == Standby && !mw->priv->current_call)
- ekiga_main_window_add_device_dialog_show (mw, device, VideoInput);
-}
-
-void
-on_videoinput_device_removed_cb (const Ekiga::VideoInputDevice & device, bool, gpointer self)
-{
- /* Translators: This is a hotplug status */
- gchar *message = g_strdup_printf (_("Removed video input device %s"),
- device.GetString().c_str ());
- ekiga_main_window_flash_message (EKIGA_MAIN_WINDOW (self), "%s", message);
- g_free (message);
-}
-
-void
on_audioinput_device_added_cb (const Ekiga::AudioInputDevice & device,
bool is_desired,
gpointer self)
@@ -1920,14 +1895,6 @@ ekiga_main_window_connect_engine_signals (EkigaMainWindow *mw)
g_return_if_fail (EKIGA_IS_MAIN_WINDOW (mw));
- /* New VideoInput Engine signals */
- boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core = mw->priv->core->get<Ekiga::VideoInputCore> ("videoinput-core");
- conn = videoinput_core->device_added.connect (boost::bind (&on_videoinput_device_added_cb, _1, _2, (gpointer) mw));
- mw->priv->connections.push_back (conn);
-
- conn = videoinput_core->device_removed.connect (boost::bind (&on_videoinput_device_removed_cb, _1, _2, (gpointer) mw));
- mw->priv->connections.push_back (conn);
-
/* New AudioInput Engine signals */
boost::shared_ptr<Ekiga::AudioInputCore> audioinput_core = mw->priv->core->get<Ekiga::AudioInputCore> ("audioinput-core");
conn = audioinput_core->device_added.connect (boost::bind (&on_audioinput_device_added_cb, _1, _2, (gpointer) mw));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]