2015-03-15 14:16:23 +00:00
|
|
|
/* GStreamer fd memory
|
|
|
|
* Copyright (C) 2013 Linaro SA
|
|
|
|
* Author: Benjamin Gaignard <benjamin.gaignard@linaro.org> for Linaro.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2015-03-18 14:12:03 +00:00
|
|
|
#ifndef __GST_FD_ALLOCATOR_H__
|
|
|
|
#define __GST_FD_ALLOCATOR_H__
|
2015-03-15 14:16:23 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2018-03-13 10:19:16 +00:00
|
|
|
#include <gst/allocators/allocators-prelude.h>
|
2015-03-15 14:16:23 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2015-03-18 14:12:03 +00:00
|
|
|
typedef struct _GstFdAllocator GstFdAllocator;
|
|
|
|
typedef struct _GstFdAllocatorClass GstFdAllocatorClass;
|
|
|
|
|
2015-04-17 07:31:40 +00:00
|
|
|
#define GST_ALLOCATOR_FD "fd"
|
|
|
|
|
2015-03-18 14:12:03 +00:00
|
|
|
#define GST_TYPE_FD_ALLOCATOR (gst_fd_allocator_get_type())
|
|
|
|
#define GST_IS_FD_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FD_ALLOCATOR))
|
|
|
|
#define GST_IS_FD_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FD_ALLOCATOR))
|
|
|
|
#define GST_FD_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_FD_ALLOCATOR, GstFdAllocatorClass))
|
|
|
|
#define GST_FD_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FD_ALLOCATOR, GstFdAllocator))
|
|
|
|
#define GST_FD_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_FD_ALLOCATOR, GstFdAllocatorClass))
|
|
|
|
#define GST_FD_ALLOCATOR_CAST(obj) ((GstFdAllocator *)(obj))
|
|
|
|
|
2015-03-15 16:27:33 +00:00
|
|
|
/**
|
2015-05-18 18:45:45 +00:00
|
|
|
* GstFdMemoryFlags:
|
2015-03-15 16:27:33 +00:00
|
|
|
* @GST_FD_MEMORY_FLAG_NONE: no flag
|
|
|
|
* @GST_FD_MEMORY_FLAG_KEEP_MAPPED: once the memory is mapped,
|
|
|
|
* keep it mapped until the memory is destroyed.
|
|
|
|
* @GST_FD_MEMORY_FLAG_MAP_PRIVATE: do a private mapping instead of
|
|
|
|
* the default shared mapping.
|
2016-08-19 07:27:01 +00:00
|
|
|
* @GST_FD_MEMORY_FLAG_DONT_CLOSE: don't close the file descriptor when
|
2018-02-14 19:11:47 +00:00
|
|
|
* the memory is freed. Since: 1.10
|
2015-03-15 16:27:33 +00:00
|
|
|
*
|
|
|
|
* Various flags to control the operation of the fd backed memory.
|
2015-03-18 14:12:03 +00:00
|
|
|
*
|
|
|
|
* Since: 1.6
|
2015-03-15 16:27:33 +00:00
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
GST_FD_MEMORY_FLAG_NONE = 0,
|
|
|
|
GST_FD_MEMORY_FLAG_KEEP_MAPPED = (1 << 0),
|
|
|
|
GST_FD_MEMORY_FLAG_MAP_PRIVATE = (1 << 1),
|
2016-08-19 07:27:01 +00:00
|
|
|
GST_FD_MEMORY_FLAG_DONT_CLOSE = (1 << 2),
|
2015-03-15 16:27:33 +00:00
|
|
|
} GstFdMemoryFlags;
|
|
|
|
|
2015-03-18 14:12:03 +00:00
|
|
|
/**
|
|
|
|
* GstFdAllocator:
|
|
|
|
*
|
|
|
|
* Base class for allocators with fd-backed memory
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
2015-03-15 14:16:23 +00:00
|
|
|
*/
|
2015-03-18 14:12:03 +00:00
|
|
|
struct _GstFdAllocator
|
2015-03-15 14:16:23 +00:00
|
|
|
{
|
2015-03-18 14:12:03 +00:00
|
|
|
GstAllocator parent;
|
|
|
|
};
|
2015-03-15 14:16:23 +00:00
|
|
|
|
2015-03-18 14:12:03 +00:00
|
|
|
struct _GstFdAllocatorClass
|
|
|
|
{
|
|
|
|
GstAllocatorClass parent_class;
|
|
|
|
};
|
2015-03-15 14:16:23 +00:00
|
|
|
|
2018-03-13 10:19:16 +00:00
|
|
|
GST_ALLOCATORS_API
|
2017-05-15 23:30:34 +00:00
|
|
|
GType gst_fd_allocator_get_type (void);
|
2015-03-15 14:16:23 +00:00
|
|
|
|
2018-03-13 10:19:16 +00:00
|
|
|
GST_ALLOCATORS_API
|
2015-04-17 07:31:40 +00:00
|
|
|
GstAllocator * gst_fd_allocator_new (void);
|
2017-05-15 23:30:34 +00:00
|
|
|
|
2018-03-13 10:19:16 +00:00
|
|
|
GST_ALLOCATORS_API
|
2015-04-17 07:31:40 +00:00
|
|
|
GstMemory * gst_fd_allocator_alloc (GstAllocator * allocator, gint fd,
|
|
|
|
gsize size, GstFdMemoryFlags flags);
|
|
|
|
|
2018-03-13 10:19:16 +00:00
|
|
|
GST_ALLOCATORS_API
|
2015-04-17 07:31:40 +00:00
|
|
|
gboolean gst_is_fd_memory (GstMemory *mem);
|
2017-05-15 23:30:34 +00:00
|
|
|
|
2018-03-13 10:19:16 +00:00
|
|
|
GST_ALLOCATORS_API
|
2015-04-17 07:31:40 +00:00
|
|
|
gint gst_fd_memory_get_fd (GstMemory *mem);
|
2015-03-15 14:16:23 +00:00
|
|
|
|
2015-11-10 17:54:23 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstFdAllocator, gst_object_unref)
|
|
|
|
|
2015-03-15 14:16:23 +00:00
|
|
|
G_END_DECLS
|
2015-03-18 14:12:03 +00:00
|
|
|
|
|
|
|
#endif /* __GST_FD_ALLOCATOR_H__ */
|