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