mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
Display frames.
This commit is contained in:
parent
f8c91368e9
commit
271d8334ba
2 changed files with 72 additions and 3 deletions
|
@ -20,8 +20,10 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <gst/vaapi/gstvaapivideobuffer.h>
|
||||||
#include <gst/vaapi/gstvaapisinkbase.h>
|
#include <gst/vaapi/gstvaapisinkbase.h>
|
||||||
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
#include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||||
|
#include <gst/vaapi/gstvaapiwindow_x11.h>
|
||||||
#include "gstvaapisink.h"
|
#include "gstvaapisink.h"
|
||||||
|
|
||||||
#define GST_PLUGIN_NAME "vaapisink"
|
#define GST_PLUGIN_NAME "vaapisink"
|
||||||
|
@ -98,6 +100,67 @@ gst_vaapisink_destroy(GstVaapiSink *sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
gst_vaapisink_ensure_display(GstVaapiSink *sink)
|
||||||
|
{
|
||||||
|
if (!sink->display)
|
||||||
|
sink->display = gst_vaapi_display_x11_new(sink->display_name);
|
||||||
|
return sink->display != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_vaapisink_start(GstBaseSink *base_sink)
|
||||||
|
{
|
||||||
|
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
|
||||||
|
|
||||||
|
if (!gst_vaapisink_ensure_display(sink))
|
||||||
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_vaapisink_stop(GstBaseSink *base_sink)
|
||||||
|
{
|
||||||
|
GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
|
||||||
|
|
||||||
|
if (sink->window) {
|
||||||
|
g_object_unref(sink->window);
|
||||||
|
sink->window = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sink->display) {
|
||||||
|
g_object_unref(sink->display);
|
||||||
|
sink->display = NULL;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_vaapisink_show_frame(GstVideoSink *video_sink, GstBuffer *buffer)
|
||||||
|
{
|
||||||
|
GstVaapiSink * const sink = GST_VAAPISINK(video_sink);
|
||||||
|
GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
|
||||||
|
GstVaapiSurface *surface;
|
||||||
|
guint width, height, flags;
|
||||||
|
|
||||||
|
surface = gst_vaapi_video_buffer_get_surface(vbuffer);
|
||||||
|
if (!surface)
|
||||||
|
return GST_FLOW_UNEXPECTED;
|
||||||
|
|
||||||
|
gst_vaapi_surface_get_size(surface, &width, &height);
|
||||||
|
if (!sink->window) {
|
||||||
|
sink->window = gst_vaapi_window_x11_new(sink->display, width, height);
|
||||||
|
if (!sink->window)
|
||||||
|
return GST_FLOW_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
flags = GST_VAAPI_PICTURE_STRUCTURE_FRAME;
|
||||||
|
if (!gst_vaapi_window_put_surface(sink->window, surface, flags))
|
||||||
|
return GST_FLOW_UNEXPECTED;
|
||||||
|
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapisink_finalize(GObject *object)
|
gst_vaapisink_finalize(GObject *object)
|
||||||
{
|
{
|
||||||
|
@ -165,7 +228,6 @@ static void gst_vaapisink_base_init(gpointer klass)
|
||||||
static void gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
static void gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
||||||
GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
|
|
||||||
GstBaseSinkClass * const basesink_class = GST_BASE_SINK_CLASS(klass);
|
GstBaseSinkClass * const basesink_class = GST_BASE_SINK_CLASS(klass);
|
||||||
GstVideoSinkClass * const videosink_class = GST_VIDEO_SINK_CLASS(klass);
|
GstVideoSinkClass * const videosink_class = GST_VIDEO_SINK_CLASS(klass);
|
||||||
|
|
||||||
|
@ -173,6 +235,11 @@ static void gst_vaapisink_class_init(GstVaapiSinkClass *klass)
|
||||||
object_class->set_property = gst_vaapisink_set_property;
|
object_class->set_property = gst_vaapisink_set_property;
|
||||||
object_class->get_property = gst_vaapisink_get_property;
|
object_class->get_property = gst_vaapisink_get_property;
|
||||||
|
|
||||||
|
basesink_class->start = gst_vaapisink_start;
|
||||||
|
basesink_class->stop = gst_vaapisink_stop;
|
||||||
|
|
||||||
|
videosink_class->show_frame = gst_vaapisink_show_frame;
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class,
|
(object_class,
|
||||||
PROP_DISPLAY,
|
PROP_DISPLAY,
|
||||||
|
@ -201,8 +268,8 @@ static void gst_vaapisink_init(GstVaapiSink *sink, GstVaapiSinkClass *klass)
|
||||||
GstVaapiDisplay *
|
GstVaapiDisplay *
|
||||||
gst_vaapisink_get_display(GstVaapiSink *sink)
|
gst_vaapisink_get_display(GstVaapiSink *sink)
|
||||||
{
|
{
|
||||||
if (!sink->display)
|
if (!gst_vaapisink_ensure_display(sink))
|
||||||
sink->display = gst_vaapi_display_x11_new(sink->display_name);
|
return NULL;
|
||||||
return sink->display;
|
return sink->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <gst/video/gstvideosink.h>
|
#include <gst/video/gstvideosink.h>
|
||||||
#include <gst/vaapi/gstvaapidisplay.h>
|
#include <gst/vaapi/gstvaapidisplay.h>
|
||||||
|
#include <gst/vaapi/gstvaapiwindow.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -60,6 +61,7 @@ struct _GstVaapiSink {
|
||||||
|
|
||||||
gchar *display_name;
|
gchar *display_name;
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
|
GstVaapiWindow *window;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVaapiSinkClass {
|
struct _GstVaapiSinkClass {
|
||||||
|
|
Loading…
Reference in a new issue