mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
plugins: factor out display creation process.
Move common VA display creation code to GstVaapiPluginBase, with the default display type remaining "any". Also add a "display-changed" hook so that subclasses could perform additional tasks when/if the VA display changed, due to a new display type request for instance. All plug-ins are updated to cope with the new internal APIs.
This commit is contained in:
parent
7e58d60854
commit
6f2dfb71e6
11 changed files with 143 additions and 77 deletions
|
@ -603,8 +603,7 @@ gst_vaapidecode_set_context(GstElement *element, GstContext *context)
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
gst_vaapidecode_ensure_display(GstVaapiDecode *decode)
|
gst_vaapidecode_ensure_display(GstVaapiDecode *decode)
|
||||||
{
|
{
|
||||||
return gst_vaapi_ensure_display(decode, GST_VAAPI_DISPLAY_TYPE_ANY,
|
return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(decode));
|
||||||
&GST_VAAPI_PLUGIN_BASE_DISPLAY(decode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline guint
|
static inline guint
|
||||||
|
|
|
@ -275,8 +275,7 @@ gst_vaapidownload_init(GstVaapiDownload *download)
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
gst_vaapidownload_ensure_display(GstVaapiDownload *download)
|
gst_vaapidownload_ensure_display(GstVaapiDownload *download)
|
||||||
{
|
{
|
||||||
return gst_vaapi_ensure_display(download, GST_VAAPI_DISPLAY_TYPE_ANY,
|
return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(download));
|
||||||
&GST_VAAPI_PLUGIN_BASE_DISPLAY(download));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -113,8 +113,7 @@ enum
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
ensure_display (GstVaapiEncode * encode)
|
ensure_display (GstVaapiEncode * encode)
|
||||||
{
|
{
|
||||||
return gst_vaapi_ensure_display (encode,
|
return gst_vaapi_plugin_base_ensure_display (GST_VAAPI_PLUGIN_BASE (encode));
|
||||||
GST_VAAPI_DISPLAY_TYPE_ANY, &GST_VAAPI_PLUGIN_BASE_DISPLAY (encode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -24,12 +24,20 @@
|
||||||
|
|
||||||
#include "gst/vaapi/sysdeps.h"
|
#include "gst/vaapi/sysdeps.h"
|
||||||
#include "gstvaapipluginbase.h"
|
#include "gstvaapipluginbase.h"
|
||||||
|
#include "gstvaapipluginutil.h"
|
||||||
|
|
||||||
|
/* Default debug category is from the subclass */
|
||||||
#define GST_CAT_DEFAULT (plugin->debug_category)
|
#define GST_CAT_DEFAULT (plugin->debug_category)
|
||||||
|
|
||||||
|
static void
|
||||||
|
default_display_changed (GstVaapiPluginBase * plugin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass)
|
gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass)
|
||||||
{
|
{
|
||||||
|
klass->display_changed = default_display_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -37,6 +45,9 @@ gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
|
||||||
GstDebugCategory * debug_category)
|
GstDebugCategory * debug_category)
|
||||||
{
|
{
|
||||||
plugin->debug_category = debug_category;
|
plugin->debug_category = debug_category;
|
||||||
|
|
||||||
|
plugin->display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
|
||||||
|
plugin->display_type_req = GST_VAAPI_DISPLAY_TYPE_ANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -74,3 +85,52 @@ gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin)
|
||||||
{
|
{
|
||||||
gst_vaapi_display_replace (&plugin->display, NULL);
|
gst_vaapi_display_replace (&plugin->display, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_plugin_base_set_display_type:
|
||||||
|
* @plugin: a #GstVaapiPluginBase
|
||||||
|
* @display_type: the new request #GstVaapiDisplayType
|
||||||
|
*
|
||||||
|
* Requests a new display type. The change is effective at the next
|
||||||
|
* call to gst_vaapi_plugin_base_ensure_display().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
|
||||||
|
GstVaapiDisplayType display_type)
|
||||||
|
{
|
||||||
|
plugin->display_type_req = display_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checks wether display type 1 is compatible with display type 2 */
|
||||||
|
static gboolean
|
||||||
|
display_type_is_compatible (GstVaapiDisplayType type1,
|
||||||
|
GstVaapiDisplayType type2)
|
||||||
|
{
|
||||||
|
return (type1 == type2 || type2 == GST_VAAPI_DISPLAY_TYPE_ANY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_plugin_base_ensure_display:
|
||||||
|
* @plugin: a #GstVaapiPluginBase
|
||||||
|
*
|
||||||
|
* Ensures the display stored in @plugin complies with the requested
|
||||||
|
* display type constraints.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the display was created to match the requested
|
||||||
|
* type, %FALSE otherwise.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin)
|
||||||
|
{
|
||||||
|
if (plugin->display && display_type_is_compatible (plugin->display_type,
|
||||||
|
plugin->display_type_req))
|
||||||
|
return TRUE;
|
||||||
|
gst_vaapi_display_replace (&plugin->display, NULL);
|
||||||
|
|
||||||
|
if (!gst_vaapi_ensure_display (plugin, plugin->display_type_req))
|
||||||
|
return FALSE;
|
||||||
|
plugin->display_type = gst_vaapi_display_get_display_type (plugin->display);
|
||||||
|
|
||||||
|
GST_VAAPI_PLUGIN_BASE_GET_CLASS (plugin)->display_changed (plugin);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
|
||||||
|
|
||||||
#define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
|
#define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
|
||||||
(GST_VAAPI_PLUGIN_BASE(plugin)->display)
|
(GST_VAAPI_PLUGIN_BASE(plugin)->display)
|
||||||
|
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(plugin) \
|
||||||
|
(GST_VAAPI_PLUGIN_BASE(plugin)->display_type)
|
||||||
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
|
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
|
||||||
(gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
|
(gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
|
||||||
(new_display)))
|
(new_display)))
|
||||||
|
@ -89,6 +91,8 @@ struct _GstVaapiPluginBase
|
||||||
GstDebugCategory *debug_category;
|
GstDebugCategory *debug_category;
|
||||||
|
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
|
GstVaapiDisplayType display_type;
|
||||||
|
GstVaapiDisplayType display_type_req;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVaapiPluginBaseClass
|
struct _GstVaapiPluginBaseClass
|
||||||
|
@ -102,6 +106,8 @@ struct _GstVaapiPluginBaseClass
|
||||||
GstBaseTransformClass transform;
|
GstBaseTransformClass transform;
|
||||||
GstVideoSinkClass sink;
|
GstVideoSinkClass sink;
|
||||||
} parent_class;
|
} parent_class;
|
||||||
|
|
||||||
|
void (*display_changed) (GstVaapiPluginBase * plugin);
|
||||||
};
|
};
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
|
@ -125,6 +131,15 @@ G_GNUC_INTERNAL
|
||||||
void
|
void
|
||||||
gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
|
gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void
|
||||||
|
gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
|
||||||
|
GstVaapiDisplayType display_type);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_PLUGIN_BASE_H */
|
#endif /* GST_VAAPI_PLUGIN_BASE_H */
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
# include <gst/vaapi/gstvaapidisplay_wayland.h>
|
# include <gst/vaapi/gstvaapidisplay_wayland.h>
|
||||||
#endif
|
#endif
|
||||||
#include "gstvaapipluginutil.h"
|
#include "gstvaapipluginutil.h"
|
||||||
|
#include "gstvaapipluginbase.h"
|
||||||
|
|
||||||
/* Preferred first */
|
/* Preferred first */
|
||||||
static const char *display_types[] = {
|
static const char *display_types[] = {
|
||||||
|
@ -88,45 +89,31 @@ static const DisplayMap g_display_map[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstVaapiDisplay *
|
static GstVaapiDisplay *
|
||||||
gst_vaapi_create_display(GstVaapiDisplayType *display_type)
|
gst_vaapi_create_display(GstVaapiDisplayType display_type)
|
||||||
{
|
{
|
||||||
GstVaapiDisplay *display = NULL;
|
GstVaapiDisplay *display = NULL;
|
||||||
const DisplayMap *m;
|
const DisplayMap *m;
|
||||||
|
|
||||||
for (m = g_display_map; m->type_str != NULL; m++) {
|
for (m = g_display_map; m->type_str != NULL; m++) {
|
||||||
if (*display_type != GST_VAAPI_DISPLAY_TYPE_ANY &&
|
if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY &&
|
||||||
*display_type != m->type)
|
display_type != m->type)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
display = m->create_display(NULL);
|
display = m->create_display(NULL);
|
||||||
if (display) {
|
if (display || display_type != GST_VAAPI_DISPLAY_TYPE_ANY)
|
||||||
*display_type = m->type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*display_type != GST_VAAPI_DISPLAY_TYPE_ANY)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_ensure_display(
|
gst_vaapi_ensure_display(gpointer element, GstVaapiDisplayType type)
|
||||||
gpointer element,
|
|
||||||
GstVaapiDisplayType display_type,
|
|
||||||
GstVaapiDisplay **display_ptr
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
GstVaapiPluginBase * const plugin = GST_VAAPI_PLUGIN_BASE(element);
|
||||||
GstVaapiDisplay *display;
|
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_ptr != NULL, FALSE);
|
|
||||||
|
|
||||||
/* Already exist ? */
|
|
||||||
display = *display_ptr;
|
|
||||||
if (display)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
context = GST_VIDEO_CONTEXT(element);
|
context = GST_VIDEO_CONTEXT(element);
|
||||||
g_return_val_if_fail(context != NULL, FALSE);
|
g_return_val_if_fail(context != NULL, FALSE);
|
||||||
|
@ -134,16 +121,17 @@ gst_vaapi_ensure_display(
|
||||||
gst_vaapi_video_context_prepare(context, display_types);
|
gst_vaapi_video_context_prepare(context, display_types);
|
||||||
|
|
||||||
/* Neighbour found and it updated the display */
|
/* Neighbour found and it updated the display */
|
||||||
if (*display_ptr)
|
if (plugin->display)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* If no neighboor, or application not interested, use system default */
|
/* If no neighboor, or application not interested, use system default */
|
||||||
display = gst_vaapi_create_display(&display_type);
|
display = gst_vaapi_create_display(type);
|
||||||
if (!display)
|
if (!display)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gst_vaapi_video_context_propagate(context, display);
|
gst_vaapi_video_context_propagate(context, display);
|
||||||
*display_ptr = display;
|
GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, display);
|
||||||
|
gst_vaapi_display_unref(display);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,7 @@
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_ensure_display(
|
gst_vaapi_ensure_display(gpointer element, GstVaapiDisplayType type);
|
||||||
gpointer element,
|
|
||||||
GstVaapiDisplayType display_type,
|
|
||||||
GstVaapiDisplay **display
|
|
||||||
);
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
void
|
void
|
||||||
|
|
|
@ -272,8 +272,7 @@ gst_vaapipostproc_set_context(GstElement *element, GstContext *context)
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
gst_vaapipostproc_ensure_display(GstVaapiPostproc *postproc)
|
gst_vaapipostproc_ensure_display(GstVaapiPostproc *postproc)
|
||||||
{
|
{
|
||||||
return gst_vaapi_ensure_display(postproc, GST_VAAPI_DISPLAY_TYPE_ANY,
|
return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(postproc));
|
||||||
&GST_VAAPI_PLUGIN_BASE_DISPLAY(postproc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -187,18 +187,23 @@ static GstFlowReturn
|
||||||
gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer);
|
gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapisink_video_overlay_set_window_handle(GstVideoOverlay *overlay, guintptr window)
|
gst_vaapisink_video_overlay_set_window_handle(GstVideoOverlay *overlay,
|
||||||
|
guintptr window)
|
||||||
{
|
{
|
||||||
GstVaapiSink * const sink = GST_VAAPISINK(overlay);
|
GstVaapiSink * const sink = GST_VAAPISINK(overlay);
|
||||||
|
GstVaapiDisplayType display_type = GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink);
|
||||||
|
|
||||||
/* Disable GLX rendering when vaapisink is using a foreign X
|
/* Disable GLX rendering when vaapisink is using a foreign X
|
||||||
window. It's pretty much useless */
|
window. It's pretty much useless */
|
||||||
if (sink->display_type == GST_VAAPI_DISPLAY_TYPE_GLX)
|
if (display_type == GST_VAAPI_DISPLAY_TYPE_GLX) {
|
||||||
sink->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
|
display_type = GST_VAAPI_DISPLAY_TYPE_X11;
|
||||||
|
gst_vaapi_plugin_base_set_display_type(GST_VAAPI_PLUGIN_BASE(sink),
|
||||||
|
display_type);
|
||||||
|
}
|
||||||
|
|
||||||
sink->foreign_window = TRUE;
|
sink->foreign_window = TRUE;
|
||||||
|
|
||||||
switch (sink->display_type) {
|
switch (display_type) {
|
||||||
#if USE_X11
|
#if USE_X11
|
||||||
case GST_VAAPI_DISPLAY_TYPE_X11:
|
case GST_VAAPI_DISPLAY_TYPE_X11:
|
||||||
gst_vaapisink_ensure_window_xid(sink, window);
|
gst_vaapisink_ensure_window_xid(sink, window);
|
||||||
|
@ -347,28 +352,26 @@ get_display_type_name(GstVaapiDisplayType display_type)
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
gst_vaapisink_ensure_display(GstVaapiSink *sink)
|
gst_vaapisink_ensure_display(GstVaapiSink *sink)
|
||||||
{
|
{
|
||||||
GstVaapiDisplayType display_type;
|
return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(sink));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapisink_display_changed(GstVaapiPluginBase *plugin)
|
||||||
|
{
|
||||||
|
GstVaapiSink * const sink = GST_VAAPISINK(plugin);
|
||||||
GstVaapiRenderMode render_mode;
|
GstVaapiRenderMode render_mode;
|
||||||
const gboolean had_display = GST_VAAPI_PLUGIN_BASE_DISPLAY(sink) != NULL;
|
|
||||||
|
|
||||||
if (!gst_vaapi_ensure_display(sink, sink->display_type, &GST_VAAPI_PLUGIN_BASE_DISPLAY(sink)))
|
GST_INFO("created %s %p", get_display_type_name(plugin->display_type),
|
||||||
return FALSE;
|
plugin->display);
|
||||||
|
|
||||||
display_type = gst_vaapi_display_get_display_type(GST_VAAPI_PLUGIN_BASE_DISPLAY(sink));
|
sink->use_overlay =
|
||||||
if (display_type != sink->display_type || (!had_display && GST_VAAPI_PLUGIN_BASE_DISPLAY(sink))) {
|
gst_vaapi_display_get_render_mode(plugin->display, &render_mode) &&
|
||||||
GST_INFO("created %s %p", get_display_type_name(display_type),
|
render_mode == GST_VAAPI_RENDER_MODE_OVERLAY;
|
||||||
GST_VAAPI_PLUGIN_BASE_DISPLAY(sink));
|
GST_DEBUG("use %s rendering mode",
|
||||||
sink->display_type = display_type;
|
sink->use_overlay ? "overlay" : "texture");
|
||||||
|
|
||||||
sink->use_overlay =
|
sink->use_rotation = gst_vaapi_display_has_property(plugin->display,
|
||||||
gst_vaapi_display_get_render_mode(GST_VAAPI_PLUGIN_BASE_DISPLAY(sink), &render_mode) &&
|
GST_VAAPI_DISPLAY_PROP_ROTATION);
|
||||||
render_mode == GST_VAAPI_RENDER_MODE_OVERLAY;
|
|
||||||
GST_DEBUG("use %s rendering mode", sink->use_overlay ? "overlay" : "texture");
|
|
||||||
|
|
||||||
sink->use_rotation = gst_vaapi_display_has_property(
|
|
||||||
GST_VAAPI_PLUGIN_BASE_DISPLAY(sink), GST_VAAPI_DISPLAY_PROP_ROTATION);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -512,7 +515,9 @@ gst_vaapisink_ensure_window(GstVaapiSink *sink, guint width, guint height)
|
||||||
GstVaapiDisplay * const display = GST_VAAPI_PLUGIN_BASE_DISPLAY(sink);
|
GstVaapiDisplay * const display = GST_VAAPI_PLUGIN_BASE_DISPLAY(sink);
|
||||||
|
|
||||||
if (!sink->window) {
|
if (!sink->window) {
|
||||||
switch (sink->display_type) {
|
const GstVaapiDisplayType display_type =
|
||||||
|
GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink);
|
||||||
|
switch (display_type) {
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
case GST_VAAPI_DISPLAY_TYPE_GLX:
|
case GST_VAAPI_DISPLAY_TYPE_GLX:
|
||||||
sink->window = gst_vaapi_window_glx_new(display, width, height);
|
sink->window = gst_vaapi_window_glx_new(display, width, height);
|
||||||
|
@ -536,7 +541,7 @@ gst_vaapisink_ensure_window(GstVaapiSink *sink, guint width, guint height)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
GST_ERROR("unsupported display type %d", sink->display_type);
|
GST_ERROR("unsupported display type %d", display_type);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -580,7 +585,7 @@ gst_vaapisink_ensure_window_xid(GstVaapiSink *sink, guintptr window_id)
|
||||||
|
|
||||||
gst_vaapi_window_replace(&sink->window, NULL);
|
gst_vaapi_window_replace(&sink->window, NULL);
|
||||||
|
|
||||||
switch (sink->display_type) {
|
switch (GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink)) {
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
case GST_VAAPI_DISPLAY_TYPE_GLX:
|
case GST_VAAPI_DISPLAY_TYPE_GLX:
|
||||||
sink->window = gst_vaapi_window_glx_new_with_xid(display, xid);
|
sink->window = gst_vaapi_window_glx_new_with_xid(display, xid);
|
||||||
|
@ -590,7 +595,8 @@ gst_vaapisink_ensure_window_xid(GstVaapiSink *sink, guintptr window_id)
|
||||||
sink->window = gst_vaapi_window_x11_new_with_xid(display, xid);
|
sink->window = gst_vaapi_window_x11_new_with_xid(display, xid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
GST_ERROR("unsupported display type %d", sink->display_type);
|
GST_ERROR("unsupported display type %d",
|
||||||
|
GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return sink->window != NULL;
|
return sink->window != NULL;
|
||||||
|
@ -780,8 +786,12 @@ gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
guint win_width, win_height;
|
guint win_width, win_height;
|
||||||
|
|
||||||
|
if (!gst_vaapisink_ensure_display(sink))
|
||||||
|
return FALSE;
|
||||||
|
display = GST_VAAPI_PLUGIN_BASE_DISPLAY(sink);
|
||||||
|
|
||||||
#if USE_DRM
|
#if USE_DRM
|
||||||
if (sink->display_type == GST_VAAPI_DISPLAY_TYPE_DRM)
|
if (GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink) == GST_VAAPI_DISPLAY_TYPE_DRM)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -800,10 +810,6 @@ gst_vaapisink_set_caps(GstBaseSink *base_sink, GstCaps *caps)
|
||||||
|
|
||||||
gst_caps_replace(&sink->caps, caps);
|
gst_caps_replace(&sink->caps, caps);
|
||||||
|
|
||||||
if (!gst_vaapisink_ensure_display(sink))
|
|
||||||
return FALSE;
|
|
||||||
display = GST_VAAPI_PLUGIN_BASE_DISPLAY(sink);
|
|
||||||
|
|
||||||
#if !GST_CHECK_VERSION(1,0,0)
|
#if !GST_CHECK_VERSION(1,0,0)
|
||||||
if (sink->use_video_raw) {
|
if (sink->use_video_raw) {
|
||||||
/* Ensure the uploader is set up for upstream allocated buffers */
|
/* Ensure the uploader is set up for upstream allocated buffers */
|
||||||
|
@ -1228,7 +1234,7 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
|
||||||
if (!gst_vaapi_apply_composition(surface, src_buffer))
|
if (!gst_vaapi_apply_composition(surface, src_buffer))
|
||||||
GST_WARNING("could not update subtitles");
|
GST_WARNING("could not update subtitles");
|
||||||
|
|
||||||
switch (sink->display_type) {
|
switch (GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink)) {
|
||||||
#if USE_DRM
|
#if USE_DRM
|
||||||
case GST_VAAPI_DISPLAY_TYPE_DRM:
|
case GST_VAAPI_DISPLAY_TYPE_DRM:
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
@ -1254,7 +1260,8 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *src_buffer)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
GST_ERROR("unsupported display type %d", sink->display_type);
|
GST_ERROR("unsupported display type %d",
|
||||||
|
GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink));
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1403,7 +1410,8 @@ gst_vaapisink_set_property(
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_DISPLAY_TYPE:
|
case PROP_DISPLAY_TYPE:
|
||||||
sink->display_type = g_value_get_enum(value);
|
gst_vaapi_plugin_base_set_display_type(GST_VAAPI_PLUGIN_BASE(sink),
|
||||||
|
g_value_get_enum(value));
|
||||||
break;
|
break;
|
||||||
case PROP_FULLSCREEN:
|
case PROP_FULLSCREEN:
|
||||||
sink->fullscreen = g_value_get_boolean(value);
|
sink->fullscreen = g_value_get_boolean(value);
|
||||||
|
@ -1441,7 +1449,7 @@ gst_vaapisink_get_property(
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_DISPLAY_TYPE:
|
case PROP_DISPLAY_TYPE:
|
||||||
g_value_set_enum(value, sink->display_type);
|
g_value_set_enum(value, GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink));
|
||||||
break;
|
break;
|
||||||
case PROP_FULLSCREEN:
|
case PROP_FULLSCREEN:
|
||||||
g_value_set_boolean(value, sink->fullscreen);
|
g_value_set_boolean(value, sink->fullscreen);
|
||||||
|
@ -1473,12 +1481,15 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
||||||
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
||||||
GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
|
GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
|
||||||
GstBaseSinkClass * const basesink_class = GST_BASE_SINK_CLASS(klass);
|
GstBaseSinkClass * const basesink_class = GST_BASE_SINK_CLASS(klass);
|
||||||
|
GstVaapiPluginBaseClass * const base_plugin_class =
|
||||||
|
GST_VAAPI_PLUGIN_BASE_CLASS(klass);
|
||||||
GstPadTemplate *pad_template;
|
GstPadTemplate *pad_template;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT(gst_debug_vaapisink,
|
GST_DEBUG_CATEGORY_INIT(gst_debug_vaapisink,
|
||||||
GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
|
GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
|
||||||
|
|
||||||
gst_vaapi_plugin_base_class_init(GST_VAAPI_PLUGIN_BASE_CLASS(klass));
|
gst_vaapi_plugin_base_class_init(base_plugin_class);
|
||||||
|
base_plugin_class->display_changed = gst_vaapisink_display_changed;
|
||||||
|
|
||||||
object_class->finalize = gst_vaapisink_finalize;
|
object_class->finalize = gst_vaapisink_finalize;
|
||||||
object_class->set_property = gst_vaapisink_set_property;
|
object_class->set_property = gst_vaapisink_set_property;
|
||||||
|
@ -1598,7 +1609,10 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
||||||
static void
|
static void
|
||||||
gst_vaapisink_init(GstVaapiSink *sink)
|
gst_vaapisink_init(GstVaapiSink *sink)
|
||||||
{
|
{
|
||||||
gst_vaapi_plugin_base_init(GST_VAAPI_PLUGIN_BASE(sink), GST_CAT_DEFAULT);
|
GstVaapiPluginBase * const plugin = GST_VAAPI_PLUGIN_BASE(sink);
|
||||||
|
|
||||||
|
gst_vaapi_plugin_base_init(plugin, GST_CAT_DEFAULT);
|
||||||
|
gst_vaapi_plugin_base_set_display_type(plugin, DEFAULT_DISPLAY_TYPE);
|
||||||
|
|
||||||
sink->caps = NULL;
|
sink->caps = NULL;
|
||||||
sink->window = NULL;
|
sink->window = NULL;
|
||||||
|
@ -1613,7 +1627,6 @@ gst_vaapisink_init(GstVaapiSink *sink)
|
||||||
sink->foreign_window = FALSE;
|
sink->foreign_window = FALSE;
|
||||||
sink->fullscreen = FALSE;
|
sink->fullscreen = FALSE;
|
||||||
sink->synchronous = FALSE;
|
sink->synchronous = FALSE;
|
||||||
sink->display_type = DEFAULT_DISPLAY_TYPE;
|
|
||||||
sink->rotation = DEFAULT_ROTATION;
|
sink->rotation = DEFAULT_ROTATION;
|
||||||
sink->rotation_req = DEFAULT_ROTATION;
|
sink->rotation_req = DEFAULT_ROTATION;
|
||||||
sink->use_reflection = FALSE;
|
sink->use_reflection = FALSE;
|
||||||
|
|
|
@ -71,7 +71,6 @@ struct _GstVaapiSink {
|
||||||
|
|
||||||
GstVaapiUploader *uploader;
|
GstVaapiUploader *uploader;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstVaapiDisplayType display_type;
|
|
||||||
GstVaapiWindow *window;
|
GstVaapiWindow *window;
|
||||||
guint window_width;
|
guint window_width;
|
||||||
guint window_height;
|
guint window_height;
|
||||||
|
|
|
@ -251,8 +251,7 @@ gst_vaapiupload_init(GstVaapiUpload *upload)
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
gst_vaapiupload_ensure_display(GstVaapiUpload *upload)
|
gst_vaapiupload_ensure_display(GstVaapiUpload *upload)
|
||||||
{
|
{
|
||||||
return gst_vaapi_ensure_display(upload, GST_VAAPI_DISPLAY_TYPE_ANY,
|
return gst_vaapi_plugin_base_ensure_display(GST_VAAPI_PLUGIN_BASE(upload));
|
||||||
&GST_VAAPI_PLUGIN_BASE_DISPLAY(upload));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue