Class Context

java.lang.Object
org.javagi.base.ProxyInstance
org.freedesktop.gstreamer.gst.Context
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Context extends ProxyInstance

GstContext is a container object used to store contexts like a device context, a display server connection and similar concepts that should be shared between multiple elements.

Applications can set a context on a complete pipeline by using gst_element_set_context(), which will then be propagated to all child elements. Elements can handle these in GstElementClass::set_context and merge them with the context information they already have.

When an element needs a context it will do the following actions in this order until one step succeeds:

  1. Check if the element already has a context
  2. Query downstream with QueryType.CONTEXT for the context
  3. Query upstream with QueryType.CONTEXT for the context
  4. Post a MessageType.NEED_CONTEXT message on the bus with the required context types and afterwards check if a usable context was set now
  5. Create a context by itself and post a MessageType.HAVE_CONTEXT message on the bus.

Bins will catch MessageType.NEED_CONTEXT messages and will set any previously known context on the element that asks for it if possible. Otherwise the application should provide one if it can.

GstContext can be persistent. A persistent GstContext is kept in elements when they reach State.NULL, non-persistent ones will be removed. Also, a non-persistent context won't override a previous persistent context set to an element.

Since:
1.2
  • Constructor Details

    • Context

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

      public Context(String contextType, boolean persistent)
      Creates a new context.
      Parameters:
      contextType - Context type
      persistent - Persistent context
      Since:
      1.2
  • Method Details

    • getType

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

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

      public static boolean replace(Out<Context> oldContext, @Nullable Context newContext)

      Modifies a pointer to a GstContext to point to a different GstContext. The modification is done atomically (so this is useful for ensuring thread safety in some cases), and the reference counts are updated appropriately (the old context is unreffed, the new one is reffed).

      Either newContext or the GstContext pointed to by oldContext may be null.

      Parameters:
      oldContext - pointer to a pointer to a GstContext to be replaced.
      newContext - pointer to a GstContext that will replace the context pointed to by oldContext.
      Returns:
      true if newContext was different from oldContext
      Since:
      1.2
    • copy

      public Context copy()
      Creates a copy of the context. Returns a copy of the context.
      Returns:

      a new copy of context.

      MT safe

      Since:
      1.2
    • getContextType

      public String getContextType()
      Gets the type of context.
      Returns:
      The type of the context.
      Since:
      1.2
    • getStructure

      public Structure getStructure()
      Accesses the structure of the context.
      Returns:
      The structure of the context. The structure is still owned by the context, which means that you should not modify it, free it and that the pointer becomes invalid when you free the context.
      Since:
      1.2
    • hasContextType

      public boolean hasContextType(String contextType)
      Checks if this Context has contextType.
      Parameters:
      contextType - Context type to check.
      Returns:
      true if this Context has contextType.
      Since:
      1.2
    • isPersistent

      public boolean isPersistent()
      Checks if this Context is persistent.
      Returns:
      true if the context is persistent.
      Since:
      1.2
    • ref

      public Context ref()
      Convenience macro to increase the reference count of the context.
      Returns:
      this Context (for convenience when doing assignments)
      Since:
      1.2
    • unref

      public void unref()
      Convenience macro to decrease the reference count of the context, possibly freeing it.
      Since:
      1.2
    • writableStructure

      public Structure writableStructure()
      Gets a writable version of the structure.
      Returns:
      The structure of the context. The structure is still owned by the context, which means that you should not free it and that the pointer becomes invalid when you free the context. This function checks if this Context is writable.
      Since:
      1.2