GstBase.CollectPads¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
data |
r |
|
|
object |
r |
||
stream_lock |
r |
Class Details¶
- class GstBase.CollectPads(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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
GstBase.CollectPads.new
(). A callback should then be installed withGstBase.CollectPads.set_function
().Pads are added to the collection with
GstBase.CollectPads.add_pad
()/GstBase.CollectPads.remove_pad
(). The pad has to be a sinkpad. When added, the chain, event and query 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
GstBase.CollectPads.pop
() method. One can peek at the data with theGstBase.CollectPads.peek
() function. These functions will returnNone
if the pad received an EOS event. When all pads returnNone
from aGstBase.CollectPads.peek
(), the element can emit an EOS event itself.Data can also be dequeued in byte units using the
GstBase.CollectPads.available
(),GstBase.CollectPads.read_buffer
() andGstBase.CollectPads.flush
() calls.Elements should call
GstBase.CollectPads.start
() andGstBase.CollectPads.stop
() in their state change functions to start and stop the processing of the collectpads. TheGstBase.CollectPads.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.GstBase.CollectPads.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.
- classmethod new()[source]¶
- Returns:
a new
GstBase.CollectPads
, orNone
in case of an error.- Return type:
Create a new instance of
GstBase.CollectPads
.MT safe.
- add_pad(pad, size, destroy_notify, lock)[source]¶
- Parameters:
pad (
Gst.Pad
) – the pad to addsize (
int
) – the size of the returnedGstBase.CollectData
structuredestroy_notify (
GstBase.CollectDataDestroyNotify
) – function to be called before the returnedGstBase.CollectData
structure is freedlock (
bool
) – whether to lock this pad in usual waiting state
- Returns:
a new
GstBase.CollectData
to identify the new pad. OrNone
if wrong parameters are supplied.- Return type:
Add a pad to the collection of collect pads. The pad has to be a sinkpad. The refcount of the pad is incremented. Use
GstBase.CollectPads.remove_pad
() to remove the pad from the collection again.You specify a size for the returned
GstBase.CollectData
structure so that you can use it to store additional information.You can also specify a
GstBase.CollectDataDestroyNotify
that will be called just before theGstBase.CollectData
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 self is started.
MT safe.
- available()[source]¶
- Returns:
The maximum number of bytes queued on all pads. This function returns 0 if a pad has no queued buffer.
- Return type:
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 self STREAM_LOCK held, such as in the callback.
MT safe.
- clip_running_time(cdata, buf, user_data)[source]¶
- Parameters:
cdata (
GstBase.CollectData
) – collect data of corresponding padbuf (
Gst.Buffer
) – buffer being clipped
- Returns:
- outbuf:
output buffer with running time, or
None
if clipped
- Return type:
(
Gst.FlowReturn
, outbuf:Gst.Buffer
)
Convenience clipping function that converts incoming buffer’s timestamp to running time, or clips the buffer if outside configured segment.
Since 1.6, this clipping function also sets the DTS parameter of the
GstBase.CollectData
structure. This version of the running time DTS can be negative.GObject.G_MININT64
is used to indicate invalid value.
- event_default(data, event, discard)[source]¶
- Parameters:
data (
GstBase.CollectData
) – collect data of corresponding padevent (
Gst.Event
) – event being processeddiscard (
bool
) – process but do not send event downstream
- Return type:
Default
GstBase.CollectPads
event handling that elements should always chain up to to ensure proper operation. Element might however indicate event should not be forwarded downstream.
- flush(data, size)[source]¶
- Parameters:
data (
GstBase.CollectData
) – the data to usesize (
int
) – 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.
- Return type:
Flush size bytes from the pad data.
This function should be called with self STREAM_LOCK held, such as in the callback.
MT safe.
- peek(data)[source]¶
- Parameters:
data (
GstBase.CollectData
) – the data to use- Returns:
The buffer in data or
None
if no buffer is queued. should unref the buffer after usage.- Return type:
Gst.Buffer
orNone
Peek at the buffer currently queued in data. This function should be called with the self STREAM_LOCK held, such as in the callback handler.
MT safe.
- pop(data)[source]¶
- Parameters:
data (
GstBase.CollectData
) – the data to use- Returns:
The buffer in data or
None
if no buffer was queued. You should unref the buffer after usage.- Return type:
Gst.Buffer
orNone
Pop the buffer currently queued in data. This function should be called with the self STREAM_LOCK held, such as in the callback handler.
MT safe.
- query_default(data, query, discard)[source]¶
- Parameters:
data (
GstBase.CollectData
) – collect data of corresponding padquery (
Gst.Query
) – query being processeddiscard (
bool
) – process but do not send event downstream
- Return type:
Default
GstBase.CollectPads
query handling that elements should always chain up to to ensure proper operation. Element might however indicate query should not be forwarded downstream.
- read_buffer(data, size)[source]¶
- Parameters:
data (
GstBase.CollectData
) – the data to usesize (
int
) – the number of bytes to read
- Returns:
A sub buffer. The size of the buffer can be less that requested. A return of
None
signals that the pad is end-of-stream. Unref the buffer after use.- Return type:
Gst.Buffer
orNone
Get a subbuffer of size bytes from the given pad data.
This function should be called with self STREAM_LOCK held, such as in the callback.
MT safe.
- remove_pad(pad)[source]¶
- Parameters:
pad (
Gst.Pad
) – the pad to remove- Returns:
True
if the pad could be removed.- Return type:
Remove a pad from the collection of collect pads. This function will also free the
GstBase.CollectData
and all the resources that were allocated withGstBase.CollectPads.add_pad
().The pad will be deactivated automatically when self is stopped.
MT safe.
- set_buffer_function(func, *user_data)[source]¶
- Parameters:
func (
GstBase.CollectPadsBufferFunction
) – the function to setuser_data (
object
orNone
) – user data passed to the function
Set the callback function and user data that will be called with the oldest buffer when all pads have been collected, or
None
on EOS. If a buffer is passed, the callback owns a reference and must unref it.MT safe.
- set_clip_function(clipfunc, *user_data)[source]¶
- Parameters:
clipfunc (
GstBase.CollectPadsClipFunction
) – clip function to install
Install a clipping function that is called right after a buffer is received on a pad managed by self. See
GstBase.CollectPadsClipFunction
for more info.
- set_compare_function(func, *user_data)[source]¶
- Parameters:
func (
GstBase.CollectPadsCompareFunction
) – the function to setuser_data (
object
orNone
) – user data passed to the function
Set the timestamp comparison function.
MT safe.
- set_event_function(func, *user_data)[source]¶
- Parameters:
func (
GstBase.CollectPadsEventFunction
) – the function to setuser_data (
object
orNone
) – user data passed to the function
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 self 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.
- set_flush_function(func, *user_data)[source]¶
- Parameters:
func (
GstBase.CollectPadsFlushFunction
) – flush function to install
Install a flush function that is called when the internal state of all pads should be flushed as part of flushing seek handling. See
GstBase.CollectPadsFlushFunction
for more info.New in version 1.4.
- set_flushing(flushing)[source]¶
- Parameters:
flushing (
bool
) – desired state of the pads
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 flushingFalse
makes self accept data again. Caller must ensure that downstream streaming (thread) is not blocked, e.g. by sending a FLUSH_START downstream.MT safe.
- set_function(func, *user_data)[source]¶
- Parameters:
func (
GstBase.CollectPadsFunction
) – the function to setuser_data (
object
orNone
) – user data passed to the function
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
GstBase.CollectPads.set_buffer_function
() callback. If this callback is set, the former will be unset.MT safe.
- set_query_function(func, *user_data)[source]¶
- Parameters:
func (
GstBase.CollectPadsQueryFunction
) – the function to setuser_data (
object
orNone
) – user data passed to the function
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 self 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.
- set_waiting(data, waiting)[source]¶
- Parameters:
data (
GstBase.CollectData
) – the data to usewaiting (
bool
) – boolean indicating whether this pad should operate in waiting or non-waiting mode
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 self STREAM_LOCK held, such as in the callback.
MT safe.
- src_event_default(pad, event)[source]¶
- Parameters:
- Return type:
Default
GstBase.CollectPads
event handling for the src pad of elements. Elements can chain up to this to let flushing seek event handling be done byGstBase.CollectPads
.New in version 1.4.
- stop()[source]¶
Stops the processing of data in the collect_pads. this function will also unblock any blocking operations.
MT safe.
- take_buffer(data, size)[source]¶
- Parameters:
data (
GstBase.CollectData
) – the data to usesize (
int
) – the number of bytes to read
- Returns:
A sub buffer. The size of the buffer can be less that requested. A return of
None
signals that the pad is end-of-stream. Unref the buffer after use.- Return type:
Gst.Buffer
orNone
Get a subbuffer of size bytes from the given pad data. Flushes the amount of read bytes.
This function should be called with self STREAM_LOCK held, such as in the callback.
MT safe.