QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Protected Member Functions
QGst::Utils::ApplicationSink Class Reference

#include <QGst/Utils/ApplicationSink>

List of all members.

Public Member Functions

ElementPtr element () const
void setElement (const ElementPtr &appsink)
CapsPtr caps () const
void setCaps (const CapsPtr &caps)
bool isEos () const
uint maxBuffers () const
void setMaxBuffers (uint maxbuffers)
bool dropEnabled () const
void enableDrop (bool enable)
BufferPtr pullPreroll ()
BufferPtr pullBuffer ()
BufferListPtr pullBufferList ()

Protected Member Functions

virtual void eos ()
virtual FlowReturn newPreroll ()
virtual FlowReturn newBuffer ()
virtual FlowReturn newBufferList ()

Detailed Description

Helper class for using a GstAppSink.

Appsink is a sink plugin that supports many different methods for making the application get a handle on the GStreamer data in a pipeline. Unlike most GStreamer elements, appsink provides external API functions. This class exports those API functions in the bindings and makes it easy to implement a custom sink.

The normal way of retrieving buffers from appsink is by using the pullBuffer() and pullPreroll() methods. These methods block until a buffer becomes available in the sink or when the sink is shut down or reaches EOS.

Appsink will internally use a queue to collect buffers from the streaming thread. If the application is not pulling buffers fast enough, this queue will consume a lot of memory over time. setMaxBuffers() can be used to limit the queue size. enableDrop() controls whether the streaming thread blocks or if older buffers are dropped when the maximum queue size is reached. Note that blocking the streaming thread can negatively affect real-time performance and should be avoided.

If a blocking behaviour is not desirable, you can subclass this class and implement the newPreroll(), newBuffer() and newBufferList() which will be called to notify you when a new buffer is available.

setCaps() can be used to control the formats that appsink can receive. This property can contain non-fixed caps. The format of the pulled buffers can be obtained by getting the buffer caps.

If one of the pullPreroll() or pullBuffer() methods return NULL, the appsink is stopped or in the EOS state. You can check for the EOS state with isEos(). The eos() virtual method can also be reimplemented to be informed when the EOS state is reached to avoid polling.

The actuall appsink element can be retrieved with element() and set with setElement(). It is not necessary to set an appsink, as this class will create one as soon as it is needed.

Note:
It is not necessary to use this class in order to use GstAppSink. GstAppSink also provides signals and properties that fully substitute the functionality of this class.
See also:
ApplicationSource
Examples:
examples/appsink-src/main.cpp.

Definition at line 66 of file applicationsink.h.


Member Function Documentation

Returns:
the appsink element

Definition at line 116 of file applicationsink.cpp.

Sets the appsink element that will be used by this class

Definition at line 122 of file applicationsink.cpp.

Returns:
the caps that the appsink is configured to accept

Definition at line 130 of file applicationsink.cpp.

Sets the caps that appsink will accept

Definition at line 139 of file applicationsink.cpp.

Returns:
true if the appsink has received an End Of Stream event or if it is not in PAUSED or PLAYING state.

Definition at line 147 of file applicationsink.cpp.

Returns:
the maximum number of buffers that the sink is configured to hold in its internal queue. 0 means unlimited.

Definition at line 152 of file applicationsink.cpp.

Sets the maximum number of buffers that the sink will hold in its queue. After this amount of buffers are queued in appsink, any more buffers will block upstream elements until a buffer is pulled from appsink.

Definition at line 157 of file applicationsink.cpp.

Returns:
whether the sink is configured to drop old buffers when the maximum amount of queued buffers is reached.

Definition at line 165 of file applicationsink.cpp.

Enables dropping old buffers when the maximum amount of queued buffers is reached.

Definition at line 170 of file applicationsink.cpp.

Get the last preroll buffer in appsink. This was the buffer that caused the appsink to preroll in the PAUSED state. This buffer can be pulled many times and remains available to the application even after EOS.

This function is typically used when dealing with a pipeline in the PAUSED state. Calling this function after doing a seek will give the buffer right after the seek position.

Note that the preroll buffer will also be returned as the first buffer when calling pullBuffer().

If an EOS event was received before any buffers, this function returns a null BufferPtr. Use isEos() to check for the EOS condition.

This function blocks until a preroll buffer or EOS is received or the appsink element is set to the READY/NULL state.

Definition at line 178 of file applicationsink.cpp.

This function blocks until a buffer or EOS becomes available or the appsink element is set to the READY/NULL state.

This function will only return buffers when the appsink is in the PLAYING state. All rendered buffers will be put in a queue so that the application can pull buffers at its own rate. Note that when the application does not pull buffers fast enough, the queued buffers could consume a lot of memory, especially when dealing with raw video frames.

If an EOS event was received before any buffers, this function returns a null BufferPtr. Use isEos() to check for the EOS condition.

Examples:
examples/appsink-src/main.cpp.

Definition at line 187 of file applicationsink.cpp.

This function blocks until a buffer list or EOS becomes available or the appsink element is set to the READY/NULL state.

This function will only return buffer lists when the appsink is in the PLAYING state. All rendered buffer lists will be put in a queue so that the application can pull buffer lists at its own rate. Note that when the application does not pull buffer lists fast enough, the queued buffer lists could consume a lot of memory, especially when dealing with raw video frames.

If an EOS event was received before any buffer lists, this function returns a null BufferListPtr. Use isEos() to check for the EOS condition.

Definition at line 196 of file applicationsink.cpp.

void QGst::Utils::ApplicationSink::eos ( ) [protected, virtual]

Called when the end-of-stream has been reached.

Note:
This function is called from the steaming thread.
Examples:
examples/appsink-src/main.cpp.

Definition at line 205 of file applicationsink.cpp.

FlowReturn QGst::Utils::ApplicationSink::newPreroll ( ) [protected, virtual]

Called when a new preroll buffer is available. The new preroll buffer can be retrieved with pullPreroll() either from this function or from any other thread.

Note:
This function is called from the steaming thread.

Definition at line 209 of file applicationsink.cpp.

FlowReturn QGst::Utils::ApplicationSink::newBuffer ( ) [protected, virtual]

Called when a new buffer is available. The new buffer can be retrieved with pullBuffer() either from this function or from any other thread.

Note:
This function is called from the steaming thread.
Examples:
examples/appsink-src/main.cpp.

Definition at line 214 of file applicationsink.cpp.

FlowReturn QGst::Utils::ApplicationSink::newBufferList ( ) [protected, virtual]

Called when a new buffer list is available. The new buffer list can be retrieved with pullBufferList() either from this function or from any other thread.

Note:
This function is called from the steaming thread.

Definition at line 219 of file applicationsink.cpp.


The documentation for this class was generated from the following files: