32
32
#define GST_TYPE_MEMORY (gst_memory_get_type())
33
33
GType gst_memory_get_type(void);
35
#define GST_TYPE_ALLOCATOR (gst_allocator_get_type())
36
GType gst_allocator_get_type(void);
38
#define GST_TYPE_ALLOCATION_PARAMS (gst_allocation_params_get_type())
39
GType gst_allocation_params_get_type(void);
41
35
typedef struct _GstMemory GstMemory;
42
typedef struct _GstMemoryInfo GstMemoryInfo;
43
36
typedef struct _GstAllocator GstAllocator;
44
typedef struct _GstAllocationParams GstAllocationParams;
47
* gst_memory_alignment:
49
* The default memory alignment in bytes - 1
50
* an alignment of 7 would be the same as what malloc() guarantees.
52
GST_EXPORT gsize gst_memory_alignment;
54
38
#define GST_MEMORY_CAST(mem) ((GstMemory *)(mem))
66
50
* Flags for wrapped memory.
69
GST_MEMORY_FLAG_READONLY = (1 << 0),
70
GST_MEMORY_FLAG_NO_SHARE = (1 << 1),
71
GST_MEMORY_FLAG_ZERO_PREFIXED = (1 << 2),
72
GST_MEMORY_FLAG_ZERO_PADDED = (1 << 3),
53
GST_MEMORY_FLAG_READONLY = GST_MINI_OBJECT_FLAG_LOCK_READONLY,
54
GST_MEMORY_FLAG_NO_SHARE = (GST_MINI_OBJECT_FLAG_LAST << 0),
55
GST_MEMORY_FLAG_ZERO_PREFIXED = (GST_MINI_OBJECT_FLAG_LAST << 1),
56
GST_MEMORY_FLAG_ZERO_PADDED = (GST_MINI_OBJECT_FLAG_LAST << 2),
74
GST_MEMORY_FLAG_LAST = (1 << 16)
58
GST_MEMORY_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 16)
158
146
* Flags used when mapping memory
161
GST_MAP_READ = (1 << 0),
162
GST_MAP_WRITE = (1 << 1),
149
GST_MAP_READ = GST_LOCK_FLAG_READ,
150
GST_MAP_WRITE = GST_LOCK_FLAG_WRITE,
164
152
GST_MAP_FLAG_LAST = (1 << 16)
158
* GstMapFlags value alias for GST_MAP_READ | GST_MAP_WRITE
160
#define GST_MAP_READWRITE (GST_MAP_READ | GST_MAP_WRITE)
169
165
* @memory: a pointer to the mapped memory
170
166
* @flags: flags used when mapping the memory
171
* @data: a pointer to the mapped data
167
* @data: (array length=size): a pointer to the mapped data
172
168
* @size: the valid size in @data
173
169
* @maxsize: the maximum bytes in @data
174
170
* @user_data: extra private user_data that the implementation of the memory
195
191
#define GST_MAP_INFO_INIT { NULL, 0, NULL, 0, 0, }
200
* Map for readwrite access
202
#define GST_MAP_READWRITE (GST_MAP_READ | GST_MAP_WRITE)
205
* GST_ALLOCATOR_SYSMEM:
207
* The allocator name for the default system memory allocator
209
#define GST_ALLOCATOR_SYSMEM "SystemMemory"
212
* GstAllocationParams:
213
* @flags: flags to control allocation
214
* @align: the desired alignment of the memory
215
* @prefix: the disired prefix
216
* @padding: the desired padding
218
* Parameters to control the allocation of memory
220
struct _GstAllocationParams {
221
GstMemoryFlags flags;
227
gpointer _gst_reserved[GST_PADDING];
231
* GstAllocatorAllocFunction:
232
* @allocator: a #GstAllocator
234
* @params: allocator params
235
* @user_data: user data
237
* Allocate a new #GstMemory from @allocator that can hold at least @size
238
* bytes (+ padding) and is aligned to (@align + 1) bytes.
240
* The offset and size of the memory should be set and the prefix/padding must
241
* be filled with 0 if @params flags contains #GST_MEMORY_FLAG_ZERO_PREFIXED and
242
* #GST_MEMORY_FLAG_ZERO_PADDED respectively.
244
* @user_data is the data that was used when creating @allocator.
246
* Returns: a newly allocated #GstMemory. Free with gst_memory_unref()
248
typedef GstMemory * (*GstAllocatorAllocFunction) (GstAllocator *allocator,
249
gsize size, GstAllocationParams *params,
253
194
* GstMemoryMapFunction:
254
195
* @mem: a #GstMemory
255
196
* @maxsize: size to map
326
258
typedef gboolean (*GstMemoryIsSpanFunction) (GstMemory *mem1, GstMemory *mem2, gsize *offset);
330
* @mem_type: the memory type this allocator provides
331
* @alloc: the implementation of the GstAllocatorAllocFunction
332
* @mem_map: the implementation of the GstMemoryMapFunction
333
* @mem_unmap: the implementation of the GstMemoryUnmapFunction
334
* @mem_free: the implementation of the GstMemoryFreeFunction
335
* @mem_copy: the implementation of the GstMemoryCopyFunction
336
* @mem_share: the implementation of the GstMemoryShareFunction
337
* @mem_is_span: the implementation of the GstMemoryIsSpanFunction
339
* The #GstMemoryInfo is used to register new memory allocators and contain
340
* the implementations for various memory operations.
342
struct _GstMemoryInfo {
343
const gchar *mem_type;
345
GstAllocatorAllocFunction alloc;
347
GstMemoryMapFunction mem_map;
348
GstMemoryUnmapFunction mem_unmap;
349
GstMemoryFreeFunction mem_free;
351
GstMemoryCopyFunction mem_copy;
352
GstMemoryShareFunction mem_share;
353
GstMemoryIsSpanFunction mem_is_span;
356
gpointer _gst_reserved[GST_PADDING];
362
* An opaque type returned from gst_allocator_new() or gst_allocator_find()
363
* that can be used to allocator memory.
367
GstAllocator * gst_allocator_new (const GstMemoryInfo * info,
368
gpointer user_data, GDestroyNotify notify);
369
const gchar * gst_allocator_get_memory_type (GstAllocator * allocator);
371
GstAllocator * gst_allocator_ref (GstAllocator * allocator);
372
void gst_allocator_unref (GstAllocator * allocator);
374
void gst_allocator_register (const gchar *name, GstAllocator *allocator);
375
GstAllocator * gst_allocator_find (const gchar *name);
377
void gst_allocator_set_default (GstAllocator * allocator);
379
/* allocating memory blocks */
380
void gst_allocation_params_init (GstAllocationParams *params);
381
GstAllocationParams *
382
gst_allocation_params_copy (const GstAllocationParams *params) G_GNUC_MALLOC;
383
void gst_allocation_params_free (GstAllocationParams *params);
385
GstMemory * gst_allocator_alloc (GstAllocator * allocator, gsize size,
386
GstAllocationParams *params);
388
GstMemory * gst_memory_new_wrapped (GstMemoryFlags flags, gpointer data, gsize maxsize,
389
gsize offset, gsize size, gpointer user_data,
390
GDestroyNotify notify);
260
void gst_memory_init (GstMemory *mem, GstMemoryFlags flags,
261
GstAllocator *allocator, GstMemory *parent,
262
gsize maxsize, gsize align,
263
gsize offset, gsize size);
392
264
/* refcounting */
393
GstMemory * gst_memory_ref (GstMemory *mem);
394
void gst_memory_unref (GstMemory *mem);
396
gboolean gst_memory_is_exclusive (GstMemory *mem);
267
* @memory: The memory to refcount
269
* Increase the refcount of this memory.
271
* Returns: (transfer full): @memory (for convenience when doing assignments)
273
#ifdef _FOOL_GTK_DOC_
274
G_INLINE_FUNC GstMemory * gst_memory_ref (GstMemory * memory);
277
static inline GstMemory *
278
gst_memory_ref (GstMemory * memory)
280
return (GstMemory *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (memory));
285
* @memory: (transfer full): the memory to refcount
287
* Decrease the refcount of an memory, freeing it if the refcount reaches 0.
289
#ifdef _FOOL_GTK_DOC_
290
G_INLINE_FUNC void gst_memory_unref (GstMemory * memory);
294
gst_memory_unref (GstMemory * memory)
296
gst_mini_object_unref (GST_MINI_OBJECT_CAST (memory));
398
299
/* getting/setting memory properties */
399
300
gsize gst_memory_get_sizes (GstMemory *mem, gsize *offset, gsize *maxsize);
400
301
void gst_memory_resize (GstMemory *mem, gssize offset, gsize size);
303
#define gst_memory_lock(m,f) gst_mini_object_lock (GST_MINI_OBJECT_CAST (m), (f))
304
#define gst_memory_unlock(m,f) gst_mini_object_unlock (GST_MINI_OBJECT_CAST (m), (f))
305
#define gst_memory_is_writable(m) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (m))
402
307
/* retrieving data */
403
308
GstMemory * gst_memory_make_mapped (GstMemory *mem, GstMapInfo *info, GstMapFlags flags);
404
309
gboolean gst_memory_map (GstMemory *mem, GstMapInfo *info, GstMapFlags flags);