fix up media-info now reports format again metadata needs some rewriting

Original commit message from CVS:
fix up media-info
now reports format again
metadata needs some rewriting
This commit is contained in:
Thomas Vander Stichele 2004-01-22 19:00:27 +00:00
parent 11cb1a9f92
commit b469416f53
4 changed files with 39 additions and 8 deletions

View file

@ -1,3 +1,14 @@
2004-01-22 Thomas Vander Stichele <thomas at apestaart dot org>
* gst-libs/gst/media-info/media-info-priv.c: (have_type_callback),
(deep_notify_callback), (gmi_set_decoder), (gmi_clear_decoder),
(gmip_find_type_pre):
* gst-libs/gst/media-info/media-info-priv.h:
* gst-libs/gst/media-info/media-info.c:
(gst_media_info_instance_init), (gst_media_info_read_idler):
add fakesink to get caps on decoder src pad again
fix callback prototype to match new have_type signal signature
2004-01-22 Thomas Vander Stichele <thomas at apestaart dot org> 2004-01-22 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/adder/gstadder.c: (gst_adder_link): * gst/adder/gstadder.c: (gst_adder_link):

View file

@ -78,9 +78,11 @@ gmi_track_new (void)
/* callbacks */ /* callbacks */
static void static void
have_type_callback (GstElement *typefind, GstCaps *type, GstMediaInfoPriv *priv) have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstMediaInfoPriv *priv)
{ {
priv->type = type; g_print ("DEBUG: have_type: caps %p\n", type);
priv->type = gst_caps_copy (type);
/* FIXME: make sure we _free these somewhere */
} }
void void
@ -89,6 +91,13 @@ deep_notify_callback (GObject *object, GstObject *origin,
{ {
GValue value = { 0, }; GValue value = { 0, };
/* we only care about pad notifies */
if (!GST_IS_PAD (origin)) return;
GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
gst_object_get_name (origin));
if (strcmp (pspec->name, "metadata") == 0) if (strcmp (pspec->name, "metadata") == 0)
{ {
GST_DEBUG ("DEBUG: deep_notify: have metadata !"); GST_DEBUG ("DEBUG: deep_notify: have metadata !");
@ -265,8 +274,11 @@ gmi_set_decoder (GstMediaInfo *info, GstElement *decoder)
/* set up pipeline and connect signal handlers */ /* set up pipeline and connect signal handlers */
priv->decoder = decoder; priv->decoder = decoder;
gst_bin_add (GST_BIN (priv->pipeline), decoder); gst_bin_add (GST_BIN (priv->pipeline), decoder);
gst_bin_add (GST_BIN (priv->pipeline), priv->fakesink);
if (!gst_element_link (priv->source, decoder)) if (!gst_element_link (priv->source, decoder))
g_warning ("Couldn't connect source and decoder\n"); g_warning ("Couldn't connect source and decoder\n");
if (!gst_element_link (priv->decoder, priv->fakesink))
g_warning ("Couldn't connect decoder and fakesink\n");
/* FIXME: we should be connecting to ALL possible src pads */ /* FIXME: we should be connecting to ALL possible src pads */
if (!(priv->decoder_pad = gst_element_get_pad (decoder, "src"))) if (!(priv->decoder_pad = gst_element_get_pad (decoder, "src")))
g_warning ("Couldn't get decoder pad\n"); g_warning ("Couldn't get decoder pad\n");
@ -285,7 +297,9 @@ gmi_clear_decoder (GstMediaInfo *info)
/* FIXME: shouldn't need to set state here */ /* FIXME: shouldn't need to set state here */
gst_element_set_state (info->priv->pipeline, GST_STATE_READY); gst_element_set_state (info->priv->pipeline, GST_STATE_READY);
gst_element_unlink (info->priv->source, info->priv->decoder); gst_element_unlink (info->priv->source, info->priv->decoder);
gst_element_unlink (info->priv->decoder, info->priv->fakesink);
gst_bin_remove (GST_BIN (info->priv->pipeline), info->priv->decoder); gst_bin_remove (GST_BIN (info->priv->pipeline), info->priv->decoder);
gst_bin_remove (GST_BIN (info->priv->pipeline), info->priv->fakesink);
info->priv->decoder = NULL; info->priv->decoder = NULL;
} }
} }
@ -303,9 +317,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv)
/* clear vars that need clearing */ /* clear vars that need clearing */
if (priv->type) if (priv->type)
{ {
/* we don't need to unref, this is done inside gsttypefind.c gst_caps_free (priv->type);
gst_caps_free (priv->type);
*/
priv->type = NULL; priv->type = NULL;
} }

View file

@ -77,6 +77,8 @@ struct GstMediaInfoPriv
GstCaps *streaminfo; GstCaps *streaminfo;
GstElement *decoder; /* will be != NULL during collection */ GstElement *decoder; /* will be != NULL during collection */
GstElement *fakesink; /* so we can get caps from the
decoder sink pad */
gchar *source_element; /* type of element used as source */ gchar *source_element; /* type of element used as source */
GstElement *source; GstElement *source;

View file

@ -151,14 +151,19 @@ gst_media_info_instance_init (GstMediaInfo *info)
info->priv->pipeline = gst_pipeline_new ("media-info"); info->priv->pipeline = gst_pipeline_new ("media-info");
/* create the typefind element and make sure it stays around by reffing */
info->priv->typefind = gst_element_factory_make ("typefind", "typefind"); info->priv->typefind = gst_element_factory_make ("typefind", "typefind");
if (!GST_IS_ELEMENT (info->priv->typefind)) if (!GST_IS_ELEMENT (info->priv->typefind))
/* FIXME */
g_error ("Cannot create typefind element !"); g_error ("Cannot create typefind element !");
/* ref it so it never goes away on removal out of bins */
gst_object_ref (GST_OBJECT (info->priv->typefind)); gst_object_ref (GST_OBJECT (info->priv->typefind));
/* create the fakesink element and make sure it stays around by reffing */
info->priv->fakesink = gst_element_factory_make ("fakesink", "fakesink");
if (!GST_IS_ELEMENT (info->priv->fakesink))
g_error ("Cannot create fakesink element !");
gst_object_ref (GST_OBJECT (info->priv->fakesink));
/* use gnomevfssrc by default */ /* use gnomevfssrc by default */
source = gst_element_factory_make ("gnomevfssrc", "source"); source = gst_element_factory_make ("gnomevfssrc", "source");
if (GST_IS_ELEMENT (source)) if (GST_IS_ELEMENT (source))
@ -292,6 +297,7 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp)
GST_DEBUG ("STATE_TYPEFIND"); GST_DEBUG ("STATE_TYPEFIND");
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
{ {
GST_DEBUG ("iterating while in STATE_TYPEFIND");
GMI_DEBUG("?"); GMI_DEBUG("?");
return TRUE; return TRUE;
} }