blob: a18b0caa4b148f1eb1e82a309da76510ee8a7361 [file] [log] [blame]
Erik Walthinsenca1c48e2000-12-28 22:12:02 +00001/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
Wim Taymans9e24b852005-03-08 17:42:29 +00003 * 2000,2004 Wim Taymans <wim@fluendo.com>
Erik Walthinsenca1c48e2000-12-28 22:12:02 +00004 *
5 * gstelement.h: Header for GstElement
Erik Walthinsen1762dfb2000-01-30 09:03:00 +00006 *
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üller666c8c12012-11-03 20:44:48 +000019 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
Erik Walthinsen1762dfb2000-01-30 09:03:00 +000021 */
22
23
24#ifndef __GST_ELEMENT_H__
25#define __GST_ELEMENT_H__
26
Wim Taymanse1aeec62005-07-18 12:49:53 +000027/* gstelement.h and gstelementfactory.h include eachother */
28typedef struct _GstElement GstElement;
29typedef struct _GstElementClass GstElementClass;
30
Andy Wingoe040bb22005-09-02 15:42:00 +000031/* gstmessage.h needs State */
Wim Taymanse1a166a2005-10-21 11:36:32 +000032/**
33 * GstState:
Stefan Kost790e5d12009-12-14 15:11:42 +020034 * @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 Taymanse1a166a2005-10-21 11:36:32 +000042 *
Mart Raudsepp719a9212010-03-17 12:45:49 +020043 * The possible states an element can be in. States can be changed using
Stefan Kost790e5d12009-12-14 15:11:42 +020044 * gst_element_set_state() and checked using gst_element_get_state().
Wim Taymanse1a166a2005-10-21 11:36:32 +000045 */
Wim Taymanse1aeec62005-07-18 12:49:53 +000046typedef enum {
Wim Taymansa56bdf22005-11-10 11:17:26 +000047 GST_STATE_VOID_PENDING = 0,
Andy Wingoe040bb22005-09-02 15:42:00 +000048 GST_STATE_NULL = 1,
49 GST_STATE_READY = 2,
50 GST_STATE_PAUSED = 3,
51 GST_STATE_PLAYING = 4
52} GstState;
Wim Taymanse1aeec62005-07-18 12:49:53 +000053
54
Erik Walthinsend574ab82001-10-17 10:21:27 +000055#include <gst/gstconfig.h>
Erik Walthinsen1762dfb2000-01-30 09:03:00 +000056#include <gst/gstobject.h>
57#include <gst/gstpad.h>
Wim Taymanse1aeec62005-07-18 12:49:53 +000058#include <gst/gstbus.h>
Wim Taymans53b6bb62002-02-03 20:07:09 +000059#include <gst/gstclock.h>
Wim Taymanse1b5b742005-05-30 15:51:40 +000060#include <gst/gstelementfactory.h>
Benjamin Otte907e3e92003-10-31 19:32:47 +000061#include <gst/gstplugin.h>
Wim Taymans12bbbd52001-08-21 20:16:48 +000062#include <gst/gstpluginfeature.h>
Wim Taymansc47dc4d2005-03-07 18:27:42 +000063#include <gst/gstiterator.h>
Wim Taymansc2f41a82005-03-21 17:34:02 +000064#include <gst/gstmessage.h>
Wim Taymans44b43122011-06-07 13:25:26 +020065#include <gst/gstquery.h>
Stefan Kostb5454f72005-09-07 13:22:16 +000066#include <gst/gsttaglist.h>
Erik Walthinsen1762dfb2000-01-30 09:03:00 +000067
Johan Dahlinecd88e32004-03-15 14:43:35 +000068G_BEGIN_DECLS
69
Wim Taymansa9095a22009-08-28 18:14:23 +020070#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 Otte907e3e92003-10-31 19:32:47 +000077
Thomas Vander Stichele9b3e3a22005-09-11 12:57:36 +000078/**
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 Stichelebc93f422007-06-23 11:18:46 +000083 * @GST_STATE_CHANGE_NO_PREROLL: the state change succeeded but the element
Stefan Kost790e5d12009-12-14 15:11:42 +020084 * cannot produce data in %GST_STATE_PAUSED.
85 * This typically happens with live sources.
Wim Taymans06bc3432005-10-08 14:57:09 +000086 *
Stefan Kost6c2024f2011-05-28 10:24:37 +030087 * 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 Stichele9b3e3a22005-09-11 12:57:36 +000089 */
Wim Taymanse1aeec62005-07-18 12:49:53 +000090typedef enum {
Andy Wingoe040bb22005-09-02 15:42:00 +000091 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 Taymanse1aeec62005-07-18 12:49:53 +000096
Thomas Vander Stichele012d4ec2005-06-27 08:16:51 +000097/* NOTE: this probably should be done with an #ifdef to decide
Christian Schaller9dca9db2001-12-15 18:15:13 +000098 * whether to safe-cast or to just do the non-checking cast.
99 */
Stefan Kost5afb6e62005-09-23 14:31:21 +0000100
101/**
102 * GST_STATE:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000103 * @elem: a #GstElement to return state for.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000104 *
Wim Taymansa56bdf22005-11-10 11:17:26 +0000105 * This macro returns the current #GstState of the element.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000106 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200107#define GST_STATE(elem) (GST_ELEMENT_CAST(elem)->current_state)
Stefan Kost5afb6e62005-09-23 14:31:21 +0000108
109/**
Wim Taymans2153c452005-10-10 16:38:26 +0000110 * GST_STATE_NEXT:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000111 * @elem: a #GstElement to return the next state for.
Wim Taymans2153c452005-10-10 16:38:26 +0000112 *
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000113 * This macro returns the next #GstState of the element.
Wim Taymans2153c452005-10-10 16:38:26 +0000114 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200115#define GST_STATE_NEXT(elem) (GST_ELEMENT_CAST(elem)->next_state)
Wim Taymans2153c452005-10-10 16:38:26 +0000116
117/**
Stefan Kost5afb6e62005-09-23 14:31:21 +0000118 * GST_STATE_PENDING:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000119 * @elem: a #GstElement to return the pending state for.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000120 *
Wim Taymansa56bdf22005-11-10 11:17:26 +0000121 * This macro returns the currently pending #GstState of the element.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000122 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200123#define GST_STATE_PENDING(elem) (GST_ELEMENT_CAST(elem)->pending_state)
Erik Walthinsenb6d31c12000-07-17 17:14:15 +0000124
Wim Taymans2153c452005-10-10 16:38:26 +0000125/**
Wim Taymansd14c4c42007-03-19 10:47:56 +0000126 * 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 Taymansd14c4c42007-03-19 10:47:56 +0000130 */
Wim Taymans920ef122010-12-07 15:33:04 +0100131#define GST_STATE_TARGET(elem) (GST_ELEMENT_CAST(elem)->target_state)
Wim Taymansd14c4c42007-03-19 10:47:56 +0000132
133/**
Wim Taymans2153c452005-10-10 16:38:26 +0000134 * GST_STATE_RETURN:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000135 * @elem: a #GstElement to return the last state result for.
Wim Taymans2153c452005-10-10 16:38:26 +0000136 *
Wim Taymansa56bdf22005-11-10 11:17:26 +0000137 * This macro returns the last #GstStateChangeReturn value.
Wim Taymans2153c452005-10-10 16:38:26 +0000138 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200139#define GST_STATE_RETURN(elem) (GST_ELEMENT_CAST(elem)->last_return)
Andy Wingoe040bb22005-09-02 15:42:00 +0000140
Wim Taymansa9095a22009-08-28 18:14:23 +0200141#define __GST_SIGN(val) ((val) < 0 ? -1 : ((val) > 0 ? 1 : 0))
Wim Taymanse1a166a2005-10-21 11:36:32 +0000142/**
143 * GST_STATE_GET_NEXT:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000144 * @cur: A starting #GstState
145 * @pending: A target #GstState
Wim Taymanse1a166a2005-10-21 11:36:32 +0000146 *
Wim Taymansa56bdf22005-11-10 11:17:26 +0000147 * Given a current state @cur and a target state @pending, calculate the next (intermediate)
148 * #GstState.
Wim Taymanse1a166a2005-10-21 11:36:32 +0000149 */
Josep Torra2271b6d2011-08-10 11:07:49 +0200150#define GST_STATE_GET_NEXT(cur,pending) ((GstState)((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur))))
Wim Taymanse1a166a2005-10-21 11:36:32 +0000151/**
152 * GST_STATE_TRANSITION:
153 * @cur: A current state
154 * @next: A next state
155 *
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000156 * Given a current state @cur and a next state @next, calculate the associated
Wim Taymansa56bdf22005-11-10 11:17:26 +0000157 * #GstStateChange transition.
Wim Taymanse1a166a2005-10-21 11:36:32 +0000158 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200159#define GST_STATE_TRANSITION(cur,next) ((GstStateChange)(((cur)<<3)|(next)))
Wim Taymanse1a166a2005-10-21 11:36:32 +0000160/**
161 * GST_STATE_TRANSITION_CURRENT:
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000162 * @trans: A #GstStateChange
Wim Taymanse1a166a2005-10-21 11:36:32 +0000163 *
Wim Taymansa56bdf22005-11-10 11:17:26 +0000164 * Given a state transition @trans, extract the current #GstState.
Wim Taymanse1a166a2005-10-21 11:36:32 +0000165 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200166#define GST_STATE_TRANSITION_CURRENT(trans) ((GstState)((trans)>>3))
Wim Taymanse1a166a2005-10-21 11:36:32 +0000167/**
168 * GST_STATE_TRANSITION_NEXT:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000169 * @trans: A #GstStateChange
Wim Taymanse1a166a2005-10-21 11:36:32 +0000170 *
Wim Taymansa56bdf22005-11-10 11:17:26 +0000171 * Given a state transition @trans, extract the next #GstState.
Wim Taymanse1a166a2005-10-21 11:36:32 +0000172 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200173#define GST_STATE_TRANSITION_NEXT(trans) ((GstState)((trans)&0x7))
Wim Taymans2153c452005-10-10 16:38:26 +0000174
Thomas Vander Stichele9b3e3a22005-09-11 12:57:36 +0000175/**
176 * GstStateChange:
Stefan Kost790e5d12009-12-14 15:11:42 +0200177 * @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 Kost6c2024f2011-05-28 10:24:37 +0300195 * 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 Kost790e5d12009-12-14 15:11:42 +0200200 * </para></listitem>
201 * <listitem><para>
202 * A pipeline resets the running_time to 0.
203 * </para></listitem>
204 * <listitem><para>
Stefan Kost6c2024f2011-05-28 10:24:37 +0300205 * Live sources return %GST_STATE_CHANGE_NO_PREROLL and don't generate data.
Stefan Kost790e5d12009-12-14 15:11:42 +0200206 * </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 Kost6c2024f2011-05-28 10:24:37 +0300214 * The pipeline selects a #GstClock and distributes this to all the children
Sebastian Rasmussen53ae1b22013-12-07 15:38:19 +0100215 * before setting them to PLAYING. This means that it is only allowed to
Stefan Kost6c2024f2011-05-28 10:24:37 +0300216 * synchronize on the #GstClock in the PLAYING state.
Stefan Kost790e5d12009-12-14 15:11:42 +0200217 * </para></listitem>
218 * <listitem><para>
Stefan Kost6c2024f2011-05-28 10:24:37 +0300219 * The pipeline uses the #GstClock and the running_time to calculate the
Stefan Kost790e5d12009-12-14 15:11:42 +0200220 * 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 Kost6c2024f2011-05-28 10:24:37 +0300228 * 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 Kost790e5d12009-12-14 15:11:42 +0200230 * </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 Kost6c2024f2011-05-28 10:24:37 +0300236 * Live sources start generating data and return %GST_STATE_CHANGE_SUCCESS.
Stefan Kost790e5d12009-12-14 15:11:42 +0200237 * </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 Kost6c2024f2011-05-28 10:24:37 +0300245 * 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 Kost790e5d12009-12-14 15:11:42 +0200248 * </para></listitem>
249 * <listitem><para>
Stefan Kost6c2024f2011-05-28 10:24:37 +0300250 * Sinks unblock any #GstClock wait calls.
Stefan Kost790e5d12009-12-14 15:11:42 +0200251 * </para></listitem>
252 * <listitem><para>
Wim Taymans4a7c3b92011-11-11 16:52:41 +0100253 * When a sink does not have a pending buffer to play, it returns
Stefan Kost6c2024f2011-05-28 10:24:37 +0300254 * %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 Kost790e5d12009-12-14 15:11:42 +0200256 * </para></listitem>
257 * <listitem><para>
Stefan Kost6c2024f2011-05-28 10:24:37 +0300258 * 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 Kost790e5d12009-12-14 15:11:42 +0200261 * </para></listitem>
262 * <listitem><para>
Stefan Kost6c2024f2011-05-28 10:24:37 +0300263 * Live sources stop generating data and return %GST_STATE_CHANGE_NO_PREROLL.
Stefan Kost790e5d12009-12-14 15:11:42 +0200264 * </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 Taymans7ab1d622012-02-08 15:16:46 +0100275 * Chain or get_range functions return %GST_FLOW_FLUSHING.
Stefan Kost790e5d12009-12-14 15:11:42 +0200276 * </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 Taymanse1a166a2005-10-21 11:36:32 +0000297 *
Stefan Kost790e5d12009-12-14 15:11:42 +0200298 * These are the different state changes an element goes through.
299 * %GST_STATE_NULL &rArr; %GST_STATE_PLAYING is called an upwards state change
300 * and %GST_STATE_PLAYING &rArr; %GST_STATE_NULL a downwards state change.
Thomas Vander Stichele9b3e3a22005-09-11 12:57:36 +0000301 */
Andy Wingo1b38cd42005-09-02 16:44:57 +0000302typedef enum /*< flags=0 >*/
Andy Wingoe040bb22005-09-02 15:42:00 +0000303{
Wim Taymansa9095a22009-08-28 18:14:23 +0200304 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 Wingoe040bb22005-09-02 15:42:00 +0000310} GstStateChange;
Wim Taymans74598fd2000-12-23 03:17:52 +0000311
Stefan Kost5afb6e62005-09-23 14:31:21 +0000312/**
313 * GstElementFlags:
Wim Taymansd65773b2011-11-28 16:54:55 +0100314 * @GST_ELEMENT_FLAG_LOCKED_STATE: ignore state changes from parent
315 * @GST_ELEMENT_FLAG_SINK: the element is a sink
Edward Herveyd3ffa822012-07-10 11:46:41 +0200316 * @GST_ELEMENT_FLAG_SOURCE: the element is a source.
Wim Taymans1754ee92011-11-28 18:12:34 +0100317 * @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 Kost5afb6e62005-09-23 14:31:21 +0000320 * @GST_ELEMENT_FLAG_LAST: offset to define more flags
321 *
322 * The standard flags that an element may have.
323 */
Wim Taymansc47dc4d2005-03-07 18:27:42 +0000324typedef enum
325{
Wim Taymans26682f72012-06-11 15:49:10 +0200326 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 Kosta98aef82005-10-12 14:28:39 +0000332 /* padding */
Edward Hervey2d95de12012-03-29 15:28:44 +0200333 GST_ELEMENT_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 10)
Johan Dahlinecd88e32004-03-15 14:43:35 +0000334} GstElementFlags;
Erik Walthinsenb6d31c12000-07-17 17:14:15 +0000335
Stefan Kost5afb6e62005-09-23 14:31:21 +0000336/**
337 * GST_ELEMENT_IS_LOCKED_STATE:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000338 * @elem: A #GstElement to query
Stefan Kost5afb6e62005-09-23 14:31:21 +0000339 *
Michael Smith3d0989e2005-10-24 09:13:27 +0000340 * Check if the element is in the locked state and therefore will ignore state
Stefan Kost5afb6e62005-09-23 14:31:21 +0000341 * changes from its parent object.
342 */
Wim Taymansd65773b2011-11-28 16:54:55 +0100343#define GST_ELEMENT_IS_LOCKED_STATE(elem) (GST_OBJECT_FLAG_IS_SET(elem,GST_ELEMENT_FLAG_LOCKED_STATE))
Erik Walthinsenb6d31c12000-07-17 17:14:15 +0000344
Stefan Kost5afb6e62005-09-23 14:31:21 +0000345/**
346 * GST_ELEMENT_NAME:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000347 * @elem: A #GstElement to query
Stefan Kost5afb6e62005-09-23 14:31:21 +0000348 *
Carlos Rafael Gianif70dc952016-03-10 10:35:40 +0100349 * 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 Kost5afb6e62005-09-23 14:31:21 +0000352 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200353#define GST_ELEMENT_NAME(elem) (GST_OBJECT_NAME(elem))
Stefan Kost5afb6e62005-09-23 14:31:21 +0000354
355/**
356 * GST_ELEMENT_PARENT:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000357 * @elem: A #GstElement to query
Stefan Kost5afb6e62005-09-23 14:31:21 +0000358 *
Carlos Rafael Gianif70dc952016-03-10 10:35:40 +0100359 * 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 Kost5afb6e62005-09-23 14:31:21 +0000362 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200363#define GST_ELEMENT_PARENT(elem) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(elem)))
Stefan Kost5afb6e62005-09-23 14:31:21 +0000364
365/**
366 * GST_ELEMENT_BUS:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000367 * @elem: A #GstElement to query
Stefan Kost5afb6e62005-09-23 14:31:21 +0000368 *
Carlos Rafael Gianif70dc952016-03-10 10:35:40 +0100369 * 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 Kost5afb6e62005-09-23 14:31:21 +0000372 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200373#define GST_ELEMENT_BUS(elem) (GST_ELEMENT_CAST(elem)->bus)
Stefan Kost5afb6e62005-09-23 14:31:21 +0000374
375/**
376 * GST_ELEMENT_CLOCK:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000377 * @elem: A #GstElement to query
Stefan Kost5afb6e62005-09-23 14:31:21 +0000378 *
Carlos Rafael Gianif70dc952016-03-10 10:35:40 +0100379 * 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 Kost5afb6e62005-09-23 14:31:21 +0000382 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200383#define GST_ELEMENT_CLOCK(elem) (GST_ELEMENT_CAST(elem)->clock)
Stefan Kost5afb6e62005-09-23 14:31:21 +0000384
385/**
386 * GST_ELEMENT_PADS:
Wim Taymansa56bdf22005-11-10 11:17:26 +0000387 * @elem: A #GstElement to query
Stefan Kost5afb6e62005-09-23 14:31:21 +0000388 *
389 * Get the pads of this elements.
390 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200391#define GST_ELEMENT_PADS(elem) (GST_ELEMENT_CAST(elem)->pads)
Erik Walthinsenb6d31c12000-07-17 17:14:15 +0000392
Stefan Kostc4485272005-01-24 17:04:08 +0000393/**
Wim Taymans83b2c632009-05-26 11:53:05 +0200394 * 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 Taymans83b2c632009-05-26 11:53:05 +0200399 */
Wim Taymans920ef122010-12-07 15:33:04 +0100400#define GST_ELEMENT_START_TIME(elem) (GST_ELEMENT_CAST(elem)->start_time)
Wim Taymans83b2c632009-05-26 11:53:05 +0200401
402/**
Stefan Kostc4485272005-01-24 17:04:08 +0000403 * GST_ELEMENT_ERROR:
Wim Taymansadfd1992007-01-09 15:38:58 +0000404 * @el: the element that generates the error
Thijs Vermeir3a2d9fd2008-07-25 10:24:43 +0000405 * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
406 * @code: error code defined for that domain (see #gstreamer-GstGError)
Thomas Vander Stichelebd728f02005-06-29 12:23:35 +0000407 * @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 Kostc4485272005-01-24 17:04:08 +0000411 *
412 * Utility function that elements can use in case they encountered a fatal
Wim Taymansadfd1992007-01-09 15:38:58 +0000413 * data processing error. The pipeline will post an error message and the
Stefan Kostc4485272005-01-24 17:04:08 +0000414 * application will be requested to stop further media processing.
415 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200416#define GST_ELEMENT_ERROR(el, domain, code, text, debug) \
417G_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 Otte140c4dd2004-01-30 03:54:08 +0000427} G_STMT_END
Thomas Vander Stichele4efc3002004-01-18 21:36:20 +0000428
Stefan Kost5afb6e62005-09-23 14:31:21 +0000429/**
430 * GST_ELEMENT_WARNING:
Wim Taymansadfd1992007-01-09 15:38:58 +0000431 * @el: the element that generates the warning
Thomas Vander Stichelebe875072007-02-21 15:34:14 +0000432 * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
433 * @code: error code defined for that domain (see #gstreamer-GstGError)
Stefan Kost5afb6e62005-09-23 14:31:21 +0000434 * @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 Taymansadfd1992007-01-09 15:38:58 +0000440 * data processing problem. The pipeline will post a warning message and the
Stefan Kost5afb6e62005-09-23 14:31:21 +0000441 * application will be informed.
442 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200443#define GST_ELEMENT_WARNING(el, domain, code, text, debug) \
444G_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 Taymansc2f41a82005-03-21 17:34:02 +0000454} G_STMT_END
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000455
Thomas Vander Stichelebe875072007-02-21 15:34:14 +0000456/**
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 Santos2f0dab02011-03-22 16:26:56 -0300468 * The pipeline will post a info message and the
Thomas Vander Stichelebe875072007-02-21 15:34:14 +0000469 * application will be informed.
470 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200471#define GST_ELEMENT_INFO(el, domain, code, text, debug) \
472G_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 Stichelebe875072007-02-21 15:34:14 +0000482} G_STMT_END
483
Wim Taymans9e24b852005-03-08 17:42:29 +0000484/* the state change mutexes and conds */
Thomas Vander Stichele6eb5fb32005-10-05 22:35:14 +0000485/**
Wim Taymansa56bdf22005-11-10 11:17:26 +0000486 * GST_STATE_GET_LOCK:
487 * @elem: a #GstElement
Thomas Vander Stichele6eb5fb32005-10-05 22:35:14 +0000488 *
Wim Taymansa56bdf22005-11-10 11:17:26 +0000489 * 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 Stichele6eb5fb32005-10-05 22:35:14 +0000491 * the state, during state changes, and while finalizing.
492 */
Wim Taymans9555a7f2011-06-02 14:09:46 +0200493#define GST_STATE_GET_LOCK(elem) (&(GST_ELEMENT_CAST(elem)->state_lock))
Wim Taymansa56bdf22005-11-10 11:17:26 +0000494/**
495 * GST_STATE_GET_COND:
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000496 * @elem: a #GstElement
Wim Taymansa56bdf22005-11-10 11:17:26 +0000497 *
498 * Get the conditional used to signal the completion of a state change.
499 */
Wim Taymans252327f2012-01-19 09:27:04 +0100500#define GST_STATE_GET_COND(elem) (&GST_ELEMENT_CAST(elem)->state_cond)
Wim Taymansa56bdf22005-11-10 11:17:26 +0000501
Wim Taymans252327f2012-01-19 09:27:04 +0100502#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 Taymans1cef8c52005-10-18 17:06:29 +0000505#define GST_STATE_WAIT(elem) g_cond_wait (GST_STATE_GET_COND (elem), \
Wim Taymansa9095a22009-08-28 18:14:23 +0200506 GST_OBJECT_GET_LOCK (elem))
Wim Taymans252327f2012-01-19 09:27:04 +0100507#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 Taymans9e24b852005-03-08 17:42:29 +0000509#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 Taymansa56bdf22005-11-10 11:17:26 +0000512/**
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 Stichelee8c52502006-06-06 09:47:40 +0000516 * @state_cookie: Used to detect concurrent execution of
517 * gst_element_set_state() and gst_element_get_state()
Wim Taymans920ef122010-12-07 15:33:04 +0100518 * @target_state: the target state of an element as set by the application
Wim Taymansa56bdf22005-11-10 11:17:26 +0000519 * @current_state: the current state of an element
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000520 * @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 Taymansa56bdf22005-11-10 11:17:26 +0000524 * @last_return: the last return value of an element state change
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000525 * @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 Schleefe810dc02009-09-09 16:29:10 -0700527 * @clock: the clock of the element. This clock is usually provided to the
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000528 * 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 Taymansf7c57672009-05-21 17:32:00 +0200531 * state will yield the running_time against the clock.
Wim Taymans920ef122010-12-07 15:33:04 +0100532 * @start_time: the running_time of the last PAUSED state
Wim Taymansa56bdf22005-11-10 11:17:26 +0000533 * @numpads: number of pads of the element, includes both source and sink pads.
Evan Nemersond13ce8b2012-06-12 11:42:30 -0700534 * @pads: (element-type Gst.Pad): list of pads
Wim Taymansa56bdf22005-11-10 11:17:26 +0000535 * @numsrcpads: number of source pads of the element.
Evan Nemersond13ce8b2012-06-12 11:42:30 -0700536 * @srcpads: (element-type Gst.Pad): list of source pads
Wim Taymansa56bdf22005-11-10 11:17:26 +0000537 * @numsinkpads: number of sink pads of the element.
Evan Nemersond13ce8b2012-06-12 11:42:30 -0700538 * @sinkpads: (element-type Gst.Pad): list of sink pads
Wim Taymansa56bdf22005-11-10 11:17:26 +0000539 * @pads_cookie: updated whenever the a pad is added or removed
540 *
541 * GStreamer element abstract base class.
542 */
Wim Taymans6cacf762005-03-09 16:10:59 +0000543struct _GstElement
Wim Taymans9e24b852005-03-08 17:42:29 +0000544{
Wim Taymansa9095a22009-08-28 18:14:23 +0200545 GstObject object;
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000546
Wim Taymans1cef8c52005-10-18 17:06:29 +0000547 /*< public >*/ /* with LOCK */
Wim Taymans252327f2012-01-19 09:27:04 +0100548 GRecMutex state_lock;
Wim Taymansa56bdf22005-11-10 11:17:26 +0000549
550 /* element state */
Wim Taymans252327f2012-01-19 09:27:04 +0100551 GCond state_cond;
Wim Taymansa9095a22009-08-28 18:14:23 +0200552 guint32 state_cookie;
Wim Taymans920ef122010-12-07 15:33:04 +0100553 GstState target_state;
Wim Taymans2153c452005-10-10 16:38:26 +0000554 GstState current_state;
555 GstState next_state;
556 GstState pending_state;
557 GstStateChangeReturn last_return;
558
Wim Taymansa9095a22009-08-28 18:14:23 +0200559 GstBus *bus;
Wim Taymans68b53ac2002-12-19 21:31:03 +0000560
561 /* allocated clock */
Wim Taymansa9095a22009-08-28 18:14:23 +0200562 GstClock *clock;
563 GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */
Wim Taymans920ef122010-12-07 15:33:04 +0100564 GstClockTime start_time;
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000565
Wim Taymans9e24b852005-03-08 17:42:29 +0000566 /* element pads, these lists can only be iterated while holding
Wim Taymansc47dc4d2005-03-07 18:27:42 +0000567 * the LOCK or checking the cookie after each LOCK. */
Wim Taymans9e24b852005-03-08 17:42:29 +0000568 guint16 numpads;
569 GList *pads;
570 guint16 numsrcpads;
571 GList *srcpads;
572 guint16 numsinkpads;
573 GList *sinkpads;
574 guint32 pads_cookie;
Wim Taymans56d3cdf2001-12-18 19:03:07 +0000575
Matthew Watersd5ded152015-09-24 00:04:48 +1000576 /* with object LOCK */
577 GList *contexts;
578
Wim Taymans9e24b852005-03-08 17:42:29 +0000579 /*< private >*/
Matthew Watersd5ded152015-09-24 00:04:48 +1000580 gpointer _gst_reserved[GST_PADDING-1];
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000581};
582
Wim Taymansa56bdf22005-11-10 11:17:26 +0000583/**
584 * GstElementClass:
585 * @parent_class: the parent class structure
Wim Taymans920ef122010-12-07 15:33:04 +0100586 * @metadata: metadata for elements of this class
Wim Taymansa56bdf22005-11-10 11:17:26 +0000587 * @elementfactory: the #GstElementFactory that creates these elements
588 * @padtemplates: a #GList of #GstPadTemplate
Thomas Vander Stichelee8c52502006-06-06 09:47:40 +0000589 * @numpadtemplates: the number of padtemplates
Wim Taymansa56bdf22005-11-10 11:17:26 +0000590 * @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 Taymansa56bdf22005-11-10 11:17:26 +0000599 * @send_event: send a #GstEvent to the element
Wim Taymansa56bdf22005-11-10 11:17:26 +0000600 * @query: perform a #GstQuery on the element
Wim Taymans9c0d8ca2011-11-08 12:54:15 +0100601 * @state_changed: called immediately after a new state was set.
Sebastian Dröge1c4fe1b2012-10-16 12:31:50 +0200602 * @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ögeb9090612013-03-28 15:35:13 +0100604 * @set_context: set a #GstContext on the element
Wim Taymansa56bdf22005-11-10 11:17:26 +0000605 *
606 * GStreamer element class. Override the vmethods to implement the element
607 * functionality.
608 */
Wim Taymansc47dc4d2005-03-07 18:27:42 +0000609struct _GstElementClass
610{
Wim Taymans9e24b852005-03-08 17:42:29 +0000611 GstObjectClass parent_class;
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000612
Wim Taymans9e24b852005-03-08 17:42:29 +0000613 /*< public >*/
Wim Taymans920ef122010-12-07 15:33:04 +0100614 /* the element metadata */
615 gpointer metadata;
Ronald S. Bultje9abb3e02003-11-02 16:46:12 +0000616
617 /* factory that the element was created from */
Wim Taymansa9095a22009-08-28 18:14:23 +0200618 GstElementFactory *elementfactory;
Ronald S. Bultje9abb3e02003-11-02 16:46:12 +0000619
Andy Wingoeaaaabf2001-07-11 12:33:17 +0000620 /* templates for our pads */
Wim Taymans9e24b852005-03-08 17:42:29 +0000621 GList *padtemplates;
622 gint numpadtemplates;
623 guint32 pad_templ_cookie;
Wim Taymansc47dc4d2005-03-07 18:27:42 +0000624
Thomas Vander Stichele012d4ec2005-06-27 08:16:51 +0000625 /*< private >*/
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000626 /* signal callbacks */
Wim Taymansa9095a22009-08-28 18:14:23 +0200627 void (*pad_added) (GstElement *element, GstPad *pad);
628 void (*pad_removed) (GstElement *element, GstPad *pad);
629 void (*no_more_pads) (GstElement *element);
Erik Walthinsen4a583682001-05-25 21:00:07 +0000630
Thomas Vander Stichele012d4ec2005-06-27 08:16:51 +0000631 /*< public >*/
632 /* virtual methods for subclasses */
Wim Taymans9e24b852005-03-08 17:42:29 +0000633
634 /* request/release pads */
Thibault Saunier04d8b012015-04-02 09:44:33 +0200635 /* FIXME 2.0 harmonize naming with gst_element_request_pad */
Wim Taymans84a1f4b2011-05-10 16:41:36 +0200636 GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ,
637 const gchar* name, const GstCaps *caps);
Thibault Saunier04d8b012015-04-02 09:44:33 +0200638
Wim Taymansa9095a22009-08-28 18:14:23 +0200639 void (*release_pad) (GstElement *element, GstPad *pad);
Wim Taymans9e24b852005-03-08 17:42:29 +0000640
641 /* state changes */
Wim Taymansa9095a22009-08-28 18:14:23 +0200642 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ögeb935a812011-05-16 16:53:04 +0200646 void (*state_changed) (GstElement *element, GstState oldstate,
647 GstState newstate, GstState pending);
Wim Taymans9e24b852005-03-08 17:42:29 +0000648
Wim Taymanse1aeec62005-07-18 12:49:53 +0000649 /* bus */
Wim Taymansa9095a22009-08-28 18:14:23 +0200650 void (*set_bus) (GstElement * element, GstBus * bus);
Wim Taymans9e24b852005-03-08 17:42:29 +0000651
652 /* set/get clocks */
Wim Taymansa9095a22009-08-28 18:14:23 +0200653 GstClock* (*provide_clock) (GstElement *element);
654 gboolean (*set_clock) (GstElement *element, GstClock *clock);
Wim Taymans9e24b852005-03-08 17:42:29 +0000655
Wim Taymans8df6cd72005-05-09 10:53:13 +0000656 /* query functions */
Wim Taymansa9095a22009-08-28 18:14:23 +0200657 gboolean (*send_event) (GstElement *element, GstEvent *event);
Wim Taymans8df6cd72005-05-09 10:53:13 +0000658
Sebastian Dröge3d2127f2011-05-17 11:20:05 +0200659 gboolean (*query) (GstElement *element, GstQuery *query);
Wim Taymans6cacf762005-03-09 16:10:59 +0000660
Sebastian Dröge1c4fe1b2012-10-16 12:31:50 +0200661 gboolean (*post_message) (GstElement *element, GstMessage *message);
662
Sebastian Drögeb9090612013-03-28 15:35:13 +0100663 void (*set_context) (GstElement *element, GstContext *context);
664
Wim Taymans9e24b852005-03-08 17:42:29 +0000665 /*< private >*/
Sebastian Drögeb9090612013-03-28 15:35:13 +0100666 gpointer _gst_reserved[GST_PADDING_LARGE-2];
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000667};
668
Wim Taymansb3380852005-03-08 14:38:06 +0000669/* element class pad templates */
Wim Taymansa9095a22009-08-28 18:14:23 +0200670void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ);
Tim-Philipp Müllerfa12d232016-02-27 15:28:49 +0000671
672void gst_element_class_add_static_pad_template (GstElementClass *klass, GstStaticPadTemplate *static_templ);
673
Wim Taymansa9095a22009-08-28 18:14:23 +0200674GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name);
675GList* gst_element_class_get_pad_template_list (GstElementClass *element_class);
Stefan Kost65356fb2010-08-10 14:05:22 +0300676
677/* element class meta data */
Wim Taymans920ef122010-12-07 15:33:04 +0100678void gst_element_class_set_metadata (GstElementClass *klass,
Wim Taymansa9095a22009-08-28 18:14:23 +0200679 const gchar *longname,
680 const gchar *classification,
681 const gchar *description,
682 const gchar *author);
Tim-Philipp Müllerbca1ae82012-04-09 12:47:58 +0100683void 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 Taymans920ef122010-12-07 15:33:04 +0100688void gst_element_class_add_metadata (GstElementClass * klass,
689 const gchar * key, const gchar * value);
Tim-Philipp Müllerbca1ae82012-04-09 12:47:58 +0100690void gst_element_class_add_static_metadata (GstElementClass * klass,
691 const gchar * key, const gchar * value);
Wim Taymans4a7c3b92011-11-11 16:52:41 +0100692const gchar * gst_element_class_get_metadata (GstElementClass * klass,
Wim Taymanse8080ab2011-05-20 12:43:24 +0200693 const gchar * key);
Wim Taymans920ef122010-12-07 15:33:04 +0100694
Andy Wingod2ed0902002-05-26 03:23:25 +0000695
Wim Taymans9e24b852005-03-08 17:42:29 +0000696/* element instance */
Wim Taymansa9095a22009-08-28 18:14:23 +0200697GType gst_element_get_type (void);
Wim Taymans6637a942002-11-02 13:19:30 +0000698
Wim Taymans9e24b852005-03-08 17:42:29 +0000699/* basic name and parentage stuff from GstObject */
Stefan Kost5afb6e62005-09-23 14:31:21 +0000700
701/**
702 * gst_element_get_name:
Benjamin Gaignard5d44b1a2010-06-15 18:48:53 +0200703 * @elem: a #GstElement to get the name of @elem.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000704 *
Benjamin Gaignard5d44b1a2010-06-15 18:48:53 +0200705 * Returns a copy of the name of @elem.
706 * Caller should g_free() the return value after usage.
Evan Nemersone10266e2014-05-29 14:54:34 -0700707 * For a nameless element, this returns %NULL, which you can safely g_free()
Benjamin Gaignard5d44b1a2010-06-15 18:48:53 +0200708 * as well.
709 *
Evan Nemerson27598822014-06-11 15:21:34 -0700710 * Returns: (transfer full) (nullable): the name of @elem. g_free()
711 * after usage. MT safe.
Benjamin Gaignard5d44b1a2010-06-15 18:48:53 +0200712 *
Stefan Kost5afb6e62005-09-23 14:31:21 +0000713 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200714#define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT_CAST(elem))
Stefan Kost5afb6e62005-09-23 14:31:21 +0000715
716/**
717 * gst_element_set_name:
718 * @elem: a #GstElement to set the name of.
Stefan Kost6de84a32005-09-27 20:40:35 +0000719 * @name: the new name
Stefan Kost5afb6e62005-09-23 14:31:21 +0000720 *
721 * Sets the name of the element, getting rid of the old name if there was one.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000722 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200723#define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT_CAST(elem),name)
Stefan Kost5afb6e62005-09-23 14:31:21 +0000724
725/**
726 * gst_element_get_parent:
727 * @elem: a #GstElement to get the parent of.
728 *
Stefan Kostc45ff2b2011-05-02 16:20:24 +0300729 * Get the parent of an element.
730 *
Tim-Philipp Müller3256c702010-12-07 18:35:04 +0000731 * Returns: (transfer full): the parent of an element.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000732 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200733#define gst_element_get_parent(elem) gst_object_get_parent(GST_OBJECT_CAST(elem))
Stefan Kost5afb6e62005-09-23 14:31:21 +0000734
735/**
736 * gst_element_set_parent:
737 * @elem: a #GstElement to set the parent of.
Thomas Vander Stichelef74399e2005-09-23 16:35:43 +0000738 * @parent: the new parent #GstObject of the element.
Stefan Kost5afb6e62005-09-23 14:31:21 +0000739 *
740 * Sets the parent of an element.
741 */
Wim Taymansa9095a22009-08-28 18:14:23 +0200742#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT_CAST(elem),parent)
Thomas Vander Stichele45a34252002-12-07 22:18:17 +0000743
Wim Taymansa48bce02002-11-27 20:47:39 +0000744/* clocking */
Wim Taymansa9095a22009-08-28 18:14:23 +0200745GstClock* gst_element_provide_clock (GstElement *element);
746GstClock* gst_element_get_clock (GstElement *element);
747gboolean gst_element_set_clock (GstElement *element, GstClock *clock);
748void gst_element_set_base_time (GstElement *element, GstClockTime time);
749GstClockTime gst_element_get_base_time (GstElement *element);
750void gst_element_set_start_time (GstElement *element, GstClockTime time);
751GstClockTime gst_element_get_start_time (GstElement *element);
Wim Taymans9e24b852005-03-08 17:42:29 +0000752
Wim Taymanse1aeec62005-07-18 12:49:53 +0000753/* bus */
Wim Taymansa9095a22009-08-28 18:14:23 +0200754void gst_element_set_bus (GstElement * element, GstBus * bus);
755GstBus * gst_element_get_bus (GstElement * element);
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000756
Sebastian Drögeb9090612013-03-28 15:35:13 +0100757/* context */
758void gst_element_set_context (GstElement * element, GstContext * context);
Matthew Watersd5ded152015-09-24 00:04:48 +1000759GList * gst_element_get_contexts (GstElement * element);
760GstContext * gst_element_get_context (GstElement * element, const gchar * context_type);
761GstContext * gst_element_get_context_unlocked (GstElement * element, const gchar * context_type);
Sebastian Drögeb9090612013-03-28 15:35:13 +0100762
Wim Taymans9e24b852005-03-08 17:42:29 +0000763/* pad management */
Wim Taymansa9095a22009-08-28 18:14:23 +0200764gboolean gst_element_add_pad (GstElement *element, GstPad *pad);
765gboolean gst_element_remove_pad (GstElement *element, GstPad *pad);
766void gst_element_no_more_pads (GstElement *element);
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000767
Wim Taymansa9095a22009-08-28 18:14:23 +0200768GstPad* gst_element_get_static_pad (GstElement *element, const gchar *name);
769GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name);
Wim Taymans84a1f4b2011-05-10 16:41:36 +0200770GstPad* gst_element_request_pad (GstElement *element, GstPadTemplate *templ,
Edward Hervey04ebbc92010-12-20 13:30:43 +0100771 const gchar * name, const GstCaps *caps);
Wim Taymansa9095a22009-08-28 18:14:23 +0200772void gst_element_release_request_pad (GstElement *element, GstPad *pad);
Andy Wingo70cfc6c2002-04-07 23:32:16 +0000773
Wim Taymansa9095a22009-08-28 18:14:23 +0200774GstIterator * gst_element_iterate_pads (GstElement * element);
775GstIterator * gst_element_iterate_src_pads (GstElement * element);
776GstIterator * gst_element_iterate_sink_pads (GstElement * element);
Erik Walthinsen1762dfb2000-01-30 09:03:00 +0000777
Wim Taymans9e24b852005-03-08 17:42:29 +0000778/* event/query/format stuff */
Wim Taymansa9095a22009-08-28 18:14:23 +0200779gboolean gst_element_send_event (GstElement *element, GstEvent *event);
780gboolean gst_element_seek (GstElement *element, gdouble rate,
781 GstFormat format, GstSeekFlags flags,
Wim Taymansf05b0e22012-07-27 15:19:57 +0200782 GstSeekType start_type, gint64 start,
Wim Taymansa9095a22009-08-28 18:14:23 +0200783 GstSeekType stop_type, gint64 stop);
Sebastian Dröge3d2127f2011-05-17 11:20:05 +0200784gboolean gst_element_query (GstElement *element, GstQuery *query);
Wim Taymansa599a5b2002-05-30 19:03:30 +0000785
Wim Taymansc2f41a82005-03-21 17:34:02 +0000786/* messages */
Wim Taymansa9095a22009-08-28 18:14:23 +0200787gboolean gst_element_post_message (GstElement * element, GstMessage * message);
Wim Taymansc2f41a82005-03-21 17:34:02 +0000788
Wim Taymans9e24b852005-03-08 17:42:29 +0000789/* error handling */
Tim-Philipp Müller0ca55902006-10-08 13:27:17 +0000790/* gcc versions < 3.3 warn about NULL being passed as format to printf */
Tim-Philipp Müller7b199442013-03-30 17:20:13 +0000791#if (!defined(__GNUC__) || (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 3))
Wim Taymansa9095a22009-08-28 18:14:23 +0200792gchar * _gst_element_error_printf (const gchar *format, ...);
Tim-Philipp Müller376f6c32006-10-05 12:31:07 +0000793#else
Wim Taymansa9095a22009-08-28 18:14:23 +0200794gchar * _gst_element_error_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
Tim-Philipp Müller376f6c32006-10-05 12:31:07 +0000795#endif
Wim Taymansa9095a22009-08-28 18:14:23 +0200796void 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 Taymans9e24b852005-03-08 17:42:29 +0000800
801/* state management */
Wim Taymansa9095a22009-08-28 18:14:23 +0200802gboolean gst_element_is_locked_state (GstElement *element);
803gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state);
804gboolean gst_element_sync_state_with_parent (GstElement *element);
Benjamin Ottea03e8032003-04-08 21:14:23 +0000805
Wim Taymansa9095a22009-08-28 18:14:23 +0200806GstStateChangeReturn gst_element_get_state (GstElement * element,
807 GstState * state,
808 GstState * pending,
809 GstClockTime timeout);
810GstStateChangeReturn gst_element_set_state (GstElement *element, GstState state);
wrobell08eaa112001-12-04 22:12:50 +0000811
Wim Taymansa9095a22009-08-28 18:14:23 +0200812void gst_element_abort_state (GstElement * element);
Wim Taymansd14c4c42007-03-19 10:47:56 +0000813GstStateChangeReturn gst_element_change_state (GstElement * element,
Wim Taymansa9095a22009-08-28 18:14:23 +0200814 GstStateChange transition);
815GstStateChangeReturn gst_element_continue_state (GstElement * element,
Andy Wingo5748aa12005-11-19 17:50:52 +0000816 GstStateChangeReturn ret);
Wim Taymans3cb8b332011-06-08 13:40:32 +0200817void gst_element_lost_state (GstElement * element);
Wim Taymans6cacf762005-03-09 16:10:59 +0000818
Sebastian Dröge81771732016-02-28 12:06:40 +0200819typedef void (*GstElementCallAsyncFunc) (GstElement * element,
820 gpointer user_data);
821
822void gst_element_call_async (GstElement * element,
823 GstElementCallAsyncFunc func, gpointer user_data,
824 GDestroyNotify destroy_notify);
825
Wim Taymans9e24b852005-03-08 17:42:29 +0000826/* factory management */
Wim Taymansa9095a22009-08-28 18:14:23 +0200827GstElementFactory* gst_element_get_factory (GstElement *element);
Ronald S. Bultje9abb3e02003-11-02 16:46:12 +0000828
Tim-Philipp Müller6e3fb7a2016-03-05 14:12:36 +0000829/* utility functions */
830gulong gst_element_add_property_notify_watch (GstElement * element,
831 const gchar * property_name,
832 gboolean include_value);
833
834gulong gst_element_add_property_deep_notify_watch (GstElement * element,
835 const gchar * property_name,
836 gboolean include_value);
837
838void gst_element_remove_property_notify_watch (GstElement * element,
839 gulong watch_id);
840
Xavier Claessens46f83f52015-11-10 12:38:59 -0500841#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
842G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstElement, gst_object_unref)
843#endif
844
Andy Wingod2ed0902002-05-26 03:23:25 +0000845G_END_DECLS
Johan Dahlinecd88e32004-03-15 14:43:35 +0000846
Wim Taymans59211a42001-01-23 20:03:07 +0000847#endif /* __GST_ELEMENT_H__ */