2020-08-02 13:51:08 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2020 Igalia, S.L.
|
|
|
|
* Author: Víctor Jáquez <vjaquez@igalia.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2022-02-07 16:34:57 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstvautils
|
|
|
|
* @title: GstVaUtils
|
|
|
|
* @short_description: Utility functions for context handling
|
|
|
|
* @sources:
|
|
|
|
* - gstvautils.h
|
|
|
|
*/
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstvautils.h"
|
2022-03-25 14:56:01 +00:00
|
|
|
|
2023-03-03 19:12:13 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include "gstvadisplay_win32.h"
|
|
|
|
#else
|
|
|
|
#include "gstvadisplay_drm.h"
|
|
|
|
#endif
|
|
|
|
#include "gstvadisplay_wrapped.h"
|
2020-08-02 13:51:08 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
|
|
|
|
|
|
|
|
static void
|
|
|
|
_init_context_debug (void)
|
|
|
|
{
|
|
|
|
#ifndef GST_DISABLE_GST_DEBUG
|
2021-03-22 03:34:36 +00:00
|
|
|
static gsize _init = 0;
|
2020-08-02 13:51:08 +00:00
|
|
|
|
|
|
|
if (g_once_init_enter (&_init)) {
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT");
|
|
|
|
g_once_init_leave (&_init, 1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_va_display_found (GstElement * element, GstVaDisplay * display)
|
|
|
|
{
|
|
|
|
if (display) {
|
|
|
|
GST_CAT_LOG_OBJECT (GST_CAT_CONTEXT, element, "already have a display (%p)",
|
|
|
|
display);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
pad_query (const GValue * item, GValue * value, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstPad *pad = g_value_get_object (item);
|
|
|
|
GstQuery *query = user_data;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
res = gst_pad_peer_query (pad, query);
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
g_value_set_boolean (value, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, pad, "pad peer query failed");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_gst_va_run_query (GstElement * element, GstQuery * query,
|
|
|
|
GstPadDirection direction)
|
|
|
|
{
|
|
|
|
GstIterator *it;
|
|
|
|
GstIteratorFoldFunction func = pad_query;
|
|
|
|
GValue res = G_VALUE_INIT;
|
|
|
|
|
|
|
|
g_value_init (&res, G_TYPE_BOOLEAN);
|
|
|
|
g_value_set_boolean (&res, FALSE);
|
|
|
|
|
|
|
|
if (direction == GST_PAD_SRC)
|
|
|
|
it = gst_element_iterate_src_pads (element);
|
|
|
|
else
|
|
|
|
it = gst_element_iterate_sink_pads (element);
|
|
|
|
|
|
|
|
while (gst_iterator_fold (it, func, &res, query) == GST_ITERATOR_RESYNC)
|
|
|
|
gst_iterator_resync (it);
|
|
|
|
|
|
|
|
gst_iterator_free (it);
|
|
|
|
|
|
|
|
return g_value_get_boolean (&res);
|
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/**
|
|
|
|
* gst_va_context_query:
|
|
|
|
* @element: a #GstElement
|
|
|
|
* @context_type: the #gchar string specify the context type name
|
|
|
|
*
|
|
|
|
* Query the specified context type name.
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gst_va_context_query (GstElement * element, const gchar * context_type)
|
2020-08-02 13:51:08 +00:00
|
|
|
{
|
|
|
|
GstQuery *query;
|
|
|
|
GstContext *ctxt = NULL;
|
|
|
|
|
|
|
|
_init_context_debug ();
|
|
|
|
|
|
|
|
/* 2a) Query downstream with GST_QUERY_CONTEXT for the context and
|
|
|
|
* check if downstream already has a context of the specific type
|
|
|
|
* 2b) Query upstream as above.
|
|
|
|
*/
|
|
|
|
query = gst_query_new_context (context_type);
|
|
|
|
if (_gst_va_run_query (element, query, GST_PAD_SRC)) {
|
|
|
|
gst_query_parse_context (query, &ctxt);
|
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
|
|
|
|
"found context (%p) in downstream query", ctxt);
|
|
|
|
gst_element_set_context (element, ctxt);
|
|
|
|
} else if (_gst_va_run_query (element, query, GST_PAD_SINK)) {
|
|
|
|
gst_query_parse_context (query, &ctxt);
|
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
|
|
|
|
"found context (%p) in upstream query", ctxt);
|
|
|
|
gst_element_set_context (element, ctxt);
|
|
|
|
} else {
|
|
|
|
/* 3) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with
|
|
|
|
* the required context type and afterwards check if a
|
|
|
|
* usable context was set now as in 1). The message could
|
|
|
|
* be handled by the parent bins of the element and the
|
|
|
|
* application.
|
|
|
|
*/
|
|
|
|
GstMessage *msg;
|
|
|
|
|
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
|
|
|
|
"posting need context message");
|
|
|
|
msg = gst_message_new_need_context (GST_OBJECT_CAST (element),
|
|
|
|
context_type);
|
|
|
|
gst_element_post_message (element, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Whomever responds to the need-context message performs a
|
|
|
|
* GstElement::set_context() with the required context in which the element
|
|
|
|
* is required to update the display_ptr or call gst_va_handle_set_context().
|
|
|
|
*/
|
|
|
|
|
|
|
|
gst_query_unref (query);
|
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/**
|
|
|
|
* gst_va_element_propagate_display_context:
|
|
|
|
* @element: a #GstElement
|
|
|
|
* @display: the #GstVaDisplay to propagate
|
|
|
|
*
|
|
|
|
* Propagate @display by posting it as #GstContext in the pipeline's bus.
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
**/
|
2020-08-02 13:51:08 +00:00
|
|
|
void
|
|
|
|
gst_va_element_propagate_display_context (GstElement * element,
|
|
|
|
GstVaDisplay * display)
|
|
|
|
{
|
|
|
|
GstContext *ctxt;
|
|
|
|
GstMessage *msg;
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
_init_context_debug ();
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
if (!display) {
|
2020-09-19 19:36:58 +00:00
|
|
|
GST_ERROR_OBJECT (element, "Could not get VA display connection");
|
2020-08-02 13:51:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/* 4) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT
|
|
|
|
* message.
|
|
|
|
*/
|
2021-05-06 10:23:23 +00:00
|
|
|
ctxt = gst_context_new (GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR, TRUE);
|
2020-08-02 13:51:08 +00:00
|
|
|
gst_context_set_va_display (ctxt, display);
|
|
|
|
|
|
|
|
GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element,
|
|
|
|
"post have context (%p) message with display (%p)", ctxt, display);
|
|
|
|
msg = gst_message_new_have_context (GST_OBJECT_CAST (element), ctxt);
|
|
|
|
gst_element_post_message (element, msg);
|
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/**
|
|
|
|
* gst_va_ensure_element_data:
|
|
|
|
* @element: a #GstElement
|
|
|
|
* @render_device_path: the #gchar string of render device path
|
|
|
|
* @display_ptr: (out) (transfer full): The #GstVaDisplay to ensure
|
|
|
|
*
|
|
|
|
* Called by the va element to ensure a valid #GstVaDisplay.
|
|
|
|
*
|
|
|
|
* Returns: whether a #GstVaDisplay exists in @display_ptr
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
**/
|
2020-08-02 13:51:08 +00:00
|
|
|
gboolean
|
|
|
|
gst_va_ensure_element_data (gpointer element, const gchar * render_device_path,
|
|
|
|
GstVaDisplay ** display_ptr)
|
|
|
|
{
|
|
|
|
GstVaDisplay *display;
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
_init_context_debug ();
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
g_return_val_if_fail (element, FALSE);
|
|
|
|
g_return_val_if_fail (render_device_path, FALSE);
|
|
|
|
g_return_val_if_fail (display_ptr, FALSE);
|
|
|
|
|
|
|
|
/* 1) Check if the element already has a context of the specific
|
|
|
|
* type.
|
|
|
|
*/
|
2021-01-15 07:22:07 +00:00
|
|
|
if (gst_va_display_found (element, g_atomic_pointer_get (display_ptr)))
|
2020-08-02 13:51:08 +00:00
|
|
|
goto done;
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
gst_va_context_query (element, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR);
|
2020-08-02 13:51:08 +00:00
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/* Neighbour found and it updated the display. */
|
2021-01-15 07:22:07 +00:00
|
|
|
if (gst_va_display_found (element, g_atomic_pointer_get (display_ptr)))
|
2020-08-02 13:51:08 +00:00
|
|
|
goto done;
|
|
|
|
|
2023-03-03 19:12:13 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
display = gst_va_display_win32_new (render_device_path);
|
|
|
|
#else
|
2021-10-07 06:31:28 +00:00
|
|
|
/* If no neighbor, or application not interested, use drm. */
|
2020-08-02 13:51:08 +00:00
|
|
|
display = gst_va_display_drm_new_from_path (render_device_path);
|
2023-03-03 19:12:13 +00:00
|
|
|
#endif
|
2020-08-02 13:51:08 +00:00
|
|
|
|
2021-01-15 07:22:07 +00:00
|
|
|
gst_object_replace ((GstObject **) display_ptr, (GstObject *) display);
|
2020-08-02 13:51:08 +00:00
|
|
|
|
|
|
|
gst_va_element_propagate_display_context (element, display);
|
|
|
|
|
2021-01-16 17:16:17 +00:00
|
|
|
gst_clear_object (&display);
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
done:
|
2021-01-16 17:16:17 +00:00
|
|
|
return g_atomic_pointer_get (display_ptr) != NULL;
|
2020-08-02 13:51:08 +00:00
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/**
|
|
|
|
* gst_va_handle_set_context:
|
|
|
|
* @element: a #GstElement
|
|
|
|
* @context: a #GstContext may contain the display
|
|
|
|
* @render_device_path: the #gchar string of render device path
|
|
|
|
* @display_ptr: (out) (transfer full): The #GstVaDisplay to set
|
|
|
|
*
|
2022-02-07 16:34:57 +00:00
|
|
|
* Called by elements in their #GstElementClass::set_context vmethod.
|
2021-10-07 06:31:28 +00:00
|
|
|
* It gets a valid #GstVaDisplay if @context has it.
|
|
|
|
*
|
2022-02-07 16:34:57 +00:00
|
|
|
* Returns: whether the @display_ptr could be successfully set to a
|
|
|
|
* valid #GstVaDisplay in the @context
|
2021-10-07 06:31:28 +00:00
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
**/
|
2020-08-02 13:51:08 +00:00
|
|
|
gboolean
|
|
|
|
gst_va_handle_set_context (GstElement * element, GstContext * context,
|
|
|
|
const gchar * render_device_path, GstVaDisplay ** display_ptr)
|
|
|
|
{
|
|
|
|
GstVaDisplay *display_replacement = NULL;
|
|
|
|
const gchar *context_type, *type_name;
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
_init_context_debug ();
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
g_return_val_if_fail (display_ptr, FALSE);
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
context_type = gst_context_get_context_type (context);
|
|
|
|
|
2021-05-06 10:23:23 +00:00
|
|
|
if (g_strcmp0 (context_type, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR) == 0) {
|
2020-08-02 13:51:08 +00:00
|
|
|
type_name = G_OBJECT_TYPE_NAME (element);
|
|
|
|
if (!gst_context_get_va_display (context, type_name, render_device_path,
|
|
|
|
&display_replacement)) {
|
|
|
|
GST_CAT_WARNING_OBJECT (GST_CAT_CONTEXT, element,
|
|
|
|
"Failed to get display from context");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (display_replacement) {
|
2021-01-15 07:22:07 +00:00
|
|
|
gst_object_replace ((GstObject **) display_ptr,
|
|
|
|
(GstObject *) display_replacement);
|
|
|
|
gst_object_unref (display_replacement);
|
2020-08-02 13:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/**
|
|
|
|
* gst_va_handle_context_query:
|
|
|
|
* @element: a #GstElement
|
|
|
|
* @query: a #GstQuery to query the context
|
|
|
|
* @display: a #GstVaDisplay to answer the query
|
|
|
|
*
|
|
|
|
* Used by elements when processing their pad's queries, propagating
|
|
|
|
* element's #GstVaDisplay if the processed query requests it.
|
|
|
|
*
|
|
|
|
* Returns: whether we can handle the context query successfully
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
**/
|
2020-08-02 13:51:08 +00:00
|
|
|
gboolean
|
|
|
|
gst_va_handle_context_query (GstElement * element, GstQuery * query,
|
|
|
|
GstVaDisplay * display)
|
|
|
|
{
|
|
|
|
const gchar *context_type;
|
|
|
|
GstContext *ctxt, *old_ctxt;
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
_init_context_debug ();
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_QUERY (query), FALSE);
|
2020-08-04 08:24:49 +00:00
|
|
|
g_return_val_if_fail (!display || GST_IS_VA_DISPLAY (display), FALSE);
|
2020-08-02 13:51:08 +00:00
|
|
|
|
|
|
|
GST_CAT_LOG_OBJECT (GST_CAT_CONTEXT, element,
|
|
|
|
"handle context query %" GST_PTR_FORMAT, query);
|
|
|
|
gst_query_parse_context_type (query, &context_type);
|
|
|
|
|
2021-05-06 10:23:23 +00:00
|
|
|
if (!display
|
|
|
|
|| g_strcmp0 (context_type, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR) != 0)
|
2020-08-02 13:51:08 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gst_query_parse_context (query, &old_ctxt);
|
|
|
|
|
|
|
|
if (old_ctxt)
|
|
|
|
ctxt = gst_context_copy (old_ctxt);
|
|
|
|
else
|
2021-05-06 10:23:23 +00:00
|
|
|
ctxt = gst_context_new (GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR, TRUE);
|
2020-08-02 13:51:08 +00:00
|
|
|
|
|
|
|
gst_context_set_va_display (ctxt, display);
|
|
|
|
gst_query_set_context (query, ctxt);
|
|
|
|
gst_context_unref (ctxt);
|
|
|
|
GST_CAT_DEBUG_OBJECT (GST_CAT_CONTEXT, element,
|
2021-10-07 06:31:28 +00:00
|
|
|
"successfully %" GST_PTR_FORMAT " on %" GST_PTR_FORMAT, display, query);
|
2020-08-02 13:51:08 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/**
|
|
|
|
* gst_context_get_va_display:
|
|
|
|
* @context: a #GstContext may contain the display
|
|
|
|
* @type_name: a #gchar string of the element type
|
|
|
|
* @render_device_path: the #gchar string of render device path
|
|
|
|
* @display_ptr: (out) (transfer full): the #GstVaDisplay we get
|
|
|
|
*
|
|
|
|
* Returns: whether we find a valid @display in the @context
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
**/
|
2020-08-02 13:51:08 +00:00
|
|
|
gboolean
|
|
|
|
gst_context_get_va_display (GstContext * context, const gchar * type_name,
|
|
|
|
const gchar * render_device_path, GstVaDisplay ** display_ptr)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
GstVaDisplay *display = NULL;
|
|
|
|
gpointer dpy;
|
|
|
|
gboolean is_devnode;
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
_init_context_debug ();
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
g_return_val_if_fail (display_ptr, FALSE);
|
|
|
|
g_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
is_devnode = (g_strstr_len (type_name, -1, "renderD") != NULL);
|
|
|
|
|
|
|
|
s = gst_context_get_structure (context);
|
2020-09-19 19:43:24 +00:00
|
|
|
if (gst_structure_get (s, "gst-display", GST_TYPE_OBJECT, &display, NULL)) {
|
2020-08-19 15:18:26 +00:00
|
|
|
gboolean ret;
|
2023-03-03 19:12:13 +00:00
|
|
|
gchar *device_path = NULL;
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
if (GST_IS_VA_DISPLAY_WIN32 (display)) {
|
|
|
|
#else
|
2020-08-02 13:51:08 +00:00
|
|
|
if (GST_IS_VA_DISPLAY_DRM (display)) {
|
2023-03-03 19:12:13 +00:00
|
|
|
#endif
|
2020-08-02 13:51:08 +00:00
|
|
|
g_object_get (display, "path", &device_path, NULL);
|
2020-08-19 15:18:26 +00:00
|
|
|
ret = (g_strcmp0 (device_path, render_device_path) == 0);
|
|
|
|
g_free (device_path);
|
|
|
|
if (ret)
|
2020-08-02 13:51:08 +00:00
|
|
|
goto accept;
|
2020-09-19 19:43:24 +00:00
|
|
|
} else if (GST_IS_VA_DISPLAY (display) && !is_devnode) {
|
2020-08-02 13:51:08 +00:00
|
|
|
goto accept;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* let's try other fields */
|
|
|
|
gst_clear_object (&display);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if element is render device node specific, it doesn't accept
|
|
|
|
* VADisplay from users */
|
|
|
|
if (!is_devnode
|
|
|
|
&& gst_structure_get (s, "va-display", G_TYPE_POINTER, &dpy, NULL)) {
|
2021-05-13 16:46:21 +00:00
|
|
|
if ((display = gst_va_display_wrapped_new (dpy)))
|
2020-08-02 13:51:08 +00:00
|
|
|
goto accept;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_CAT_DEBUG (GST_CAT_CONTEXT, "No valid GstVaDisplay from context (%p)",
|
|
|
|
context);
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
accept:
|
|
|
|
{
|
|
|
|
*display_ptr = display;
|
|
|
|
|
|
|
|
GST_CAT_LOG (GST_CAT_CONTEXT, "got GstVaDisplay (%p) from context (%p)",
|
|
|
|
*display_ptr, context);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
/**
|
|
|
|
* gst_context_set_va_display:
|
|
|
|
* @context: a #GstContext
|
|
|
|
* @display: the #GstVaDisplay we want to set
|
|
|
|
*
|
|
|
|
* Set the @display in the @context
|
|
|
|
*
|
|
|
|
* Since: 1.22
|
|
|
|
*/
|
2020-08-02 13:51:08 +00:00
|
|
|
void
|
|
|
|
gst_context_set_va_display (GstContext * context, GstVaDisplay * display)
|
|
|
|
{
|
|
|
|
GstStructure *s;
|
|
|
|
|
2021-10-07 06:31:28 +00:00
|
|
|
_init_context_debug ();
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
|
2022-03-29 17:49:40 +00:00
|
|
|
s = gst_context_writable_structure (context);
|
|
|
|
gst_structure_set (s, "gst-display", GST_TYPE_OBJECT, display, NULL);
|
|
|
|
|
2020-09-19 19:36:58 +00:00
|
|
|
if (display) {
|
2022-03-29 17:49:40 +00:00
|
|
|
GObjectClass *klass = G_OBJECT_GET_CLASS (display);
|
|
|
|
gchar *vendor_desc = NULL;
|
|
|
|
gchar *path = NULL;
|
|
|
|
|
|
|
|
g_object_get (display, "description", &vendor_desc, NULL);
|
|
|
|
if (g_object_class_find_property (klass, "path"))
|
|
|
|
g_object_get (display, "path", &path, NULL);
|
|
|
|
|
2020-08-02 13:51:08 +00:00
|
|
|
GST_CAT_LOG (GST_CAT_CONTEXT,
|
|
|
|
"setting GstVaDisplay (%" GST_PTR_FORMAT ") on context (%"
|
2022-03-29 17:49:40 +00:00
|
|
|
GST_PTR_FORMAT "), description: \"%s\", path: %s", display, context,
|
|
|
|
GST_STR_NULL (vendor_desc), GST_STR_NULL (path));
|
2020-08-02 13:51:08 +00:00
|
|
|
|
2022-03-29 17:49:40 +00:00
|
|
|
if (vendor_desc) {
|
|
|
|
gst_structure_set (s, "description", G_TYPE_STRING, vendor_desc, NULL);
|
|
|
|
g_free (vendor_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
gst_structure_set (s, "path", G_TYPE_STRING, path, NULL);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
}
|
2020-08-02 13:51:08 +00:00
|
|
|
}
|