From e11f38b98bd665f07740a1da35a181785cc6c1b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 25 Jun 2012 23:17:32 +0100 Subject: [PATCH] toc: add more entry types Make entry types less abstract. https://bugzilla.gnome.org/show_bug.cgi?id=678742 --- docs/gst/gstreamer-sections.txt | 5 +++ gst/gsttoc.c | 68 +++++++++++++++++++++++++++++++++++++---- gst/gsttoc.h | 30 +++++++++++++++--- win32/common/libgstreamer.def | 3 ++ 4 files changed, 95 insertions(+), 11 deletions(-) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 92bcd07..ec5ad2b 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2726,6 +2726,11 @@ gst_toc_find_entry gst_toc_entry_get_start_stop gst_toc_entry_set_start_stop gst_toc_entry_type_get_nick +gst_toc_entry_get_entry_type +gst_toc_entry_is_alternative +gst_toc_entry_is_sequence +GST_TOC_ENTRY_TYPE_IS_ALTERNATIVE +GST_TOC_ENTRY_TYPE_IS_SEQUENCE GST_TYPE_TOC GST_TYPE_TOC_ENTRY diff --git a/gst/gsttoc.c b/gst/gsttoc.c index c150c0d..bb7b0b6 100644 --- a/gst/gsttoc.c +++ b/gst/gsttoc.c @@ -880,19 +880,75 @@ gst_toc_entry_get_start_stop (const GstTocEntry * entry, gint64 * start, * * Converts @type to a string representation. * - * Returns: Returns the human-readable @type. Can be NULL if an error occurred. - * Since: 0.11.92 + * Returns: Returns a human-readable string for @type. This string is + * only for debugging purpose and should not be displayed in a user + * interface. */ const gchar * gst_toc_entry_type_get_nick (GstTocEntryType type) { - const gchar *entry_types[] = { "chapter", "edition" }; + switch (type) { + case GST_TOC_ENTRY_TYPE_ANGLE: + return "angle"; + case GST_TOC_ENTRY_TYPE_VERSION: + return "version"; + case GST_TOC_ENTRY_TYPE_EDITION: + return "edition"; + case GST_TOC_ENTRY_TYPE_TITLE: + return "title"; + case GST_TOC_ENTRY_TYPE_TRACK: + return "track"; + case GST_TOC_ENTRY_TYPE_CHAPTER: + return "chapter"; + default: + break; + } + return "invalid"; +} + +/** + * gst_toc_entry_get_entry_type: + * @entry: a #GstTocEntry + * + * Returns: @entry's entry type + */ +GstTocEntryType +gst_toc_entry_get_entry_type (GstTocEntry * entry) +{ + g_return_val_if_fail (entry != NULL, GST_TOC_ENTRY_TYPE_INVALID); + + return entry->type; +} + +/** + * gst_toc_entry_is_alternative: + * @entry: a #GstTocEntry + * + * Returns: %TRUE if @entry's type is an alternative type, otherwise %FALSE + */ +gboolean +gst_toc_entry_is_alternative (GstTocEntry * entry) +{ + g_return_val_if_fail (entry != NULL, FALSE); - g_return_val_if_fail ((gint) type >= 0 - && (gint) type < G_N_ELEMENTS (entry_types), NULL); - return entry_types[type]; + return GST_TOC_ENTRY_TYPE_IS_ALTERNATIVE (entry->type); } +/** + * gst_toc_entry_is_sequence: + * @entry: a #GstTocEntry + * + * Returns: %TRUE if @entry's type is a sequence type, otherwise %FALSE + */ +gboolean +gst_toc_entry_is_sequence (GstTocEntry * entry) +{ + g_return_val_if_fail (entry != NULL, FALSE); + + return GST_TOC_ENTRY_TYPE_IS_SEQUENCE (entry->type); +} + + gboolean __gst_toc_structure_get_updated (const GstStructure * toc) { diff --git a/gst/gsttoc.h b/gst/gsttoc.h index 3b97322..dd87115 100644 --- a/gst/gsttoc.h +++ b/gst/gsttoc.h @@ -38,16 +38,31 @@ typedef struct _GstToc GstToc; /** * GstTocEntryType: - * @GST_TOC_ENTRY_TYPE_CHAPTER: a chapter type entry. - * @GST_TOC_ENTRY_TYPE_EDITION: an edition entry (angle or alternative in other terms). + * @GST_TOC_ENTRY_TYPE_ANGLE: entry is an angle (i.e. an alternative) + * @GST_TOC_ENTRY_TYPE_VERSION: entry is a version (i.e. alternative) + * @GST_TOC_ENTRY_TYPE_EDITION: entry is an edition (i.e. alternative) + * @GST_TOC_ENTRY_TYPE_INVALID: invalid entry type value + * @GST_TOC_ENTRY_TYPE_TITLE: entry is a title (i.e. a part of a sequence) + * @GST_TOC_ENTRY_TYPE_TRACK: entry is a track (i.e. a part of a sequence) + * @GST_TOC_ENTRY_TYPE_CHAPTER: entry is a chapter (i.e. a part of a sequence) * - * The different types of TOC entry. + * The different types of TOC entries (see #GstTocEntry). + * + * There are two types of TOC entries: alternatives or parts in a sequence. */ typedef enum { - GST_TOC_ENTRY_TYPE_CHAPTER = 0, - GST_TOC_ENTRY_TYPE_EDITION = 1 + GST_TOC_ENTRY_TYPE_ANGLE = -3, + GST_TOC_ENTRY_TYPE_VERSION = -2, + GST_TOC_ENTRY_TYPE_EDITION = -1, + GST_TOC_ENTRY_TYPE_INVALID = 0, + GST_TOC_ENTRY_TYPE_TITLE = 1, + GST_TOC_ENTRY_TYPE_TRACK = 2, + GST_TOC_ENTRY_TYPE_CHAPTER = 3, } GstTocEntryType; +#define GST_TOC_ENTRY_TYPE_IS_ALTERNATIVE(entry_type) (entry_type < 0) +#define GST_TOC_ENTRY_TYPE_IS_SEQUENCE(entry_type) (entry_type > 0) + /** * GstTocEntry: * @uid: unique (for a whole TOC) id of the entry. This value should be persistent and @@ -124,6 +139,11 @@ GstTocEntry * gst_toc_entry_new_with_pad (GstTocEntryType type, const gch GstTocEntry * gst_toc_find_entry (const GstToc *toc, const gchar *uid); +GstTocEntryType gst_toc_entry_get_entry_type (GstTocEntry * entry); + +gboolean gst_toc_entry_is_alternative (GstTocEntry * entry); +gboolean gst_toc_entry_is_sequence (GstTocEntry * entry); + void gst_toc_entry_set_start_stop (GstTocEntry *entry, gint64 start, gint64 stop); gboolean gst_toc_entry_get_start_stop (const GstTocEntry *entry, gint64 *start, gint64 *stop); const gchar * gst_toc_entry_type_get_nick (GstTocEntryType type); diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index ea9a92f..85204e3 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -1128,8 +1128,11 @@ EXPORTS gst_task_start gst_task_state_get_type gst_task_stop + gst_toc_entry_get_entry_type gst_toc_entry_get_start_stop gst_toc_entry_get_type + gst_toc_entry_is_alternative + gst_toc_entry_is_sequence gst_toc_entry_new gst_toc_entry_new_with_pad gst_toc_entry_set_start_stop -- 2.7.4