summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: efb4485)
raw | patch | inline | side by side (parent: efb4485)
author | Rob Clark <rob@ti.com> | |
Wed, 13 Jun 2012 01:08:02 +0000 (20:08 -0500) | ||
committer | Nikhil Devshatwar <a0132237@ti.com> | |
Wed, 15 May 2013 10:35:39 +0000 (16:05 +0530) |
Add gst-libs/gst/dmabuf which contains helpers to attach and retrieve dmabuf
handles to/from buffers.
handles to/from buffers.
configure.ac | patch | blob | history | |
gst-libs/gst/Makefile.am | patch | blob | history | |
gst-libs/gst/dmabuf/Makefile.am | [new file with mode: 0644] | patch | blob |
gst-libs/gst/dmabuf/dmabuf.c | [new file with mode: 0644] | patch | blob |
gst-libs/gst/dmabuf/dmabuf.h | [new file with mode: 0644] | patch | blob |
pkgconfig/Makefile.am | patch | blob | history | |
pkgconfig/gstreamer-dmabuf-uninstalled.pc.in | [new file with mode: 0644] | patch | blob |
pkgconfig/gstreamer-dmabuf.pc.in | [new file with mode: 0644] | patch | blob |
pkgconfig/gstreamer-plugins-base-uninstalled.pc.in | patch | blob | history | |
pkgconfig/gstreamer-plugins-base.pc.in | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index aa854ce2bcd1ca361abf83802d0758bb41f2b3a3..068ccd82a15b5c2ff334d9753b8e509333b9a65a 100644 (file)
--- a/configure.ac
+++ b/configure.ac
gst-libs/gst/pbutils/Makefile
gst-libs/gst/pbutils/gstpluginsbaseversion.h
gst-libs/gst/video/Makefile
+gst-libs/gst/dmabuf/Makefile
tools/Makefile
pkgconfig/Makefile
pkgconfig/gstreamer-audio.pc
pkgconfig/gstreamer-app-uninstalled.pc
pkgconfig/gstreamer-cdda.pc
pkgconfig/gstreamer-cdda-uninstalled.pc
+pkgconfig/gstreamer-dmabuf.pc
+pkgconfig/gstreamer-dmabuf-uninstalled.pc
pkgconfig/gstreamer-fft.pc
pkgconfig/gstreamer-fft-uninstalled.pc
pkgconfig/gstreamer-floatcast.pc
index 09842516216fc39c3ffe7894c4312b8ed43cf5db..b4de6320c4b48f127cfd171a0510f99262ec9744 100644 (file)
--- a/gst-libs/gst/Makefile.am
+++ b/gst-libs/gst/Makefile.am
sdp \
rtsp \
video \
+ dmabuf \
pbutils \
audio \
riff \
diff --git a/gst-libs/gst/dmabuf/Makefile.am b/gst-libs/gst/dmabuf/Makefile.am
--- /dev/null
@@ -0,0 +1,21 @@
+lib_LTLIBRARIES = libgstdmabuf-@GST_MAJORMINOR@.la
+
+libgstdmabuf_@GST_MAJORMINOR@_la_SOURCES = \
+ dmabuf.c
+libgstdmabuf_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/dmabuf
+libgstdmabuf_@GST_MAJORMINOR@include_HEADERS = \
+ dmabuf.h
+
+libgstdmabuf_@GST_MAJORMINOR@_la_CFLAGS = \
+ $(GST_PLUGINS_BASE_CFLAGS)\
+ $(GST_BASE_CFLAGS) \
+ $(GST_CFLAGS)
+
+libgstdmabuf_@GST_MAJORMINOR@_la_LIBADD = $(GST_BASE_LIBS) \
+ $(GST_LIBS)
+
+libgstdmabuf_@GST_MAJORMINOR@_la_LDFLAGS = \
+ $(GST_LIB_LDFLAGS) \
+ $(GST_ALL_LDFLAGS) \
+ $(GST_LT_LDFLAGS)
+
diff --git a/gst-libs/gst/dmabuf/dmabuf.c b/gst-libs/gst/dmabuf/dmabuf.c
--- /dev/null
@@ -0,0 +1,163 @@
+/* GStreamer dmabuf
+ *
+ * Copyright (c) 2012, Texas Instruments Incorporated
+ *
+ * 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.
+ */
+
+/**
+ * SECTION:gstdmabuf
+ * @short_description: GStreamer dmabuf support
+ *
+ * Since: 0.10.?
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+
+#include "dmabuf.h"
+
+struct _GstDmaBuf
+{
+ GstMiniObject parent;
+
+ int fd;
+};
+
+struct _GstDmaBufClass
+{
+ GstMiniObjectClass parent_class;
+};
+
+#define GST_DMA_BUF_QUARK gst_dma_buf_quark_get_type()
+static GST_BOILERPLATE_QUARK (GstDmaBuf, gst_dma_buf_quark);
+
+#define DMA_BUF_QUARK dma_buf_quark_get_type()
+static GST_BOILERPLATE_QUARK (DmaBuf, dma_buf_quark);
+
+/**
+ * gst_buffer_set_dma_buf:
+ * @buf: a #GstBuffer
+ * @dmabuf: (allow-none): a #GstDmaBuf, or NULL to clear a
+ * previously-set dmabuf
+ *
+ * Sets an dmabuf handle on a buffer. The buffer will obtain its own
+ * reference to the dmabuf handle, meaning this function does not take
+ * ownership of @dmabuf.
+ *
+ * Since: 0.10.?
+ */
+void
+gst_buffer_set_dma_buf (GstBuffer * buf, GstDmaBuf * dmabuf)
+{
+ gst_buffer_set_qdata (buf, GST_DMA_BUF_QUARK,
+ gst_structure_id_new (GST_DMA_BUF_QUARK,
+ DMA_BUF_QUARK, GST_TYPE_DMA_BUF, dmabuf, NULL));
+}
+
+/**
+ * gst_buffer_get_dma_buf:
+ * @buf: a #GstBuffer
+ *
+ * Get the dmabuf handle that has previously been attached to a buffer
+ * with gst_buffer_set_dma_buf(), usually by another element
+ * upstream.
+ *
+ * Returns: (transfer none): the #GstDmaBuf attached to
+ * this buffer, or NULL. Does not return a reference to the dmabuf handle,
+ * caller must obtain her own ref via gst_dma_buf_ref()
+ * if needed.
+ *
+ * Since: 0.10.?
+ */
+GstDmaBuf *
+gst_buffer_get_dma_buf (GstBuffer * buf)
+{
+ const GstStructure *s;
+ const GValue *val;
+
+ s = gst_buffer_get_qdata (buf, GST_DMA_BUF_QUARK);
+ if (s == NULL)
+ return NULL;
+
+ val = gst_structure_id_get_value (s, DMA_BUF_QUARK);
+ if (val == NULL)
+ return NULL;
+
+ return GST_DMA_BUF (gst_value_get_mini_object (val));
+}
+
+static void
+gst_dma_buf_finalize (GstMiniObject * mini_obj)
+{
+ GstDmaBuf *dmabuf = (GstDmaBuf *) mini_obj;
+ close (dmabuf->fd);
+
+ /* not chaining up to GstMiniObject's finalize for now, we know it's empty */
+}
+
+static void
+gst_dma_buf_class_init (GstDmaBufClass * klass)
+{
+ GST_MINI_OBJECT_CLASS (klass)->finalize = gst_dma_buf_finalize;
+}
+
+GST_BOILERPLATE_MINI_OBJECT (GstDmaBuf, gst_dma_buf);
+
+/**
+ * gst_dma_buf_new:
+ * @fd: (transfer full) the dmabuf fd
+ *
+ * Creates a new dmabuf handle object, which takes ownership of the
+ * specified dmabuf file descriptor. When the dmabuf handle object
+ * is finalized, the dmabuf fd is closed.
+ *
+ * Returns: (transfer full): a new #GstDmaBuf. Unref with
+ * gst_dma_buf_unref() when no longer needed.
+ *
+ * Since: 0.10.?
+ */
+GstDmaBuf *
+gst_dma_buf_new (int fd)
+{
+ GstDmaBuf *dmabuf;
+
+ dmabuf = (GstDmaBuf *) gst_mini_object_new (GST_TYPE_DMA_BUF);
+
+ dmabuf->fd = fd;
+
+ return dmabuf;
+}
+
+/**
+ * gst_dma_buf_get_fd:
+ *
+ * Returns: a the dmabuf file descriptor object; if the caller wants
+ * to hold on to the handle after the reference on the corresponding
+ * gst buffer is lost, she should probably dup() the fd. (Although
+ * it is probably better to hang on to the ref to the GstBuffer and
+ * let that hold the ref to the dmabuf fd).
+ *
+ * Since: 0.10.?
+ */
+int
+gst_dma_buf_get_fd (GstDmaBuf * dmabuf)
+{
+ return dmabuf->fd;
+}
diff --git a/gst-libs/gst/dmabuf/dmabuf.h b/gst-libs/gst/dmabuf/dmabuf.h
--- /dev/null
@@ -0,0 +1,101 @@
+/* GStreamer dmabuf
+ *
+ * Copyright (c) 2012, Texas Instruments Incorporated
+ *
+ * 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_DMA_BUF_H__
+#define __GST_DMA_BUF_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GstDmaBuf:
+ *
+ * A handle to a dma-buf suitable for sharing across devices.
+ *
+ * Since: 0.10.?
+ */
+#define GST_TYPE_DMA_BUF \
+ (gst_dma_buf_get_type ())
+#define GST_DMA_BUF(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DMA_BUF, GstDmaBuf))
+#define GST_IS_DMA_BUF(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DMA_BUF))
+
+typedef struct _GstDmaBuf GstDmaBuf;
+typedef struct _GstDmaBufClass GstDmaBufClass;
+
+/**
+ * gst_dma_buf_ref:
+ * @dmabuf: a a #GstDmaBuf.
+ *
+ * Increases the refcount by one.
+ *
+ * Returns: (transfer full): @dmabuf
+ *
+ * Since: 0.10.?
+ */
+#ifdef _FOOL_GTK_DOC_
+G_INLINE_FUNC GstDmaBuf *
+gst_dma_buf_ref (GstDmaBuf * dmabuf);
+#endif
+
+static inline GstDmaBuf *
+gst_dma_buf_ref (GstDmaBuf * dmabuf)
+{
+ return (GstDmaBuf *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (dmabuf));
+}
+
+/**
+ * gst_dma_buf_unref:
+ * @dmabuf: (transfer full): a #GstDmaBuf.
+ *
+ * Decreases the refcount. If the refcount reaches 0, the dmabuf will be
+ * freed and closed.
+ *
+ * Since: 0.10.?
+ */
+#ifdef _FOOL_GTK_DOC_
+G_INLINE_FUNC void
+gst_dma_buf_unref (GstDmaBuf * dmabuf);
+#endif
+
+static inline void
+gst_dma_buf_unref (GstDmaBuf * dmabuf)
+{
+ gst_mini_object_unref (GST_MINI_OBJECT_CAST (dmabuf));
+}
+
+GType gst_dma_buf_get_type (void);
+
+GstDmaBuf * gst_dma_buf_new (int fd);
+
+int gst_dma_buf_get_fd (GstDmaBuf * buf);
+
+/* attach/retrieve dmabuf from buffers */
+
+void gst_buffer_set_dma_buf (GstBuffer * buf,
+ GstDmaBuf * dmabuf);
+
+GstDmaBuf * gst_buffer_get_dma_buf (GstBuffer * buf);
+
+G_END_DECLS
+
+#endif /* __GST_DMA_BUF_H__ */
diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am
index 8fb25292357b6db8cb7c17b1bfbc7623d74d874f..50506feaf8779afe0f906d6bbc8a671af99f714c 100644 (file)
--- a/pkgconfig/Makefile.am
+++ b/pkgconfig/Makefile.am
gstreamer-audio-@GST_MAJORMINOR@.pc \
gstreamer-app-@GST_MAJORMINOR@.pc \
gstreamer-cdda-@GST_MAJORMINOR@.pc \
+ gstreamer-dmabuf-@GST_MAJORMINOR@.pc \
gstreamer-fft-@GST_MAJORMINOR@.pc \
gstreamer-floatcast-@GST_MAJORMINOR@.pc \
gstreamer-interfaces-@GST_MAJORMINOR@.pc \
gstreamer-audio-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-app-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-cdda-@GST_MAJORMINOR@-uninstalled.pc \
+ gstreamer-dmabuf-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-fft-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-floatcast-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-interfaces-@GST_MAJORMINOR@-uninstalled.pc \
gstreamer-audio.pc.in gstreamer-audio-uninstalled.pc.in \
gstreamer-app.pc.in gstreamer-app-uninstalled.pc.in \
gstreamer-cdda.pc.in gstreamer-cdda-uninstalled.pc.in \
+ gstreamer-dmabuf.pc.in gstreamer-dmabuf-uninstalled.pc.in \
gstreamer-fft.pc.in gstreamer-fft-uninstalled.pc.in \
gstreamer-floatcast.pc.in gstreamer-floatcast-uninstalled.pc.in \
gstreamer-interfaces.pc.in gstreamer-interfaces-uninstalled.pc.in \
diff --git a/pkgconfig/gstreamer-dmabuf-uninstalled.pc.in b/pkgconfig/gstreamer-dmabuf-uninstalled.pc.in
--- /dev/null
@@ -0,0 +1,16 @@
+# the standard variables don't make sense for an uninstalled copy
+prefix=
+exec_prefix=
+libdir=
+# 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/video
+typelibdir=@abs_top_builddir@/gst-libs/gst/video
+
+Name: GStreamer DMA-BUF Library, Uninstalled
+Description: Video base classes and helper functions, uninstalled
+Version: @VERSION@
+Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@
+Libs: @abs_top_builddir@/gst-libs/gst/dmabuf/libgstdmabuf-@GST_MAJORMINOR@.la
+Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
+
diff --git a/pkgconfig/gstreamer-dmabuf.pc.in b/pkgconfig/gstreamer-dmabuf.pc.in
--- /dev/null
@@ -0,0 +1,16 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@/gstreamer-@GST_MAJORMINOR@
+datarootdir=${prefix}/share
+datadir=${datarootdir}
+girdir=${datadir}/gir-1.0
+typelibdir=${libdir}/girepository-1.0
+
+Name: GStreamer DMA-BUF Library
+Description: Video base classes and helper functions
+Requires: gstreamer-@GST_MAJORMINOR@ gstreamer-base-@GST_MAJORMINOR@
+Version: @VERSION@
+Libs: -L${libdir} -lgstdmabuf-@GST_MAJORMINOR@
+Cflags: -I${includedir}
+
diff --git a/pkgconfig/gstreamer-plugins-base-uninstalled.pc.in b/pkgconfig/gstreamer-plugins-base-uninstalled.pc.in
index 8a9bea2178de631ab5ff434c0072164fd2c2710d..b9efabeff0113224b7c581c3926c347595e09d1c 100644 (file)
Description: Streaming media framework, base plugins libraries, uninstalled
Version: @VERSION@
Requires: gstreamer-@GST_MAJORMINOR@
-Libs: -L@abs_top_builddir@/gst-libs/gst/audio -L@abs_top_builddir@/gst-libs/gst/cdda -L@abs_top_builddir@/gst-libs/gst/fft -L@abs_top_builddir@/gst-libs/gst/floatcast -L@abs_top_builddir@/gst-libs/gst/interfaces -L@abs_top_builddir@/gst-libs/gst/netbuffer -L@abs_top_builddir@/gst-libs/gst/riff -L@abs_top_builddir@/gst-libs/gst/rtp -L@abs_top_builddir@/gst-libs/gst/rtsp -L@abs_top_builddir@/gst-libs/gst/sdp -L@abs_top_builddir@/gst-libs/gst/tag -L@abs_top_builddir@/gst-libs/gst/pbutils -L@abs_top_builddir@/gst-libs/gst/video -L@abs_top_builddir@/gst-libs/gst/app
+Libs: -L@abs_top_builddir@/gst-libs/gst/audio -L@abs_top_builddir@/gst-libs/gst/cdda -L@abs_top_builddir@/gst-libs/gst/dmabuf -L@abs_top_builddir@/gst-libs/gst/fft -L@abs_top_builddir@/gst-libs/gst/floatcast -L@abs_top_builddir@/gst-libs/gst/interfaces -L@abs_top_builddir@/gst-libs/gst/netbuffer -L@abs_top_builddir@/gst-libs/gst/riff -L@abs_top_builddir@/gst-libs/gst/rtp -L@abs_top_builddir@/gst-libs/gst/rtsp -L@abs_top_builddir@/gst-libs/gst/sdp -L@abs_top_builddir@/gst-libs/gst/tag -L@abs_top_builddir@/gst-libs/gst/pbutils -L@abs_top_builddir@/gst-libs/gst/video -L@abs_top_builddir@/gst-libs/gst/app
Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
-libraries=app audio cdda fft floatcast interfaces netbuffer riff rtp rtsp sdp tag pbutils video
+libraries=app audio cdda fft dmabuf floatcast interfaces netbuffer riff rtp rtsp sdp tag pbutils video
index 4bc6088c2a258355ae053efa22b07673d6124521..70e6d863541fc98210637299da6d7a8b257e38c8 100644 (file)
Libs: -L${libdir}
Cflags: -I${includedir}
-libraries=audio cdda fft floatcast interfaces netbuffer riff rtp tag pbutils video
+libraries=audio cdda dmabuf fft floatcast interfaces netbuffer riff rtp tag pbutils video