mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst/subparse/gstsubparse.*: Add 'encoding' property (#341681).
Original commit message from CVS: Patch by: Young-Ho Cha <ganadist chollian net> * gst/subparse/gstsubparse.c: (gst_sub_parse_dispose), (gst_sub_parse_class_init), (gst_sub_parse_init), (gst_sub_parse_set_property), (gst_sub_parse_get_property), (convert_encoding): * gst/subparse/gstsubparse.h: Add 'encoding' property (#341681). * gst/subparse/samiparse.c: (characters_sami): Output is pango markup, so we need to escape text between tags (#342143).
This commit is contained in:
parent
10d35563dd
commit
7b7a6d12f5
5 changed files with 93 additions and 4 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2006-05-17 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
Patch by: Young-Ho Cha <ganadist chollian net>
|
||||||
|
|
||||||
|
* gst/subparse/gstsubparse.c: (gst_sub_parse_dispose),
|
||||||
|
(gst_sub_parse_class_init), (gst_sub_parse_init),
|
||||||
|
(gst_sub_parse_set_property), (gst_sub_parse_get_property),
|
||||||
|
(convert_encoding):
|
||||||
|
* gst/subparse/gstsubparse.h:
|
||||||
|
Add 'encoding' property (#341681).
|
||||||
|
|
||||||
|
* gst/subparse/samiparse.c: (characters_sami):
|
||||||
|
Output is pango markup, so we need to escape text
|
||||||
|
between tags (#342143).
|
||||||
|
|
||||||
2006-05-16 Tim-Philipp Müller <tim at centricular dot net>
|
2006-05-16 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst-libs/gst/audio/multichannel.c:
|
* gst-libs/gst/audio/multichannel.c:
|
||||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit 3062df90281144cbdb55bd58ee9f0714ab346c23
|
Subproject commit 8eb9ea46137c34191bdbeca946ca4419ba573b51
|
|
@ -34,6 +34,22 @@
|
||||||
GST_DEBUG_CATEGORY_STATIC (sub_parse_debug);
|
GST_DEBUG_CATEGORY_STATIC (sub_parse_debug);
|
||||||
#define GST_CAT_DEFAULT sub_parse_debug
|
#define GST_CAT_DEFAULT sub_parse_debug
|
||||||
|
|
||||||
|
#define DEFAULT_ENCODING NULL
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_ENCODING
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_sub_parse_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
static void
|
||||||
|
gst_sub_parse_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
|
|
||||||
static const GstElementDetails sub_parse_details =
|
static const GstElementDetails sub_parse_details =
|
||||||
GST_ELEMENT_DETAILS ("Subtitle parser",
|
GST_ELEMENT_DETAILS ("Subtitle parser",
|
||||||
"Codec/Parser/Subtitle",
|
"Codec/Parser/Subtitle",
|
||||||
|
@ -123,6 +139,10 @@ gst_sub_parse_dispose (GObject * object)
|
||||||
gst_segment_free (subparse->segment);
|
gst_segment_free (subparse->segment);
|
||||||
subparse->segment = NULL;
|
subparse->segment = NULL;
|
||||||
}
|
}
|
||||||
|
if (subparse->encoding) {
|
||||||
|
g_free (subparse->encoding);
|
||||||
|
subparse->encoding = NULL;
|
||||||
|
}
|
||||||
sami_context_deinit (&subparse->state);
|
sami_context_deinit (&subparse->state);
|
||||||
|
|
||||||
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
|
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
|
||||||
|
@ -137,8 +157,17 @@ gst_sub_parse_class_init (GstSubParseClass * klass)
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
object_class->dispose = gst_sub_parse_dispose;
|
object_class->dispose = gst_sub_parse_dispose;
|
||||||
|
object_class->set_property = gst_sub_parse_set_property;
|
||||||
|
object_class->get_property = gst_sub_parse_get_property;
|
||||||
|
|
||||||
element_class->change_state = gst_sub_parse_change_state;
|
element_class->change_state = gst_sub_parse_change_state;
|
||||||
|
|
||||||
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ENCODING,
|
||||||
|
g_param_spec_string ("encoding", "subtitle charset encoding",
|
||||||
|
"Encoding to assume if input subtitles are not in UTF-8 encoding. "
|
||||||
|
"If not set, the GST_SUBTITLE_ENCODING environment variable will "
|
||||||
|
"be checked for an encoding to use. If that is not set either, "
|
||||||
|
"ISO-8859-15 will be assumed.", DEFAULT_ENCODING, G_PARAM_READWRITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -167,6 +196,7 @@ gst_sub_parse_init (GstSubParse * subparse)
|
||||||
GST_WARNING_OBJECT (subparse, "segment creation failed");
|
GST_WARNING_OBJECT (subparse, "segment creation failed");
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
subparse->encoding = g_strdup (DEFAULT_ENCODING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -237,6 +267,43 @@ beach:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_sub_parse_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstSubParse *subparse = GST_SUBPARSE (object);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (subparse);
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_ENCODING:
|
||||||
|
g_free (subparse->encoding);
|
||||||
|
subparse->encoding = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (subparse);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_sub_parse_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstSubParse *subparse = GST_SUBPARSE (object);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (subparse);
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_ENCODING:
|
||||||
|
g_value_set_string (value, subparse->encoding);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (subparse);
|
||||||
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
convert_encoding (GstSubParse * self, const gchar * str, gsize len)
|
convert_encoding (GstSubParse * self, const gchar * str, gsize len)
|
||||||
{
|
{
|
||||||
|
@ -253,7 +320,10 @@ convert_encoding (GstSubParse * self, const gchar * str, gsize len)
|
||||||
self->valid_utf8 = FALSE;
|
self->valid_utf8 = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
encoding = g_getenv ("GST_SUBTITLE_ENCODING");
|
encoding = self->encoding;
|
||||||
|
if (encoding == NULL || *encoding == '\0') {
|
||||||
|
encoding = g_getenv ("GST_SUBTITLE_ENCODING");
|
||||||
|
}
|
||||||
if (encoding == NULL || *encoding == '\0') {
|
if (encoding == NULL || *encoding == '\0') {
|
||||||
/* if local encoding is UTF-8 and no encoding specified
|
/* if local encoding is UTF-8 and no encoding specified
|
||||||
* via the environment variable, assume ISO-8859-15 */
|
* via the environment variable, assume ISO-8859-15 */
|
||||||
|
|
|
@ -84,6 +84,7 @@ struct _GstSubParse {
|
||||||
|
|
||||||
gboolean flushing;
|
gboolean flushing;
|
||||||
gboolean valid_utf8;
|
gboolean valid_utf8;
|
||||||
|
gchar *encoding;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstSubParseClass {
|
struct _GstSubParseClass {
|
||||||
|
|
|
@ -235,18 +235,21 @@ static void
|
||||||
characters_sami (void *ctx, const xmlChar * ch, int len)
|
characters_sami (void *ctx, const xmlChar * ch, int len)
|
||||||
{
|
{
|
||||||
GstSamiContext *sctx = (GstSamiContext *) ctx;
|
GstSamiContext *sctx = (GstSamiContext *) ctx;
|
||||||
|
gchar *escaped;
|
||||||
|
|
||||||
/* skip title */
|
/* skip title */
|
||||||
if (sctx->in_title)
|
if (sctx->in_title)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
escaped = g_markup_escape_text ((const gchar *) ch, len);
|
||||||
if (has_tag (sctx->state, RT_TAG)) {
|
if (has_tag (sctx->state, RT_TAG)) {
|
||||||
g_string_append_c (sctx->rubybuf, ' ');
|
g_string_append_c (sctx->rubybuf, ' ');
|
||||||
g_string_append_len (sctx->rubybuf, (const gchar *) ch, len);
|
g_string_append (sctx->rubybuf, escaped);
|
||||||
g_string_append_c (sctx->rubybuf, ' ');
|
g_string_append_c (sctx->rubybuf, ' ');
|
||||||
} else {
|
} else {
|
||||||
g_string_append_len (sctx->buf, (const gchar *) ch, len);
|
g_string_append (sctx->buf, escaped);
|
||||||
}
|
}
|
||||||
|
g_free (escaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
static xmlSAXHandler samiSAXHandlerStruct = {
|
static xmlSAXHandler samiSAXHandlerStruct = {
|
||||||
|
|
Loading…
Reference in a new issue