? gst/pb
Index: gst/playback/gstplaybasebin.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gstplaybasebin.c,v
retrieving revision 1.109
diff -u -r1.109 gstplaybasebin.c
--- gst/playback/gstplaybasebin.c	11 May 2006 21:01:05 -0000	1.109
+++ gst/playback/gstplaybasebin.c	24 May 2006 12:45:11 -0000
@@ -71,7 +71,8 @@
   ARG_SOURCE,
   ARG_VIDEO,
   ARG_AUDIO,
-  ARG_TEXT
+  ARG_TEXT,
+  ARG_SUBTITLE_ENCODING
 };
 
 static void gst_play_base_bin_class_init (GstPlayBaseBinClass * klass);
@@ -187,6 +188,12 @@
       g_param_spec_int ("current-text", "Current text",
           "Currently playing text stream (-1 = none)",
           -1, G_MAXINT, -1, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_klass, ARG_SUBTITLE_ENCODING,
+      g_param_spec_string ("subtitle-encoding", "subtitle 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.", NULL, G_PARAM_READWRITE));
 
   GST_DEBUG_CATEGORY_INIT (gst_play_base_bin_debug, "playbasebin", 0,
       "playbasebin");
@@ -208,6 +215,8 @@
   play_base_bin->source = NULL;
   play_base_bin->decoder = NULL;
   play_base_bin->subtitle = NULL;
+  play_base_bin->subencoding = NULL;
+  play_base_bin->subtitle_elements = g_slist_alloc ();
 
   play_base_bin->group_lock = g_mutex_new ();
   play_base_bin->group_cond = g_cond_new ();
@@ -229,6 +238,10 @@
   play_base_bin->uri = NULL;
   g_free (play_base_bin->suburi);
   play_base_bin->suburi = NULL;
+  g_free (play_base_bin->subencoding);
+  play_base_bin->subencoding = NULL;
+  g_slist_free (play_base_bin->subtitle_elements);
+  play_base_bin->subtitle_elements = NULL;
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
@@ -1147,6 +1160,43 @@
   }
 }
 
+static void
+set_encoding_element (GstElement * element, gchar * encoding)
+{
+  if (!element)
+    return;
+  GST_DEBUG ("Set element %s encoding property to %s",
+      GST_ELEMENT_NAME (element), encoding);
+  g_object_set (G_OBJECT (element), "subtitle-encoding", encoding, NULL);
+}
+
+
+static void
+cb_decodebin_add_element (GstBin * decodebin, GstElement * element,
+    gpointer data)
+{
+
+  GstPlayBaseBin *play_base_bin = GST_PLAY_BASE_BIN (data);
+
+  if (!g_object_class_find_property (G_OBJECT_GET_CLASS (element),
+          "subtitle-encoding"))
+    return;
+  set_encoding_element (element, play_base_bin->subencoding);
+  play_base_bin->subtitle_elements =
+      g_slist_append (play_base_bin->subtitle_elements, element);
+}
+
+static void
+cb_decodebin_remove_element (GstBin * decodebin, GstElement * element,
+    gpointer data)
+{
+
+  GstPlayBaseBin *play_base_bin = GST_PLAY_BASE_BIN (data);
+
+  play_base_bin->subtitle_elements =
+      g_slist_remove (play_base_bin->subtitle_elements, element);
+}
+
 
 /*
  * Generate source ! subparse bins.
@@ -1161,9 +1211,13 @@
   if (!source)
     return NULL;
   subparse = gst_element_factory_make ("decodebin", "subtitle-decoder");
-
+  g_signal_connect (subparse, "element-added",
+      G_CALLBACK (cb_decodebin_add_element), play_base_bin);
+  g_signal_connect (subparse, "element-removed",
+      G_CALLBACK (cb_decodebin_remove_element), play_base_bin);
   subbin = gst_bin_new ("subtitle-bin");
   gst_bin_add_many (GST_BIN (subbin), source, subparse, NULL);
+
   gst_element_link (source, subparse);
 
   /* return the subtitle GstElement object */
@@ -1802,6 +1856,24 @@
           GST_STREAM_TYPE_TEXT, g_value_get_int (value));
       GROUP_UNLOCK (play_base_bin);
       break;
+    case ARG_SUBTITLE_ENCODING:
+    {
+      const gchar *encoding = g_value_get_string (value);
+
+      if (encoding == NULL) {
+        g_warning ("cannot set NULL encoding");
+        return;
+      }
+      if ((!encoding && !play_base_bin->subencoding) ||
+          (encoding && play_base_bin->subencoding &&
+              !strcmp (play_base_bin->subencoding, encoding)))
+        return;
+      g_free (play_base_bin->subencoding);
+      play_base_bin->subencoding = g_strdup (encoding);
+      g_slist_foreach (play_base_bin->subtitle_elements,
+          (GFunc) set_encoding_element, play_base_bin->subencoding);
+      break;
+    }
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1876,6 +1948,9 @@
               GST_STREAM_TYPE_TEXT));
       GROUP_UNLOCK (play_base_bin);
       break;
+    case ARG_SUBTITLE_ENCODING:
+      g_value_set_string (value, play_base_bin->subencoding);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
Index: gst/playback/gstplaybasebin.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gstplaybasebin.h,v
retrieving revision 1.20
diff -u -r1.20 gstplaybasebin.h
--- gst/playback/gstplaybasebin.h	11 May 2006 21:01:05 -0000	1.20
+++ gst/playback/gstplaybasebin.h	24 May 2006 12:45:11 -0000
@@ -75,11 +75,12 @@
 
   /* currently loaded media */
   gint           current[NUM_TYPES];
-  gchar         *uri, *suburi;
+  gchar         *uri, *suburi, *subencoding;
   gboolean       is_stream;
   GstElement    *source;
   GstElement    *decoder;
   GstElement    *subtitle; /* additional filesrc ! subparse bin */
+  GSList        *subtitle_elements;     /* subtitle elements that have 'subtitle-encoding' property */
   gboolean       need_rebuild;
 
   /* group management - using own lock */
Index: gst/subparse/gstsubparse.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst/subparse/gstsubparse.c,v
retrieving revision 1.33
diff -u -r1.33 gstsubparse.c
--- gst/subparse/gstsubparse.c	17 May 2006 17:49:10 -0000	1.33
+++ gst/subparse/gstsubparse.c	24 May 2006 12:45:11 -0000
@@ -163,7 +163,7 @@
   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",
+      g_param_spec_string ("subtitle-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, "
