vaapisink: add support for "display-name" property.

Add a "display-name" property to vaapisink so that the end user could
select the desired output. Keep "display-name" in-line with the existing
"display" (GstVaapiDisplayXXX type).

So, for X11 or GLX, the "display-name" is the usual display name as we
know for XOpenDisplay(); for Wayland, the "display-name" is the name used
for wl_display_connect(); and for DRM, the "display-name" is actually the
DRI device name.

https://bugzilla.gnome.org/show_bug.cgi?id=722247
This commit is contained in:
Gwenole Beauchesne 2014-07-25 11:13:29 +02:00
parent b8040b35c1
commit 5ffa82b64c
4 changed files with 69 additions and 11 deletions

View file

@ -54,6 +54,25 @@ implements_interface_init (GstImplementsInterfaceClass * iface)
#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)
@ -61,12 +80,8 @@ 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
@ -74,9 +89,10 @@ plugin_set_context (GstVideoContext * context, const gchar * type,
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
@ -212,6 +228,22 @@ gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
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

View file

@ -93,6 +93,8 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
(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)))
@ -137,6 +139,7 @@ struct _GstVaapiPluginBase
GstVaapiDisplay *display;
GstVaapiDisplayType display_type;
GstVaapiDisplayType display_type_req;
gchar *display_name;
GstVaapiUploader *uploader;
gboolean uploader_used;
@ -188,6 +191,11 @@ void
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);

View file

@ -90,7 +90,8 @@ static const DisplayMap g_display_map[] = {
};
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;
@ -99,7 +100,7 @@ gst_vaapi_create_display (GstVaapiDisplayType display_type)
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;
}
@ -126,7 +127,7 @@ gst_vaapi_ensure_display (gpointer element, GstVaapiDisplayType type)
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;

View file

@ -128,6 +128,7 @@ enum {
PROP_0,
PROP_DISPLAY_TYPE,
PROP_DISPLAY_NAME,
PROP_FULLSCREEN,
PROP_SYNCHRONOUS,
PROP_USE_GLX,
@ -1148,6 +1149,10 @@ gst_vaapisink_set_property(
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;
@ -1186,6 +1191,9 @@ gst_vaapisink_get_property(
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;
@ -1277,6 +1285,15 @@ gst_vaapisink_class_init(GstVaapiSinkClass *klass)
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,