1 | /* GStreamer fd memory |
2 | * Copyright (C) 2013 Linaro SA |
3 | * Author: Benjamin Gaignard <benjamin.gaignard@linaro.org> for Linaro. |
4 | * |
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. |
9 | * |
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. |
14 | * |
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. |
19 | */ |
20 | |
21 | #ifndef __GST_FD_ALLOCATOR_H__ |
22 | #define __GST_FD_ALLOCATOR_H__ |
23 | |
24 | #include <gst/gst.h> |
25 | #include <gst/allocators/allocators-prelude.h> |
26 | |
27 | G_BEGIN_DECLS |
28 | |
29 | typedef struct _GstFdAllocator GstFdAllocator; |
30 | typedef struct _GstFdAllocatorClass GstFdAllocatorClass; |
31 | |
32 | #define GST_ALLOCATOR_FD "fd" |
33 | |
34 | #define GST_TYPE_FD_ALLOCATOR (gst_fd_allocator_get_type()) |
35 | #define GST_IS_FD_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FD_ALLOCATOR)) |
36 | #define GST_IS_FD_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FD_ALLOCATOR)) |
37 | #define GST_FD_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_FD_ALLOCATOR, GstFdAllocatorClass)) |
38 | #define GST_FD_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FD_ALLOCATOR, GstFdAllocator)) |
39 | #define GST_FD_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_FD_ALLOCATOR, GstFdAllocatorClass)) |
40 | #define GST_FD_ALLOCATOR_CAST(obj) ((GstFdAllocator *)(obj)) |
41 | |
42 | /** |
43 | * GstFdMemoryFlags: |
44 | * @GST_FD_MEMORY_FLAG_NONE: no flag |
45 | * @GST_FD_MEMORY_FLAG_KEEP_MAPPED: once the memory is mapped, |
46 | * keep it mapped until the memory is destroyed. |
47 | * @GST_FD_MEMORY_FLAG_MAP_PRIVATE: do a private mapping instead of |
48 | * the default shared mapping. |
49 | * @GST_FD_MEMORY_FLAG_DONT_CLOSE: don't close the file descriptor when |
50 | * the memory is freed. Since: 1.10 |
51 | * |
52 | * Various flags to control the operation of the fd backed memory. |
53 | * |
54 | * Since: 1.6 |
55 | */ |
56 | typedef enum { |
57 | GST_FD_MEMORY_FLAG_NONE = 0, |
58 | GST_FD_MEMORY_FLAG_KEEP_MAPPED = (1 << 0), |
59 | GST_FD_MEMORY_FLAG_MAP_PRIVATE = (1 << 1), |
60 | GST_FD_MEMORY_FLAG_DONT_CLOSE = (1 << 2), |
61 | } GstFdMemoryFlags; |
62 | |
63 | /** |
64 | * GstFdAllocator: |
65 | * |
66 | * Base class for allocators with fd-backed memory |
67 | * |
68 | * Since: 1.6 |
69 | */ |
70 | struct _GstFdAllocator |
71 | { |
72 | GstAllocator parent; |
73 | }; |
74 | |
75 | struct _GstFdAllocatorClass |
76 | { |
77 | GstAllocatorClass parent_class; |
78 | }; |
79 | |
80 | GST_ALLOCATORS_API |
81 | GType gst_fd_allocator_get_type (void); |
82 | |
83 | GST_ALLOCATORS_API |
84 | GstAllocator * gst_fd_allocator_new (void); |
85 | |
86 | GST_ALLOCATORS_API |
87 | GstMemory * gst_fd_allocator_alloc (GstAllocator * allocator, gint fd, |
88 | gsize size, GstFdMemoryFlags flags); |
89 | |
90 | GST_ALLOCATORS_API |
91 | gboolean gst_is_fd_memory (GstMemory *mem); |
92 | |
93 | GST_ALLOCATORS_API |
94 | gint gst_fd_memory_get_fd (GstMemory *mem); |
95 | |
96 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstFdAllocator, gst_object_unref) |
97 | |
98 | G_END_DECLS |
99 | |
100 | #endif /* __GST_FD_ALLOCATOR_H__ */ |
101 | |