~ubuntu-branches/ubuntu/trusty/gstreamer1.0/trusty

« back to all changes in this revision

Viewing changes to gst/gstallocator.h

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2012-08-08 18:12:33 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120808181233-riejwxprfsxh1njl
Tags: 0.11.93-1
* New upstream release:
  + debian/libgstreamer.symbols:
    - Update symbols file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GStreamer
 
2
 * Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
 
3
 *
 
4
 * gstallocator.h: Header for memory allocation
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
20
 */
 
21
 
 
22
 
 
23
#ifndef __GST_ALLOCATOR_H__
 
24
#define __GST_ALLOCATOR_H__
 
25
 
 
26
#include <gst/gstmemory.h>
 
27
 
 
28
G_BEGIN_DECLS
 
29
 
 
30
typedef struct _GstAllocatorPrivate GstAllocatorPrivate;
 
31
typedef struct _GstAllocatorClass GstAllocatorClass;
 
32
 
 
33
#define GST_TYPE_ALLOCATOR                 (gst_allocator_get_type())
 
34
#define GST_IS_ALLOCATOR(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ALLOCATOR))
 
35
#define GST_IS_ALLOCATOR_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ALLOCATOR))
 
36
#define GST_ALLOCATOR_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ALLOCATOR, GstAllocatorClass))
 
37
#define GST_ALLOCATOR(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ALLOCATOR, GstAllocator))
 
38
#define GST_ALLOCATOR_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ALLOCATOR, GstAllocatorClass))
 
39
#define GST_ALLOCATOR_CAST(obj)            ((GstAllocator *)(obj))
 
40
 
 
41
#define GST_TYPE_ALLOCATION_PARAMS (gst_allocation_params_get_type())
 
42
GType gst_allocation_params_get_type(void);
 
43
 
 
44
typedef struct _GstAllocationParams GstAllocationParams;
 
45
 
 
46
/**
 
47
 * gst_memory_alignment:
 
48
 *
 
49
 * The default memory alignment in bytes - 1
 
50
 * an alignment of 7 would be the same as what malloc() guarantees.
 
51
 */
 
52
GST_EXPORT gsize gst_memory_alignment;
 
53
 
 
54
/**
 
55
 * GST_ALLOCATOR_SYSMEM:
 
56
 *
 
57
 * The allocator name for the default system memory allocator
 
58
 */
 
59
#define GST_ALLOCATOR_SYSMEM   "SystemMemory"
 
60
 
 
61
/**
 
62
 * GstAllocationParams:
 
63
 * @flags: flags to control allocation
 
64
 * @align: the desired alignment of the memory
 
65
 * @prefix: the desired prefix
 
66
 * @padding: the desired padding
 
67
 *
 
68
 * Parameters to control the allocation of memory
 
69
 */
 
70
struct _GstAllocationParams {
 
71
  GstMemoryFlags flags;
 
72
  gsize          align;
 
73
  gsize          prefix;
 
74
  gsize          padding;
 
75
 
 
76
  /*< private >*/
 
77
  gpointer _gst_reserved[GST_PADDING];
 
78
};
 
79
 
 
80
/**
 
81
 * GstAllocatorFlags:
 
82
 * @GST_ALLOCATOR_FLAG_CUSTOM_ALLOC: The allocator has a custom alloc function.
 
83
 * @GST_ALLOCATOR_FLAG_LAST: first flag that can be used for custom purposes
 
84
 *
 
85
 * Flags for allocators.
 
86
 */
 
87
typedef enum {
 
88
  GST_ALLOCATOR_FLAG_CUSTOM_ALLOC  = (GST_OBJECT_FLAG_LAST << 0),
 
89
 
 
90
  GST_ALLOCATOR_FLAG_LAST          = (GST_OBJECT_FLAG_LAST << 16)
 
91
} GstAllocatorFlags;
 
92
 
 
93
/**
 
94
 * GstAllocator:
 
95
 * @object: parent structure
 
96
 * @mem_type: the memory type this allocator provides
 
97
 * @mem_map: the implementation of the GstMemoryMapFunction
 
98
 * @mem_unmap: the implementation of the GstMemoryUnmapFunction
 
99
 * @mem_copy: the implementation of the GstMemoryCopyFunction
 
100
 * @mem_share: the implementation of the GstMemoryShareFunction
 
101
 * @mem_is_span: the implementation of the GstMemoryIsSpanFunction
 
102
 *
 
103
 * The #GstAllocator is used to create new memory.
 
104
 */
 
105
struct _GstAllocator
 
106
{
 
107
  GstObject  object;
 
108
 
 
109
  const gchar              *mem_type;
 
110
 
 
111
  GstMemoryMapFunction      mem_map;
 
112
  GstMemoryUnmapFunction    mem_unmap;
 
113
 
 
114
  GstMemoryCopyFunction     mem_copy;
 
115
  GstMemoryShareFunction    mem_share;
 
116
  GstMemoryIsSpanFunction   mem_is_span;
 
117
 
 
118
  /*< private >*/
 
119
  gpointer _gst_reserved[GST_PADDING];
 
120
 
 
121
  GstAllocatorPrivate *priv;
 
122
};
 
123
 
 
124
struct _GstAllocatorClass {
 
125
  GstObjectClass object_class;
 
126
 
 
127
  GstMemory *  (*alloc)      (GstAllocator *allocator, gsize size,
 
128
                              GstAllocationParams *params);
 
129
  void         (*free)       (GstAllocator *allocator, GstMemory *memory);
 
130
 
 
131
  /*< private >*/
 
132
  gpointer _gst_reserved[GST_PADDING];
 
133
};
 
134
 
 
135
GType gst_allocator_get_type(void);
 
136
 
 
137
/* allocators */
 
138
void           gst_allocator_register        (const gchar *name, GstAllocator *allocator);
 
139
GstAllocator * gst_allocator_find            (const gchar *name);
 
140
void           gst_allocator_set_default     (GstAllocator * allocator);
 
141
 
 
142
/* allocation parameters */
 
143
void           gst_allocation_params_init    (GstAllocationParams *params);
 
144
GstAllocationParams *
 
145
               gst_allocation_params_copy    (const GstAllocationParams *params) G_GNUC_MALLOC;
 
146
void           gst_allocation_params_free    (GstAllocationParams *params);
 
147
 
 
148
/* allocating memory blocks */
 
149
GstMemory *    gst_allocator_alloc           (GstAllocator * allocator, gsize size,
 
150
                                              GstAllocationParams *params);
 
151
void           gst_allocator_free            (GstAllocator * allocator, GstMemory *memory);
 
152
 
 
153
GstMemory *    gst_memory_new_wrapped  (GstMemoryFlags flags, gpointer data, gsize maxsize,
 
154
                                        gsize offset, gsize size, gpointer user_data,
 
155
                                        GDestroyNotify notify);
 
156
 
 
157
G_END_DECLS
 
158
 
 
159
#endif /* __GST_ALLOCATOR_H__ */