mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
79d11c2022
New plugin with an element for H.264 decoding with VA-API. This novel approach, different from gstreamer-vaapi, uses gstcodecs library for state handling. The code is expected to looks cleaner because it uses VA-API without further layers or wrappers. * It uses the first supported DRM device as default VA display (other displays will be supported through user's GstContext) * Requires libva >= 1.6 * No multiview/stereo profiles neither interlaced streams because gstcodecs doesn't handle them yet * It is incompatible with gstreamer-vaapi * Even if memory:VAMemory is exposed, it is not handled yet by any other element * Caps templates are generated dynamically querying VAAPI, but YV12 and I420 are added for system memory caps because they seem to be supported for all the drivers when downloading frames onto main memory, as they are used by xvimagesink and others, avoiding color conversion. * Surfaces aren't bounded to context, so they can grow beyond the DBP size, allowing smooth reverse playback. * There isn't yet error handling and recovery. * 10-bit H.264 streams aren't supported by libva. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1379>
97 lines
2.7 KiB
C
97 lines
2.7 KiB
C
/* GStreamer
|
|
* Copyright (C) 2020 Igalia, S.L.
|
|
* Author: Víctor Jáquez <vjaquez@igalia.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., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "gstvadevice.h"
|
|
|
|
#include <gudev/gudev.h>
|
|
#include "gstvadisplay_drm.h"
|
|
|
|
#define GST_CAT_DEFAULT gstva_debug
|
|
GST_DEBUG_CATEGORY_EXTERN (gstva_debug);
|
|
|
|
GST_DEFINE_MINI_OBJECT_TYPE (GstVaDevice, gst_va_device);
|
|
|
|
static void
|
|
gst_va_device_free (GstVaDevice * device)
|
|
{
|
|
if (device->display)
|
|
gst_object_unref (device->display);
|
|
g_free (device->render_device_path);
|
|
g_free (device);
|
|
}
|
|
|
|
static GstVaDevice *
|
|
gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path)
|
|
{
|
|
GstVaDevice *device = g_new0 (GstVaDevice, 1);
|
|
|
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (device), 0, GST_TYPE_VA_DEVICE,
|
|
NULL, NULL, (GstMiniObjectFreeFunction) gst_va_device_free);
|
|
|
|
/* take ownership */
|
|
device->display = display;
|
|
device->render_device_path = g_strdup (render_device_path);
|
|
|
|
return device;
|
|
}
|
|
|
|
GList *
|
|
gst_va_device_find_devices (void)
|
|
{
|
|
GUdevClient *client;
|
|
GList *udev_devices, *dev;
|
|
GQueue devices = G_QUEUE_INIT;
|
|
|
|
client = g_udev_client_new (NULL);
|
|
udev_devices = g_udev_client_query_by_subsystem (client, "drm");
|
|
|
|
for (dev = udev_devices; dev; dev = g_list_next (dev)) {
|
|
GstVaDisplay *dpy;
|
|
GUdevDevice *udev = (GUdevDevice *) dev->data;
|
|
const gchar *path = g_udev_device_get_device_file (udev);
|
|
const gchar *name = g_udev_device_get_name (udev);
|
|
|
|
if (!path || !g_str_has_prefix (name, "renderD")) {
|
|
GST_LOG ("Ignoring %s in %s", name, path);
|
|
continue;
|
|
}
|
|
|
|
if (!(dpy = gst_va_display_drm_new_from_path (path)))
|
|
continue;
|
|
|
|
GST_INFO ("Found VA-API device: %s", path);
|
|
g_queue_push_tail (&devices, gst_va_device_new (dpy, path));
|
|
}
|
|
|
|
g_list_free_full (udev_devices, g_object_unref);
|
|
g_object_unref (client);
|
|
|
|
return devices.head;
|
|
}
|
|
|
|
void
|
|
gst_va_device_list_free (GList * devices)
|
|
{
|
|
g_list_free_full (devices, (GDestroyNotify) gst_mini_object_unref);
|
|
}
|