[ekiga] Fixed processing on camera names with non-ascii characters on Windows too



commit 90b6fe1cbe6ab7cef3e4954d4cae767e65df9b8c
Author: Michael Rickmann <mrickma gwdg de>
Date:   Tue Jul 21 21:37:56 2009 +0200

    Fixed processing on camera names with non-ascii characters on Windows too

 .../components/ptlib/audioinput-manager-ptlib.cpp  |   13 +++----------
 .../components/ptlib/audiooutput-manager-ptlib.cpp |   13 +++----------
 lib/engine/components/ptlib/utils.cpp              |   11 ++++++++++-
 .../components/ptlib/videoinput-manager-ptlib.cpp  |   13 +++----------
 4 files changed, 19 insertions(+), 31 deletions(-)
---
diff --git a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
index 0d70fc0..f783a52 100644
--- a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
@@ -77,12 +77,9 @@ void GMAudioInputManager_ptlib::get_devices(std::vector <Ekiga::AudioInputDevice
 
       for (PINDEX j = 0; devices_array[j] != NULL; j++) {
 
-#ifdef WIN32
-        device.name = devices_array[j];
-#else
-        // linux USB subsystem uses latin-1 encoding, while ekiga uses utf-8
+        /* linux USB subsystem uses latin-1 encoding, Windows codepage,
+           while ekiga uses utf-8 */
         device.name = latin2utf (devices_array[j]);
-#endif
         devices.push_back(device);
       }
       free (devices_array);
@@ -113,11 +110,7 @@ bool GMAudioInputManager_ptlib::open (unsigned channels, unsigned samplerate, un
   current_state.bits_per_sample = bits_per_sample;
 
   input_device = PSoundChannel::CreateOpenedChannel (current_state.device.source,
-#ifdef WIN32
-                                                     current_state.device.name,
-#else
-                                                     utf2latin (current_state.device.name),  // reencode back to latin-1
-#endif
+                                                     utf2latin (current_state.device.name),  // reencode back to latin-1 or codepage
                                                      PSoundChannel::Recorder,
                                                      channels,
                                                      samplerate,
diff --git a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
index 763aaa4..04c1310 100644
--- a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
@@ -77,12 +77,9 @@ void GMAudioOutputManager_ptlib::get_devices(std::vector <Ekiga::AudioOutputDevi
 
       for (PINDEX j = 0; devices_array[j] != NULL; j++) {
 
-#ifdef WIN32
-        device.name = devices_array[j];
-#else
-        // linux USB subsystem uses latin-1 encoding, while ekiga uses utf-8
+        /* linux USB subsystem uses latin-1 encoding, Windows codepage,
+           while ekiga uses utf-8 */
         device.name = latin2utf (devices_array[j]);
-#endif
         devices.push_back(device);
       }
       free (devices_array);
@@ -113,11 +110,7 @@ bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channel
   current_state[ps].bits_per_sample = bits_per_sample;
 
   output_device[ps] = PSoundChannel::CreateOpenedChannel (current_state[ps].device.source,
-#ifdef WIN32
-                                                          current_state[ps].device.name,
-#else
-                                                          utf2latin (current_state[ps].device.name),  // reencode back to latin-1
-#endif
+                                                          utf2latin (current_state[ps].device.name),  // reencode back to latin-1 or codepage
                                                           PSoundChannel::Player,
                                                           channels,
                                                           samplerate,
diff --git a/lib/engine/components/ptlib/utils.cpp b/lib/engine/components/ptlib/utils.cpp
index c86f250..197b649 100644
--- a/lib/engine/components/ptlib/utils.cpp
+++ b/lib/engine/components/ptlib/utils.cpp
@@ -43,10 +43,14 @@ latin2utf (const std::string str)
 {
   gchar *utf8_str;
   std::string result;
-
+#ifdef WIN32
+  utf8_str = g_locale_to_utf8 (str.c_str (), -1,
+                               NULL, NULL, NULL);
+#else
   utf8_str = g_convert (str.c_str (), -1,
                         "UTF-8", "ISO-8859-1",
                         NULL, NULL, NULL);
+#endif
   result = std::string (utf8_str);
   g_free (utf8_str);
   return result;
@@ -60,9 +64,14 @@ utf2latin (const std::string str)
   std::string result;
 
   g_warn_if_fail (g_utf8_validate (str.c_str (), -1, NULL));
+#ifdef WIN32
+  latin_str = g_locale_from_utf8 (str.c_str (), -1,
+                                  NULL, NULL, NULL);
+#else
   latin_str = g_convert (str.c_str (), -1,
                          "ISO-8859-1", "UTF-8",
                          NULL, NULL, NULL);
+#endif
   result = std::string (latin_str);
   g_free (latin_str);
   return result;
diff --git a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
index aacb497..ba8553a 100644
--- a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
@@ -79,12 +79,9 @@ void GMVideoInputManager_ptlib::get_devices(std::vector <Ekiga::VideoInputDevice
 
       for (PINDEX j = 0; devices_array[j] != NULL; j++) {
 
-#ifdef WIN32
-        device.name = devices_array[j];
-#else
-        // linux USB subsystem uses latin-1 encoding, while ekiga uses utf-8
+        /* linux USB subsystem uses latin-1 encoding, Windows codepage,
+           while ekiga uses utf-8 */
         device.name = latin2utf (devices_array[j]);
-#endif
         devices.push_back(device);
       }
       free (devices_array);
@@ -120,11 +117,7 @@ bool GMVideoInputManager_ptlib::open (unsigned width, unsigned height, unsigned
   expectedFrameSize = (width * height * 3) >> 1;
 
   pvideo_format = (PVideoDevice::VideoFormat)current_state.format;
-#ifdef WIN32
-  input_device = PVideoInputDevice::CreateOpenedDevice (current_state.device.source, current_state.device.name, FALSE);
-#else
-  input_device = PVideoInputDevice::CreateOpenedDevice (current_state.device.source, utf2latin (current_state.device.name), FALSE);  // reencode back to latin-1
-#endif
+  input_device = PVideoInputDevice::CreateOpenedDevice (current_state.device.source, utf2latin (current_state.device.name), FALSE);  // reencode back to latin-1 or codepage
 
   Ekiga::VideoInputErrorCodes error_code = Ekiga::VI_ERROR_NONE;
   if (!input_device)



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