# GstContext

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 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 GST_QUERY_CONTEXT for the context
3. Query upstream with GST_QUERY_CONTEXT for the context
4. Post a GST_MESSAGE_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 GST_MESSAGE_HAVE_CONTEXT message on the bus.

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

## GstContext

## Gst.Context

### Constructors

#### gst_context_new

    GstContext *
    gst_context_new (const gchar * context_type,
                     gboolean persistent)

Creates a new context.

Parameters:

`context_type` –

Context type

`persistent` –

Persistent context

Returns ( [transfer: full]) –

The new context.

Since : 1.2

#### Gst.Context.prototype.new

    function Gst.Context.prototype.new(context_type: String, persistent: Number): {
        // javascript wrapper for 'gst_context_new'
    }

Creates a new context.

Parameters:

`context_type` (String) –

Context type

`persistent` (Number) –

Persistent context

Returns (Gst.Context) –

The new context.

Since : 1.2

#### Gst.Context.new

    def Gst.Context.new (context_type, persistent):
        #python wrapper for 'gst_context_new'

Creates a new context.

Parameters:

`context_type` (str) –

Context type

`persistent` (bool) –

Persistent context

Returns (Gst.Context) –

The new context.

Since : 1.2

### Methods

#### gst_context_copy

    GstContext *
    gst_context_copy (const GstContext * context)

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

Parameters:

`context` –

the context to copy

Returns ( [transfer: full]) –

a new copy of context.

MT safe

Since : 1.2

#### Gst.Context.prototype.copy

    function Gst.Context.prototype.copy(): {
        // javascript wrapper for 'gst_context_copy'
    }

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

Parameters:

`context` (Gst.Context) –

the context to copy

Returns (Gst.Context) –

a new copy of context.

MT safe

Since : 1.2

#### Gst.Context.copy

    def Gst.Context.copy (self):
        #python wrapper for 'gst_context_copy'

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

Parameters:

`context` (Gst.Context) –

the context to copy

Returns (Gst.Context) –

a new copy of context.

MT safe

Since : 1.2

#### gst_context_get_context_type

    const gchar *
    gst_context_get_context_type (const GstContext * context)

Gets the type of context.

Parameters:

`context` –

The GstContext.

Returns –

The type of the context.

Since : 1.2

#### Gst.Context.prototype.get_context_type

    function Gst.Context.prototype.get_context_type(): {
        // javascript wrapper for 'gst_context_get_context_type'
    }

Gets the type of context.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (String) –

The type of the context.

Since : 1.2

#### Gst.Context.get_context_type

    def Gst.Context.get_context_type (self):
        #python wrapper for 'gst_context_get_context_type'

Gets the type of context.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (str) –

The type of the context.

Since : 1.2

#### gst_context_get_structure

    const GstStructure *
    gst_context_get_structure (const GstContext * context)

Accesses the structure of the context.

Parameters:

`context` –

The GstContext.

Returns ( [transfer: none]) –

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

#### Gst.Context.prototype.get_structure

    function Gst.Context.prototype.get_structure(): {
        // javascript wrapper for 'gst_context_get_structure'
    }

Accesses the structure of the context.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (Gst.Structure) –

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

#### Gst.Context.get_structure

    def Gst.Context.get_structure (self):
        #python wrapper for 'gst_context_get_structure'

Accesses the structure of the context.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (Gst.Structure) –

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

#### gst_context_get_task_pool

    gboolean
    gst_context_get_task_pool (GstContext * context,
                               GstTaskPool ** pool)

Gets the task pool from context.

Parameters:

`context` –

a GstContext

`pool` ( [out][transfer: full][nullable]) –

a GstTaskPool

Returns –

TRUE if a task pool was set on context

Since : 1.28

#### Gst.Context.prototype.get_task_pool

    function Gst.Context.prototype.get_task_pool(): {
        // javascript wrapper for 'gst_context_get_task_pool'
    }

Gets the task pool from context.

Parameters:

`context` (Gst.Context) –

a Gst.Context

Returns a tuple made of:

(Number ) –

true if a task pool was set on context

`pool` (Gst.TaskPool ) –

true if a task pool was set on context

Since : 1.28

#### Gst.Context.get_task_pool

    def Gst.Context.get_task_pool (self):
        #python wrapper for 'gst_context_get_task_pool'

Gets the task pool from context.

Parameters:

`context` (Gst.Context) –

a Gst.Context

Returns a tuple made of:

(bool ) –

True if a task pool was set on context

`pool` (Gst.TaskPool ) –

True if a task pool was set on context

Since : 1.28

#### gst_context_has_context_type

    gboolean
    gst_context_has_context_type (const GstContext * context,
                                  const gchar * context_type)

Checks if context has context_type.

Parameters:

`context` –

The GstContext.

`context_type` –

Context type to check.

Returns –

TRUE if context has context_type.

Since : 1.2

#### Gst.Context.prototype.has_context_type

    function Gst.Context.prototype.has_context_type(context_type: String): {
        // javascript wrapper for 'gst_context_has_context_type'
    }

Checks if context has context_type.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

`context_type` (String) –

Context type to check.

Returns (Number) –

true if context has context_type.

Since : 1.2

#### Gst.Context.has_context_type

    def Gst.Context.has_context_type (self, context_type):
        #python wrapper for 'gst_context_has_context_type'

Checks if context has context_type.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

`context_type` (str) –

Context type to check.

Returns (bool) –

True if context has context_type.

Since : 1.2

#### gst_context_is_persistent

    gboolean
    gst_context_is_persistent (const GstContext * context)

Checks if context is persistent.

Parameters:

`context` –

The GstContext.

Returns –

TRUE if the context is persistent.

Since : 1.2

#### Gst.Context.prototype.is_persistent

    function Gst.Context.prototype.is_persistent(): {
        // javascript wrapper for 'gst_context_is_persistent'
    }

Checks if context is persistent.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (Number) –

true if the context is persistent.

Since : 1.2

#### Gst.Context.is_persistent

    def Gst.Context.is_persistent (self):
        #python wrapper for 'gst_context_is_persistent'

Checks if context is persistent.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (bool) –

True if the context is persistent.

Since : 1.2

#### gst_context_is_writable

    gboolean
    gst_context_is_writable (const GstContext * context)

Tests if you can safely modify context. It is only safe to modify context when there is only one owner of the context - ie, the object is writable.

Parameters:

`context` –

a GstContext

Returns –
No description available

#### Gst.Context.prototype.is_writable

    function Gst.Context.prototype.is_writable(): {
        // javascript wrapper for 'gst_context_is_writable'
    }

Tests if you can safely modify context. It is only safe to modify context when there is only one owner of the context - ie, the object is writable.

Parameters:

`context` (Gst.Context) –

a Gst.Context

Returns (Number) –
No description available

#### Gst.Context.is_writable

    def Gst.Context.is_writable (self):
        #python wrapper for 'gst_context_is_writable'

Tests if you can safely modify context. It is only safe to modify context when there is only one owner of the context - ie, the object is writable.

Parameters:

`context` (Gst.Context) –

a Gst.Context

Returns (bool) –
No description available

#### gst_context_make_writable

    GstContext *
    gst_context_make_writable (GstContext * context)

Returns a writable copy of context.

If there is only one reference count on context, the caller must be the owner, and so this function will return the context object unchanged. If on the other hand there is more than one reference on the object, a new context object will be returned. The caller's reference on context will be removed, and instead the caller will own a reference to the returned object.

In short, this function unrefs the context in the argument and refs the context that it returns. Don't access the argument after calling this function. See also: gst_context_ref.

Parameters:

`context` ( [transfer: full]) –

a GstContext

Returns ( [transfer: full]) –

a writable context which may or may not be the same as context

#### Gst.Context.prototype.make_writable

    function Gst.Context.prototype.make_writable(): {
        // javascript wrapper for 'gst_context_make_writable'
    }

Returns a writable copy of context.

If there is only one reference count on context, the caller must be the owner, and so this function will return the context object unchanged. If on the other hand there is more than one reference on the object, a new context object will be returned. The caller's reference on context will be removed, and instead the caller will own a reference to the returned object.

In short, this function unrefs the context in the argument and refs the context that it returns. Don't access the argument after calling this function. See also: Gst.Context.prototype.ref.

Parameters:

`context` (Gst.Context) –

a Gst.Context

Returns (Gst.Context) –

a writable context which may or may not be the same as context

#### Gst.Context.make_writable

    def Gst.Context.make_writable (self):
        #python wrapper for 'gst_context_make_writable'

Returns a writable copy of context.

If there is only one reference count on context, the caller must be the owner, and so this function will return the context object unchanged. If on the other hand there is more than one reference on the object, a new context object will be returned. The caller's reference on context will be removed, and instead the caller will own a reference to the returned object.

In short, this function unrefs the context in the argument and refs the context that it returns. Don't access the argument after calling this function. See also: Gst.Context.ref.

Parameters:

`context` (Gst.Context) –

a Gst.Context

Returns (Gst.Context) –

a writable context which may or may not be the same as context

#### gst_context_ref

    GstContext *
    gst_context_ref (GstContext * context)

Convenience macro to increase the reference count of the context.

Parameters:

`context` –

the context to ref

Returns –

context (for convenience when doing assignments)

Since : 1.2

#### Gst.Context.prototype.ref

    function Gst.Context.prototype.ref(): {
        // javascript wrapper for 'gst_context_ref'
    }

Convenience macro to increase the reference count of the context.

Parameters:

`context` (Gst.Context) –

the context to ref

Returns (Gst.Context) –

context (for convenience when doing assignments)

Since : 1.2

#### Gst.Context.ref

    def Gst.Context.ref (self):
        #python wrapper for 'gst_context_ref'

Convenience macro to increase the reference count of the context.

Parameters:

`context` (Gst.Context) –

the context to ref

Returns (Gst.Context) –

context (for convenience when doing assignments)

Since : 1.2

#### gst_context_set_task_pool

    gst_context_set_task_pool (GstContext * context,
                               GstTaskPool * pool)

Sets pool on context as the task pool to be shared between elements. If pool is NULL, any previously set task pool will be removed from the context.

Parameters:

`context` –

a GstContext

`pool` ( [transfer: none][nullable]) –

a GstTaskPool or NULL to unset

Since : 1.28

#### Gst.Context.prototype.set_task_pool

    function Gst.Context.prototype.set_task_pool(pool: Gst.TaskPool): {
        // javascript wrapper for 'gst_context_set_task_pool'
    }

Sets pool on context as the task pool to be shared between elements. If pool is null, any previously set task pool will be removed from the context.

Parameters:

`context` (Gst.Context) –

a Gst.Context

`pool` (Gst.TaskPool) –

a Gst.TaskPool or null to unset

Since : 1.28

#### Gst.Context.set_task_pool

    def Gst.Context.set_task_pool (self, pool):
        #python wrapper for 'gst_context_set_task_pool'

Sets pool on context as the task pool to be shared between elements. If pool is None, any previously set task pool will be removed from the context.

Parameters:

`context` (Gst.Context) –

a Gst.Context

`pool` (Gst.TaskPool) –

a Gst.TaskPool or None to unset

Since : 1.28

#### gst_context_unref

    gst_context_unref (GstContext * context)

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

Parameters:

`context` –

the context to unref

Since : 1.2

#### Gst.Context.prototype.unref

    function Gst.Context.prototype.unref(): {
        // javascript wrapper for 'gst_context_unref'
    }

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

Parameters:

`context` (Gst.Context) –

the context to unref

Since : 1.2

#### Gst.Context.unref

    def Gst.Context.unref (self):
        #python wrapper for 'gst_context_unref'

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

Parameters:

`context` (Gst.Context) –

the context to unref

Since : 1.2

#### gst_context_writable_structure

    GstStructure *
    gst_context_writable_structure (GstContext * context)

Gets a writable version of the structure.

Parameters:

`context` –

The GstContext.

Returns ( [transfer: none]) –

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 context is writable.

Since : 1.2

#### Gst.Context.prototype.writable_structure

    function Gst.Context.prototype.writable_structure(): {
        // javascript wrapper for 'gst_context_writable_structure'
    }

Gets a writable version of the structure.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (Gst.Structure) –

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 context is writable.

Since : 1.2

#### Gst.Context.writable_structure

    def Gst.Context.writable_structure (self):
        #python wrapper for 'gst_context_writable_structure'

Gets a writable version of the structure.

Parameters:

`context` (Gst.Context) –

The Gst.Context.

Returns (Gst.Structure) –

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 context is writable.

Since : 1.2

### Functions

#### gst_context_replace

    gboolean
    gst_context_replace (GstContext ** old_context,
                         GstContext * new_context)

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 new_context or the GstContext pointed to by old_context may be NULL.

Parameters:

`old_context` ( [inout][transfer: full]) –

pointer to a pointer to a GstContext to be replaced.

`new_context` ( [allow-none][transfer: none]) –

pointer to a GstContext that will replace the context pointed to by old_context.

Returns –

TRUE if new_context was different from old_context

Since : 1.2

#### Gst.prototype.context_replace

    function Gst.prototype.context_replace(old_context: Gst.Context, new_context: Gst.Context): {
        // javascript wrapper for 'gst_context_replace'
    }

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 null.

Parameters:

`old_context` (Gst.Context) –

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

`new_context` (Gst.Context) –

pointer to a Gst.Context that will replace the context pointed to by old_context.

Returns a tuple made of:

(Number ) –

true if new_context was different from old_context

`old_context` (Gst.Context ) –

true if new_context was different from old_context

Since : 1.2

#### Gst.context_replace

    def Gst.context_replace (old_context, new_context):
        #python wrapper for 'gst_context_replace'

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.

Parameters:

`old_context` (Gst.Context) –

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

`new_context` (Gst.Context) –

pointer to a Gst.Context that will replace the context pointed to by old_context.

Returns a tuple made of:

(bool ) –

True if new_context was different from old_context

`old_context` (Gst.Context ) –

True if new_context was different from old_context

Since : 1.2

## Functions

### gst_clear_context

    gst_clear_context (GstContext ** context_ptr)

Clears a reference to a GstContext.

context_ptr must not be `NULL`.

If the reference is `NULL` then this function does nothing. Otherwise, the reference count of the context is decreased and the pointer is set to `NULL`.

Parameters:

`context_ptr` –

a pointer to a GstContext reference

Since : 1.24

## Function Macros

### GST_CONTEXT_CAST

    #define GST_CONTEXT_CAST(obj)                    ((GstContext*)(obj))

The results of the search are