diff --git a/subprojects/gst-plugins-bad/sys/va/gstvautils.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvautils.c similarity index 78% rename from subprojects/gst-plugins-bad/sys/va/gstvautils.c rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvautils.c index 57952ebf7d..bc54f26742 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvautils.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvautils.c @@ -44,8 +44,6 @@ _init_context_debug (void) static gboolean gst_va_display_found (GstElement * element, GstVaDisplay * display) { - _init_context_debug (); - if (display) { GST_CAT_LOG_OBJECT (GST_CAT_CONTEXT, element, "already have a display (%p)", display); @@ -62,8 +60,6 @@ pad_query (const GValue * item, GValue * value, gpointer user_data) GstQuery *query = user_data; gboolean res; - _init_context_debug (); - res = gst_pad_peer_query (pad, query); if (res) { @@ -99,8 +95,17 @@ _gst_va_run_query (GstElement * element, GstQuery * query, return g_value_get_boolean (&res); } -static void -_gst_context_query (GstElement * element, const gchar * context_type) +/** + * 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) { GstQuery *query; GstContext *ctxt = NULL; @@ -147,9 +152,15 @@ _gst_context_query (GstElement * element, const gchar * context_type) gst_query_unref (query); } -/* 4) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT - * message. - */ +/** + * 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 + **/ void gst_va_element_propagate_display_context (GstElement * element, GstVaDisplay * display) @@ -157,13 +168,16 @@ gst_va_element_propagate_display_context (GstElement * element, GstContext *ctxt; GstMessage *msg; + _init_context_debug (); + if (!display) { GST_ERROR_OBJECT (element, "Could not get VA display connection"); return; } - _init_context_debug (); - + /* 4) Create a context by itself and post a GST_MESSAGE_HAVE_CONTEXT + * message. + */ ctxt = gst_context_new (GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR, TRUE); gst_context_set_va_display (ctxt, display); @@ -173,12 +187,26 @@ gst_va_element_propagate_display_context (GstElement * element, gst_element_post_message (element, msg); } +/** + * 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 + **/ gboolean gst_va_ensure_element_data (gpointer element, const gchar * render_device_path, GstVaDisplay ** display_ptr) { GstVaDisplay *display; + _init_context_debug (); + g_return_val_if_fail (element, FALSE); g_return_val_if_fail (render_device_path, FALSE); g_return_val_if_fail (display_ptr, FALSE); @@ -189,13 +217,13 @@ gst_va_ensure_element_data (gpointer element, const gchar * render_device_path, if (gst_va_display_found (element, g_atomic_pointer_get (display_ptr))) goto done; - _gst_context_query (element, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR); + gst_va_context_query (element, GST_VA_DISPLAY_HANDLE_CONTEXT_TYPE_STR); - /* Neighbour found and it updated the display */ + /* Neighbour found and it updated the display. */ if (gst_va_display_found (element, g_atomic_pointer_get (display_ptr))) goto done; - /* If no neighbor, or application not interested, use drm */ + /* If no neighbor, or application not interested, use drm. */ display = gst_va_display_drm_new_from_path (render_device_path); gst_object_replace ((GstObject **) display_ptr, (GstObject *) display); @@ -208,6 +236,21 @@ done: return g_atomic_pointer_get (display_ptr) != NULL; } +/** + * 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 + * + * Called by elements in their GstElement::set_context() vmehtods. + * It gets a valid #GstVaDisplay if @context has it. + * + * Returns: whether the @display_ptr could be successfully set to + * a valid #GstVaDisplay in the @context + * + * Since: 1.22 + **/ gboolean gst_va_handle_set_context (GstElement * element, GstContext * context, const gchar * render_device_path, GstVaDisplay ** display_ptr) @@ -215,6 +258,8 @@ gst_va_handle_set_context (GstElement * element, GstContext * context, GstVaDisplay *display_replacement = NULL; const gchar *context_type, *type_name; + _init_context_debug (); + g_return_val_if_fail (display_ptr, FALSE); if (!context) @@ -241,6 +286,19 @@ gst_va_handle_set_context (GstElement * element, GstContext * context, return TRUE; } +/** + * 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 + **/ gboolean gst_va_handle_context_query (GstElement * element, GstQuery * query, GstVaDisplay * display) @@ -248,12 +306,12 @@ gst_va_handle_context_query (GstElement * element, GstQuery * query, const gchar *context_type; GstContext *ctxt, *old_ctxt; + _init_context_debug (); + g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (GST_IS_QUERY (query), FALSE); g_return_val_if_fail (!display || GST_IS_VA_DISPLAY (display), FALSE); - _init_context_debug (); - GST_CAT_LOG_OBJECT (GST_CAT_CONTEXT, element, "handle context query %" GST_PTR_FORMAT, query); gst_query_parse_context_type (query, &context_type); @@ -273,11 +331,22 @@ gst_va_handle_context_query (GstElement * element, GstQuery * query, gst_query_set_context (query, ctxt); gst_context_unref (ctxt); GST_CAT_DEBUG_OBJECT (GST_CAT_CONTEXT, element, - "successuflly %" GST_PTR_FORMAT " on %" GST_PTR_FORMAT, display, query); + "successfully %" GST_PTR_FORMAT " on %" GST_PTR_FORMAT, display, query); return TRUE; } +/** + * 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 + **/ gboolean gst_context_get_va_display (GstContext * context, const gchar * type_name, const gchar * render_device_path, GstVaDisplay ** display_ptr) @@ -287,6 +356,8 @@ gst_context_get_va_display (GstContext * context, const gchar * type_name, gpointer dpy; gboolean is_devnode; + _init_context_debug (); + g_return_val_if_fail (display_ptr, FALSE); g_return_val_if_fail (context, FALSE); @@ -333,11 +404,22 @@ accept: } } +/** + * gst_context_set_va_display: + * @context: a #GstContext + * @display: the #GstVaDisplay we want to set + * + * Set the @display in the @context + * + * Since: 1.22 + */ void gst_context_set_va_display (GstContext * context, GstVaDisplay * display) { GstStructure *s; + _init_context_debug (); + g_return_if_fail (context != NULL); if (display) { diff --git a/subprojects/gst-plugins-bad/sys/va/gstvautils.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvautils.h similarity index 90% rename from subprojects/gst-plugins-bad/sys/va/gstvautils.h rename to subprojects/gst-plugins-bad/gst-libs/gst/va/gstvautils.h index 3bca0b82f6..65de738b16 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvautils.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvautils.h @@ -24,23 +24,31 @@ G_BEGIN_DECLS +GST_VA_API gboolean gst_va_ensure_element_data (gpointer element, const gchar *render_device_path, GstVaDisplay ** display_ptr); +GST_VA_API +void gst_va_context_query (GstElement * element, + const gchar * context_type); +GST_VA_API gboolean gst_va_handle_set_context (GstElement * element, GstContext * context, const gchar *render_device_path, GstVaDisplay ** display_ptr); +GST_VA_API gboolean gst_va_handle_context_query (GstElement * element, GstQuery * query, GstVaDisplay * display); +GST_VA_API void gst_va_element_propagate_display_context (GstElement * element, GstVaDisplay * display); - +GST_VA_API gboolean gst_context_get_va_display (GstContext * context, const gchar * type_name, const gchar * render_device_path, GstVaDisplay ** display_ptr); +GST_VA_API void gst_context_set_va_display (GstContext * context, GstVaDisplay * display); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build index df8edb0eb1..7d92c8da50 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/meson.build @@ -2,12 +2,14 @@ va_sources = [ 'gstvadisplay.c', 'gstvadisplay_drm.c', 'gstvadisplay_wrapped.c', + 'gstvautils.c', ] va_headers = [ 'gstvadisplay.h', 'gstvadisplay_drm.h', 'gstvadisplay_wrapped.h', + 'gstvautils.h', 'va_fwd.h', 'va-prelude.h', ] diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c index 8414ecb2ee..28e4bc33c6 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c @@ -18,12 +18,13 @@ * Boston, MA 02110-1301, USA. */ +#include + #include "gstvabasedec.h" #include "gstvaallocator.h" #include "gstvacaps.h" #include "gstvapool.h" -#include "gstvautils.h" #include "gstvavideoformat.h" #define GST_CAT_DEFAULT (base->debug_category) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c index f9cef373ff..925001365e 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c @@ -22,12 +22,13 @@ #include "config.h" #endif +#include + #include "gstvabasetransform.h" #include "gstvaallocator.h" #include "gstvacaps.h" #include "gstvapool.h" -#include "gstvautils.h" #define GST_CAT_DEFAULT gst_va_base_transform_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c b/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c index 04544476d5..c628eeb52d 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvadeinterlace.c @@ -54,6 +54,7 @@ #include #include +#include #include "gstvaallocator.h" #include "gstvabasetransform.h" @@ -61,7 +62,6 @@ #include "gstvadisplay_priv.h" #include "gstvafilter.h" #include "gstvapool.h" -#include "gstvautils.h" GST_DEBUG_CATEGORY_STATIC (gst_va_deinterlace_debug); #define GST_CAT_DEFAULT gst_va_deinterlace_debug diff --git a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c index be0453ef6b..503f653978 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvavpp.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvavpp.c @@ -68,6 +68,7 @@ #include "gstvavpp.h" #include +#include #include @@ -77,7 +78,6 @@ #include "gstvadisplay_priv.h" #include "gstvafilter.h" #include "gstvapool.h" -#include "gstvautils.h" GST_DEBUG_CATEGORY_STATIC (gst_va_vpp_debug); #define GST_CAT_DEFAULT gst_va_vpp_debug diff --git a/subprojects/gst-plugins-bad/sys/va/meson.build b/subprojects/gst-plugins-bad/sys/va/meson.build index c830de327f..3f6baa02cc 100644 --- a/subprojects/gst-plugins-bad/sys/va/meson.build +++ b/subprojects/gst-plugins-bad/sys/va/meson.build @@ -14,7 +14,6 @@ va_sources = [ 'gstvapool.c', 'gstvaprofile.c', 'gstvasurfacecopy.c', - 'gstvautils.c', 'gstvavideoformat.c', 'gstvavp8dec.c', 'gstvavp9dec.c',