toc: add more entry types
[platform/upstream/gstreamer.git] / gst / gsttoc.h
1 /* GStreamer
2  * (c) 2010, 2012 Alexander Saprykin <xelfium@gmail.com>
3  *
4  * gsttoc.h: generic TOC API declaration
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __GST_TOC_H__
23 #define __GST_TOC_H__
24
25 #include <gst/gstconfig.h>
26 #include <gst/gstminiobject.h>
27 #include <gst/gststructure.h>
28 #include <gst/gsttaglist.h>
29 #include <gst/gstformat.h>
30
31 G_BEGIN_DECLS
32
33 #define GST_TYPE_TOC (gst_toc_get_type ())
34 #define GST_TYPE_TOC_ENTRY (gst_toc_entry_get_type ())
35
36 typedef struct _GstTocEntry GstTocEntry;
37 typedef struct _GstToc GstToc;
38
39 /**
40  * GstTocEntryType:
41  * @GST_TOC_ENTRY_TYPE_ANGLE: entry is an angle (i.e. an alternative)
42  * @GST_TOC_ENTRY_TYPE_VERSION: entry is a version (i.e. alternative)
43  * @GST_TOC_ENTRY_TYPE_EDITION: entry is an edition (i.e. alternative)
44  * @GST_TOC_ENTRY_TYPE_INVALID: invalid entry type value
45  * @GST_TOC_ENTRY_TYPE_TITLE: entry is a title (i.e. a part of a sequence)
46  * @GST_TOC_ENTRY_TYPE_TRACK: entry is a track (i.e. a part of a sequence)
47  * @GST_TOC_ENTRY_TYPE_CHAPTER: entry is a chapter (i.e. a part of a sequence)
48  *
49  * The different types of TOC entries (see #GstTocEntry).
50  *
51  * There are two types of TOC entries: alternatives or parts in a sequence.
52  */
53 typedef enum {
54   GST_TOC_ENTRY_TYPE_ANGLE       = -3,
55   GST_TOC_ENTRY_TYPE_VERSION     = -2,
56   GST_TOC_ENTRY_TYPE_EDITION     = -1,
57   GST_TOC_ENTRY_TYPE_INVALID     = 0,
58   GST_TOC_ENTRY_TYPE_TITLE       = 1,
59   GST_TOC_ENTRY_TYPE_TRACK       = 2,
60   GST_TOC_ENTRY_TYPE_CHAPTER     = 3,
61 } GstTocEntryType;
62
63 #define GST_TOC_ENTRY_TYPE_IS_ALTERNATIVE(entry_type)  (entry_type < 0)
64 #define GST_TOC_ENTRY_TYPE_IS_SEQUENCE(entry_type)     (entry_type > 0)
65
66 /**
67  * GstTocEntry:
68  * @uid: unique (for a whole TOC) id of the entry. This value should be persistent and
69  * should not be changed while updating TOC. @uid should be handled as "opaque" value
70  * without meaning (e.g. applications should not assume the /editionX/chapterY/chapter/Z structure,
71  * other demuxers could do something else), it should help to track updates of certain entries.
72  * @type: #GstTocEntryType of this entry.
73  * @subentries: (element-type GstTocEntry): list of #GstTocEntry
74  * children.
75  * @pads: (element-type GstPad): list of #GstPad objects, related to
76  * this #GstTocEntry.
77  * @tags: tags related to this entry.
78  * @info: extra information related to this entry.
79  *
80  * Definition of TOC entry structure.
81  */
82 struct _GstTocEntry {
83   GstMiniObject mini_object;
84
85   gchar *uid;
86   GstTocEntryType type;
87   GList *subentries;
88   GList *pads;
89   GstTagList *tags;
90   GstStructure *info;
91
92   /*< private >*/
93   gpointer _gst_reserved[GST_PADDING];
94 };
95
96 /* FIXME: pad member should be GstPad type, but that's
97  * impossible due to recursive includes */
98
99 /**
100  * GstToc:
101  * @entries: (element-type GstTocEntry): list of #GstTocEntry entries
102  *   of the TOC.
103  * @tags: tags related to the whole TOC.
104  * @info: extra information related to the TOC.
105  *
106  * Definition of TOC structure.
107  */
108 struct _GstToc {
109   GstMiniObject mini_object;
110
111   GList *entries;
112   GstTagList *tags;
113   GstStructure *info;
114
115   /*< private >*/
116   gpointer _gst_reserved[GST_PADDING];
117 };
118
119 /* functions to return type structures */
120 GType           gst_toc_get_type                (void);
121 GType           gst_toc_entry_get_type          (void);
122
123 /* functions to create, ref and unref/free TOCs */
124 GstToc *        gst_toc_new                     (void);
125
126 #define gst_toc_ref(toc)            (GstToc*)gst_mini_object_ref(GST_MINI_OBJECT_CAST(toc))
127 #define gst_toc_unref(toc)          gst_mini_object_unref(GST_MINI_OBJECT_CAST(toc))
128 #define gst_toc_copy(toc)           (GstToc*)gst_mini_object_copy(GST_MINI_OBJECT_CAST(toc))
129 #define gst_toc_make_writable(toc)  (GstToc*)gst_mini_object_make_writable(GST_MINI_OBJECT_CAST(toc))
130
131 /* functions to create, ref and unref/free TOC entries */
132 GstTocEntry *   gst_toc_entry_new               (GstTocEntryType type, const gchar *uid);
133 GstTocEntry *   gst_toc_entry_new_with_pad      (GstTocEntryType type, const gchar *uid, GstPad * pad);
134
135 #define gst_toc_entry_ref(entry)            (GstTocEntry*)gst_mini_object_ref(GST_MINI_OBJECT_CAST(entry))
136 #define gst_toc_entry_unref(entry)          gst_mini_object_unref(GST_MINI_OBJECT_CAST(entry))
137 #define gst_toc_entry_copy(entry)           (GstTocEntry*)gst_mini_object_copy(GST_MINI_OBJECT_CAST(entry))
138 #define gst_toc_entry_make_writable(entry)  (GstTocEntry*)gst_mini_object_make_writable(GST_MINI_OBJECT_CAST(entry))
139
140 GstTocEntry *   gst_toc_find_entry              (const GstToc *toc, const gchar *uid);
141
142 GstTocEntryType gst_toc_entry_get_entry_type    (GstTocEntry * entry);
143
144 gboolean        gst_toc_entry_is_alternative    (GstTocEntry * entry);
145 gboolean        gst_toc_entry_is_sequence       (GstTocEntry * entry);
146
147 void            gst_toc_entry_set_start_stop    (GstTocEntry *entry, gint64 start, gint64 stop);
148 gboolean        gst_toc_entry_get_start_stop    (const GstTocEntry *entry, gint64 *start, gint64 *stop);
149 const gchar *   gst_toc_entry_type_get_nick     (GstTocEntryType type);
150
151 G_END_DECLS
152
153 #endif /* __GST_TOC_H__ */
154