summaryrefslogtreecommitdiffstats
path: root/patches/gstreamer/gst-plugins-good-0.10.16-rusxmms.diff
blob: 95aea1993e39854d71951d8fba12eb891a889fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
diff -dPNur gst-plugins-good-0.10.16/configure.ac gst-plugins-good-0.10.16-ds/configure.ac
--- gst-plugins-good-0.10.16/configure.ac	2009-08-29 00:05:24.000000000 +0400
+++ gst-plugins-good-0.10.16-ds/configure.ac	2009-10-29 06:20:29.000000000 +0300
@@ -939,6 +939,13 @@
   AC_SUBST(BZ2_LIBS)
 ])
 
+dnl *** id3demux to use LibRCC
+translit(dnm, m, l) AM_CONDITIONAL(USE_LIBRCC, true)
+AG_GST_CHECK_FEATURE(LIBRCC, [librcc support for id3demux],, [
+  AG_GST_CHECK_LIBHEADER(LIBRCC, rcc, rccInit, ,librcc.h, LIBRCC_LIBS="-lrcc")
+  AC_SUBST(LIBRCC_LIBS)
+])
+
 else
 
 dnl not building plugins with external dependencies,
@@ -974,6 +981,7 @@
 AM_CONDITIONAL(USE_XSHM, false)
 AM_CONDITIONAL(USE_XVIDEO, false)
 AM_CONDITIONAL(USE_ZLIB, false)
+AM_CONDITIONAL(USE_LIBRCC, false)
 
 fi dnl of EXT plugins
 
diff -dPNur gst-plugins-good-0.10.16/gst/id3demux/gstid3demux.c gst-plugins-good-0.10.16-ds/gst/id3demux/gstid3demux.c
--- gst-plugins-good-0.10.16/gst/id3demux/gstid3demux.c	2009-08-11 02:15:55.000000000 +0400
+++ gst-plugins-good-0.10.16-ds/gst/id3demux/gstid3demux.c	2009-10-29 06:44:25.000000000 +0300
@@ -56,6 +56,7 @@
 
 #include "gstid3demux.h"
 #include "id3tags.h"
+#include "rccpatch.h"
 
 static const GstElementDetails gst_id3demux_details =
 GST_ELEMENT_DETAILS ("ID3 tag demuxer",
@@ -107,11 +108,22 @@
 }
 
 static void
+gst_id3demux_finalize (GObject * object)
+{
+  GstID3Demux *demux = GST_ID3DEMUX (object);
+
+  rcc_patch_unref();
+  
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
 gst_id3demux_class_init (GstID3DemuxClass * klass)
 {
   GstTagDemuxClass *tagdemux_class = (GstTagDemuxClass *) klass;
   GObjectClass *gobject_class = (GObjectClass *) klass;
 
+  gobject_class->finalize = gst_id3demux_finalize;
   gobject_class->set_property = gst_id3demux_set_property;
   gobject_class->get_property = gst_id3demux_get_property;
 
@@ -133,6 +145,7 @@
 gst_id3demux_init (GstID3Demux * id3demux, GstID3DemuxClass * klass)
 {
   id3demux->prefer_v1 = DEFAULT_PREFER_V1;
+  rcc_patch_ref();
 }
 
 static gboolean
diff -dPNur gst-plugins-good-0.10.16/gst/id3demux/id3v2frames.c gst-plugins-good-0.10.16-ds/gst/id3demux/id3v2frames.c
--- gst-plugins-good-0.10.16/gst/id3demux/id3v2frames.c	2009-08-11 02:15:55.000000000 +0400
+++ gst-plugins-good-0.10.16-ds/gst/id3demux/id3v2frames.c	2009-10-29 06:40:17.000000000 +0300
@@ -33,6 +33,7 @@
 #endif
 
 #include "id3tags.h"
+#include "rccpatch.h"
 
 GST_DEBUG_CATEGORY_EXTERN (id3demux_debug);
 #define GST_CAT_DEFAULT (id3demux_debug)
@@ -986,7 +987,12 @@
         utf8 = NULL;
       }
     }
-  }
+  } 
+
+  /* Try LibRCC library to detect encoding */
+  utf8 = rcc_patch_to_utf8(start, size);
+  if (utf8) goto beach;
+  
   /* Try current locale (if not UTF-8) */
   if (!g_get_charset (&env)) {
     if ((utf8 = g_locale_to_utf8 (start, size, &bytes_read, NULL, NULL))) {
diff -dPNur gst-plugins-good-0.10.16/gst/id3demux/Makefile.am gst-plugins-good-0.10.16-ds/gst/id3demux/Makefile.am
--- gst-plugins-good-0.10.16/gst/id3demux/Makefile.am	2009-08-11 02:15:55.000000000 +0400
+++ gst-plugins-good-0.10.16-ds/gst/id3demux/Makefile.am	2009-10-29 06:20:06.000000000 +0300
@@ -1,10 +1,15 @@
 plugin_LTLIBRARIES = libgstid3demux.la
 
-libgstid3demux_la_SOURCES = gstid3demux.c id3tags.c id3v2frames.c
+libgstid3demux_la_SOURCES = gstid3demux.c id3tags.c id3v2frames.c rccpatch.c
 libgstid3demux_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) 
 libgstid3demux_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgsttag-@GST_MAJORMINOR@ \
 	-lgstpbutils-@GST_MAJORMINOR@ $(GST_BASE_LIBS) $(ZLIB_LIBS)
 libgstid3demux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstid3demux_la_LIBTOOLFLAGS = --tag=disable-static
 
-noinst_HEADERS = gstid3demux.h id3tags.h
+if USE_LIBRCC
+    libgstid3demux_la_LIBADD +=  @LIBRCC_LIBS@
+endif
+
+
+noinst_HEADERS = gstid3demux.h id3tags.h rccpatch.h
diff -dPNur gst-plugins-good-0.10.16/gst/id3demux/rccpatch.c gst-plugins-good-0.10.16-ds/gst/id3demux/rccpatch.c
--- gst-plugins-good-0.10.16/gst/id3demux/rccpatch.c	1970-01-01 03:00:00.000000000 +0300
+++ gst-plugins-good-0.10.16-ds/gst/id3demux/rccpatch.c	2009-10-29 07:05:20.000000000 +0300
@@ -0,0 +1,91 @@
+#ifdef HAVE_CONFIG_H 
+#include "config.h" 
+#endif 
+
+#include <stdlib.h>
+#include "rccpatch.h"
+
+#ifdef HAVE_LIBRCC
+# include <librcc.h>
+#endif /* HAVE_LIBRCC */
+
+
+#ifdef HAVE_LIBRCC
+# define ID3_CLASS 0
+# define ID3V2_CLASS 1
+# define UTF_CLASS 2
+# define OUT_CLASS 3
+static rcc_class classes[] = {
+    { "id3", RCC_CLASS_STANDARD, NULL, NULL, "ID3 Encoding", 0 },
+    { "id3v2", RCC_CLASS_STANDARD, "id3", NULL, "ID3 v.2 Encoding", 0 },
+    { "utf", RCC_CLASS_KNOWN, "UTF-8", NULL, "Unicode Encoding", 0},
+    { "out", RCC_CLASS_TRANSLATE_LOCALE, "LC_CTYPE", NULL, "Output Encoding", 0 },
+    { NULL, RCC_CLASS_STANDARD, NULL, NULL, NULL, 0 }
+};
+
+static int rcc_initialized = 0;
+
+static rcc_context ctx = NULL;
+#endif /* HAVE_LIBRCC */
+
+
+static void rcc_patch_free() {
+#ifdef HAVE_LIBRCC
+    if (rcc_initialized) {
+	puts("clean");
+       rccFree();
+       rcc_initialized = 0;
+    }
+#endif /* HAVE_LIBRCC */
+}
+
+static void rcc_patch_init() {
+#ifdef HAVE_LIBRCC
+    if (rcc_initialized) return;
+    puts("init");
+    rccInit();
+    rccInitDefaultContext(NULL, 0, 0, classes, 0);
+    rccLoad(NULL, "xmms");
+    rccInitDb4(NULL, NULL, 0);
+    rcc_initialized = 1;
+#endif /* HAVE_LIBRCC */
+}
+
+static int registered = 0;
+static int ref_count = 0;
+static GStaticMutex lock = G_STATIC_MUTEX_INIT;
+
+void rcc_patch_ref() {
+    puts("ref");
+    g_static_mutex_lock(&lock);
+    if (!registered) {
+	g_atexit(rcc_patch_free);
+	registered = 1;
+    }
+    if (++ref_count==1) rcc_patch_init();
+    g_static_mutex_unlock(&lock);
+}
+
+void rcc_patch_unref() {
+    puts("unref");
+    g_static_mutex_lock(&lock);
+    if (--ref_count==0) rcc_patch_free();
+    g_static_mutex_unlock(&lock);
+}
+
+gchar *rcc_patch_to_utf8(const gchar *str, const guint size) {
+#ifdef HAVE_LIBRCC
+    gchar *res;
+
+    if (rcc_initialized) {
+	g_static_mutex_lock(&lock);
+	res = rccSizedRecode(ctx, ID3_CLASS, UTF_CLASS, str, size, NULL);
+	g_static_mutex_unlock(&lock);
+
+	return res;
+    }
+#endif /* HAVE_LIBRCC */
+
+    return  NULL;
+}
+
diff -dPNur gst-plugins-good-0.10.16/gst/id3demux/rccpatch.h gst-plugins-good-0.10.16-ds/gst/id3demux/rccpatch.h
--- gst-plugins-good-0.10.16/gst/id3demux/rccpatch.h	1970-01-01 03:00:00.000000000 +0300
+++ gst-plugins-good-0.10.16-ds/gst/id3demux/rccpatch.h	2009-10-29 06:23:58.000000000 +0300
@@ -0,0 +1,12 @@
+#ifndef _RCC_PATCH_H
+#define _RCC_PATCH_H
+
+#include <gst/gst.h>
+
+void rcc_patch_ref();
+void rcc_patch_unref();
+
+gchar *rcc_patch_to_utf8(const gchar *str, const guint size);
+
+
+#endif /* _RCC_PATCH_H */