toc: add GstTocScope and require it in the constructor

This is because we need to be able to signal different TOCs
to downstream elements such as muxers and the application,
and because we need to send both types as events (because
the sink should post the TOC messages for the app in the
end, just like tag messages are now posted by the sinks),
and hence need to make TOC events multi-sticky.

https://bugzilla.gnome.org/show_bug.cgi?id=678742
This commit is contained in:
Tim-Philipp Müller 2012-07-27 23:56:54 +01:00
parent 28f041126a
commit e8ab1006c7
7 changed files with 54 additions and 8 deletions

View file

@ -2736,6 +2736,7 @@ gst_task_state_get_type
<FILE>gsttoc</FILE>
<TITLE>GstToc</TITLE>
GstToc
GstTocScope
GstTocEntry
GstTocEntryType
gst_toc_new
@ -2743,6 +2744,7 @@ gst_toc_ref
gst_toc_unref
gst_toc_copy
gst_toc_make_writable
gst_toc_get_scope
gst_toc_get_entries
gst_toc_append_entry
gst_toc_get_tags

View file

@ -731,7 +731,7 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
g_type_class_ref (gst_scheduling_flags_get_type ());
g_type_class_ref (gst_meta_flags_get_type ());
g_type_class_ref (gst_toc_entry_type_get_type ());
g_type_class_ref (gst_toc_scope_get_type ());
g_type_class_ref (gst_control_binding_get_type ());
g_type_class_ref (gst_control_source_get_type ());
g_type_class_ref (gst_lock_flags_get_type ());
@ -1084,6 +1084,7 @@ gst_deinit (void)
g_type_class_unref (g_type_class_peek (gst_tag_flag_get_type ()));
g_type_class_unref (g_type_class_peek (gst_task_state_get_type ()));
g_type_class_unref (g_type_class_peek (gst_toc_entry_type_get_type ()));
g_type_class_unref (g_type_class_peek (gst_toc_scope_get_type ()));
g_type_class_unref (g_type_class_peek (gst_type_find_probability_get_type
()));
g_type_class_unref (g_type_class_peek (gst_uri_type_get_type ()));

View file

@ -90,6 +90,7 @@ struct _GstToc
{
GstMiniObject mini_object;
GstTocScope scope;
GList *entries;
GstTagList *tags;
};
@ -106,6 +107,7 @@ GST_DEFINE_MINI_OBJECT_TYPE (GstTocEntry, gst_toc_entry);
/**
* gst_toc_new:
* @scope: scope of this TOC
*
* Create a new #GstToc structure.
*
@ -113,21 +115,39 @@ GST_DEFINE_MINI_OBJECT_TYPE (GstTocEntry, gst_toc_entry);
* with gst_toc_unref().
*/
GstToc *
gst_toc_new (void)
gst_toc_new (GstTocScope scope)
{
GstToc *toc;
g_return_val_if_fail (scope == GST_TOC_SCOPE_GLOBAL ||
scope == GST_TOC_SCOPE_CURRENT, NULL);
toc = g_slice_new0 (GstToc);
gst_mini_object_init (GST_MINI_OBJECT_CAST (toc), 0, GST_TYPE_TOC,
(GstMiniObjectCopyFunction) gst_toc_copy, NULL,
(GstMiniObjectFreeFunction) gst_toc_free);
toc->scope = scope;
toc->tags = gst_tag_list_new_empty ();
return toc;
}
/**
* gst_toc_get_scope:
* @toc: a #GstToc instance
*
* Returns: scope of @toc
*/
GstTocScope
gst_toc_get_scope (const GstToc * toc)
{
g_return_val_if_fail (toc != NULL, GST_TOC_SCOPE_GLOBAL);
return toc->scope;
}
/**
* gst_toc_set_tags:
* @toc: A #GstToc instance
@ -413,7 +433,7 @@ gst_toc_copy (const GstToc * toc)
g_return_val_if_fail (toc != NULL, NULL);
ret = gst_toc_new ();
ret = gst_toc_new (toc->scope);
if (GST_IS_TAG_LIST (toc->tags)) {
list = gst_tag_list_copy (toc->tags);
@ -431,7 +451,6 @@ gst_toc_copy (const GstToc * toc)
cur = cur->next;
}
ret->entries = g_list_reverse (ret->entries);
return ret;
}
@ -730,7 +749,8 @@ void
gst_toc_dump (GstToc * toc)
{
#ifndef GST_DISABLE_GST_DEBUG
GST_TRACE (" Toc %p, tags: %" GST_PTR_FORMAT, toc, toc->tags);
GST_TRACE (" Toc %p, scope: %s, tags: %" GST_PTR_FORMAT, toc,
(toc->scope == GST_TOC_SCOPE_GLOBAL) ? "global" : "current", toc->tags);
gst_toc_dump_entries (toc->entries, 2);
#endif
}

View file

@ -36,6 +36,24 @@ G_BEGIN_DECLS
typedef struct _GstTocEntry GstTocEntry;
typedef struct _GstToc GstToc;
/**
* GstTocScope:
* @GST_TOC_SCOPE_GLOBAL: global TOC representing all selectable options
* (this is what applications are usually interested in)
* @GST_TOC_SCOPE_CURRENT: TOC for the currently active/selected stream
* (this is a TOC representing the current stream from start to EOS,
* and is what a TOC writer / muxer is usually interested in; it will
* usually be a subset of the global TOC, e.g. just the chapters of
* the current title, or the chapters selected for playback from the
* current title)
*
* The scope of a TOC.
*/
typedef enum {
GST_TOC_SCOPE_GLOBAL = 1,
GST_TOC_SCOPE_CURRENT = 2
} GstTocScope;
/**
* GstTocEntryType:
* @GST_TOC_ENTRY_TYPE_ANGLE: entry is an angle (i.e. an alternative)
@ -68,7 +86,9 @@ GType gst_toc_get_type (void);
GType gst_toc_entry_get_type (void);
/* functions to create, ref and unref/free TOCs */
GstToc * gst_toc_new (void);
GstToc * gst_toc_new (GstTocScope scope);
GstTocScope gst_toc_get_scope (const GstToc *toc);
void gst_toc_set_tags (GstToc *toc, GstTagList * tags);
void gst_toc_merge_tags (GstToc *toc, GstTagList *tags, GstTagMergeMode mode);

View file

@ -137,7 +137,8 @@ GST_START_TEST (test_serializing)
gchar *uid;
gint64 start = -1, stop = -1;
toc = gst_toc_new ();
toc = gst_toc_new (GST_TOC_SCOPE_GLOBAL);
fail_unless_equals_int (gst_toc_get_scope (toc), GST_TOC_SCOPE_GLOBAL);
fail_if (toc == NULL);
tags = gst_tag_list_new (GST_TAG_TITLE, TOC_TAG, NULL);
gst_toc_set_tags (toc, tags);

View file

@ -137,7 +137,7 @@ create_toc (void)
GstTocEntry *ed, *ch, *subch;
GstTagList *tags;
toc = gst_toc_new ();
toc = gst_toc_new (GST_TOC_SCOPE_GLOBAL);
tags = gst_tag_list_new_empty ();
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_TITLE, TOC_TAG, NULL);
gst_toc_set_tags (toc, tags);

View file

@ -1151,10 +1151,12 @@ EXPORTS
gst_toc_entry_type_get_type
gst_toc_find_entry
gst_toc_get_entries
gst_toc_get_scope
gst_toc_get_tags
gst_toc_get_type
gst_toc_merge_tags
gst_toc_new
gst_toc_scope_get_type
gst_toc_set_tags
gst_toc_setter_get_toc
gst_toc_setter_get_type