Blame gst/gstcontext.h

Packit f546b1
/* GStreamer
Packit f546b1
 * Copyright (C) 2013 Collabora Ltd.
Packit f546b1
 *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Packit f546b1
 * Copyright (C) 2013 Sebastian Dröge <slomo@circular-chaos.org>
Packit f546b1
 *
Packit f546b1
 * gstcontext.h: Header for GstContext subsystem
Packit f546b1
 *
Packit f546b1
 * This library is free software; you can redistribute it and/or
Packit f546b1
 * modify it under the terms of the GNU Library General Public
Packit f546b1
 * License as published by the Free Software Foundation; either
Packit f546b1
 * version 2 of the License, or (at your option) any later version.
Packit f546b1
 *
Packit f546b1
 * This library is distributed in the hope that it will be useful,
Packit f546b1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit f546b1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit f546b1
 * Library General Public License for more details.
Packit f546b1
 *
Packit f546b1
 * You should have received a copy of the GNU Library General Public
Packit f546b1
 * License along with this library; if not, write to the
Packit f546b1
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit f546b1
 * Boston, MA 02110-1301, USA.
Packit f546b1
 */
Packit f546b1
Packit f546b1
#ifndef __GST_CONTEXT_H__
Packit f546b1
#define __GST_CONTEXT_H__
Packit f546b1
Packit f546b1
#include <glib.h>
Packit f546b1
Packit f546b1
G_BEGIN_DECLS
Packit f546b1
Packit f546b1
typedef struct _GstContext GstContext;
Packit f546b1
Packit f546b1
#include <gst/gstminiobject.h>
Packit f546b1
#include <gst/gststructure.h>
Packit f546b1
Packit f546b1
GST_API GType _gst_context_type;
Packit f546b1
Packit f546b1
#define GST_TYPE_CONTEXT                         (_gst_context_type)
Packit f546b1
#define GST_IS_CONTEXT(obj)                      (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
Packit f546b1
#define GST_CONTEXT_CAST(obj)                    ((GstContext*)(obj))
Packit f546b1
#define GST_CONTEXT(obj)                         (GST_CONTEXT_CAST(obj))
Packit f546b1
Packit f546b1
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
GType           gst_context_get_type            (void);
Packit f546b1
Packit f546b1
Packit f546b1
/* refcounting */
Packit f546b1
/**
Packit f546b1
 * gst_context_ref:
Packit f546b1
 * @context: the context to ref
Packit f546b1
 *
Packit f546b1
 * Convenience macro to increase the reference count of the context.
Packit f546b1
 *
Packit f546b1
 * Returns: @context (for convenience when doing assignments)
Packit f546b1
 */
Packit f546b1
static inline GstContext *
Packit f546b1
gst_context_ref (GstContext * context)
Packit f546b1
{
Packit f546b1
  return (GstContext *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (context));
Packit f546b1
}
Packit f546b1
Packit f546b1
/**
Packit f546b1
 * gst_context_unref:
Packit f546b1
 * @context: the context to unref
Packit f546b1
 *
Packit f546b1
 * Convenience macro to decrease the reference count of the context, possibly
Packit f546b1
 * freeing it.
Packit f546b1
 */
Packit f546b1
static inline void
Packit f546b1
gst_context_unref (GstContext * context)
Packit f546b1
{
Packit f546b1
  gst_mini_object_unref (GST_MINI_OBJECT_CAST (context));
Packit f546b1
}
Packit f546b1
Packit f546b1
/* copy context */
Packit f546b1
/**
Packit f546b1
 * gst_context_copy:
Packit f546b1
 * @context: the context to copy
Packit f546b1
 *
Packit f546b1
 * Creates a copy of the context. Returns a copy of the context.
Packit f546b1
 *
Packit f546b1
 * Returns: (transfer full): a new copy of @context.
Packit f546b1
 *
Packit f546b1
 * MT safe
Packit f546b1
 */
Packit f546b1
static inline GstContext *
Packit f546b1
gst_context_copy (const GstContext * context)
Packit f546b1
{
Packit f546b1
  return GST_CONTEXT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (context)));
Packit f546b1
}
Packit f546b1
Packit f546b1
/**
Packit f546b1
 * gst_context_is_writable:
Packit f546b1
 * @context: a #GstContext
Packit f546b1
 *
Packit f546b1
 * Tests if you can safely write into a context's structure or validly
Packit f546b1
 * modify the seqnum and timestamp fields.
Packit f546b1
 */
Packit f546b1
#define         gst_context_is_writable(context)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (context))
Packit f546b1
/**
Packit f546b1
 * gst_context_make_writable:
Packit f546b1
 * @context: (transfer full): the context to make writable
Packit f546b1
 *
Packit f546b1
 * Checks if a context is writable. If not, a writable copy is made and
Packit f546b1
 * returned.
Packit f546b1
 *
Packit f546b1
 * Returns: (transfer full): a context (possibly a duplicate) that is writable.
Packit f546b1
 *
Packit f546b1
 * MT safe
Packit f546b1
 */
Packit f546b1
#define         gst_context_make_writable(context)  GST_CONTEXT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (context)))
Packit f546b1
/**
Packit f546b1
 * gst_context_replace:
Packit f546b1
 * @old_context: (inout) (transfer full): pointer to a pointer to a #GstContext
Packit f546b1
 *     to be replaced.
Packit f546b1
 * @new_context: (allow-none) (transfer none): pointer to a #GstContext that will
Packit f546b1
 *     replace the context pointed to by @old_context.
Packit f546b1
 *
Packit f546b1
 * Modifies a pointer to a #GstContext to point to a different #GstContext. The
Packit f546b1
 * modification is done atomically (so this is useful for ensuring thread safety
Packit f546b1
 * in some cases), and the reference counts are updated appropriately (the old
Packit f546b1
 * context is unreffed, the new one is reffed).
Packit f546b1
 *
Packit f546b1
 * Either @new_context or the #GstContext pointed to by @old_context may be %NULL.
Packit f546b1
 *
Packit f546b1
 * Returns: %TRUE if @new_context was different from @old_context
Packit f546b1
 */
Packit f546b1
static inline gboolean
Packit f546b1
gst_context_replace (GstContext **old_context, GstContext *new_context)
Packit f546b1
{
Packit f546b1
  return gst_mini_object_replace ((GstMiniObject **) old_context, (GstMiniObject *) new_context);
Packit f546b1
}
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
GstContext *          gst_context_new                      (const gchar * context_type,
Packit f546b1
                                                            gboolean persistent) G_GNUC_MALLOC;
Packit f546b1
GST_API
Packit f546b1
const gchar *         gst_context_get_context_type         (const GstContext * context);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gboolean              gst_context_has_context_type         (const GstContext * context, const gchar * context_type);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
const GstStructure *  gst_context_get_structure            (const GstContext * context);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
GstStructure *        gst_context_writable_structure       (GstContext * context);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gboolean              gst_context_is_persistent            (const GstContext * context);
Packit f546b1
Packit f546b1
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
Packit f546b1
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstContext, gst_context_unref)
Packit f546b1
#endif
Packit f546b1
Packit f546b1
G_END_DECLS
Packit f546b1
Packit f546b1
#endif /* __GST_CONTEXT_H__ */