wayland: Add new gst-wayland library containing a new GstWaylandVideo interface
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Mon, 6 May 2013 10:16:02 +0000 (13:16 +0300)
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Tue, 17 Jun 2014 11:51:23 +0000 (13:51 +0200)
This interface is needed to be able to embed waylandsink into
other wayland surfaces. Due to the special nature of wayland,
GstVideoOverlay is not enough for this job.

configure.ac
gst-libs/gst/Makefile.am
gst-libs/gst/wayland/Makefile.am [new file with mode: 0644]
gst-libs/gst/wayland/wayland.c [new file with mode: 0644]
gst-libs/gst/wayland/wayland.h [new file with mode: 0644]

index a744366..05319a3 100644 (file)
@@ -3206,6 +3206,7 @@ gst-libs/gst/interfaces/Makefile
 gst-libs/gst/codecparsers/Makefile
 gst-libs/gst/mpegts/Makefile
 gst-libs/gst/uridownloader/Makefile
+gst-libs/gst/wayland/Makefile
 sys/Makefile
 sys/dshowdecwrapper/Makefile
 sys/acmenc/Makefile
index 0123469..93abc17 100644 (file)
@@ -6,9 +6,13 @@ if USE_GLES2
 GL_DIR = gl
 endif
 
+if USE_WAYLAND
+WAYLAND_DIR=wayland
+endif
+
 SUBDIRS = interfaces basecamerabinsrc codecparsers \
-        insertbin uridownloader mpegts $(GL_DIR)
+        insertbin uridownloader mpegts $(GL_DIR) $(WAYLAND_DIR)
 
 noinst_HEADERS = gst-i18n-plugin.h gettext.h glib-compat-private.h
 DIST_SUBDIRS = interfaces gl basecamerabinsrc codecparsers \
-       insertbin uridownloader mpegts
+       insertbin uridownloader mpegts wayland
diff --git a/gst-libs/gst/wayland/Makefile.am b/gst-libs/gst/wayland/Makefile.am
new file mode 100644 (file)
index 0000000..53295dc
--- /dev/null
@@ -0,0 +1,89 @@
+lib_LTLIBRARIES = libgstwayland-@GST_API_VERSION@.la
+
+libgstwayland_@GST_API_VERSION@_la_SOURCES = wayland.c
+
+libgstwayland_@GST_API_VERSION@includedir = \
+       $(includedir)/gstreamer-@GST_API_VERSION@/gst/wayland
+
+libgstwayland_@GST_API_VERSION@include_HEADERS = wayland.h
+
+libgstwayland_@GST_API_VERSION@_la_CFLAGS = \
+       $(GST_PLUGINS_BAD_CFLAGS) \
+       $(GST_CFLAGS) \
+       $(WAYLAND_CFLAGS)
+
+libgstwayland_@GST_API_VERSION@_la_LIBADD = \
+       $(GST_LIBS) \
+       $(WAYLAND_LIBS)
+
+libgstwayland_@GST_API_VERSION@_la_LDFLAGS = \
+       $(GST_LIB_LDFLAGS) \
+       $(GST_ALL_LDFLAGS) \
+       $(GST_LT_LDFLAGS)
+
+
+if HAVE_INTROSPECTION
+BUILT_GIRSOURCES = GstWayland-@GST_API_VERSION@.gir
+
+gir_headers=$(patsubst %,$(srcdir)/%, $(libgstwayland_@GST_API_VERSION@include_HEADERS))
+gir_headers+=$(patsubst %,$(builddir)/%, $(built_headers))
+gir_sources=$(patsubst %,$(srcdir)/%, $(libgstwayland_@GST_API_VERSION@_la_SOURCES))
+gir_sources+=$(patsubst %,$(builddir)/%, $(built_sources))
+
+GstWayland-@GST_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libgstwayland-@GST_API_VERSION@.la
+       $(AM_V_GEN)PKG_CONFIG_PATH="$(GST_PKG_CONFIG_PATH)" \
+               GST_PLUGIN_SYSTEM_PATH_1_0="" GST_PLUGIN_PATH_1_0="" GST_REGISTRY_UPDATE=no \
+               $(INTROSPECTION_SCANNER) -v --namespace GstWayland \
+               --nsversion=@GST_API_VERSION@ \
+               --strip-prefix=Gst \
+               --warn-all \
+               --c-include "gst/wayland/wayland.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=libgstwayland-@GST_API_VERSION@.la \
+               --include=Gst-@GST_API_VERSION@ \
+               --libtool="$(top_builddir)/libtool" \
+               --pkg gstreamer-@GST_API_VERSION@ \
+               --pkg-export gstreamer-wayland-@GST_API_VERSION@ \
+               --add-init-section="gst_init(NULL,NULL);" \
+               -DGST_USE_UNSTABLE_API \
+               --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
+
+Android.mk:  $(BUILT_SOURCES) Makefile.am
+       androgenizer -:PROJECT libgstwayland -:STATIC libgstwayland-@GST_API_VERSION@ \
+        -:TAGS eng debug \
+         -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+        -:SOURCES $(libgstwayland_@GST_API_VERSION@_la_SOURCES) \
+         $(built_sources) \
+        -:CFLAGS $(DEFS) $(libgstwayland_@GST_API_VERSION@_la_CFLAGS) \
+        -:LDFLAGS $(libgstwayland_@GST_API_VERSION@_la_LDFLAGS) \
+                  $(libgstwayland@GST_API_VERSION@_la_LIBADD) \
+                  -ldl \
+        -:HEADER_TARGET gstreamer-@GST_API_VERSION@/gst/wayland \
+        -:HEADERS $(libgstwaylandinclude_HEADERS) \
+         $(built_headers) \
+        -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+       > $@
diff --git a/gst-libs/gst/wayland/wayland.c b/gst-libs/gst/wayland/wayland.c
new file mode 100644 (file)
index 0000000..9ede5b8
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * GStreamer Wayland Library
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/wayland/wayland.h>
+#include <gst/video/videooverlay.h>
+
+G_DEFINE_INTERFACE (GstWaylandVideo, gst_wayland_video, GST_TYPE_VIDEO_OVERLAY);
+
+static void
+gst_wayland_video_default_init (GstWaylandVideoInterface * klass)
+{
+  (void) klass;
+}
+
+/**
+ * gst_wayland_video_set_surface_size:
+ *
+ * This tells the video sink to change the size of its drawing
+ * surface. The caller must call gst_wayland_video_pause_rendering
+ * before calling this method and gst_wayland_video_resume_rendering
+ * later, on the next redraw request.
+ */
+void
+gst_wayland_video_set_surface_size (GstWaylandVideo * video, gint w, gint h)
+{
+  GstWaylandVideoInterface *iface;
+
+  g_return_if_fail (video != NULL);
+  g_return_if_fail (GST_IS_WAYLAND_VIDEO (video));
+
+  iface = GST_WAYLAND_VIDEO_GET_INTERFACE (video);
+
+  if (iface->set_surface_size) {
+    iface->set_surface_size (video, w, h);
+  }
+}
+
+/**
+ * gst_wayland_video_pause_rendering:
+ *
+ * This tells the video sink to stop rendering on the surface,
+ * dropping frames in the meanwhile. This should be called
+ * before resizing a stack of subsurfaces, one of which is
+ * the surface of the video sink.
+ */
+void
+gst_wayland_video_pause_rendering (GstWaylandVideo * video)
+{
+  GstWaylandVideoInterface *iface;
+
+  g_return_if_fail (video != NULL);
+  g_return_if_fail (GST_IS_WAYLAND_VIDEO (video));
+
+  iface = GST_WAYLAND_VIDEO_GET_INTERFACE (video);
+
+  if (iface->pause_rendering) {
+    iface->pause_rendering (video);
+  }
+}
+
+/**
+ * gst_wayland_video_resume_rendering:
+ *
+ * Resumes surface rendering that was previously paused
+ * with gst_wayland_video_pause_rendering. This function will
+ * block until there is a new wl_buffer commited on the surface
+ * inside the element, either with a new frame (if the element
+ * is PLAYING) or with an old frame (if the element is PAUSED).
+ */
+void
+gst_wayland_video_resume_rendering (GstWaylandVideo * video)
+{
+  GstWaylandVideoInterface *iface;
+
+  g_return_if_fail (video != NULL);
+  g_return_if_fail (GST_IS_WAYLAND_VIDEO (video));
+
+  iface = GST_WAYLAND_VIDEO_GET_INTERFACE (video);
+
+  if (iface->resume_rendering) {
+    iface->resume_rendering (video);
+  }
+}
diff --git a/gst-libs/gst/wayland/wayland.h b/gst-libs/gst/wayland/wayland.h
new file mode 100644 (file)
index 0000000..93f047b
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * GStreamer Wayland Library
+ * Copyright (C) 2014 Collabora Ltd.
+ *
+ * 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_WAYLAND_H__
+#define __GST_WAYLAND_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_WAYLAND_VIDEO \
+    (gst_wayland_video_get_type ())
+#define GST_WAYLAND_VIDEO(obj) \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WAYLAND_VIDEO, GstWaylandVideo))
+#define GST_IS_WAYLAND_VIDEO(obj) \
+    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WAYLAND_VIDEO))
+#define GST_WAYLAND_VIDEO_GET_INTERFACE(inst) \
+    (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_WAYLAND_VIDEO, GstWaylandVideoInterface))
+
+/**
+ * GstWaylandVideo:
+ *
+ * Opaque #GstWaylandVideo interface structure
+ */
+typedef struct _GstWaylandVideo GstWaylandVideo;
+typedef struct _GstWaylandVideoInterface GstWaylandVideoInterface;
+
+
+/**
+ * GstWaylandVideoInterface:
+ * @iface: parent interface type.
+ *
+ * #GstWaylandVideo interface
+ */
+struct _GstWaylandVideoInterface {
+  GTypeInterface iface;
+
+  /* virtual functions */
+  void (*set_surface_size)     (GstWaylandVideo *video, gint w, gint h);
+  void (*pause_rendering)      (GstWaylandVideo *video);
+  void (*resume_rendering)     (GstWaylandVideo *video);
+};
+
+GType   gst_wayland_video_get_type (void);
+
+/* virtual function wrappers */
+
+void gst_wayland_video_set_surface_size (GstWaylandVideo * video,
+        gint w, gint h);
+
+void gst_wayland_video_pause_rendering (GstWaylandVideo * video);
+void gst_wayland_video_resume_rendering (GstWaylandVideo * video);
+
+G_END_DECLS
+
+#endif /* __GST_WAYLAND_H__ */