- if (subentry->type == GST_TOC_ENTRY_TYPE_EDITION)
- ++editions_count;
- else
- ++chapters_count;
-
- /* check for mixed content */
- if (G_UNLIKELY (chapters_count > 0 && editions_count > 0)) {
- g_critical
- ("Mixed editions and chapters in the TOC contents, the TOC is broken");
- gst_structure_free (ret);
- g_value_unset (&entry_val);
- g_value_unset (&subentries_val);
- return NULL;
- }
-
- /* skip empty editions */
- if (G_UNLIKELY (subentry->type == GST_TOC_ENTRY_TYPE_EDITION
- && subentry->subentries == NULL)) {
- g_warning
- ("Empty edition found while serializing TOC to GstStructure, skipping");
- cur = cur->next;
- continue;
- }
-
- subentry_struct = gst_toc_entry_to_structure (subentry, level + 1);
-
- /* check for success */
- if (G_UNLIKELY (subentry_struct == NULL)) {
- gst_structure_free (ret);
- g_value_unset (&subentries_val);
- g_value_unset (&entry_val);
- return NULL;
- }
-
- /* skip empty editions */
- if (G_UNLIKELY (subentry->type == GST_TOC_ENTRY_TYPE_EDITION
- && subentry->subentries == NULL)) {
- g_warning
- ("Empty edition found while serializing TOC to GstStructure, skipping");
- cur = cur->next;
- continue;
- }
-
- gst_value_set_structure (&entry_val, subentry_struct);
- gst_value_array_append_value (&subentries_val, &entry_val);
- gst_structure_free (subentry_struct);
-
- cur = cur->next;
- }
-
- gst_structure_id_set_value (ret, gst_toc_fields[GST_TOC_SUBENTRIES],
- &subentries_val);
-
- g_value_unset (&subentries_val);
- g_value_unset (&entry_val);
- return ret;
-}
-
-GstStructure *
-__gst_toc_to_structure (const GstToc * toc)
-{
- GValue val = { 0 };
- GValue subentries_val = { 0 };
- GstStructure *ret, *subentry_struct;
- GstTocEntry *subentry;
- GList *cur;
- guint editions_count = 0, chapters_count = 0;
-
- g_return_val_if_fail (toc != NULL, NULL);
- g_return_val_if_fail (toc->entries != NULL, NULL);
-
- ret = gst_toc_structure_new (toc->tags, toc->info);
-
- g_value_init (&val, GST_TYPE_STRUCTURE);
- g_value_init (&subentries_val, GST_TYPE_ARRAY);
- cur = toc->entries;
-
- while (cur != NULL) {
- subentry = cur->data;
-
- if (subentry->type == GST_TOC_ENTRY_TYPE_EDITION)
- ++editions_count;
- else
- ++chapters_count;
-
- /* check for mixed content */
- if (G_UNLIKELY (chapters_count > 0 && editions_count > 0)) {
- g_critical
- ("Mixed editions and chapters in the TOC contents, the TOC is broken");
- gst_structure_free (ret);
- g_value_unset (&val);
- g_value_unset (&subentries_val);
- return NULL;
- }
-
- /* skip empty editions */
- if (G_UNLIKELY (subentry->type == GST_TOC_ENTRY_TYPE_EDITION
- && subentry->subentries == NULL)) {
- g_warning
- ("Empty edition found while serializing TOC to GstStructure, skipping");
- cur = cur->next;
- continue;
- }
-
- subentry_struct = gst_toc_entry_to_structure (subentry, 0);
-
- /* check for success */
- if (G_UNLIKELY (subentry_struct == NULL)) {
- g_critical ("Couldn't serialize TOC to GstStructure");
- gst_structure_free (ret);
- g_value_unset (&val);
- g_value_unset (&subentries_val);
- return NULL;
- }
-
- gst_value_set_structure (&val, subentry_struct);
- gst_value_array_append_value (&subentries_val, &val);
- gst_structure_free (subentry_struct);
-
- cur = cur->next;
- }
-
- gst_structure_id_set_value (ret, gst_toc_fields[GST_TOC_SUBENTRIES],
- &subentries_val);
-
- g_value_unset (&val);
- g_value_unset (&subentries_val);
- return ret;
-}
-
-static gboolean
-gst_toc_check_entry_for_uid (const GstTocEntry * entry, const gchar * uid)
-{
- GList *cur;
-
- g_return_val_if_fail (entry != NULL, FALSE);
- g_return_val_if_fail (uid != NULL, FALSE);