toc: add gst_toc_dump() function for debugging
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Mon, 9 Jul 2012 12:12:27 +0000 (13:12 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Mon, 9 Jul 2012 12:12:27 +0000 (13:12 +0100)
API: gst_toc_dump()

gst/gsttoc.c
gst/gsttoc.h
tests/check/gst/gsttoc.c

index c1e713a53235d518b20e81941b12412116ed9f6b..1bb26c0218e1363c1dd45146a4a0fe5bfe1a0d3d 100644 (file)
@@ -212,6 +212,11 @@ gst_toc_append_entry (GstToc * toc, GstTocEntry * entry)
   g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (toc)));
 
   toc->entries = g_list_append (toc->entries, entry);
+
+  GST_LOG ("appended %s entry with uid %s to toc %p",
+      gst_toc_entry_type_get_nick (entry->type), entry->uid, toc);
+
+  gst_toc_dump (toc);
 }
 
 /**
@@ -595,6 +600,9 @@ gst_toc_entry_append_sub_entry (GstTocEntry * entry, GstTocEntry * subentry)
   g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (entry)));
 
   entry->subentries = g_list_append (entry->subentries, subentry);
+
+  GST_LOG ("appended %s subentry with uid %s to entry %s",
+      gst_toc_entry_type_get_nick (subentry->type), subentry->uid, entry->uid);
 }
 
 /**
@@ -678,3 +686,36 @@ gst_toc_entry_get_tags (const GstTocEntry * entry)
 
   return entry->tags;
 }
+
+#ifndef GST_DISABLE_GST_DEBUG
+static void
+gst_toc_dump_entries (GList * entries, guint depth)
+{
+  GList *e;
+  gchar *indent;
+
+  indent = g_malloc0 (depth + 1);
+  memset (indent, ' ', depth);
+  for (e = entries; e != NULL; e = e->next) {
+    GstTocEntry *entry = e->data;
+
+    GST_TRACE ("%s+ %s (%s), %" GST_TIME_FORMAT " - %" GST_TIME_FORMAT ", "
+        "tags: %" GST_PTR_FORMAT, indent, entry->uid,
+        gst_toc_entry_type_get_nick (entry->type),
+        GST_TIME_ARGS (entry->start), GST_TIME_ARGS (entry->stop), entry->tags);
+
+    if (entry->subentries != NULL)
+      gst_toc_dump_entries (entry->subentries, depth + 2);
+  }
+  g_free (indent);
+}
+#endif
+
+void
+gst_toc_dump (GstToc * toc)
+{
+#ifndef GST_DISABLE_GST_DEBUG
+  GST_TRACE ("        Toc %p, tags: %" GST_PTR_FORMAT, toc, toc->tags);
+  gst_toc_dump_entries (toc->entries, 2);
+#endif
+}
index 67009d9904170fe7595ed9dc4c6dd0744971c40b..2131b901b08a17d3571cba2875cdc4e5aa7b4a6d 100644 (file)
@@ -77,6 +77,8 @@ GstTagList *       gst_toc_get_tags                (const GstToc *toc);
 void               gst_toc_append_entry               (GstToc *toc, GstTocEntry *entry);
 GList *            gst_toc_get_entries             (const GstToc *toc);
 
+void               gst_toc_dump                    (GstToc *toc);
+
 #define gst_toc_ref(toc)            (GstToc*)gst_mini_object_ref(GST_MINI_OBJECT_CAST(toc))
 #define gst_toc_unref(toc)          gst_mini_object_unref(GST_MINI_OBJECT_CAST(toc))
 #define gst_toc_copy(toc)           (GstToc*)gst_mini_object_copy(GST_MINI_OBJECT_CAST(toc))
index 669246356c7add7676871615607ed56da96f949d..9c3f781e391a9a0405ed22242c6072d4708af12d 100644 (file)
@@ -70,6 +70,9 @@
   GList *entries, *subentries, *subsubentries;                           \
   gchar *tag_t;                                                          \
                                                                          \
+  /* dump TOC */                                                         \
+  gst_toc_dump (toc_t);                                                  \
+                                                                         \
   /* check TOC */                                                        \
   tags = gst_toc_get_tags (toc_t);                                       \
   fail_unless (tags != NULL);                                            \