toc: add GstTocScope and require it in the constructor
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 27 Jul 2012 22:56:54 +0000 (23:56 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 28 Jul 2012 08:16:06 +0000 (09:16 +0100)
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

docs/gst/gstreamer-sections.txt
gst/gst.c
gst/gsttoc.c
gst/gsttoc.h
tests/check/gst/gsttoc.c
tests/check/gst/gsttocsetter.c
win32/common/libgstreamer.def

index d1a02c624cb37287237dafe68fabbd4f94af7cbb..fa929291dc9841be4582fd392f65e5eb4c06dbf7 100644 (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
index 59eb657bbc1344d2e08bb696a3a5b38ea944760e..ece27f2cad33f44249c589431f0bfb38673c9f5e 100644 (file)
--- a/gst/gst.c
+++ b/gst/gst.c
@@ -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 ()));
index 4e1ab8d422853abaaa77cbdb9a394f78b704b1cc..0a15156fb607a9db0f25e346d5de32c13e551bd1 100644 (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
 }
index 94d97fdf801130caa5c0e6beb17caa0835e5b4da..9439cca2391cda4f1b10cd252ccfd6466def3df3 100644 (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);
index c9b2dee82b8bafba6afc90f52aac26b4f62a3f00..4a03cd77a4749cfd136616e0a278d60b31ce9d0d 100644 (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);
index a153a176dacf9a964d7387bc654d111823c3710c..4cdd3bf23053fffac1977b32882eda0fc11981b6 100644 (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);
index 7be9b169f9fad889e488c45c56e87f7c55d7b611..cb2a1f861bd53d6a9cb521f1a0145102ad62d273 100644 (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