mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
88 lines
2.4 KiB
C
88 lines
2.4 KiB
C
/* 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);
|
|
}
|