2 * Copyright (C) 2013 Linaro SA
3 * Author: Benjamin Gaignard <benjamin.gaignard@linaro.org> for Linaro.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __GST_FD_ALLOCATOR_H__
22 #define __GST_FD_ALLOCATOR_H__
28 typedef struct _GstFdAllocator GstFdAllocator;
29 typedef struct _GstFdAllocatorClass GstFdAllocatorClass;
31 #define GST_ALLOCATOR_FD "fd"
33 #define GST_TYPE_FD_ALLOCATOR (gst_fd_allocator_get_type())
34 #define GST_IS_FD_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FD_ALLOCATOR))
35 #define GST_IS_FD_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FD_ALLOCATOR))
36 #define GST_FD_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_FD_ALLOCATOR, GstFdAllocatorClass))
37 #define GST_FD_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FD_ALLOCATOR, GstFdAllocator))
38 #define GST_FD_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_FD_ALLOCATOR, GstFdAllocatorClass))
39 #define GST_FD_ALLOCATOR_CAST(obj) ((GstFdAllocator *)(obj))
43 * @GST_FD_MEMORY_FLAG_NONE: no flag
44 * @GST_FD_MEMORY_FLAG_KEEP_MAPPED: once the memory is mapped,
45 * keep it mapped until the memory is destroyed.
46 * @GST_FD_MEMORY_FLAG_MAP_PRIVATE: do a private mapping instead of
47 * the default shared mapping.
49 * Various flags to control the operation of the fd backed memory.
54 GST_FD_MEMORY_FLAG_NONE = 0,
55 GST_FD_MEMORY_FLAG_KEEP_MAPPED = (1 << 0),
56 GST_FD_MEMORY_FLAG_MAP_PRIVATE = (1 << 1),
62 * Base class for allocators with fd-backed memory
66 struct _GstFdAllocator
71 struct _GstFdAllocatorClass
73 GstAllocatorClass parent_class;
76 GType gst_fd_allocator_get_type (void);
78 GstAllocator * gst_fd_allocator_new (void);
79 GstMemory * gst_fd_allocator_alloc (GstAllocator * allocator, gint fd,
80 gsize size, GstFdMemoryFlags flags);
82 gboolean gst_is_fd_memory (GstMemory *mem);
83 gint gst_fd_memory_get_fd (GstMemory *mem);
85 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
86 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstFdAllocator, gst_object_unref)
91 #endif /* __GST_FD_ALLOCATOR_H__ */