fix up media-info now reports format again metadata needs some rewriting
authorThomas Vander Stichele <thomas@apestaart.org>
Thu, 22 Jan 2004 19:00:27 +0000 (19:00 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Thu, 22 Jan 2004 19:00:27 +0000 (19:00 +0000)
Original commit message from CVS:
fix up media-info
now reports format again
metadata needs some rewriting

ChangeLog
gst-libs/gst/media-info/media-info-priv.c
gst-libs/gst/media-info/media-info-priv.h
gst-libs/gst/media-info/media-info.c

index 84f7858..6f8f816 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 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>
+
        * gst/adder/gstadder.c: (gst_adder_link):
           fix non-compile and cut-n-paste code
 
index 2707793..5b4aa32 100644 (file)
@@ -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;
   }
 
index e7ae708..84f6113 100644 (file)
@@ -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;
 
index a847785..826d4fe 100644 (file)
@@ -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;
       }