| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | #ifndef _GSTREAMERMM_SEGMENT_H |
| 3 | #define _GSTREAMERMM_SEGMENT_H |
| 4 | |
| 5 | |
| 6 | #include <glibmm/ustring.h> |
| 7 | #include <sigc++/sigc++.h> |
| 8 | |
| 9 | /* gstreamermm - a C++ wrapper for gstreamer |
| 10 | * |
| 11 | * Copyright 2008-2016 The gstreamermm Development Team |
| 12 | * |
| 13 | * This library is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU Lesser General Public |
| 15 | * License as published by the Free Software Foundation; either |
| 16 | * version 2.1 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * This library is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | * Lesser General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU Lesser General Public |
| 24 | * License along with this library; if not, write to the Free |
| 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 26 | */ |
| 27 | |
| 28 | #include <gstreamermm/clock.h> |
| 29 | #include <gstreamermm/format.h> |
| 30 | |
| 31 | |
| 32 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 33 | extern "C" { typedef struct _GstSegment GstSegment; } |
| 34 | #endif |
| 35 | |
| 36 | namespace Gst |
| 37 | { |
| 38 | |
| 39 | /** @addtogroup gstreamermmEnums gstreamermm Enums and Flags */ |
| 40 | |
| 41 | /** |
| 42 | * @var SeekFlags SEEK_FLAG_NONE |
| 43 | * No flag. |
| 44 | * |
| 45 | * @var SeekFlags SEEK_FLAG_FLUSH |
| 46 | * Flush pipeline. |
| 47 | * |
| 48 | * @var SeekFlags SEEK_FLAG_ACCURATE |
| 49 | * Accurate position is requested, this might |
| 50 | * be considerably slower for some formats. |
| 51 | * |
| 52 | * @var SeekFlags SEEK_FLAG_KEY_UNIT |
| 53 | * Seek to the nearest keyframe. This might be |
| 54 | * faster but less accurate. |
| 55 | * |
| 56 | * @var SeekFlags SEEK_FLAG_SEGMENT |
| 57 | * Perform a segment seek. |
| 58 | * |
| 59 | * @var SeekFlags SEEK_FLAG_TRICKMODE |
| 60 | * When doing fast forward or fast reverse playback, allow |
| 61 | * elements to skip frames instead of generating all |
| 62 | * frames. (Since 1.6). |
| 63 | * |
| 64 | * @var SeekFlags SEEK_FLAG_SNAP_BEFORE |
| 65 | * Go to a location before the requested position, |
| 66 | * if Gst::SEEK_FLAG_KEY_UNIT this means the keyframe at or before |
| 67 | * the requested position the one at or before the seek target. |
| 68 | * |
| 69 | * @var SeekFlags SEEK_FLAG_SNAP_AFTER |
| 70 | * Go to a location after the requested position, |
| 71 | * if Gst::SEEK_FLAG_KEY_UNIT this means the keyframe at of after the |
| 72 | * requested position. |
| 73 | * |
| 74 | * @var SeekFlags SEEK_FLAG_SNAP_NEAREST |
| 75 | * Go to a position near the requested position, |
| 76 | * if Gst::SEEK_FLAG_KEY_UNIT this means the keyframe closest |
| 77 | * to the requested position, if both keyframes are at an equal |
| 78 | * distance, behaves like Gst::SEEK_FLAG_SNAP_BEFORE. |
| 79 | * |
| 80 | * @var SeekFlags SEEK_FLAG_TRICKMODE_KEY_UNITS |
| 81 | * When doing fast forward or fast reverse |
| 82 | * playback, request that elements only decode keyframes |
| 83 | * and skip all other content, for formats that have |
| 84 | * keyframes. (Since 1.6). |
| 85 | * |
| 86 | * @var SeekFlags SEEK_FLAG_TRICKMODE_NO_AUDIO |
| 87 | * When doing fast forward or fast reverse |
| 88 | * playback, request that audio decoder elements skip |
| 89 | * decoding and output only gap events or silence. (Since 1.6). |
| 90 | * |
| 91 | * @var SeekFlags SEEK_FLAG_SKIP |
| 92 | * Deprecated backward compatibility flag, replaced |
| 93 | * by Gst::SEEK_FLAG_TRICKMODE. |
| 94 | * |
| 95 | * @enum SeekFlags |
| 96 | * |
| 97 | * Flags to be used with Gst::Element::seek() or Gst::Event::new_seek(). All flags |
| 98 | * can be used together. |
| 99 | * |
| 100 | * A non flushing seek might take some time to perform as the currently |
| 101 | * playing data in the pipeline will not be cleared. |
| 102 | * |
| 103 | * An accurate seek might be slower for formats that don't have any indexes |
| 104 | * or timestamp markers in the stream. Specifying this flag might require a |
| 105 | * complete scan of the file in those cases. |
| 106 | * |
| 107 | * When performing a segment seek: after the playback of the segment completes, |
| 108 | * no EOS will be emitted by the element that performed the seek, but a |
| 109 | * Gst::MESSAGE_SEGMENT_DONE message will be posted on the bus by the element. |
| 110 | * When this message is posted, it is possible to send a new seek event to |
| 111 | * continue playback. With this seek method it is possible to perform seamless |
| 112 | * looping or simple linear editing. |
| 113 | * |
| 114 | * When doing fast forward (rate > 1.0) or fast reverse (rate < -1.0) trickmode |
| 115 | * playback, the Gst::SEEK_FLAG_TRICKMODE flag can be used to instruct decoders |
| 116 | * and demuxers to adjust the playback rate by skipping frames. This can improve |
| 117 | * performance and decrease CPU usage because not all frames need to be decoded. |
| 118 | * |
| 119 | * Beyond that, the Gst::SEEK_FLAG_TRICKMODE_KEY_UNITS flag can be used to |
| 120 | * request that decoders skip all frames except key units, and |
| 121 | * Gst::SEEK_FLAG_TRICKMODE_NO_AUDIO flags can be used to request that audio |
| 122 | * decoders do no decoding at all, and simple output silence. |
| 123 | * |
| 124 | * The Gst::SEEK_FLAG_SNAP_BEFORE flag can be used to snap to the previous |
| 125 | * relevant location, and the Gst::SEEK_FLAG_SNAP_AFTER flag can be used to |
| 126 | * select the next relevant location. If Gst::SEEK_FLAG_KEY_UNIT is specified, |
| 127 | * the relevant location is a keyframe. If both flags are specified, the nearest |
| 128 | * of these locations will be selected. If none are specified, the implementation is |
| 129 | * free to select whichever it wants. |
| 130 | * |
| 131 | * The before and after here are in running time, so when playing backwards, |
| 132 | * the next location refers to the one that will played in next, and not the |
| 133 | * one that is located after in the actual source stream. |
| 134 | * |
| 135 | * Also see part-seeking.txt in the GStreamer design documentation for more |
| 136 | * details on the meaning of these flags and the behaviour expected of |
| 137 | * elements that handle them. |
| 138 | * |
| 139 | * @ingroup gstreamermmEnums |
| 140 | * @par Bitwise operators: |
| 141 | * <tt>%SeekFlags operator|(SeekFlags, SeekFlags)</tt><br> |
| 142 | * <tt>%SeekFlags operator&(SeekFlags, SeekFlags)</tt><br> |
| 143 | * <tt>%SeekFlags operator^(SeekFlags, SeekFlags)</tt><br> |
| 144 | * <tt>%SeekFlags operator~(SeekFlags)</tt><br> |
| 145 | * <tt>%SeekFlags& operator|=(SeekFlags&, SeekFlags)</tt><br> |
| 146 | * <tt>%SeekFlags& operator&=(SeekFlags&, SeekFlags)</tt><br> |
| 147 | * <tt>%SeekFlags& operator^=(SeekFlags&, SeekFlags)</tt><br> |
| 148 | */ |
| 149 | enum SeekFlags |
| 150 | { |
| 151 | SEEK_FLAG_NONE = 0x0, |
| 152 | SEEK_FLAG_FLUSH = (1 << 0), |
| 153 | SEEK_FLAG_ACCURATE = (1 << 1), |
| 154 | SEEK_FLAG_KEY_UNIT = (1 << 2), |
| 155 | SEEK_FLAG_SEGMENT = (1 << 3), |
| 156 | SEEK_FLAG_TRICKMODE = (1 << 4), |
| 157 | SEEK_FLAG_SKIP = (1 << 4), |
| 158 | SEEK_FLAG_SNAP_BEFORE = (1 << 5), |
| 159 | SEEK_FLAG_SNAP_AFTER = (1 << 6), |
| 160 | SEEK_FLAG_SNAP_NEAREST = 0x60, |
| 161 | SEEK_FLAG_TRICKMODE_KEY_UNITS = (1 << 7), |
| 162 | SEEK_FLAG_TRICKMODE_NO_AUDIO = (1 << 8) |
| 163 | }; |
| 164 | |
| 165 | /** @ingroup gstreamermmEnums */ |
| 166 | inline SeekFlags operator|(SeekFlags lhs, SeekFlags rhs) |
| 167 | { return static_cast<SeekFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } |
| 168 | |
| 169 | /** @ingroup gstreamermmEnums */ |
| 170 | inline SeekFlags operator&(SeekFlags lhs, SeekFlags rhs) |
| 171 | { return static_cast<SeekFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } |
| 172 | |
| 173 | /** @ingroup gstreamermmEnums */ |
| 174 | inline SeekFlags operator^(SeekFlags lhs, SeekFlags rhs) |
| 175 | { return static_cast<SeekFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } |
| 176 | |
| 177 | /** @ingroup gstreamermmEnums */ |
| 178 | inline SeekFlags operator~(SeekFlags flags) |
| 179 | { return static_cast<SeekFlags>(~static_cast<unsigned>(flags)); } |
| 180 | |
| 181 | /** @ingroup gstreamermmEnums */ |
| 182 | inline SeekFlags& operator|=(SeekFlags& lhs, SeekFlags rhs) |
| 183 | { return (lhs = static_cast<SeekFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } |
| 184 | |
| 185 | /** @ingroup gstreamermmEnums */ |
| 186 | inline SeekFlags& operator&=(SeekFlags& lhs, SeekFlags rhs) |
| 187 | { return (lhs = static_cast<SeekFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } |
| 188 | |
| 189 | /** @ingroup gstreamermmEnums */ |
| 190 | inline SeekFlags& operator^=(SeekFlags& lhs, SeekFlags rhs) |
| 191 | { return (lhs = static_cast<SeekFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } |
| 192 | |
| 193 | } // namespace Gst |
| 194 | |
| 195 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 196 | namespace Glib |
| 197 | { |
| 198 | |
| 199 | template <> |
| 200 | class Value<Gst::SeekFlags> : public Glib::Value_Flags<Gst::SeekFlags> |
| 201 | { |
| 202 | public: |
| 203 | static GType value_type() G_GNUC_CONST; |
| 204 | }; |
| 205 | |
| 206 | } // namespace Glib |
| 207 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 208 | |
| 209 | namespace Gst |
| 210 | { |
| 211 | |
| 212 | /** |
| 213 | * @var SeekType SEEK_TYPE_NONE |
| 214 | * No change in position is required. |
| 215 | * |
| 216 | * @var SeekType SEEK_TYPE_SET |
| 217 | * Absolute position is requested. |
| 218 | * |
| 219 | * @var SeekType SEEK_TYPE_END |
| 220 | * Relative position to duration is requested. |
| 221 | * |
| 222 | * @enum SeekType |
| 223 | * |
| 224 | * The different types of seek events. When constructing a seek event with |
| 225 | * Gst::Event::new_seek() or when doing Gst::Segment::do_seek(). |
| 226 | * |
| 227 | * @ingroup gstreamermmEnums |
| 228 | */ |
| 229 | enum SeekType |
| 230 | { |
| 231 | SEEK_TYPE_NONE, |
| 232 | SEEK_TYPE_SET, |
| 233 | SEEK_TYPE_END |
| 234 | }; |
| 235 | |
| 236 | } // namespace Gst |
| 237 | |
| 238 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 239 | namespace Glib |
| 240 | { |
| 241 | |
| 242 | template <> |
| 243 | class Value<Gst::SeekType> : public Glib::Value_Enum<Gst::SeekType> |
| 244 | { |
| 245 | public: |
| 246 | static GType value_type() G_GNUC_CONST; |
| 247 | }; |
| 248 | |
| 249 | } // namespace Glib |
| 250 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 251 | |
| 252 | namespace Gst |
| 253 | { |
| 254 | |
| 255 | |
| 256 | /** A class that describes the configured region of interest in a media file. |
| 257 | * This helper structure holds the relevant values for tracking the region of |
| 258 | * interest in a media file, called a segment. |
| 259 | * |
| 260 | * The structure can be used for two purposes: |
| 261 | * |
| 262 | * - performing seeks (handling seek events) |
| 263 | * - tracking playback regions (handling newsegment events) |
| 264 | * |
| 265 | * The segment is usually configured by the application with a seek event which |
| 266 | * is propagated upstream and eventually handled by an element that performs |
| 267 | * the seek. |
| 268 | * |
| 269 | * The configured segment is then propagated back downstream with a newsegment |
| 270 | * event. This information is then used to clip media to the segment |
| 271 | * boundaries. |
| 272 | * |
| 273 | * A segment structure is initialized with init(), which takes a Format that |
| 274 | * will be used as the format of the segment values. The segment will be |
| 275 | * configured with a start value of 0 and a stop/duration of -1, which is |
| 276 | * undefined. The default rate and applied_rate is 1.0. |
| 277 | * |
| 278 | * The current position in the segment should be set with the set_last_stop(). |
| 279 | * The public last_stop field contains the last set stop position in the |
| 280 | * segment. |
| 281 | * |
| 282 | * For elements that perform seeks, the current segment should be updated with |
| 283 | * the set_seek() and the values from the seek event. This method will update |
| 284 | * all the segment fields. The last_stop field will contain the new playback |
| 285 | * position. If the cur_type was different from Gst::SEEK_TYPE_NONE, playback |
| 286 | * continues from the last_stop position, possibly with updated flags or rate. |
| 287 | * |
| 288 | * For elements that want to synchronize to the pipeline clock, |
| 289 | * to_running_time() can be used to convert a timestamp to a value that can be |
| 290 | * used to synchronize to the clock. This function takes into account all |
| 291 | * accumulated segments as well as any rate or applied_rate conversions. |
| 292 | * |
| 293 | * For elements that need to perform operations on media data in stream_time, |
| 294 | * to_stream_time() can be used to convert a timestamp and the segment info to |
| 295 | * stream time (which is always between 0 and the duration of the stream). |
| 296 | * |
| 297 | * Last reviewed on 2016-07-12 (1.8.0) |
| 298 | */ |
| 299 | class Segment |
| 300 | { |
| 301 | public: |
| 302 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 303 | using CppObjectType = Segment; |
| 304 | using BaseObjectType = GstSegment; |
| 305 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 306 | |
| 307 | /** Get the GType for this class, for use with the underlying GObject type system. |
| 308 | */ |
| 309 | static GType get_type() G_GNUC_CONST; |
| 310 | |
| 311 | Segment(); |
| 312 | |
| 313 | explicit Segment(GstSegment* gobject, bool make_a_copy = true); |
| 314 | |
| 315 | Segment(const Segment& other); |
| 316 | Segment& operator=(const Segment& other); |
| 317 | |
| 318 | Segment(Segment&& other) noexcept; |
| 319 | Segment& operator=(Segment&& other) noexcept; |
| 320 | |
| 321 | ~Segment() noexcept; |
| 322 | |
| 323 | void swap(Segment& other) noexcept; |
| 324 | |
| 325 | ///Provides access to the underlying C instance. |
| 326 | GstSegment* gobj() { return gobject_; } |
| 327 | |
| 328 | ///Provides access to the underlying C instance. |
| 329 | const GstSegment* gobj() const { return gobject_; } |
| 330 | |
| 331 | ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. |
| 332 | GstSegment* gobj_copy() const; |
| 333 | |
| 334 | protected: |
| 335 | GstSegment* gobject_; |
| 336 | |
| 337 | private: |
| 338 | |
| 339 | |
| 340 | public: |
| 341 | |
| 342 | /** Clip the given @a start and @a stop values to the segment boundaries given |
| 343 | * in @a segment. @a start and @a stop are compared and clipped to @a segment |
| 344 | * start and stop values. |
| 345 | * |
| 346 | * If the function returns <tt>false</tt>, @a start and @a stop are known to fall |
| 347 | * outside of @a segment and @a clip_start and @a clip_stop are not updated. |
| 348 | * |
| 349 | * When the function returns <tt>true</tt>, @a clip_start and @a clip_stop will be |
| 350 | * updated. If @a clip_start or @a clip_stop are different from @a start or @a stop |
| 351 | * respectively, the region fell partially in the segment. |
| 352 | * |
| 353 | * Note that when @a stop is -1, @a clip_stop will be set to the end of the |
| 354 | * segment. Depending on the use case, this may or may not be what you want. |
| 355 | * |
| 356 | * @param format The format of the segment. |
| 357 | * @param start The start position in the segment. |
| 358 | * @param stop The stop position in the segment. |
| 359 | * @param clip_start The clipped start position in the segment. |
| 360 | * @param clip_stop The clipped stop position in the segment. |
| 361 | * @return <tt>true</tt> if the given @a start and @a stop times fall partially or |
| 362 | * completely in @a segment, <tt>false</tt> if the values are completely outside |
| 363 | * of the segment. |
| 364 | */ |
| 365 | bool clip(Format format, guint64 start, guint64 stop, guint64& clip_start, guint64& clip_stop) const; |
| 366 | |
| 367 | /** The start/position fields are set to 0 and the stop/duration |
| 368 | * fields are set to -1 (unknown). The default rate of 1.0 and no |
| 369 | * flags are set. |
| 370 | * |
| 371 | * Initialize @a segment to its default values. |
| 372 | * |
| 373 | * @param format The format of the segment. |
| 374 | */ |
| 375 | void init(Format format); |
| 376 | |
| 377 | /** Update the segment structure with the field values of a seek event (see |
| 378 | * Gst::Event::new_seek()). |
| 379 | * |
| 380 | * After calling this method, the segment field position and time will |
| 381 | * contain the requested new position in the segment. The new requested |
| 382 | * position in the segment depends on @a rate and @a start_type and @a stop_type. |
| 383 | * |
| 384 | * For positive @a rate, the new position in the segment is the new @a segment |
| 385 | * start field when it was updated with a @a start_type different from |
| 386 | * Gst::SEEK_TYPE_NONE. If no update was performed on @a segment start position |
| 387 | * (Gst::SEEK_TYPE_NONE), @a start is ignored and @a segment position is |
| 388 | * unmodified. |
| 389 | * |
| 390 | * For negative @a rate, the new position in the segment is the new @a segment |
| 391 | * stop field when it was updated with a @a stop_type different from |
| 392 | * Gst::SEEK_TYPE_NONE. If no stop was previously configured in the segment, the |
| 393 | * duration of the segment will be used to update the stop position. |
| 394 | * If no update was performed on @a segment stop position (Gst::SEEK_TYPE_NONE), |
| 395 | * @a stop is ignored and @a segment position is unmodified. |
| 396 | * |
| 397 | * The applied rate of the segment will be set to 1.0 by default. |
| 398 | * If the caller can apply a rate change, it should update @a segment |
| 399 | * rate and applied_rate after calling this function. |
| 400 | * |
| 401 | * @a update will be set to <tt>true</tt> if a seek should be performed to the segment |
| 402 | * position field. This field can be <tt>false</tt> if, for example, only the @a rate |
| 403 | * has been changed but not the playback position. |
| 404 | * |
| 405 | * @param rate The rate of the segment. |
| 406 | * @param format The format of the segment. |
| 407 | * @param flags The segment flags for the segment. |
| 408 | * @param start_type The seek method. |
| 409 | * @param start The seek start value. |
| 410 | * @param stop_type The seek method. |
| 411 | * @param stop The seek stop value. |
| 412 | * @param update Boolean holding whether position was updated. |
| 413 | * @return <tt>true</tt> if the seek could be performed. |
| 414 | */ |
| 415 | |
| 416 | void set_seek(double rate, Format format, SeekFlags flags, SeekType start_type, gint64 start, SeekType stop_type, gint64 stop, bool& update); |
| 417 | |
| 418 | /** Translate @a position to the total running time using the currently configured |
| 419 | * segment. Position is a value between @a segment start and stop time. |
| 420 | * |
| 421 | * This function is typically used by elements that need to synchronize to the |
| 422 | * global clock in a pipeline. The running time is a constantly increasing value |
| 423 | * starting from 0. When init() is called, this value will reset to |
| 424 | * 0. |
| 425 | * |
| 426 | * This function returns -1 if the position is outside of @a segment start and stop. |
| 427 | * |
| 428 | * @param format The format of the segment. |
| 429 | * @param position The position in the segment. |
| 430 | * @return The position as the total running time or -1 when an invalid position |
| 431 | * was given. |
| 432 | */ |
| 433 | guint64 to_running_time(Format format, guint64 position) const; |
| 434 | |
| 435 | /** Translate @a position to the total running time using the currently configured |
| 436 | * segment. Compared to to_running_time() this function can return |
| 437 | * negative running-time. |
| 438 | * |
| 439 | * This function is typically used by elements that need to synchronize buffers |
| 440 | * against the clock or eachother. |
| 441 | * |
| 442 | * @a position can be any value and the result of this function for values outside |
| 443 | * of the segment is extrapolated. |
| 444 | * |
| 445 | * When 1 is returned, @a position resulted in a positive running-time returned |
| 446 | * in @a running_time. |
| 447 | * |
| 448 | * When this function returns -1, the returned @a running_time should be negated |
| 449 | * to get the real negative running time. |
| 450 | * |
| 451 | * @param format The format of the segment. |
| 452 | * @param position The position in the segment. |
| 453 | * @param running_time Result running-time. |
| 454 | * @return A 1 or -1 on success, 0 on failure. |
| 455 | */ |
| 456 | int to_running_time(Format format, guint64 position, guint64& running_time) const; |
| 457 | |
| 458 | /** Translate @a position to stream time using the currently configured |
| 459 | * segment. The @a position value must be between @a segment start and |
| 460 | * stop value. |
| 461 | * |
| 462 | * This function is typically used by elements that need to operate on |
| 463 | * the stream time of the buffers it receives, such as effect plugins. |
| 464 | * In those use cases, @a position is typically the buffer timestamp or |
| 465 | * clock time that one wants to convert to the stream time. |
| 466 | * The stream time is always between 0 and the total duration of the |
| 467 | * media stream. |
| 468 | * |
| 469 | * @param format The format of the segment. |
| 470 | * @param position The position in the segment. |
| 471 | * @return The position in stream_time or -1 when an invalid position |
| 472 | * was given. |
| 473 | */ |
| 474 | guint64 to_stream_time(Format format, guint64 position) const; |
| 475 | |
| 476 | /** Translate @a position to the total stream time using the currently configured |
| 477 | * segment. Compared to to_stream_time() this function can return |
| 478 | * negative stream-time. |
| 479 | * |
| 480 | * This function is typically used by elements that need to synchronize buffers |
| 481 | * against the clock or eachother. |
| 482 | * |
| 483 | * @a position can be any value and the result of this function for values outside |
| 484 | * of the segment is extrapolated. |
| 485 | * |
| 486 | * When 1 is returned, @a position resulted in a positive stream-time returned |
| 487 | * in @a stream_time. |
| 488 | * |
| 489 | * When this function returns -1, the returned @a stream_time should be negated |
| 490 | * to get the real negative stream time. |
| 491 | * |
| 492 | * @param format The format of the segment. |
| 493 | * @param position The position in the segment. |
| 494 | * @param stream_time Result stream-time. |
| 495 | * @return A 1 or -1 on success, 0 on failure. |
| 496 | */ |
| 497 | int to_stream_time(Format format, guint64 position, guint64& stream_time) const; |
| 498 | |
| 499 | /** Convert @a running_time into a position in the segment so that |
| 500 | * to_running_time() with that position returns @a running_time. |
| 501 | * |
| 502 | * @param format The format of the segment. |
| 503 | * @param running_time The running_time in the segment. |
| 504 | * @return The position in the segment for @a running_time. This function returns |
| 505 | * -1 when @a running_time is -1 or when it is not inside @a segment. |
| 506 | * |
| 507 | * Deprecated. Use position_from_running_time() instead. |
| 508 | */ |
| 509 | guint64 to_position(Format format, guint64 running_time) const; |
| 510 | |
| 511 | /** Adjust the start/stop and base values of @a segment such that the next valid |
| 512 | * buffer will be one with @a running_time. |
| 513 | * |
| 514 | * @param format The format of the segment. |
| 515 | * @param running_time The running_time in the segment. |
| 516 | * @return <tt>true</tt> if the segment could be updated successfully. If <tt>false</tt> is |
| 517 | * returned, @a running_time is -1 or not in @a segment. |
| 518 | */ |
| 519 | bool set_running_time(Format format, guint64 running_time); |
| 520 | |
| 521 | /** Convert @a running_time into a position in the segment so that |
| 522 | * to_running_time() with that position returns @a running_time. |
| 523 | * |
| 524 | * @param format The format of the segment. |
| 525 | * @param running_time The running_time in the segment. |
| 526 | * @return The position in the segment for @a running_time. This function returns |
| 527 | * -1 when @a running_time is -1 or when it is not inside @a segment. |
| 528 | */ |
| 529 | guint64 position_from_running_time(Gst::Format format, guint64 running_time) const; |
| 530 | |
| 531 | /** Translate @a running_time to the segment position using the currently configured |
| 532 | * segment. Compared to position_from_running_time() this function can |
| 533 | * return negative segment position. |
| 534 | * |
| 535 | * This function is typically used by elements that need to synchronize buffers |
| 536 | * against the clock or each other. |
| 537 | * |
| 538 | * @a running_time can be any value and the result of this function for values |
| 539 | * outside of the segment is extrapolated. |
| 540 | * |
| 541 | * When 1 is returned, @a running_time resulted in a positive position returned |
| 542 | * in @a position. |
| 543 | * |
| 544 | * When this function returns -1, the returned @a position should be negated |
| 545 | * to get the real negative segment position. |
| 546 | * |
| 547 | * @param format The format of the segment. |
| 548 | * @param running_time The running-time. |
| 549 | * @param position The resulting position in the segment. |
| 550 | * @return A 1 or -1 on success, 0 on failure. |
| 551 | */ |
| 552 | int position_from_running_time(Gst::Format format, guint64 running_time, guint64& position) const; |
| 553 | |
| 554 | /** Convert @a stream_time into a position in the segment so that |
| 555 | * to_stream_time() with that position returns @a stream_time. |
| 556 | * |
| 557 | * @param format The format of the segment. |
| 558 | * @param stream_time The stream_time in the segment. |
| 559 | * @return The position in the segment for @a stream_time. This function returns |
| 560 | * -1 when @a stream_time is -1 or when it is not inside @a segment. |
| 561 | */ |
| 562 | guint64 position_from_stream_time(Gst::Format format, guint64 stream_time) const; |
| 563 | |
| 564 | /** Translate @a stream_time to the segment position using the currently configured |
| 565 | * segment. Compared to position_from_stream_time() this function can |
| 566 | * return negative segment position. |
| 567 | * |
| 568 | * This function is typically used by elements that need to synchronize buffers |
| 569 | * against the clock or each other. |
| 570 | * |
| 571 | * @a stream_time can be any value and the result of this function for values outside |
| 572 | * of the segment is extrapolated. |
| 573 | * |
| 574 | * When 1 is returned, @a stream_time resulted in a positive position returned |
| 575 | * in @a position. |
| 576 | * |
| 577 | * When this function returns -1, the returned @a position should be negated |
| 578 | * to get the real negative segment position. |
| 579 | * |
| 580 | * @param format The format of the segment. |
| 581 | * @param stream_time The stream-time. |
| 582 | * @param position The resulting position in the segment. |
| 583 | * @return A 1 or -1 on success, 0 on failure. |
| 584 | */ |
| 585 | int position_from_stream_time(Gst::Format format, guint64 stream_time, guint64& position) const; |
| 586 | |
| 587 | /** Adjust the values in @a segment so that @a offset is applied to all |
| 588 | * future running-time calculations. |
| 589 | * |
| 590 | * @param format The format of the segment. |
| 591 | * @param offset The offset to apply in the segment. |
| 592 | * @return <tt>true</tt> if the segment could be updated successfully. If <tt>false</tt> is |
| 593 | * returned, @a offset is not in @a segment. |
| 594 | */ |
| 595 | bool offset_running_time(Gst::Format format, gint64 offset); |
| 596 | |
| 597 | /** Checks for two segments being equal. Equality here is defined |
| 598 | * as perfect equality, including floating point values. |
| 599 | * |
| 600 | * @param s2 A Gst::Segment structure. |
| 601 | * @return <tt>true</tt> if the segments are equal, <tt>false</tt> otherwise. |
| 602 | */ |
| 603 | bool is_equal(const Gst::Segment& s2) const; |
| 604 | |
| 605 | |
| 606 | }; |
| 607 | |
| 608 | } //namespace Gst |
| 609 | |
| 610 | |
| 611 | namespace Gst |
| 612 | { |
| 613 | |
| 614 | /** @relates Gst::Segment |
| 615 | * @param lhs The left-hand side |
| 616 | * @param rhs The right-hand side |
| 617 | */ |
| 618 | inline void swap(Segment& lhs, Segment& rhs) noexcept |
| 619 | { lhs.swap(rhs); } |
| 620 | |
| 621 | } // namespace Gst |
| 622 | |
| 623 | namespace Glib |
| 624 | { |
| 625 | |
| 626 | /** A Glib::wrap() method for this object. |
| 627 | * |
| 628 | * @param object The C instance. |
| 629 | * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
| 630 | * @result A C++ instance that wraps this C instance. |
| 631 | * |
| 632 | * @relates Gst::Segment |
| 633 | */ |
| 634 | Gst::Segment wrap(GstSegment* object, bool take_copy = false); |
| 635 | |
| 636 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 637 | template <> |
| 638 | class Value<Gst::Segment> : public Glib::Value_Boxed<Gst::Segment> |
| 639 | {}; |
| 640 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 641 | |
| 642 | } // namespace Glib |
| 643 | |
| 644 | |
| 645 | #endif /* _GSTREAMERMM_SEGMENT_H */ |
| 646 |