diff options
author | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
commit | 5323a782c4e8c42781f22ce2f488962a18f82554 (patch) | |
tree | f71537197b16f0f8fd0d6937f7120d018d220814 /include/gst/allocators | |
parent | 50acf9d37183f86f6f623aad410003392b0af41f (diff) |
Jabber: initial version of Jingle support
Diffstat (limited to 'include/gst/allocators')
-rw-r--r-- | include/gst/allocators/allocators-prelude.h | 33 | ||||
-rw-r--r-- | include/gst/allocators/allocators.h | 32 | ||||
-rw-r--r-- | include/gst/allocators/gstdmabuf.h | 120 | ||||
-rw-r--r-- | include/gst/allocators/gstfdmemory.h | 100 | ||||
-rw-r--r-- | include/gst/allocators/gstphysmemory.h | 62 |
5 files changed, 347 insertions, 0 deletions
diff --git a/include/gst/allocators/allocators-prelude.h b/include/gst/allocators/allocators-prelude.h new file mode 100644 index 0000000000..c18a815a8e --- /dev/null +++ b/include/gst/allocators/allocators-prelude.h @@ -0,0 +1,33 @@ +/* GStreamer Allocators Library + * Copyright (C) 2018 GStreamer developers + * + * allocators-prelude.h: prelude include header for gst-allocators library + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_ALLOCATORS_PRELUDE_H__ +#define __GST_ALLOCATORS_PRELUDE_H__ + +#include <gst/gst.h> + +#ifdef BUILDING_GST_ALLOCATORS +#define GST_ALLOCATORS_API GST_API_EXPORT /* from config.h */ +#else +#define GST_ALLOCATORS_API GST_API_IMPORT +#endif + +#endif /* __GST_ALLOCATORS_PRELUDE_H__ */ diff --git a/include/gst/allocators/allocators.h b/include/gst/allocators/allocators.h new file mode 100644 index 0000000000..b616aa20e6 --- /dev/null +++ b/include/gst/allocators/allocators.h @@ -0,0 +1,32 @@ +/* GStreamer + * Copyright (C) 2012 GStreamer developers + * + * allocators.h: single include header for gst-allocators library + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_ALLOCATORS_H__ +#define __GST_ALLOCATORS_H__ + +#include <gst/allocators/allocators-prelude.h> + +#include <gst/allocators/gstdmabuf.h> +#include <gst/allocators/gstfdmemory.h> +#include <gst/allocators/gstphysmemory.h> + +#endif /* __GST_ALLOCATORS_H__ */ + diff --git a/include/gst/allocators/gstdmabuf.h b/include/gst/allocators/gstdmabuf.h new file mode 100644 index 0000000000..603331ae90 --- /dev/null +++ b/include/gst/allocators/gstdmabuf.h @@ -0,0 +1,120 @@ +/* GStreamer dmabuf allocator + * 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. + */ + +#ifndef __GST_DMABUF_H__ +#define __GST_DMABUF_H__ + +#include <gst/gst.h> +#include <gst/allocators/gstfdmemory.h> + +G_BEGIN_DECLS + +/** + * GST_CAPS_FEATURE_MEMORY_DMABUF: + * + * Constant that defines the caps feature name for DMA buffer sharing. + * + * It has to be used for non-mappable dma-buf only, i.e. when the underlying + * memory is not mappable to user space. Or when the mapped memory contains + * non meaningful data. It can be the case for protected content or when the + * user wants explicitly avoid any software post processing. + * + * In these cases all elements between the exported and the importer has to work + * in passthrough mode. This is done by adding this caps feature. + * + * When the memory is mappable for read and write requests then it is assumes + * to be a fast path and so this caps feature should not be used. Though + * according to the dma-buf protocol, while it is mapped it prevents the + * exporter to migrate the buffer. + * + * This caps feature should not serve at all the purpose of selecting the + * @GST_ALLOCATOR_DMABUF allocator during caps negotiation. + * When the exporter is the upstream element from the importer point of view, + * the exporter should try to map the dma buffer at runtime (preferably during + * decide_allocation phase). When it succeeds for #GST_MAP_READWRITE this caps + * feature should not be used. This allows scalers, color converts and any image + * processing filters to work directly on the dma buffer. + * In this case the importer element should check all incoming memory using + * gst_is_dmabuf_memory(). + * + * Since: 1.12 + */ +#define GST_CAPS_FEATURE_MEMORY_DMABUF "memory:DMABuf" + +#define GST_ALLOCATOR_DMABUF "dmabuf" + +#define GST_TYPE_DMABUF_ALLOCATOR (gst_dmabuf_allocator_get_type()) +#define GST_IS_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DMABUF_ALLOCATOR)) +#define GST_IS_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DMABUF_ALLOCATOR)) +#define GST_DMABUF_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DMABUF_ALLOCATOR, GstDmaBufAllocatorClass)) +#define GST_DMABUF_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DMABUF_ALLOCATOR, GstDmaBufAllocator)) +#define GST_DMABUF_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DMABUF_ALLOCATOR, GstDmaBufAllocatorClass)) +#define GST_DMABUF_ALLOCATOR_CAST(obj) ((GstDmaBufAllocator *)(obj)) + +typedef struct _GstDmaBufAllocator GstDmaBufAllocator; +typedef struct _GstDmaBufAllocatorClass GstDmaBufAllocatorClass; + +/** + * GstDmaBufAllocator: + * + * Base class for allocators with dmabuf-backed memory + * + * Since: 1.12 + */ +struct _GstDmaBufAllocator +{ + GstFdAllocator parent; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +struct _GstDmaBufAllocatorClass +{ + GstFdAllocatorClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + + +GST_ALLOCATORS_API +GType gst_dmabuf_allocator_get_type (void); + +GST_ALLOCATORS_API +GstAllocator * gst_dmabuf_allocator_new (void); + +GST_ALLOCATORS_API +GstMemory * gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size); + +GST_ALLOCATORS_API +GstMemory * gst_dmabuf_allocator_alloc_with_flags (GstAllocator * allocator, gint fd, gsize size, GstFdMemoryFlags flags); + +GST_ALLOCATORS_API +gint gst_dmabuf_memory_get_fd (GstMemory * mem); + +GST_ALLOCATORS_API +gboolean gst_is_dmabuf_memory (GstMemory * mem); + + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDmaBufAllocator, gst_object_unref) + +G_END_DECLS +#endif /* __GST_DMABUF_H__ */ diff --git a/include/gst/allocators/gstfdmemory.h b/include/gst/allocators/gstfdmemory.h new file mode 100644 index 0000000000..43217b7033 --- /dev/null +++ b/include/gst/allocators/gstfdmemory.h @@ -0,0 +1,100 @@ +/* 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. + */ + +#ifndef __GST_FD_ALLOCATOR_H__ +#define __GST_FD_ALLOCATOR_H__ + +#include <gst/gst.h> +#include <gst/allocators/allocators-prelude.h> + +G_BEGIN_DECLS + +typedef struct _GstFdAllocator GstFdAllocator; +typedef struct _GstFdAllocatorClass GstFdAllocatorClass; + +#define GST_ALLOCATOR_FD "fd" + +#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)) + +/** + * GstFdMemoryFlags: + * @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. + * @GST_FD_MEMORY_FLAG_DONT_CLOSE: don't close the file descriptor when + * the memory is freed. Since: 1.10 + * + * Various flags to control the operation of the fd backed memory. + * + * Since: 1.6 + */ +typedef enum { + GST_FD_MEMORY_FLAG_NONE = 0, + GST_FD_MEMORY_FLAG_KEEP_MAPPED = (1 << 0), + GST_FD_MEMORY_FLAG_MAP_PRIVATE = (1 << 1), + GST_FD_MEMORY_FLAG_DONT_CLOSE = (1 << 2), +} GstFdMemoryFlags; + +/** + * GstFdAllocator: + * + * Base class for allocators with fd-backed memory + * + * Since: 1.6 + */ +struct _GstFdAllocator +{ + GstAllocator parent; +}; + +struct _GstFdAllocatorClass +{ + GstAllocatorClass parent_class; +}; + +GST_ALLOCATORS_API +GType gst_fd_allocator_get_type (void); + +GST_ALLOCATORS_API +GstAllocator * gst_fd_allocator_new (void); + +GST_ALLOCATORS_API +GstMemory * gst_fd_allocator_alloc (GstAllocator * allocator, gint fd, + gsize size, GstFdMemoryFlags flags); + +GST_ALLOCATORS_API +gboolean gst_is_fd_memory (GstMemory *mem); + +GST_ALLOCATORS_API +gint gst_fd_memory_get_fd (GstMemory *mem); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstFdAllocator, gst_object_unref) + +G_END_DECLS + +#endif /* __GST_FD_ALLOCATOR_H__ */ diff --git a/include/gst/allocators/gstphysmemory.h b/include/gst/allocators/gstphysmemory.h new file mode 100644 index 0000000000..d0a9d07134 --- /dev/null +++ b/include/gst/allocators/gstphysmemory.h @@ -0,0 +1,62 @@ +/* GStreamer + * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com> + * + * 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. + */ + +#ifndef __GST_PHYS_MEMORY_H__ +#define __GST_PHYS_MEMORY_H__ + +#include <gst/gst.h> +#include <gst/allocators/allocators-prelude.h> + +G_BEGIN_DECLS + +#define GST_TYPE_PHYS_MEMORY_ALLOCATOR (gst_phys_memory_allocator_get_type()) +GST_ALLOCATORS_API +G_DECLARE_INTERFACE (GstPhysMemoryAllocator, gst_phys_memory_allocator, + GST, PHYS_MEMORY_ALLOCATOR, GstAllocator) + +#define GST_PHYS_MEMORY_ALLOCATOR_GET_INTERFACE(obj) (GST_PHYS_MEMORY_ALLOCATOR_GET_IFACE(obj)) +#define GST_PHYS_MEMORY_ALLOCATOR_CAST(obj) ((GstPhysMemoryAllocator *)(obj)) + +/** + * GstPhysMemoryAllocatorInterface: + * @get_phys_addr: Implementations shall return the physicall memory address + * that is backing the provided memory, or 0 if none. + * + * Marker interface for allocators with physical address backed memory + * + * Since: 1.14 + */ +struct _GstPhysMemoryAllocatorInterface +{ + /*< private >*/ + GTypeInterface parent_iface; + + /*< public >*/ + guintptr (*get_phys_addr) (GstPhysMemoryAllocator * allocator, GstMemory * mem); +}; + +GST_ALLOCATORS_API +gboolean gst_is_phys_memory (GstMemory *mem); + +GST_ALLOCATORS_API +guintptr gst_phys_memory_get_phys_addr (GstMemory * mem); + +G_END_DECLS + +#endif /* __GST_PHYS_MEMORY_H__ */ |