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

#include <QGst/Utils/ApplicationSource>

List of all members.

Public Member Functions

ElementPtr element () const
void setElement (const ElementPtr &appsrc)
CapsPtr caps () const
void setCaps (const CapsPtr &caps)
quint64 minLatency () const
quint64 maxLatency () const
void setLatency (quint64 min, quint64 max)
qint64 size () const
void setSize (qint64 size)
AppStreamType streamType () const
void setStreamType (AppStreamType type)
quint64 maxBytes () const
void setMaxBytes (quint64 max)
bool blockEnabled () const
void enableBlock (bool enable)
bool isLive () const
void setLive (bool islive)
uint minPercent () const
void setMinPercent (uint min)
Format format () const
void setFormat (Format f)
FlowReturn pushBuffer (const BufferPtr &buffer)
FlowReturn endOfStream ()

Protected Member Functions

virtual void needData (uint length)
virtual void enoughData ()
virtual bool seekData (quint64 offset)

Detailed Description

Helper class for using a GstAppSrc.

Appsrc is an element that can be used by applications to insert data into a GStreamer pipeline. Unlike most GStreamer elements, appsrc provides external API functions. This class exports those API functions in the bindings and makes it easy to implement a custom source.

Before operating appsrc, the caps() must be set to a fixed caps describing the format of the data that will be pushed with appsrc. An exception to this is when pushing buffers with unknown caps, in which case no caps should be set. This is typically true of file-like sources that push raw byte buffers.

The main way of handing data to the appsrc element is by calling the pushBuffer() method. This will put the buffer onto a queue from which appsrc will read from in its streaming thread. It is important to note that data transport will not happen from the thread that performed the pushBuffer() call.

maxBytes() controls how much data can be queued in appsrc before appsrc considers the queue full. A filled internal queue will always cause enoughData() to be called, which signals the application that it should stop pushing data into appsrc. Use setBlock() to cause appsrc to block the pushBuffer() method until free data becomes available again.

When the internal queue is running out of data, the needData() function is called, which signals the application that it should start pushing more data into appsrc.

In addition to the needData() and enoughData() functions, appsrc can also call the seekData() function when streamMode() is set to AppStreamTypeSeekable or AppStreamTypeRandomAccess. The seekData() argument will contain the new desired position in the stream expressed in the unit set with setFormat(). After seekData() has been called, the application should push buffers from the new position.

Appsrc can operate in two different ways:

In all modes, the size() should contain the total stream size in bytes. Setting the size is mandatory in the AppStreamTypeRandomAccess mode. For the AppStreamTypeStream and AppStreamTypeSeekable modes, setting the size is optional but recommended.

When the application is finished pushing data into appsrc, it should call endOfStream(). After this call, no more buffers can be pushed into appsrc until a flushing seek happened or the state of the appsrc has gone through READY.

The actuall appsrc element can be retrieved with element() and set with setElement(). It is not necessary to set an appsrc, 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 GstAppSrc. GstAppSrc also provides signals and properties that fully substitute the functionality of this class.
See also:
ApplicationSink
Examples:
examples/appsink-src/main.cpp.

Definition at line 89 of file applicationsource.h.


Member Function Documentation

Returns:
the appsrc element

Definition at line 105 of file applicationsource.cpp.

Sets the appsrc element that will be used by this class

Definition at line 111 of file applicationsource.cpp.

Returns:
the caps that the appsrc is configured to produce

Definition at line 119 of file applicationsource.cpp.

Sets the capabilities of this source. After calling this method, this appsrc will only be able to produce buffers with these capabilities. caps must be fixed and the caps on the buffers must match the caps or left NULL.

Definition at line 128 of file applicationsource.cpp.

Returns:
the minimum latency of this element

Definition at line 136 of file applicationsource.cpp.

Returns:
the maximum latency of this element

Definition at line 145 of file applicationsource.cpp.

void QGst::Utils::ApplicationSource::setLatency ( quint64  min,
quint64  max 
)

Configure the minimum and maximum latency. If min is set to -1, the default latency calculations for pseudo-live sources will be used.

Definition at line 154 of file applicationsource.cpp.

Returns:
the size of the stream in bytes. A value of -1 means that the size is not known.

Definition at line 162 of file applicationsource.cpp.

Set the size of the stream in bytes. A value of -1 means that the size is not known.

Definition at line 167 of file applicationsource.cpp.

Returns:
the stream type of this appsrc

Definition at line 175 of file applicationsource.cpp.

void QGst::Utils::ApplicationSource::setStreamType ( AppStreamType  type)

Set the stream type on appsrc. For seekable streams, the seekData() method must be reimplemented.

Definition at line 181 of file applicationsource.cpp.

Returns:
the maximum amount of bytes that can be queued in appsrc

Definition at line 189 of file applicationsource.cpp.

Set the maximum amount of bytes that can be queued in appsrc. After the maximum amount of bytes are queued, the enoughData() method of this class will be called.

Definition at line 194 of file applicationsource.cpp.

Returns:
true if appsrc is configured to block any calls to pushBuffer() when the maximum amount of bytes are queued.

Definition at line 202 of file applicationsource.cpp.

Enables or disables blocking calls to pushBuffer() when the maximum amount of bytes are queued.

Definition at line 207 of file applicationsource.cpp.

Returns:
true if the appsrc is configured to act as a live source

Definition at line 215 of file applicationsource.cpp.

Sets whether appsrc will act as a live source

Definition at line 220 of file applicationsource.cpp.

Returns:
the minimum percent of maxBytes() that when reached, needData() will be called

Definition at line 228 of file applicationsource.cpp.

Sets the minimum percent of maxBytes() that when reached, needData() will be called

Definition at line 233 of file applicationsource.cpp.

FlowReturn QGst::Utils::ApplicationSource::pushBuffer ( const BufferPtr buffer)

Adds a buffer to the queue of buffers that the appsrc element will push to its source pad. When the block property is TRUE, this function can block until free space becomes available in the queue.

Returns:
FlowOk when the buffer was successfuly queued, FlowWrongState when appsrc is not PAUSED or PLAYING or FlowUnexpected when EOS occured.

Definition at line 254 of file applicationsource.cpp.

Indicates to the appsrc element that the last buffer queued in the element is the last buffer of the stream.

Returns:
FlowOk when the EOS was successfuly queued or FlowWrongState when appsrc is not PAUSED or PLAYING.

Definition at line 263 of file applicationsource.cpp.

void QGst::Utils::ApplicationSource::needData ( uint  length) [protected, virtual]

Called when the appsrc needs more data. A buffer or EOS should be pushed to appsrc from this thread or another thread. length is just a hint and when it is set to -1, any number of bytes can be pushed into appsrc.

Definition at line 272 of file applicationsource.cpp.

void QGst::Utils::ApplicationSource::enoughData ( ) [protected, virtual]

Called when appsrc has enough data. It is recommended that the application stops calling pushBuffer() until the needData() method is called again to avoid excessive buffer queueing.

Definition at line 277 of file applicationsource.cpp.

bool QGst::Utils::ApplicationSource::seekData ( quint64  offset) [protected, virtual]

Called when a seek should be performed to the offset. The next pushBuffer() should produce buffers from the new offset. This method is only called for seekable stream types.

Definition at line 281 of file applicationsource.cpp.


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