GstCollectPads

GstCollectPads — manages a set of pads that operate in collect mode

Synopsis

#include <gst/base/gstcollectpads.h>

struct              GstCollectData;
struct              GstCollectPads;
GstFlowReturn       (*GstCollectPadsFunction)           (GstCollectPads *pads,
                                                         gpointer user_data);
GstBuffer *         (*GstCollectPadsClipFunction)       (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         GstBuffer *buffer,
                                                         gpointer user_data);
void                (*GstCollectDataDestroyNotify)      (GstCollectData *data);
GstCollectPads *    gst_collect_pads_new                (void);
void                gst_collect_pads_set_function       (GstCollectPads *pads,
                                                         GstCollectPadsFunction func,
                                                         gpointer user_data);
void                gst_collect_pads_set_clip_function  (GstCollectPads *pads,
                                                         GstCollectPadsClipFunction clipfunc,
                                                         gpointer user_data);
GstCollectData *    gst_collect_pads_add_pad            (GstCollectPads *pads,
                                                         GstPad *pad,
                                                         guint size);
GstCollectData *    gst_collect_pads_add_pad_full       (GstCollectPads *pads,
                                                         GstPad *pad,
                                                         guint size,
                                                         GstCollectDataDestroyNotify destroy_notify);
gboolean            gst_collect_pads_remove_pad         (GstCollectPads *pads,
                                                         GstPad *pad);
gboolean            gst_collect_pads_is_active          (GstCollectPads *pads,
                                                         GstPad *pad);
GstFlowReturn       gst_collect_pads_collect            (GstCollectPads *pads);
GstFlowReturn       gst_collect_pads_collect_range      (GstCollectPads *pads,
                                                         guint64 offset,
                                                         guint length);
void                gst_collect_pads_start              (GstCollectPads *pads);
void                gst_collect_pads_stop               (GstCollectPads *pads);
void                gst_collect_pads_set_flushing       (GstCollectPads *pads,
                                                         gboolean flushing);
GstBuffer *         gst_collect_pads_peek               (GstCollectPads *pads,
                                                         GstCollectData *data);
GstBuffer *         gst_collect_pads_pop                (GstCollectPads *pads,
                                                         GstCollectData *data);
guint               gst_collect_pads_available          (GstCollectPads *pads);
guint               gst_collect_pads_read               (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint8 **bytes,
                                                         guint size);
GstBuffer *         gst_collect_pads_read_buffer        (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint size);
GstBuffer *         gst_collect_pads_take_buffer        (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint size);
guint               gst_collect_pads_flush              (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint size);

Object Hierarchy

  GObject
   +----GstObject
         +----GstCollectPads

Description

Manages a set of pads that operate in collect mode. This means that control is given to the manager of this object when all pads have data.

Last reviewed on 2006-05-10 (0.10.6)

Details

struct GstCollectData

struct GstCollectData {
  /* with LOCK of @collect */
  GstCollectPads        *collect;
  GstPad                *pad;
  GstBuffer             *buffer;
  guint                  pos;
  GstSegment             segment;
};

Structure used by the collect_pads.

GstCollectPads *collect;

owner GstCollectPads

GstPad *pad;

GstPad managed by this data

GstBuffer *buffer;

currently queued buffer.

guint pos;

position in the buffer

GstSegment segment;

last segment received.

struct GstCollectPads

struct GstCollectPads {
  GSList        *data;                  /* list of CollectData items */
};

Collectpads object. Note that data is only reliable for iterating the list of GstCollectData when inside the GstCollectPadsFunction callback.

GSList *data;

GList of GstCollectData managed by this GstCollectPads.

GstCollectPadsFunction ()

GstFlowReturn       (*GstCollectPadsFunction)           (GstCollectPads *pads,
                                                         gpointer user_data);

A function that will be called when all pads have received data.

pads :

the GstCollectPads that triggered the callback

user_data :

user data passed to gst_collect_pads_set_function()

Returns :

GST_FLOW_OK for success

GstCollectPadsClipFunction ()

GstBuffer *         (*GstCollectPadsClipFunction)       (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         GstBuffer *buffer,
                                                         gpointer user_data);

A function that will be called when buffer is received on the pad managed by data in the collecpad object pads.

The function should use the segment of data and the negotiated media type on the pad to perform clipping of buffer.

This function takes ownership of buffer.

pads :

a GstCollectPads

data :

a GstCollectData

buffer :

a GstBuffer

user_data :

user data

Returns :

a GstBuffer that contains the clipped data of buffer or NULL when the buffer has been clipped completely.

Since 0.10.26


GstCollectDataDestroyNotify ()

void                (*GstCollectDataDestroyNotify)      (GstCollectData *data);

A function that will be called when the GstCollectData will be freed. It is passed the pointer to the structure and should free any custom memory and resources allocated for it.

data :

the GstCollectData that will be freed

Since 0.10.12


gst_collect_pads_new ()

GstCollectPads *    gst_collect_pads_new                (void);

Create a new instance of GstCollectPads.

MT safe.

Returns :

a new GstCollectPads, or NULL in case of an error. [transfer full]

gst_collect_pads_set_function ()

void                gst_collect_pads_set_function       (GstCollectPads *pads,
                                                         GstCollectPadsFunction func,
                                                         gpointer user_data);

Set the callback function and user data that will be called when all the pads added to the collection have buffers queued.

MT safe.

pads :

the collectspads to use

func :

the function to set

user_data :

user data passed to the function. [closure]

gst_collect_pads_set_clip_function ()

void                gst_collect_pads_set_clip_function  (GstCollectPads *pads,
                                                         GstCollectPadsClipFunction clipfunc,
                                                         gpointer user_data);

Install a clipping function that is called right after a buffer is received on a pad managed by pads. See GstCollectPadsClipFunction for more info.

pads :

the collectspads to use

clipfunc :

clip function to install

user_data :

user data to pass to clip_func. [closure]

Since 0.10.26


gst_collect_pads_add_pad ()

GstCollectData *    gst_collect_pads_add_pad            (GstCollectPads *pads,
                                                         GstPad *pad,
                                                         guint size);

Add a pad to the collection of collect pads. The pad has to be a sinkpad. The refcount of the pad is incremented. Use gst_collect_pads_remove_pad() to remove the pad from the collection again.

This function will override the chain and event functions of the pad along with the element_private data, which is used to store private information for the collectpads.

You specify a size for the returned GstCollectData structure so that you can use it to store additional information.

The pad will be automatically activated in push mode when pads is started.

This function calls gst_collect_pads_add_pad_full() passing a value of NULL for destroy_notify.

MT safe.

pads :

the collectspads to use

pad :

the pad to add. [transfer none]

size :

the size of the returned GstCollectData structure

Returns :

a new GstCollectData to identify the new pad. Or NULL if wrong parameters are supplied.

gst_collect_pads_add_pad_full ()

GstCollectData *    gst_collect_pads_add_pad_full       (GstCollectPads *pads,
                                                         GstPad *pad,
                                                         guint size,
                                                         GstCollectDataDestroyNotify destroy_notify);

Add a pad to the collection of collect pads. The pad has to be a sinkpad. The refcount of the pad is incremented. Use gst_collect_pads_remove_pad() to remove the pad from the collection again.

You specify a size for the returned GstCollectData structure so that you can use it to store additional information.

You can also specify a GstCollectDataDestroyNotify that will be called just before the GstCollectData structure is freed. It is passed the pointer to the structure and should free any custom memory and resources allocated for it.

The pad will be automatically activated in push mode when pads is started.

MT safe.

pads :

the collectspads to use

pad :

the pad to add. [transfer none]

size :

the size of the returned GstCollectData structure

destroy_notify :

function to be called before the returned GstCollectData structure is freed

Returns :

a new GstCollectData to identify the new pad. Or NULL if wrong parameters are supplied.

Since 0.10.12


gst_collect_pads_remove_pad ()

gboolean            gst_collect_pads_remove_pad         (GstCollectPads *pads,
                                                         GstPad *pad);

Remove a pad from the collection of collect pads. This function will also free the GstCollectData and all the resources that were allocated with gst_collect_pads_add_pad().

The pad will be deactivated automatically when pads is stopped.

MT safe.

pads :

the collectspads to use

pad :

the pad to remove. [transfer none]

Returns :

TRUE if the pad could be removed.

gst_collect_pads_is_active ()

gboolean            gst_collect_pads_is_active          (GstCollectPads *pads,
                                                         GstPad *pad);

Check if a pad is active.

This function is currently not implemented.

MT safe.

pads :

the collectspads to use. [transfer none]

pad :

the pad to check

Returns :

TRUE if the pad is active.

gst_collect_pads_collect ()

GstFlowReturn       gst_collect_pads_collect            (GstCollectPads *pads);

Collect data on all pads. This function is usually called from a GstTask function in an element.

This function is currently not implemented.

MT safe.

pads :

the collectspads to use

Returns :

GstFlowReturn of the operation.

gst_collect_pads_collect_range ()

GstFlowReturn       gst_collect_pads_collect_range      (GstCollectPads *pads,
                                                         guint64 offset,
                                                         guint length);

Collect data with offset and length on all pads. This function is typically called in the getrange function of an element.

This function is currently not implemented.

MT safe.

pads :

the collectspads to use

offset :

the offset to collect

length :

the length to collect

Returns :

GstFlowReturn of the operation.

gst_collect_pads_start ()

void                gst_collect_pads_start              (GstCollectPads *pads);

Starts the processing of data in the collect_pads.

MT safe.

pads :

the collectspads to use

gst_collect_pads_stop ()

void                gst_collect_pads_stop               (GstCollectPads *pads);

Stops the processing of data in the collect_pads. this function will also unblock any blocking operations.

MT safe.

pads :

the collectspads to use

gst_collect_pads_set_flushing ()

void                gst_collect_pads_set_flushing       (GstCollectPads *pads,
                                                         gboolean flushing);

Change the flushing state of all the pads in the collection. No pad is able to accept anymore data when flushing is TRUE. Calling this function with flushing FALSE makes pads accept data again.

MT safe.

pads :

the collectspads to use

flushing :

desired state of the pads

Since 0.10.7.


gst_collect_pads_peek ()

GstBuffer *         gst_collect_pads_peek               (GstCollectPads *pads,
                                                         GstCollectData *data);

Peek at the buffer currently queued in data. This function should be called with the pads LOCK held, such as in the callback handler.

MT safe.

pads :

the collectspads to peek

data :

the data to use

Returns :

The buffer in data or NULL if no buffer is queued. should unref the buffer after usage. [transfer full]

gst_collect_pads_pop ()

GstBuffer *         gst_collect_pads_pop                (GstCollectPads *pads,
                                                         GstCollectData *data);

Pop the buffer currently queued in data. This function should be called with the pads LOCK held, such as in the callback handler.

Free-function: gst_buffer_unref

MT safe.

pads :

the collectspads to pop

data :

the data to use

Returns :

The buffer in data or NULL if no buffer was queued. You should unref the buffer after usage. [transfer full]

gst_collect_pads_available ()

guint               gst_collect_pads_available          (GstCollectPads *pads);

Query how much bytes can be read from each queued buffer. This means that the result of this call is the maximum number of bytes that can be read from each of the pads.

This function should be called with pads LOCK held, such as in the callback.

MT safe.

pads :

the collectspads to query

Returns :

The maximum number of bytes queued on all pads. This function returns 0 if a pad has no queued buffer.

gst_collect_pads_read ()

guint               gst_collect_pads_read               (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint8 **bytes,
                                                         guint size);

Get a pointer in bytes where size bytes can be read from the given pad data.

This function should be called with pads LOCK held, such as in the callback.

MT safe.

pads :

the collectspads to query

data :

the data to use

bytes :

a pointer to a byte array. [out][transfer none][array length=size]

size :

the number of bytes to read

Returns :

The number of bytes available for consumption in the memory pointed to by bytes. This can be less than size and is 0 if the pad is end-of-stream.

gst_collect_pads_read_buffer ()

GstBuffer *         gst_collect_pads_read_buffer        (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint size);

Get a buffer of size bytes from the given pad data.

This function should be called with pads LOCK held, such as in the callback.

Free-function: gst_buffer_unref

pads :

the collectspads to query

data :

the data to use

size :

the number of bytes to read

Returns :

a GstBuffer. The size of the buffer can be less that requested. A return of NULL signals that the pad is end-of-stream. Unref the buffer with gst_buffer_unref() after use. MT safe. [transfer full]

Since 0.10.18


gst_collect_pads_take_buffer ()

GstBuffer *         gst_collect_pads_take_buffer        (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint size);

Get a buffer of size bytes from the given pad data. Flushes the amount of read bytes.

This function should be called with pads LOCK held, such as in the callback.

Free-function: gst_buffer_unref

MT safe.

pads :

the collectspads to query

data :

the data to use

size :

the number of bytes to read

Returns :

a GstBuffer. The size of the buffer can be less that requested. A return of NULL signals that the pad is end-of-stream. Unref the buffer after use. [transfer full]

Since 0.10.18


gst_collect_pads_flush ()

guint               gst_collect_pads_flush              (GstCollectPads *pads,
                                                         GstCollectData *data,
                                                         guint size);

Flush size bytes from the pad data.

This function should be called with pads LOCK held, such as in the callback.

MT safe.

pads :

the collectspads to query

data :

the data to use

size :

the number of bytes to flush

Returns :

The number of bytes flushed. This can be less than size and is 0 if the pad was end-of-stream.