mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
pluginutils: cosmetics (indentation fixes).
This commit is contained in:
parent
96040a0fa2
commit
aa64ce0bed
2 changed files with 139 additions and 130 deletions
|
@ -25,169 +25,171 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <gst/video/videocontext.h>
|
||||||
#if USE_X11
|
#if USE_X11
|
||||||
# include <gst/vaapi/gstvaapidisplay_x11.h>
|
# include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||||
#endif
|
#endif
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gstvaapipluginutil.h"
|
#include "gstvaapipluginutil.h"
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/* Preferred first */
|
/* Preferred first */
|
||||||
static const char *display_types[] = {
|
static const char *display_types[] = {
|
||||||
"gst-vaapi-display",
|
"gst-vaapi-display",
|
||||||
"vaapi-display",
|
"vaapi-display",
|
||||||
"x11-display",
|
"x11-display",
|
||||||
"x11-display-name",
|
"x11-display-name",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_ensure_display (gpointer element, GstVaapiDisplay **display)
|
gst_vaapi_ensure_display(gpointer element, GstVaapiDisplay **display)
|
||||||
{
|
{
|
||||||
GstVideoContext *context;
|
GstVideoContext *context;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_VIDEO_CONTEXT (element), FALSE);
|
g_return_val_if_fail(GST_IS_VIDEO_CONTEXT(element), FALSE);
|
||||||
g_return_val_if_fail (display != NULL, FALSE);
|
g_return_val_if_fail(display != NULL, FALSE);
|
||||||
|
|
||||||
/* Already exist ? */
|
/* Already exist ? */
|
||||||
if (*display)
|
if (*display)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
context = GST_VIDEO_CONTEXT (element);
|
context = GST_VIDEO_CONTEXT(element);
|
||||||
gst_video_context_prepare (context, display_types);
|
gst_video_context_prepare(context, display_types);
|
||||||
|
|
||||||
/* If no neighboor, or application not interested, use system default */
|
/* If no neighboor, or application not interested, use system default */
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
if (!*display)
|
if (!*display)
|
||||||
*display = gst_vaapi_display_glx_new (NULL);
|
*display = gst_vaapi_display_glx_new(NULL);
|
||||||
#endif
|
#endif
|
||||||
if (!*display)
|
if (!*display)
|
||||||
*display = gst_vaapi_display_x11_new (NULL);
|
*display = gst_vaapi_display_x11_new(NULL);
|
||||||
|
|
||||||
/* FIXME allocator should return NULL in case of failure */
|
/* FIXME allocator should return NULL in case of failure */
|
||||||
if (*display && !gst_vaapi_display_get_display(*display)) {
|
if (*display && !gst_vaapi_display_get_display(*display)) {
|
||||||
g_object_unref (*display);
|
g_object_unref(*display);
|
||||||
*display = NULL;
|
*display = NULL;
|
||||||
}
|
}
|
||||||
|
return (*display != NULL);
|
||||||
return (*display != NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_set_display (const gchar *type,
|
gst_vaapi_set_display(
|
||||||
const GValue *value,
|
const gchar *type,
|
||||||
GstVaapiDisplay **display)
|
const GValue *value,
|
||||||
|
GstVaapiDisplay **display
|
||||||
|
)
|
||||||
{
|
{
|
||||||
GstVaapiDisplay *dpy = NULL;
|
GstVaapiDisplay *dpy = NULL;
|
||||||
|
|
||||||
if (!strcmp (type, "x11-display-name")) {
|
if (!strcmp(type, "x11-display-name")) {
|
||||||
g_return_if_fail (G_VALUE_HOLDS_STRING (value));
|
g_return_if_fail(G_VALUE_HOLDS_STRING(value));
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
dpy = gst_vaapi_display_glx_new (g_value_get_string (value));
|
dpy = gst_vaapi_display_glx_new(g_value_get_string(value));
|
||||||
#endif
|
#endif
|
||||||
if (!dpy)
|
if (!dpy)
|
||||||
dpy = gst_vaapi_display_x11_new (g_value_get_string (value));
|
dpy = gst_vaapi_display_x11_new(g_value_get_string(value));
|
||||||
} else if (!strcmp (type, "x11-display")) {
|
}
|
||||||
g_return_if_fail (G_VALUE_HOLDS_POINTER (value));
|
else if (!strcmp(type, "x11-display")) {
|
||||||
|
g_return_if_fail(G_VALUE_HOLDS_POINTER(value));
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
dpy = gst_vaapi_display_glx_new_with_display (g_value_get_pointer (value));
|
dpy = gst_vaapi_display_glx_new_with_display(g_value_get_pointer(value));
|
||||||
#endif
|
#endif
|
||||||
if (!dpy)
|
if (!dpy)
|
||||||
dpy = gst_vaapi_display_x11_new_with_display (g_value_get_pointer (value));
|
dpy = gst_vaapi_display_x11_new_with_display(g_value_get_pointer(value));
|
||||||
} else if (!strcmp (type, "vaapi-display")) {
|
}
|
||||||
g_return_if_fail (G_VALUE_HOLDS_POINTER (value));
|
else if (!strcmp(type, "vaapi-display")) {
|
||||||
dpy = gst_vaapi_display_new_with_display (g_value_get_pointer (value));
|
g_return_if_fail(G_VALUE_HOLDS_POINTER(value));
|
||||||
} else if (!strcmp (type, "gst-vaapi-display")) {
|
dpy = gst_vaapi_display_new_with_display(g_value_get_pointer(value));
|
||||||
g_return_if_fail (G_VALUE_HOLDS_OBJECT (value));
|
}
|
||||||
dpy = g_value_dup_object (value);
|
else if (!strcmp(type, "gst-vaapi-display")) {
|
||||||
}
|
g_return_if_fail(G_VALUE_HOLDS_OBJECT(value));
|
||||||
|
dpy = g_value_dup_object(value);
|
||||||
if (dpy) {
|
|
||||||
if (*display)
|
|
||||||
g_object_unref (*display);
|
|
||||||
*display = dpy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_reply_to_query (GstQuery *query, GstVaapiDisplay *display)
|
|
||||||
{
|
|
||||||
const gchar **types;
|
|
||||||
const gchar *type;
|
|
||||||
gint i;
|
|
||||||
gboolean res = FALSE;
|
|
||||||
|
|
||||||
if (!display)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
types = gst_video_context_query_get_supported_types (query);
|
|
||||||
|
|
||||||
if (!types)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
for (i = 0; types[i]; i++) {
|
|
||||||
type = types[i];
|
|
||||||
|
|
||||||
if (!strcmp (type, "gst-vaapi-display")) {
|
|
||||||
gst_video_context_query_set_object (query, type, G_OBJECT (display));
|
|
||||||
|
|
||||||
} else if (!strcmp (type, "vaapi-display")) {
|
|
||||||
VADisplay vadpy = gst_vaapi_display_get_display(display);
|
|
||||||
gst_video_context_query_set_pointer (query, type, vadpy);
|
|
||||||
|
|
||||||
} else if (!strcmp (type, "x11-display") &&
|
|
||||||
GST_VAAPI_IS_DISPLAY_X11(display)) {
|
|
||||||
GstVaapiDisplayX11 *xvadpy = GST_VAAPI_DISPLAY_X11 (display);
|
|
||||||
Display *x11dpy = gst_vaapi_display_x11_get_display (xvadpy);
|
|
||||||
gst_video_context_query_set_pointer (query, type, x11dpy);
|
|
||||||
|
|
||||||
} else if (!strcmp (type, "x11-display-name") &&
|
|
||||||
GST_VAAPI_IS_DISPLAY_X11(display)) {
|
|
||||||
GstVaapiDisplayX11 *xvadpy = GST_VAAPI_DISPLAY_X11 (display);
|
|
||||||
Display *x11dpy = gst_vaapi_display_x11_get_display (xvadpy);
|
|
||||||
gst_video_context_query_set_string (query, type, DisplayString(x11dpy));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = TRUE;
|
if (dpy) {
|
||||||
break;
|
if (*display)
|
||||||
}
|
g_object_unref(*display);
|
||||||
|
*display = dpy;
|
||||||
return res;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_append_surface_caps (GstCaps *out_caps, GstCaps *in_caps)
|
gst_vaapi_reply_to_query(GstQuery *query, GstVaapiDisplay *display)
|
||||||
{
|
{
|
||||||
GstStructure *structure;
|
const gchar **types;
|
||||||
const GValue *v_width, *v_height, *v_framerate, *v_par;
|
const gchar *type;
|
||||||
guint i, n_structures;
|
gint i;
|
||||||
|
gboolean res = FALSE;
|
||||||
|
|
||||||
structure = gst_caps_get_structure (in_caps, 0);
|
if (!display)
|
||||||
v_width = gst_structure_get_value (structure, "width");
|
return FALSE;
|
||||||
v_height = gst_structure_get_value (structure, "height");
|
|
||||||
v_framerate = gst_structure_get_value (structure, "framerate");
|
|
||||||
v_par = gst_structure_get_value (structure, "pixel-aspect-ratio");
|
|
||||||
if (!v_width || !v_height)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
n_structures = gst_caps_get_size (out_caps);
|
types = gst_video_context_query_get_supported_types(query);
|
||||||
for (i = 0; i < n_structures; i++) {
|
|
||||||
structure = gst_caps_get_structure (out_caps, i);
|
if (!types)
|
||||||
gst_structure_set_value (structure, "width", v_width);
|
return FALSE;
|
||||||
gst_structure_set_value (structure, "height", v_height);
|
|
||||||
if (v_framerate)
|
for (i = 0; types[i]; i++) {
|
||||||
gst_structure_set_value (structure, "framerate", v_framerate);
|
type = types[i];
|
||||||
if (v_par)
|
|
||||||
gst_structure_set_value (structure, "pixel-aspect-ratio", v_par);
|
if (!strcmp(type, "gst-vaapi-display")) {
|
||||||
}
|
gst_video_context_query_set_object(query, type, G_OBJECT(display));
|
||||||
return TRUE;
|
}
|
||||||
|
else if (!strcmp(type, "vaapi-display")) {
|
||||||
|
VADisplay vadpy = gst_vaapi_display_get_display(display);
|
||||||
|
gst_video_context_query_set_pointer(query, type, vadpy);
|
||||||
|
}
|
||||||
|
else if (!strcmp(type, "x11-display") &&
|
||||||
|
GST_VAAPI_IS_DISPLAY_X11(display)) {
|
||||||
|
GstVaapiDisplayX11 *xvadpy = GST_VAAPI_DISPLAY_X11(display);
|
||||||
|
Display *x11dpy = gst_vaapi_display_x11_get_display(xvadpy);
|
||||||
|
gst_video_context_query_set_pointer(query, type, x11dpy);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (!strcmp(type, "x11-display-name") &&
|
||||||
|
GST_VAAPI_IS_DISPLAY_X11(display)) {
|
||||||
|
GstVaapiDisplayX11 *xvadpy = GST_VAAPI_DISPLAY_X11(display);
|
||||||
|
Display *x11dpy = gst_vaapi_display_x11_get_display(xvadpy);
|
||||||
|
gst_video_context_query_set_string(query, type, DisplayString(x11dpy));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_append_surface_caps(GstCaps *out_caps, GstCaps *in_caps)
|
||||||
|
{
|
||||||
|
GstStructure *structure;
|
||||||
|
const GValue *v_width, *v_height, *v_framerate, *v_par;
|
||||||
|
guint i, n_structures;
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure(in_caps, 0);
|
||||||
|
v_width = gst_structure_get_value(structure, "width");
|
||||||
|
v_height = gst_structure_get_value(structure, "height");
|
||||||
|
v_framerate = gst_structure_get_value(structure, "framerate");
|
||||||
|
v_par = gst_structure_get_value(structure, "pixel-aspect-ratio");
|
||||||
|
if (!v_width || !v_height)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
n_structures = gst_caps_get_size(out_caps);
|
||||||
|
for (i = 0; i < n_structures; i++) {
|
||||||
|
structure = gst_caps_get_structure(out_caps, i);
|
||||||
|
gst_structure_set_value(structure, "width", v_width);
|
||||||
|
gst_structure_set_value(structure, "height", v_height);
|
||||||
|
if (v_framerate)
|
||||||
|
gst_structure_set_value(structure, "framerate", v_framerate);
|
||||||
|
if (v_par)
|
||||||
|
gst_structure_set_value(structure, "pixel-aspect-ratio", v_par);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GType
|
GType
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
#ifndef GST_VAAPI_PLUGIN_UTIL_H
|
#ifndef GST_VAAPI_PLUGIN_UTIL_H
|
||||||
#define GST_VAAPI_PLUGIN_UTIL_H
|
#define GST_VAAPI_PLUGIN_UTIL_H
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <gst/video/videocontext.h>
|
|
||||||
#include <gst/vaapi/gstvaapidisplay.h>
|
#include <gst/vaapi/gstvaapidisplay.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,9 +45,18 @@ enum _GstVaapiDisplayType {
|
||||||
GType
|
GType
|
||||||
gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
|
gst_vaapi_display_type_get_type(void) G_GNUC_CONST;
|
||||||
|
|
||||||
gboolean gst_vaapi_ensure_display (gpointer element, GstVaapiDisplay **display);
|
gboolean
|
||||||
void gst_vaapi_set_display (const gchar *type, const GValue *value, GstVaapiDisplay **display);
|
gst_vaapi_ensure_display(gpointer element, GstVaapiDisplay **display);
|
||||||
gboolean gst_vaapi_reply_to_query (GstQuery *query, GstVaapiDisplay *display);
|
|
||||||
|
void
|
||||||
|
gst_vaapi_set_display(
|
||||||
|
const gchar *type,
|
||||||
|
const GValue *value,
|
||||||
|
GstVaapiDisplay **display
|
||||||
|
);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_reply_to_query(GstQuery *query, GstVaapiDisplay *display);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_append_surface_caps (GstCaps *out_caps, GstCaps *in_caps);
|
gst_vaapi_append_surface_caps (GstCaps *out_caps, GstCaps *in_caps);
|
||||||
|
|
Loading…
Reference in a new issue