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;
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;
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);
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:
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,
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:
}
}
- 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;
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