mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
ximagesink: make metadata methods more like core
This commit is contained in:
parent
8a786d10be
commit
92f9995d98
3 changed files with 33 additions and 20 deletions
|
@ -64,10 +64,10 @@ gst_ximagesink_handle_xerror (Display * display, XErrorEvent * xevent)
|
|||
return 0;
|
||||
}
|
||||
|
||||
GstBuffer *
|
||||
gst_ximage_buffer_new (GstXImageSink * ximagesink, gint width, gint height)
|
||||
GstMetaXImage *
|
||||
gst_buffer_add_meta_ximage (GstBuffer * buffer, GstXImageSink * ximagesink,
|
||||
gint width, gint height)
|
||||
{
|
||||
GstBuffer *ximage;
|
||||
int (*handler) (Display *, XErrorEvent *);
|
||||
gboolean success = FALSE;
|
||||
GstXContext *xcontext;
|
||||
|
@ -75,8 +75,9 @@ gst_ximage_buffer_new (GstXImageSink * ximagesink, gint width, gint height)
|
|||
|
||||
xcontext = ximagesink->xcontext;
|
||||
|
||||
ximage = gst_buffer_new ();
|
||||
meta = GST_META_XIMAGE_ADD (ximage);
|
||||
meta =
|
||||
(GstMetaXImage *) gst_buffer_add_meta (buffer, GST_META_INFO_XIMAGE,
|
||||
NULL);
|
||||
#ifdef HAVE_XSHM
|
||||
meta->SHMInfo.shmaddr = ((void *) -1);
|
||||
meta->SHMInfo.shmid = -1;
|
||||
|
@ -85,7 +86,7 @@ gst_ximage_buffer_new (GstXImageSink * ximagesink, gint width, gint height)
|
|||
meta->height = height;
|
||||
meta->sink = gst_object_ref (ximagesink);
|
||||
|
||||
GST_DEBUG_OBJECT (ximagesink, "creating image %p (%dx%d)", ximage,
|
||||
GST_DEBUG_OBJECT (ximagesink, "creating image %p (%dx%d)", buffer,
|
||||
meta->width, meta->height);
|
||||
|
||||
g_mutex_lock (ximagesink->x_lock);
|
||||
|
@ -173,19 +174,18 @@ gst_ximage_buffer_new (GstXImageSink * ximagesink, gint width, gint height)
|
|||
error_caught = FALSE;
|
||||
XSetErrorHandler (handler);
|
||||
|
||||
GST_BUFFER_DATA (ximage) = (guchar *) meta->ximage->data;
|
||||
GST_BUFFER_SIZE (ximage) = meta->size;
|
||||
GST_BUFFER_DATA (buffer) = (guchar *) meta->ximage->data;
|
||||
GST_BUFFER_SIZE (buffer) = meta->size;
|
||||
|
||||
g_mutex_unlock (ximagesink->x_lock);
|
||||
|
||||
success = TRUE;
|
||||
|
||||
beach:
|
||||
if (!success) {
|
||||
gst_buffer_unref (GST_BUFFER_CAST (ximage));
|
||||
ximage = NULL;
|
||||
}
|
||||
return ximage;
|
||||
if (!success)
|
||||
meta = NULL;
|
||||
|
||||
return meta;
|
||||
|
||||
/* ERRORS */
|
||||
create_failed:
|
||||
|
@ -286,6 +286,21 @@ beach:
|
|||
GST_OBJECT_UNLOCK (ximagesink);
|
||||
}
|
||||
|
||||
GstBuffer *
|
||||
gst_ximage_buffer_new (GstXImageSink * ximagesink, gint width, gint height)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
GstMetaXImage *meta;
|
||||
|
||||
buffer = gst_buffer_new ();
|
||||
meta = gst_buffer_add_meta_ximage (buffer, ximagesink, width, height);
|
||||
if (meta == NULL) {
|
||||
gst_buffer_unref (buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#ifdef HAVE_XSHM /* Check that XShm calls actually work */
|
||||
gboolean
|
||||
gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
|
||||
|
|
|
@ -50,11 +50,9 @@ typedef struct _GstXImageBufferPoolPrivate GstXImageBufferPoolPrivate;
|
|||
const GstMetaInfo * gst_meta_ximage_get_info (void);
|
||||
#define GST_META_INFO_XIMAGE (gst_meta_ximage_get_info())
|
||||
|
||||
#define GST_META_GET(b,t,i) ((t *)gst_buffer_get_meta((b),(i)))
|
||||
#define GST_META_ADD(b,t,i,p) ((t *)gst_buffer_add_meta((b),(i),(p)))
|
||||
|
||||
#define GST_META_XIMAGE_GET(b) GST_META_GET(b,GstMetaXImage,GST_META_INFO_XIMAGE)
|
||||
#define GST_META_XIMAGE_ADD(b) GST_META_ADD(b,GstMetaXImage,GST_META_INFO_XIMAGE,NULL)
|
||||
#define gst_buffer_get_meta_ximage(b) ((GstMetaXImage*)gst_buffer_get_meta((b),GST_META_INFO_XIMAGE))
|
||||
GstMetaXImage * gst_buffer_add_meta_ximage (GstBuffer *buffer, GstXImageSink * ximagesink,
|
||||
gint width, gint height);
|
||||
|
||||
/**
|
||||
* GstMetaXImage:
|
||||
|
|
|
@ -246,7 +246,7 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstBuffer * ximage)
|
|||
}
|
||||
}
|
||||
|
||||
meta = GST_META_XIMAGE_GET (ximage);
|
||||
meta = gst_buffer_get_meta_ximage (ximage);
|
||||
src.w = meta->width;
|
||||
src.h = meta->height;
|
||||
dst.w = ximagesink->xwindow->width;
|
||||
|
@ -1210,7 +1210,7 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
|||
if (!ximagesink->xcontext)
|
||||
return GST_FLOW_ERROR;
|
||||
|
||||
meta = GST_META_XIMAGE_GET (buf);
|
||||
meta = gst_buffer_get_meta_ximage (buf);
|
||||
|
||||
if (meta) {
|
||||
/* If this buffer has been allocated using our buffer management we simply
|
||||
|
|
Loading…
Reference in a new issue