| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | #ifndef _GSTREAMERMM_OBJECT_H |
| 3 | #define _GSTREAMERMM_OBJECT_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 <gst/gst.h> |
| 29 | #include <glibmm/object.h> |
| 30 | #include <glibmm/listhandle.h> |
| 31 | #include <glibmm/threads.h> |
| 32 | #include <gstreamermm/clockutils.h> |
| 33 | |
| 34 | |
| 35 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 36 | using GstObject = struct _GstObject; |
| 37 | using GstObjectClass = struct _GstObjectClass; |
| 38 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 39 | |
| 40 | |
| 41 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 42 | namespace Gst |
| 43 | { class Object_Class; } // namespace Gst |
| 44 | #endif //DOXYGEN_SHOULD_SKIP_THIS |
| 45 | |
| 46 | namespace Gst |
| 47 | { |
| 48 | |
| 49 | /** @addtogroup gstreamermmEnums gstreamermm Enums and Flags */ |
| 50 | |
| 51 | /** |
| 52 | * @var ObjectFlags OBJECT_FLAG_LAST |
| 53 | * Subclasses can add additional flags starting from this flag. |
| 54 | * |
| 55 | * @enum ObjectFlags |
| 56 | * |
| 57 | * The standard flags that an gstobject may have. |
| 58 | * |
| 59 | * @ingroup gstreamermmEnums |
| 60 | * @par Bitwise operators: |
| 61 | * <tt>%ObjectFlags operator|(ObjectFlags, ObjectFlags)</tt><br> |
| 62 | * <tt>%ObjectFlags operator&(ObjectFlags, ObjectFlags)</tt><br> |
| 63 | * <tt>%ObjectFlags operator^(ObjectFlags, ObjectFlags)</tt><br> |
| 64 | * <tt>%ObjectFlags operator~(ObjectFlags)</tt><br> |
| 65 | * <tt>%ObjectFlags& operator|=(ObjectFlags&, ObjectFlags)</tt><br> |
| 66 | * <tt>%ObjectFlags& operator&=(ObjectFlags&, ObjectFlags)</tt><br> |
| 67 | * <tt>%ObjectFlags& operator^=(ObjectFlags&, ObjectFlags)</tt><br> |
| 68 | */ |
| 69 | enum ObjectFlags |
| 70 | { |
| 71 | OBJECT_FLAG_LAST = (1<<4) |
| 72 | }; |
| 73 | |
| 74 | /** @ingroup gstreamermmEnums */ |
| 75 | inline ObjectFlags operator|(ObjectFlags lhs, ObjectFlags rhs) |
| 76 | { return static_cast<ObjectFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } |
| 77 | |
| 78 | /** @ingroup gstreamermmEnums */ |
| 79 | inline ObjectFlags operator&(ObjectFlags lhs, ObjectFlags rhs) |
| 80 | { return static_cast<ObjectFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } |
| 81 | |
| 82 | /** @ingroup gstreamermmEnums */ |
| 83 | inline ObjectFlags operator^(ObjectFlags lhs, ObjectFlags rhs) |
| 84 | { return static_cast<ObjectFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } |
| 85 | |
| 86 | /** @ingroup gstreamermmEnums */ |
| 87 | inline ObjectFlags operator~(ObjectFlags flags) |
| 88 | { return static_cast<ObjectFlags>(~static_cast<unsigned>(flags)); } |
| 89 | |
| 90 | /** @ingroup gstreamermmEnums */ |
| 91 | inline ObjectFlags& operator|=(ObjectFlags& lhs, ObjectFlags rhs) |
| 92 | { return (lhs = static_cast<ObjectFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } |
| 93 | |
| 94 | /** @ingroup gstreamermmEnums */ |
| 95 | inline ObjectFlags& operator&=(ObjectFlags& lhs, ObjectFlags rhs) |
| 96 | { return (lhs = static_cast<ObjectFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } |
| 97 | |
| 98 | /** @ingroup gstreamermmEnums */ |
| 99 | inline ObjectFlags& operator^=(ObjectFlags& lhs, ObjectFlags rhs) |
| 100 | { return (lhs = static_cast<ObjectFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } |
| 101 | |
| 102 | } // namespace Gst |
| 103 | |
| 104 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 105 | namespace Glib |
| 106 | { |
| 107 | |
| 108 | template <> |
| 109 | class Value<Gst::ObjectFlags> : public Glib::Value_Flags<Gst::ObjectFlags> |
| 110 | { |
| 111 | public: |
| 112 | static GType value_type() G_GNUC_CONST; |
| 113 | }; |
| 114 | |
| 115 | } // namespace Glib |
| 116 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 117 | |
| 118 | namespace Gst |
| 119 | { |
| 120 | |
| 121 | |
| 122 | /** @defgroup GstBaseClasses gstreamermm Base Classes |
| 123 | * Wrapped GStreamer base classes (plug-ins and other classes derrive from |
| 124 | * these). |
| 125 | */ |
| 126 | |
| 127 | /** A base class for the GStreamer object hierarchy. |
| 128 | * Gst::Object provides a root for the object hierarchy tree filed in by the |
| 129 | * GStreamer library. It is currently a thin wrapper on top of Glib::Object. |
| 130 | * It is an abstract class that is not very usable on its own. |
| 131 | * |
| 132 | * Gst::Object gives us basic refcounting, parenting functionality and |
| 133 | * locking. Most of the function are just extended for special GStreamer needs |
| 134 | * and can be found under the same name in the base class of Gst::Object which |
| 135 | * is Glib::Object (e.g. Glib::Object::reference() becomes |
| 136 | * Gst:Object::reference(). |
| 137 | * |
| 138 | * In contrast to Glib::Object instances, Gst::Object adds a name property. |
| 139 | * The functions set_name() and get_name() are used to set/get the name of the |
| 140 | * object. |
| 141 | * |
| 142 | * Last reviewed on 2016-06-06 (1.8.0) |
| 143 | * @ingroup GstBaseClasses |
| 144 | */ |
| 145 | |
| 146 | class Object : public Glib::Object |
| 147 | { |
| 148 | |
| 149 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 150 | |
| 151 | public: |
| 152 | using CppObjectType = Object; |
| 153 | using CppClassType = Object_Class; |
| 154 | using BaseObjectType = GstObject; |
| 155 | using BaseClassType = GstObjectClass; |
| 156 | |
| 157 | // noncopyable |
| 158 | Object(const Object&) = delete; |
| 159 | Object& operator=(const Object&) = delete; |
| 160 | |
| 161 | private: friend class Object_Class; |
| 162 | static CppClassType object_class_; |
| 163 | |
| 164 | protected: |
| 165 | explicit Object(const Glib::ConstructParams& construct_params); |
| 166 | explicit Object(GstObject* castitem); |
| 167 | |
| 168 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 169 | |
| 170 | public: |
| 171 | |
| 172 | Object(Object&& src) noexcept; |
| 173 | Object& operator=(Object&& src) noexcept; |
| 174 | |
| 175 | ~Object() noexcept override; |
| 176 | |
| 177 | /** Get the GType for this class, for use with the underlying GObject type system. |
| 178 | */ |
| 179 | static GType get_type() G_GNUC_CONST; |
| 180 | |
| 181 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 182 | |
| 183 | |
| 184 | static GType get_base_type() G_GNUC_CONST; |
| 185 | #endif |
| 186 | |
| 187 | ///Provides access to the underlying C GObject. |
| 188 | GstObject* gobj() { return reinterpret_cast<GstObject*>(gobject_); } |
| 189 | |
| 190 | ///Provides access to the underlying C GObject. |
| 191 | const GstObject* gobj() const { return reinterpret_cast<GstObject*>(gobject_); } |
| 192 | |
| 193 | ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. |
| 194 | GstObject* gobj_copy(); |
| 195 | |
| 196 | private: |
| 197 | |
| 198 | |
| 199 | public: |
| 200 | bool is_element() const; |
| 201 | bool is_element_factory() const; |
| 202 | bool is_pad() const; |
| 203 | bool is_pad_template() const; |
| 204 | bool is_bin() const; |
| 205 | |
| 206 | /** Returns the entire set of flags for the object. |
| 207 | */ |
| 208 | guint32 get_flags() const; |
| 209 | |
| 210 | //TODO: These conversions should probably be in the glibmm conversion files. |
| 211 | |
| 212 | |
| 213 | /** Sets the name of @a object, or gives @a object a guaranteed unique |
| 214 | * name (if @a name is <tt>nullptr</tt>). |
| 215 | * This function makes a copy of the provided name, so the caller |
| 216 | * retains ownership of the name it sent. |
| 217 | * |
| 218 | * @param name New name of object. |
| 219 | * @return <tt>true</tt> if the name could be set. Since Objects that have |
| 220 | * a parent cannot be renamed, this function returns <tt>false</tt> in those |
| 221 | * cases. |
| 222 | * |
| 223 | * MT safe. This function grabs and releases @a object's LOCK. |
| 224 | */ |
| 225 | bool set_name(const Glib::ustring& name); |
| 226 | |
| 227 | /** Returns a copy of the name of @a object. |
| 228 | * For a nameless object, this returns <tt>nullptr</tt>, which you can safely Glib::free() |
| 229 | * as well. |
| 230 | * |
| 231 | * Free-function: g_free |
| 232 | * |
| 233 | * @return The name of @a object. |
| 234 | * |
| 235 | * MT safe. This function grabs and releases @a object's LOCK. |
| 236 | */ |
| 237 | Glib::ustring get_name() const; |
| 238 | |
| 239 | /** Sets the parent of @a object to @a parent. The object's reference count will |
| 240 | * be incremented, and any floating reference will be removed (see ref_sink()). |
| 241 | * |
| 242 | * @param parent New parent of object. |
| 243 | * @return <tt>true</tt> if @a parent could be set or <tt>false</tt> when @a object |
| 244 | * already had a parent or @a object and @a parent are the same. |
| 245 | * |
| 246 | * MT safe. Grabs and releases @a object's LOCK. |
| 247 | */ |
| 248 | bool set_parent(const Glib::RefPtr<Gst::Object>& parent); |
| 249 | |
| 250 | /** Returns the parent of @a object. This function increases the refcount |
| 251 | * of the parent object so you should unref() it after usage. |
| 252 | * |
| 253 | * @return Parent of @a object, this can be |
| 254 | * <tt>nullptr</tt> if @a object has no parent. unref after usage. |
| 255 | * |
| 256 | * MT safe. Grabs and releases @a object's LOCK. |
| 257 | */ |
| 258 | Glib::RefPtr<Gst::Object> get_parent(); |
| 259 | |
| 260 | /** Returns the parent of @a object. This function increases the refcount |
| 261 | * of the parent object so you should unref() it after usage. |
| 262 | * |
| 263 | * @return Parent of @a object, this can be |
| 264 | * <tt>nullptr</tt> if @a object has no parent. unref after usage. |
| 265 | * |
| 266 | * MT safe. Grabs and releases @a object's LOCK. |
| 267 | */ |
| 268 | Glib::RefPtr<const Gst::Object> get_parent() const; |
| 269 | |
| 270 | /** Clear the parent of @a object, removing the associated reference. |
| 271 | * This function decreases the refcount of @a object. |
| 272 | * |
| 273 | * MT safe. Grabs and releases @a object's lock. |
| 274 | */ |
| 275 | void unparent(); |
| 276 | |
| 277 | |
| 278 | /** Change the control-rate for this @a object. Audio processing Gst::Element |
| 279 | * objects will use this rate to sub-divide their processing loop and call |
| 280 | * sync_values() inbetween. The length of the processing segment |
| 281 | * should be up to @a control-rate nanoseconds. |
| 282 | * |
| 283 | * The control-rate should not change if the element is in Gst::STATE_PAUSED or |
| 284 | * Gst::STATE_PLAYING. |
| 285 | * |
| 286 | * @param control_rate The new control-rate in nanoseconds. |
| 287 | */ |
| 288 | void set_control_rate(Gst::ClockTime control_rate); |
| 289 | |
| 290 | /** Obtain the control-rate for this @a object. Audio processing Gst::Element |
| 291 | * objects will use this rate to sub-divide their processing loop and call |
| 292 | * sync_values() inbetween. The length of the processing segment |
| 293 | * should be up to @a control-rate nanoseconds. |
| 294 | * |
| 295 | * If the @a object is not under property control, this will return |
| 296 | * Gst::CLOCK_TIME_NONE. This allows the element to avoid the sub-dividing. |
| 297 | * |
| 298 | * The control-rate is not expected to change if the element is in |
| 299 | * Gst::STATE_PAUSED or Gst::STATE_PLAYING. |
| 300 | * |
| 301 | * @return The control rate in nanoseconds. |
| 302 | */ |
| 303 | Gst::ClockTime get_control_rate() const; |
| 304 | |
| 305 | /** Returns a suggestion for timestamps where buffers should be split |
| 306 | * to get best controller results. |
| 307 | * |
| 308 | * @return Returns the suggested timestamp or Gst::CLOCK_TIME_NONE |
| 309 | * if no control-rate was set. |
| 310 | */ |
| 311 | Gst::ClockTime suggest_next_sync() const; |
| 312 | |
| 313 | /** Sets the properties of the object, according to the Gst::ControlSources that |
| 314 | * (maybe) handle them and for the given timestamp. |
| 315 | * |
| 316 | * If this function fails, it is most likely the application developers fault. |
| 317 | * Most probably the control sources are not setup correctly. |
| 318 | * |
| 319 | * @param timestamp The time that should be processed. |
| 320 | * @return <tt>true</tt> if the controller values could be applied to the object |
| 321 | * properties, <tt>false</tt> otherwise. |
| 322 | */ |
| 323 | bool sync_values(Gst::ClockTime timestamp); |
| 324 | |
| 325 | |
| 326 | /** This function is used to disable all controlled properties of the @a object for |
| 327 | * some time, i.e.\ sync_values() will do nothing. |
| 328 | * |
| 329 | * @param disabled Boolean that specifies whether to disable the controller |
| 330 | * or not. |
| 331 | */ |
| 332 | void set_control_bindings_disabled(bool disabled); |
| 333 | |
| 334 | /** Check if the @a object has an active controlled properties. |
| 335 | * |
| 336 | * @return <tt>true</tt> if the object has active controlled properties. |
| 337 | */ |
| 338 | bool has_asctive_control_bindings() const; |
| 339 | |
| 340 | // Ignore default signal and error callback. |
| 341 | |
| 342 | |
| 343 | /** Checks to see if there is any object named @a name in @a list. This function |
| 344 | * does not do any locking of any kind. You might want to protect the |
| 345 | * provided list with the lock of the owner of the list. This function |
| 346 | * will lock each Gst::Object in the list to compare the name, so be |
| 347 | * careful when passing a list with a locked object. |
| 348 | * |
| 349 | * @param list A list of Gst::Object to |
| 350 | * check through. |
| 351 | * @param name The name to search for. |
| 352 | * @return <tt>true</tt> if a Gst::Object named @a name does not appear in @a list, |
| 353 | * <tt>false</tt> if it does. |
| 354 | * |
| 355 | * MT safe. Grabs and releases the LOCK of each object in the list. |
| 356 | */ |
| 357 | static bool check_uniqueness(const Glib::ListHandle<const Gst::Object>& list, const Glib::ustring& name); |
| 358 | |
| 359 | |
| 360 | /** Check if @a object has an ancestor @a ancestor somewhere up in |
| 361 | * the hierarchy. One can e.g. check if a Gst::Element is inside a Gst::Pipeline. |
| 362 | * |
| 363 | * Deprecated: Use has_as_ancestor() instead. |
| 364 | * |
| 365 | * MT safe. Grabs and releases @a object's locks. |
| 366 | * |
| 367 | * @param ancestor A Gst::Object to check as ancestor. |
| 368 | * @return <tt>true</tt> if @a ancestor is an ancestor of @a object. |
| 369 | */ |
| 370 | bool has_ancestor(const Glib::RefPtr<const Gst::Object>& ancestor) const; |
| 371 | |
| 372 | /** Check if @a object has an ancestor @a ancestor somewhere up in |
| 373 | * the hierarchy. One can e.g. check if a Gst::Element is inside a Gst::Pipeline. |
| 374 | * |
| 375 | * @param ancestor A Gst::Object to check as ancestor. |
| 376 | * @return <tt>true</tt> if @a ancestor is an ancestor of @a object. |
| 377 | * |
| 378 | * MT safe. Grabs and releases @a object's locks. |
| 379 | */ |
| 380 | bool has_as_ancestor(const Glib::RefPtr<Gst::Object>& ancestor) const; |
| 381 | |
| 382 | /** Check if @a parent is the parent of @a object. |
| 383 | * E.g. a Gst::Element can check if it owns a given Gst::Pad. |
| 384 | * |
| 385 | * @param parent A Gst::Object to check as parent. |
| 386 | * @return <tt>false</tt> if either @a object or @a parent is <tt>nullptr</tt>. <tt>true</tt> if @a parent is |
| 387 | * the parent of @a object. Otherwise <tt>false</tt>. |
| 388 | * |
| 389 | * MT safe. Grabs and releases @a object's locks. |
| 390 | */ |
| 391 | bool has_as_parent(const Glib::RefPtr<Gst::Object>& parent) const; |
| 392 | |
| 393 | |
| 394 | /** Generates a string describing the path of @a object in |
| 395 | * the object hierarchy. Only useful (or used) for debugging. |
| 396 | * |
| 397 | * @return A string describing the path of @a object. |
| 398 | * |
| 399 | * MT safe. Grabs and releases the Gst::Object's LOCK for all objects |
| 400 | * in the hierarchy. |
| 401 | */ |
| 402 | Glib::ustring get_path_string(); |
| 403 | |
| 404 | /** The name of the object. |
| 405 | * |
| 406 | * @return A PropertyProxy that allows you to get or set the value of the property, |
| 407 | * or receive notification when the value of the property changes. |
| 408 | */ |
| 409 | Glib::PropertyProxy< Glib::ustring > property_name() ; |
| 410 | |
| 411 | /** The name of the object. |
| 412 | * |
| 413 | * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, |
| 414 | * or receive notification when the value of the property changes. |
| 415 | */ |
| 416 | Glib::PropertyProxy_ReadOnly< Glib::ustring > property_name() const; |
| 417 | |
| 418 | /** The parent of the object. |
| 419 | * |
| 420 | * @return A PropertyProxy that allows you to get or set the value of the property, |
| 421 | * or receive notification when the value of the property changes. |
| 422 | */ |
| 423 | Glib::PropertyProxy< Glib::RefPtr<Gst::Object> > property_parent() ; |
| 424 | |
| 425 | /** The parent of the object. |
| 426 | * |
| 427 | * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, |
| 428 | * or receive notification when the value of the property changes. |
| 429 | */ |
| 430 | Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gst::Object> > property_parent() const; |
| 431 | |
| 432 | |
| 433 | //TODO: Maybe GParamSpec should be wrapped in glibmm? |
| 434 | |
| 435 | /** |
| 436 | * @par Slot Prototype: |
| 437 | * <tt>void on_my_%deep_notify(const Glib::RefPtr<Gst::Object>& prop_object, GParamSpec* prop)</tt> |
| 438 | * |
| 439 | * The deep notify signal is used to be notified of property changes. It is |
| 440 | * typically attached to the toplevel bin to receive notifications from all |
| 441 | * the elements contained in that bin. |
| 442 | * |
| 443 | * @param prop_object The object that originated the signal. |
| 444 | * @param prop The property that changed. |
| 445 | */ |
| 446 | |
| 447 | Glib::SignalProxy< void,const Glib::RefPtr<Gst::Object>&,GParamSpec* > signal_deep_notify(); |
| 448 | |
| 449 | |
| 450 | int get_refcount() const; |
| 451 | |
| 452 | |
| 453 | public: |
| 454 | |
| 455 | public: |
| 456 | //C++ methods used to invoke GTK+ virtual functions: |
| 457 | |
| 458 | protected: |
| 459 | //GTK+ Virtual Functions (override these to change behaviour): |
| 460 | |
| 461 | //Default Signal Handlers:: |
| 462 | /// This is a default handler for the signal signal_deep_notify(). |
| 463 | virtual void on_deep_notify(const Glib::RefPtr<Gst::Object>& prop_object, GParamSpec* prop); |
| 464 | |
| 465 | |
| 466 | }; |
| 467 | |
| 468 | } // namespace Gst |
| 469 | |
| 470 | |
| 471 | namespace Glib |
| 472 | { |
| 473 | /** A Glib::wrap() method for this object. |
| 474 | * |
| 475 | * @param object The C instance. |
| 476 | * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
| 477 | * @result A C++ instance that wraps this C instance. |
| 478 | * |
| 479 | * @relates Gst::Object |
| 480 | */ |
| 481 | Glib::RefPtr<Gst::Object> wrap(GstObject* object, bool take_copy = false); |
| 482 | } |
| 483 | |
| 484 | |
| 485 | #endif /* _GSTREAMERMM_OBJECT_H */ |
| 486 |