gstpad.h 36.3 KB
Newer Older
1
2
/* GStreamer
 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3
 *                    2000 Wim Taymans <wim.taymans@chello.be>
4
5
 *
 * gstpad.h: Header for GstPad object
Erik Walthinsen's avatar
Erik Walthinsen committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


#ifndef __GST_PAD_H__
#define __GST_PAD_H__

27
#include <gst/gstconfig.h>
28

Wim Taymans's avatar
Wim Taymans committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
typedef struct _GstPad GstPad;
typedef struct _GstPadPrivate GstPadPrivate;
typedef struct _GstPadClass GstPadClass;

/**
 * GstPadDirection:
 * @GST_PAD_UNKNOWN: direction is unknown.
 * @GST_PAD_SRC: the pad is a source pad.
 * @GST_PAD_SINK: the pad is a sink pad.
 *
 * The direction of a pad.
 */
typedef enum {
  GST_PAD_UNKNOWN,
  GST_PAD_SRC,
  GST_PAD_SINK
} GstPadDirection;

Erik Walthinsen's avatar
Erik Walthinsen committed
47
48
#include <gst/gstobject.h>
#include <gst/gstbuffer.h>
49
#include <gst/gstbufferlist.h>
50
#include <gst/gstcaps.h>
Wim Taymans's avatar
Wim Taymans committed
51
#include <gst/gstpadtemplate.h>
Wim Taymans's avatar
Wim Taymans committed
52
#include <gst/gstevent.h>
53
#include <gst/gstquery.h>
Wim Taymans's avatar
Wim Taymans committed
54
#include <gst/gsttask.h>
Erik Walthinsen's avatar
Erik Walthinsen committed
55

56
57
G_BEGIN_DECLS

58
/*
59
60
 * Pad base class
 */
61
#define GST_TYPE_PAD			(gst_pad_get_type ())
62
#define GST_IS_PAD(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
Wim Taymans's avatar
Wim Taymans committed
63
#define GST_IS_PAD_CLASS(klass)		(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
64
65
#define GST_PAD(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
#define GST_PAD_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
66
#define GST_PAD_CAST(obj)		((GstPad*)(obj))
67

68

69

70
71
/**
 * GstPadLinkReturn:
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
72
73
74
75
76
77
78
 * @GST_PAD_LINK_OK		: link succeeded
 * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
 * @GST_PAD_LINK_WAS_LINKED	: pad was already linked
 * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
 * @GST_PAD_LINK_NOFORMAT	: pads do not have common format
 * @GST_PAD_LINK_NOSCHED	: pads cannot cooperate in scheduling
 * @GST_PAD_LINK_REFUSED	: refused for some reason
Wim Taymans's avatar
Wim Taymans committed
79
80
 *
 * Result values from gst_pad_link and friends.
81
 */
82
typedef enum {
83
84
85
86
87
88
  GST_PAD_LINK_OK               =  0,
  GST_PAD_LINK_WRONG_HIERARCHY  = -1,
  GST_PAD_LINK_WAS_LINKED       = -2,
  GST_PAD_LINK_WRONG_DIRECTION  = -3,
  GST_PAD_LINK_NOFORMAT         = -4,
  GST_PAD_LINK_NOSCHED          = -5,
89
  GST_PAD_LINK_REFUSED          = -6
90
} GstPadLinkReturn;
91

92
93
94
95
96
/**
 * GST_PAD_LINK_FAILED:
 * @ret: the #GstPadLinkReturn value
 *
 * Macro to test if the given #GstPadLinkReturn value indicates a failed
97
 * link step.
98
 */
Wim Taymans's avatar
Wim Taymans committed
99
#define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
100
101
102
103
104

/**
 * GST_PAD_LINK_SUCCESSFUL:
 * @ret: the #GstPadLinkReturn value
 *
105
 * Macro to test if the given #GstPadLinkReturn value indicates a successful
106
 * link step.
107
 */
Wim Taymans's avatar
Wim Taymans committed
108
#define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
109

110
111
/**
 * GstFlowReturn:
112
 * @GST_FLOW_RESEND:		 Resend buffer, possibly with new caps (not
113
 *                                 sent yet) (unused/unimplemented).
114
 * @GST_FLOW_OK:		 Data passing was ok.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
115
116
 * @GST_FLOW_NOT_LINKED:	 Pad is not linked.
 * @GST_FLOW_WRONG_STATE:	 Pad is in wrong state.
117
 * @GST_FLOW_EOS:                Pad is EOS.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
118
 * @GST_FLOW_NOT_NEGOTIATED:	 Pad is not negotiated.
119
120
121
 * @GST_FLOW_ERROR:		 Some (fatal) error occured. Element generating
 *                               this error should post an error message with more
 *                               details.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
122
 * @GST_FLOW_NOT_SUPPORTED:	 This operation is not supported.
123
124
125
126
127
128
129
 * @GST_FLOW_CUSTOM_SUCCESS:	 Elements can use values starting from
 *                               this (and higher) to define custom success
 *                               codes. Since 0.10.7.
 * @GST_FLOW_CUSTOM_SUCCESS_1:	 Pre-defined custom success code (define your
 *                               custom success code to this to avoid compiler
 *                               warnings). Since 0.10.29.
 * @GST_FLOW_CUSTOM_SUCCESS_2:	 Pre-defined custom success code. Since 0.10.29.
130
 * @GST_FLOW_CUSTOM_ERROR:	 Elements can use values starting from
131
132
133
134
135
136
 *                               this (and lower) to define custom error codes.
 *                               Since 0.10.7.
 * @GST_FLOW_CUSTOM_ERROR_1:	 Pre-defined custom error code (define your
 *                               custom error code to this to avoid compiler
 *                               warnings). Since 0.10.29.
 * @GST_FLOW_CUSTOM_ERROR_2:	 Pre-defined custom error code. Since 0.10.29.
137
 *
138
 * The result of passing data to a pad.
139
 *
140
 * Note that the custom return values should not be exposed outside of the
141
 * element scope and are available since 0.10.7.
142
 */
143
/* FIXME 0.11: remove custom flow returns */
144
typedef enum {
145
  /* custom success starts here */
146
147
  GST_FLOW_CUSTOM_SUCCESS_2 = 102,
  GST_FLOW_CUSTOM_SUCCESS_1 = 101,
148
149
  GST_FLOW_CUSTOM_SUCCESS = 100,

150
  /* core predefined */
151
152
  GST_FLOW_RESEND	  =  1,
  GST_FLOW_OK		  =  0,
153
  /* expected failures */
154
155
  GST_FLOW_NOT_LINKED     = -1,
  GST_FLOW_WRONG_STATE    = -2,
156
  /* error cases */
157
  GST_FLOW_EOS            = -3,
158
159
  GST_FLOW_NOT_NEGOTIATED = -4,
  GST_FLOW_ERROR	  = -5,
160
161
  GST_FLOW_NOT_SUPPORTED  = -6,

162
  /* custom error starts here */
163
164
165
  GST_FLOW_CUSTOM_ERROR   = -100,
  GST_FLOW_CUSTOM_ERROR_1 = -101,
  GST_FLOW_CUSTOM_ERROR_2 = -102
166
167
} GstFlowReturn;

168
const gchar*	        gst_flow_get_name	(GstFlowReturn ret);
169
170
GQuark			gst_flow_to_quark	(GstFlowReturn ret);

171
172
/**
 * GstPadLinkCheck:
173
174
 * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility.
 * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents.
175
 *   Could be omitted if it is already known that the two elements that own the
Stefan Kost's avatar
Stefan Kost committed
176
 *   pads are in the same bin.
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using
 *   their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but
 *   would be unsafe e.g. if one pad has %GST_CAPS_ANY.
 * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the
 *   caps returned by gst_pad_get_caps().
 *
 * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS
 * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are
 * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed.
 *
 * <warning><para>
 * Only disable some of the checks if you are 100% certain you know the link
 * will not fail because of hierarchy/caps compatibility failures. If uncertain,
 * use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods
 * for linking the pads.
 * </para></warning>
193
 *
194
195
196
197
 * Since: 0.10.30
 */

typedef enum {
198
199
200
  GST_PAD_LINK_CHECK_NOTHING       = 0,
  GST_PAD_LINK_CHECK_HIERARCHY     = 1 << 0,
  GST_PAD_LINK_CHECK_TEMPLATE_CAPS = 1 << 1,
201
  GST_PAD_LINK_CHECK_CAPS          = 1 << 2
202
203
204
205
206
} GstPadLinkCheck;

/**
 * GST_PAD_LINK_CHECK_DEFAULT:
 *
Stefan Kost's avatar
Stefan Kost committed
207
 * The default checks done when linking pads (i.e. the ones used by
208
 * gst_pad_link()).
209
210
211
 *
 * Since: 0.10.30
 */
212
#define GST_PAD_LINK_CHECK_DEFAULT ((GstPadLinkCheck) (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS))
213

Wim Taymans's avatar
Wim Taymans committed
214
/**
215
 * GstPadActivateMode:
Wim Taymans's avatar
Wim Taymans committed
216
217
218
 * @GST_PAD_ACTIVATE_NONE: Pad will not handle dataflow
 * @GST_PAD_ACTIVATE_PUSH: Pad handles dataflow in downstream push mode
 * @GST_PAD_ACTIVATE_PULL: Pad handles dataflow in upstream pull mode
Wim Taymans's avatar
Wim Taymans committed
219
220
 *
 * The status of a GstPad. After activating a pad, which usually happens when the
221
 * parent element goes from READY to PAUSED, the GstPadActivateMode defines if the
Wim Taymans's avatar
Wim Taymans committed
222
223
 * pad operates in push or pull mode.
 */
224
typedef enum {
225
226
227
228
  GST_PAD_ACTIVATE_NONE,
  GST_PAD_ACTIVATE_PUSH,
  GST_PAD_ACTIVATE_PULL
} GstPadActivateMode;
229
230

/* pad states */
Wim Taymans's avatar
Wim Taymans committed
231
232
233
234
235
236
237
238
239
240
241
/**
 * GstPadActivateFunction:
 * @pad: a #GstPad
 *
 * This function is called when the pad is activated during the element
 * READY to PAUSED state change. By default this function will call the
 * activate function that puts the pad in push mode but elements can
 * override this function to activate the pad in pull mode if they wish.
 *
 * Returns: TRUE if the pad could be activated.
 */
242
typedef gboolean		(*GstPadActivateFunction)	(GstPad *pad);
Wim Taymans's avatar
Wim Taymans committed
243
244
245
246
247
/**
 * GstPadActivateModeFunction:
 * @pad: a #GstPad
 * @active: activate or deactivate the pad.
 *
248
 * The prototype of the push and pull activate functions.
Wim Taymans's avatar
Wim Taymans committed
249
250
251
 *
 * Returns: TRUE if the pad could be activated or deactivated.
 */
252
typedef gboolean		(*GstPadActivateModeFunction)	(GstPad *pad, gboolean active);
253

254

Wim Taymans's avatar
Wim Taymans committed
255
/* data passing */
256
257
/**
 * GstPadChainFunction:
258
259
 * @pad: the sink #GstPad that performed the chain.
 * @buffer: the #GstBuffer that is chained, not %NULL.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
260
 *
Wim Taymans's avatar
Wim Taymans committed
261
 * A function that will be called on sinkpads when chaining buffers.
262
 * The function typically processes the data contained in the buffer and
263
 * either consumes the data or passes it on to the internally linked pad(s).
264
 *
265
266
267
268
 * The implementer of this function receives a refcount to @buffer and should
 * gst_buffer_unref() when the buffer is no longer needed.
 *
 * When a chain function detects an error in the data stream, it must post an
269
 * error on the bus and return an appropriate #GstFlowReturn value.
270
271
 *
 * Returns: #GST_FLOW_OK for success
272
 */
273
typedef GstFlowReturn		(*GstPadChainFunction)		(GstPad *pad, GstBuffer *buffer);
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293

/**
 * GstPadChainListFunction:
 * @pad: the sink #GstPad that performed the chain.
 * @list: the #GstBufferList that is chained, not %NULL.
 *
 * A function that will be called on sinkpads when chaining buffer lists.
 * The function typically processes the data contained in the buffer list and
 * either consumes the data or passes it on to the internally linked pad(s).
 *
 * The implementer of this function receives a refcount to @list and
 * should gst_buffer_list_unref() when the list is no longer needed.
 *
 * When a chainlist function detects an error in the data stream, it must
 * post an error on the bus and return an appropriate #GstFlowReturn value.
 *
 * Returns: #GST_FLOW_OK for success
 */
typedef GstFlowReturn		(*GstPadChainListFunction)	(GstPad *pad, GstBufferList *list);

Wim Taymans's avatar
Wim Taymans committed
294
295
/**
 * GstPadGetRangeFunction:
296
 * @pad: the src #GstPad to perform the getrange on.
Wim Taymans's avatar
Wim Taymans committed
297
298
 * @offset: the offset of the range
 * @length: the length of the range
299
 * @buffer: a memory location to hold the result buffer, cannot be NULL.
Wim Taymans's avatar
Wim Taymans committed
300
 *
301
302
 * This function will be called on source pads when a peer element
 * request a buffer at the specified @offset and @length. If this function
303
 * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
Wim Taymans's avatar
Wim Taymans committed
304
305
 * contents of @buffer is invalid for any other return value.
 *
306
 * This function is installed on a source pad with
307
 * gst_pad_set_getrange_function() and can only be called on source pads after
308
309
310
311
312
 * they are successfully activated with gst_pad_activate_pull().
 *
 * @offset and @length are always given in byte units. @offset must normally be a value
 * between 0 and the length in bytes of the data available on @pad. The
 * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
313
 * #GST_QUERY_SEEKING.
314
315
316
317
318
 *
 * Any @offset larger or equal than the length will make the function return
 * #GST_FLOW_UNEXPECTED, which corresponds to EOS. In this case @buffer does not
 * contain a valid buffer.
 *
319
320
321
 * The buffer size of @buffer will only be smaller than @length when @offset is
 * near the end of the stream. In all other cases, the size of @buffer must be
 * exactly the requested size.
322
 *
323
 * It is allowed to call this function with a 0 @length and valid @offset, in
324
325
326
327
 * which case @buffer will contain a 0-sized buffer and the function returns
 * #GST_FLOW_OK.
 *
 * When this function is called with a -1 @offset, the sequentially next buffer
328
 * of length @length in the stream is returned.
329
330
331
332
333
 *
 * When this function is called with a -1 @length, a buffer with a default
 * optimal length is returned in @buffer. The length might depend on the value
 * of @offset.
 *
334
335
 * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
 * return value leaves @buffer undefined.
Wim Taymans's avatar
Wim Taymans committed
336
 */
337
typedef GstFlowReturn		(*GstPadGetRangeFunction)	(GstPad *pad, guint64 offset,
Wim Taymans's avatar
Wim Taymans committed
338
		                                                 guint length, GstBuffer **buffer);
339
340
341
342
343
344
345
346
347
348

/**
 * GstPadEventFunction:
 * @pad: the #GstPad to handle the event.
 * @event: the #GstEvent to handle.
 *
 * Function signature to handle an event for the pad.
 *
 * Returns: TRUE if the pad could handle the event.
 */
349
typedef gboolean		(*GstPadEventFunction)		(GstPad *pad, GstEvent *event);
350

351

352
/* internal links */
353
354
355
356
357
358
359
360
361
362
363
364
365
366
/**
 * GstPadIterIntLinkFunction:
 * @pad: The #GstPad to query.
 *
 * The signature of the internal pad link iterator function.
 *
 * Returns: a new #GstIterator that will iterate over all pads that are
 * linked to the given pad on the inside of the parent element.
 *
 * the caller must call gst_iterator_free() after usage.
 *
 * Since 0.10.21
 */
typedef GstIterator*           (*GstPadIterIntLinkFunction)    (GstPad *pad);
367

Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
368
/* generic query function */
369
370
371
372
373
374
/**
 * GstPadQueryTypeFunction:
 * @pad: a #GstPad to query
 *
 * The signature of the query types function.
 *
Wim Taymans's avatar
Wim Taymans committed
375
 * Returns: a constant array of query types
376
 */
377
typedef const GstQueryType*	(*GstPadQueryTypeFunction)	(GstPad *pad);
378
379
380
381

/**
 * GstPadQueryFunction:
 * @pad: the #GstPad to query.
382
 * @query: the #GstQuery object to execute
383
 *
384
 * The signature of the query function.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
385
 *
386
387
 * Returns: TRUE if the query could be performed.
 */
388
typedef gboolean		(*GstPadQueryFunction)		(GstPad *pad, GstQuery *query);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
389

390

391
/* linking */
392
393
394
395
396
397
398
399
400
/**
 * GstPadLinkFunction
 * @pad: the #GstPad that is linked.
 * @peer: the peer #GstPad of the link
 *
 * Function signature to handle a new link on the pad.
 *
 * Returns: the result of the link with the specified peer.
 */
401
typedef GstPadLinkReturn	(*GstPadLinkFunction)		(GstPad *pad, GstPad *peer);
402
403
404
405
406
407
/**
 * GstPadUnlinkFunction
 * @pad: the #GstPad that is linked.
 *
 * Function signature to handle a unlinking the pad prom its peer.
 */
408
typedef void			(*GstPadUnlinkFunction)		(GstPad *pad);
409

410

411
/* caps nego */
412
413
414
/**
 * GstPadGetCapsFunction:
 * @pad: the #GstPad to get the capabilities of.
415
416
417
418
419
420
421
 * @filter: filter #GstCaps.
 *
 * When called on sinkpads @filter contains the caps that
 * upstream could produce in the order preferred by upstream. When
 * called on srcpads @filter contains the caps accepted by
 * downstream in the preffered order. @filter might be %NULL but if
 * it is not %NULL only a subset of @filter must be returned.
422
423
424
 *
 * Returns a copy of the capabilities of the specified pad. By default this
 * function will return the pad template capabilities, but can optionally
Wim Taymans's avatar
Wim Taymans committed
425
 * be overridden by elements.
426
427
428
 *
 * Returns: a newly allocated copy #GstCaps of the pad.
 */
429
typedef GstCaps*		(*GstPadGetCapsFunction)	(GstPad *pad, GstCaps *filter);
Wim Taymans's avatar
Wim Taymans committed
430
431
432
433
434
435
436
437
438
439
440
441

/**
 * GstPadAcceptCapsFunction:
 * @pad: the #GstPad to check
 * @caps: the #GstCaps to check
 *
 * Check if @pad can accept @caps. By default this function will see if @caps
 * intersect with the result from gst_pad_get_caps() by can be overridden to
 * perform extra checks.
 *
 * Returns: TRUE if the caps can be accepted by the pad.
 */
442
typedef gboolean		(*GstPadAcceptCapsFunction)	(GstPad *pad, GstCaps *caps);
Wim Taymans's avatar
Wim Taymans committed
443
444
/**
 * GstPadFixateCapsFunction:
445
 * @pad: a #GstPad
Wim Taymans's avatar
Wim Taymans committed
446
447
 * @caps: the #GstCaps to fixate
 *
Piotr Fusik's avatar
Piotr Fusik committed
448
 * Given possibly unfixed caps @caps, let @pad use its default preferred
Wim Taymans's avatar
Wim Taymans committed
449
450
451
452
 * format to make a fixed caps. @caps should be writable. By default this
 * function will pick the first value of any ranges or lists in the caps but
 * elements can override this function to perform other behaviour.
 */
453
typedef void			(*GstPadFixateCapsFunction)	(GstPad *pad, GstCaps *caps);
454

455
/* misc */
456
/**
457
458
459
 * GstPadForwardFunction:
 * @pad: the #GstPad that is forwarded.
 * @user_data: the gpointer to optional user data.
460
 *
461
462
 * A forward function is called for all internally linked pads, see
 * gst_pad_forward().
463
464
465
 *
 * Returns: TRUE if the dispatching procedure has to be stopped.
 */
466
typedef gboolean		(*GstPadForwardFunction)	(GstPad *pad, gpointer user_data);
Wim Taymans's avatar
Wim Taymans committed
467

468
/**
469
470
471
472
473
474
 * GstPadProbeType:
 * @GST_PAD_PROBE_TYPE_INVALID: invalid probe type
 * @GST_PAD_PROBE_TYPE_IDLE: probe idle pads and block
 * @GST_PAD_PROBE_TYPE_BLOCK: probe and block pads
 * @GST_PAD_PROBE_TYPE_BUFFER: probe buffers
 * @GST_PAD_PROBE_TYPE_BUFFER_LIST: probe buffer lists
Wim Taymans's avatar
Wim Taymans committed
475
476
 * @GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: probe downstream events
 * @GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: probe upstream events
477
478
 * @GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM: probe downstream queries
 * @GST_PAD_PROBE_TYPE_QUERY_UPSTREAM: probe upstream queries
479
480
 * @GST_PAD_PROBE_TYPE_PUSH: probe push
 * @GST_PAD_PROBE_TYPE_PULL: probe pull
481
 *
Wim Taymans's avatar
Wim Taymans committed
482
 * The different probing types that can occur. When either one of
483
 * @GST_PAD_PROBE_TYPE_IDLE or @GST_PAD_PROBE_TYPE_BLOCK is used, the probe will be a
Wim Taymans's avatar
Wim Taymans committed
484
 * blocking probe.
485
486
487
 */
typedef enum
{
Wim Taymans's avatar
Wim Taymans committed
488
  GST_PAD_PROBE_TYPE_INVALID          = 0,
Wim Taymans's avatar
Wim Taymans committed
489
  /* flags to control blocking */
Wim Taymans's avatar
Wim Taymans committed
490
491
  GST_PAD_PROBE_TYPE_IDLE             = (1 << 0),
  GST_PAD_PROBE_TYPE_BLOCK            = (1 << 1),
Wim Taymans's avatar
Wim Taymans committed
492
  /* flags to select datatypes */
493
494
495
496
497
498
  GST_PAD_PROBE_TYPE_BUFFER           = (1 << 4),
  GST_PAD_PROBE_TYPE_BUFFER_LIST      = (1 << 5),
  GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM = (1 << 6),
  GST_PAD_PROBE_TYPE_EVENT_UPSTREAM   = (1 << 7),
  GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM = (1 << 8),
  GST_PAD_PROBE_TYPE_QUERY_UPSTREAM   = (1 << 9),
Wim Taymans's avatar
Wim Taymans committed
499
  /* flags to select scheduling mode */
500
501
  GST_PAD_PROBE_TYPE_PUSH             = (1 << 12),
  GST_PAD_PROBE_TYPE_PULL             = (1 << 13),
502
} GstPadProbeType;
503

Wim Taymans's avatar
Wim Taymans committed
504
505
506
507
508
509
510
511
512
513
514
#define GST_PAD_PROBE_TYPE_BLOCKING         (GST_PAD_PROBE_TYPE_IDLE | GST_PAD_PROBE_TYPE_BLOCK)
#define GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM)
#define GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM   (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
#define GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM  (GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | \
                                             GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM)
#define GST_PAD_PROBE_TYPE_DATA_UPSTREAM    (GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
#define GST_PAD_PROBE_TYPE_DATA_BOTH        (GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM | \
                                             GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
#define GST_PAD_PROBE_TYPE_EVENT_BOTH       (GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | \
                                             GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
#define GST_PAD_PROBE_TYPE_SCHEDULING       (GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_PULL)
515
516

/**
517
518
519
520
521
 * GstPadProbeReturn:
 * @GST_PAD_PROBE_OK: normal probe return value
 * @GST_PAD_PROBE_DROP: drop data in data probes
 * @GST_PAD_PROBE_REMOVE: remove probe
 * @GST_PAD_PROBE_PASS: pass the data item in the block probe and block on
522
 *                         the next item
523
 *
Edward Hervey's avatar
Edward Hervey committed
524
 * Different return values for the #GstPadProbeCallback.
525
526
527
 */
typedef enum
{
528
529
530
531
532
  GST_PAD_PROBE_DROP,
  GST_PAD_PROBE_OK,
  GST_PAD_PROBE_REMOVE,
  GST_PAD_PROBE_PASS,
} GstPadProbeReturn;
533

Wim Taymans's avatar
Wim Taymans committed
534
535
536
537

/**
 * GstPadProbeInfo:
 * @type: the current probe type
Wim Taymans's avatar
Wim Taymans committed
538
539
540
541
542
543
 * @data: type specific data, check the @type field to know the datatype.
 *    This field can be NULL.
 * @offset: offset of pull probe, this field is valid when @type contains
 *    #GST_PAD_PROBE_TYPE_PULL
 * @size: size of pull probe, this field is valid when @type contains
 *    #GST_PAD_PROBE_TYPE_PULL
Wim Taymans's avatar
Wim Taymans committed
544
545
546
547
548
549
550
 *
 * Info passed in the #GstPadProbeCallback.
 */
typedef struct
{
  GstPadProbeType type;
  gpointer data;
Wim Taymans's avatar
Wim Taymans committed
551
552
  guint64 offset;
  guint size;
Wim Taymans's avatar
Wim Taymans committed
553
554
555
556
557
558
559
560
} GstPadProbeInfo;

#define GST_PAD_PROBE_INFO_TYPE(d)         ((d)->type)
#define GST_PAD_PROBE_INFO_DATA(d)         ((d)->data)

#define GST_PAD_PROBE_INFO_BUFFER(d)       GST_BUFFER_CAST(GST_PAD_PROBE_INFO_DATA(d))
#define GST_PAD_PROBE_INFO_BUFFER_LIST(d)  GST_BUFFER_LIST_CAST(GST_PAD_PROBE_INFO_DATA(d))
#define GST_PAD_PROBE_INFO_EVENT(d)        GST_EVENT_CAST(GST_PAD_PROBE_INFO_DATA(d))
561
#define GST_PAD_PROBE_INFO_QUERY(d)        GST_QUERY_CAST(GST_PAD_PROBE_INFO_DATA(d))
Wim Taymans's avatar
Wim Taymans committed
562

Wim Taymans's avatar
Wim Taymans committed
563
564
565
#define GST_PAD_PROBE_INFO_OFFSET(d)       ((d)->offset)
#define GST_PAD_PROBE_INFO_SIZE(d)         ((d)->size)

Stefan Kost's avatar
Stefan Kost committed
566
/**
567
 * GstPadProbeCallback
568
 * @pad: the #GstPad that is blocked
Wim Taymans's avatar
Wim Taymans committed
569
 * @info: #GstPadProbeInfo
Stefan Kost's avatar
Stefan Kost committed
570
571
 * @user_data: the gpointer to optional user data.
 *
572
 * Callback used by gst_pad_add_probe(). Gets called to notify about the current
573
 * blocking type.
Wim Taymans's avatar
Wim Taymans committed
574
575
 *
 * The callback is allowed to modify the data pointer in @info.
Stefan Kost's avatar
Stefan Kost committed
576
 */
Wim Taymans's avatar
Wim Taymans committed
577
578
typedef GstPadProbeReturn   (*GstPadProbeCallback)   (GstPad *pad, GstPadProbeInfo *info,
                                                      gpointer user_data);
579

580
581
582
583
584
585
586
587
588
589
/**
 * GstPadStickyEventsForeachFunction:
 * @pad: the #GstPad.
 * @event: the sticky #GstEvent.
 * @user_data: the #gpointer to optional user data.
 *
 * Callback used by gst_pad_sticky_events_foreach().
 *
 * Returns: GST_FLOW_OK if the iteration should continue
 */
Wim Taymans's avatar
Wim Taymans committed
590
591
typedef GstFlowReturn       (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent *event,
                                                                  gpointer user_data);
592

593
594
595
/**
 * GstPadFlags:
 * @GST_PAD_BLOCKED: is dataflow on a pad blocked
Wim Taymans's avatar
Wim Taymans committed
596
 * @GST_PAD_FLUSHING: is pad refusing buffers
597
 * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
598
 * @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event
599
600
601
602
 * @GST_PAD_NEED_RECONFIGURE: the pad should be reconfigured/renegotiated.
 *                            The flag has to be unset manually after
 *                            reconfiguration happened.
 *                            Since: 0.10.34.
603
 * @GST_PAD_NEED_EVENTS: the pad has pending events
604
605
606
 * @GST_PAD_FIXED_CAPS: the pad is using fixed caps this means that once the
 *                      caps are set on the pad, the getcaps function only
 *                      returns those caps.
607
608
609
610
 * @GST_PAD_FLAG_LAST: offset to define more flags
 *
 * Pad state flags
 */
611
typedef enum {
612
613
614
615
616
  GST_PAD_BLOCKED          = (GST_OBJECT_FLAG_LAST << 0),
  GST_PAD_FLUSHING         = (GST_OBJECT_FLAG_LAST << 1),
  GST_PAD_IN_GETCAPS       = (GST_OBJECT_FLAG_LAST << 2),
  GST_PAD_BLOCKING         = (GST_OBJECT_FLAG_LAST << 4),
  GST_PAD_NEED_RECONFIGURE = (GST_OBJECT_FLAG_LAST << 5),
617
  GST_PAD_NEED_EVENTS      = (GST_OBJECT_FLAG_LAST << 6),
618
  GST_PAD_FIXED_CAPS       = (GST_OBJECT_FLAG_LAST << 7),
619
  /* padding */
620
  GST_PAD_FLAG_LAST        = (GST_OBJECT_FLAG_LAST << 16)
621
} GstPadFlags;
622

Wim Taymans's avatar
Wim Taymans committed
623
624
625
626
627
628
629
630
631
632
/**
 * GstPad:
 * @element_private: private data owned by the parent element
 * @padtemplate: padtemplate for this pad
 * @direction: the direction of the pad, cannot change after creating
 *             the pad.
 * @stream_rec_lock: recursive stream lock of the pad, used to protect
 *                   the data used in streaming.
 * @task: task for this pad if the pad is actively driving dataflow.
 * @block_cond: conditional to signal pad block
Wim Taymans's avatar
Wim Taymans committed
633
 * @probes: installed probes
Wim Taymans's avatar
Wim Taymans committed
634
635
636
 * @getcapsfunc: function to get caps of the pad
 * @acceptcapsfunc: function to check if pad can accept caps
 * @fixatecapsfunc: function to fixate caps
Wim Taymans's avatar
Wim Taymans committed
637
 * @mode: current activation mode of the pad
Wim Taymans's avatar
Wim Taymans committed
638
639
640
 * @activatefunc: pad activation function
 * @activatepushfunc: function to activate/deactivate pad in push mode
 * @activatepullfunc: function to activate/deactivate pad in pull mode
Wim Taymans's avatar
Wim Taymans committed
641
 * @peer: the pad this pad is linked to
Wim Taymans's avatar
Wim Taymans committed
642
643
 * @linkfunc: function called when pad is linked
 * @unlinkfunc: function called when pad is unlinked
644
 * @chainfunc: function to chain buffer to pad
Wim Taymans's avatar
Wim Taymans committed
645
 * @chainlistfunc: function to chain a list of buffers to pad
Wim Taymans's avatar
Wim Taymans committed
646
647
 * @getrangefunc: function to get a range of data from a pad
 * @eventfunc: function to send an event to a pad
Wim Taymans's avatar
Wim Taymans committed
648
 * @offset: the pad offset
Wim Taymans's avatar
Wim Taymans committed
649
650
 * @querytypefunc: get list of supported queries
 * @queryfunc: perform a query on the pad
651
 * @iterintlinkfunc: get the internal links iterator of this pad
652
 *
Wim Taymans's avatar
Wim Taymans committed
653
654
 * The #GstPad structure. Use the functions to update the variables.
 */
655
struct _GstPad {
Wim Taymans's avatar
Wim Taymans committed
656
  GstObject                      object;
Erik Walthinsen's avatar
Erik Walthinsen committed
657

Wim Taymans's avatar
Wim Taymans committed
658
  /*< public >*/
Wim Taymans's avatar
Wim Taymans committed
659
  gpointer                       element_private;
Erik Walthinsen's avatar
Erik Walthinsen committed
660

Wim Taymans's avatar
Wim Taymans committed
661
  GstPadTemplate                *padtemplate;
662

Wim Taymans's avatar
Wim Taymans committed
663
  GstPadDirection                direction;
664

Wim Taymans's avatar
Wim Taymans committed
665
666
  /*< public >*/ /* with STREAM_LOCK */
  /* streaming rec_lock */
667
  GStaticRecMutex		 stream_rec_lock;
Wim Taymans's avatar
Wim Taymans committed
668
669
670
671
672
  GstTask			*task;

  /*< public >*/ /* with LOCK */
  /* block cond, mutex is from the object */
  GCond				*block_cond;
673
  GHookList                      probes;
Wim Taymans's avatar
Wim Taymans committed
674

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
675
  /* the pad capabilities */
676
677
678
  GstPadGetCapsFunction		getcapsfunc;
  GstPadAcceptCapsFunction	 acceptcapsfunc;
  GstPadFixateCapsFunction	 fixatecapsfunc;
Wim Taymans's avatar
Wim Taymans committed
679

680
  GstPadActivateMode		 mode;
Wim Taymans's avatar
Wim Taymans committed
681
  GstPadActivateFunction	 activatefunc;
682
683
  GstPadActivateModeFunction	 activatepushfunc;
  GstPadActivateModeFunction	 activatepullfunc;
Erik Walthinsen's avatar
Erik Walthinsen committed
684

685
  /* pad link */
Wim Taymans's avatar
Wim Taymans committed
686
  GstPad			*peer;
687
688
  GstPadLinkFunction		 linkfunc;
  GstPadUnlinkFunction		 unlinkfunc;
Erik Walthinsen's avatar
Erik Walthinsen committed
689

690
  /* data transport functions */
691
  GstPadChainFunction		 chainfunc;
Wim Taymans's avatar
Wim Taymans committed
692
  GstPadChainListFunction        chainlistfunc;
693
  GstPadGetRangeFunction	 getrangefunc;
694
  GstPadEventFunction		 eventfunc;
695

696
697
698
  /* pad offset */
  gint64                         offset;

699
  /* generic query method */
700
  GstPadQueryTypeFunction	 querytypefunc;
701
702
703
  GstPadQueryFunction		 queryfunc;

  /* internal links */
Wim Taymans's avatar
Wim Taymans committed
704
  GstPadIterIntLinkFunction      iterintlinkfunc;
705

Wim Taymans's avatar
Wim Taymans committed
706
  /*< private >*/
707
  /* counts number of probes attached. */
708
  gint				 num_probes;
709
  gint				 num_blocked;
710

Wim Taymans's avatar
Wim Taymans committed
711
712
713
  GstPadPrivate                 *priv;

  gpointer _gst_reserved[GST_PADDING];
Erik Walthinsen's avatar
Erik Walthinsen committed
714
715
};

716
717
struct _GstPadClass {
  GstObjectClass	parent_class;
718
719

  /* signal callbacks */
720
721
  void		(*linked)		(GstPad *pad, GstPad *peer);
  void		(*unlinked)		(GstPad *pad, GstPad *peer);
722
723

  /*< private >*/
724
  gpointer _gst_reserved[GST_PADDING];
Erik Walthinsen's avatar
Erik Walthinsen committed
725
726
};

727
728
729

/***** helper macros *****/
/* GstPad */
730
#define GST_PAD_NAME(pad)		(GST_OBJECT_NAME(pad))
731
#define GST_PAD_PARENT(pad)		(GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
Wim Taymans's avatar
Wim Taymans committed
732
#define GST_PAD_ELEMENT_PRIVATE(pad)    (GST_PAD_CAST(pad)->element_private)
733
#define GST_PAD_PAD_TEMPLATE(pad)	(GST_PAD_CAST(pad)->padtemplate)
734
735
736
737
738
#define GST_PAD_DIRECTION(pad)		(GST_PAD_CAST(pad)->direction)
#define GST_PAD_TASK(pad)		(GST_PAD_CAST(pad)->task)
#define GST_PAD_ACTIVATE_MODE(pad)	(GST_PAD_CAST(pad)->mode)

#define GST_PAD_ACTIVATEFUNC(pad)	(GST_PAD_CAST(pad)->activatefunc)
739
740
#define GST_PAD_ACTIVATEPUSHFUNC(pad)	(GST_PAD_CAST(pad)->activatepushfunc)
#define GST_PAD_ACTIVATEPULLFUNC(pad)	(GST_PAD_CAST(pad)->activatepullfunc)
741
#define GST_PAD_CHAINFUNC(pad)		(GST_PAD_CAST(pad)->chainfunc)
Wim Taymans's avatar
Wim Taymans committed
742
#define GST_PAD_CHAINLISTFUNC(pad)      (GST_PAD_CAST(pad)->chainlistfunc)
743
744
745
746
#define GST_PAD_GETRANGEFUNC(pad)	(GST_PAD_CAST(pad)->getrangefunc)
#define GST_PAD_EVENTFUNC(pad)		(GST_PAD_CAST(pad)->eventfunc)
#define GST_PAD_QUERYTYPEFUNC(pad)	(GST_PAD_CAST(pad)->querytypefunc)
#define GST_PAD_QUERYFUNC(pad)		(GST_PAD_CAST(pad)->queryfunc)
747
#define GST_PAD_ITERINTLINKFUNC(pad)    (GST_PAD_CAST(pad)->iterintlinkfunc)
748
749
750
751
752
753
754
755
756

#define GST_PAD_PEER(pad)		(GST_PAD_CAST(pad)->peer)
#define GST_PAD_LINKFUNC(pad)		(GST_PAD_CAST(pad)->linkfunc)
#define GST_PAD_UNLINKFUNC(pad)		(GST_PAD_CAST(pad)->unlinkfunc)

#define GST_PAD_GETCAPSFUNC(pad)	(GST_PAD_CAST(pad)->getcapsfunc)
#define GST_PAD_ACCEPTCAPSFUNC(pad)	(GST_PAD_CAST(pad)->acceptcapsfunc)
#define GST_PAD_FIXATECAPSFUNC(pad)	(GST_PAD_CAST(pad)->fixatecapsfunc)

757
758
759
#define GST_PAD_IS_SRC(pad)		(GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
#define GST_PAD_IS_SINK(pad)		(GST_PAD_DIRECTION(pad) == GST_PAD_SINK)

760
#define GST_PAD_IS_LINKED(pad)		(GST_PAD_PEER(pad) != NULL)
761

762
#define GST_PAD_IS_ACTIVE(pad)          (GST_PAD_ACTIVATE_MODE(pad) != GST_PAD_ACTIVATE_NONE)
Wim Taymans's avatar
Wim Taymans committed
763

764
#define GST_PAD_IS_BLOCKED(pad)		(GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
765
#define GST_PAD_IS_BLOCKING(pad)	(GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING))
766
767
#define GST_PAD_IS_FLUSHING(pad)	(GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
#define GST_PAD_IS_IN_GETCAPS(pad)	(GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS))
768
#define GST_PAD_NEEDS_RECONFIGURE(pad)  (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_NEED_RECONFIGURE))
769
#define GST_PAD_NEEDS_EVENTS(pad)       (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_NEED_EVENTS))
770
#define GST_PAD_IS_FIXED_CAPS(pad)	(GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FIXED_CAPS))
771

772
773
#define GST_PAD_SET_FLUSHING(pad)	(GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING))
#define GST_PAD_UNSET_FLUSHING(pad)	(GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING))
774

Wim Taymans's avatar
Wim Taymans committed
775
776
777
778
779
780
781
/**
 * GST_PAD_GET_STREAM_LOCK:
 * @pad: a #GstPad
 *
 * Get the stream lock of @pad. The stream lock is protecting the
 * resources used in the data processing functions of @pad.
 */
782
#define GST_PAD_GET_STREAM_LOCK(pad)    (&(GST_PAD_CAST(pad)->stream_rec_lock))
Wim Taymans's avatar
Wim Taymans committed
783
784
785
786
787
788
/**
 * GST_PAD_STREAM_LOCK:
 * @pad: a #GstPad
 *
 * Lock the stream lock of @pad.
 */
789
#define GST_PAD_STREAM_LOCK(pad)        (g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad)))
Wim Taymans's avatar
Wim Taymans committed
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
/**
 * GST_PAD_STREAM_LOCK_FULL:
 * @pad: a #GstPad
 * @t: the number of times to recursively lock
 *
 * Lock the stream lock of @pad @t times.
 */
#define GST_PAD_STREAM_LOCK_FULL(pad,t) (g_static_rec_mutex_lock_full(GST_PAD_GET_STREAM_LOCK(pad), t))
/**
 * GST_PAD_STREAM_TRYLOCK:
 * @pad: a #GstPad
 *
 * Try to Lock the stream lock of the pad, return TRUE if the lock could be
 * taken.
 */
805
#define GST_PAD_STREAM_TRYLOCK(pad)     (g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad)))
Wim Taymans's avatar
Wim Taymans committed
806
807
808
809
810
811
/**
 * GST_PAD_STREAM_UNLOCK:
 * @pad: a #GstPad
 *
 * Unlock the stream lock of @pad.
 */
812
#define GST_PAD_STREAM_UNLOCK(pad)      (g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad)))
Wim Taymans's avatar
Wim Taymans committed
813
814
815
816
817
818
819
/**
 * GST_PAD_STREAM_UNLOCK_FULL:
 * @pad: a #GstPad
 *
 * Fully unlock the recursive stream lock of @pad, return the number of times
 * @pad was locked.
 */
820
821
#define GST_PAD_STREAM_UNLOCK_FULL(pad) (g_static_rec_mutex_unlock_full(GST_PAD_GET_STREAM_LOCK(pad)))

822
#define GST_PAD_BLOCK_GET_COND(pad)     (GST_PAD_CAST(pad)->block_cond)
823
#define GST_PAD_BLOCK_WAIT(pad)         (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))
Wim Taymans's avatar
Wim Taymans committed
824
#define GST_PAD_BLOCK_SIGNAL(pad)       (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
825
#define GST_PAD_BLOCK_BROADCAST(pad)    (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad)))
Wim Taymans's avatar
Wim Taymans committed
826

827
GType			gst_pad_get_type			(void);
828

829
/* creating pads */
830
831
GstPad*			gst_pad_new				(const gchar *name, GstPadDirection direction);
GstPad*			gst_pad_new_from_template		(GstPadTemplate *templ, const gchar *name);
832
833
GstPad*			gst_pad_new_from_static_template	(GstStaticPadTemplate *templ, const gchar *name);

834

Stefan Kost's avatar
Stefan Kost committed
835
836
837
838
/**
 * gst_pad_get_name:
 * @pad: the pad to get the name from
 *
Wim Taymans's avatar
Wim Taymans committed
839
 * Get a copy of the name of the pad. g_free() after usage.
Stefan Kost's avatar
Stefan Kost committed
840
841
842
 *
 * MT safe.
 */
843
#define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad))
Stefan Kost's avatar
Stefan Kost committed
844
845
846
847
/**
 * gst_pad_get_parent:
 * @pad: the pad to get the parent of
 *
Wim Taymans's avatar
Wim Taymans committed
848
 * Get the parent of @pad. This function increases the refcount
Stefan Kost's avatar
Stefan Kost committed
849
 * of the parent object so you should gst_object_unref() it after usage.
Wim Taymans's avatar
Wim Taymans committed
850
 * Can return NULL if the pad did not have a parent.
Stefan Kost's avatar
Stefan Kost committed
851
852
853
 *
 * MT safe.
 */
Wim Taymans's avatar
Wim Taymans committed
854
#define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad))
855

856
GstPadDirection		gst_pad_get_direction			(GstPad *pad);
Erik Walthinsen's avatar
Erik Walthinsen committed
857

858
gboolean		gst_pad_set_active			(GstPad *pad, gboolean active);
859
gboolean		gst_pad_is_active			(GstPad *pad);
860
861
862
gboolean		gst_pad_activate_pull			(GstPad *pad, gboolean active);
gboolean		gst_pad_activate_push			(GstPad *pad, gboolean active);

863
gulong                  gst_pad_add_probe                       (GstPad *pad,
864
								 GstPadProbeType mask,
865
								 GstPadProbeCallback callback,
866
                                                                 gpointer user_data,
Wim Taymans's avatar
Wim Taymans committed
867
                                                                 GDestroyNotify destroy_data);
868
void                    gst_pad_remove_probe                    (GstPad *pad, gulong id);
869

Wim Taymans's avatar
Wim Taymans committed
870
gboolean		gst_pad_is_blocked			(GstPad *pad);
871
gboolean		gst_pad_is_blocking			(GstPad *pad);
Erik Walthinsen's avatar
Erik Walthinsen committed
872

873
void                    gst_pad_mark_reconfigure                (GstPad *pad);
874
875
gboolean		gst_pad_check_reconfigure               (GstPad *pad);

876
877
void			gst_pad_set_element_private		(GstPad *pad, gpointer priv);
gpointer		gst_pad_get_element_private		(GstPad *pad);
878

879
GstPadTemplate*		gst_pad_get_pad_template		(GstPad *pad);
Erik Walthinsen's avatar
Erik Walthinsen committed
880

881
GstEvent*               gst_pad_get_sticky_event                (GstPad *pad, GstEventType event_type);
882
GstFlowReturn           gst_pad_sticky_events_foreach           (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
883

884
/* data passing setup functions */
Wim Taymans's avatar
Wim Taymans committed
885
void			gst_pad_set_activate_function		(GstPad *pad, GstPadActivateFunction activate);
886
887
void			gst_pad_set_activatepull_function	(GstPad *pad, GstPadActivateModeFunction activatepull);
void			gst_pad_set_activatepush_function	(GstPad *pad, GstPadActivateModeFunction activatepush);
888
void			gst_pad_set_chain_function		(GstPad *pad, GstPadChainFunction chain);
Wim Taymans's avatar
Wim Taymans committed
889
void			gst_pad_set_chain_list_function	        (GstPad *pad, GstPadChainListFunction chainlist);
Wim Taymans's avatar
Wim Taymans committed
890
void			gst_pad_set_getrange_function		(GstPad *pad, GstPadGetRangeFunction get);
891
void			gst_pad_set_event_function		(GstPad *pad, GstPadEventFunction event);
892

893
/* pad links */
894
895
void			gst_pad_set_link_function		(GstPad *pad, GstPadLinkFunction link);
void			gst_pad_set_unlink_function		(GstPad *pad, GstPadUnlinkFunction unlink);
Benjamin Otte's avatar
Benjamin Otte committed
896

897
gboolean                gst_pad_can_link                        (GstPad *srcpad, GstPad *sinkpad);
898
GstPadLinkReturn        gst_pad_link				(GstPad *srcpad, GstPad *sinkpad);
899
GstPadLinkReturn        gst_pad_link_full			(GstPad *srcpad, GstPad *sinkpad, GstPadLinkCheck flags);
Wim Taymans's avatar
Wim Taymans committed
900
gboolean		gst_pad_unlink				(GstPad *srcpad, GstPad *sinkpad);
901
gboolean		gst_pad_is_linked			(GstPad *pad);
Erik Walthinsen's avatar
Erik Walthinsen committed
902

903
GstPad*			gst_pad_get_peer			(GstPad *pad);
904
905

/* capsnego functions */
906
void			gst_pad_set_getcaps_function		(GstPad *pad, GstPadGetCapsFunction getcaps);
Wim Taymans's avatar
Wim Taymans committed
907
908
void			gst_pad_set_acceptcaps_function		(GstPad *pad, GstPadAcceptCapsFunction acceptcaps);
void			gst_pad_set_fixatecaps_function		(GstPad *pad, GstPadFixateCapsFunction fixatecaps);
909

910
GstCaps*                gst_pad_get_pad_template_caps		(GstPad *pad);
911

912
/* capsnego function for linked/unlinked pads */
Wim Taymans's avatar
Wim Taymans committed
913
914
GstCaps *		gst_pad_get_current_caps                (GstPad * pad);
gboolean		gst_pad_has_current_caps                (GstPad * pad);
915
GstCaps *		gst_pad_get_caps			(GstPad * pad, GstCaps *filter);
916
void			gst_pad_fixate_caps			(GstPad * pad, GstCaps *caps);
917
918
gboolean		gst_pad_accept_caps			(GstPad * pad, GstCaps *caps);
gboolean		gst_pad_set_caps			(GstPad * pad, GstCaps *caps);
919

920
GstCaps *		gst_pad_peer_get_caps			(GstPad * pad, GstCaps *filter);
921
gboolean		gst_pad_peer_accept_caps		(GstPad * pad, GstCaps *caps);
922

923
/* capsnego for linked pads */
924
GstCaps *		gst_pad_get_allowed_caps		(GstPad * pad);
925

926
927
928
929
/* pad offsets */
gint64                  gst_pad_get_offset                      (GstPad *pad);
void                    gst_pad_set_offset                      (GstPad *pad, gint64 offset);

930
/* data passing functions to peer */
Wim Taymans's avatar
Wim Taymans committed
931
GstFlowReturn		gst_pad_push				(GstPad *pad, GstBuffer *buffer);
932
GstFlowReturn		gst_pad_push_list			(GstPad *pad, GstBufferList *list);
Wim Taymans's avatar
Wim Taymans committed
933
934
935
GstFlowReturn		gst_pad_pull_range			(GstPad *pad, guint64 offset, guint size,
								 GstBuffer **buffer);
gboolean		gst_pad_push_event			(GstPad *pad, GstEvent *event);
936
gboolean		gst_pad_event_default			(GstPad *pad, GstEvent *event);
Wim Taymans's avatar
Wim Taymans committed
937

938
939
/* data passing functions on pad */
GstFlowReturn		gst_pad_chain				(GstPad *pad, GstBuffer *buffer);
940
GstFlowReturn		gst_pad_chain_list                      (GstPad *pad, GstBufferList *list);
941
942
943
944
GstFlowReturn		gst_pad_get_range			(GstPad *pad, guint64 offset, guint size,
								 GstBuffer **buffer);
gboolean		gst_pad_send_event			(GstPad *pad, GstEvent *event);

Wim Taymans's avatar
Wim Taymans committed
945
/* pad tasks */
946
gboolean		gst_pad_start_task			(GstPad *pad, GstTaskFunction func,
947
								 gpointer data);
948
949
gboolean		gst_pad_pause_task			(GstPad *pad);
gboolean		gst_pad_stop_task			(GstPad *pad);