mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-23 17:14:23 +00:00
context: Change GstContext to contain only a single context
It was unintuitive that GstContext was actually a list of different contexts. GstContext now is only a type string and a structure to contain the actual context.
This commit is contained in:
parent
014690326f
commit
4d367dc1b0
3 changed files with 34 additions and 10 deletions
|
@ -63,6 +63,7 @@ struct _GstContext
|
||||||
{
|
{
|
||||||
GstMiniObject mini_object;
|
GstMiniObject mini_object;
|
||||||
|
|
||||||
|
gchar *context_type;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gboolean persistent;
|
gboolean persistent;
|
||||||
};
|
};
|
||||||
|
@ -119,6 +120,8 @@ _gst_context_copy (GstContext * context)
|
||||||
|
|
||||||
gst_context_init (copy);
|
gst_context_init (copy);
|
||||||
|
|
||||||
|
copy->context_type = g_strdup (context->context_type);
|
||||||
|
|
||||||
structure = GST_CONTEXT_STRUCTURE (context);
|
structure = GST_CONTEXT_STRUCTURE (context);
|
||||||
GST_CONTEXT_STRUCTURE (copy) = gst_structure_copy (structure);
|
GST_CONTEXT_STRUCTURE (copy) = gst_structure_copy (structure);
|
||||||
gst_structure_set_parent_refcount (GST_CONTEXT_STRUCTURE (copy),
|
gst_structure_set_parent_refcount (GST_CONTEXT_STRUCTURE (copy),
|
||||||
|
@ -148,11 +151,13 @@ gst_context_init (GstContext * context)
|
||||||
* Since: 1.2
|
* Since: 1.2
|
||||||
*/
|
*/
|
||||||
GstContext *
|
GstContext *
|
||||||
gst_context_new (gboolean persistent)
|
gst_context_new (const gchar * context_type, gboolean persistent)
|
||||||
{
|
{
|
||||||
GstContext *context;
|
GstContext *context;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
|
g_return_val_if_fail (context_type != NULL, NULL);
|
||||||
|
|
||||||
context = g_slice_new0 (GstContext);
|
context = g_slice_new0 (GstContext);
|
||||||
|
|
||||||
GST_CAT_LOG (GST_CAT_CONTEXT, "creating new context %p", context);
|
GST_CAT_LOG (GST_CAT_CONTEXT, "creating new context %p", context);
|
||||||
|
@ -161,12 +166,31 @@ gst_context_new (gboolean persistent)
|
||||||
gst_structure_set_parent_refcount (structure, &context->mini_object.refcount);
|
gst_structure_set_parent_refcount (structure, &context->mini_object.refcount);
|
||||||
gst_context_init (context);
|
gst_context_init (context);
|
||||||
|
|
||||||
|
context->context_type = g_strdup (context_type);
|
||||||
GST_CONTEXT_STRUCTURE (context) = structure;
|
GST_CONTEXT_STRUCTURE (context) = structure;
|
||||||
context->persistent = persistent;
|
context->persistent = persistent;
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_context_get_context_type:
|
||||||
|
* @context: The #GstContext.
|
||||||
|
*
|
||||||
|
* Get the type of @context.
|
||||||
|
*
|
||||||
|
* Returns: The type of the context.
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gst_context_get_context_type (const GstContext * context)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GST_IS_CONTEXT (context), NULL);
|
||||||
|
|
||||||
|
return context->context_type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_context_get_structure:
|
* gst_context_get_structure:
|
||||||
* @context: The #GstContext.
|
* @context: The #GstContext.
|
||||||
|
|
|
@ -144,10 +144,12 @@ gst_context_replace (GstContext **old_context, GstContext *new_context)
|
||||||
return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context);
|
return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
GstContext * gst_context_new (gboolean persistent) G_GNUC_MALLOC;
|
GstContext * gst_context_new (const gchar * context_type,
|
||||||
|
gboolean persistent) G_GNUC_MALLOC;
|
||||||
|
|
||||||
const GstStructure * gst_context_get_structure (const GstContext *context);
|
const gchar * gst_context_get_context_type (const GstContext * context);
|
||||||
GstStructure * gst_context_writable_structure (GstContext *context);
|
const GstStructure * gst_context_get_structure (const GstContext * context);
|
||||||
|
GstStructure * gst_context_writable_structure (GstContext * context);
|
||||||
|
|
||||||
gboolean gst_context_is_persistent (const GstContext * context);
|
gboolean gst_context_is_persistent (const GstContext * context);
|
||||||
|
|
||||||
|
|
|
@ -709,17 +709,15 @@ gst_debug_print_object (gpointer ptr)
|
||||||
if (GST_IS_CONTEXT (object)) {
|
if (GST_IS_CONTEXT (object)) {
|
||||||
GstContext *context = GST_CONTEXT_CAST (object);
|
GstContext *context = GST_CONTEXT_CAST (object);
|
||||||
gchar *s, *ret;
|
gchar *s, *ret;
|
||||||
|
const gchar *type;
|
||||||
const GstStructure *structure;
|
const GstStructure *structure;
|
||||||
|
|
||||||
|
type = gst_context_get_context_type (context);
|
||||||
structure = gst_context_get_structure (context);
|
structure = gst_context_get_structure (context);
|
||||||
|
|
||||||
if (structure) {
|
s = gst_info_structure_to_string (structure);
|
||||||
s = gst_info_structure_to_string (structure);
|
|
||||||
} else {
|
|
||||||
s = g_strdup ("(NULL)");
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = g_strdup_printf ("context '%s'", s);
|
ret = g_strdup_printf ("context '%s'='%s'", type, s);
|
||||||
g_free (s);
|
g_free (s);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue