mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 05:16:05 +00:00
ximagesink: experiment with convenience macros
This commit is contained in:
parent
a1a237d0ea
commit
ce7498e7c3
2 changed files with 16 additions and 10 deletions
|
@ -190,7 +190,7 @@ gst_ximage_buffer_dispose (GstBuffer * ximage)
|
||||||
gboolean recycled = FALSE;
|
gboolean recycled = FALSE;
|
||||||
gboolean running;
|
gboolean running;
|
||||||
|
|
||||||
meta = GST_META_XIMAGE_GET (ximage, FALSE);
|
meta = GST_META_XIMAGE_FIND (ximage);
|
||||||
g_return_if_fail (meta != NULL);
|
g_return_if_fail (meta != NULL);
|
||||||
|
|
||||||
ximagesink = meta->ximagesink;
|
ximagesink = meta->ximagesink;
|
||||||
|
@ -238,7 +238,7 @@ no_sink:
|
||||||
static void
|
static void
|
||||||
gst_ximage_buffer_free (GstBuffer * ximage)
|
gst_ximage_buffer_free (GstBuffer * ximage)
|
||||||
{
|
{
|
||||||
GstMetaXImage *meta = GST_META_XIMAGE_GET (ximage, FALSE);
|
GstMetaXImage *meta = GST_META_XIMAGE_FIND (ximage);
|
||||||
g_return_if_fail (meta != NULL);
|
g_return_if_fail (meta != NULL);
|
||||||
|
|
||||||
/* make sure it is not recycled */
|
/* make sure it is not recycled */
|
||||||
|
@ -375,7 +375,7 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps)
|
||||||
buffer = gst_buffer_new ();
|
buffer = gst_buffer_new ();
|
||||||
GST_MINI_OBJECT_CAST (buffer)->dispose =
|
GST_MINI_OBJECT_CAST (buffer)->dispose =
|
||||||
(GstMiniObjectDisposeFunction) gst_ximage_buffer_dispose;
|
(GstMiniObjectDisposeFunction) gst_ximage_buffer_dispose;
|
||||||
meta = GST_META_XIMAGE_GET (buffer, TRUE);
|
meta = GST_META_XIMAGE_ADD (buffer);
|
||||||
#ifdef HAVE_XSHM
|
#ifdef HAVE_XSHM
|
||||||
meta->SHMInfo.shmaddr = ((void *) -1);
|
meta->SHMInfo.shmaddr = ((void *) -1);
|
||||||
meta->SHMInfo.shmid = -1;
|
meta->SHMInfo.shmid = -1;
|
||||||
|
@ -546,7 +546,7 @@ gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink, GstBuffer * ximage)
|
||||||
g_return_if_fail (ximage != NULL);
|
g_return_if_fail (ximage != NULL);
|
||||||
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
|
g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
|
||||||
|
|
||||||
meta = GST_META_XIMAGE_GET (ximage, FALSE);
|
meta = GST_META_XIMAGE_FIND (ximage);
|
||||||
g_return_if_fail (meta != NULL);
|
g_return_if_fail (meta != NULL);
|
||||||
|
|
||||||
/* Hold the object lock to ensure the XContext doesn't disappear */
|
/* Hold the object lock to ensure the XContext doesn't disappear */
|
||||||
|
@ -686,7 +686,7 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstBuffer * ximage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
meta = GST_META_XIMAGE_GET (ximage, FALSE);
|
meta = GST_META_XIMAGE_FIND (ximage);
|
||||||
src.w = meta->width;
|
src.w = meta->width;
|
||||||
src.h = meta->height;
|
src.h = meta->height;
|
||||||
dst.w = ximagesink->xwindow->width;
|
dst.w = ximagesink->xwindow->width;
|
||||||
|
@ -1515,7 +1515,7 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
/* If our ximage has changed we destroy it, next chain iteration will create
|
/* If our ximage has changed we destroy it, next chain iteration will create
|
||||||
a new one */
|
a new one */
|
||||||
if ((ximagesink->ximage)) {
|
if ((ximagesink->ximage)) {
|
||||||
GstMetaXImage *meta = GST_META_XIMAGE_GET (ximagesink->ximage, FALSE);
|
GstMetaXImage *meta = GST_META_XIMAGE_FIND (ximagesink->ximage);
|
||||||
|
|
||||||
if (((GST_VIDEO_SINK_WIDTH (ximagesink) != meta->width) ||
|
if (((GST_VIDEO_SINK_WIDTH (ximagesink) != meta->width) ||
|
||||||
(GST_VIDEO_SINK_HEIGHT (ximagesink) != meta->height))) {
|
(GST_VIDEO_SINK_HEIGHT (ximagesink) != meta->height))) {
|
||||||
|
@ -1645,7 +1645,7 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
if (!ximagesink->xcontext)
|
if (!ximagesink->xcontext)
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
|
|
||||||
meta = GST_META_XIMAGE_GET (buf, FALSE);
|
meta = GST_META_XIMAGE_FIND (buf);
|
||||||
|
|
||||||
if (meta) {
|
if (meta) {
|
||||||
/* If this buffer has been allocated using our buffer management we simply
|
/* If this buffer has been allocated using our buffer management we simply
|
||||||
|
@ -1666,7 +1666,7 @@ gst_ximagesink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
|
||||||
goto no_ximage;
|
goto no_ximage;
|
||||||
|
|
||||||
if (GST_BUFFER_SIZE (ximagesink->ximage) < GST_BUFFER_SIZE (buf)) {
|
if (GST_BUFFER_SIZE (ximagesink->ximage) < GST_BUFFER_SIZE (buf)) {
|
||||||
meta = GST_META_XIMAGE_GET (ximagesink->ximage, FALSE);
|
meta = GST_META_XIMAGE_FIND (ximagesink->ximage);
|
||||||
|
|
||||||
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE,
|
||||||
("Failed to create output image buffer of %dx%d pixels",
|
("Failed to create output image buffer of %dx%d pixels",
|
||||||
|
@ -1883,7 +1883,7 @@ alloc:
|
||||||
ximage = ximagesink->buffer_pool->data;
|
ximage = ximagesink->buffer_pool->data;
|
||||||
|
|
||||||
if (ximage) {
|
if (ximage) {
|
||||||
meta = GST_META_XIMAGE_GET (ximage, FALSE);
|
meta = GST_META_XIMAGE_FIND (ximage);
|
||||||
|
|
||||||
/* Removing from the pool */
|
/* Removing from the pool */
|
||||||
ximagesink->buffer_pool = g_slist_delete_link (ximagesink->buffer_pool,
|
ximagesink->buffer_pool = g_slist_delete_link (ximagesink->buffer_pool,
|
||||||
|
|
|
@ -157,8 +157,14 @@ struct _GstMetaXImage
|
||||||
};
|
};
|
||||||
|
|
||||||
const GstMetaInfo * gst_meta_ximage_get_info (void);
|
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,c) ((t *)gst_buffer_get_meta((b),(i),(c)))
|
||||||
|
#define GST_META_XIMAGE_GET(b,c) GST_META_GET(b,GstMetaXImage,GST_META_INFO_XIMAGE,c)
|
||||||
|
|
||||||
|
#define GST_META_XIMAGE_ADD(buf) GST_META_XIMAGE_GET(buf,TRUE)
|
||||||
|
#define GST_META_XIMAGE_FIND(buf) GST_META_XIMAGE_GET(buf,FALSE)
|
||||||
|
|
||||||
#define GST_META_XIMAGE_GET(buf,create) ((GstMetaXImage *)gst_buffer_get_meta(buf,gst_meta_ximage_get_info(),create))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstXImageSink:
|
* GstXImageSink:
|
||||||
|
|
Loading…
Reference in a new issue