#endif
/* GstVideoContext interface */
+static void
+plugin_set_display (GstVaapiPluginBase * plugin, GstVaapiDisplay * display)
+{
+ const gchar *const display_name =
+ gst_vaapi_display_get_display_name (display);
+
+ if (plugin->display_name && g_strcmp0 (plugin->display_name, display_name)) {
+ GST_DEBUG_OBJECT (plugin, "incompatible display name '%s', requested '%s'",
+ display_name, plugin->display_name);
+ gst_vaapi_display_replace (&plugin->display, NULL);
+ } else {
+ GST_INFO_OBJECT (plugin, "set display %p", display);
+ gst_vaapi_display_replace (&plugin->display, display);
+ plugin->display_type = gst_vaapi_display_get_display_type (display);
+ gst_vaapi_plugin_base_set_display_name (plugin, display_name);
+ }
+ gst_vaapi_display_unref (display);
+}
+
#if GST_CHECK_VERSION(1,1,0)
static void
plugin_set_context (GstElement * element, GstContext * context)
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
GstVaapiDisplay *display = NULL;
- if (gst_vaapi_video_context_get_display (context, &display)) {
- GST_INFO_OBJECT (element, "set display %p", display);
- gst_vaapi_display_replace (&plugin->display, display);
- gst_vaapi_display_unref (display);
- plugin->display_type = gst_vaapi_display_get_display_type (display);
- }
+ if (gst_vaapi_video_context_get_display (context, &display))
+ plugin_set_display (plugin, display);
}
#else
static void
const GValue * value)
{
GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (context);
+ GstVaapiDisplay *display = NULL;
- gst_vaapi_set_display (type, value, &plugin->display);
- plugin->display_type = gst_vaapi_display_get_display_type (plugin->display);
+ gst_vaapi_set_display (type, value, &display);
+ plugin_set_display (plugin, display);
}
static void
plugin->display_type_req = display_type;
}
+/**
+ * gst_vaapi_plugin_base_set_display_name:
+ * @plugin: a #GstVaapiPluginBase
+ * @display_name: the new display name to match
+ *
+ * Sets the name of the display to look for. The change is effective
+ * at the next call to gst_vaapi_plugin_base_ensure_display().
+ */
+void
+gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
+ const gchar * display_name)
+{
+ g_free (plugin->display_name);
+ plugin->display_name = g_strdup (display_name);
+}
+
/**
* gst_vaapi_plugin_base_ensure_display:
* @plugin: a #GstVaapiPluginBase
(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_NAME(plugin) \
+ (GST_VAAPI_PLUGIN_BASE(plugin)->display_name)
#define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
(gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
(new_display)))
GstVaapiDisplay *display;
GstVaapiDisplayType display_type;
GstVaapiDisplayType display_type_req;
+ gchar *display_name;
GstVaapiUploader *uploader;
gboolean uploader_used;
gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
GstVaapiDisplayType display_type);
+G_GNUC_INTERNAL
+void
+gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
+ const gchar * display_name);
+
G_GNUC_INTERNAL
gboolean
gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
};
static GstVaapiDisplay *
-gst_vaapi_create_display (GstVaapiDisplayType display_type)
+gst_vaapi_create_display (GstVaapiDisplayType display_type,
+ const gchar * display_name)
{
GstVaapiDisplay *display = NULL;
const DisplayMap *m;
if (display_type != GST_VAAPI_DISPLAY_TYPE_ANY && display_type != m->type)
continue;
- display = m->create_display (NULL);
+ display = m->create_display (display_name);
if (display || display_type != GST_VAAPI_DISPLAY_TYPE_ANY)
break;
}
return TRUE;
/* If no neighboor, or application not interested, use system default */
- display = gst_vaapi_create_display (type);
+ display = gst_vaapi_create_display (type, plugin->display_name);
if (!display)
return FALSE;
PROP_0,
PROP_DISPLAY_TYPE,
+ PROP_DISPLAY_NAME,
PROP_FULLSCREEN,
PROP_SYNCHRONOUS,
PROP_USE_GLX,
gst_vaapi_plugin_base_set_display_type(GST_VAAPI_PLUGIN_BASE(sink),
g_value_get_enum(value));
break;
+ case PROP_DISPLAY_NAME:
+ gst_vaapi_plugin_base_set_display_name(GST_VAAPI_PLUGIN_BASE(sink),
+ g_value_get_string(value));
+ break;
case PROP_FULLSCREEN:
sink->fullscreen = g_value_get_boolean(value);
break;
case PROP_DISPLAY_TYPE:
g_value_set_enum(value, GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(sink));
break;
+ case PROP_DISPLAY_NAME:
+ g_value_set_string(value, GST_VAAPI_PLUGIN_BASE_DISPLAY_NAME(sink));
+ break;
case PROP_FULLSCREEN:
g_value_set_boolean(value, sink->fullscreen);
break;
GST_VAAPI_DISPLAY_TYPE_ANY,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property
+ (object_class,
+ PROP_DISPLAY_NAME,
+ g_param_spec_string("display-name",
+ "display name",
+ "display name to use",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
#if USE_GLX
g_object_class_install_property
(object_class,