:right-sidebar: True Context =================================================================== .. currentmodule:: gi.repository.Gst .. versionadded:: 1.2 .. class:: Context(**kwargs) :no-contents-entry: :obj:`~gi.repository.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 :func:`~gi.repository.Gst.Element.set_context`, which will then be propagated to all child elements. Elements can handle these in :obj:`~gi.repository.Gst.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 :const:`~gi.repository.Gst.QueryType.CONTEXT` for the context - Query upstream with :const:`~gi.repository.Gst.QueryType.CONTEXT` for the context - Post a :const:`~gi.repository.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 :const:`~gi.repository.Gst.MessageType.HAVE_CONTEXT` message on the bus. Bins will catch :const:`~gi.repository.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. :obj:`~gi.repository.Gst.Context` can be persistent. A persistent :obj:`~gi.repository.Gst.Context` is kept in elements when they reach :const:`~gi.repository.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. Constructors ------------ .. rst-class:: interim-class .. class:: Context :no-index: .. classmethod:: new(context_type: str, persistent: bool) -> ~gi.repository.Gst.Context Creates a new context. .. versionadded:: 1.2 :param context_type: Context type :param persistent: Persistent context Methods ------- .. rst-class:: interim-class .. class:: Context :no-index: .. method:: get_context_type() -> str Gets the type of ``context``\. .. versionadded:: 1.2 .. method:: get_structure() -> ~gi.repository.Gst.Structure Accesses the structure of the context. .. versionadded:: 1.2 .. method:: has_context_type(context_type: str) -> bool Checks if ``context`` has ``context_type``\. .. versionadded:: 1.2 :param context_type: Context type to check. .. method:: is_persistent() -> bool Checks if ``context`` is persistent. .. versionadded:: 1.2 .. method:: writable_structure() -> ~gi.repository.Gst.Structure Gets a writable version of the structure. .. versionadded:: 1.2