diff --git a/gst/gstcontext.c b/gst/gstcontext.c index b790df89c7..953f3ea103 100644 --- a/gst/gstcontext.c +++ b/gst/gstcontext.c @@ -63,6 +63,7 @@ struct _GstContext { GstMiniObject mini_object; + gchar *context_type; GstStructure *structure; gboolean persistent; }; @@ -119,6 +120,8 @@ _gst_context_copy (GstContext * context) gst_context_init (copy); + copy->context_type = g_strdup (context->context_type); + structure = GST_CONTEXT_STRUCTURE (context); GST_CONTEXT_STRUCTURE (copy) = gst_structure_copy (structure); gst_structure_set_parent_refcount (GST_CONTEXT_STRUCTURE (copy), @@ -148,11 +151,13 @@ gst_context_init (GstContext * context) * Since: 1.2 */ GstContext * -gst_context_new (gboolean persistent) +gst_context_new (const gchar * context_type, gboolean persistent) { GstContext *context; GstStructure *structure; + g_return_val_if_fail (context_type != NULL, NULL); + context = g_slice_new0 (GstContext); 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_context_init (context); + context->context_type = g_strdup (context_type); GST_CONTEXT_STRUCTURE (context) = structure; context->persistent = persistent; 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: * @context: The #GstContext. diff --git a/gst/gstcontext.h b/gst/gstcontext.h index a1d2afa420..7ee3324b2e 100644 --- a/gst/gstcontext.h +++ b/gst/gstcontext.h @@ -144,10 +144,12 @@ gst_context_replace (GstContext **old_context, GstContext *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); -GstStructure * gst_context_writable_structure (GstContext *context); +const gchar * gst_context_get_context_type (const 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); diff --git a/gst/gstinfo.c b/gst/gstinfo.c index ea2876da42..550121709e 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -709,17 +709,15 @@ gst_debug_print_object (gpointer ptr) if (GST_IS_CONTEXT (object)) { GstContext *context = GST_CONTEXT_CAST (object); gchar *s, *ret; + const gchar *type; const GstStructure *structure; + type = gst_context_get_context_type (context); structure = gst_context_get_structure (context); - if (structure) { - s = gst_info_structure_to_string (structure); - } else { - s = g_strdup ("(NULL)"); - } + s = gst_info_structure_to_string (structure); - ret = g_strdup_printf ("context '%s'", s); + ret = g_strdup_printf ("context '%s'='%s'", type, s); g_free (s); return ret; }