Class ElementFactory

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class ElementFactory extends PluginFeature

GstElementFactory is used to create instances of elements. A GstElementFactory can be added to a GstPlugin as it is also a GstPluginFeature.

Use the gst_element_factory_find() and gst_element_factory_create() functions to create element instances or use gst_element_factory_make() as a convenient shortcut.

The following code example shows you how to create a GstFileSrc element.

Using an element factory

  #include <gst/gst.h>

  GstElement *src;
  GstElementFactory *srcfactory;

  gst_init (&argc, &argv);

  srcfactory = gst_element_factory_find ("filesrc");
  g_return_if_fail (srcfactory != NULL);
  src = gst_element_factory_create (srcfactory, "src");
  g_return_if_fail (src != NULL);
  ...
  • Constructor Details

    • ElementFactory

      public ElementFactory(MemorySegment address)
      Create a ElementFactory instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ElementFactory

      public ElementFactory()
      Create a new ElementFactory.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ElementFactory class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ElementFactory asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class PluginFeature
      Returns:
      the instance as if it were its parent type
    • find

      public static @Nullable ElementFactory find(String name)
      Search for an element factory of the given name. Refs the returned element factory; caller is responsible for unreffing.
      Parameters:
      name - name of factory to find
      Returns:
      GstElementFactory if found, null otherwise
    • listFilter

      public static List<ElementFactory> listFilter(List<ElementFactory> list, Caps caps, PadDirection direction, boolean subsetonly)

      Filter out all the elementfactories in list that can handle caps in the given direction.

      If subsetonly is true, then only the elements whose pads templates are a complete superset of caps will be returned. Else any element whose pad templates caps can intersect with caps will be returned.

      Parameters:
      list - a GList of GstElementFactory to filter
      caps - a GstCaps
      direction - a GstPadDirection to filter on
      subsetonly - whether to filter on caps subsets or not.
      Returns:
      a GList of GstElementFactory elements that match the given requisites. Use gst_plugin_feature_list_free after usage.
    • listGetElements

      public static List<ElementFactory> listGetElements(ElementFactoryListType type, Rank minrank)
      Get a list of factories that match the given type. Only elements with a rank greater or equal to minrank will be returned. The list of factories is returned by decreasing rank.
      Parameters:
      type - a GstElementFactoryListType
      minrank - Minimum rank
      Returns:
      a GList of GstElementFactory elements. Use gst_plugin_feature_list_free() after usage.
    • make

      public static @Nullable Element make(String factoryname, @Nullable String name)
      Create a new element of the type defined by the given element factory. If name is null, then the element will receive a guaranteed unique name, consisting of the element factory name and a number. If name is given, it will be given the name supplied.
      Parameters:
      factoryname - a named factory to instantiate
      name - name of new element, or null to automatically create a unique name
      Returns:
      new GstElement or null if unable to create element
    • makeFull

      public static @Nullable Element makeFull(String factoryname, @Nullable String first, Object... varargs)
      Create a new element of the type defined by the given element factory. The supplied list of properties, will be passed at object construction.
      Parameters:
      factoryname - a named factory to instantiate
      first - name of first property
      varargs - null terminated list of properties
      Returns:
      new GstElement or null if unable to create element
      Since:
      1.20
    • makeWithProperties

      public static @Nullable Element makeWithProperties(String factoryname, @Nullable String @Nullable [] names, @Nullable Value @Nullable [] values)
      Create a new element of the type defined by the given elementfactory. The supplied list of properties, will be passed at object construction.
      Parameters:
      factoryname - a named factory to instantiate
      names - array of properties names
      values - array of associated properties values
      Returns:
      new GstElement or null if the element couldn't be created
      Since:
      1.20
    • canSinkAllCaps

      public boolean canSinkAllCaps(Caps caps)
      Checks if the factory can sink all possible capabilities.
      Parameters:
      caps - the caps to check
      Returns:
      true if the caps are fully compatible.
    • canSinkAnyCaps

      public boolean canSinkAnyCaps(Caps caps)
      Checks if the factory can sink any possible capability.
      Parameters:
      caps - the caps to check
      Returns:
      true if the caps have a common subset.
    • canSrcAllCaps

      public boolean canSrcAllCaps(Caps caps)
      Checks if the factory can src all possible capabilities.
      Parameters:
      caps - the caps to check
      Returns:
      true if the caps are fully compatible.
    • canSrcAnyCaps

      public boolean canSrcAnyCaps(Caps caps)
      Checks if the factory can src any possible capability.
      Parameters:
      caps - the caps to check
      Returns:
      true if the caps have a common subset.
    • create

      public @Nullable Element create(@Nullable String name)
      Create a new element of the type defined by the given elementfactory. It will be given the name supplied, since all elements require a name as their first argument.
      Parameters:
      name - name of new element, or null to automatically create a unique name
      Returns:
      new GstElement or null if the element couldn't be created
    • createFull

      public @Nullable Element createFull(@Nullable String first, Object... varargs)
      Create a new element of the type defined by the given elementfactory. The supplied list of properties, will be passed at object construction.
      Parameters:
      first - name of the first property
      varargs - null terminated list of properties
      Returns:
      new GstElement or null if the element couldn't be created
      Since:
      1.20
    • createWithProperties

      public @Nullable Element createWithProperties(@Nullable String @Nullable [] names, @Nullable Value @Nullable [] values)
      Create a new element of the type defined by the given elementfactory. The supplied list of properties, will be passed at object construction.
      Parameters:
      names - array of properties names
      values - array of associated properties values
      Returns:
      new GstElement or null if the element couldn't be created
      Since:
      1.20
    • getElementType

      public Type getElementType()
      Get the GType for elements managed by this factory. The type can only be retrieved if the element factory is loaded, which can be assured with gst_plugin_feature_load().
      Returns:
      the GType for elements managed by this factory or 0 if the factory is not loaded.
    • getMetadata

      public @Nullable String getMetadata(String key)
      Get the metadata on this ElementFactory with key.
      Parameters:
      key - a key
      Returns:
      the metadata with key on this ElementFactory or null when there was no metadata with the given key.
    • getMetadataKeys

      public @Nullable String @Nullable [] getMetadataKeys()
      Get the available keys for the metadata on factory.
      Returns:
      a null-terminated array of key strings, or null when there is no metadata. Free with g_strfreev() when no longer needed.
    • getNumPadTemplates

      public int getNumPadTemplates()
      Gets the number of pad_templates in this factory.
      Returns:
      the number of pad_templates
    • getSkipDocumentation

      public boolean getSkipDocumentation()
      Queries whether registered element managed by this ElementFactory needs to be excluded from documentation system or not.
      Returns:
      true if documentation should be skipped
      Since:
      1.20
    • getStaticPadTemplates

      public List<StaticPadTemplate> getStaticPadTemplates()
      Gets the GList of GstStaticPadTemplate for this factory.
      Returns:
      the static pad templates
    • getUriProtocols

      public String[] getUriProtocols()
      Gets a null-terminated array of protocols this element supports or null if no protocols are supported. You may not change the contents of the returned array, as it is still owned by the element factory. Use g_strdupv() to make a copy of the protocol string array if you need to.
      Returns:
      the supported protocols or null
    • getUriType

      public URIType getUriType()
      Gets the type of URIs the element supports or GST_URI_UNKNOWN if none.
      Returns:
      type of URIs this element supports
    • hasInterface

      public boolean hasInterface(String interfacename)
      Check if this ElementFactory implements the interface with name interfacename.
      Parameters:
      interfacename - an interface name
      Returns:
      true when this ElementFactory implement the interface.
    • listIsType

      public boolean listIsType(ElementFactoryListType type)
      Check if this ElementFactory is of the given types.
      Parameters:
      type - a GstElementFactoryListType
      Returns:
      true if this ElementFactory is of type.
    • builder

      public static ElementFactory.Builder<? extends ElementFactory.Builder> builder()
      A ElementFactory.Builder object constructs a ElementFactory with the specified properties. Use the various set...() methods to set properties, and finish construction with ElementFactory.Builder.build().
      Returns:
      the builder object