[ekiga] Applied patch from Eugen Dedu to fix bug #575907
- From: Julien Puydt <jpuydt src gnome org>
- To: svn-commits-list gnome org
- Subject: [ekiga] Applied patch from Eugen Dedu to fix bug #575907
- Date: Tue, 21 Apr 2009 03:01:44 -0400 (EDT)
commit c9aedde448254512c81ce30d5a0ac869c15e679c
Author: Julien Puydt <jpuydt noether localdomain>
Date: Tue Apr 21 09:01:03 2009 +0200
Applied patch from Eugen Dedu to fix bug #575907
It consists in two functions to translate C++ strings between the utf8 and latin1 encodings
---
lib/engine/components/ptlib/Makefile.am | 2 +
.../components/ptlib/audioinput-manager-ptlib.cpp | 14 ++++++-
.../components/ptlib/audiooutput-manager-ptlib.cpp | 28 +++++++++----
lib/engine/components/ptlib/utils.cpp | 42 ++++++++++++++++++++
lib/engine/components/ptlib/utils.h | 4 ++
.../components/ptlib/videoinput-manager-ptlib.cpp | 20 +++++++--
6 files changed, 94 insertions(+), 16 deletions(-)
diff --git a/lib/engine/components/ptlib/Makefile.am b/lib/engine/components/ptlib/Makefile.am
index 5f68290..159e190 100644
--- a/lib/engine/components/ptlib/Makefile.am
+++ b/lib/engine/components/ptlib/Makefile.am
@@ -15,6 +15,8 @@ INCLUDES = \
-I$(top_srcdir)/lib/engine/hal
libgmptlib_la_SOURCES = \
+ $(ptlib_dir)/utils.h \
+ $(ptlib_dir)/utils.cpp \
$(ptlib_dir)/audioinput-manager-ptlib.h \
$(ptlib_dir)/audioinput-manager-ptlib.cpp \
$(ptlib_dir)/audioinput-main-ptlib.h \
diff --git a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
index 8b53fed..e76f021 100644
--- a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
@@ -37,6 +37,7 @@
#include "audioinput-manager-ptlib.h"
#include "ptbuildopts.h"
#include "ptlib.h"
+#include "utils.h"
#define DEVICE_TYPE "PTLIB"
@@ -76,7 +77,12 @@ 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
+ device.name = latin2utf (devices_array[j]);
+#endif
devices.push_back(device);
}
free (devices_array);
@@ -106,13 +112,17 @@ bool GMAudioInputManager_ptlib::open (unsigned channels, unsigned samplerate, un
current_state.samplerate = samplerate;
current_state.bits_per_sample = bits_per_sample;
- input_device = PSoundChannel::CreateOpenedChannel (current_state.device.source,
+ 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
PSoundChannel::Recorder,
channels,
samplerate,
bits_per_sample);
-
+
Ekiga::AudioInputErrorCodes error_code = Ekiga::AI_ERROR_NONE;
if (!input_device)
error_code = Ekiga::AI_ERROR_DEVICE;
diff --git a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
index c9bfcef..9d60dd3 100644
--- a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
@@ -37,6 +37,7 @@
#include "audiooutput-manager-ptlib.h"
#include "ptbuildopts.h"
#include "ptlib.h"
+#include "utils.h"
#define DEVICE_TYPE "PTLIB"
@@ -76,7 +77,12 @@ 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
+ device.name = latin2utf (devices_array[j]);
+#endif
devices.push_back(device);
}
free (devices_array);
@@ -90,7 +96,7 @@ bool GMAudioOutputManager_ptlib::set_device (Ekiga::AudioOutputPS ps, const Ekig
if ( device.type == DEVICE_TYPE ) {
PTRACE(4, "GMAudioOutputManager_ptlib\tSetting Device[" << ps << "] " << device);
- current_state[ps].device = device;
+ current_state[ps].device = device;
return true;
}
@@ -106,12 +112,16 @@ bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channel
current_state[ps].samplerate = samplerate;
current_state[ps].bits_per_sample = bits_per_sample;
- output_device[ps] = PSoundChannel::CreateOpenedChannel (current_state[ps].device.source,
- current_state[ps].device.name,
- PSoundChannel::Player,
- channels,
- samplerate,
- 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
+ PSoundChannel::Player,
+ channels,
+ samplerate,
+ bits_per_sample);
Ekiga::AudioOutputErrorCodes error_code = Ekiga::AO_ERROR_NONE;
if (!output_device[ps])
@@ -155,8 +165,8 @@ void GMAudioOutputManager_ptlib::set_buffer_size (Ekiga::AudioOutputPS ps, unsig
}
-bool GMAudioOutputManager_ptlib::set_frame_data (Ekiga::AudioOutputPS ps,
- const char *data,
+bool GMAudioOutputManager_ptlib::set_frame_data (Ekiga::AudioOutputPS ps,
+ const char *data,
unsigned size,
unsigned & bytes_written)
{
diff --git a/lib/engine/components/ptlib/utils.cpp b/lib/engine/components/ptlib/utils.cpp
new file mode 100644
index 0000000..eb8f095
--- /dev/null
+++ b/lib/engine/components/ptlib/utils.cpp
@@ -0,0 +1,42 @@
+#include <glib.h>
+
+#include "utils.h"
+
+const std::string
+latin2utf (const std::string str)
+{
+ gchar *utf8_str;
+ std::string result;
+
+ if (g_utf8_validate (str.c_str (), -1, NULL))
+ utf8_str = g_strdup (str.c_str ());
+ else
+ utf8_str = g_convert (str.c_str (), -1,
+ "UTF-8", "ISO-8859-1",
+ NULL, NULL, NULL);
+
+ result = std::string (utf8_str);
+
+ g_free (utf8_str);
+
+ return result;
+}
+
+
+const std::string
+utf2latin (const std::string str)
+{
+ gchar *utf8_str;
+ std::string result;
+
+ g_warn_if_fail (g_utf8_validate (str.c_str (), -1, NULL));
+ utf8_str = g_convert (str.c_str (), -1,
+ "ISO-8859-1", "UTF-8",
+ NULL, NULL, NULL);
+
+ result = std::string (utf8_str);
+
+ g_free (utf8_str);
+
+ return result;
+}
diff --git a/lib/engine/components/ptlib/utils.h b/lib/engine/components/ptlib/utils.h
new file mode 100644
index 0000000..366a6f6
--- /dev/null
+++ b/lib/engine/components/ptlib/utils.h
@@ -0,0 +1,4 @@
+#include <string>
+
+const std::string latin2utf (const std::string str);
+const std::string utf2latin (const std::string str);
diff --git a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
index 84b6f17..87ec2ee 100644
--- a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
@@ -37,6 +37,7 @@
#include "videoinput-manager-ptlib.h"
#include "ptbuildopts.h"
#include "ptlib.h"
+#include "utils.h"
#define DEVICE_TYPE "PTLIB"
@@ -75,15 +76,20 @@ void GMVideoInputManager_ptlib::get_devices(std::vector <Ekiga::VideoInputDevice
(device.source != "FFMPEG") ) {
video_devices = PVideoInputDevice::GetDriversDeviceNames (device.source);
devices_array = video_devices.ToCharArray ();
-
+
for (PINDEX j = 0; devices_array[j] != NULL; j++) {
-
+
+#ifdef WIN32
device.name = devices_array[j];
- devices.push_back(device);
+#else
+ // linux USB subsystem uses latin-1 encoding, while ekiga uses utf-8
+ device.name = latin2utf (devices_array[j]);
+#endif
+ devices.push_back(device);
}
free (devices_array);
}
- }
+ }
free (sources_array);
}
@@ -92,7 +98,7 @@ bool GMVideoInputManager_ptlib::set_device (const Ekiga::VideoInputDevice & devi
if ( device.type == DEVICE_TYPE ) {
PTRACE(4, "GMVideoInputManager_ptlib\tSetting Device " << device);
- current_state.device = device;
+ current_state.device = device;
current_state.channel = channel;
current_state.format = format;
return true;
@@ -114,7 +120,11 @@ 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
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]