Each page has one title and it looks better like that
3.2 KiB
QtGStreamer vs C GStreamer
QtGStreamer is designed to mirror the C GStreamer API as closely as possible. There are, of course, minor differences. They are documented here.
Common Functions
C GStreamer | QtGStreamer |
---|---|
gst_element_factory_make() |
QGst::ElementFactory::make(const QString &factoryName, const char *elementName=NULL) |
gst_parse_bin_from_description() |
QGst::Bin::fromDescription(const QString &description, BinFromDescriptionOption ghostUnlinkedPads=Ghost) |
gst_caps_from_string() |
|
g_signal_connect() |
QGlib::connect(GObject* instance, const char *detailedSignal, T *receiver, R(T::*)(Args...) slot, ConnectFlags flags) |
Naming Convention
QtGStreamer follows a strict naming policy to help make cross referencing easier:
Namespaces
The "G" namespace (GObject
, GValue
, etc...) is referred to as
"QGlib".
The "Gst" namespace (GstObject
, GstElement
, etc...) is referred to
as "QGst".
Class Names
Class names should be the same as their G* equivalents, with the
namespace prefix removed. For example, "GstObject
" becomes
"QGst::Object
", "GParamSpec
" becomes "QGlib::ParamSpec
", etc...
Method Names
In general the method names should be the same as the GStreamer ones, with the g[st]_<class> prefix removed and converted to camel case.
For example,
gboolean gst_caps_is_emtpy(const GstCaps *caps);
becomes:
namespace QGst {
class Caps {
bool isEmpty() const;
}
}
There are cases where this may not be followed:
- Properties. Most property getters have a "get" prefix, for
example,
gst_object_get_name()
. In QtGStreamer the "get" prefix is omitted, so this becomes justname()
. - Overloaded members. In C there is no possibility to have two
methods with the same name, so overloaded members usually have some
extra suffix, like "_full". For example,
g_object_set_data()
andg_object_set_data_full()
. In C++ we just add a method with the same name, or put optional parameters in the existing method. - Other cases where the glib/gstreamer method name doesn't make much
sense. For example,
gst_element_is_locked_state()
. That doesn't make sense in english, as "sate" is the subject and should go before the verb "is". So, it becomesstateIsLocked()
.
Reference Counting
Reference counting is handled the same way as Qt does. There is no need
to call g_object_ref()`` and g_object_unref()
.
Access to GStreamer Elements
QtGStreamer provides access to the underlying C objects, in case you need them. This is accessible with a simple cast:
ElementPtr qgstElement = QGst::ElementFactory::make("playbin");
GstElement* gstElement = GST_ELEMENT(qgstElement);