Erik Walthinsen | ca1c48e | 2000-12-28 22:12:02 +0000 | [diff] [blame] | 1 | /* GStreamer |
| 2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 3 | * 2000,2004 Wim Taymans <wim@fluendo.com> |
Erik Walthinsen | ca1c48e | 2000-12-28 22:12:02 +0000 | [diff] [blame] | 4 | * |
| 5 | * gstelement.h: Header for GstElement |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 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 |
Tim-Philipp Müller | 666c8c1 | 2012-11-03 20:44:48 +0000 | [diff] [blame] | 19 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 20 | * Boston, MA 02110-1301, USA. |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | |
| 24 | #ifndef __GST_ELEMENT_H__ |
| 25 | #define __GST_ELEMENT_H__ |
| 26 | |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 27 | /* gstelement.h and gstelementfactory.h include eachother */ |
| 28 | typedef struct _GstElement GstElement; |
| 29 | typedef struct _GstElementClass GstElementClass; |
| 30 | |
Andy Wingo | e040bb2 | 2005-09-02 15:42:00 +0000 | [diff] [blame] | 31 | /* gstmessage.h needs State */ |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 32 | /** |
| 33 | * GstState: |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 34 | * @GST_STATE_VOID_PENDING: no pending state. |
| 35 | * @GST_STATE_NULL : the NULL state or initial state of an element. |
| 36 | * @GST_STATE_READY : the element is ready to go to PAUSED. |
| 37 | * @GST_STATE_PAUSED : the element is PAUSED, it is ready to accept and |
| 38 | * process data. Sink elements however only accept one |
| 39 | * buffer and then block. |
| 40 | * @GST_STATE_PLAYING : the element is PLAYING, the #GstClock is running and |
| 41 | * the data is flowing. |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 42 | * |
Mart Raudsepp | 719a921 | 2010-03-17 12:45:49 +0200 | [diff] [blame] | 43 | * The possible states an element can be in. States can be changed using |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 44 | * gst_element_set_state() and checked using gst_element_get_state(). |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 45 | */ |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 46 | typedef enum { |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 47 | GST_STATE_VOID_PENDING = 0, |
Andy Wingo | e040bb2 | 2005-09-02 15:42:00 +0000 | [diff] [blame] | 48 | GST_STATE_NULL = 1, |
| 49 | GST_STATE_READY = 2, |
| 50 | GST_STATE_PAUSED = 3, |
| 51 | GST_STATE_PLAYING = 4 |
| 52 | } GstState; |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 53 | |
| 54 | |
Erik Walthinsen | d574ab8 | 2001-10-17 10:21:27 +0000 | [diff] [blame] | 55 | #include <gst/gstconfig.h> |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 56 | #include <gst/gstobject.h> |
| 57 | #include <gst/gstpad.h> |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 58 | #include <gst/gstbus.h> |
Wim Taymans | 53b6bb6 | 2002-02-03 20:07:09 +0000 | [diff] [blame] | 59 | #include <gst/gstclock.h> |
Wim Taymans | e1b5b74 | 2005-05-30 15:51:40 +0000 | [diff] [blame] | 60 | #include <gst/gstelementfactory.h> |
Benjamin Otte | 907e3e9 | 2003-10-31 19:32:47 +0000 | [diff] [blame] | 61 | #include <gst/gstplugin.h> |
Wim Taymans | 12bbbd5 | 2001-08-21 20:16:48 +0000 | [diff] [blame] | 62 | #include <gst/gstpluginfeature.h> |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 63 | #include <gst/gstiterator.h> |
Wim Taymans | c2f41a8 | 2005-03-21 17:34:02 +0000 | [diff] [blame] | 64 | #include <gst/gstmessage.h> |
Wim Taymans | 44b4312 | 2011-06-07 13:25:26 +0200 | [diff] [blame] | 65 | #include <gst/gstquery.h> |
Stefan Kost | b5454f7 | 2005-09-07 13:22:16 +0000 | [diff] [blame] | 66 | #include <gst/gsttaglist.h> |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 67 | |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 68 | G_BEGIN_DECLS |
| 69 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 70 | #define GST_TYPE_ELEMENT (gst_element_get_type ()) |
| 71 | #define GST_IS_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ELEMENT)) |
| 72 | #define GST_IS_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ELEMENT)) |
| 73 | #define GST_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ELEMENT, GstElementClass)) |
| 74 | #define GST_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ELEMENT, GstElement)) |
| 75 | #define GST_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ELEMENT, GstElementClass)) |
| 76 | #define GST_ELEMENT_CAST(obj) ((GstElement*)(obj)) |
Benjamin Otte | 907e3e9 | 2003-10-31 19:32:47 +0000 | [diff] [blame] | 77 | |
Thomas Vander Stichele | 9b3e3a2 | 2005-09-11 12:57:36 +0000 | [diff] [blame] | 78 | /** |
| 79 | * GstStateChangeReturn: |
| 80 | * @GST_STATE_CHANGE_FAILURE : the state change failed |
| 81 | * @GST_STATE_CHANGE_SUCCESS : the state change succeeded |
| 82 | * @GST_STATE_CHANGE_ASYNC : the state change will happen asynchronously |
Thomas Vander Stichele | bc93f42 | 2007-06-23 11:18:46 +0000 | [diff] [blame] | 83 | * @GST_STATE_CHANGE_NO_PREROLL: the state change succeeded but the element |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 84 | * cannot produce data in %GST_STATE_PAUSED. |
| 85 | * This typically happens with live sources. |
Wim Taymans | 06bc343 | 2005-10-08 14:57:09 +0000 | [diff] [blame] | 86 | * |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 87 | * The possible return values from a state change function such as |
| 88 | * gst_element_set_state(). Only @GST_STATE_CHANGE_FAILURE is a real failure. |
Thomas Vander Stichele | 9b3e3a2 | 2005-09-11 12:57:36 +0000 | [diff] [blame] | 89 | */ |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 90 | typedef enum { |
Andy Wingo | e040bb2 | 2005-09-02 15:42:00 +0000 | [diff] [blame] | 91 | GST_STATE_CHANGE_FAILURE = 0, |
| 92 | GST_STATE_CHANGE_SUCCESS = 1, |
| 93 | GST_STATE_CHANGE_ASYNC = 2, |
| 94 | GST_STATE_CHANGE_NO_PREROLL = 3 |
| 95 | } GstStateChangeReturn; |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 96 | |
Thomas Vander Stichele | 012d4ec | 2005-06-27 08:16:51 +0000 | [diff] [blame] | 97 | /* NOTE: this probably should be done with an #ifdef to decide |
Christian Schaller | 9dca9db | 2001-12-15 18:15:13 +0000 | [diff] [blame] | 98 | * whether to safe-cast or to just do the non-checking cast. |
| 99 | */ |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * GST_STATE: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 103 | * @elem: a #GstElement to return state for. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 104 | * |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 105 | * This macro returns the current #GstState of the element. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 106 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 107 | #define GST_STATE(elem) (GST_ELEMENT_CAST(elem)->current_state) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 108 | |
| 109 | /** |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 110 | * GST_STATE_NEXT: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 111 | * @elem: a #GstElement to return the next state for. |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 112 | * |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 113 | * This macro returns the next #GstState of the element. |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 114 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 115 | #define GST_STATE_NEXT(elem) (GST_ELEMENT_CAST(elem)->next_state) |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 116 | |
| 117 | /** |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 118 | * GST_STATE_PENDING: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 119 | * @elem: a #GstElement to return the pending state for. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 120 | * |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 121 | * This macro returns the currently pending #GstState of the element. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 122 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 123 | #define GST_STATE_PENDING(elem) (GST_ELEMENT_CAST(elem)->pending_state) |
Erik Walthinsen | b6d31c1 | 2000-07-17 17:14:15 +0000 | [diff] [blame] | 124 | |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 125 | /** |
Wim Taymans | d14c4c4 | 2007-03-19 10:47:56 +0000 | [diff] [blame] | 126 | * GST_STATE_TARGET: |
| 127 | * @elem: a #GstElement to return the target state for. |
| 128 | * |
| 129 | * This macro returns the target #GstState of the element. |
Wim Taymans | d14c4c4 | 2007-03-19 10:47:56 +0000 | [diff] [blame] | 130 | */ |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 131 | #define GST_STATE_TARGET(elem) (GST_ELEMENT_CAST(elem)->target_state) |
Wim Taymans | d14c4c4 | 2007-03-19 10:47:56 +0000 | [diff] [blame] | 132 | |
| 133 | /** |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 134 | * GST_STATE_RETURN: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 135 | * @elem: a #GstElement to return the last state result for. |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 136 | * |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 137 | * This macro returns the last #GstStateChangeReturn value. |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 138 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 139 | #define GST_STATE_RETURN(elem) (GST_ELEMENT_CAST(elem)->last_return) |
Andy Wingo | e040bb2 | 2005-09-02 15:42:00 +0000 | [diff] [blame] | 140 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 141 | #define __GST_SIGN(val) ((val) < 0 ? -1 : ((val) > 0 ? 1 : 0)) |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 142 | /** |
| 143 | * GST_STATE_GET_NEXT: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 144 | * @cur: A starting #GstState |
| 145 | * @pending: A target #GstState |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 146 | * |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 147 | * Given a current state @cur and a target state @pending, calculate the next (intermediate) |
| 148 | * #GstState. |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 149 | */ |
Josep Torra | 2271b6d | 2011-08-10 11:07:49 +0200 | [diff] [blame] | 150 | #define GST_STATE_GET_NEXT(cur,pending) ((GstState)((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur)))) |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 151 | /** |
| 152 | * GST_STATE_TRANSITION: |
| 153 | * @cur: A current state |
| 154 | * @next: A next state |
| 155 | * |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 156 | * Given a current state @cur and a next state @next, calculate the associated |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 157 | * #GstStateChange transition. |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 158 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 159 | #define GST_STATE_TRANSITION(cur,next) ((GstStateChange)(((cur)<<3)|(next))) |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 160 | /** |
| 161 | * GST_STATE_TRANSITION_CURRENT: |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 162 | * @trans: A #GstStateChange |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 163 | * |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 164 | * Given a state transition @trans, extract the current #GstState. |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 165 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 166 | #define GST_STATE_TRANSITION_CURRENT(trans) ((GstState)((trans)>>3)) |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 167 | /** |
| 168 | * GST_STATE_TRANSITION_NEXT: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 169 | * @trans: A #GstStateChange |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 170 | * |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 171 | * Given a state transition @trans, extract the next #GstState. |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 172 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 173 | #define GST_STATE_TRANSITION_NEXT(trans) ((GstState)((trans)&0x7)) |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 174 | |
Thomas Vander Stichele | 9b3e3a2 | 2005-09-11 12:57:36 +0000 | [diff] [blame] | 175 | /** |
| 176 | * GstStateChange: |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 177 | * @GST_STATE_CHANGE_NULL_TO_READY : state change from NULL to READY. |
| 178 | * <itemizedlist> |
| 179 | * <listitem><para> |
| 180 | * The element must check if the resources it needs are available. Device |
| 181 | * sinks and -sources typically try to probe the device to constrain their |
| 182 | * caps. |
| 183 | * </para></listitem> |
| 184 | * <listitem><para> |
| 185 | * The element opens the device (in case feature need to be probed). |
| 186 | * </para></listitem> |
| 187 | * </itemizedlist> |
| 188 | * @GST_STATE_CHANGE_READY_TO_PAUSED : state change from READY to PAUSED. |
| 189 | * <itemizedlist> |
| 190 | * <listitem><para> |
| 191 | * The element pads are activated in order to receive data in PAUSED. |
| 192 | * Streaming threads are started. |
| 193 | * </para></listitem> |
| 194 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 195 | * Some elements might need to return %GST_STATE_CHANGE_ASYNC and complete |
| 196 | * the state change when they have enough information. It is a requirement |
| 197 | * for sinks to return %GST_STATE_CHANGE_ASYNC and complete the state change |
| 198 | * when they receive the first buffer or %GST_EVENT_EOS (preroll). |
| 199 | * Sinks also block the dataflow when in PAUSED. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 200 | * </para></listitem> |
| 201 | * <listitem><para> |
| 202 | * A pipeline resets the running_time to 0. |
| 203 | * </para></listitem> |
| 204 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 205 | * Live sources return %GST_STATE_CHANGE_NO_PREROLL and don't generate data. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 206 | * </para></listitem> |
| 207 | * </itemizedlist> |
| 208 | * @GST_STATE_CHANGE_PAUSED_TO_PLAYING: state change from PAUSED to PLAYING. |
| 209 | * <itemizedlist> |
| 210 | * <listitem><para> |
| 211 | * Most elements ignore this state change. |
| 212 | * </para></listitem> |
| 213 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 214 | * The pipeline selects a #GstClock and distributes this to all the children |
Sebastian Rasmussen | 53ae1b2 | 2013-12-07 15:38:19 +0100 | [diff] [blame] | 215 | * before setting them to PLAYING. This means that it is only allowed to |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 216 | * synchronize on the #GstClock in the PLAYING state. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 217 | * </para></listitem> |
| 218 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 219 | * The pipeline uses the #GstClock and the running_time to calculate the |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 220 | * base_time. The base_time is distributed to all children when performing |
| 221 | * the state change. |
| 222 | * </para></listitem> |
| 223 | * <listitem><para> |
| 224 | * Sink elements stop blocking on the preroll buffer or event and start |
| 225 | * rendering the data. |
| 226 | * </para></listitem> |
| 227 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 228 | * Sinks can post %GST_MESSAGE_EOS in the PLAYING state. It is not allowed |
| 229 | * to post %GST_MESSAGE_EOS when not in the PLAYING state. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 230 | * </para></listitem> |
| 231 | * <listitem><para> |
| 232 | * While streaming in PAUSED or PLAYING elements can create and remove |
| 233 | * sometimes pads. |
| 234 | * </para></listitem> |
| 235 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 236 | * Live sources start generating data and return %GST_STATE_CHANGE_SUCCESS. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 237 | * </para></listitem> |
| 238 | * </itemizedlist> |
| 239 | * @GST_STATE_CHANGE_PLAYING_TO_PAUSED: state change from PLAYING to PAUSED. |
| 240 | * <itemizedlist> |
| 241 | * <listitem><para> |
| 242 | * Most elements ignore this state change. |
| 243 | * </para></listitem> |
| 244 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 245 | * The pipeline calculates the running_time based on the last selected |
| 246 | * #GstClock and the base_time. It stores this information to continue |
| 247 | * playback when going back to the PLAYING state. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 248 | * </para></listitem> |
| 249 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 250 | * Sinks unblock any #GstClock wait calls. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 251 | * </para></listitem> |
| 252 | * <listitem><para> |
Wim Taymans | 4a7c3b9 | 2011-11-11 16:52:41 +0100 | [diff] [blame] | 253 | * When a sink does not have a pending buffer to play, it returns |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 254 | * %GST_STATE_CHANGE_ASYNC from this state change and completes the state |
| 255 | * change when it receives a new buffer or an %GST_EVENT_EOS. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 256 | * </para></listitem> |
| 257 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 258 | * Any queued %GST_MESSAGE_EOS items are removed since they will be reposted |
| 259 | * when going back to the PLAYING state. The EOS messages are queued in |
| 260 | * #GstBin containers. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 261 | * </para></listitem> |
| 262 | * <listitem><para> |
Stefan Kost | 6c2024f | 2011-05-28 10:24:37 +0300 | [diff] [blame] | 263 | * Live sources stop generating data and return %GST_STATE_CHANGE_NO_PREROLL. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 264 | * </para></listitem> |
| 265 | * </itemizedlist> |
| 266 | * @GST_STATE_CHANGE_PAUSED_TO_READY : state change from PAUSED to READY. |
| 267 | * <itemizedlist> |
| 268 | * <listitem><para> |
| 269 | * Sinks unblock any waits in the preroll. |
| 270 | * </para></listitem> |
| 271 | * <listitem><para> |
| 272 | * Elements unblock any waits on devices |
| 273 | * </para></listitem> |
| 274 | * <listitem><para> |
Wim Taymans | 7ab1d62 | 2012-02-08 15:16:46 +0100 | [diff] [blame] | 275 | * Chain or get_range functions return %GST_FLOW_FLUSHING. |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 276 | * </para></listitem> |
| 277 | * <listitem><para> |
| 278 | * The element pads are deactivated so that streaming becomes impossible and |
| 279 | * all streaming threads are stopped. |
| 280 | * </para></listitem> |
| 281 | * <listitem><para> |
| 282 | * The sink forgets all negotiated formats |
| 283 | * </para></listitem> |
| 284 | * <listitem><para> |
| 285 | * Elements remove all sometimes pads |
| 286 | * </para></listitem> |
| 287 | * </itemizedlist> |
| 288 | * @GST_STATE_CHANGE_READY_TO_NULL : state change from READY to NULL. |
| 289 | * <itemizedlist> |
| 290 | * <listitem><para> |
| 291 | * Elements close devices |
| 292 | * </para></listitem> |
| 293 | * <listitem><para> |
| 294 | * Elements reset any internal state. |
| 295 | * </para></listitem> |
| 296 | * </itemizedlist> |
Wim Taymans | e1a166a | 2005-10-21 11:36:32 +0000 | [diff] [blame] | 297 | * |
Stefan Kost | 790e5d1 | 2009-12-14 15:11:42 +0200 | [diff] [blame] | 298 | * These are the different state changes an element goes through. |
| 299 | * %GST_STATE_NULL ⇒ %GST_STATE_PLAYING is called an upwards state change |
| 300 | * and %GST_STATE_PLAYING ⇒ %GST_STATE_NULL a downwards state change. |
Thomas Vander Stichele | 9b3e3a2 | 2005-09-11 12:57:36 +0000 | [diff] [blame] | 301 | */ |
Andy Wingo | 1b38cd4 | 2005-09-02 16:44:57 +0000 | [diff] [blame] | 302 | typedef enum /*< flags=0 >*/ |
Andy Wingo | e040bb2 | 2005-09-02 15:42:00 +0000 | [diff] [blame] | 303 | { |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 304 | GST_STATE_CHANGE_NULL_TO_READY = (GST_STATE_NULL<<3) | GST_STATE_READY, |
| 305 | GST_STATE_CHANGE_READY_TO_PAUSED = (GST_STATE_READY<<3) | GST_STATE_PAUSED, |
| 306 | GST_STATE_CHANGE_PAUSED_TO_PLAYING = (GST_STATE_PAUSED<<3) | GST_STATE_PLAYING, |
| 307 | GST_STATE_CHANGE_PLAYING_TO_PAUSED = (GST_STATE_PLAYING<<3) | GST_STATE_PAUSED, |
| 308 | GST_STATE_CHANGE_PAUSED_TO_READY = (GST_STATE_PAUSED<<3) | GST_STATE_READY, |
| 309 | GST_STATE_CHANGE_READY_TO_NULL = (GST_STATE_READY<<3) | GST_STATE_NULL |
Andy Wingo | e040bb2 | 2005-09-02 15:42:00 +0000 | [diff] [blame] | 310 | } GstStateChange; |
Wim Taymans | 74598fd | 2000-12-23 03:17:52 +0000 | [diff] [blame] | 311 | |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 312 | /** |
| 313 | * GstElementFlags: |
Wim Taymans | d65773b | 2011-11-28 16:54:55 +0100 | [diff] [blame] | 314 | * @GST_ELEMENT_FLAG_LOCKED_STATE: ignore state changes from parent |
| 315 | * @GST_ELEMENT_FLAG_SINK: the element is a sink |
Edward Hervey | d3ffa82 | 2012-07-10 11:46:41 +0200 | [diff] [blame] | 316 | * @GST_ELEMENT_FLAG_SOURCE: the element is a source. |
Wim Taymans | 1754ee9 | 2011-11-28 18:12:34 +0100 | [diff] [blame] | 317 | * @GST_ELEMENT_FLAG_PROVIDE_CLOCK: the element can provide a clock |
| 318 | * @GST_ELEMENT_FLAG_REQUIRE_CLOCK: the element requires a clock |
| 319 | * @GST_ELEMENT_FLAG_INDEXABLE: the element can use an index |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 320 | * @GST_ELEMENT_FLAG_LAST: offset to define more flags |
| 321 | * |
| 322 | * The standard flags that an element may have. |
| 323 | */ |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 324 | typedef enum |
| 325 | { |
Wim Taymans | 26682f7 | 2012-06-11 15:49:10 +0200 | [diff] [blame] | 326 | GST_ELEMENT_FLAG_LOCKED_STATE = (GST_OBJECT_FLAG_LAST << 0), |
| 327 | GST_ELEMENT_FLAG_SINK = (GST_OBJECT_FLAG_LAST << 1), |
| 328 | GST_ELEMENT_FLAG_SOURCE = (GST_OBJECT_FLAG_LAST << 2), |
| 329 | GST_ELEMENT_FLAG_PROVIDE_CLOCK = (GST_OBJECT_FLAG_LAST << 3), |
| 330 | GST_ELEMENT_FLAG_REQUIRE_CLOCK = (GST_OBJECT_FLAG_LAST << 4), |
| 331 | GST_ELEMENT_FLAG_INDEXABLE = (GST_OBJECT_FLAG_LAST << 5), |
Stefan Kost | a98aef8 | 2005-10-12 14:28:39 +0000 | [diff] [blame] | 332 | /* padding */ |
Edward Hervey | 2d95de1 | 2012-03-29 15:28:44 +0200 | [diff] [blame] | 333 | GST_ELEMENT_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 10) |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 334 | } GstElementFlags; |
Erik Walthinsen | b6d31c1 | 2000-07-17 17:14:15 +0000 | [diff] [blame] | 335 | |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 336 | /** |
| 337 | * GST_ELEMENT_IS_LOCKED_STATE: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 338 | * @elem: A #GstElement to query |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 339 | * |
Michael Smith | 3d0989e | 2005-10-24 09:13:27 +0000 | [diff] [blame] | 340 | * Check if the element is in the locked state and therefore will ignore state |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 341 | * changes from its parent object. |
| 342 | */ |
Wim Taymans | d65773b | 2011-11-28 16:54:55 +0100 | [diff] [blame] | 343 | #define GST_ELEMENT_IS_LOCKED_STATE(elem) (GST_OBJECT_FLAG_IS_SET(elem,GST_ELEMENT_FLAG_LOCKED_STATE)) |
Erik Walthinsen | b6d31c1 | 2000-07-17 17:14:15 +0000 | [diff] [blame] | 344 | |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 345 | /** |
| 346 | * GST_ELEMENT_NAME: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 347 | * @elem: A #GstElement to query |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 348 | * |
Carlos Rafael Giani | f70dc95 | 2016-03-10 10:35:40 +0100 | [diff] [blame] | 349 | * Gets the name of this element. This is not thread-safe by default |
| 350 | * (i.e. you will have to make sure the object lock is taken yourself). |
| 351 | * If in doubt use gst_element_get_name() instead. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 352 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 353 | #define GST_ELEMENT_NAME(elem) (GST_OBJECT_NAME(elem)) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 354 | |
| 355 | /** |
| 356 | * GST_ELEMENT_PARENT: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 357 | * @elem: A #GstElement to query |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 358 | * |
Carlos Rafael Giani | f70dc95 | 2016-03-10 10:35:40 +0100 | [diff] [blame] | 359 | * Get the parent object of this element. This is not thread-safe by default |
| 360 | * (i.e. you will have to make sure the object lock is taken yourself). |
| 361 | * If in doubt use gst_object_get_parent() instead. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 362 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 363 | #define GST_ELEMENT_PARENT(elem) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(elem))) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 364 | |
| 365 | /** |
| 366 | * GST_ELEMENT_BUS: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 367 | * @elem: A #GstElement to query |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 368 | * |
Carlos Rafael Giani | f70dc95 | 2016-03-10 10:35:40 +0100 | [diff] [blame] | 369 | * Get the message bus of this element. This is not thread-safe by default |
| 370 | * (i.e. you will have to make sure the object lock is taken yourself). |
| 371 | * If in doubt use gst_element_get_bus() instead. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 372 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 373 | #define GST_ELEMENT_BUS(elem) (GST_ELEMENT_CAST(elem)->bus) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 374 | |
| 375 | /** |
| 376 | * GST_ELEMENT_CLOCK: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 377 | * @elem: A #GstElement to query |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 378 | * |
Carlos Rafael Giani | f70dc95 | 2016-03-10 10:35:40 +0100 | [diff] [blame] | 379 | * Get the clock of this element.This is not thread-safe by default |
| 380 | * (i.e. you will have to make sure it is safe yourself). |
| 381 | * If in doubt use gst_element_get_clock() instead. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 382 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 383 | #define GST_ELEMENT_CLOCK(elem) (GST_ELEMENT_CAST(elem)->clock) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 384 | |
| 385 | /** |
| 386 | * GST_ELEMENT_PADS: |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 387 | * @elem: A #GstElement to query |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 388 | * |
| 389 | * Get the pads of this elements. |
| 390 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 391 | #define GST_ELEMENT_PADS(elem) (GST_ELEMENT_CAST(elem)->pads) |
Erik Walthinsen | b6d31c1 | 2000-07-17 17:14:15 +0000 | [diff] [blame] | 392 | |
Stefan Kost | c448527 | 2005-01-24 17:04:08 +0000 | [diff] [blame] | 393 | /** |
Wim Taymans | 83b2c63 | 2009-05-26 11:53:05 +0200 | [diff] [blame] | 394 | * GST_ELEMENT_START_TIME: |
| 395 | * @elem: a #GstElement to return the start time for. |
| 396 | * |
| 397 | * This macro returns the start_time of the @elem. The start_time is the |
| 398 | * running_time of the pipeline when the element went to PAUSED. |
Wim Taymans | 83b2c63 | 2009-05-26 11:53:05 +0200 | [diff] [blame] | 399 | */ |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 400 | #define GST_ELEMENT_START_TIME(elem) (GST_ELEMENT_CAST(elem)->start_time) |
Wim Taymans | 83b2c63 | 2009-05-26 11:53:05 +0200 | [diff] [blame] | 401 | |
| 402 | /** |
Stefan Kost | c448527 | 2005-01-24 17:04:08 +0000 | [diff] [blame] | 403 | * GST_ELEMENT_ERROR: |
Wim Taymans | adfd199 | 2007-01-09 15:38:58 +0000 | [diff] [blame] | 404 | * @el: the element that generates the error |
Thijs Vermeir | 3a2d9fd | 2008-07-25 10:24:43 +0000 | [diff] [blame] | 405 | * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError) |
| 406 | * @code: error code defined for that domain (see #gstreamer-GstGError) |
Thomas Vander Stichele | bd728f0 | 2005-06-29 12:23:35 +0000 | [diff] [blame] | 407 | * @text: the message to display (format string and args enclosed in |
| 408 | parentheses) |
| 409 | * @debug: debugging information for the message (format string and args |
| 410 | enclosed in parentheses) |
Stefan Kost | c448527 | 2005-01-24 17:04:08 +0000 | [diff] [blame] | 411 | * |
| 412 | * Utility function that elements can use in case they encountered a fatal |
Wim Taymans | adfd199 | 2007-01-09 15:38:58 +0000 | [diff] [blame] | 413 | * data processing error. The pipeline will post an error message and the |
Stefan Kost | c448527 | 2005-01-24 17:04:08 +0000 | [diff] [blame] | 414 | * application will be requested to stop further media processing. |
| 415 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 416 | #define GST_ELEMENT_ERROR(el, domain, code, text, debug) \ |
| 417 | G_STMT_START { \ |
| 418 | gchar *__txt = _gst_element_error_printf text; \ |
| 419 | gchar *__dbg = _gst_element_error_printf debug; \ |
| 420 | if (__txt) \ |
| 421 | GST_WARNING_OBJECT (el, "error: %s", __txt); \ |
| 422 | if (__dbg) \ |
| 423 | GST_WARNING_OBJECT (el, "error: %s", __dbg); \ |
| 424 | gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR, \ |
| 425 | GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \ |
| 426 | __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); \ |
Benjamin Otte | 140c4dd | 2004-01-30 03:54:08 +0000 | [diff] [blame] | 427 | } G_STMT_END |
Thomas Vander Stichele | 4efc300 | 2004-01-18 21:36:20 +0000 | [diff] [blame] | 428 | |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 429 | /** |
| 430 | * GST_ELEMENT_WARNING: |
Wim Taymans | adfd199 | 2007-01-09 15:38:58 +0000 | [diff] [blame] | 431 | * @el: the element that generates the warning |
Thomas Vander Stichele | be87507 | 2007-02-21 15:34:14 +0000 | [diff] [blame] | 432 | * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError) |
| 433 | * @code: error code defined for that domain (see #gstreamer-GstGError) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 434 | * @text: the message to display (format string and args enclosed in |
| 435 | parentheses) |
| 436 | * @debug: debugging information for the message (format string and args |
| 437 | enclosed in parentheses) |
| 438 | * |
| 439 | * Utility function that elements can use in case they encountered a non-fatal |
Wim Taymans | adfd199 | 2007-01-09 15:38:58 +0000 | [diff] [blame] | 440 | * data processing problem. The pipeline will post a warning message and the |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 441 | * application will be informed. |
| 442 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 443 | #define GST_ELEMENT_WARNING(el, domain, code, text, debug) \ |
| 444 | G_STMT_START { \ |
| 445 | gchar *__txt = _gst_element_error_printf text; \ |
| 446 | gchar *__dbg = _gst_element_error_printf debug; \ |
| 447 | if (__txt) \ |
| 448 | GST_WARNING_OBJECT (el, "warning: %s", __txt); \ |
| 449 | if (__dbg) \ |
| 450 | GST_WARNING_OBJECT (el, "warning: %s", __dbg); \ |
| 451 | gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING, \ |
| 452 | GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \ |
| 453 | __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); \ |
Wim Taymans | c2f41a8 | 2005-03-21 17:34:02 +0000 | [diff] [blame] | 454 | } G_STMT_END |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 455 | |
Thomas Vander Stichele | be87507 | 2007-02-21 15:34:14 +0000 | [diff] [blame] | 456 | /** |
| 457 | * GST_ELEMENT_INFO: |
| 458 | * @el: the element that generates the information |
| 459 | * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError) |
| 460 | * @code: error code defined for that domain (see #gstreamer-GstGError) |
| 461 | * @text: the message to display (format string and args enclosed in |
| 462 | parentheses) |
| 463 | * @debug: debugging information for the message (format string and args |
| 464 | enclosed in parentheses) |
| 465 | * |
| 466 | * Utility function that elements can use in case they want to inform |
| 467 | * the application of something noteworthy that is not an error. |
Thiago Santos | 2f0dab0 | 2011-03-22 16:26:56 -0300 | [diff] [blame] | 468 | * The pipeline will post a info message and the |
Thomas Vander Stichele | be87507 | 2007-02-21 15:34:14 +0000 | [diff] [blame] | 469 | * application will be informed. |
| 470 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 471 | #define GST_ELEMENT_INFO(el, domain, code, text, debug) \ |
| 472 | G_STMT_START { \ |
| 473 | gchar *__txt = _gst_element_error_printf text; \ |
| 474 | gchar *__dbg = _gst_element_error_printf debug; \ |
| 475 | if (__txt) \ |
| 476 | GST_INFO_OBJECT (el, "info: %s", __txt); \ |
| 477 | if (__dbg) \ |
| 478 | GST_INFO_OBJECT (el, "info: %s", __dbg); \ |
| 479 | gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_INFO, \ |
| 480 | GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \ |
| 481 | __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); \ |
Thomas Vander Stichele | be87507 | 2007-02-21 15:34:14 +0000 | [diff] [blame] | 482 | } G_STMT_END |
| 483 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 484 | /* the state change mutexes and conds */ |
Thomas Vander Stichele | 6eb5fb3 | 2005-10-05 22:35:14 +0000 | [diff] [blame] | 485 | /** |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 486 | * GST_STATE_GET_LOCK: |
| 487 | * @elem: a #GstElement |
Thomas Vander Stichele | 6eb5fb3 | 2005-10-05 22:35:14 +0000 | [diff] [blame] | 488 | * |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 489 | * Get a reference to the state lock of @elem. |
| 490 | * This lock is used by the core. It is taken while getting or setting |
Thomas Vander Stichele | 6eb5fb3 | 2005-10-05 22:35:14 +0000 | [diff] [blame] | 491 | * the state, during state changes, and while finalizing. |
| 492 | */ |
Wim Taymans | 9555a7f | 2011-06-02 14:09:46 +0200 | [diff] [blame] | 493 | #define GST_STATE_GET_LOCK(elem) (&(GST_ELEMENT_CAST(elem)->state_lock)) |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 494 | /** |
| 495 | * GST_STATE_GET_COND: |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 496 | * @elem: a #GstElement |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 497 | * |
| 498 | * Get the conditional used to signal the completion of a state change. |
| 499 | */ |
Wim Taymans | 252327f | 2012-01-19 09:27:04 +0100 | [diff] [blame] | 500 | #define GST_STATE_GET_COND(elem) (&GST_ELEMENT_CAST(elem)->state_cond) |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 501 | |
Wim Taymans | 252327f | 2012-01-19 09:27:04 +0100 | [diff] [blame] | 502 | #define GST_STATE_LOCK(elem) g_rec_mutex_lock(GST_STATE_GET_LOCK(elem)) |
| 503 | #define GST_STATE_TRYLOCK(elem) g_rec_mutex_trylock(GST_STATE_GET_LOCK(elem)) |
| 504 | #define GST_STATE_UNLOCK(elem) g_rec_mutex_unlock(GST_STATE_GET_LOCK(elem)) |
Wim Taymans | 1cef8c5 | 2005-10-18 17:06:29 +0000 | [diff] [blame] | 505 | #define GST_STATE_WAIT(elem) g_cond_wait (GST_STATE_GET_COND (elem), \ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 506 | GST_OBJECT_GET_LOCK (elem)) |
Wim Taymans | 252327f | 2012-01-19 09:27:04 +0100 | [diff] [blame] | 507 | #define GST_STATE_WAIT_UNTIL(elem, end_time) g_cond_wait_until (GST_STATE_GET_COND (elem), \ |
| 508 | GST_OBJECT_GET_LOCK (elem), end_time) |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 509 | #define GST_STATE_SIGNAL(elem) g_cond_signal (GST_STATE_GET_COND (elem)); |
| 510 | #define GST_STATE_BROADCAST(elem) g_cond_broadcast (GST_STATE_GET_COND (elem)); |
| 511 | |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 512 | /** |
| 513 | * GstElement: |
| 514 | * @state_lock: Used to serialize execution of gst_element_set_state() |
| 515 | * @state_cond: Used to signal completion of a state change |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 516 | * @state_cookie: Used to detect concurrent execution of |
| 517 | * gst_element_set_state() and gst_element_get_state() |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 518 | * @target_state: the target state of an element as set by the application |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 519 | * @current_state: the current state of an element |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 520 | * @next_state: the next state of an element, can be #GST_STATE_VOID_PENDING if |
| 521 | * the element is in the correct state. |
| 522 | * @pending_state: the final state the element should go to, can be |
| 523 | * #GST_STATE_VOID_PENDING if the element is in the correct state |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 524 | * @last_return: the last return value of an element state change |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 525 | * @bus: the bus of the element. This bus is provided to the element by the |
| 526 | * parent element or the application. A #GstPipeline has a bus of its own. |
David Schleef | e810dc0 | 2009-09-09 16:29:10 -0700 | [diff] [blame] | 527 | * @clock: the clock of the element. This clock is usually provided to the |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 528 | * element by the toplevel #GstPipeline. |
| 529 | * @base_time: the time of the clock right before the element is set to |
| 530 | * PLAYING. Subtracting @base_time from the current clock time in the PLAYING |
Wim Taymans | f7c5767 | 2009-05-21 17:32:00 +0200 | [diff] [blame] | 531 | * state will yield the running_time against the clock. |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 532 | * @start_time: the running_time of the last PAUSED state |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 533 | * @numpads: number of pads of the element, includes both source and sink pads. |
Evan Nemerson | d13ce8b | 2012-06-12 11:42:30 -0700 | [diff] [blame] | 534 | * @pads: (element-type Gst.Pad): list of pads |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 535 | * @numsrcpads: number of source pads of the element. |
Evan Nemerson | d13ce8b | 2012-06-12 11:42:30 -0700 | [diff] [blame] | 536 | * @srcpads: (element-type Gst.Pad): list of source pads |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 537 | * @numsinkpads: number of sink pads of the element. |
Evan Nemerson | d13ce8b | 2012-06-12 11:42:30 -0700 | [diff] [blame] | 538 | * @sinkpads: (element-type Gst.Pad): list of sink pads |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 539 | * @pads_cookie: updated whenever the a pad is added or removed |
| 540 | * |
| 541 | * GStreamer element abstract base class. |
| 542 | */ |
Wim Taymans | 6cacf76 | 2005-03-09 16:10:59 +0000 | [diff] [blame] | 543 | struct _GstElement |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 544 | { |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 545 | GstObject object; |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 546 | |
Wim Taymans | 1cef8c5 | 2005-10-18 17:06:29 +0000 | [diff] [blame] | 547 | /*< public >*/ /* with LOCK */ |
Wim Taymans | 252327f | 2012-01-19 09:27:04 +0100 | [diff] [blame] | 548 | GRecMutex state_lock; |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 549 | |
| 550 | /* element state */ |
Wim Taymans | 252327f | 2012-01-19 09:27:04 +0100 | [diff] [blame] | 551 | GCond state_cond; |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 552 | guint32 state_cookie; |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 553 | GstState target_state; |
Wim Taymans | 2153c45 | 2005-10-10 16:38:26 +0000 | [diff] [blame] | 554 | GstState current_state; |
| 555 | GstState next_state; |
| 556 | GstState pending_state; |
| 557 | GstStateChangeReturn last_return; |
| 558 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 559 | GstBus *bus; |
Wim Taymans | 68b53ac | 2002-12-19 21:31:03 +0000 | [diff] [blame] | 560 | |
| 561 | /* allocated clock */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 562 | GstClock *clock; |
| 563 | GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */ |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 564 | GstClockTime start_time; |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 565 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 566 | /* element pads, these lists can only be iterated while holding |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 567 | * the LOCK or checking the cookie after each LOCK. */ |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 568 | guint16 numpads; |
| 569 | GList *pads; |
| 570 | guint16 numsrcpads; |
| 571 | GList *srcpads; |
| 572 | guint16 numsinkpads; |
| 573 | GList *sinkpads; |
| 574 | guint32 pads_cookie; |
Wim Taymans | 56d3cdf | 2001-12-18 19:03:07 +0000 | [diff] [blame] | 575 | |
Matthew Waters | d5ded15 | 2015-09-24 00:04:48 +1000 | [diff] [blame] | 576 | /* with object LOCK */ |
| 577 | GList *contexts; |
| 578 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 579 | /*< private >*/ |
Matthew Waters | d5ded15 | 2015-09-24 00:04:48 +1000 | [diff] [blame] | 580 | gpointer _gst_reserved[GST_PADDING-1]; |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 581 | }; |
| 582 | |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 583 | /** |
| 584 | * GstElementClass: |
| 585 | * @parent_class: the parent class structure |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 586 | * @metadata: metadata for elements of this class |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 587 | * @elementfactory: the #GstElementFactory that creates these elements |
| 588 | * @padtemplates: a #GList of #GstPadTemplate |
Thomas Vander Stichele | e8c5250 | 2006-06-06 09:47:40 +0000 | [diff] [blame] | 589 | * @numpadtemplates: the number of padtemplates |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 590 | * @pad_templ_cookie: changed whenever the padtemplates change |
| 591 | * @request_new_pad: called when a new pad is requested |
| 592 | * @release_pad: called when a request pad is to be released |
| 593 | * @get_state: get the state of the element |
| 594 | * @set_state: set a new state on the element |
| 595 | * @change_state: called by @set_state to perform an incremental state change |
| 596 | * @set_bus: set a #GstBus on the element |
| 597 | * @provide_clock: gets the #GstClock provided by the element |
| 598 | * @set_clock: set the #GstClock on the element |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 599 | * @send_event: send a #GstEvent to the element |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 600 | * @query: perform a #GstQuery on the element |
Wim Taymans | 9c0d8ca | 2011-11-08 12:54:15 +0100 | [diff] [blame] | 601 | * @state_changed: called immediately after a new state was set. |
Sebastian Dröge | 1c4fe1b | 2012-10-16 12:31:50 +0200 | [diff] [blame] | 602 | * @post_message: called when a message is posted on the element. Chain up to |
| 603 | * the parent class' handler to have it posted on the bus. |
Sebastian Dröge | b909061 | 2013-03-28 15:35:13 +0100 | [diff] [blame] | 604 | * @set_context: set a #GstContext on the element |
Wim Taymans | a56bdf2 | 2005-11-10 11:17:26 +0000 | [diff] [blame] | 605 | * |
| 606 | * GStreamer element class. Override the vmethods to implement the element |
| 607 | * functionality. |
| 608 | */ |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 609 | struct _GstElementClass |
| 610 | { |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 611 | GstObjectClass parent_class; |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 612 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 613 | /*< public >*/ |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 614 | /* the element metadata */ |
| 615 | gpointer metadata; |
Ronald S. Bultje | 9abb3e0 | 2003-11-02 16:46:12 +0000 | [diff] [blame] | 616 | |
| 617 | /* factory that the element was created from */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 618 | GstElementFactory *elementfactory; |
Ronald S. Bultje | 9abb3e0 | 2003-11-02 16:46:12 +0000 | [diff] [blame] | 619 | |
Andy Wingo | eaaaabf | 2001-07-11 12:33:17 +0000 | [diff] [blame] | 620 | /* templates for our pads */ |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 621 | GList *padtemplates; |
| 622 | gint numpadtemplates; |
| 623 | guint32 pad_templ_cookie; |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 624 | |
Thomas Vander Stichele | 012d4ec | 2005-06-27 08:16:51 +0000 | [diff] [blame] | 625 | /*< private >*/ |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 626 | /* signal callbacks */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 627 | void (*pad_added) (GstElement *element, GstPad *pad); |
| 628 | void (*pad_removed) (GstElement *element, GstPad *pad); |
| 629 | void (*no_more_pads) (GstElement *element); |
Erik Walthinsen | 4a58368 | 2001-05-25 21:00:07 +0000 | [diff] [blame] | 630 | |
Thomas Vander Stichele | 012d4ec | 2005-06-27 08:16:51 +0000 | [diff] [blame] | 631 | /*< public >*/ |
| 632 | /* virtual methods for subclasses */ |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 633 | |
| 634 | /* request/release pads */ |
Thibault Saunier | 04d8b01 | 2015-04-02 09:44:33 +0200 | [diff] [blame] | 635 | /* FIXME 2.0 harmonize naming with gst_element_request_pad */ |
Wim Taymans | 84a1f4b | 2011-05-10 16:41:36 +0200 | [diff] [blame] | 636 | GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ, |
| 637 | const gchar* name, const GstCaps *caps); |
Thibault Saunier | 04d8b01 | 2015-04-02 09:44:33 +0200 | [diff] [blame] | 638 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 639 | void (*release_pad) (GstElement *element, GstPad *pad); |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 640 | |
| 641 | /* state changes */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 642 | GstStateChangeReturn (*get_state) (GstElement * element, GstState * state, |
| 643 | GstState * pending, GstClockTime timeout); |
| 644 | GstStateChangeReturn (*set_state) (GstElement *element, GstState state); |
| 645 | GstStateChangeReturn (*change_state) (GstElement *element, GstStateChange transition); |
Sebastian Dröge | b935a81 | 2011-05-16 16:53:04 +0200 | [diff] [blame] | 646 | void (*state_changed) (GstElement *element, GstState oldstate, |
| 647 | GstState newstate, GstState pending); |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 648 | |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 649 | /* bus */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 650 | void (*set_bus) (GstElement * element, GstBus * bus); |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 651 | |
| 652 | /* set/get clocks */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 653 | GstClock* (*provide_clock) (GstElement *element); |
| 654 | gboolean (*set_clock) (GstElement *element, GstClock *clock); |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 655 | |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 656 | /* query functions */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 657 | gboolean (*send_event) (GstElement *element, GstEvent *event); |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 658 | |
Sebastian Dröge | 3d2127f | 2011-05-17 11:20:05 +0200 | [diff] [blame] | 659 | gboolean (*query) (GstElement *element, GstQuery *query); |
Wim Taymans | 6cacf76 | 2005-03-09 16:10:59 +0000 | [diff] [blame] | 660 | |
Sebastian Dröge | 1c4fe1b | 2012-10-16 12:31:50 +0200 | [diff] [blame] | 661 | gboolean (*post_message) (GstElement *element, GstMessage *message); |
| 662 | |
Sebastian Dröge | b909061 | 2013-03-28 15:35:13 +0100 | [diff] [blame] | 663 | void (*set_context) (GstElement *element, GstContext *context); |
| 664 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 665 | /*< private >*/ |
Sebastian Dröge | b909061 | 2013-03-28 15:35:13 +0100 | [diff] [blame] | 666 | gpointer _gst_reserved[GST_PADDING_LARGE-2]; |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 667 | }; |
| 668 | |
Wim Taymans | b338085 | 2005-03-08 14:38:06 +0000 | [diff] [blame] | 669 | /* element class pad templates */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 670 | void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ); |
Tim-Philipp Müller | fa12d23 | 2016-02-27 15:28:49 +0000 | [diff] [blame] | 671 | |
| 672 | void gst_element_class_add_static_pad_template (GstElementClass *klass, GstStaticPadTemplate *static_templ); |
| 673 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 674 | GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name); |
| 675 | GList* gst_element_class_get_pad_template_list (GstElementClass *element_class); |
Stefan Kost | 65356fb | 2010-08-10 14:05:22 +0300 | [diff] [blame] | 676 | |
| 677 | /* element class meta data */ |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 678 | void gst_element_class_set_metadata (GstElementClass *klass, |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 679 | const gchar *longname, |
| 680 | const gchar *classification, |
| 681 | const gchar *description, |
| 682 | const gchar *author); |
Tim-Philipp Müller | bca1ae8 | 2012-04-09 12:47:58 +0100 | [diff] [blame] | 683 | void gst_element_class_set_static_metadata (GstElementClass *klass, |
| 684 | const gchar *longname, |
| 685 | const gchar *classification, |
| 686 | const gchar *description, |
| 687 | const gchar *author); |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 688 | void gst_element_class_add_metadata (GstElementClass * klass, |
| 689 | const gchar * key, const gchar * value); |
Tim-Philipp Müller | bca1ae8 | 2012-04-09 12:47:58 +0100 | [diff] [blame] | 690 | void gst_element_class_add_static_metadata (GstElementClass * klass, |
| 691 | const gchar * key, const gchar * value); |
Wim Taymans | 4a7c3b9 | 2011-11-11 16:52:41 +0100 | [diff] [blame] | 692 | const gchar * gst_element_class_get_metadata (GstElementClass * klass, |
Wim Taymans | e8080ab | 2011-05-20 12:43:24 +0200 | [diff] [blame] | 693 | const gchar * key); |
Wim Taymans | 920ef12 | 2010-12-07 15:33:04 +0100 | [diff] [blame] | 694 | |
Andy Wingo | d2ed090 | 2002-05-26 03:23:25 +0000 | [diff] [blame] | 695 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 696 | /* element instance */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 697 | GType gst_element_get_type (void); |
Wim Taymans | 6637a94 | 2002-11-02 13:19:30 +0000 | [diff] [blame] | 698 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 699 | /* basic name and parentage stuff from GstObject */ |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 700 | |
| 701 | /** |
| 702 | * gst_element_get_name: |
Benjamin Gaignard | 5d44b1a | 2010-06-15 18:48:53 +0200 | [diff] [blame] | 703 | * @elem: a #GstElement to get the name of @elem. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 704 | * |
Benjamin Gaignard | 5d44b1a | 2010-06-15 18:48:53 +0200 | [diff] [blame] | 705 | * Returns a copy of the name of @elem. |
| 706 | * Caller should g_free() the return value after usage. |
Evan Nemerson | e10266e | 2014-05-29 14:54:34 -0700 | [diff] [blame] | 707 | * For a nameless element, this returns %NULL, which you can safely g_free() |
Benjamin Gaignard | 5d44b1a | 2010-06-15 18:48:53 +0200 | [diff] [blame] | 708 | * as well. |
| 709 | * |
Evan Nemerson | 2759882 | 2014-06-11 15:21:34 -0700 | [diff] [blame] | 710 | * Returns: (transfer full) (nullable): the name of @elem. g_free() |
| 711 | * after usage. MT safe. |
Benjamin Gaignard | 5d44b1a | 2010-06-15 18:48:53 +0200 | [diff] [blame] | 712 | * |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 713 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 714 | #define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT_CAST(elem)) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 715 | |
| 716 | /** |
| 717 | * gst_element_set_name: |
| 718 | * @elem: a #GstElement to set the name of. |
Stefan Kost | 6de84a3 | 2005-09-27 20:40:35 +0000 | [diff] [blame] | 719 | * @name: the new name |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 720 | * |
| 721 | * Sets the name of the element, getting rid of the old name if there was one. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 722 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 723 | #define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT_CAST(elem),name) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 724 | |
| 725 | /** |
| 726 | * gst_element_get_parent: |
| 727 | * @elem: a #GstElement to get the parent of. |
| 728 | * |
Stefan Kost | c45ff2b | 2011-05-02 16:20:24 +0300 | [diff] [blame] | 729 | * Get the parent of an element. |
| 730 | * |
Tim-Philipp Müller | 3256c70 | 2010-12-07 18:35:04 +0000 | [diff] [blame] | 731 | * Returns: (transfer full): the parent of an element. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 732 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 733 | #define gst_element_get_parent(elem) gst_object_get_parent(GST_OBJECT_CAST(elem)) |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 734 | |
| 735 | /** |
| 736 | * gst_element_set_parent: |
| 737 | * @elem: a #GstElement to set the parent of. |
Thomas Vander Stichele | f74399e | 2005-09-23 16:35:43 +0000 | [diff] [blame] | 738 | * @parent: the new parent #GstObject of the element. |
Stefan Kost | 5afb6e6 | 2005-09-23 14:31:21 +0000 | [diff] [blame] | 739 | * |
| 740 | * Sets the parent of an element. |
| 741 | */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 742 | #define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT_CAST(elem),parent) |
Thomas Vander Stichele | 45a3425 | 2002-12-07 22:18:17 +0000 | [diff] [blame] | 743 | |
Wim Taymans | a48bce0 | 2002-11-27 20:47:39 +0000 | [diff] [blame] | 744 | /* clocking */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 745 | GstClock* gst_element_provide_clock (GstElement *element); |
| 746 | GstClock* gst_element_get_clock (GstElement *element); |
| 747 | gboolean gst_element_set_clock (GstElement *element, GstClock *clock); |
| 748 | void gst_element_set_base_time (GstElement *element, GstClockTime time); |
| 749 | GstClockTime gst_element_get_base_time (GstElement *element); |
| 750 | void gst_element_set_start_time (GstElement *element, GstClockTime time); |
| 751 | GstClockTime gst_element_get_start_time (GstElement *element); |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 752 | |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 753 | /* bus */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 754 | void gst_element_set_bus (GstElement * element, GstBus * bus); |
| 755 | GstBus * gst_element_get_bus (GstElement * element); |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 756 | |
Sebastian Dröge | b909061 | 2013-03-28 15:35:13 +0100 | [diff] [blame] | 757 | /* context */ |
| 758 | void gst_element_set_context (GstElement * element, GstContext * context); |
Matthew Waters | d5ded15 | 2015-09-24 00:04:48 +1000 | [diff] [blame] | 759 | GList * gst_element_get_contexts (GstElement * element); |
| 760 | GstContext * gst_element_get_context (GstElement * element, const gchar * context_type); |
| 761 | GstContext * gst_element_get_context_unlocked (GstElement * element, const gchar * context_type); |
Sebastian Dröge | b909061 | 2013-03-28 15:35:13 +0100 | [diff] [blame] | 762 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 763 | /* pad management */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 764 | gboolean gst_element_add_pad (GstElement *element, GstPad *pad); |
| 765 | gboolean gst_element_remove_pad (GstElement *element, GstPad *pad); |
| 766 | void gst_element_no_more_pads (GstElement *element); |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 767 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 768 | GstPad* gst_element_get_static_pad (GstElement *element, const gchar *name); |
| 769 | GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name); |
Wim Taymans | 84a1f4b | 2011-05-10 16:41:36 +0200 | [diff] [blame] | 770 | GstPad* gst_element_request_pad (GstElement *element, GstPadTemplate *templ, |
Edward Hervey | 04ebbc9 | 2010-12-20 13:30:43 +0100 | [diff] [blame] | 771 | const gchar * name, const GstCaps *caps); |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 772 | void gst_element_release_request_pad (GstElement *element, GstPad *pad); |
Andy Wingo | 70cfc6c | 2002-04-07 23:32:16 +0000 | [diff] [blame] | 773 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 774 | GstIterator * gst_element_iterate_pads (GstElement * element); |
| 775 | GstIterator * gst_element_iterate_src_pads (GstElement * element); |
| 776 | GstIterator * gst_element_iterate_sink_pads (GstElement * element); |
Erik Walthinsen | 1762dfb | 2000-01-30 09:03:00 +0000 | [diff] [blame] | 777 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 778 | /* event/query/format stuff */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 779 | gboolean gst_element_send_event (GstElement *element, GstEvent *event); |
| 780 | gboolean gst_element_seek (GstElement *element, gdouble rate, |
| 781 | GstFormat format, GstSeekFlags flags, |
Wim Taymans | f05b0e2 | 2012-07-27 15:19:57 +0200 | [diff] [blame] | 782 | GstSeekType start_type, gint64 start, |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 783 | GstSeekType stop_type, gint64 stop); |
Sebastian Dröge | 3d2127f | 2011-05-17 11:20:05 +0200 | [diff] [blame] | 784 | gboolean gst_element_query (GstElement *element, GstQuery *query); |
Wim Taymans | a599a5b | 2002-05-30 19:03:30 +0000 | [diff] [blame] | 785 | |
Wim Taymans | c2f41a8 | 2005-03-21 17:34:02 +0000 | [diff] [blame] | 786 | /* messages */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 787 | gboolean gst_element_post_message (GstElement * element, GstMessage * message); |
Wim Taymans | c2f41a8 | 2005-03-21 17:34:02 +0000 | [diff] [blame] | 788 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 789 | /* error handling */ |
Tim-Philipp Müller | 0ca5590 | 2006-10-08 13:27:17 +0000 | [diff] [blame] | 790 | /* gcc versions < 3.3 warn about NULL being passed as format to printf */ |
Tim-Philipp Müller | 7b19944 | 2013-03-30 17:20:13 +0000 | [diff] [blame] | 791 | #if (!defined(__GNUC__) || (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)) |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 792 | gchar * _gst_element_error_printf (const gchar *format, ...); |
Tim-Philipp Müller | 376f6c3 | 2006-10-05 12:31:07 +0000 | [diff] [blame] | 793 | #else |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 794 | gchar * _gst_element_error_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2); |
Tim-Philipp Müller | 376f6c3 | 2006-10-05 12:31:07 +0000 | [diff] [blame] | 795 | #endif |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 796 | void gst_element_message_full (GstElement * element, GstMessageType type, |
| 797 | GQuark domain, gint code, gchar * text, |
| 798 | gchar * debug, const gchar * file, |
| 799 | const gchar * function, gint line); |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 800 | |
| 801 | /* state management */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 802 | gboolean gst_element_is_locked_state (GstElement *element); |
| 803 | gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state); |
| 804 | gboolean gst_element_sync_state_with_parent (GstElement *element); |
Benjamin Otte | a03e803 | 2003-04-08 21:14:23 +0000 | [diff] [blame] | 805 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 806 | GstStateChangeReturn gst_element_get_state (GstElement * element, |
| 807 | GstState * state, |
| 808 | GstState * pending, |
| 809 | GstClockTime timeout); |
| 810 | GstStateChangeReturn gst_element_set_state (GstElement *element, GstState state); |
wrobell | 08eaa11 | 2001-12-04 22:12:50 +0000 | [diff] [blame] | 811 | |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 812 | void gst_element_abort_state (GstElement * element); |
Wim Taymans | d14c4c4 | 2007-03-19 10:47:56 +0000 | [diff] [blame] | 813 | GstStateChangeReturn gst_element_change_state (GstElement * element, |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 814 | GstStateChange transition); |
| 815 | GstStateChangeReturn gst_element_continue_state (GstElement * element, |
Andy Wingo | 5748aa1 | 2005-11-19 17:50:52 +0000 | [diff] [blame] | 816 | GstStateChangeReturn ret); |
Wim Taymans | 3cb8b33 | 2011-06-08 13:40:32 +0200 | [diff] [blame] | 817 | void gst_element_lost_state (GstElement * element); |
Wim Taymans | 6cacf76 | 2005-03-09 16:10:59 +0000 | [diff] [blame] | 818 | |
Sebastian Dröge | 8177173 | 2016-02-28 12:06:40 +0200 | [diff] [blame] | 819 | typedef void (*GstElementCallAsyncFunc) (GstElement * element, |
| 820 | gpointer user_data); |
| 821 | |
| 822 | void gst_element_call_async (GstElement * element, |
| 823 | GstElementCallAsyncFunc func, gpointer user_data, |
| 824 | GDestroyNotify destroy_notify); |
| 825 | |
Wim Taymans | 9e24b85 | 2005-03-08 17:42:29 +0000 | [diff] [blame] | 826 | /* factory management */ |
Wim Taymans | a9095a2 | 2009-08-28 18:14:23 +0200 | [diff] [blame] | 827 | GstElementFactory* gst_element_get_factory (GstElement *element); |
Ronald S. Bultje | 9abb3e0 | 2003-11-02 16:46:12 +0000 | [diff] [blame] | 828 | |
Tim-Philipp Müller | 6e3fb7a | 2016-03-05 14:12:36 +0000 | [diff] [blame] | 829 | /* utility functions */ |
| 830 | gulong gst_element_add_property_notify_watch (GstElement * element, |
| 831 | const gchar * property_name, |
| 832 | gboolean include_value); |
| 833 | |
| 834 | gulong gst_element_add_property_deep_notify_watch (GstElement * element, |
| 835 | const gchar * property_name, |
| 836 | gboolean include_value); |
| 837 | |
| 838 | void gst_element_remove_property_notify_watch (GstElement * element, |
| 839 | gulong watch_id); |
| 840 | |
Xavier Claessens | 46f83f5 | 2015-11-10 12:38:59 -0500 | [diff] [blame] | 841 | #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC |
| 842 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstElement, gst_object_unref) |
| 843 | #endif |
| 844 | |
Andy Wingo | d2ed090 | 2002-05-26 03:23:25 +0000 | [diff] [blame] | 845 | G_END_DECLS |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 846 | |
Wim Taymans | 59211a4 | 2001-01-23 20:03:07 +0000 | [diff] [blame] | 847 | #endif /* __GST_ELEMENT_H__ */ |