[ekiga] Set the default audio and video devices



commit 1eb2c13b76ceca2bfa7fe20f31b4e2b9769987dd
Author: Eugen Dedu <Eugen Dedu pu-pm univ-fcomte fr>
Date:   Wed May 12 18:27:42 2010 +0200

    Set the default audio and video devices
    
    They are used when ekiga is installed for the first time.  Tested on
    GNU/Linux and Windows.
    
    Conflicts:
    
    	src/gui/misc.cpp
    	src/gui/misc.h

 ekiga.schemas.in.in     |    6 ++--
 src/gui/assistant.cpp   |   16 ++++++---
 src/gui/misc.cpp        |   81 +++++++++++++++++++++++++++++++++++++++++++++++
 src/gui/misc.h          |   55 ++++++++++++++++++++++++++++++++
 src/gui/preferences.cpp |   14 ++++----
 5 files changed, 156 insertions(+), 16 deletions(-)
---
diff --git a/ekiga.schemas.in.in b/ekiga.schemas.in.in
index 63de033..7d67aa4 100644
--- a/ekiga.schemas.in.in
+++ b/ekiga.schemas.in.in
@@ -5,7 +5,7 @@
       <applyto>/apps/@PACKAGE_NAME@/devices/audio/output_device</applyto>
       <owner>Ekiga</owner>
       <type>string</type>
-      <default>Default (PTLIB/ALSA)</default>
+      <default></default>
       <locale name="C">
 	<short>Audio output device</short>
 	<long>Select the audio output device to use</long>
@@ -16,7 +16,7 @@
       <applyto>/apps/@PACKAGE_NAME@/devices/audio/input_device</applyto>
       <owner>Ekiga</owner>
       <type>string</type>
-      <default>Default (PTLIB/ALSA)</default>
+      <default></default>
       <locale name="C">
 	<short>Audio input device</short>
 	<long>Select the audio input device to use</long>
@@ -193,7 +193,7 @@
       <applyto>/apps/@PACKAGE_NAME@/general/sound_events/output_device</applyto>
       <owner>Ekiga</owner>
       <type>string</type>
-      <default>Default (PTLIB/ALSA)</default>
+      <default></default>
       <locale name="C">
 	<short>Alternative audio output device</short>
 	<long>Select an alternative audio output device to use for sound events.</long>
diff --git a/src/gui/assistant.cpp b/src/gui/assistant.cpp
index bb7ffce..e227f64 100644
--- a/src/gui/assistant.cpp
+++ b/src/gui/assistant.cpp
@@ -1066,16 +1066,16 @@ prepare_audio_devices_page (EkigaAssistant *assistant)
   char **array;
 
   ringer = gm_conf_get_string (SOUND_EVENTS_KEY "output_device");
-  if (ringer == NULL)
-    ringer = g_strdup ("Default (PTLIB/ALSA)");
+  if (ringer == NULL || !ringer[0])
+    ringer = g_strdup (get_default_audio_device_name ());
 
   player = gm_conf_get_string (AUDIO_DEVICES_KEY "output_device");
-  if (player == NULL)
-    player = g_strdup ("Default (PTLIB/ALSA)");
+  if (player == NULL || !player[0])
+    player = g_strdup (get_default_audio_device_name ());
 
   recorder = gm_conf_get_string (AUDIO_DEVICES_KEY "input_device");
-  if (recorder == NULL)
-    recorder = g_strdup ("Default (PTLIB/ALSA)");
+  if (recorder == NULL || !recorder[0])
+    recorder = g_strdup (get_default_audio_device_name ());
 
   /* FIXME: We should use DetectDevices, however DetectDevices
    * works only for the currently selected audio and video plugins,
@@ -1184,6 +1184,10 @@ prepare_video_devices_page (EkigaAssistant *assistant)
   get_videoinput_devices_list (assistant->priv->core, device_list);
   array = convert_string_list (device_list);
   current_plugin = gm_conf_get_string (VIDEO_DEVICES_KEY "input_device");
+  if (current_plugin == NULL || !current_plugin[0]) {
+    g_free (current_plugin);
+    current_plugin = g_strdup (get_default_video_device_name (array));
+  }
   update_combo_box (GTK_COMBO_BOX (assistant->priv->video_device),
                     array, current_plugin);
   g_free (array);
diff --git a/src/gui/misc.cpp b/src/gui/misc.cpp
new file mode 100644
index 0000000..ca10912
--- /dev/null
+++ b/src/gui/misc.cpp
@@ -0,0 +1,81 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2009 Damien Sandras <dsandras seconix com>
+ *
+ * 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.
+ */
+
+
+/*
+ *                         misc.cpp  -  description
+ *                         ------------------------
+ *   begin                : Thu Nov 22 2001
+ *   copyright            : (C) 2000-2006 by Damien Sandras
+ *   description          : This file contains miscellaneous functions.
+ *   Additional Code      : De Michele Cristiano, Miguel Rodríguez
+ *
+ */
+
+
+#include "config.h"
+
+#include "misc.h"
+#include "ekiga.h"
+#include "callbacks.h"
+
+#include "gmdialog.h"
+#include "gmconf.h"
+
+#include <glib/gi18n.h>
+
+
+/* return the default audio device name */
+const gchar *get_default_audio_device_name (void)
+{
+#ifdef WIN32
+  return "Default (PTLIB/WindowsMultimedia)";
+#else
+  return "Default (PTLIB/ALSA)";
+#endif
+}
+
+/* return the default video name from the list of existing devices */
+const gchar *get_default_video_device_name (const gchar * const *options)
+{
+#ifdef WIN32
+  /* look for the entry containing "PTLIB/DirectShow" or "PTLIB/VideoForWindows" */
+  for (int i = 0; options[i]; i++)
+    if (g_strrstr (options[i], "PTLIB/DirectShow")
+        || g_strrstr (options[i], "PTLIB/VideoForWindows"))
+      return options[i];
+#else
+  /* look for the entry containing "PTLIB/V4L2", otherwise "PTLIB/V4L" */
+  for (int i = 0; options[i]; i++)
+    if (g_strrstr (options[i], "PTLIB/V4L2"))
+      return options[i];
+  for (int i = 0; options[i]; i++)
+    if (g_strrstr (options[i], "PTLIB/V4L"))
+      return options[i];
+#endif
+  return NULL;  // not found
+}
diff --git a/src/gui/misc.h b/src/gui/misc.h
new file mode 100644
index 0000000..a24a154
--- /dev/null
+++ b/src/gui/misc.h
@@ -0,0 +1,55 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2009 Damien Sandras <dsandras seconix com>
+ *
+ * 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.
+ */
+
+
+/*
+ *                         misc.h  -  description
+ *                         ----------------------
+ *   begin                : Thu Nov 22 2001
+ *   copyright            : (C) 2000-2006 by Damien Sandras
+ *   description          : This file contains miscellaneous functions.
+ *   Additional Code      : De Michele Cristiano, Miguel Rodríguez
+ *
+ */
+
+
+#ifndef _MISC_H_
+#define _MISC_H_
+
+/* DESCRIPTION  :  /
+ * BEHAVIOR     :  /
+ * PRE          :  /
+ */
+const gchar *get_default_audio_device_name (void);
+
+
+/* DESCRIPTION  :  /
+ * BEHAVIOR     :  /
+ * PRE          :  /
+ */
+const gchar *get_default_video_device_name (const gchar * const *options);
+#endif
diff --git a/src/gui/preferences.cpp b/src/gui/preferences.cpp
index b36ef76..41811ed 100644
--- a/src/gui/preferences.cpp
+++ b/src/gui/preferences.cpp
@@ -775,16 +775,16 @@ gm_pw_init_audio_devices_page (GtkWidget *prefs_window,
   gm_prefs_window_get_audiooutput_devices_list (pw->core, device_list);
   array = gm_prefs_window_convert_string_list(device_list);
   pw->sound_events_output = 
-    gnome_prefs_string_option_menu_new (subsection, _("Ringing Device"), (const gchar **)array, SOUND_EVENTS_KEY "output_device", _("Select the ringing audio device to use"), 0, "Default (PTLIB/ALSA)");
+    gnome_prefs_string_option_menu_new (subsection, _("Ringing Device"), (const gchar **)array, SOUND_EVENTS_KEY "output_device", _("Select the ringing audio device to use"), 0, get_default_audio_device_name ());
   pw->audio_player =
-    gnome_prefs_string_option_menu_new (subsection, _("Output device:"), (const gchar **)array, AUDIO_DEVICES_KEY "output_device", _("Select the audio output device to use"), 1, "Default (PTLIB/ALSA)");
+    gnome_prefs_string_option_menu_new (subsection, _("Output device:"), (const gchar **)array, AUDIO_DEVICES_KEY "output_device", _("Select the audio output device to use"), 1, get_default_audio_device_name ());
   g_free (array);
 
   /* The recorder */
   gm_prefs_window_get_audioinput_devices_list (pw->core, device_list);
   array = gm_prefs_window_convert_string_list(device_list);
   pw->audio_recorder =
-    gnome_prefs_string_option_menu_new (subsection, _("Input device:"), (const gchar **)array, AUDIO_DEVICES_KEY "input_device", _("Select the audio input device to use"), 2, "Default (PTLIB/ALSA)");
+    gnome_prefs_string_option_menu_new (subsection, _("Input device:"), (const gchar **)array, AUDIO_DEVICES_KEY "input_device", _("Select the audio input device to use"), 2, get_default_audio_device_name ());
   g_free (array);
 
 
@@ -1290,11 +1290,11 @@ gm_prefs_window_update_devices_list (GtkWidget *prefs_window)
   gnome_prefs_string_option_menu_update (pw->audio_player,
  					 (const gchar **)array,
  					 AUDIO_DEVICES_KEY "output_device",
-                                         "Default (PTLIB/ALSA)");
+ 					 get_default_audio_device_name ());
   gnome_prefs_string_option_menu_update (pw->sound_events_output,
                                          (const gchar **)array,
                                          SOUND_EVENTS_KEY "output_device",
-                                         "Default (PTLIB/ALSA)");
+                                         get_default_audio_device_name ());
   g_free (array);
 
   /* The recorder */
@@ -1303,7 +1303,7 @@ gm_prefs_window_update_devices_list (GtkWidget *prefs_window)
   gnome_prefs_string_option_menu_update (pw->audio_recorder,
  					 (const gchar **)array,
  					 AUDIO_DEVICES_KEY "input_device",
-                                         "Default (PTLIB/ALSA)");
+ 					 get_default_audio_device_name ());
   g_free (array);
 
 
@@ -1313,7 +1313,7 @@ gm_prefs_window_update_devices_list (GtkWidget *prefs_window)
   gnome_prefs_string_option_menu_update (pw->video_device,
 					 (const gchar **)array,
 					 VIDEO_DEVICES_KEY "input_device",
-                                         NULL);
+					 get_default_video_device_name (array));
   g_free (array);
 }
 



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