2 * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
4 * gstmemory.h: Header for memory blocks
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #ifndef __GST_MEMORY_H__
24 #define __GST_MEMORY_H__
30 typedef struct _GstMemory GstMemory;
31 typedef struct _GstMemoryInfo GstMemoryInfo;
32 typedef struct _GstMemoryImpl GstMemoryImpl;
36 * @info: pointer to the #GstMemoryInfo
38 * Base structure for memory implementations. Custom memory will put this structure
39 * as the first member of their structure.
42 const GstMemoryImpl *impl;
53 * GST_MEMORY_TRACE_NAME:
55 * The name used for tracing memory allocations.
57 #define GST_MEMORY_TRACE_NAME "GstMemory"
59 typedef gsize (*GstMemoryGetSizesFunction) (GstMemory *mem, gsize *maxsize);
61 typedef void (*GstMemorySetSizeFunction) (GstMemory *mem, gsize size);
62 typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize *size, gsize *maxsize,
64 typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gsize size);
66 typedef void (*GstMemoryFreeFunction) (GstMemory *mem);
67 typedef GstMemory * (*GstMemoryCopyFunction) (GstMemory *mem);
71 * @impl: tag indentifying the implementor of the api
72 * @size: size of the memory structure
74 * The #GstMemoryInfo provides information about a specific metadata
77 struct _GstMemoryInfo {
78 GstMemoryGetSizesFunction get_sizes;
79 GstMemorySetSizeFunction set_size;
80 GstMemoryMapFunction map;
81 GstMemoryUnmapFunction unmap;
82 GstMemoryFreeFunction free;
83 GstMemoryCopyFunction copy;
86 void _gst_memory_init (void);
88 GstMemory * gst_memory_ref (GstMemory *mem);
89 void gst_memory_unref (GstMemory *mem);
91 gsize gst_memory_get_sizes (GstMemory *mem, gsize *maxsize);
92 void gst_memory_set_size (GstMemory *mem, gsize size);
94 gpointer gst_memory_map (GstMemory *mem, gsize *size, gsize *maxsize,
96 gboolean gst_memory_unmap (GstMemory *mem, gpointer data, gsize size);
98 GstMemory * gst_memory_copy (GstMemory *mem);
101 GstMemory * gst_memory_new_wrapped (gpointer data, GFreeFunc free_func,
102 gsize maxsize, gsize offset, gsize size);
103 GstMemory * gst_memory_new_alloc (gsize maxsize, gsize align);
106 const GstMemoryImpl * gst_memory_register (const gchar *impl, const GstMemoryInfo *info);
109 const GstMemoryInfo * gst_memory_get_info (const gchar * impl);
114 #endif /* __GST_MEMORY_H__ */