mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
allocators: Add GstPhysMemoryAllocator abstraction
This can be used in a generic way as common interface by all platforms that, in one way or another, pass around physical memory addresses. https://bugzilla.gnome.org/show_bug.cgi?id=779067
This commit is contained in:
parent
2132ba9a94
commit
5cdf3a3976
9 changed files with 265 additions and 6 deletions
|
@ -3584,6 +3584,7 @@ gst-libs/gst/player/Makefile
|
|||
gst-libs/gst/video/Makefile
|
||||
gst-libs/gst/audio/Makefile
|
||||
gst-libs/gst/opencv/Makefile
|
||||
gst-libs/gst/allocators/Makefile
|
||||
sys/Makefile
|
||||
sys/dshowdecwrapper/Makefile
|
||||
sys/acmenc/Makefile
|
||||
|
@ -3734,6 +3735,8 @@ pkgconfig/gstreamer-bad-video.pc
|
|||
pkgconfig/gstreamer-bad-video-uninstalled.pc
|
||||
pkgconfig/gstreamer-bad-audio.pc
|
||||
pkgconfig/gstreamer-bad-audio-uninstalled.pc
|
||||
pkgconfig/gstreamer-bad-allocators.pc
|
||||
pkgconfig/gstreamer-bad-allocators-uninstalled.pc
|
||||
tools/Makefile
|
||||
m4/Makefile
|
||||
)
|
||||
|
|
|
@ -15,12 +15,12 @@ OPENCV_DIR=opencv
|
|||
endif
|
||||
|
||||
SUBDIRS = uridownloader adaptivedemux interfaces basecamerabinsrc codecparsers \
|
||||
insertbin mpegts base video audio player $(GL_DIR) $(WAYLAND_DIR) \
|
||||
insertbin mpegts base video audio player allocators $(GL_DIR) $(WAYLAND_DIR) \
|
||||
$(OPENCV_DIR)
|
||||
|
||||
noinst_HEADERS = gst-i18n-plugin.h gettext.h glib-compat-private.h
|
||||
DIST_SUBDIRS = uridownloader adaptivedemux interfaces gl basecamerabinsrc \
|
||||
codecparsers insertbin mpegts wayland opencv base video audio player
|
||||
codecparsers insertbin mpegts wayland opencv base video audio player allocators
|
||||
|
||||
#dependencies
|
||||
video, audio: base
|
||||
|
@ -29,7 +29,7 @@ adaptivedemux: uridownloader
|
|||
|
||||
INDEPENDENT_SUBDIRS = \
|
||||
interfaces basecamerabinsrc codecparsers insertbin uridownloader \
|
||||
mpegts base player $(GL_DIR) $(WAYLAND_DIR) $(OPENCV_DIR)
|
||||
mpegts base player allocators $(GL_DIR) $(WAYLAND_DIR) $(OPENCV_DIR)
|
||||
|
||||
.PHONY: independent-subdirs $(INDEPENDENT_SUBDIRS)
|
||||
|
||||
|
|
65
gst-libs/gst/allocators/Makefile.am
Normal file
65
gst-libs/gst/allocators/Makefile.am
Normal file
|
@ -0,0 +1,65 @@
|
|||
lib_LTLIBRARIES = libgstbadallocators-@GST_API_VERSION@.la
|
||||
|
||||
libgstbadallocators_@GST_API_VERSION@_includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/allocators
|
||||
|
||||
libgstbadallocators_@GST_API_VERSION@_include_HEADERS = \
|
||||
badallocators.h \
|
||||
gstphysmemory.h
|
||||
|
||||
noinst_HEADERS =
|
||||
|
||||
libgstbadallocators_@GST_API_VERSION@_la_SOURCES = \
|
||||
gstphysmemory.c
|
||||
|
||||
libgstbadallocators_@GST_API_VERSION@_la_LIBADD = $(GST_LIBS) $(LIBM)
|
||||
libgstbadallocators_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
|
||||
libgstbadallocators_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
BUILT_GIRSOURCES = GstBadAllocators-@GST_API_VERSION@.gir
|
||||
|
||||
gir_headers=$(patsubst %,$(srcdir)/%, $(libgstbadallocators_@GST_API_VERSION@_include_HEADERS))
|
||||
gir_sources=$(patsubst %,$(srcdir)/%, $(libgstbadallocators_@GST_API_VERSION@_la_SOURCES))
|
||||
gir_cincludes=$(patsubst %,--c-include='gst/badallocators/%',$(libgstbadallocators_@GST_API_VERSION@_include_HEADERS))
|
||||
|
||||
GstBadAllocators-@GST_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libgstbadallocators-@GST_API_VERSION@.la
|
||||
$(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" GI_SCANNER_DISABLE_CACHE=yes\
|
||||
GST_PLUGIN_SYSTEM_PATH="" GST_PLUGIN_PATH="" GST_REGISTRY_UPDATE=no \
|
||||
CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" CC="$(CC)" PKG_CONFIG="$(PKG_CONFIG)" DLLTOOL="$(DLLTOOL)" \
|
||||
$(INTROSPECTION_SCANNER) -v --namespace GstBadAllocators \
|
||||
--nsversion=@GST_API_VERSION@ \
|
||||
--identifier-prefix=Gst \
|
||||
--symbol-prefix=gst \
|
||||
--warn-all \
|
||||
--c-include "gst/allocators/badallocators.h" \
|
||||
-I$(top_srcdir)/gst-libs \
|
||||
-I$(top_builddir)/gst-libs \
|
||||
--add-include-path=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-@GST_API_VERSION@` \
|
||||
--library=libgstbadallocators-@GST_API_VERSION@.la \
|
||||
--include=Gst-@GST_API_VERSION@ \
|
||||
--libtool="$(top_builddir)/libtool" \
|
||||
--pkg gstreamer-@GST_API_VERSION@ \
|
||||
--pkg-export gstreamer-badallocators-@GST_API_VERSION@ \
|
||||
--output $@ \
|
||||
$(gir_headers) \
|
||||
$(gir_sources)
|
||||
|
||||
# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
|
||||
# install anything - we need to install inside our prefix.
|
||||
girdir = $(datadir)/gir-1.0
|
||||
gir_DATA = $(BUILT_GIRSOURCES)
|
||||
|
||||
typelibsdir = $(libdir)/girepository-1.0/
|
||||
|
||||
typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
|
||||
|
||||
%.typelib: %.gir $(INTROSPECTION_COMPILER)
|
||||
$(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
|
||||
$(INTROSPECTION_COMPILER) \
|
||||
--includedir=$(srcdir) \
|
||||
--includedir=$(builddir) \
|
||||
--includedir=`PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" $(PKG_CONFIG) --variable=girdir gstreamer-@GST_API_VERSION@` \
|
||||
$(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
|
||||
|
||||
CLEANFILES = $(BUILT_GIRSOURCES) $(typelibs_DATA)
|
||||
endif
|
28
gst-libs/gst/allocators/badallocators.h
Normal file
28
gst-libs/gst/allocators/badallocators.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2017 GStreamer developers
|
||||
*
|
||||
* allocatorsbad.h: single include header for gst-allocators-bad 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_BAD_H__
|
||||
#define __GST_ALLOCATORS_BAD_H__
|
||||
|
||||
#include <gst/allocators/gstphysmemory.h>
|
||||
|
||||
#endif /* __GST_ALLOCATORS_BAD_H__ */
|
||||
|
69
gst-libs/gst/allocators/gstphysmemory.c
Normal file
69
gst-libs/gst/allocators/gstphysmemory.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstphysmemory.h"
|
||||
|
||||
G_DEFINE_INTERFACE (GstPhysMemoryAllocator, gst_phys_memory_allocator,
|
||||
GST_TYPE_ALLOCATOR);
|
||||
|
||||
static void
|
||||
gst_phys_memory_allocator_default_init (GstPhysMemoryAllocatorInterface * iface)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_is_phys_memory:
|
||||
* @mem: a #GstMemory
|
||||
*
|
||||
* Returns: whether the memory at @mem is backed by physical memory
|
||||
*
|
||||
* Since: 1.12
|
||||
*/
|
||||
gboolean
|
||||
gst_is_phys_memory (GstMemory * mem)
|
||||
{
|
||||
return mem != NULL && mem->allocator != NULL
|
||||
&& g_type_is_a (G_OBJECT_TYPE (mem->allocator),
|
||||
GST_TYPE_PHYS_MEMORY_ALLOCATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_phys_memory_get_phys_addr:
|
||||
* @mem: a #GstMemory
|
||||
*
|
||||
* Returns: Physical memory address that is backing @mem, or 0 if none
|
||||
*
|
||||
* Since: 1.12
|
||||
*/
|
||||
guintptr
|
||||
gst_phys_memory_get_phys_addr (GstMemory * mem)
|
||||
{
|
||||
GstPhysMemoryAllocatorInterface *iface;
|
||||
|
||||
g_return_val_if_fail (gst_is_phys_memory (mem), 0);
|
||||
|
||||
iface = GST_PHYS_MEMORY_ALLOCATOR_GET_INTERFACE (mem->allocator);
|
||||
g_return_val_if_fail (iface->get_phys_addr != NULL, 0);
|
||||
|
||||
return iface->get_phys_addr ((GstPhysMemoryAllocator *) mem->allocator, mem);
|
||||
}
|
59
gst-libs/gst/allocators/gstphysmemory.h
Normal file
59
gst-libs/gst/allocators/gstphysmemory.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* 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>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstPhysMemoryAllocator GstPhysMemoryAllocator;
|
||||
typedef struct _GstPhysMemoryAllocatorInterface GstPhysMemoryAllocatorInterface;
|
||||
|
||||
#define GST_TYPE_PHYS_MEMORY_ALLOCATOR (gst_phys_memory_allocator_get_type())
|
||||
#define GST_IS_PHYS_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PHYS_MEMORY_ALLOCATOR))
|
||||
#define GST_IS_PHYS_MEMORY_ALLOCATOR_INTERFACE(iface) (G_TYPE_CHECK_INTERFACE_TYPE ((iface), GST_TYPE_PHYS_MEMORY_ALLOCATOR))
|
||||
#define GST_PHYS_MEMORY_ALLOCATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_PHYS_MEMORY_ALLOCATOR, GstPhysMemoryAllocatorInterface))
|
||||
#define GST_PHYS_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PHYS_MEMORY_ALLOCATOR, GstPhysMemoryAllocator))
|
||||
#define GST_PHYS_MEMORY_ALLOCATOR_INTERFACE(iface) (G_TYPE_CHECK_INTERFACE_CAST ((iface), GST_TYPE_PHYS_MEMORY_ALLOCATOR, GstPhysMemoryAllocatorInterface))
|
||||
#define GST_PHYS_MEMORY_ALLOCATOR_CAST(obj) ((GstPhysMemoryAllocator *)(obj))
|
||||
|
||||
/**
|
||||
* GstPhysMemoryAllocatorInterface:
|
||||
*
|
||||
* Marker interface for allocators with physical address backed memory
|
||||
*
|
||||
* Since: 1.12
|
||||
*/
|
||||
struct _GstPhysMemoryAllocatorInterface
|
||||
{
|
||||
GTypeInterface parent_iface;
|
||||
|
||||
guintptr (*get_phys_addr) (GstPhysMemoryAllocator * allocator, GstMemory * mem);
|
||||
};
|
||||
|
||||
GType gst_phys_memory_allocator_get_type (void);
|
||||
|
||||
gboolean gst_is_phys_memory (GstMemory *mem);
|
||||
guintptr gst_phys_memory_get_phys_addr (GstMemory * mem);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_PHYS_MEMORY_H__ */
|
|
@ -8,7 +8,8 @@ pcverfiles = \
|
|||
gstreamer-player-@GST_API_VERSION@.pc \
|
||||
gstreamer-bad-base-@GST_API_VERSION@.pc \
|
||||
gstreamer-bad-audio-@GST_API_VERSION@.pc \
|
||||
gstreamer-bad-video-@GST_API_VERSION@.pc
|
||||
gstreamer-bad-video-@GST_API_VERSION@.pc \
|
||||
gstreamer-bad-allocators-@GST_API_VERSION@.pc
|
||||
|
||||
pcverfiles_uninstalled = \
|
||||
gstreamer-plugins-bad-@GST_API_VERSION@-uninstalled.pc \
|
||||
|
@ -18,7 +19,8 @@ pcverfiles_uninstalled = \
|
|||
gstreamer-player-@GST_API_VERSION@-uninstalled.pc \
|
||||
gstreamer-bad-base-@GST_API_VERSION@-uninstalled.pc \
|
||||
gstreamer-bad-audio-@GST_API_VERSION@-uninstalled.pc \
|
||||
gstreamer-bad-video-@GST_API_VERSION@-uninstalled.pc
|
||||
gstreamer-bad-video-@GST_API_VERSION@-uninstalled.pc \
|
||||
gstreamer-bad-allocators-@GST_API_VERSION@-uninstalled.pc
|
||||
|
||||
if HAVE_GST_GL
|
||||
pcverfiles += gstreamer-gl-@GST_API_VERSION@.pc
|
||||
|
@ -64,7 +66,8 @@ pcinfiles = \
|
|||
gstreamer-player.pc.in gstreamer-player-uninstalled.pc.in \
|
||||
gstreamer-bad-audio.pc.in gstreamer-bad-audio-uninstalled.pc.in \
|
||||
gstreamer-bad-video.pc.in gstreamer-bad-video-uninstalled.pc.in \
|
||||
gstreamer-bad-base.pc.in gstreamer-bad-base-uninstalled.pc.in
|
||||
gstreamer-bad-base.pc.in gstreamer-bad-base-uninstalled.pc.in \
|
||||
gstreamer-bad-allocators.pc.in gstreamer-bad-allocators-uninstalled.pc.in
|
||||
|
||||
DISTCLEANFILES = $(pcinfiles:.in=)
|
||||
EXTRA_DIST = $(pcinfiles)
|
||||
|
|
16
pkgconfig/gstreamer-bad-allocators-uninstalled.pc.in
Normal file
16
pkgconfig/gstreamer-bad-allocators-uninstalled.pc.in
Normal file
|
@ -0,0 +1,16 @@
|
|||
# the standard variables don't make sense for an uninstalled copy
|
||||
prefix=
|
||||
exec_prefix=
|
||||
libdir=@abs_top_builddir@/gst-libs/gst/allocators/.libs
|
||||
# includedir is builddir because it is used to find gstconfig.h in places
|
||||
includedir=@abs_top_builddir@/gst-libs
|
||||
girdir=@abs_top_builddir@/gst-libs/gst/allocators
|
||||
typelibdir=@abs_top_builddir@/gst-libs/gst/allocators
|
||||
|
||||
Name: GStreamer Bad Allocators Library, Uninstalled
|
||||
Description: Bad Allocators implementation, uninstalled
|
||||
Version: @VERSION@
|
||||
Requires: gstreamer-@GST_API_VERSION@
|
||||
Libs: -L${libdir} -lgstbadallocators-@GST_API_VERSION@
|
||||
Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
|
||||
|
16
pkgconfig/gstreamer-bad-allocators.pc.in
Normal file
16
pkgconfig/gstreamer-bad-allocators.pc.in
Normal file
|
@ -0,0 +1,16 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@/gstreamer-@GST_API_VERSION@
|
||||
datarootdir=${prefix}/share
|
||||
datadir=${datarootdir}
|
||||
girdir=${datadir}/gir-1.0
|
||||
typelibdir=${libdir}/girepository-1.0
|
||||
|
||||
Name: GStreamer Bad Allocators Library
|
||||
Description: Bad Allocators implementation
|
||||
Requires: gstreamer-@GST_API_VERSION@
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lgstbadallocators-@GST_API_VERSION@
|
||||
Cflags: -I${includedir}
|
||||
|
Loading…
Reference in a new issue