Top |
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.
Collectpads are created with gst_collect_pads_new()
. A callback should then
be installed with gst_collect_pads_set_function()
.
Pads are added to the collection with gst_collect_pads_add_pad()
/
gst_collect_pads_remove_pad()
. The pad
has to be a sinkpad. The chain and event functions of the pad are
overridden. The element_private of the pad is used to store
private information for the collectpads.
For each pad, data is queued in the _chain function or by performing a pull_range.
When data is queued on all pads in waiting mode, the callback function is called.
Data can be dequeued from the pad with the gst_collect_pads_pop()
method.
One can peek at the data with the gst_collect_pads_peek()
function.
These functions will return NULL
if the pad received an EOS event. When all
pads return NULL
from a gst_collect_pads_peek()
, the element can emit an EOS
event itself.
Data can also be dequeued in byte units using the gst_collect_pads_available()
,
gst_collect_pads_read_buffer()
and gst_collect_pads_flush()
calls.
Elements should call gst_collect_pads_start()
and gst_collect_pads_stop()
in
their state change functions to start and stop the processing of the collectpads.
The gst_collect_pads_stop()
call should be called before calling the parent
element state change function in the PAUSED_TO_READY state change to ensure
no pad is blocked and the element can finish streaming.
gst_collect_pads_set_waiting()
sets a pad to waiting or non-waiting mode.
CollectPads element is not waiting for data to be collected on non-waiting pads.
Thus these pads may but need not have data when the callback is called.
All pads are in waiting mode by default.
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.
GstFlowReturn (*GstCollectPadsBufferFunction) (GstCollectPads *pads
,GstCollectData *data
,GstBuffer *buffer
,gpointer user_data
);
A function that will be called when a (considered oldest) buffer can be muxed.
If all pads have reached EOS, this function is called with NULL
buffer
and NULL
data
.
pads |
the GstCollectPads that triggered the callback |
|
data |
the GstCollectData of pad that has received the buffer |
|
buffer |
the GstBuffer. |
[transfer full] |
user_data |
user data passed to |
GstFlowReturn (*GstCollectPadsClipFunction) (GstCollectPads *pads
,GstCollectData *data
,GstBuffer *inbuffer
,GstBuffer **outbuffer
,gpointer user_data
);
A function that will be called when inbuffer
is received on the pad managed
by data
in the collectpad object pads
.
The function should use the segment of data
and the negotiated media type on
the pad to perform clipping of inbuffer
.
This function takes ownership of inbuffer
and should output a buffer in
outbuffer
or return NULL
in outbuffer
if the buffer should be dropped.
gint (*GstCollectPadsCompareFunction) (GstCollectPads *pads
,GstCollectData *data1
,GstClockTime timestamp1
,GstCollectData *data2
,GstClockTime timestamp2
,gpointer user_data
);
A function for comparing two timestamps of buffers or newsegments collected on one pad.
pads |
the GstCollectPads that is comparing the timestamps |
|
data1 |
the first GstCollectData |
|
timestamp1 |
the first timestamp |
|
data2 |
the second GstCollectData |
|
timestamp2 |
the second timestamp |
|
user_data |
user data passed to |
gboolean (*GstCollectPadsEventFunction) (GstCollectPads *pads
,GstCollectData *pad
,GstEvent *event
,gpointer user_data
);
A function that will be called while processing an event. It takes
ownership of the event and is responsible for chaining up (to
gst_collect_pads_event_default()
) or dropping events (such typical cases
being handled by the default handler).
pads |
the GstCollectPads that triggered the callback |
|
pad |
the GstPad that received an event |
|
event |
the GstEvent received |
|
user_data |
user data passed to |
void (*GstCollectPadsFlushFunction) (GstCollectPads *pads
,gpointer user_data
);
A function that will be called while processing a flushing seek event.
The function should flush any internal state of the element and the state of
all the pads. It should clear only the state not directly managed by the
pads
object. It is therefore not necessary to call
gst_collect_pads_set_flushing nor gst_collect_pads_clear from this function.
Since 1.4
gboolean (*GstCollectPadsQueryFunction) (GstCollectPads *pads
,GstCollectData *pad
,GstQuery *query
,gpointer user_data
);
A function that will be called while processing a query. It takes
ownership of the query and is responsible for chaining up (to
events downstream (with gst_pad_event_default()
).
pads |
the GstCollectPads that triggered the callback |
|
pad |
the GstPad that received an event |
|
query |
the GstEvent received |
|
user_data |
user data passed to |
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 |
#define GST_COLLECT_PADS_STATE(data) (((GstCollectData *) data)->state)
A flags word containing GstCollectPadsStateFlags flags set on this collected pad.
#define GST_COLLECT_PADS_STATE_IS_SET(data,flag) !!(GST_COLLECT_PADS_STATE (data) & flag)
Gives the status of a specific flag on a collected pad.
#define GST_COLLECT_PADS_STATE_SET(data,flag) (GST_COLLECT_PADS_STATE (data) |= flag)
Sets a state flag on a collected pad.
#define GST_COLLECT_PADS_STATE_UNSET(data,flag) (GST_COLLECT_PADS_STATE (data) &= ~(flag))
Clears a state flag on a collected pad.
#define GST_COLLECT_PADS_GET_STREAM_LOCK(pads) (&((GstCollectPads *)pads)->stream_lock)
Get the stream lock of pads
. The stream lock is used to coordinate and
serialize execution among the various streams being collected, and in
protecting the resources used to accomplish this.
#define GST_COLLECT_PADS_STREAM_LOCK(pads) g_rec_mutex_lock(GST_COLLECT_PADS_GET_STREAM_LOCK (pads))
Lock the stream lock of pads
.
#define GST_COLLECT_PADS_STREAM_UNLOCK(pads) g_rec_mutex_unlock(GST_COLLECT_PADS_GET_STREAM_LOCK (pads))
Unlock the stream lock of pads
.
GstCollectPads *
gst_collect_pads_new (void
);
Create a new instance of GstCollectPads.
MT safe.
GstCollectData * gst_collect_pads_add_pad (GstCollectPads *pads
,GstPad *pad
,guint size
,GstCollectDataDestroyNotify destroy_notify
,gboolean lock
);
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.
Keeping a pad locked in waiting state is only relevant when using the default collection algorithm (providing the oldest buffer). It ensures a buffer must be available on this pad for a collection to take place. This is of typical use to a muxer element where non-subtitle streams should always be in waiting state, e.g. to assure that caps information is available on all these streams when initial headers have to be written.
The pad will be automatically activated in push mode when pads
is
started.
MT safe.
pads |
the collectpads 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. |
[scope async] |
lock |
whether to lock this pad in usual waiting state |
a new GstCollectData to identify the
new pad. Or NULL
if wrong parameters are supplied.
[nullable][transfer none]
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.
void
gst_collect_pads_start (GstCollectPads *pads
);
Starts the processing of data in the collect_pads.
MT safe.
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.
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
STREAM_LOCK held, such as
in the callback.
MT safe.
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
STREAM_LOCK held, such as
in the callback.
MT safe.
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
STREAM_LOCK held, such as in the callback
handler.
MT safe.
GstBuffer * gst_collect_pads_pop (GstCollectPads *pads
,GstCollectData *data
);
Pop the buffer currently queued in data
. This function
should be called with the pads
STREAM_LOCK held, such as in the callback
handler.
MT safe.
The buffer in data
or NULL
if no buffer was
queued. You should unref the buffer after usage.
[transfer full]
GstBuffer * gst_collect_pads_read_buffer (GstCollectPads *pads
,GstCollectData *data
,guint size
);
Get a subbuffer of size
bytes from the given pad data
.
This function should be called with pads
STREAM_LOCK held, such as in the
callback.
MT safe.
A sub buffer. 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]
GstBuffer * gst_collect_pads_take_buffer (GstCollectPads *pads
,GstCollectData *data
,guint size
);
Get a subbuffer of size
bytes from the given pad data
. Flushes the amount
of read bytes.
This function should be called with pads
STREAM_LOCK held, such as in the
callback.
MT safe.
A sub buffer. 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.
GstFlowReturn gst_collect_pads_clip_running_time (GstCollectPads *pads
,GstCollectData *cdata
,GstBuffer *buf
,GstBuffer **outbuf
,gpointer user_data
);
Convenience clipping function that converts incoming buffer's timestamp to running time, or clips the buffer if outside configured segment.
gboolean gst_collect_pads_query_default (GstCollectPads *pads
,GstCollectData *data
,GstQuery *query
,gboolean discard
);
Default GstCollectPads query handling that elements should always chain up to to ensure proper operation. Element might however indicate query should not be forwarded downstream.
gboolean gst_collect_pads_event_default (GstCollectPads *pads
,GstCollectData *data
,GstEvent *event
,gboolean discard
);
Default GstCollectPads event handling that elements should always chain up to to ensure proper operation. Element might however indicate event should not be forwarded downstream.
gboolean gst_collect_pads_src_event_default (GstCollectPads *pads
,GstPad *pad
,GstEvent *event
);
Default GstCollectPads event handling for the src pad of elements. Elements can chain up to this to let flushing seek event handling be done by GstCollectPads.
pads |
the GstCollectPads to use |
|
pad |
src GstPad that received the event |
|
event |
event being processed |
Since 1.4
void gst_collect_pads_set_buffer_function (GstCollectPads *pads
,GstCollectPadsBufferFunction func
,gpointer user_data
);
Set the callback function and user data that will be called with
the oldest buffer when all pads have been collected, or NULL
on EOS.
If a buffer is passed, the callback owns a reference and must unref
it.
MT safe.
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.
void gst_collect_pads_set_compare_function (GstCollectPads *pads
,GstCollectPadsCompareFunction func
,gpointer user_data
);
Set the timestamp comparison function.
MT safe.
void gst_collect_pads_set_event_function (GstCollectPads *pads
,GstCollectPadsEventFunction func
,gpointer user_data
);
Set the event callback function and user data that will be called when
collectpads has received an event originating from one of the collected
pads. If the event being processed is a serialized one, this callback is
called with pads
STREAM_LOCK held, otherwise not. As this lock should be
held when calling a number of CollectPads functions, it should be acquired
if so (unusually) needed.
MT safe.
void gst_collect_pads_set_flush_function (GstCollectPads *pads
,GstCollectPadsFlushFunction func
,gpointer user_data
);
Install a flush function that is called when the internal state of all pads should be flushed as part of flushing seek handling. See GstCollectPadsFlushFunction for more info.
pads |
the collectpads to use |
|
func |
flush function to install |
|
user_data |
user data to pass to |
Since 1.4
void gst_collect_pads_set_query_function (GstCollectPads *pads
,GstCollectPadsQueryFunction func
,gpointer user_data
);
Set the query callback function and user data that will be called after
collectpads has received a query originating from one of the collected
pads. If the query being processed is a serialized one, this callback is
called with pads
STREAM_LOCK held, otherwise not. As this lock should be
held when calling a number of CollectPads functions, it should be acquired
if so (unusually) needed.
MT safe.
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.
Caller must ensure that downstream streaming (thread) is not blocked,
e.g. by sending a FLUSH_START downstream.
MT safe.
void gst_collect_pads_set_function (GstCollectPads *pads
,GstCollectPadsFunction func
,gpointer user_data
);
CollectPads provides a default collection algorithm that will determine
the oldest buffer available on all of its pads, and then delegate
to a configured callback.
However, if circumstances are more complicated and/or more control
is desired, this sets a callback that will be invoked instead when
all the pads added to the collection have buffers queued.
Evidently, this callback is not compatible with
gst_collect_pads_set_buffer_function()
callback.
If this callback is set, the former will be unset.
MT safe.
void gst_collect_pads_set_waiting (GstCollectPads *pads
,GstCollectData *data
,gboolean waiting
);
Sets a pad to waiting or non-waiting mode, if at least this pad has not been created with locked waiting state, in which case nothing happens.
This function should be called with pads
STREAM_LOCK held, such as
in the callback.
MT safe.
struct GstCollectPads { GSList *data; /* list of CollectData items */ };
Collectpads object.
GSList * |
GList of GstCollectData managed by this GstCollectPads. |
[element-type GstBase.CollectData] |
struct GstCollectData { /* with STREAM_LOCK of @collect */ GstCollectPads *collect; GstPad *pad; GstBuffer *buffer; guint pos; GstSegment segment; };
Structure used by the collect_pads.
GstCollectPads * |
owner GstCollectPads |
|
GstPad * |
GstPad managed by this data |
|
GstBuffer * |
currently queued buffer. |
|
guint |
position in the buffer |
|
GstSegment |
last segment received. |
Set if collectdata's pad is EOS. |
||
Set if collectdata's pad is flushing. |
||
Set if collectdata's pad received a new_segment event. |
||
Set if collectdata's pad must be waited for when collecting. |
||
Set collectdata's pad WAITING state must not be changed. GstCollectPadsStateFlags indicate private state of a collectdata('s pad). |