Class TypeFindFactory
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.gobject.TypeInstance
org.gnome.gobject.GObject
org.gnome.gobject.InitiallyUnowned
org.freedesktop.gstreamer.gst.GstObject
org.freedesktop.gstreamer.gst.PluginFeature
org.freedesktop.gstreamer.gst.TypeFindFactory
- All Implemented Interfaces:
Proxy
These functions allow querying information about registered typefind functions. How to create and register these functions is described in the section "Writing typefind functions".
The following example shows how to write a very simple typefinder that identifies the given data. You can get quite a bit more complicated than that though.
typedef struct {
guint8 *data;
guint size;
guint probability;
GstCaps *data;
} MyTypeFind;
static void
my_peek (gpointer data, gint64 offset, guint size)
{
MyTypeFind *find = (MyTypeFind *) data;
if (offset >= 0 && offset + size <= find->size) {
return find->data + offset;
}
return NULL;
}
static void
my_suggest (gpointer data, guint probability, GstCaps *caps)
{
MyTypeFind *find = (MyTypeFind *) data;
if (probability > find->probability) {
find->probability = probability;
gst_caps_replace (&find->caps, caps);
}
}
static GstCaps *
find_type (guint8 *data, guint size)
{
GList *walk, *type_list;
MyTypeFind find = {data, size, 0, NULL};
GstTypeFind gst_find = {my_peek, my_suggest, &find, };
walk = type_list = gst_type_find_factory_get_list ();
while (walk) {
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data);
walk = g_list_next (walk)
gst_type_find_factory_call_function (factory, &gst_find);
}
g_list_free (type_list);
return find.caps;
};
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTypeFindFactory.Builder<B extends TypeFindFactory.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class PluginFeature
PluginFeature.PluginFeature$Impl, PluginFeature.PluginFeatureClassNested classes/interfaces inherited from class GstObject
GstObject.DeepNotifyCallback, GstObject.Object$Impl, GstObject.ObjectClassNested classes/interfaces inherited from class InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class GObject
GObject.NotifyCallback -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new TypeFindFactory.TypeFindFactory(MemorySegment address) Create a TypeFindFactory instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected TypeFindFactoryasParent()Return this instance as if it were its parent type.static TypeFindFactory.Builder<? extends TypeFindFactory.Builder> builder()ATypeFindFactory.Builderobject constructs aTypeFindFactorywith the specified properties.voidcallFunction(TypeFind find) Calls theGstTypeFindFunctionassociated with this factory.@Nullable CapsgetCaps()Gets theGstCapsassociated with a typefind factory.@Nullable String @Nullable []Gets the extensions associated with aGstTypeFindFactory.static List<TypeFindFactory> getList()Gets the list of all registered typefind factories.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the TypeFindFactory class.booleanCheck whether the factory has a typefind function.Methods inherited from class PluginFeature
checkVersion, getPlugin, getPluginName, getRank, listCopy, listDebug, listFree, load, rankCompareFunc, setRankMethods inherited from class GstObject
addControlBinding, checkUniqueness, deepNotify, defaultDeepNotify, defaultError, emitDeepNotify, getControlBinding, getControlRate, getGValueArray, getName, getParent, getPathString, getValue, getValueArray, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, onDeepNotify, ref, refSink, removeControlBinding, replace, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setName, setParent, suggestNextSync, syncValues, unparent, unrefMethods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
TypeFindFactory
Create a TypeFindFactory instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
TypeFindFactory
public TypeFindFactory()Create a new TypeFindFactory.
-
-
Method Details
-
getType
Get the GType of the TypeFindFactory class.- Returns:
- the GType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code.- Overrides:
asParentin classPluginFeature- Returns:
- the instance as if it were its parent type
-
getList
Gets the list of all registered typefind factories. You must free the list using gst_plugin_feature_list_free().
The returned factories are sorted by highest rank first, and then by factory name.
Free-function: gst_plugin_feature_list_free
- Returns:
- the list of all
registered
GstTypeFindFactory.
-
callFunction
Calls theGstTypeFindFunctionassociated with this factory.- Parameters:
find- a properly setupGstTypeFindentry. The get_data and suggest_type members must be set.
-
getCaps
Gets theGstCapsassociated with a typefind factory.- Returns:
- the
GstCapsassociated with this factory
-
getExtensions
Gets the extensions associated with aGstTypeFindFactory. The returned array should not be changed. If you need to change stuff in it, you should copy it using g_strdupv(). This function may returnnullto indicate a 0-length list.- Returns:
- a
null-terminated array of extensions associated with this factory
-
hasFunction
public boolean hasFunction()Check whether the factory has a typefind function. Typefind factories without typefind functions are a last-effort fallback mechanism to e.g. assume a certain media type based on the file extension.- Returns:
trueif the factory has a typefind functions set, otherwisefalse
-
builder
ATypeFindFactory.Builderobject constructs aTypeFindFactorywith the specified properties. Use the variousset...()methods to set properties, and finish construction withTypeFindFactory.Builder.build().- Returns:
- the builder object
-