Blame gst/gstallocator.h

Packit Service 963350
/* GStreamer
Packit Service 963350
 * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
Packit Service 963350
 *
Packit Service 963350
 * gstallocator.h: Header for memory allocation
Packit Service 963350
 *
Packit Service 963350
 * This library is free software; you can redistribute it and/or
Packit Service 963350
 * modify it under the terms of the GNU Library General Public
Packit Service 963350
 * License as published by the Free Software Foundation; either
Packit Service 963350
 * version 2 of the License, or (at your option) any later version.
Packit Service 963350
 *
Packit Service 963350
 * This library is distributed in the hope that it will be useful,
Packit Service 963350
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 963350
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 963350
 * Library General Public License for more details.
Packit Service 963350
 *
Packit Service 963350
 * You should have received a copy of the GNU Library General Public
Packit Service 963350
 * License along with this library; if not, write to the
Packit Service 963350
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit Service 963350
 * Boston, MA 02110-1301, USA.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
Packit Service 963350
#ifndef __GST_ALLOCATOR_H__
Packit Service 963350
#define __GST_ALLOCATOR_H__
Packit Service 963350
Packit Service 963350
#include <gst/gstmemory.h>
Packit Service 963350
#include <gst/gstobject.h>
Packit Service 963350
Packit Service 963350
G_BEGIN_DECLS
Packit Service 963350
Packit Service 963350
typedef struct _GstAllocatorPrivate GstAllocatorPrivate;
Packit Service 963350
typedef struct _GstAllocatorClass GstAllocatorClass;
Packit Service 963350
Packit Service 963350
#define GST_TYPE_ALLOCATOR                 (gst_allocator_get_type())
Packit Service 963350
#define GST_IS_ALLOCATOR(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ALLOCATOR))
Packit Service 963350
#define GST_IS_ALLOCATOR_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ALLOCATOR))
Packit Service 963350
#define GST_ALLOCATOR_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ALLOCATOR, GstAllocatorClass))
Packit Service 963350
#define GST_ALLOCATOR(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ALLOCATOR, GstAllocator))
Packit Service 963350
#define GST_ALLOCATOR_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ALLOCATOR, GstAllocatorClass))
Packit Service 963350
#define GST_ALLOCATOR_CAST(obj)            ((GstAllocator *)(obj))
Packit Service 963350
Packit Service 963350
#define GST_TYPE_ALLOCATION_PARAMS (gst_allocation_params_get_type())
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GType gst_allocation_params_get_type(void);
Packit Service 963350
Packit Service 963350
typedef struct _GstAllocationParams GstAllocationParams;
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_memory_alignment:
Packit Service 963350
 *
Packit Service 963350
 * The default memory alignment in bytes - 1
Packit Service 963350
 * an alignment of 7 would be the same as what malloc() guarantees.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
GST_API gsize gst_memory_alignment;
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GST_ALLOCATOR_SYSMEM:
Packit Service 963350
 *
Packit Service 963350
 * The allocator name for the default system memory allocator
Packit Service 963350
 */
Packit Service 963350
#define GST_ALLOCATOR_SYSMEM   "SystemMemory"
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstAllocationParams:
Packit Service 963350
 * @flags: flags to control allocation
Packit Service 963350
 * @align: the desired alignment of the memory
Packit Service 963350
 * @prefix: the desired prefix
Packit Service 963350
 * @padding: the desired padding
Packit Service 963350
 *
Packit Service 963350
 * Parameters to control the allocation of memory
Packit Service 963350
 */
Packit Service 963350
struct _GstAllocationParams {
Packit Service 963350
  GstMemoryFlags flags;
Packit Service 963350
  gsize          align;
Packit Service 963350
  gsize          prefix;
Packit Service 963350
  gsize          padding;
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING];
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstAllocatorFlags:
Packit Service 963350
 * @GST_ALLOCATOR_FLAG_CUSTOM_ALLOC: The allocator has a custom alloc function.
Packit Service 963350
 * @GST_ALLOCATOR_FLAG_LAST: first flag that can be used for custom purposes
Packit Service 963350
 *
Packit Service 963350
 * Flags for allocators.
Packit Service 963350
 */
Packit Service 963350
typedef enum {
Packit Service 963350
  GST_ALLOCATOR_FLAG_CUSTOM_ALLOC  = (GST_OBJECT_FLAG_LAST << 0),
Packit Service 963350
Packit Service 963350
  GST_ALLOCATOR_FLAG_LAST          = (GST_OBJECT_FLAG_LAST << 16)
Packit Service 963350
} GstAllocatorFlags;
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstAllocator:
Packit Service 963350
 * @mem_map: the implementation of the GstMemoryMapFunction
Packit Service 963350
 * @mem_unmap: the implementation of the GstMemoryUnmapFunction
Packit Service 963350
 * @mem_copy: the implementation of the GstMemoryCopyFunction
Packit Service 963350
 * @mem_share: the implementation of the GstMemoryShareFunction
Packit Service 963350
 * @mem_is_span: the implementation of the GstMemoryIsSpanFunction
Packit Service 963350
 * @mem_map_full: the implementation of the GstMemoryMapFullFunction.
Packit Service 963350
 *      Will be used instead of @mem_map if present. (Since 1.6)
Packit Service 963350
 * @mem_unmap_full: the implementation of the GstMemoryUnmapFullFunction.
Packit Service 963350
 *      Will be used instead of @mem_unmap if present. (Since 1.6)
Packit Service 963350
 *
Packit Service 963350
 * The #GstAllocator is used to create new memory.
Packit Service 963350
 */
Packit Service 963350
struct _GstAllocator
Packit Service 963350
{
Packit Service 963350
  GstObject  object;
Packit Service 963350
Packit Service 963350
  const gchar               *mem_type;
Packit Service 963350
Packit Service 963350
  /*< public >*/
Packit Service 963350
  GstMemoryMapFunction       mem_map;
Packit Service 963350
  GstMemoryUnmapFunction     mem_unmap;
Packit Service 963350
Packit Service 963350
  GstMemoryCopyFunction      mem_copy;
Packit Service 963350
  GstMemoryShareFunction     mem_share;
Packit Service 963350
  GstMemoryIsSpanFunction    mem_is_span;
Packit Service 963350
Packit Service 963350
  GstMemoryMapFullFunction   mem_map_full;
Packit Service 963350
  GstMemoryUnmapFullFunction mem_unmap_full;
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING - 2];
Packit Service 963350
Packit Service 963350
  GstAllocatorPrivate *priv;
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstAllocatorClass:
Packit Service 963350
 * @object_class:  Object parent class
Packit Service 963350
 * @alloc: implementation that acquires memory
Packit Service 963350
 * @free: implementation that releases memory
Packit Service 963350
 *
Packit Service 963350
 * The #GstAllocator is used to create new memory.
Packit Service 963350
 */
Packit Service 963350
struct _GstAllocatorClass {
Packit Service 963350
  GstObjectClass object_class;
Packit Service 963350
Packit Service 963350
  /*< public >*/
Packit Service 963350
  GstMemory *  (*alloc)      (GstAllocator *allocator, gsize size,
Packit Service 963350
                              GstAllocationParams *params);
Packit Service 963350
  void         (*free)       (GstAllocator *allocator, GstMemory *memory);
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING];
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GType          gst_allocator_get_type (void);
Packit Service 963350
Packit Service 963350
/* allocators */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void           gst_allocator_register        (const gchar *name, GstAllocator *allocator);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstAllocator * gst_allocator_find            (const gchar *name);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void           gst_allocator_set_default     (GstAllocator * allocator);
Packit Service 963350
Packit Service 963350
/* allocation parameters */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void           gst_allocation_params_init    (GstAllocationParams *params);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstAllocationParams *
Packit Service 963350
               gst_allocation_params_copy    (const GstAllocationParams *params) G_GNUC_MALLOC;
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void           gst_allocation_params_free    (GstAllocationParams *params);
Packit Service 963350
Packit Service 963350
/* allocating memory blocks */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMemory *    gst_allocator_alloc           (GstAllocator * allocator, gsize size,
Packit Service 963350
                                              GstAllocationParams *params);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void           gst_allocator_free            (GstAllocator * allocator, GstMemory *memory);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMemory *    gst_memory_new_wrapped  (GstMemoryFlags flags, gpointer data, gsize maxsize,
Packit Service 963350
                                        gsize offset, gsize size, gpointer user_data,
Packit Service 963350
                                        GDestroyNotify notify);
Packit Service 963350
Packit Service 963350
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
Packit Service 963350
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAllocationParams, gst_allocation_params_free)
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
G_END_DECLS
Packit Service 963350
Packit Service 963350
#endif /* __GST_ALLOCATOR_H__ */