gst/multipart/multipartdemux.*: Don't blindly copy the mime-type as the caps name because they not always map directl...
Original commit message from CVS: 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.
This commit is contained in:
parent
b9775592e3
commit
94fb1d9870
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
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>
|
2008-05-20 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* ext/esd/esdsink.c: (gst_esdsink_write):
|
* ext/esd/esdsink.c: (gst_esdsink_write):
|
||||||
|
@ -100,6 +100,19 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
|||||||
GST_STATIC_CAPS ("multipart/x-mixed-replace")
|
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 GstFlowReturn gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf);
|
||||||
|
|
||||||
static GstStateChangeReturn gst_multipart_demux_change_state (GstElement *
|
static GstStateChangeReturn gst_multipart_demux_change_state (GstElement *
|
||||||
@ -131,6 +144,8 @@ gst_multipart_demux_base_init (gpointer g_class)
|
|||||||
static void
|
static void
|
||||||
gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
|
gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
@ -148,6 +163,13 @@ gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
|
|||||||
"Try to autofind the prefix (deprecated unused, see boundary)",
|
"Try to autofind the prefix (deprecated unused, see boundary)",
|
||||||
DEFAULT_AUTOSCAN, G_PARAM_READWRITE));
|
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;
|
gstelement_class->change_state = gst_multipart_demux_change_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +207,23 @@ gst_multipart_demux_finalize (GObject * object)
|
|||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
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 *
|
static GstMultipartPad *
|
||||||
gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
|
gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
|
||||||
gboolean * created)
|
gboolean * created)
|
||||||
@ -209,6 +248,7 @@ gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
|
|||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
GstMultipartPad *mppad;
|
GstMultipartPad *mppad;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
const gchar *capsname;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
mppad = g_new0 (GstMultipartPad, 1);
|
mppad = g_new0 (GstMultipartPad, 1);
|
||||||
@ -220,9 +260,13 @@ gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
|
|||||||
gst_pad_new_from_static_template (&multipart_demux_src_template_factory,
|
gst_pad_new_from_static_template (&multipart_demux_src_template_factory,
|
||||||
name);
|
name);
|
||||||
g_free (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_use_fixed_caps (pad);
|
||||||
gst_pad_set_caps (pad, caps);
|
gst_pad_set_caps (pad, caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
mppad->pad = pad;
|
mppad->pad = pad;
|
||||||
mppad->mime = g_strdup (mime);
|
mppad->mime = g_strdup (mime);
|
||||||
@ -520,6 +564,7 @@ gst_multipart_demux_change_state (GstElement * element,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_multipart_set_property (GObject * object, guint prop_id,
|
gst_multipart_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
@ -33,6 +33,7 @@ G_BEGIN_DECLS
|
|||||||
#define GST_TYPE_MULTIPART_DEMUX (gst_multipart_demux_get_type())
|
#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(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_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(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))
|
#define GST_IS_MULTIPART_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIPART_DEMUX))
|
||||||
|
|
||||||
@ -86,6 +87,8 @@ struct _GstMultipartDemux
|
|||||||
struct _GstMultipartDemuxClass
|
struct _GstMultipartDemuxClass
|
||||||
{
|
{
|
||||||
GstElementClass parent_class;
|
GstElementClass parent_class;
|
||||||
|
|
||||||
|
GHashTable *gstnames;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user