gboolean
gst_vaapi_ensure_display (gpointer element, GstVaapiDisplayType type)
{
  GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
  GstVaapiDisplay *display;
  GstVideoContext *context;

  g_return_val_if_fail (GST_IS_VIDEO_CONTEXT (element), FALSE);

  context = GST_VIDEO_CONTEXT (element);
  g_return_val_if_fail (context != NULL, FALSE);

  gst_vaapi_video_context_prepare (context, display_types);

  /* Neighbour found and it updated the display */
  if (gst_vaapi_plugin_base_has_display_type (plugin, type))
    return TRUE;

  /* If no neighboor, or application not interested, use system default */
  if (plugin->gl_context)
    display = gst_vaapi_create_display_from_gl_context (plugin->gl_context);
  else
    display = gst_vaapi_create_display (type, plugin->display_name);
  if (!display)
    return FALSE;

  gst_vaapi_video_context_propagate (context, display);
  GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE (plugin, display);
  gst_vaapi_display_unref (display);
  return TRUE;
}
gboolean
gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type)
{
  GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
  GstVaapiDisplay *display;

  g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);

  if (gst_vaapi_video_context_prepare (element, &plugin->display)) {
    /* Neighbour found and it updated the display */
    if (gst_vaapi_plugin_base_has_display_type (plugin, type))
      return TRUE;
  }

  /* If no neighboor, or application not interested, use system default */
  if (plugin->gl_context)
    display = gst_vaapi_create_display_from_gl_context (plugin->gl_context);
  else
    display = gst_vaapi_create_display (type, plugin->display_name);
  if (!display)
    return FALSE;

  gst_vaapi_video_context_propagate (element, display);
  gst_vaapi_display_unref (display);
  return TRUE;
}
Ejemplo n.º 3
0
gboolean
gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type)
{
  GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
  GstVaapiDisplay *display = NULL;

  g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);

  if (gst_vaapi_video_context_prepare (element, &plugin->display)) {
    /* Neighbour found and it updated the display */
    if (gst_vaapi_plugin_base_has_display_type (plugin, type))
      return TRUE;
  }

  /* Query for a local GstGL context. If it's found, it will be used
   * to create the VA display */
  if (!plugin->gl_context)
    gst_vaapi_find_gl_context (element);

  /* If no neighboor, or application not interested, use system default */
  if (plugin->gl_context) {
    display = gst_vaapi_create_display_from_gl_context (plugin->gl_context);
    /* Cannot instantiate VA display based on GL context. Reset the
     *  requested display type to ANY to try again */
    if (!display)
      gst_vaapi_plugin_base_set_display_type (plugin,
          GST_VAAPI_DISPLAY_TYPE_ANY);
  }
  if (!display)
    display = gst_vaapi_create_display (type, plugin->display_name);
  if (!display)
    return FALSE;

  gst_vaapi_video_context_propagate (element, display);
  gst_object_unref (display);
  return TRUE;
}