summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2014-02-13 10:02:54 +0100
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2014-06-17 13:51:21 +0200
commitf6e72c8725bb80519d219be0fd0080f617ca27f3 (patch)
treec23950b4117bce49a6b3d3ac54a55ee405814cc8
parent0ee558f4c624e6f25ee55d5cda47a29c012b49b5 (diff)
downloadgstreamer-plugins-bad-f6e72c8725bb80519d219be0fd0080f617ca27f3.tar.gz
waylandsink: split video format related functions out to a separate file
-rw-r--r--ext/wayland/Makefile.am5
-rw-r--r--ext/wayland/gstwaylandsink.c61
-rw-r--r--ext/wayland/gstwaylandsink.h2
-rw-r--r--ext/wayland/wlvideoformat.c88
-rw-r--r--ext/wayland/wlvideoformat.h38
5 files changed, 131 insertions, 63 deletions
diff --git a/ext/wayland/Makefile.am b/ext/wayland/Makefile.am
index 80b361453..60cbf7ecd 100644
--- a/ext/wayland/Makefile.am
+++ b/ext/wayland/Makefile.am
@@ -1,6 +1,7 @@
plugin_LTLIBRARIES = libgstwaylandsink.la
-libgstwaylandsink_la_SOURCES = gstwaylandsink.c waylandpool.c wldisplay.c
+libgstwaylandsink_la_SOURCES = gstwaylandsink.c waylandpool.c wldisplay.c \
+ wlvideoformat.c
libgstwaylandsink_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
$(WAYLAND_CFLAGS)
libgstwaylandsink_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
@@ -9,4 +10,4 @@ libgstwaylandsink_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
libgstwaylandsink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstwaylandsink_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
-noinst_HEADERS = gstwaylandsink.h waylandpool.h wldisplay.h
+noinst_HEADERS = gstwaylandsink.h waylandpool.h wldisplay.h wlvideoformat.h
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
index 0a371284e..7b5fb832c 100644
--- a/ext/wayland/gstwaylandsink.c
+++ b/ext/wayland/gstwaylandsink.c
@@ -41,6 +41,7 @@
#endif
#include "gstwaylandsink.h"
+#include "wlvideoformat.h"
/* signals */
enum
@@ -96,50 +97,6 @@ static void frame_redraw_callback (void *data,
static void create_window (GstWaylandSink * sink, GstWlDisplay * display,
int width, int height);
-typedef struct
-{
- uint32_t wl_format;
- GstVideoFormat gst_format;
-} wl_VideoFormat;
-
-static const wl_VideoFormat formats[] = {
-#if G_BYTE_ORDER == G_BIG_ENDIAN
- {WL_SHM_FORMAT_XRGB8888, GST_VIDEO_FORMAT_xRGB},
- {WL_SHM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_ARGB},
-#else
- {WL_SHM_FORMAT_XRGB8888, GST_VIDEO_FORMAT_BGRx},
- {WL_SHM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_BGRA},
-#endif
-};
-
-static uint32_t
-gst_wayland_format_to_wl_format (GstVideoFormat format)
-{
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (formats); i++)
- if (formats[i].gst_format == format)
- return formats[i].wl_format;
-
- GST_WARNING ("wayland video format not found");
- return -1;
-}
-
-#ifndef GST_DISABLE_GST_DEBUG
-static const gchar *
-gst_wayland_format_to_string (uint32_t wl_format)
-{
- guint i;
- GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
-
- for (i = 0; i < G_N_ELEMENTS (formats); i++)
- if (formats[i].wl_format == wl_format)
- format = formats[i].gst_format;
-
- return gst_video_format_to_string (format);
-}
-#endif
-
static void
gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
{
@@ -272,22 +229,6 @@ gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
}
static gboolean
-gst_wayland_sink_format_from_caps (uint32_t * wl_format, GstCaps * caps)
-{
- GstStructure *structure;
- const gchar *format;
- GstVideoFormat fmt;
-
- structure = gst_caps_get_structure (caps, 0);
- format = gst_structure_get_string (structure, "format");
- fmt = gst_video_format_from_string (format);
-
- *wl_format = gst_wayland_format_to_wl_format (fmt);
-
- return (*wl_format != -1);
-}
-
-static gboolean
gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
{
GstWaylandSink *sink;
diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h
index c5a1057d9..35a99ae24 100644
--- a/ext/wayland/gstwaylandsink.h
+++ b/ext/wayland/gstwaylandsink.h
@@ -89,7 +89,7 @@ struct _GstWaylandSink
gint video_width;
gint video_height;
- uint32_t format;
+ enum wl_shm_format format;
};
struct _GstWaylandSinkClass
diff --git a/ext/wayland/wlvideoformat.c b/ext/wayland/wlvideoformat.c
new file mode 100644
index 000000000..ff2858b61
--- /dev/null
+++ b/ext/wayland/wlvideoformat.c
@@ -0,0 +1,88 @@
+/* GStreamer Wayland video sink
+ *
+ * Copyright (C) 2011 Intel Corporation
+ * Copyright (C) 2011 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
+ * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
+ * 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 Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
+#include "wlvideoformat.h"
+
+typedef struct
+{
+ enum wl_shm_format wl_format;
+ GstVideoFormat gst_format;
+} wl_VideoFormat;
+
+static const wl_VideoFormat formats[] = {
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ {WL_SHM_FORMAT_XRGB8888, GST_VIDEO_FORMAT_xRGB},
+ {WL_SHM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_ARGB},
+#else
+ {WL_SHM_FORMAT_XRGB8888, GST_VIDEO_FORMAT_BGRx},
+ {WL_SHM_FORMAT_ARGB8888, GST_VIDEO_FORMAT_BGRA},
+#endif
+};
+
+enum wl_shm_format
+gst_video_format_to_wayland_format (GstVideoFormat format)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (formats); i++)
+ if (formats[i].gst_format == format)
+ return formats[i].wl_format;
+
+ GST_WARNING ("wayland video format not found");
+ return -1;
+}
+
+GstVideoFormat
+gst_wayland_format_to_video_format (enum wl_shm_format wl_format)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (formats); i++)
+ if (formats[i].wl_format == wl_format)
+ return formats[i].gst_format;
+
+ GST_WARNING ("gst video format not found");
+ return GST_VIDEO_FORMAT_UNKNOWN;
+}
+
+const gchar *
+gst_wayland_format_to_string (enum wl_shm_format wl_format)
+{
+ return gst_video_format_to_string
+ (gst_wayland_format_to_video_format (wl_format));
+}
+
+gboolean
+gst_wayland_sink_format_from_caps (enum wl_shm_format * wl_format,
+ GstCaps * caps)
+{
+ GstVideoInfo info;
+ GstVideoFormat fmt;
+
+ gst_video_info_from_caps (&info, caps);
+ fmt = GST_VIDEO_INFO_FORMAT (&info);
+
+ *wl_format = gst_video_format_to_wayland_format (fmt);
+
+ return (*wl_format != -1);
+}
diff --git a/ext/wayland/wlvideoformat.h b/ext/wayland/wlvideoformat.h
new file mode 100644
index 000000000..d5ddd627d
--- /dev/null
+++ b/ext/wayland/wlvideoformat.h
@@ -0,0 +1,38 @@
+/* GStreamer Wayland video sink
+ *
+ * Copyright (C) 2011 Intel Corporation
+ * Copyright (C) 2011 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
+ * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
+ * 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 Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GST_WL_VIDEO_FORMAT_H__
+#define __GST_WL_VIDEO_FORMAT_H__
+
+#include <wayland-client.h>
+#include <gst/video/video.h>
+
+enum wl_shm_format gst_video_format_to_wayland_format (GstVideoFormat format);
+GstVideoFormat gst_wayland_format_to_video_format (enum wl_shm_format wl_format);
+
+const gchar *gst_wayland_format_to_string (enum wl_shm_format wl_format);
+
+gboolean gst_wayland_sink_format_from_caps (enum wl_shm_format * wl_format,
+ GstCaps * caps);
+
+#endif