mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
Add gst_vaapi_display_lookup_downstream() helper.
This commit is contained in:
parent
af1fd4b910
commit
453164d0c5
3 changed files with 141 additions and 0 deletions
|
@ -37,6 +37,7 @@ libgstvaapi_source_c = \
|
|||
gstvaapisurfacepool.c \
|
||||
gstvaapisurfaceproxy.c \
|
||||
gstvaapiutils.c \
|
||||
gstvaapiutils_gst.c \
|
||||
gstvaapivalue.c \
|
||||
gstvaapivideobuffer.c \
|
||||
gstvaapivideopool.c \
|
||||
|
@ -75,6 +76,7 @@ libgstvaapi_source_priv_h = \
|
|||
gstvaapidisplay_priv.h \
|
||||
gstvaapiobject_priv.h \
|
||||
gstvaapiutils.h \
|
||||
gstvaapiutils_gst.h \
|
||||
gstvaapi_priv.h \
|
||||
$(libgst_vaapi_ffmpeg_source_priv_h) \
|
||||
$(NULL)
|
||||
|
|
108
gst-libs/gst/vaapi/gstvaapiutils_gst.c
Normal file
108
gst-libs/gst/vaapi/gstvaapiutils_gst.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* gstvaapiutils_gst.c - GST utilties
|
||||
*
|
||||
* gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gstvaapiutils_gst.h"
|
||||
#include "gstvaapivideosink.h"
|
||||
#include "gstvaapivideobuffer.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
static GstVaapiDisplay *
|
||||
lookup_through_vaapisink_iface(GstElement *element)
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiVideoSink *sink;
|
||||
|
||||
GST_DEBUG("looking for a downstream vaapisink");
|
||||
|
||||
/* Look for a downstream vaapisink */
|
||||
sink = gst_vaapi_video_sink_lookup(element);
|
||||
if (!sink)
|
||||
return NULL;
|
||||
|
||||
display = gst_vaapi_video_sink_get_display(sink);
|
||||
GST_DEBUG(" found display %p", display);
|
||||
return display;
|
||||
}
|
||||
|
||||
static GstVaapiDisplay *
|
||||
lookup_through_peer_buffer(GstElement *element)
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
GstPad *pad;
|
||||
GstBuffer *buffer;
|
||||
GstFlowReturn ret;
|
||||
|
||||
GST_DEBUG("looking for a GstVaapiVideoBuffer from peer");
|
||||
|
||||
/* Lookup for a GstVaapiVideoBuffer from peer */
|
||||
pad = gst_element_get_static_pad(element, "src");
|
||||
if (!pad)
|
||||
return NULL;
|
||||
|
||||
buffer = NULL;
|
||||
ret = gst_pad_alloc_buffer(pad, 0, 0, GST_PAD_CAPS(pad), &buffer);
|
||||
g_object_unref(pad);
|
||||
if (ret != GST_FLOW_OK || !buffer)
|
||||
return NULL;
|
||||
|
||||
display = GST_VAAPI_IS_VIDEO_BUFFER(buffer) ?
|
||||
gst_vaapi_video_buffer_get_display(GST_VAAPI_VIDEO_BUFFER(buffer)) :
|
||||
NULL;
|
||||
gst_buffer_unref(buffer);
|
||||
|
||||
GST_DEBUG(" found display %p", display);
|
||||
return display;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_display_lookup_downstream:
|
||||
* @element: a #GstElement
|
||||
*
|
||||
* Finds a suitable #GstVaapiDisplay downstream from @element.
|
||||
*
|
||||
* 1. Check whether a downstream element implements the
|
||||
* #GstVaapiVideoSinkInterface interface.
|
||||
*
|
||||
* 2. Check whether the @element peer implements a custom
|
||||
* buffer_alloc() function that allocates #GstVaapiVideoBuffer
|
||||
* buffers.
|
||||
*
|
||||
* Return value: a downstream allocated #GstVaapiDisplay object, or
|
||||
* %NULL if none was found
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_lookup_downstream(GstElement *element)
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
|
||||
display = lookup_through_vaapisink_iface(element);
|
||||
if (display)
|
||||
return display;
|
||||
|
||||
display = lookup_through_peer_buffer(element);
|
||||
if (display)
|
||||
return display;
|
||||
|
||||
return NULL;
|
||||
}
|
31
gst-libs/gst/vaapi/gstvaapiutils_gst.h
Normal file
31
gst-libs/gst/vaapi/gstvaapiutils_gst.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* gstvaapiutils_gst.h - GST utilties
|
||||
*
|
||||
* gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_UTILS_GST_H
|
||||
#define GST_VAAPI_UTILS_GST_H
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_display_lookup_downstream(GstElement *element);
|
||||
|
||||
#endif /* GST_VAAPI_UTILS_GST_H */
|
Loading…
Reference in a new issue