From e3ce799217c95b2196cabafdfb1d9bb452046c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 17 Sep 2013 13:10:53 +0200 Subject: [PATCH] context: Add persistent qualifier for a context Non-persistent contexts are removed when elements go back to NULL state, persistent contexts are not. Applications most likely want to set persistent contexts. --- gst/gstcontext.c | 28 ++++++++++++++++++++++++++-- gst/gstcontext.h | 7 +++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/gst/gstcontext.c b/gst/gstcontext.c index 92afb75bab..b790df89c7 100644 --- a/gst/gstcontext.c +++ b/gst/gstcontext.c @@ -1,6 +1,7 @@ /* GStreamer * Copyright (C) 2013 Collabora Ltd. * Author: Sebastian Dröge + * Copyright (C) 2013 Sebastian Dröge * * gstcontext.h: Header for GstContext subsystem * @@ -63,6 +64,7 @@ struct _GstContext GstMiniObject mini_object; GstStructure *structure; + gboolean persistent; }; #define GST_CONTEXT_STRUCTURE(c) (((GstContext *)(c))->structure) @@ -122,6 +124,8 @@ _gst_context_copy (GstContext * context) gst_structure_set_parent_refcount (GST_CONTEXT_STRUCTURE (copy), ©->mini_object.refcount); + copy->persistent = context->persistent; + return GST_CONTEXT_CAST (copy); } @@ -135,6 +139,7 @@ gst_context_init (GstContext * context) /** * gst_context_new: + * @persistent: Persistent context * * Create a new context. * @@ -143,7 +148,7 @@ gst_context_init (GstContext * context) * Since: 1.2 */ GstContext * -gst_context_new (void) +gst_context_new (gboolean persistent) { GstContext *context; GstStructure *structure; @@ -157,6 +162,7 @@ gst_context_new (void) gst_context_init (context); GST_CONTEXT_STRUCTURE (context) = structure; + context->persistent = persistent; return context; } @@ -174,7 +180,7 @@ gst_context_new (void) * Since: 1.2 */ const GstStructure * -gst_context_get_structure (GstContext * context) +gst_context_get_structure (const GstContext * context) { g_return_val_if_fail (GST_IS_CONTEXT (context), NULL); @@ -202,3 +208,21 @@ gst_context_writable_structure (GstContext * context) return GST_CONTEXT_STRUCTURE (context); } + +/** + * gst_context_is_persistent: + * @context: The #GstContext. + * + * Check if @context is persistent. + * + * Returns: %TRUE if the context is persistent. + * + * Since: 1.2 + */ +gboolean +gst_context_is_persistent (const GstContext * context) +{ + g_return_val_if_fail (GST_IS_CONTEXT (context), NULL); + + return context->persistent; +} diff --git a/gst/gstcontext.h b/gst/gstcontext.h index 7f4a565c58..a1d2afa420 100644 --- a/gst/gstcontext.h +++ b/gst/gstcontext.h @@ -1,6 +1,7 @@ /* GStreamer * Copyright (C) 2013 Collabora Ltd. * Author: Sebastian Dröge + * Copyright (C) 2013 Sebastian Dröge * * gstcontext.h: Header for GstContext subsystem * @@ -143,11 +144,13 @@ gst_context_replace (GstContext **old_context, GstContext *new_context) return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context); } -GstContext * gst_context_new (void) G_GNUC_MALLOC; +GstContext * gst_context_new (gboolean persistent) G_GNUC_MALLOC; -const GstStructure * gst_context_get_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); + G_END_DECLS #endif /* __GST_CONTEXT_H__ */