GstCollectPads

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

Synopsis


#include <gst/base/gstcollectpads.h>


            GstCollectPads;
            GstCollectPadsClass;
GstFlowReturn (*GstCollectPadsFunction)     (GstCollectPads *pads,
                                             gpointer user_data);
GstCollectPads* gst_collectpads_new         (void);
void        gst_collectpads_set_function    (GstCollectPads *pads,
                                             GstCollectPadsFunction func,
                                             gpointer user_data);
GstCollectData* gst_collectpads_add_pad     (GstCollectPads *pads,
                                             GstPad *pad,
                                             guint size);
gboolean    gst_collectpads_remove_pad      (GstCollectPads *pads,
                                             GstPad *pad);
gboolean    gst_collectpads_is_active       (GstCollectPads *pads,
                                             GstPad *pad);
GstFlowReturn gst_collectpads_collect       (GstCollectPads *pads);
GstFlowReturn gst_collectpads_collect_range (GstCollectPads *pads,
                                             guint64 offset,
                                             guint length);
void        gst_collectpads_start           (GstCollectPads *pads);
void        gst_collectpads_stop            (GstCollectPads *pads);
GstBuffer*  gst_collectpads_peek            (GstCollectPads *pads,
                                             GstCollectData *data);
GstBuffer*  gst_collectpads_pop             (GstCollectPads *pads,
                                             GstCollectData *data);
guint       gst_collectpads_available       (GstCollectPads *pads);
guint       gst_collectpads_read            (GstCollectPads *pads,
                                             GstCollectData *data,
                                             guint8 **bytes,
                                             guint size);
guint       gst_collectpads_flush           (GstCollectPads *pads,
                                             GstCollectData *data,
                                             guint size);
#define     GST_COLLECTPADS_BROADCAST       (pads)
#define     GST_COLLECTPADS_GET_COND        (pads)
#define     GST_COLLECTPADS_SIGNAL          (pads)
#define     GST_COLLECTPADS_WAIT            (pads)


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.

  • Pads are added to the collection with add/remove_pad. The pad has to be a sinkpad. The chain function of the pad is overridden. The element_private of the pad is used to store private information.

  • For each pad, data is queued in the chain function or by performing a pull_range.

  • When data is queued on all pads, a callback function is called.

  • Data can be dequeued from the pad with the _pop() method. One can _peek() at the data with the peek function.

  • Data can also be dequeued with the available/read/flush calls.

Details

GstCollectPads

typedef struct {
  GSList	*data;			/* GstCollectData in this collection */
  guint32	 cookie;

  GCond		*cond;			/* to signal removal of data */
} GstCollectPads;


GstCollectPadsClass

typedef struct {
  GstObjectClass parent_class;
} GstCollectPadsClass;


GstCollectPadsFunction ()

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

pads :
user_data :
Returns :

gst_collectpads_new ()

GstCollectPads* gst_collectpads_new         (void);

Create a new instance of GstCollectsPads.

Returns : a new GstCollectPads, or NULL in case of an error. MT safe.

gst_collectpads_set_function ()

void        gst_collectpads_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

gst_collectpads_add_pad ()

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

Add a pad to the collection of collect pads. The pad has to be a sinkpad.

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

pads : the collectspads to use
pad : the pad to add
size : the size of the returned GstCollectData structure
Returns : a new GstCollectData to identify the new pad. Or NULL if wrong parameters are supplied. MT safe.

gst_collectpads_remove_pad ()

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

Remove a pad from the collection of collect pads.

pads : the collectspads to use
pad : the pad to remove
Returns : TRUE if the pad could be removed. MT safe.

gst_collectpads_is_active ()

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

Check if a pad is active.

pads : the collectspads to use
pad : the pad to check
Returns : TRUE if the pad is active. MT safe.

gst_collectpads_collect ()

GstFlowReturn gst_collectpads_collect       (GstCollectPads *pads);

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

pads : the collectspads to use
Returns : GstFlowReturn of the operation. MT safe.

gst_collectpads_collect_range ()

GstFlowReturn gst_collectpads_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.

pads : the collectspads to use
offset : the offset to collect
length : the length to collect
Returns : GstFlowReturn of the operation. MT safe.

gst_collectpads_start ()

void        gst_collectpads_start           (GstCollectPads *pads);

Starts the processing of data in the collectpads.

MT safe.

pads : the collectspads to use

gst_collectpads_stop ()

void        gst_collectpads_stop            (GstCollectPads *pads);

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

MT safe.

pads : the collectspads to use

gst_collectpads_peek ()

GstBuffer*  gst_collectpads_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.

pads : the collectspads to peek
data : the data to use
Returns : The buffer in data or NULL if no buffer is queued. You should unref the buffer after usage. MT safe.

gst_collectpads_pop ()

GstBuffer*  gst_collectpads_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.

pads : the collectspads to pop
data : the data to use
Returns : The buffer in data or NULL if no buffer was queued. The You should unref the buffer after usage. MT safe.

gst_collectpads_available ()

guint       gst_collectpads_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.

Returns: The maximum number of bytes queued on all pad. This function

pads : the collectspads to query
Returns : 0 if a pad has no queued buffer. MT safe.

gst_collectpads_read ()

guint       gst_collectpads_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.

pads : the collectspads to query
data : the data to use
bytes : a pointer to a byte array
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. MT safe.

gst_collectpads_flush ()

guint       gst_collectpads_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.

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. MT safe.

GST_COLLECTPADS_BROADCAST()

#define GST_COLLECTPADS_BROADCAST(pads)(g_cond_broadcast (GST_COLLECTPADS_GET_COND (pads)))

pads :

GST_COLLECTPADS_GET_COND()

#define GST_COLLECTPADS_GET_COND(pads) (((GstCollectPads *)pads)->cond)

pads :

GST_COLLECTPADS_SIGNAL()

#define GST_COLLECTPADS_SIGNAL(pads)   (g_cond_signal (GST_COLLECTPADS_GET_COND (pads)))

pads :

GST_COLLECTPADS_WAIT()

#define GST_COLLECTPADS_WAIT(pads)     (g_cond_wait (GST_COLLECTPADS_GET_COND (pads), GST_GET_LOCK (pads)))

pads :