diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-03-04 18:32:53 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-03-04 18:32:53 +0100 |
commit | 92f9995d98cdada8dda1a0bad39262bc1d43daaa (patch) | |
tree | 36f7109a0f93e05f98fecab91a673e7d50c90687 | |
parent | 8a786d10be06c4a5cee957bd9eb4bb07b3b304f9 (diff) |
ximagesink: make metadata methods more like core
-rw-r--r-- | sys/ximage/ximagepool.c | 41 | ||||
-rw-r--r-- | sys/ximage/ximagepool.h | 8 | ||||
-rw-r--r-- | sys/ximage/ximagesink.c | 4 |
3 files changed, 33 insertions, 20 deletions
diff --git a/sys/ximage/ximagepool.c b/sys/ximage/ximagepool.c index ca359db5a..3e7f7773b 100644 --- a/sys/ximage/ximagepool.c +++ b/sys/ximage/ximagepool.c @@ -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, diff --git a/sys/ximage/ximagepool.h b/sys/ximage/ximagepool.h index 691ffb840..273ed6663 100644 --- a/sys/ximage/ximagepool.h +++ b/sys/ximage/ximagepool.h @@ -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: diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index 1bf95f221..6e510cbe4 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -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 |