gstbin.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* GStreamer
  2. * Copyright (C) 1999,2000 Erik Walthinsen <[email protected]>
  3. * 2000 Wim Taymans <[email protected]>
  4. *
  5. * gstbin.h: Header for GstBin container object
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301, USA.
  21. */
  22. #ifndef __GST_BIN_H__
  23. #define __GST_BIN_H__
  24. #include <gst/gstelement.h>
  25. #include <gst/gstiterator.h>
  26. #include <gst/gstbus.h>
  27. G_BEGIN_DECLS
  28. #define GST_TYPE_BIN (gst_bin_get_type ())
  29. #define GST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN))
  30. #define GST_IS_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BIN))
  31. #define GST_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BIN, GstBinClass))
  32. #define GST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin))
  33. #define GST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass))
  34. #define GST_BIN_CAST(obj) ((GstBin*)(obj))
  35. /**
  36. * GstBinFlags:
  37. * @GST_BIN_FLAG_NO_RESYNC: don't resync a state change when elements are
  38. * added or linked in the bin (Since 1.0.5)
  39. * @GST_BIN_FLAG_LAST: the last enum in the series of flags for bins.
  40. * Derived classes can use this as first value in a list of flags.
  41. *
  42. * GstBinFlags are a set of flags specific to bins. Most are set/used
  43. * internally. They can be checked using the GST_OBJECT_FLAG_IS_SET () macro,
  44. * and (un)set using GST_OBJECT_FLAG_SET () and GST_OBJECT_FLAG_UNSET ().
  45. */
  46. typedef enum {
  47. GST_BIN_FLAG_NO_RESYNC = (GST_ELEMENT_FLAG_LAST << 0),
  48. /* padding */
  49. GST_BIN_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 5)
  50. } GstBinFlags;
  51. /**
  52. * GST_BIN_IS_NO_RESYNC:
  53. * @bin: A #GstBin
  54. *
  55. * Check if @bin will resync its state change when elements are added and
  56. * removed.
  57. *
  58. * Since: 1.0.5
  59. */
  60. #define GST_BIN_IS_NO_RESYNC(bin) (GST_OBJECT_FLAG_IS_SET(bin,GST_BIN_FLAG_NO_RESYNC))
  61. typedef struct _GstBin GstBin;
  62. typedef struct _GstBinClass GstBinClass;
  63. typedef struct _GstBinPrivate GstBinPrivate;
  64. /**
  65. * GST_BIN_NUMCHILDREN:
  66. * @bin: a #GstBin
  67. *
  68. * Gets the number of children in a bin.
  69. */
  70. #define GST_BIN_NUMCHILDREN(bin) (GST_BIN_CAST(bin)->numchildren)
  71. /**
  72. * GST_BIN_CHILDREN:
  73. * @bin: a #GstBin
  74. *
  75. * Gets the list with children in a bin.
  76. */
  77. #define GST_BIN_CHILDREN(bin) (GST_BIN_CAST(bin)->children)
  78. /**
  79. * GST_BIN_CHILDREN_COOKIE:
  80. * @bin: a #GstBin
  81. *
  82. * Gets the children cookie that watches the children list.
  83. */
  84. #define GST_BIN_CHILDREN_COOKIE(bin) (GST_BIN_CAST(bin)->children_cookie)
  85. /**
  86. * GstBin:
  87. * @numchildren: the number of children in this bin
  88. * @children: (element-type Gst.Element): the list of children in this bin
  89. * @children_cookie: updated whenever @children changes
  90. * @child_bus: internal bus for handling child messages
  91. * @messages: (element-type Gst.Message): queued and cached messages
  92. * @polling: the bin is currently calculating its state
  93. * @state_dirty: the bin needs to recalculate its state (deprecated)
  94. * @clock_dirty: the bin needs to select a new clock
  95. * @provided_clock: the last clock selected
  96. * @clock_provider: the element that provided @provided_clock
  97. *
  98. * The GstBin base class. Subclasses can access these fields provided
  99. * the LOCK is taken.
  100. */
  101. struct _GstBin {
  102. GstElement element;
  103. /*< public >*/ /* with LOCK */
  104. /* our children, subclass are supposed to update these
  105. * fields to reflect their state with _iterate_*() */
  106. gint numchildren;
  107. GList *children;
  108. guint32 children_cookie;
  109. GstBus *child_bus;
  110. GList *messages;
  111. gboolean polling;
  112. gboolean state_dirty;
  113. gboolean clock_dirty;
  114. GstClock *provided_clock;
  115. GstElement *clock_provider;
  116. /*< private >*/
  117. GstBinPrivate *priv;
  118. gpointer _gst_reserved[GST_PADDING];
  119. };
  120. /**
  121. * GstBinClass:
  122. * @parent_class: bin parent class
  123. * @add_element: method to add an element to a bin
  124. * @remove_element: method to remove an element from a bin
  125. * @handle_message: method to handle a message from the children
  126. *
  127. * Subclasses can override the @add_element and @remove_element to
  128. * update the list of children in the bin.
  129. *
  130. * The @handle_message method can be overridden to implement custom
  131. * message handling. @handle_message takes ownership of the message, just like
  132. * #gst_element_post_message.
  133. */
  134. struct _GstBinClass {
  135. GstElementClass parent_class;
  136. /*< private >*/
  137. GThreadPool *pool;
  138. /* signals */
  139. void (*element_added) (GstBin *bin, GstElement *child);
  140. void (*element_removed) (GstBin *bin, GstElement *child);
  141. /*< public >*/
  142. /* virtual methods for subclasses */
  143. gboolean (*add_element) (GstBin *bin, GstElement *element);
  144. gboolean (*remove_element) (GstBin *bin, GstElement *element);
  145. void (*handle_message) (GstBin *bin, GstMessage *message);
  146. /*< private >*/
  147. /* signal */
  148. gboolean (*do_latency) (GstBin *bin);
  149. /*< private >*/
  150. gpointer _gst_reserved[GST_PADDING];
  151. };
  152. GType gst_bin_get_type (void);
  153. GstElement* gst_bin_new (const gchar *name);
  154. /* add and remove elements from the bin */
  155. gboolean gst_bin_add (GstBin *bin, GstElement *element);
  156. gboolean gst_bin_remove (GstBin *bin, GstElement *element);
  157. /* retrieve a single child */
  158. GstElement* gst_bin_get_by_name (GstBin *bin, const gchar *name);
  159. GstElement* gst_bin_get_by_name_recurse_up (GstBin *bin, const gchar *name);
  160. GstElement* gst_bin_get_by_interface (GstBin *bin, GType iface);
  161. /* retrieve multiple children */
  162. GstIterator* gst_bin_iterate_elements (GstBin *bin);
  163. GstIterator* gst_bin_iterate_sorted (GstBin *bin);
  164. GstIterator* gst_bin_iterate_recurse (GstBin *bin);
  165. GstIterator* gst_bin_iterate_sinks (GstBin *bin);
  166. GstIterator* gst_bin_iterate_sources (GstBin *bin);
  167. GstIterator* gst_bin_iterate_all_by_interface (GstBin *bin, GType iface);
  168. /* latency */
  169. gboolean gst_bin_recalculate_latency (GstBin * bin);
  170. G_END_DECLS
  171. #endif /* __GST_BIN_H__ */