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 sample from appsink is by using the pullSample() and pullPreroll() methods. These methods block until a sample becomes available in the sink or when the sink is shut down or reaches EOS.
Appsink will internally use a queue to collect samples from the streaming thread. If the application is not pulling samples 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 samples 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(), newSample() and newBufferList() which will be called to notify you when a new sample 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 samples can be obtained by getting the sample caps.
If one of the pullPreroll() or pullSample() 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.
- 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
Definition at line 66 of file applicationsink.h.
Get the last preroll sample in appsink. This was the sample that caused the appsink to preroll in the PAUSED state. This sample 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 sample right after the seek position.
Note that the preroll sample will also be returned as the first sample when calling pullSample().
If an EOS event was received before any samples, this function returns a null SamplePtr. Use isEos() to check for the EOS condition.
This function blocks until a preroll sample or EOS is received or the appsink element is set to the READY/NULL state.
Definition at line 169 of file applicationsink.cpp.