[Bug 679695] toc: improvement gst_toc_find_entry()

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Tue Jul 10 09:55:23 PDT 2012


https://bugzilla.gnome.org/show_bug.cgi?id=679695
  GStreamer | gstreamer (core) | git

Anton Belka <dark-al> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #218446|0001-toc-improvement-gst_to |0002-toc-improvement-gst_to
           filename|c_find_entry.patch          |c_find_entry.patch

--- Comment #1 from Anton Belka <dark-al at ya.ru> 2012-07-10 16:55:16 UTC ---
(From update of attachment 218446)
>From 471917e6f2f0435f2a712b94e7fd5b1efd0d7587 Mon Sep 17 00:00:00 2001
From: Anton Belka <antonbelka at gmail.com>
Date: Tue, 10 Jul 2012 18:15:20 +0300
Subject: [PATCH] toc: improvement gst_toc_find_entry()

Recursive search for the required entry. Instead of return top-level entry,
return entry with needed UID.
---
 gst/gsttoc.c |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/gst/gsttoc.c b/gst/gsttoc.c
index c1e713a..95accc3 100644
--- a/gst/gsttoc.c
+++ b/gst/gsttoc.c
@@ -298,25 +298,29 @@ gst_toc_entry_free (GstTocEntry * entry)
   g_slice_free (GstTocEntry, entry);
 }

-static gboolean
-gst_toc_check_entry_for_uid (const GstTocEntry * entry, const gchar * uid)
+static GstTocEntry *
+gst_toc_check_subentries_for_uid (const GstTocEntry * entry, const gchar *
uid)
 {
   GList *cur;
+  GstTocEntry *subentry, *tmp;

   g_return_val_if_fail (entry != NULL, FALSE);
   g_return_val_if_fail (uid != NULL, FALSE);

-  if (g_strcmp0 (entry->uid, uid) == 0)
-    return TRUE;
-
   cur = entry->subentries;
   while (cur != NULL) {
-    if (gst_toc_check_entry_for_uid (cur->data, uid))
-      return TRUE;
+    subentry = cur->data;
+    if (g_strcmp0 (subentry->uid, uid) == 0) {
+      return subentry;
+    } else {
+      tmp = gst_toc_check_subentries_for_uid (subentry, uid);
+      if (tmp != NULL)
+        return tmp;
+    }
     cur = cur->next;
   }

-  return FALSE;
+  return NULL;
 }

 /**
@@ -334,14 +338,21 @@ GstTocEntry *
 gst_toc_find_entry (const GstToc * toc, const gchar * uid)
 {
   GList *cur;
+  GstTocEntry *entry, *subentry;

   g_return_val_if_fail (toc != NULL, NULL);
   g_return_val_if_fail (uid != NULL, NULL);

   cur = toc->entries;
   while (cur != NULL) {
-    if (gst_toc_check_entry_for_uid (cur->data, uid))
-      return cur->data;
+    entry = cur->data;
+    if (g_strcmp0 (entry->uid, uid) == 0) {
+      return entry;
+    } else {
+      subentry = gst_toc_check_subentries_for_uid (entry, uid);
+      if (subentry != NULL)
+        return subentry;
+    }
     cur = cur->next;
   }

-- 
1.7.4.1

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list