+2008-05-21 Wim Taymans <wim.taymans@collabora.co.uk>
+
+ Patch by: Patrick Radizi <patrick dot radizi at axis dot com>
+
+ * gst/multipart/multipartdemux.c: (gst_multipart_demux_class_init),
+ (gst_multipart_demux_get_gstname),
+ (gst_multipart_find_pad_by_mime), (gst_multipart_demux_chain):
+ * gst/multipart/multipartdemux.h:
+ Don't blindly copy the mime-type as the caps name because they not
+ always map directly. Instead use a hashtable with common mappings.
+ Fixes #533287.
+
2008-05-20 Wim Taymans <wim.taymans@collabora.co.uk>
* ext/esd/esdsink.c: (gst_esdsink_write):
GST_STATIC_CAPS ("multipart/x-mixed-replace")
);
+typedef struct
+{
+ const gchar *key;
+ const gchar *val;
+} GstNamesMap;
+
+/* convert from mime types to gst structure names. Add more when needed. */
+static const GstNamesMap gstnames[] = {
+ {"audio/basic", "audio/x-mulaw"},
+ {NULL, NULL}
+};
+
+
static GstFlowReturn gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf);
static GstStateChangeReturn gst_multipart_demux_change_state (GstElement *
static void
gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
{
+ int i;
+
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
"Try to autofind the prefix (deprecated unused, see boundary)",
DEFAULT_AUTOSCAN, G_PARAM_READWRITE));
+ /* populate gst names and mime types pairs */
+ klass->gstnames = g_hash_table_new (g_str_hash, g_str_equal);
+ for (i = 0; gstnames[i].key; i++) {
+ g_hash_table_insert (klass->gstnames, (gpointer) gstnames[i].key,
+ (gpointer) gstnames[i].val);
+ }
+
gstelement_class->change_state = gst_multipart_demux_change_state;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+static const gchar *
+gst_multipart_demux_get_gstname (GstMultipartDemux * demux, gchar * mimetype)
+{
+ GstMultipartDemuxClass *klass;
+ const gchar *gstname;
+
+ klass = GST_MULTIPART_DEMUX_GET_CLASS (demux);
+
+ /* use hashtable to convert to gst name */
+ gstname = g_hash_table_lookup (klass->gstnames, mimetype);
+ if (gstname == NULL) {
+ /* no gst name mapping, use mime type */
+ gstname = mimetype;
+ }
+ return gstname;
+}
+
static GstMultipartPad *
gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
gboolean * created)
GstPad *pad;
GstMultipartPad *mppad;
gchar *name;
+ const gchar *capsname;
GstCaps *caps;
mppad = g_new0 (GstMultipartPad, 1);
gst_pad_new_from_static_template (&multipart_demux_src_template_factory,
name);
g_free (name);
- caps = gst_caps_from_string (mime);
+
+ /* take the mime type, convert it to the caps name */
+ capsname = gst_multipart_demux_get_gstname (demux, mime);
+ caps = gst_caps_from_string (capsname);
gst_pad_use_fixed_caps (pad);
gst_pad_set_caps (pad, caps);
+ gst_caps_unref (caps);
mppad->pad = pad;
mppad->mime = g_strdup (mime);
return ret;
}
+
static void
gst_multipart_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
#define GST_TYPE_MULTIPART_DEMUX (gst_multipart_demux_get_type())
#define GST_MULTIPART_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTIPART_DEMUX, GstMultipartDemux))
#define GST_MULTIPART_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTIPART_DEMUX, GstMultipartDemux))
+#define GST_MULTIPART_DEMUX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MULTIPART_DEMUX, GstMultipartDemuxClass))
#define GST_IS_MULTIPART_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIPART_DEMUX))
#define GST_IS_MULTIPART_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIPART_DEMUX))
struct _GstMultipartDemuxClass
{
GstElementClass parent_class;
+
+ GHashTable *gstnames;
};
G_END_DECLS