1 /* GStreamer 2 * 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 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public 18 * License along with this library; if not, write to the 19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 24 #ifndef __GST_PAD_H__ 25 #define __GST_PAD_H__ 26 27 #include <gst/gstconfig.h> 28 29 typedef struct _GstPad GstPad; 30 typedef struct _GstPadPrivate GstPadPrivate; 31 typedef struct _GstPadClass GstPadClass; 32 typedef struct _GstPadProbeInfo GstPadProbeInfo; 33 34 /** 35 * GstPadDirection: 36 * @GST_PAD_UNKNOWN: direction is unknown. 37 * @GST_PAD_SRC: the pad is a source pad. 38 * @GST_PAD_SINK: the pad is a sink pad. 39 * 40 * The direction of a pad. 41 */ 42 typedef enum { 43 GST_PAD_UNKNOWN, 44 GST_PAD_SRC, 45 GST_PAD_SINK 46 } GstPadDirection; 47 48 /** 49 * GstPadMode: 50 * @GST_PAD_MODE_NONE: Pad will not handle dataflow 51 * @GST_PAD_MODE_PUSH: Pad handles dataflow in downstream push mode 52 * @GST_PAD_MODE_PULL: Pad handles dataflow in upstream pull mode 53 * 54 * The status of a GstPad. After activating a pad, which usually happens when the 55 * parent element goes from READY to PAUSED, the GstPadMode defines if the 56 * pad operates in push or pull mode. 57 */ 58 typedef enum { 59 GST_PAD_MODE_NONE, 60 GST_PAD_MODE_PUSH, 61 GST_PAD_MODE_PULL 62 } GstPadMode; 63 64 #include <glib.h> 65 66 GST_API 67 const gchar * gst_pad_mode_get_name (GstPadMode mode); 68 69 #include <gst/gstobject.h> 70 #include <gst/gstbuffer.h> 71 #include <gst/gstbufferlist.h> 72 #include <gst/gstcaps.h> 73 #include <gst/gstpadtemplate.h> 74 #include <gst/gstevent.h> 75 #include <gst/gstquery.h> 76 #include <gst/gsttask.h> 77 78 G_BEGIN_DECLS 79 80 /* 81 * Pad base class 82 */ 83 #define GST_TYPE_PAD (gst_pad_get_type ()) 84 #define GST_IS_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD)) 85 #define GST_IS_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD)) 86 #define GST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad)) 87 #define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass)) 88 #define GST_PAD_CAST(obj) ((GstPad*)(obj)) 89 90 91 92 /** 93 * GstPadLinkReturn: 94 * @GST_PAD_LINK_OK : link succeeded 95 * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent 96 * @GST_PAD_LINK_WAS_LINKED : pad was already linked 97 * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction 98 * @GST_PAD_LINK_NOFORMAT : pads do not have common format 99 * @GST_PAD_LINK_NOSCHED : pads cannot cooperate in scheduling 100 * @GST_PAD_LINK_REFUSED : refused for some reason 101 * 102 * Result values from gst_pad_link and friends. 103 */ 104 typedef enum { 105 GST_PAD_LINK_OK = 0, 106 GST_PAD_LINK_WRONG_HIERARCHY = -1, 107 GST_PAD_LINK_WAS_LINKED = -2, 108 GST_PAD_LINK_WRONG_DIRECTION = -3, 109 GST_PAD_LINK_NOFORMAT = -4, 110 GST_PAD_LINK_NOSCHED = -5, 111 GST_PAD_LINK_REFUSED = -6 112 } GstPadLinkReturn; 113 114 /** 115 * GST_PAD_LINK_FAILED: 116 * @ret: the #GstPadLinkReturn value 117 * 118 * Macro to test if the given #GstPadLinkReturn value indicates a failed 119 * link step. 120 */ 121 #define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK) 122 123 /** 124 * GST_PAD_LINK_SUCCESSFUL: 125 * @ret: the #GstPadLinkReturn value 126 * 127 * Macro to test if the given #GstPadLinkReturn value indicates a successful 128 * link step. 129 */ 130 #define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK) 131 132 /** 133 * GstFlowReturn: 134 * @GST_FLOW_OK: Data passing was ok. 135 * @GST_FLOW_NOT_LINKED: Pad is not linked. 136 * @GST_FLOW_FLUSHING: Pad is flushing. 137 * @GST_FLOW_EOS: Pad is EOS. 138 * @GST_FLOW_NOT_NEGOTIATED: Pad is not negotiated. 139 * @GST_FLOW_ERROR: Some (fatal) error occurred. Element generating 140 * this error should post an error message using 141 * GST_ELEMENT_ERROR() with more details. 142 * @GST_FLOW_NOT_SUPPORTED: This operation is not supported. 143 * @GST_FLOW_CUSTOM_SUCCESS: Elements can use values starting from 144 * this (and higher) to define custom success 145 * codes. 146 * @GST_FLOW_CUSTOM_SUCCESS_1: Pre-defined custom success code (define your 147 * custom success code to this to avoid compiler 148 * warnings). 149 * @GST_FLOW_CUSTOM_SUCCESS_2: Pre-defined custom success code. 150 * @GST_FLOW_CUSTOM_ERROR: Elements can use values starting from 151 * this (and lower) to define custom error codes. 152 * @GST_FLOW_CUSTOM_ERROR_1: Pre-defined custom error code (define your 153 * custom error code to this to avoid compiler 154 * warnings). 155 * @GST_FLOW_CUSTOM_ERROR_2: Pre-defined custom error code. 156 * 157 * The result of passing data to a pad. 158 * 159 * Note that the custom return values should not be exposed outside of the 160 * element scope. 161 */ 162 typedef enum { 163 /* custom success starts here */ 164 GST_FLOW_CUSTOM_SUCCESS_2 = 102, 165 GST_FLOW_CUSTOM_SUCCESS_1 = 101, 166 GST_FLOW_CUSTOM_SUCCESS = 100, 167 168 /* core predefined */ 169 GST_FLOW_OK = 0, 170 /* expected failures */ 171 GST_FLOW_NOT_LINKED = -1, 172 GST_FLOW_FLUSHING = -2, 173 /* error cases */ 174 GST_FLOW_EOS = -3, 175 GST_FLOW_NOT_NEGOTIATED = -4, 176 GST_FLOW_ERROR = -5, 177 GST_FLOW_NOT_SUPPORTED = -6, 178 #ifdef OHOS_EXT_FUNC 179 // ohos.ext.func.0033 180 GST_FLOW_RECONNECTION_TIMEOUT = -7, 181 #endif 182 183 /* custom error starts here */ 184 GST_FLOW_CUSTOM_ERROR = -100, 185 GST_FLOW_CUSTOM_ERROR_1 = -101, 186 GST_FLOW_CUSTOM_ERROR_2 = -102 187 } GstFlowReturn; 188 189 GST_API 190 const gchar * gst_flow_get_name (GstFlowReturn ret); 191 192 GST_API 193 GQuark gst_flow_to_quark (GstFlowReturn ret); 194 195 GST_API 196 const gchar * gst_pad_link_get_name (GstPadLinkReturn ret); 197 198 /** 199 * GstPadLinkCheck: 200 * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility. 201 * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents. 202 * Could be omitted if it is already known that the two elements that own the 203 * pads are in the same bin. 204 * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using 205 * their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but 206 * would be unsafe e.g. if one pad has %GST_CAPS_ANY. 207 * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the 208 * caps returned by gst_pad_query_caps(). 209 * @GST_PAD_LINK_CHECK_NO_RECONFIGURE: Disables pushing a reconfigure event when pads are 210 * linked. 211 * @GST_PAD_LINK_CHECK_DEFAULT: The default checks done when linking 212 * pads (i.e. the ones used by gst_pad_link()). 213 * 214 * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS 215 * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are 216 * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed. 217 * 218 * > Only disable some of the checks if you are 100% certain you know the link 219 * > will not fail because of hierarchy/caps compatibility failures. If uncertain, 220 * > use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods 221 * > for linking the pads. 222 */ 223 224 typedef enum { 225 GST_PAD_LINK_CHECK_NOTHING = 0, 226 GST_PAD_LINK_CHECK_HIERARCHY = 1 << 0, 227 GST_PAD_LINK_CHECK_TEMPLATE_CAPS = 1 << 1, 228 GST_PAD_LINK_CHECK_CAPS = 1 << 2, 229 230 231 /* Not really checks, more like flags 232 * Added here to avoid creating a new gst_pad_link_variant */ 233 GST_PAD_LINK_CHECK_NO_RECONFIGURE = 1 << 3, 234 235 GST_PAD_LINK_CHECK_DEFAULT = GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS 236 } GstPadLinkCheck; 237 238 /* pad states */ 239 /** 240 * GstPadActivateFunction: 241 * @pad: a #GstPad 242 * @parent: the parent of @pad 243 * 244 * This function is called when the pad is activated during the element 245 * READY to PAUSED state change. By default this function will call the 246 * activate function that puts the pad in push mode but elements can 247 * override this function to activate the pad in pull mode if they wish. 248 * 249 * Returns: %TRUE if the pad could be activated. 250 */ 251 typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstObject *parent); 252 /** 253 * GstPadActivateModeFunction: 254 * @pad: a #GstPad 255 * @parent: the parent of @pad 256 * @mode: the requested activation mode of @pad 257 * @active: activate or deactivate the pad. 258 * 259 * The prototype of the push and pull activate functions. 260 * 261 * Returns: %TRUE if the pad could be activated or deactivated. 262 */ 263 typedef gboolean (*GstPadActivateModeFunction) (GstPad *pad, GstObject *parent, 264 GstPadMode mode, gboolean active); 265 266 267 /* data passing */ 268 /** 269 * GstPadChainFunction: 270 * @pad: the sink #GstPad that performed the chain. 271 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 272 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 273 * during the execution of this function. 274 * @buffer: (transfer full): the #GstBuffer that is chained, not %NULL. 275 * 276 * A function that will be called on sinkpads when chaining buffers. 277 * The function typically processes the data contained in the buffer and 278 * either consumes the data or passes it on to the internally linked pad(s). 279 * 280 * The implementer of this function receives a refcount to @buffer and should 281 * gst_buffer_unref() when the buffer is no longer needed. 282 * 283 * When a chain function detects an error in the data stream, it must post an 284 * error on the bus and return an appropriate #GstFlowReturn value. 285 * 286 * Returns: #GST_FLOW_OK for success 287 */ 288 typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstObject *parent, 289 GstBuffer *buffer); 290 291 /** 292 * GstPadChainListFunction: 293 * @pad: the sink #GstPad that performed the chain. 294 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 295 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 296 * during the execution of this function. 297 * @list: (transfer full): the #GstBufferList that is chained, not %NULL. 298 * 299 * A function that will be called on sinkpads when chaining buffer lists. 300 * The function typically processes the data contained in the buffer list and 301 * either consumes the data or passes it on to the internally linked pad(s). 302 * 303 * The implementer of this function receives a refcount to @list and 304 * should gst_buffer_list_unref() when the list is no longer needed. 305 * 306 * When a chainlist function detects an error in the data stream, it must 307 * post an error on the bus and return an appropriate #GstFlowReturn value. 308 * 309 * Returns: #GST_FLOW_OK for success 310 */ 311 typedef GstFlowReturn (*GstPadChainListFunction) (GstPad *pad, GstObject *parent, 312 GstBufferList *list); 313 314 /** 315 * GstPadGetRangeFunction: 316 * @pad: the src #GstPad to perform the getrange on. 317 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 318 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 319 * during the execution of this function. 320 * @offset: the offset of the range 321 * @length: the length of the range 322 * @buffer: a memory location to hold the result buffer, cannot be %NULL. 323 * 324 * This function will be called on source pads when a peer element 325 * request a buffer at the specified @offset and @length. If this function 326 * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The 327 * contents of @buffer is invalid for any other return value. 328 * 329 * This function is installed on a source pad with 330 * gst_pad_set_getrange_function() and can only be called on source pads after 331 * they are successfully activated with gst_pad_activate_mode() with the 332 * #GST_PAD_MODE_PULL. 333 * 334 * @offset and @length are always given in byte units. @offset must normally be a value 335 * between 0 and the length in bytes of the data available on @pad. The 336 * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a 337 * #GST_QUERY_SEEKING. 338 * 339 * Any @offset larger or equal than the length will make the function return 340 * #GST_FLOW_EOS, which corresponds to EOS. In this case @buffer does not 341 * contain a valid buffer. 342 * 343 * The buffer size of @buffer will only be smaller than @length when @offset is 344 * near the end of the stream. In all other cases, the size of @buffer must be 345 * exactly the requested size. 346 * 347 * It is allowed to call this function with a 0 @length and valid @offset, in 348 * which case @buffer will contain a 0-sized buffer and the function returns 349 * #GST_FLOW_OK. 350 * 351 * When this function is called with a -1 @offset, the sequentially next buffer 352 * of length @length in the stream is returned. 353 * 354 * When this function is called with a -1 @length, a buffer with a default 355 * optimal length is returned in @buffer. The length might depend on the value 356 * of @offset. 357 * 358 * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other 359 * return value leaves @buffer undefined. 360 */ 361 typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, GstObject *parent, 362 guint64 offset, guint length, 363 GstBuffer **buffer); 364 365 /** 366 * GstPadEventFunction: 367 * @pad: the #GstPad to handle the event. 368 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 369 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 370 * during the execution of this function. 371 * @event: (transfer full): the #GstEvent to handle. 372 * 373 * Function signature to handle an event for the pad. 374 * 375 * Returns: %TRUE if the pad could handle the event. 376 */ 377 typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstObject *parent, 378 GstEvent *event); 379 380 /** 381 * GstPadEventFullFunction: 382 * @pad: the #GstPad to handle the event. 383 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 384 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 385 * during the execution of this function. 386 * @event: (transfer full): the #GstEvent to handle. 387 * 388 * Function signature to handle an event for the pad. 389 * 390 * This variant is for specific elements that will take into account the 391 * last downstream flow return (from a pad push), in which case they can 392 * return it. 393 * 394 * Returns: %GST_FLOW_OK if the event was handled properly, or any other 395 * #GstFlowReturn dependent on downstream state. 396 * 397 * Since: 1.8 398 */ 399 typedef GstFlowReturn (*GstPadEventFullFunction) (GstPad *pad, GstObject *parent, 400 GstEvent *event); 401 402 403 /* internal links */ 404 /** 405 * GstPadIterIntLinkFunction: 406 * @pad: The #GstPad to query. 407 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 408 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 409 * during the execution of this function. 410 * 411 * The signature of the internal pad link iterator function. 412 * 413 * Returns: a new #GstIterator that will iterate over all pads that are 414 * linked to the given pad on the inside of the parent element. 415 * 416 * the caller must call gst_iterator_free() after usage. 417 */ 418 typedef GstIterator* (*GstPadIterIntLinkFunction) (GstPad *pad, GstObject *parent); 419 420 /* generic query function */ 421 /** 422 * GstPadQueryFunction: 423 * @pad: the #GstPad to query. 424 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 425 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 426 * during the execution of this function. 427 * @query: the #GstQuery object to execute 428 * 429 * The signature of the query function. 430 * 431 * Returns: %TRUE if the query could be performed. 432 */ 433 typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstObject *parent, 434 GstQuery *query); 435 436 437 /* linking */ 438 /** 439 * GstPadLinkFunction: 440 * @pad: the #GstPad that is linked. 441 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 442 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 443 * during the execution of this function. 444 * @peer: the peer #GstPad of the link 445 * 446 * Function signature to handle a new link on the pad. 447 * 448 * Returns: the result of the link with the specified peer. 449 */ 450 typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstObject *parent, GstPad *peer); 451 /** 452 * GstPadUnlinkFunction: 453 * @pad: the #GstPad that is linked. 454 * @parent: (allow-none): the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT 455 * flag is set, @parent is guaranteed to be not-%NULL and remain valid 456 * during the execution of this function. 457 * 458 * Function signature to handle a unlinking the pad prom its peer. 459 * 460 * The pad's lock is already held when the unlink function is called, so most 461 * pad functions cannot be called from within the callback. 462 */ 463 typedef void (*GstPadUnlinkFunction) (GstPad *pad, GstObject *parent); 464 465 466 /* misc */ 467 /** 468 * GstPadForwardFunction: 469 * @pad: the #GstPad that is forwarded. 470 * @user_data: the gpointer to optional user data. 471 * 472 * A forward function is called for all internally linked pads, see 473 * gst_pad_forward(). 474 * 475 * Returns: %TRUE if the dispatching procedure has to be stopped. 476 */ 477 typedef gboolean (*GstPadForwardFunction) (GstPad *pad, gpointer user_data); 478 479 /** 480 * GstPadProbeType: 481 * @GST_PAD_PROBE_TYPE_INVALID: invalid probe type 482 * @GST_PAD_PROBE_TYPE_IDLE: probe idle pads and block while the callback is called 483 * @GST_PAD_PROBE_TYPE_BLOCK: probe and block pads 484 * @GST_PAD_PROBE_TYPE_BUFFER: probe buffers 485 * @GST_PAD_PROBE_TYPE_BUFFER_LIST: probe buffer lists 486 * @GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: probe downstream events 487 * @GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: probe upstream events 488 * @GST_PAD_PROBE_TYPE_EVENT_FLUSH: probe flush events. This probe has to be 489 * explicitly enabled and is not included in the 490 * @@GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM or 491 * @@GST_PAD_PROBE_TYPE_EVENT_UPSTREAM probe types. 492 * @GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM: probe downstream queries 493 * @GST_PAD_PROBE_TYPE_QUERY_UPSTREAM: probe upstream queries 494 * @GST_PAD_PROBE_TYPE_PUSH: probe push 495 * @GST_PAD_PROBE_TYPE_PULL: probe pull 496 * @GST_PAD_PROBE_TYPE_BLOCKING: probe and block at the next opportunity, at data flow or when idle 497 * @GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM: probe downstream data (buffers, buffer lists, and events) 498 * @GST_PAD_PROBE_TYPE_DATA_UPSTREAM: probe upstream data (events) 499 * @GST_PAD_PROBE_TYPE_DATA_BOTH: probe upstream and downstream data (buffers, buffer lists, and events) 500 * @GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM: probe and block downstream data (buffers, buffer lists, and events) 501 * @GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM: probe and block upstream data (events) 502 * @GST_PAD_PROBE_TYPE_EVENT_BOTH: probe upstream and downstream events 503 * @GST_PAD_PROBE_TYPE_QUERY_BOTH: probe upstream and downstream queries 504 * @GST_PAD_PROBE_TYPE_ALL_BOTH: probe upstream events and queries and downstream buffers, buffer lists, events and queries 505 * @GST_PAD_PROBE_TYPE_SCHEDULING: probe push and pull 506 * 507 * The different probing types that can occur. When either one of 508 * @GST_PAD_PROBE_TYPE_IDLE or @GST_PAD_PROBE_TYPE_BLOCK is used, the probe will be a 509 * blocking probe. 510 */ 511 typedef enum 512 { 513 GST_PAD_PROBE_TYPE_INVALID = 0, 514 /* flags to control blocking */ 515 GST_PAD_PROBE_TYPE_IDLE = (1 << 0), 516 GST_PAD_PROBE_TYPE_BLOCK = (1 << 1), 517 /* flags to select datatypes */ 518 GST_PAD_PROBE_TYPE_BUFFER = (1 << 4), 519 GST_PAD_PROBE_TYPE_BUFFER_LIST = (1 << 5), 520 GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM = (1 << 6), 521 GST_PAD_PROBE_TYPE_EVENT_UPSTREAM = (1 << 7), 522 GST_PAD_PROBE_TYPE_EVENT_FLUSH = (1 << 8), 523 GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM = (1 << 9), 524 GST_PAD_PROBE_TYPE_QUERY_UPSTREAM = (1 << 10), 525 /* flags to select scheduling mode */ 526 GST_PAD_PROBE_TYPE_PUSH = (1 << 12), 527 GST_PAD_PROBE_TYPE_PULL = (1 << 13), 528 529 /* flag combinations */ 530 GST_PAD_PROBE_TYPE_BLOCKING = GST_PAD_PROBE_TYPE_IDLE | GST_PAD_PROBE_TYPE_BLOCK, 531 GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM = GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, 532 GST_PAD_PROBE_TYPE_DATA_UPSTREAM = GST_PAD_PROBE_TYPE_EVENT_UPSTREAM, 533 GST_PAD_PROBE_TYPE_DATA_BOTH = GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM | GST_PAD_PROBE_TYPE_DATA_UPSTREAM, 534 GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM = GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM, 535 GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM = GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_UPSTREAM, 536 GST_PAD_PROBE_TYPE_EVENT_BOTH = GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_UPSTREAM, 537 GST_PAD_PROBE_TYPE_QUERY_BOTH = GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM | GST_PAD_PROBE_TYPE_QUERY_UPSTREAM, 538 GST_PAD_PROBE_TYPE_ALL_BOTH = GST_PAD_PROBE_TYPE_DATA_BOTH | GST_PAD_PROBE_TYPE_QUERY_BOTH, 539 GST_PAD_PROBE_TYPE_SCHEDULING = GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_PULL 540 } GstPadProbeType; 541 542 543 /** 544 * GstPadProbeReturn: 545 * @GST_PAD_PROBE_OK: normal probe return value. This leaves the probe in 546 * place, and defers decisions about dropping or passing data to other 547 * probes, if any. If there are no other probes, the default behaviour 548 * for the probe type applies ('block' for blocking probes, 549 * and 'pass' for non-blocking probes). 550 * @GST_PAD_PROBE_DROP: drop data in data probes. For push mode this means that 551 * the data item is not sent downstream. For pull mode, it means that 552 * the data item is not passed upstream. In both cases, no other probes 553 * are called for this item and %GST_FLOW_OK or %TRUE is returned to the 554 * caller. 555 * @GST_PAD_PROBE_REMOVE: remove this probe, passing the data. For blocking probes 556 * this will cause data flow to unblock, unless there are also other 557 * blocking probes installed. 558 * @GST_PAD_PROBE_PASS: pass the data item in the block probe and block on the 559 * next item. Note, that if there are multiple pad probes installed and 560 * any probe returns PASS, the data will be passed. 561 * @GST_PAD_PROBE_HANDLED: Data has been handled in the probe and will not be 562 * forwarded further. For events and buffers this is the same behaviour as 563 * %GST_PAD_PROBE_DROP (except that in this case you need to unref the buffer 564 * or event yourself). For queries it will also return %TRUE to the caller. 565 * The probe can also modify the #GstFlowReturn value by using the 566 * #GST_PAD_PROBE_INFO_FLOW_RETURN() accessor. 567 * Note that the resulting query must contain valid entries. 568 * Since: 1.6 569 * 570 * Different return values for the #GstPadProbeCallback. 571 */ 572 typedef enum 573 { 574 GST_PAD_PROBE_DROP, 575 GST_PAD_PROBE_OK, 576 GST_PAD_PROBE_REMOVE, 577 GST_PAD_PROBE_PASS, 578 GST_PAD_PROBE_HANDLED 579 } GstPadProbeReturn; 580 581 582 /** 583 * GstPadProbeInfo: 584 * @type: the current probe type 585 * @id: the id of the probe 586 * @data: (allow-none): type specific data, check the @type field to know the 587 * datatype. This field can be %NULL. 588 * @offset: offset of pull probe, this field is valid when @type contains 589 * #GST_PAD_PROBE_TYPE_PULL 590 * @size: size of pull probe, this field is valid when @type contains 591 * #GST_PAD_PROBE_TYPE_PULL 592 * 593 * Info passed in the #GstPadProbeCallback. 594 */ 595 struct _GstPadProbeInfo 596 { 597 GstPadProbeType type; 598 gulong id; 599 gpointer data; 600 guint64 offset; 601 guint size; 602 603 /*< private >*/ 604 union { 605 gpointer _gst_reserved[GST_PADDING]; 606 struct { 607 GstFlowReturn flow_ret; 608 } abi; 609 } ABI; 610 }; 611 612 #define GST_PAD_PROBE_INFO_TYPE(d) ((d)->type) 613 #define GST_PAD_PROBE_INFO_ID(d) ((d)->id) 614 #define GST_PAD_PROBE_INFO_DATA(d) ((d)->data) 615 #define GST_PAD_PROBE_INFO_FLOW_RETURN(d) ((d)->ABI.abi.flow_ret) 616 617 #define GST_PAD_PROBE_INFO_BUFFER(d) GST_BUFFER_CAST(GST_PAD_PROBE_INFO_DATA(d)) 618 #define GST_PAD_PROBE_INFO_BUFFER_LIST(d) GST_BUFFER_LIST_CAST(GST_PAD_PROBE_INFO_DATA(d)) 619 #define GST_PAD_PROBE_INFO_EVENT(d) GST_EVENT_CAST(GST_PAD_PROBE_INFO_DATA(d)) 620 #define GST_PAD_PROBE_INFO_QUERY(d) GST_QUERY_CAST(GST_PAD_PROBE_INFO_DATA(d)) 621 622 #define GST_PAD_PROBE_INFO_OFFSET(d) ((d)->offset) 623 #define GST_PAD_PROBE_INFO_SIZE(d) ((d)->size) 624 625 GST_API 626 GstEvent* gst_pad_probe_info_get_event (GstPadProbeInfo * info); 627 628 GST_API 629 GstQuery* gst_pad_probe_info_get_query (GstPadProbeInfo * info); 630 631 GST_API 632 GstBuffer* gst_pad_probe_info_get_buffer (GstPadProbeInfo * info); 633 634 GST_API 635 GstBufferList* gst_pad_probe_info_get_buffer_list (GstPadProbeInfo * info); 636 637 /** 638 * GstPadProbeCallback: 639 * @pad: the #GstPad that is blocked 640 * @info: #GstPadProbeInfo 641 * @user_data: the gpointer to optional user data. 642 * 643 * Callback used by gst_pad_add_probe(). Gets called to notify about the current 644 * blocking type. 645 * 646 * The callback is allowed to modify the data pointer in @info. 647 * 648 * Returns: a #GstPadProbeReturn 649 */ 650 typedef GstPadProbeReturn (*GstPadProbeCallback) (GstPad *pad, GstPadProbeInfo *info, 651 gpointer user_data); 652 653 /** 654 * GstPadStickyEventsForeachFunction: 655 * @pad: the #GstPad. 656 * @event: (allow-none): a sticky #GstEvent. 657 * @user_data: the #gpointer to optional user data. 658 * 659 * Callback used by gst_pad_sticky_events_foreach(). 660 * 661 * When this function returns %TRUE, the next event will be 662 * returned. When %FALSE is returned, gst_pad_sticky_events_foreach() will return. 663 * 664 * When @event is set to %NULL, the item will be removed from the list of sticky events. 665 * @event can be replaced by assigning a new reference to it. 666 * This function is responsible for unreffing the old event when 667 * removing or modifying. 668 * 669 * Returns: %TRUE if the iteration should continue 670 */ 671 typedef gboolean (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent **event, 672 gpointer user_data); 673 674 /** 675 * GstPadFlags: 676 * @GST_PAD_FLAG_BLOCKED: is dataflow on a pad blocked 677 * @GST_PAD_FLAG_FLUSHING: is pad flushing 678 * @GST_PAD_FLAG_EOS: is pad in EOS state 679 * @GST_PAD_FLAG_BLOCKING: is pad currently blocking on a buffer or event 680 * @GST_PAD_FLAG_NEED_PARENT: ensure that there is a parent object before calling 681 * into the pad callbacks. 682 * @GST_PAD_FLAG_NEED_RECONFIGURE: the pad should be reconfigured/renegotiated. 683 * The flag has to be unset manually after 684 * reconfiguration happened. 685 * @GST_PAD_FLAG_PENDING_EVENTS: the pad has pending events 686 * @GST_PAD_FLAG_FIXED_CAPS: the pad is using fixed caps. This means that 687 * once the caps are set on the pad, the default caps query function 688 * will only return those caps. 689 * @GST_PAD_FLAG_PROXY_CAPS: the default event and query handler will forward 690 * all events and queries to the internally linked pads 691 * instead of discarding them. 692 * @GST_PAD_FLAG_PROXY_ALLOCATION: the default query handler will forward 693 * allocation queries to the internally linked pads 694 * instead of discarding them. 695 * @GST_PAD_FLAG_PROXY_SCHEDULING: the default query handler will forward 696 * scheduling queries to the internally linked pads 697 * instead of discarding them. 698 * @GST_PAD_FLAG_ACCEPT_INTERSECT: the default accept-caps handler will check 699 * it the caps intersect the query-caps result instead 700 * of checking for a subset. This is interesting for 701 * parsers that can accept incompletely specified caps. 702 * @GST_PAD_FLAG_ACCEPT_TEMPLATE: the default accept-caps handler will use 703 * the template pad caps instead of query caps to 704 * compare with the accept caps. Use this in combination 705 * with %GST_PAD_FLAG_ACCEPT_INTERSECT. (Since: 1.6) 706 * @GST_PAD_FLAG_LAST: offset to define more flags 707 * 708 * Pad state flags 709 */ 710 typedef enum { 711 GST_PAD_FLAG_BLOCKED = (GST_OBJECT_FLAG_LAST << 0), 712 GST_PAD_FLAG_FLUSHING = (GST_OBJECT_FLAG_LAST << 1), 713 GST_PAD_FLAG_EOS = (GST_OBJECT_FLAG_LAST << 2), 714 GST_PAD_FLAG_BLOCKING = (GST_OBJECT_FLAG_LAST << 3), 715 GST_PAD_FLAG_NEED_PARENT = (GST_OBJECT_FLAG_LAST << 4), 716 GST_PAD_FLAG_NEED_RECONFIGURE = (GST_OBJECT_FLAG_LAST << 5), 717 GST_PAD_FLAG_PENDING_EVENTS = (GST_OBJECT_FLAG_LAST << 6), 718 GST_PAD_FLAG_FIXED_CAPS = (GST_OBJECT_FLAG_LAST << 7), 719 GST_PAD_FLAG_PROXY_CAPS = (GST_OBJECT_FLAG_LAST << 8), 720 GST_PAD_FLAG_PROXY_ALLOCATION = (GST_OBJECT_FLAG_LAST << 9), 721 GST_PAD_FLAG_PROXY_SCHEDULING = (GST_OBJECT_FLAG_LAST << 10), 722 GST_PAD_FLAG_ACCEPT_INTERSECT = (GST_OBJECT_FLAG_LAST << 11), 723 GST_PAD_FLAG_ACCEPT_TEMPLATE = (GST_OBJECT_FLAG_LAST << 12), 724 /* padding */ 725 GST_PAD_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16) 726 } GstPadFlags; 727 728 /** 729 * GstPad: 730 * @element_private: private data owned by the parent element 731 * @padtemplate: padtemplate for this pad 732 * @direction: the direction of the pad, cannot change after creating 733 * the pad. 734 * 735 * The #GstPad structure. Use the functions to update the variables. 736 */ 737 struct _GstPad { 738 GstObject object; 739 740 /*< public >*/ 741 gpointer element_private; 742 743 GstPadTemplate *padtemplate; 744 745 GstPadDirection direction; 746 747 /*< private >*/ 748 /* streaming rec_lock */ 749 GRecMutex stream_rec_lock; 750 GstTask *task; 751 752 /* block cond, mutex is from the object */ 753 GCond block_cond; 754 GHookList probes; 755 756 GstPadMode mode; 757 GstPadActivateFunction activatefunc; 758 gpointer activatedata; 759 GDestroyNotify activatenotify; 760 GstPadActivateModeFunction activatemodefunc; 761 gpointer activatemodedata; 762 GDestroyNotify activatemodenotify; 763 764 /* pad link */ 765 GstPad *peer; 766 GstPadLinkFunction linkfunc; 767 gpointer linkdata; 768 GDestroyNotify linknotify; 769 GstPadUnlinkFunction unlinkfunc; 770 gpointer unlinkdata; 771 GDestroyNotify unlinknotify; 772 773 /* data transport functions */ 774 GstPadChainFunction chainfunc; 775 gpointer chaindata; 776 GDestroyNotify chainnotify; 777 GstPadChainListFunction chainlistfunc; 778 gpointer chainlistdata; 779 GDestroyNotify chainlistnotify; 780 GstPadGetRangeFunction getrangefunc; 781 gpointer getrangedata; 782 GDestroyNotify getrangenotify; 783 GstPadEventFunction eventfunc; 784 gpointer eventdata; 785 GDestroyNotify eventnotify; 786 787 /* pad offset */ 788 gint64 offset; 789 790 /* generic query method */ 791 GstPadQueryFunction queryfunc; 792 gpointer querydata; 793 GDestroyNotify querynotify; 794 795 /* internal links */ 796 GstPadIterIntLinkFunction iterintlinkfunc; 797 gpointer iterintlinkdata; 798 GDestroyNotify iterintlinknotify; 799 800 /* counts number of probes attached. */ 801 gint num_probes; 802 gint num_blocked; 803 804 GstPadPrivate *priv; 805 806 union { 807 gpointer _gst_reserved[GST_PADDING]; 808 struct { 809 GstFlowReturn last_flowret; 810 GstPadEventFullFunction eventfullfunc; 811 } abi; 812 } ABI; 813 }; 814 815 struct _GstPadClass { 816 GstObjectClass parent_class; 817 818 /* signal callbacks */ 819 void (*linked) (GstPad *pad, GstPad *peer); 820 void (*unlinked) (GstPad *pad, GstPad *peer); 821 822 /*< private >*/ 823 gpointer _gst_reserved[GST_PADDING]; 824 }; 825 826 827 /***** helper macros *****/ 828 /* GstPad */ 829 830 /** 831 * GST_PAD_NAME: 832 * @pad: a #GstPad 833 * 834 * Get name of the given pad. 835 * No locking is performed in this function, use gst_pad_get_name() instead. 836 */ 837 #define GST_PAD_NAME(pad) (GST_OBJECT_NAME(pad)) 838 /** 839 * GST_PAD_PARENT: 840 * @pad: a #GstPad 841 * 842 * Get the @pad parent. 843 * No locking is performed in this function, use gst_pad_get_parent() instead. 844 */ 845 #define GST_PAD_PARENT(pad) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad))) 846 /** 847 * GST_PAD_ELEMENT_PRIVATE: 848 * @pad: a #GstPad 849 * 850 * Get the private data of @pad, which is usually some pad- or stream-specific 851 * structure created by the element and set on the pad when creating it. 852 * No locking is performed in this function. 853 */ 854 #define GST_PAD_ELEMENT_PRIVATE(pad) (GST_PAD_CAST(pad)->element_private) 855 /** 856 * GST_PAD_PAD_TEMPLATE: 857 * @pad: a #GstPad 858 * 859 * Get the @pad #GstPadTemplate. It describes the possible media types 860 * a @pad or an element factory can handle. 861 */ 862 #define GST_PAD_PAD_TEMPLATE(pad) (GST_PAD_CAST(pad)->padtemplate) 863 /** 864 * GST_PAD_DIRECTION: 865 * @pad: a #GstPad 866 * 867 * Get the #GstPadDirection of the given @pad. Accessor macro, use 868 * gst_pad_get_direction() instead. 869 */ 870 #define GST_PAD_DIRECTION(pad) (GST_PAD_CAST(pad)->direction) 871 /** 872 * GST_PAD_TASK: 873 * @pad: a #GstPad 874 * 875 * Get the #GstTask of @pad. Accessor macro used by GStreamer. Use the 876 * gst_pad_start_task(), gst_pad_stop_task() and gst_pad_pause_task() 877 * functions instead. 878 */ 879 #define GST_PAD_TASK(pad) (GST_PAD_CAST(pad)->task) 880 /** 881 * GST_PAD_MODE: 882 * @pad: a #GstPad 883 * 884 * Get the #GstPadMode of pad, which will be GST_PAD_MODE_NONE if the pad 885 * has not been activated yet, and otherwise either GST_PAD_MODE_PUSH or 886 * GST_PAD_MODE_PULL depending on which mode the pad was activated in. 887 */ 888 #define GST_PAD_MODE(pad) (GST_PAD_CAST(pad)->mode) 889 /** 890 * GST_PAD_ACTIVATEFUNC: 891 * @pad: a #GstPad 892 * 893 * Get the #GstPadActivateFunction from @pad. 894 */ 895 #define GST_PAD_ACTIVATEFUNC(pad) (GST_PAD_CAST(pad)->activatefunc) 896 /** 897 * GST_PAD_ACTIVATEMODEFUNC: 898 * @pad: a #GstPad 899 * 900 * Get the #GstPadActivateModeFunction from the given @pad. 901 */ 902 #define GST_PAD_ACTIVATEMODEFUNC(pad) (GST_PAD_CAST(pad)->activatemodefunc) 903 /** 904 * GST_PAD_CHAINFUNC: 905 * @pad: a #GstPad 906 * 907 * Get the #GstPadChainFunction from the given @pad. 908 */ 909 #define GST_PAD_CHAINFUNC(pad) (GST_PAD_CAST(pad)->chainfunc) 910 /** 911 * GST_PAD_CHAINLISTFUNC: 912 * @pad: a #GstPad 913 * 914 * Get the #GstPadChainListFunction from the given @pad. 915 */ 916 #define GST_PAD_CHAINLISTFUNC(pad) (GST_PAD_CAST(pad)->chainlistfunc) 917 /** 918 * GST_PAD_GETRANGEFUNC: 919 * @pad: a #GstPad 920 * 921 * Get the #GstPadGetRangeFunction from the given @pad. 922 */ 923 #define GST_PAD_GETRANGEFUNC(pad) (GST_PAD_CAST(pad)->getrangefunc) 924 /** 925 * GST_PAD_EVENTFUNC: 926 * @pad: a #GstPad 927 * 928 * Get the #GstPadEventFunction from the given @pad, which 929 * is the function that handles events on the pad. You can 930 * use this to set your own event handling function on a pad 931 * after you create it. If your element derives from a base 932 * class, use the base class's virtual functions instead. 933 */ 934 #define GST_PAD_EVENTFUNC(pad) (GST_PAD_CAST(pad)->eventfunc) 935 /** 936 * GST_PAD_EVENTFULLFUNC: 937 * @pad: a #GstPad 938 * 939 * Get the #GstPadEventFullFunction from the given @pad, which 940 * is the function that handles events on the pad. You can 941 * use this to set your own event handling function on a pad 942 * after you create it. If your element derives from a base 943 * class, use the base class's virtual functions instead. 944 * 945 * Since: 1.8 946 */ 947 #define GST_PAD_EVENTFULLFUNC(pad) (GST_PAD_CAST(pad)->ABI.abi.eventfullfunc) 948 /** 949 * GST_PAD_QUERYFUNC: 950 * @pad: a #GstPad 951 * 952 * Get the #GstPadQueryFunction from @pad, which is the function 953 * that handles queries on the pad. You can use this to set your 954 * own query handling function on a pad after you create it. If your 955 * element derives from a base class, use the base class's virtual 956 * functions instead. 957 */ 958 #define GST_PAD_QUERYFUNC(pad) (GST_PAD_CAST(pad)->queryfunc) 959 /** 960 * GST_PAD_ITERINTLINKFUNC: 961 * @pad: a #GstPad 962 * 963 * Get the #GstPadIterIntLinkFunction from the given @pad. 964 */ 965 #define GST_PAD_ITERINTLINKFUNC(pad) (GST_PAD_CAST(pad)->iterintlinkfunc) 966 /** 967 * GST_PAD_PEER: 968 * @pad: a #GstPad 969 * 970 * Return the pad's peer member. This member is a pointer to the linked @pad. 971 * No locking is performed in this function, use gst_pad_get_peer() instead. 972 */ 973 #define GST_PAD_PEER(pad) (GST_PAD_CAST(pad)->peer) 974 /** 975 * GST_PAD_LINKFUNC: 976 * @pad: a #GstPad 977 * 978 * Get the #GstPadLinkFunction for the given @pad. 979 */ 980 #define GST_PAD_LINKFUNC(pad) (GST_PAD_CAST(pad)->linkfunc) 981 /** 982 * GST_PAD_UNLINKFUNC: 983 * @pad: a #GstPad 984 * 985 * Get the #GstPadUnlinkFunction from the given @pad. 986 */ 987 #define GST_PAD_UNLINKFUNC(pad) (GST_PAD_CAST(pad)->unlinkfunc) 988 /** 989 * GST_PAD_IS_SRC: 990 * @pad: a #GstPad 991 * 992 * Returns: %TRUE if the pad is a source pad (i.e. produces data). 993 */ 994 #define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC) 995 /** 996 * GST_PAD_IS_SINK: 997 * @pad: a #GstPad 998 * 999 * Returns: %TRUE if the pad is a sink pad (i.e. consumes data). 1000 */ 1001 #define GST_PAD_IS_SINK(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SINK) 1002 /** 1003 * GST_PAD_IS_LINKED: 1004 * @pad: a #GstPad 1005 * 1006 * Returns: %TRUE if the pad is linked to another pad. Use gst_pad_is_linked() 1007 * instead. 1008 */ 1009 #define GST_PAD_IS_LINKED(pad) (GST_PAD_PEER(pad) != NULL) 1010 /** 1011 * GST_PAD_IS_ACTIVE: 1012 * @pad: a #GstPad 1013 * 1014 * Returns: %TRUE if the pad has been activated. 1015 */ 1016 #define GST_PAD_IS_ACTIVE(pad) (GST_PAD_MODE(pad) != GST_PAD_MODE_NONE) 1017 /** 1018 * GST_PAD_IS_BLOCKED: 1019 * @pad: a #GstPad 1020 * 1021 * Check if the dataflow on a @pad is blocked. Use gst_pad_is_blocked() instead. 1022 */ 1023 #define GST_PAD_IS_BLOCKED(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED)) 1024 /** 1025 * GST_PAD_IS_BLOCKING: 1026 * @pad: a #GstPad 1027 * 1028 * Check if the @pad is currently blocking on a buffer or event. Use 1029 * gst_pad_is_blocking() instead. 1030 */ 1031 #define GST_PAD_IS_BLOCKING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING)) 1032 /** 1033 * GST_PAD_IS_FLUSHING: 1034 * @pad: a #GstPad 1035 * 1036 * Check if the given @pad is flushing. 1037 */ 1038 #define GST_PAD_IS_FLUSHING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING)) 1039 /** 1040 * GST_PAD_SET_FLUSHING: 1041 * @pad: a #GstPad 1042 * 1043 * Set the given @pad to flushing state, which means it will not accept any 1044 * more events, queries or buffers, and return GST_FLOW_FLUSHING if any buffers 1045 * are pushed on it. This usually happens when the pad is shut down or when 1046 * a flushing seek happens. This is used inside GStreamer when flush start/stop 1047 * events pass through pads, or when an element state is changed and pads are 1048 * activated or deactivated. 1049 */ 1050 #define GST_PAD_SET_FLUSHING(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_FLUSHING)) 1051 /** 1052 * GST_PAD_UNSET_FLUSHING: 1053 * @pad: a #GstPad 1054 * 1055 * Unset the flushing flag. 1056 */ 1057 #define GST_PAD_UNSET_FLUSHING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_FLUSHING)) 1058 /** 1059 * GST_PAD_IS_EOS: 1060 * @pad: a #GstPad 1061 * 1062 * Check if the @pad is in EOS state. 1063 */ 1064 #define GST_PAD_IS_EOS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_EOS)) 1065 /** 1066 * GST_PAD_NEEDS_RECONFIGURE: 1067 * @pad: a #GstPad 1068 * 1069 * Check if the @pad should be reconfigured/renegotiated. 1070 * The flag has to be unset manually after reconfiguration happened. 1071 * Use gst_pad_needs_reconfigure() or gst_pad_check_reconfigure() instead. 1072 */ 1073 #define GST_PAD_NEEDS_RECONFIGURE(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_RECONFIGURE)) 1074 /** 1075 * GST_PAD_HAS_PENDING_EVENTS: 1076 * @pad: a #GstPad 1077 * 1078 * Check if the given @pad has pending events. This is used internally by 1079 * GStreamer. 1080 */ 1081 #define GST_PAD_HAS_PENDING_EVENTS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PENDING_EVENTS)) 1082 /** 1083 * GST_PAD_IS_FIXED_CAPS: 1084 * @pad: a #GstPad 1085 * 1086 * Check if the given @pad is using fixed caps, which means that 1087 * once the caps are set on the @pad, the caps query function will 1088 * only return those caps. See gst_pad_use_fixed_caps(). 1089 */ 1090 #define GST_PAD_IS_FIXED_CAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FIXED_CAPS)) 1091 /** 1092 * GST_PAD_NEEDS_PARENT: 1093 * @pad: a #GstPad 1094 * 1095 * Check if there is a parent object before calling into the @pad callbacks. 1096 * This is used internally by GStreamer. 1097 */ 1098 #define GST_PAD_NEEDS_PARENT(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_PARENT)) 1099 /** 1100 * GST_PAD_IS_PROXY_CAPS: 1101 * @pad: a #GstPad 1102 * 1103 * Check if the given @pad is set to proxy caps. This means that the default 1104 * event and query handler will forward all events and queries to the 1105 * internally linked @pads instead of discarding them. 1106 */ 1107 #define GST_PAD_IS_PROXY_CAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_CAPS)) 1108 /** 1109 * GST_PAD_SET_PROXY_CAPS: 1110 * @pad: a #GstPad 1111 * 1112 * Set @pad to proxy caps, so that all caps-related events and queries are 1113 * proxied down- or upstream to the other side of the element automatically. 1114 * Set this if the element always outputs data in the exact same format as it 1115 * receives as input. This is just for convenience to avoid implementing some 1116 * standard event and query handling code in an element. 1117 */ 1118 #define GST_PAD_SET_PROXY_CAPS(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_CAPS)) 1119 /** 1120 * GST_PAD_UNSET_PROXY_CAPS: 1121 * @pad: a #GstPad 1122 * 1123 * Unset proxy caps flag. 1124 */ 1125 #define GST_PAD_UNSET_PROXY_CAPS(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_CAPS)) 1126 /** 1127 * GST_PAD_IS_PROXY_ALLOCATION: 1128 * @pad: a #GstPad 1129 * 1130 * Check if the given @pad is set as proxy allocation which means 1131 * that the default query handler will forward allocation queries to the 1132 * internally linked @pads instead of discarding them. 1133 */ 1134 #define GST_PAD_IS_PROXY_ALLOCATION(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_ALLOCATION)) 1135 /** 1136 * GST_PAD_SET_PROXY_ALLOCATION: 1137 * @pad: a #GstPad 1138 * 1139 * Set @pad to proxy allocation queries, which means that the default query 1140 * handler will forward allocation queries to the internally linked @pads 1141 * instead of discarding them. 1142 * Set this if the element always outputs data in the exact same format as it 1143 * receives as input. This is just for convenience to avoid implementing some 1144 * standard query handling code in an element. 1145 */ 1146 #define GST_PAD_SET_PROXY_ALLOCATION(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_ALLOCATION)) 1147 /** 1148 * GST_PAD_UNSET_PROXY_ALLOCATION: 1149 * @pad: a #GstPad 1150 * 1151 * Unset proxy allocation flag. 1152 */ 1153 #define GST_PAD_UNSET_PROXY_ALLOCATION(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_ALLOCATION)) 1154 /** 1155 * GST_PAD_IS_PROXY_SCHEDULING: 1156 * @pad: a #GstPad 1157 * 1158 * Check if the given @pad is set to proxy scheduling queries, which means that 1159 * the default query handler will forward scheduling queries to the internally 1160 * linked @pads instead of discarding them. 1161 */ 1162 #define GST_PAD_IS_PROXY_SCHEDULING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_SCHEDULING)) 1163 /** 1164 * GST_PAD_SET_PROXY_SCHEDULING: 1165 * @pad: a #GstPad 1166 * 1167 * Set @pad to proxy scheduling queries, which means that the default query 1168 * handler will forward scheduling queries to the internally linked @pads 1169 * instead of discarding them. You will usually want to handle scheduling 1170 * queries explicitly if your element supports multiple scheduling modes. 1171 */ 1172 #define GST_PAD_SET_PROXY_SCHEDULING(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_SCHEDULING)) 1173 /** 1174 * GST_PAD_UNSET_PROXY_SCHEDULING: 1175 * @pad: a #GstPad 1176 * 1177 * Unset proxy scheduling flag. 1178 */ 1179 #define GST_PAD_UNSET_PROXY_SCHEDULING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_SCHEDULING)) 1180 /** 1181 * GST_PAD_IS_ACCEPT_INTERSECT: 1182 * @pad: a #GstPad 1183 * 1184 * Check if the pad's accept intersect flag is set. The default accept-caps 1185 * handler will check if the caps intersect the query-caps result instead of 1186 * checking for a subset. This is interesting for parser elements that can 1187 * accept incompletely specified caps. 1188 */ 1189 #define GST_PAD_IS_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT)) 1190 /** 1191 * GST_PAD_SET_ACCEPT_INTERSECT: 1192 * @pad: a #GstPad 1193 * 1194 * Set @pad to by default accept caps by intersecting the result instead of 1195 * checking for a subset. This is interesting for parser elements that can 1196 * accept incompletely specified caps. 1197 */ 1198 #define GST_PAD_SET_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT)) 1199 /** 1200 * GST_PAD_UNSET_ACCEPT_INTERSECT: 1201 * @pad: a #GstPad 1202 * 1203 * Unset accept intersect flag. 1204 */ 1205 #define GST_PAD_UNSET_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT)) 1206 /** 1207 * GST_PAD_IS_ACCEPT_TEMPLATE: 1208 * @pad: a #GstPad 1209 * 1210 * Check if the pad's accept caps operation will use the pad template caps. 1211 * The default accept-caps will do a query caps to get the caps, which might 1212 * be querying downstream causing unnecessary overhead. It is recommended to 1213 * implement a proper accept-caps query handler or to use this flag to prevent 1214 * recursive accept-caps handling. 1215 * 1216 * Since: 1.6 1217 */ 1218 #define GST_PAD_IS_ACCEPT_TEMPLATE(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_ACCEPT_TEMPLATE)) 1219 /** 1220 * GST_PAD_SET_ACCEPT_TEMPLATE: 1221 * @pad: a #GstPad 1222 * 1223 * Set @pad to by default use the pad template caps to compare with 1224 * the accept caps instead of using a caps query result. 1225 * 1226 * Since: 1.6 1227 */ 1228 #define GST_PAD_SET_ACCEPT_TEMPLATE(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_ACCEPT_TEMPLATE)) 1229 /** 1230 * GST_PAD_UNSET_ACCEPT_TEMPLATE: 1231 * @pad: a #GstPad 1232 * 1233 * Unset accept template flag. 1234 * 1235 * Since: 1.6 1236 */ 1237 #define GST_PAD_UNSET_ACCEPT_TEMPLATE(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_ACCEPT_TEMPLATE)) 1238 /** 1239 * GST_PAD_GET_STREAM_LOCK: 1240 * @pad: a #GstPad 1241 * 1242 * Get the stream lock of @pad. The stream lock is protecting the 1243 * resources used in the data processing functions of @pad. Accessor 1244 * macro, use GST_PAD_STREAM_LOCK() and GST_PAD_STREAM_UNLOCK() instead 1245 * to take/release the pad's stream lock. 1246 */ 1247 #define GST_PAD_GET_STREAM_LOCK(pad) (&(GST_PAD_CAST(pad)->stream_rec_lock)) 1248 /** 1249 * GST_PAD_STREAM_LOCK: 1250 * @pad: a #GstPad 1251 * 1252 * Take the pad's stream lock. The stream lock is recursive and will be taken 1253 * when buffers or serialized downstream events are pushed on a pad. 1254 */ 1255 #define GST_PAD_STREAM_LOCK(pad) g_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad)) 1256 /** 1257 * GST_PAD_STREAM_TRYLOCK: 1258 * @pad: a #GstPad 1259 * 1260 * Try to take the pad's stream lock, and return %TRUE if the lock could be 1261 * taken, and otherwise %FALSE. 1262 */ 1263 #define GST_PAD_STREAM_TRYLOCK(pad) g_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad)) 1264 /** 1265 * GST_PAD_STREAM_UNLOCK: 1266 * @pad: a #GstPad 1267 * 1268 * Release the pad's stream lock. 1269 */ 1270 #define GST_PAD_STREAM_UNLOCK(pad) g_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad)) 1271 /** 1272 * GST_PAD_LAST_FLOW_RETURN: 1273 * @pad: a #GstPad 1274 * 1275 * Gets the last flow return on this pad 1276 * 1277 * Since: 1.4 1278 */ 1279 #define GST_PAD_LAST_FLOW_RETURN(pad) (GST_PAD_CAST(pad)->ABI.abi.last_flowret) 1280 1281 #define GST_PAD_BLOCK_GET_COND(pad) (&GST_PAD_CAST(pad)->block_cond) 1282 #define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad))) 1283 #define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad))) 1284 #define GST_PAD_BLOCK_BROADCAST(pad) (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad))) 1285 1286 GST_API 1287 GType gst_pad_get_type (void); 1288 1289 /* creating pads */ 1290 1291 GST_API 1292 GstPad* gst_pad_new (const gchar *name, GstPadDirection direction); 1293 1294 GST_API 1295 GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name); 1296 1297 GST_API 1298 GstPad* gst_pad_new_from_static_template (GstStaticPadTemplate *templ, const gchar *name); 1299 1300 1301 /** 1302 * gst_pad_get_name: 1303 * @pad: the pad to get the name from 1304 * 1305 * Get a copy of the name of the pad. g_free() after usage. 1306 * 1307 * MT safe. 1308 */ 1309 #define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad)) 1310 /** 1311 * gst_pad_get_parent: 1312 * @pad: the pad to get the parent of 1313 * 1314 * Get the parent of @pad. This function increases the refcount 1315 * of the parent object so you should gst_object_unref() it after usage. 1316 * Can return %NULL if the pad did not have a parent. 1317 * 1318 * MT safe. 1319 * 1320 * Returns: (nullable): the parent 1321 */ 1322 #define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad)) 1323 1324 GST_API 1325 GstPadDirection gst_pad_get_direction (GstPad *pad); 1326 1327 GST_API 1328 gboolean gst_pad_set_active (GstPad *pad, gboolean active); 1329 1330 GST_API 1331 gboolean gst_pad_is_active (GstPad *pad); 1332 1333 GST_API 1334 gboolean gst_pad_activate_mode (GstPad *pad, GstPadMode mode, 1335 gboolean active); 1336 GST_API 1337 gulong gst_pad_add_probe (GstPad *pad, 1338 GstPadProbeType mask, 1339 GstPadProbeCallback callback, 1340 gpointer user_data, 1341 GDestroyNotify destroy_data); 1342 GST_API 1343 void gst_pad_remove_probe (GstPad *pad, gulong id); 1344 1345 GST_API 1346 gboolean gst_pad_is_blocked (GstPad *pad); 1347 1348 GST_API 1349 gboolean gst_pad_is_blocking (GstPad *pad); 1350 1351 GST_API 1352 void gst_pad_mark_reconfigure (GstPad *pad); 1353 1354 GST_API 1355 gboolean gst_pad_needs_reconfigure (GstPad *pad); 1356 1357 GST_API 1358 gboolean gst_pad_check_reconfigure (GstPad *pad); 1359 1360 GST_API 1361 void gst_pad_set_element_private (GstPad *pad, gpointer priv); 1362 1363 GST_API 1364 gpointer gst_pad_get_element_private (GstPad *pad); 1365 1366 GST_API 1367 GstPadTemplate* gst_pad_get_pad_template (GstPad *pad); 1368 1369 GST_API 1370 GstFlowReturn gst_pad_store_sticky_event (GstPad *pad, GstEvent *event); 1371 1372 GST_API 1373 GstEvent* gst_pad_get_sticky_event (GstPad *pad, GstEventType event_type, 1374 guint idx); 1375 1376 GST_API 1377 void gst_pad_sticky_events_foreach (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data); 1378 1379 /* data passing setup functions */ 1380 1381 GST_API 1382 void gst_pad_set_activate_function_full (GstPad *pad, 1383 GstPadActivateFunction activate, 1384 gpointer user_data, 1385 GDestroyNotify notify); 1386 GST_API 1387 void gst_pad_set_activatemode_function_full (GstPad *pad, 1388 GstPadActivateModeFunction activatemode, 1389 gpointer user_data, 1390 GDestroyNotify notify); 1391 /* data passing functions */ 1392 1393 GST_API 1394 void gst_pad_set_chain_function_full (GstPad *pad, 1395 GstPadChainFunction chain, 1396 gpointer user_data, 1397 GDestroyNotify notify); 1398 GST_API 1399 void gst_pad_set_chain_list_function_full (GstPad *pad, 1400 GstPadChainListFunction chainlist, 1401 gpointer user_data, 1402 GDestroyNotify notify); 1403 GST_API 1404 void gst_pad_set_getrange_function_full (GstPad *pad, 1405 GstPadGetRangeFunction get, 1406 gpointer user_data, 1407 GDestroyNotify notify); 1408 GST_API 1409 void gst_pad_set_event_function_full (GstPad *pad, 1410 GstPadEventFunction event, 1411 gpointer user_data, 1412 GDestroyNotify notify); 1413 GST_API 1414 void gst_pad_set_event_full_function_full (GstPad *pad, 1415 GstPadEventFullFunction event, 1416 gpointer user_data, 1417 GDestroyNotify notify); 1418 1419 #define gst_pad_set_activate_function(p,f) gst_pad_set_activate_function_full((p),(f),NULL,NULL) 1420 #define gst_pad_set_activatemode_function(p,f) gst_pad_set_activatemode_function_full((p),(f),NULL,NULL) 1421 #define gst_pad_set_chain_function(p,f) gst_pad_set_chain_function_full((p),(f),NULL,NULL) 1422 #define gst_pad_set_chain_list_function(p,f) gst_pad_set_chain_list_function_full((p),(f),NULL,NULL) 1423 #define gst_pad_set_getrange_function(p,f) gst_pad_set_getrange_function_full((p),(f),NULL,NULL) 1424 #define gst_pad_set_event_function(p,f) gst_pad_set_event_function_full((p),(f),NULL,NULL) 1425 #define gst_pad_set_event_full_function(p,f) gst_pad_set_event_full_function_full((p),(f),NULL,NULL) 1426 1427 /* pad links */ 1428 1429 GST_API 1430 void gst_pad_set_link_function_full (GstPad *pad, 1431 GstPadLinkFunction link, 1432 gpointer user_data, 1433 GDestroyNotify notify); 1434 GST_API 1435 void gst_pad_set_unlink_function_full (GstPad *pad, 1436 GstPadUnlinkFunction unlink, 1437 gpointer user_data, 1438 GDestroyNotify notify); 1439 1440 #define gst_pad_set_link_function(p,f) gst_pad_set_link_function_full((p),(f),NULL,NULL) 1441 #define gst_pad_set_unlink_function(p,f) gst_pad_set_unlink_function_full((p),(f),NULL,NULL) 1442 1443 GST_API 1444 gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad); 1445 1446 GST_API 1447 GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad); 1448 1449 GST_API 1450 GstPadLinkReturn gst_pad_link_full (GstPad *srcpad, GstPad *sinkpad, GstPadLinkCheck flags); 1451 1452 GST_API 1453 gboolean gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad); 1454 1455 GST_API 1456 gboolean gst_pad_is_linked (GstPad *pad); 1457 1458 GST_API 1459 GstPad* gst_pad_get_peer (GstPad *pad); 1460 1461 GST_API 1462 GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); 1463 1464 /* capsnego function for linked/unlinked pads */ 1465 1466 GST_API 1467 GstCaps * gst_pad_get_current_caps (GstPad * pad); 1468 1469 GST_API 1470 gboolean gst_pad_has_current_caps (GstPad * pad); 1471 1472 /* capsnego for linked pads */ 1473 1474 GST_API 1475 GstCaps * gst_pad_get_allowed_caps (GstPad * pad); 1476 1477 /* pad offsets */ 1478 1479 GST_API 1480 gint64 gst_pad_get_offset (GstPad *pad); 1481 1482 GST_API 1483 void gst_pad_set_offset (GstPad *pad, gint64 offset); 1484 1485 /* data passing functions to peer */ 1486 1487 GST_API 1488 GstFlowReturn gst_pad_push (GstPad *pad, GstBuffer *buffer); 1489 1490 GST_API 1491 GstFlowReturn gst_pad_push_list (GstPad *pad, GstBufferList *list); 1492 1493 GST_API 1494 GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size, 1495 GstBuffer **buffer); 1496 GST_API 1497 gboolean gst_pad_push_event (GstPad *pad, GstEvent *event); 1498 1499 GST_API 1500 gboolean gst_pad_event_default (GstPad *pad, GstObject *parent, 1501 GstEvent *event); 1502 GST_API 1503 GstFlowReturn gst_pad_get_last_flow_return (GstPad *pad); 1504 1505 /* data passing functions on pad */ 1506 1507 GST_API 1508 GstFlowReturn gst_pad_chain (GstPad *pad, GstBuffer *buffer); 1509 1510 GST_API 1511 GstFlowReturn gst_pad_chain_list (GstPad *pad, GstBufferList *list); 1512 1513 GST_API 1514 GstFlowReturn gst_pad_get_range (GstPad *pad, guint64 offset, guint size, 1515 GstBuffer **buffer); 1516 GST_API 1517 gboolean gst_pad_send_event (GstPad *pad, GstEvent *event); 1518 1519 /* pad tasks */ 1520 1521 GST_API 1522 gboolean gst_pad_start_task (GstPad *pad, GstTaskFunction func, 1523 gpointer user_data, GDestroyNotify notify); 1524 GST_API 1525 gboolean gst_pad_pause_task (GstPad *pad); 1526 1527 GST_API 1528 gboolean gst_pad_stop_task (GstPad *pad); 1529 1530 GST_API 1531 GstTaskState gst_pad_get_task_state (GstPad *pad); 1532 1533 /* internal links */ 1534 1535 GST_API 1536 void gst_pad_set_iterate_internal_links_function_full (GstPad * pad, 1537 GstPadIterIntLinkFunction iterintlink, 1538 gpointer user_data, 1539 GDestroyNotify notify); 1540 1541 GST_API 1542 GstIterator * gst_pad_iterate_internal_links (GstPad * pad); 1543 1544 GST_API 1545 GstIterator * gst_pad_iterate_internal_links_default (GstPad * pad, GstObject *parent); 1546 1547 #define gst_pad_set_iterate_internal_links_function(p,f) gst_pad_set_iterate_internal_links_function_full((p),(f),NULL,NULL) 1548 1549 GST_API 1550 GstPad * gst_pad_get_single_internal_link (GstPad * pad); 1551 1552 /* generic query function */ 1553 1554 GST_API 1555 gboolean gst_pad_query (GstPad *pad, GstQuery *query); 1556 1557 GST_API 1558 gboolean gst_pad_peer_query (GstPad *pad, GstQuery *query); 1559 1560 GST_API 1561 void gst_pad_set_query_function_full (GstPad *pad, GstPadQueryFunction query, 1562 gpointer user_data, 1563 GDestroyNotify notify); 1564 GST_API 1565 gboolean gst_pad_query_default (GstPad *pad, GstObject *parent, 1566 GstQuery *query); 1567 1568 #define gst_pad_set_query_function(p,f) gst_pad_set_query_function_full((p),(f),NULL,NULL) 1569 1570 /* misc helper functions */ 1571 1572 GST_API 1573 gboolean gst_pad_forward (GstPad *pad, GstPadForwardFunction forward, 1574 gpointer user_data); 1575 1576 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPad, gst_object_unref) 1577 1578 G_END_DECLS 1579 1580 #endif /* __GST_PAD_H__ */ 1581