Context#
Added in version 1.2.
- class Context(**kwargs)#
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
set_context()
, which will then be propagated to all
child elements. Elements can handle these in ElementClass
::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
CONTEXT
for the contextQuery upstream with
CONTEXT
for the context- Post a
NEED_CONTEXT
message on the bus with the required context types and afterwards check if a usable context was set now
- Post a
- Create a context by itself and post a
HAVE_CONTEXT
message on the bus.
- Create a context by itself and post a
Bins will catch 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.
Context
can be persistent.
A persistent Context
is kept in elements when they reach
NULL
, non-persistent ones will be removed.
Also, a non-persistent context won’t override a previous persistent
context set to an element.