/* GStreamer
- * Copyright (C) 2011 Wim Taymans <wim.taymans@gmail.com>
+ * Copyright (C) 2013 Collabora Ltd.
+ * Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ * Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
*
* gstcontext.h: Header for GstContext subsystem
*
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
-
#ifndef __GST_CONTEXT_H__
#define __GST_CONTEXT_H__
-typedef struct _GstContext GstContext;
-
-#include <gst/gstminiobject.h>
-#include <gst/gstevent.h>
+#include <glib.h>
G_BEGIN_DECLS
-#define GST_CONTEXT_TRACE_NAME "GstContext"
+typedef struct _GstContext GstContext;
+#include <gst/gstminiobject.h>
+#include <gst/gststructure.h>
-#define GST_TYPE_CONTEXT (gst_context_get_type())
-#define GST_IS_CONTEXT(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
-#define GST_CONTEXT(obj) ((GstContext *)(obj))
-#define GST_CONTEXT_CAST(obj) ((GstContext *)(obj))
+GST_API GType _gst_context_type;
+#define GST_TYPE_CONTEXT (_gst_context_type)
+#define GST_IS_CONTEXT(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
+#define GST_CONTEXT_CAST(obj) ((GstContext*)(obj))
+#define GST_CONTEXT(obj) (GST_CONTEXT_CAST(obj))
-/**
- * gst_context_is_writable:
- * @ctx: a #GstContext
- *
- * Tests if you can safely update @ctx with new events.
- */
-#define gst_context_is_writable(ctx) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (ctx))
-/**
- * gst_context_make_writable:
- * @ctx: (transfer full): a #GstContext
- *
- * Makes a writable context from the given context. If the source context is
- * already writable, this will simply return the same context. A copy will
- * otherwise be made using gst_context_copy().
- *
- * Returns: (transfer full): a writable context which may or may not be the
- * same as @ctx
- */
-#define gst_context_make_writable(ctx) GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (ctx)))
-/**
- * gst_context_replace:
- * @old_ctx: (inout) (transfer full): pointer to a pointer to a #GstContext
- * to be replaced.
- * @new_ctx: (allow-none) (transfer none): pointer to a #GstContext that will
- * replace the context pointed to by @old_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.
- */
-#define gst_context_replace(old_ctx,new_ctx) \
- gst_mini_object_replace ((GstMiniObject **)(old_ctx), GST_MINI_OBJECT_CAST (new_ctx))
+GST_API
+GType gst_context_get_type (void);
-GType gst_context_get_type (void);
/* refcounting */
/**
* gst_context_ref:
- * @context: The context to refcount
+ * @context: the context to ref
*
- * Increase the refcount of this context.
+ * Convenience macro to increase the reference count of the context.
*
- * Returns: (transfer full): @context (for convenience when doing assignments)
+ * Returns: @context (for convenience when doing assignments)
*/
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC GstContext * gst_context_ref (GstContext * context);
-#endif
-
static inline GstContext *
gst_context_ref (GstContext * context)
{
/**
* gst_context_unref:
- * @context: (transfer full): the context to refcount
+ * @context: the context to unref
*
- * Decrease the refcount of an context, freeing it if the refcount reaches 0.
+ * Convenience macro to decrease the reference count of the context, possibly
+ * freeing it.
*/
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC void gst_context_unref (GstContext * context);
-#endif
-
static inline void
gst_context_unref (GstContext * context)
{
/* copy context */
/**
* gst_context_copy:
- * @context: The context to copy
+ * @context: the context to copy
+ *
+ * Creates a copy of the context. Returns a copy of the context.
*
- * Copy the context using the context specific copy function.
+ * Returns: (transfer full): a new copy of @context.
*
- * Returns: (transfer full): the new context
+ * MT safe
*/
-#ifdef _FOOL_GTK_DOC_
-G_INLINE_FUNC GstContext * gst_context_copy (const GstContext * context);
-#endif
-
static inline GstContext *
gst_context_copy (const GstContext * context)
{
return GST_CONTEXT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (context)));
}
-GstContext * gst_context_new (void);
+/**
+ * gst_context_is_writable:
+ * @context: a #GstContext
+ *
+ * Tests if you can safely write into a context's structure or validly
+ * modify the seqnum and timestamp fields.
+ */
+#define gst_context_is_writable(context) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (context))
+/**
+ * gst_context_make_writable:
+ * @context: (transfer full): the context to make writable
+ *
+ * Checks if a context is writable. If not, a writable copy is made and
+ * returned.
+ *
+ * Returns: (transfer full): a context (possibly a duplicate) that is writable.
+ *
+ * MT safe
+ */
+#define gst_context_make_writable(context) GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (context)))
+/**
+ * gst_context_replace:
+ * @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.
+ *
+ * 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.
+ *
+ * Returns: %TRUE if @new_context was different from @old_context
+ */
+static inline gboolean
+gst_context_replace (GstContext **old_context, GstContext *new_context)
+{
+ return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context);
+}
+
+GST_API
+GstContext * gst_context_new (const gchar * context_type,
+ gboolean persistent) G_GNUC_MALLOC;
+GST_API
+const gchar * gst_context_get_context_type (const GstContext * context);
-/* updating and setting events */
-void gst_context_update (GstContext *context, GstEvent *event);
-GstEvent * gst_context_get (GstContext *context, GstEventType type);
+GST_API
+gboolean gst_context_has_context_type (const GstContext * context, const gchar * context_type);
-void gst_context_clear (GstContext *context);
+GST_API
+const GstStructure * gst_context_get_structure (const GstContext * context);
-/* foreach */
-void gst_context_foreach (GstContext *context, GFunc func, gpointer user_data);
+GST_API
+GstStructure * gst_context_writable_structure (GstContext * context);
+
+GST_API
+gboolean gst_context_is_persistent (const GstContext * context);
+
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstContext, gst_context_unref)
+#endif
G_END_DECLS