From a4614f19e69ea978d27a6b42694eede2c0422024 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Thu, 22 Jan 2004 19:00:27 +0000 Subject: 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 --- gst-libs/gst/media-info/media-info-priv.c | 22 +++++++++++++++++----- gst-libs/gst/media-info/media-info-priv.h | 2 ++ gst-libs/gst/media-info/media-info.c | 12 +++++++++--- 3 files changed, 28 insertions(+), 8 deletions(-) (limited to 'gst-libs') diff --git a/gst-libs/gst/media-info/media-info-priv.c b/gst-libs/gst/media-info/media-info-priv.c index 27077936..5b4aa325 100644 --- a/gst-libs/gst/media-info/media-info-priv.c +++ b/gst-libs/gst/media-info/media-info-priv.c @@ -78,9 +78,11 @@ gmi_track_new (void) /* callbacks */ 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 @@ -89,6 +91,13 @@ deep_notify_callback (GObject *object, GstObject *origin, { 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) { 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 */ priv->decoder = 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)) 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 */ if (!(priv->decoder_pad = gst_element_get_pad (decoder, "src"))) 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 */ gst_element_set_state (info->priv->pipeline, GST_STATE_READY); 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->fakesink); info->priv->decoder = NULL; } } @@ -303,9 +317,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv) /* clear vars that need clearing */ 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; } diff --git a/gst-libs/gst/media-info/media-info-priv.h b/gst-libs/gst/media-info/media-info-priv.h index e7ae708f..84f6113f 100644 --- a/gst-libs/gst/media-info/media-info-priv.h +++ b/gst-libs/gst/media-info/media-info-priv.h @@ -77,6 +77,8 @@ struct GstMediaInfoPriv GstCaps *streaminfo; 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 */ GstElement *source; diff --git a/gst-libs/gst/media-info/media-info.c b/gst-libs/gst/media-info/media-info.c index a847785f..826d4fef 100644 --- a/gst-libs/gst/media-info/media-info.c +++ b/gst-libs/gst/media-info/media-info.c @@ -151,14 +151,19 @@ gst_media_info_instance_init (GstMediaInfo *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"); if (!GST_IS_ELEMENT (info->priv->typefind)) - /* FIXME */ 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)); + /* 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 */ source = gst_element_factory_make ("gnomevfssrc", "source"); if (GST_IS_ELEMENT (source)) @@ -292,6 +297,7 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp) GST_DEBUG ("STATE_TYPEFIND"); if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) { + GST_DEBUG ("iterating while in STATE_TYPEFIND"); GMI_DEBUG("?"); return TRUE; } -- cgit v1.2.1