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  * Conversion parameters:
26  * inFile  = gstreamer-GstSegment.html
27  * outPack = gstreamer
28  * outFile = Segment
29  * strct   = GstSegment
30  * realStrct=
31  * ctorStrct=
32  * clss    = Segment
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_segment_
41  * 	- gst_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * structWrap:
49  * 	- GstSegment* -> Segment
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gstreamer.Segment;
56 
57 public  import gstreamerc.gstreamertypes;
58 
59 private import gstreamerc.gstreamer;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 
64 private import glib.Str;
65 
66 
67 
68 
69 /**
70  * Description
71  * This helper structure holds the relevant values for tracking the region of
72  * interest in a media file, called a segment.
73  * The structure can be used for two purposes:
74  * performing seeks (handling seek events)
75  * tracking playback regions (handling newsegment events)
76  * The segment is usually configured by the application with a seek event which
77  * is propagated upstream and eventually handled by an element that performs the seek.
78  * The configured segment is then propagated back downstream with a newsegment event.
79  * This information is then used to clip media to the segment boundaries.
80  * A segment structure is initialized with gst_segment_init(), which takes a GstFormat
81  * that will be used as the format of the segment values. The segment will be configured
82  * with a start value of 0 and a stop/duration of -1, which is undefined. The default
83  * rate and applied_rate is 1.0.
84  * If the segment is used for managing seeks, the segment duration should be set with
85  * gst_segment_set_duration(). The public duration field contains the duration of the
86  * segment. When using the segment for seeking, the start and time members should
87  * normally be left to their default 0 value. The stop position is left to -1 unless
88  * explicitly configured to a different value after a seek event.
89  * The current position in the segment should be set with the gst_segment_set_last_stop().
90  * The public last_stop field contains the last set stop position in the segment.
91  * For elements that perform seeks, the current segment should be updated with the
92  * gst_segment_set_seek() and the values from the seek event. This method will update
93  * all the segment fields. The last_stop field will contain the new playback position.
94  * If the cur_type was different from GST_SEEK_TYPE_NONE, playback continues from
95  * the last_stop position, possibly with updated flags or rate.
96  * For elements that want to use GstSegment to track the playback region, use
97  * gst_segment_set_newsegment() to update the segment fields with the information from
98  * the newsegment event. The gst_segment_clip() method can be used to check and clip
99  * the media data to the segment boundaries.
100  * For elements that want to synchronize to the pipeline clock, gst_segment_to_running_time()
101  * can be used to convert a timestamp to a value that can be used to synchronize
102  * to the clock. This function takes into account all accumulated segments as well as
103  * any rate or applied_rate conversions.
104  * For elements that need to perform operations on media data in stream_time,
105  * gst_segment_to_stream_time() can be used to convert a timestamp and the segment
106  * info to stream time (which is always between 0 and the duration of the stream).
107  * Last reviewed on 2007-05-17 (0.10.13)
108  */
109 public class Segment
110 {
111 	
112 	/** the main Gtk struct */
113 	protected GstSegment* gstSegment;
114 	
115 	
116 	public GstSegment* getSegmentStruct()
117 	{
118 		return gstSegment;
119 	}
120 	
121 	
122 	/** the main Gtk struct as a void* */
123 	protected void* getStruct()
124 	{
125 		return cast(void*)gstSegment;
126 	}
127 	
128 	/**
129 	 * Sets our main struct and passes it to the parent class
130 	 */
131 	public this (GstSegment* gstSegment)
132 	{
133 		this.gstSegment = gstSegment;
134 	}
135 	
136 	/**
137 	 */
138 	
139 	/**
140 	 * Clip the given start and stop values to the segment boundaries given
141 	 * in segment. start and stop are compared and clipped to segment
142 	 * start and stop values.
143 	 * If the function returns FALSE, start and stop are known to fall
144 	 * outside of segment and clip_start and clip_stop are not updated.
145 	 * When the function returns TRUE, clip_start and clip_stop will be
146 	 * updated. If clip_start or clip_stop are different from start or stop
147 	 * respectively, the region fell partially in the segment.
148 	 * Note that when stop is -1, clip_stop will be set to the end of the
149 	 * segment. Depending on the use case, this may or may not be what you want.
150 	 * Params:
151 	 * format = the format of the segment.
152 	 * start = the start position in the segment
153 	 * stop = the stop position in the segment
154 	 * clipStart = the clipped start position in the segment
155 	 * clipStop = the clipped stop position in the segment
156 	 * Returns: TRUE if the given start and stop times fall partially or completely in segment, FALSE if the values are completely outside of the segment.
157 	 */
158 	public int clip(GstFormat format, long start, long stop, ref long clipStart, ref long clipStop)
159 	{
160 		// gboolean gst_segment_clip (GstSegment *segment,  GstFormat format,  gint64 start,  gint64 stop,  gint64 *clip_start,  gint64 *clip_stop);
161 		return gst_segment_clip(gstSegment, format, start, stop, &clipStart, &clipStop);
162 	}
163 	
164 	/**
165 	 * The start/last_stop positions are set to 0 and the stop/duration
166 	 * fields are set to -1 (unknown). The default rate of 1.0 and no
167 	 * flags are set.
168 	 * Initialize segment to its default values.
169 	 * Params:
170 	 * format = the format of the segment.
171 	 */
172 	public void init(GstFormat format)
173 	{
174 		// void gst_segment_init (GstSegment *segment,  GstFormat format);
175 		gst_segment_init(gstSegment, format);
176 	}
177 	
178 	/**
179 	 * Allocate a new GstSegment structure and initialize it using
180 	 * gst_segment_init().
181 	 * Throws: ConstructionException GTK+ fails to create the object.
182 	 */
183 	public this ()
184 	{
185 		// GstSegment* gst_segment_new (void);
186 		auto p = gst_segment_new();
187 		if(p is null)
188 		{
189 			throw new ConstructionException("null returned by gst_segment_new()");
190 		}
191 		this(cast(GstSegment*) p);
192 	}
193 	
194 	/**
195 	 * Free the allocated segment segment.
196 	 */
197 	public void free()
198 	{
199 		// void gst_segment_free (GstSegment *segment);
200 		gst_segment_free(gstSegment);
201 	}
202 	
203 	/**
204 	 * Set the duration of the segment to duration. This function is mainly
205 	 * used by elements that perform seeking and know the total duration of the
206 	 * segment.
207 	 * This field should be set to allow seeking requests relative to the
208 	 * duration.
209 	 * Params:
210 	 * format = the format of the segment.
211 	 * duration = the duration of the segment info or -1 if unknown.
212 	 */
213 	public void setDuration(GstFormat format, long duration)
214 	{
215 		// void gst_segment_set_duration (GstSegment *segment,  GstFormat format,  gint64 duration);
216 		gst_segment_set_duration(gstSegment, format, duration);
217 	}
218 	
219 	/**
220 	 * Set the last observed stop position in the segment to position.
221 	 * This field should be set to allow seeking requests relative to the
222 	 * current playing position.
223 	 * Params:
224 	 * format = the format of the segment.
225 	 * position = the position
226 	 */
227 	public void setLastStop(GstFormat format, long position)
228 	{
229 		// void gst_segment_set_last_stop (GstSegment *segment,  GstFormat format,  gint64 position);
230 		gst_segment_set_last_stop(gstSegment, format, position);
231 	}
232 	
233 	/**
234 	 * Update the segment structure with the field values of a new segment event and
235 	 * with a default applied_rate of 1.0.
236 	 * Params:
237 	 * segment = a GstSegment structure.
238 	 * update = flag indicating a new segment is started or updated
239 	 * rate = the rate of the segment.
240 	 * format = the format of the segment.
241 	 * start = the new start value
242 	 * stop = the new stop value
243 	 * time = the new stream time
244 	 * Since 0.10.6
245 	 */
246 	public void setNewsegment(int update, double rate, GstFormat format, long start, long stop, long time)
247 	{
248 		// void gst_segment_set_newsegment (GstSegment *segment,  gboolean update,  gdouble rate,  GstFormat format,  gint64 start,  gint64 stop,  gint64 time);
249 		gst_segment_set_newsegment(gstSegment, update, rate, format, start, stop, time);
250 	}
251 	
252 	/**
253 	 * Update the segment structure with the field values of a new segment event.
254 	 * Params:
255 	 * segment = a GstSegment structure.
256 	 * update = flag indicating a new segment is started or updated
257 	 * rate = the rate of the segment.
258 	 * appliedRate = the applied rate of the segment.
259 	 * format = the format of the segment.
260 	 * start = the new start value
261 	 * stop = the new stop value
262 	 * time = the new stream time
263 	 */
264 	public void setNewsegmentFull(int update, double rate, double appliedRate, GstFormat format, long start, long stop, long time)
265 	{
266 		// void gst_segment_set_newsegment_full (GstSegment *segment,  gboolean update,  gdouble rate,  gdouble applied_rate,  GstFormat format,  gint64 start,  gint64 stop,  gint64 time);
267 		gst_segment_set_newsegment_full(gstSegment, update, rate, appliedRate, format, start, stop, time);
268 	}
269 	
270 	/**
271 	 * Update the segment structure with the field values of a seek event (see
272 	 * gst_event_new_seek()).
273 	 * After calling this method, the segment field last_stop and time will
274 	 * contain the requested new position in the segment. The new requested
275 	 * position in the segment depends on rate and start_type and stop_type.
276 	 * For positive rate, the new position in the segment is the new segment
277 	 * start field when it was updated with a start_type different from
278 	 * GST_SEEK_TYPE_NONE. If no update was performed on segment start position
279 	 * (GST_SEEK_TYPE_NONE), start is ignored and segment last_stop is
280 	 * unmodified.
281 	 * For negative rate, the new position in the segment is the new segment
282 	 * stop field when it was updated with a stop_type different from
283 	 * GST_SEEK_TYPE_NONE. If no stop was previously configured in the segment, the
284 	 * duration of the segment will be used to update the stop position.
285 	 * If no update was performed on segment stop position (GST_SEEK_TYPE_NONE),
286 	 * stop is ignored and segment last_stop is unmodified.
287 	 * The applied rate of the segment will be set to 1.0 by default.
288 	 * If the caller can apply a rate change, it should update segment
289 	 * rate and applied_rate after calling this function.
290 	 * update will be set to TRUE if a seek should be performed to the segment
291 	 * last_stop field. This field can be FALSE if, for example, only the rate
292 	 * has been changed but not the playback position.
293 	 * Params:
294 	 * rate = the rate of the segment.
295 	 * format = the format of the segment.
296 	 * flags = the seek flags for the segment
297 	 * startType = the seek method
298 	 * start = the seek start value
299 	 * stopType = the seek method
300 	 * stop = the seek stop value
301 	 * update = boolean holding whether last_stop was updated.
302 	 */
303 	public void setSeek(double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop, ref int update)
304 	{
305 		// void gst_segment_set_seek (GstSegment *segment,  gdouble rate,  GstFormat format,  GstSeekFlags flags,  GstSeekType start_type,  gint64 start,  GstSeekType stop_type,  gint64 stop,  gboolean *update);
306 		gst_segment_set_seek(gstSegment, rate, format, flags, startType, start, stopType, stop, &update);
307 	}
308 	
309 	/**
310 	 * Translate position to the total running time using the currently configured
311 	 * and previously accumulated segments. Position is a value between segment
312 	 * start and stop time.
313 	 * This function is typically used by elements that need to synchronize to the
314 	 * global clock in a pipeline. The runnning time is a constantly increasing value
315 	 * starting from 0. When gst_segment_init() is called, this value will reset to
316 	 * 0.
317 	 * This function returns -1 if the position is outside of segment start and stop.
318 	 * Params:
319 	 * format = the format of the segment.
320 	 * position = the position in the segment
321 	 * Returns: the position as the total running time or -1 when an invalid position was given.
322 	 */
323 	public long toRunningTime(GstFormat format, long position)
324 	{
325 		// gint64 gst_segment_to_running_time (GstSegment *segment,  GstFormat format,  gint64 position);
326 		return gst_segment_to_running_time(gstSegment, format, position);
327 	}
328 	
329 	/**
330 	 * Translate position to stream time using the currently configured
331 	 * segment. The position value must be between segment start and
332 	 * stop value.
333 	 * This function is typically used by elements that need to operate on
334 	 * the stream time of the buffers it receives, such as effect plugins.
335 	 * In those use cases, position is typically the buffer timestamp or
336 	 * clock time that one wants to convert to the stream time.
337 	 * The stream time is always between 0 and the total duration of the
338 	 * media stream.
339 	 * Params:
340 	 * format = the format of the segment.
341 	 * position = the position in the segment
342 	 * Returns: the position in stream_time or -1 when an invalid position was given.
343 	 */
344 	public long toStreamTime(GstFormat format, long position)
345 	{
346 		// gint64 gst_segment_to_stream_time (GstSegment *segment,  GstFormat format,  gint64 position);
347 		return gst_segment_to_stream_time(gstSegment, format, position);
348 	}
349 }