EGLDisplay
gst_vaapi_display_egl_get_gl_display (GstVaapiDisplayEGL * display)
{
  g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_EGL (display), EGL_NO_DISPLAY);

  return display->egl_display->base.handle.p;
}
gboolean
gst_vaapi_display_egl_set_gl_context (GstVaapiDisplayEGL * display,
    EGLContext gl_context)
{
  g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_EGL (display), FALSE);

  return ensure_context_is_wrapped (display, gl_context);
}
EGLContext
gst_vaapi_display_egl_get_gl_context (GstVaapiDisplayEGL * display)
{
  g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_EGL (display), EGL_NO_CONTEXT);

  return ensure_context (display) ? display->egl_context->base.handle.p :
      EGL_NO_CONTEXT;
}
/**
 * gst_vaapi_window_egl_new:
 * @display: a #GstVaapiDisplay
 * @width: the requested window width, in pixels
 * @height: the requested windo height, in pixels
 *
 * Creates a window with the specified @width and @height. The window
 * will be attached to the @display and remains invisible to the user
 * until gst_vaapi_window_show() is called.
 *
 * Return value: the newly allocated #GstVaapiWindow object
 */
GstVaapiWindow *
gst_vaapi_window_egl_new (GstVaapiDisplay * display, guint width, guint height)
{
  GST_DEBUG ("new window, size %ux%u", width, height);

  g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_EGL (display), NULL);

  return
      gst_vaapi_window_new_internal (GST_VAAPI_WINDOW_CLASS
      (gst_vaapi_window_egl_class ()), display, GST_VAAPI_ID_INVALID, width,
      height);
}
gboolean
gst_vaapi_display_egl_set_current_display (GstVaapiDisplayEGL * display)
{
  EglDisplay *egl_display;

  g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_EGL (display), FALSE);

  if (G_UNLIKELY (eglGetCurrentDisplay () == EGL_NO_DISPLAY))
    return TRUE;
  if (G_LIKELY (display->egl_display->base.handle.p == eglGetCurrentDisplay ()))
    return TRUE;

  egl_display = egl_display_new_wrapped (eglGetCurrentDisplay ());
  if (!egl_display)
    return FALSE;
  egl_object_replace (&display->egl_display, egl_display);
  egl_object_unref (egl_display);
  if (!gst_vaapi_display_egl_set_gl_context (display, eglGetCurrentContext ()))
    return FALSE;

  return TRUE;
}