toc: Fix gst_toc_find_entry()

Recursive search for the required entry, instead of returning the
top-level entry that contains an entry with the search UID.
This commit is contained in:
Anton Belka 2012-07-10 18:15:20 +03:00 committed by Sebastian Dröge
parent 042d1ff398
commit be38fbba5e

View file

@ -283,25 +283,30 @@ gst_toc_entry_free (GstTocEntry * entry)
g_slice_free (GstTocEntry, entry); g_slice_free (GstTocEntry, entry);
} }
static gboolean static GstTocEntry *
gst_toc_check_entry_for_uid (const GstTocEntry * entry, const gchar * uid) gst_toc_entry_find_sub_entry (const GstTocEntry * entry, const gchar * uid)
{ {
GList *cur; GList *cur;
GstTocEntry *subentry, *subsubentry;
g_return_val_if_fail (entry != NULL, FALSE); g_return_val_if_fail (entry != NULL, NULL);
g_return_val_if_fail (uid != NULL, FALSE); g_return_val_if_fail (uid != NULL, NULL);
if (g_strcmp0 (entry->uid, uid) == 0)
return TRUE;
cur = entry->subentries; cur = entry->subentries;
while (cur != NULL) { while (cur != NULL) {
if (gst_toc_check_entry_for_uid (cur->data, uid)) subentry = cur->data;
return TRUE;
if (g_strcmp0 (subentry->uid, uid) == 0)
return subentry;
subsubentry = gst_toc_entry_find_sub_entry (subentry, uid);
if (subsubentry != NULL)
return subsubentry;
cur = cur->next; cur = cur->next;
} }
return FALSE; return NULL;
} }
/** /**
@ -311,20 +316,27 @@ gst_toc_check_entry_for_uid (const GstTocEntry * entry, const gchar * uid)
* *
* Find #GstTocEntry with given @uid in the @toc. * Find #GstTocEntry with given @uid in the @toc.
* *
* Returns: #GstTocEntry with specified @uid from the @toc, or NULL if not found. * Returns: (transfer none): #GstTocEntry with specified @uid from the @toc, or NULL if not found.
*/ */
GstTocEntry * GstTocEntry *
gst_toc_find_entry (const GstToc * toc, const gchar * uid) gst_toc_find_entry (const GstToc * toc, const gchar * uid)
{ {
GList *cur; GList *cur;
GstTocEntry *entry, *subentry;
g_return_val_if_fail (toc != NULL, NULL); g_return_val_if_fail (toc != NULL, NULL);
g_return_val_if_fail (uid != NULL, NULL); g_return_val_if_fail (uid != NULL, NULL);
cur = toc->entries; cur = toc->entries;
while (cur != NULL) { while (cur != NULL) {
if (gst_toc_check_entry_for_uid (cur->data, uid)) entry = cur->data;
return cur->data;
if (g_strcmp0 (entry->uid, uid) == 0)
return entry;
subentry = gst_toc_entry_find_sub_entry (entry, uid);
if (subentry != NULL)
return subentry;
cur = cur->next; cur = cur->next;
} }