Gst.Context

Fields

None

Methods

class

new (context_type, persistent)

class

replace (old_context, new_context)

copy ()

get_context_type ()

get_structure ()

has_context_type (context_type)

is_persistent ()

ref ()

unref ()

writable_structure ()

Details

class Gst.Context

Gst.Context 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:

Check if the element already has a context

Query downstream with Gst.QueryType.CONTEXT for the context

Query upstream with Gst.QueryType.CONTEXT for the context

Post a Gst.MessageType.NEED_CONTEXT message on the bus with the required context types and afterwards check if a usable context was set now

Create a context by itself and post a Gst.MessageType.HAVE_CONTEXT message on the bus.

Bins will catch Gst.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.

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

New in version 1.2.

classmethod new(context_type, persistent)[source]
Parameters:
  • context_type (str) – Context type

  • persistent (bool) – Persistent context

Returns:

The new context.

Return type:

Gst.Context

Creates a new context.

New in version 1.2.

classmethod replace(old_context, new_context)[source]
Parameters:
Returns:

True if new_context was different from old_context

old_context:

pointer to a pointer to a Gst.Context to be replaced.

Return type:

(bool, old_context: Gst.Context)

Modifies a pointer to a Gst.Context to point to a different Gst.Context. 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 new_context or the Gst.Context pointed to by old_context may be None.

New in version 1.2.

copy()[source]
Returns:

a new copy of self.

MT safe

Return type:

Gst.Context

Creates a copy of the context. Returns a copy of the context.

New in version 1.2.

get_context_type()[source]
Returns:

The type of the context.

Return type:

str

Gets the type of self.

New in version 1.2.

get_structure()[source]
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.

Return type:

Gst.Structure

Accesses the structure of the context.

New in version 1.2.

has_context_type(context_type)[source]
Parameters:

context_type (str) – Context type to check.

Returns:

True if self has context_type.

Return type:

bool

Checks if self has context_type.

New in version 1.2.

is_persistent()[source]
Returns:

True if the context is persistent.

Return type:

bool

Checks if self is persistent.

New in version 1.2.

ref()[source]
Returns:

self (for convenience when doing assignments)

Return type:

Gst.Context

Convenience macro to increase the reference count of the context.

New in version 1.2.

unref()[source]

Convenience macro to decrease the reference count of the context, possibly freeing it.

New in version 1.2.

writable_structure()[source]
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 self is writable.

Return type:

Gst.Structure

Gets a writable version of the structure.

New in version 1.2.