1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.Toc;
26 
27 private import glib.ConstructionException;
28 private import glib.ListG;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gstreamer.TagList;
32 private import gstreamer.TocEntry;
33 private import gstreamerc.gstreamer;
34 public  import gstreamerc.gstreamertypes;
35 
36 
37 /**
38  * #GstToc functions are used to create/free #GstToc and #GstTocEntry structures.
39  * Also they are used to convert #GstToc into #GstStructure and vice versa.
40  * 
41  * #GstToc lets you to inform other elements in pipeline or application that playing
42  * source has some kind of table of contents (TOC). These may be chapters, editions,
43  * angles or other types. For example: DVD chapters, Matroska chapters or cue sheet
44  * TOC. Such TOC will be useful for applications to display instead of just a
45  * playlist.
46  * 
47  * Using TOC is very easy. Firstly, create #GstToc structure which represents root
48  * contents of the source. You can also attach TOC-specific tags to it. Then fill
49  * it with #GstTocEntry entries by appending them to the #GstToc using
50  * gst_toc_append_entry(), and appending subentries to a #GstTocEntry using
51  * gst_toc_entry_append_sub_entry().
52  * 
53  * Note that root level of the TOC can contain only either editions or chapters. You
54  * should not mix them together at the same level. Otherwise you will get serialization
55  * /deserialization errors. Make sure that no one of the entries has negative start and
56  * stop values.
57  * 
58  * Use gst_event_new_toc() to create a new TOC #GstEvent, and gst_event_parse_toc() to
59  * parse received TOC event. Use gst_event_new_toc_select() to create a new TOC select #GstEvent,
60  * and gst_event_parse_toc_select() to parse received TOC select event. The same rule for
61  * the #GstMessage: gst_message_new_toc() to create new TOC #GstMessage, and
62  * gst_message_parse_toc() to parse received TOC message.
63  * 
64  * TOCs can have global scope or current scope. Global scope TOCs contain
65  * all entries that can possibly be selected using a toc select event, and
66  * are what an application is usually interested in. TOCs with current scope
67  * only contain the parts of the TOC relevant to the currently selected/playing
68  * stream; the current scope TOC is used by downstream elements such as muxers
69  * to write correct TOC entries when transcoding files, for example. When
70  * playing a DVD, the global TOC would contain a hierarchy of all titles,
71  * chapters and angles, for example, while the current TOC would only contain
72  * the chapters for the currently playing title if playback of a specific
73  * title was requested.
74  * 
75  * Applications and plugins should not rely on TOCs having a certain kind of
76  * structure, but should allow for different alternatives. For example, a
77  * simple CUE sheet embedded in a file may be presented as a flat list of
78  * track entries, or could have a top-level edition node (or some other
79  * alternative type entry) with track entries underneath that node; or even
80  * multiple top-level edition nodes (or some other alternative type entries)
81  * each with track entries underneath, in case the source file has extracted
82  * a track listing from different sources).
83  */
84 public class Toc
85 {
86 	/** the main Gtk struct */
87 	protected GstToc* gstToc;
88 	protected bool ownedRef;
89 
90 	/** Get the main Gtk struct */
91 	public GstToc* getTocStruct(bool transferOwnership = false)
92 	{
93 		if (transferOwnership)
94 			ownedRef = false;
95 		return gstToc;
96 	}
97 
98 	/** the main Gtk struct as a void* */
99 	protected void* getStruct()
100 	{
101 		return cast(void*)gstToc;
102 	}
103 
104 	/**
105 	 * Sets our main struct and passes it to the parent class.
106 	 */
107 	public this (GstToc* gstToc, bool ownedRef = false)
108 	{
109 		this.gstToc = gstToc;
110 		this.ownedRef = ownedRef;
111 	}
112 
113 
114 	/** */
115 	public static GType getType()
116 	{
117 		return gst_toc_get_type();
118 	}
119 
120 	/**
121 	 * Create a new #GstToc structure.
122 	 *
123 	 * Params:
124 	 *     scop = scope of this TOC
125 	 *
126 	 * Returns: newly allocated #GstToc structure, free it
127 	 *     with gst_toc_unref().
128 	 *
129 	 * Throws: ConstructionException GTK+ fails to create the object.
130 	 */
131 	public this(GstTocScope scop)
132 	{
133 		auto p = gst_toc_new(scop);
134 		
135 		if(p is null)
136 		{
137 			throw new ConstructionException("null returned by new");
138 		}
139 		
140 		this(cast(GstToc*) p);
141 	}
142 
143 	/**
144 	 * Appends the #GstTocEntry @entry to @toc.
145 	 *
146 	 * Params:
147 	 *     entry = A #GstTocEntry
148 	 */
149 	public void appendEntry(TocEntry entry)
150 	{
151 		gst_toc_append_entry(gstToc, (entry is null) ? null : entry.getTocEntryStruct());
152 	}
153 
154 	/** */
155 	public void dump()
156 	{
157 		gst_toc_dump(gstToc);
158 	}
159 
160 	/**
161 	 * Find #GstTocEntry with given @uid in the @toc.
162 	 *
163 	 * Params:
164 	 *     uid = UID to find #GstTocEntry with.
165 	 *
166 	 * Returns: #GstTocEntry with specified
167 	 *     @uid from the @toc, or %NULL if not found.
168 	 */
169 	public TocEntry findEntry(string uid)
170 	{
171 		auto p = gst_toc_find_entry(gstToc, Str.toStringz(uid));
172 		
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 		
178 		return ObjectG.getDObject!(TocEntry)(cast(GstTocEntry*) p);
179 	}
180 
181 	/**
182 	 * Gets the list of #GstTocEntry of @toc.
183 	 *
184 	 * Returns: A #GList of #GstTocEntry for @entry
185 	 */
186 	public ListG getEntries()
187 	{
188 		auto p = gst_toc_get_entries(gstToc);
189 		
190 		if(p is null)
191 		{
192 			return null;
193 		}
194 		
195 		return new ListG(cast(GList*) p);
196 	}
197 
198 	/**
199 	 * Returns: scope of @toc
200 	 */
201 	public GstTocScope getScope()
202 	{
203 		return gst_toc_get_scope(gstToc);
204 	}
205 
206 	/**
207 	 * Gets the tags for @toc.
208 	 *
209 	 * Returns: A #GstTagList for @entry
210 	 */
211 	public TagList getTags()
212 	{
213 		auto p = gst_toc_get_tags(gstToc);
214 		
215 		if(p is null)
216 		{
217 			return null;
218 		}
219 		
220 		return ObjectG.getDObject!(TagList)(cast(GstTagList*) p);
221 	}
222 
223 	/**
224 	 * Merge @tags into the existing tags of @toc using @mode.
225 	 *
226 	 * Params:
227 	 *     tags = A #GstTagList or %NULL
228 	 *     mode = A #GstTagMergeMode
229 	 */
230 	public void mergeTags(TagList tags, GstTagMergeMode mode)
231 	{
232 		gst_toc_merge_tags(gstToc, (tags is null) ? null : tags.getTagListStruct(), mode);
233 	}
234 
235 	/**
236 	 * Set a #GstTagList with tags for the complete @toc.
237 	 *
238 	 * Params:
239 	 *     tags = A #GstTagList or %NULL
240 	 */
241 	public void setTags(TagList tags)
242 	{
243 		gst_toc_set_tags(gstToc, (tags is null) ? null : tags.getTagListStruct());
244 	}
245 }