ximagesink: get rid of unnecessary private struct for pool

This is not exposed as API after all.
This commit is contained in:
Tim-Philipp Müller 2014-09-27 15:53:43 +01:00
parent 324ebd19e3
commit fb8f53efb7
2 changed files with 38 additions and 54 deletions

View file

@ -35,17 +35,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_debug_ximagepool);
#define GST_CAT_DEFAULT gst_debug_ximagepool
struct _GstXImageBufferPoolPrivate
{
GstCaps *caps;
GstVideoInfo info;
GstVideoAlignment align;
guint padded_width;
guint padded_height;
gboolean add_metavideo;
gboolean need_alignment;
};
/* X11 stuff */
static gboolean error_caught = FALSE;
@ -225,15 +214,13 @@ ximage_memory_alloc (GstXImageBufferPool * xpool)
gboolean success = FALSE;
GstXContext *xcontext;
gint width, height, align = 15, offset;
GstXImageBufferPoolPrivate *priv;
GstXImageMemory *mem;
priv = xpool->priv;
ximagesink = xpool->sink;
xcontext = ximagesink->xcontext;
width = priv->padded_width;
height = priv->padded_height;
width = xpool->padded_width;
height = xpool->padded_height;
mem = g_slice_new (GstXImageMemory);
@ -241,10 +228,10 @@ ximage_memory_alloc (GstXImageBufferPool * xpool)
mem->SHMInfo.shmaddr = ((void *) -1);
mem->SHMInfo.shmid = -1;
#endif
mem->x = priv->align.padding_left;
mem->y = priv->align.padding_top;
mem->width = GST_VIDEO_INFO_WIDTH (&priv->info);
mem->height = GST_VIDEO_INFO_HEIGHT (&priv->info);
mem->x = xpool->align.padding_left;
mem->y = xpool->align.padding_top;
mem->width = GST_VIDEO_INFO_WIDTH (&xpool->info);
mem->height = GST_VIDEO_INFO_HEIGHT (&xpool->info);
mem->sink = gst_object_ref (ximagesink);
GST_DEBUG_OBJECT (ximagesink, "creating image %p (%dx%d)", mem,
@ -535,9 +522,6 @@ beach:
/* bufferpool */
static void gst_ximage_buffer_pool_finalize (GObject * object);
#define GST_XIMAGE_BUFFER_POOL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_XIMAGE_BUFFER_POOL, GstXImageBufferPoolPrivate))
#define gst_ximage_buffer_pool_parent_class parent_class
G_DEFINE_TYPE (GstXImageBufferPool, gst_ximage_buffer_pool,
GST_TYPE_BUFFER_POOL);
@ -556,7 +540,6 @@ static gboolean
ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
{
GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
GstXImageBufferPoolPrivate *priv = xpool->priv;
GstVideoInfo info;
GstCaps *caps;
@ -574,44 +557,44 @@ ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
caps);
/* keep track of the width and height and caps */
if (priv->caps)
gst_caps_unref (priv->caps);
priv->caps = gst_caps_ref (caps);
if (xpool->caps)
gst_caps_unref (xpool->caps);
xpool->caps = gst_caps_ref (caps);
/* check for the configured metadata */
priv->add_metavideo =
xpool->add_metavideo =
gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
/* parse extra alignment info */
priv->need_alignment = gst_buffer_pool_config_has_option (config,
xpool->need_alignment = gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
if (priv->need_alignment) {
gst_buffer_pool_config_get_video_alignment (config, &priv->align);
if (xpool->need_alignment) {
gst_buffer_pool_config_get_video_alignment (config, &xpool->align);
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", priv->align.padding_top,
priv->align.padding_left, priv->align.padding_left,
priv->align.padding_bottom);
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", xpool->align.padding_top,
xpool->align.padding_left, xpool->align.padding_left,
xpool->align.padding_bottom);
/* do padding and alignment */
gst_video_info_align (&info, &priv->align);
gst_video_info_align (&info, &xpool->align);
/* we need the video metadata too now */
priv->add_metavideo = TRUE;
xpool->add_metavideo = TRUE;
} else {
gst_video_alignment_reset (&priv->align);
gst_video_alignment_reset (&xpool->align);
}
/* add the padding */
priv->padded_width =
GST_VIDEO_INFO_WIDTH (&info) + priv->align.padding_left +
priv->align.padding_right;
priv->padded_height =
GST_VIDEO_INFO_HEIGHT (&info) + priv->align.padding_top +
priv->align.padding_bottom;
xpool->padded_width =
GST_VIDEO_INFO_WIDTH (&info) + xpool->align.padding_left +
xpool->align.padding_right;
xpool->padded_height =
GST_VIDEO_INFO_HEIGHT (&info) + xpool->align.padding_top +
xpool->align.padding_bottom;
priv->info = info;
xpool->info = info;
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config);
@ -640,12 +623,11 @@ ximage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
GstBufferPoolAcquireParams * params)
{
GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
GstXImageBufferPoolPrivate *priv = xpool->priv;
GstVideoInfo *info;
GstBuffer *ximage;
GstMemory *mem;
info = &priv->info;
info = &xpool->info;
ximage = gst_buffer_new ();
mem = ximage_memory_alloc (xpool);
@ -655,7 +637,7 @@ ximage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
}
gst_buffer_append_memory (ximage, mem);
if (priv->add_metavideo) {
if (xpool->add_metavideo) {
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
/* these are just the defaults for now */
gst_buffer_add_video_meta_full (ximage, GST_VIDEO_FRAME_FLAG_NONE,
@ -697,8 +679,6 @@ gst_ximage_buffer_pool_class_init (GstXImageBufferPoolClass * klass)
GObjectClass *gobject_class = (GObjectClass *) klass;
GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
g_type_class_add_private (klass, sizeof (GstXImageBufferPoolPrivate));
gobject_class->finalize = gst_ximage_buffer_pool_finalize;
gstbufferpool_class->get_options = ximage_buffer_pool_get_options;
@ -709,19 +689,18 @@ gst_ximage_buffer_pool_class_init (GstXImageBufferPoolClass * klass)
static void
gst_ximage_buffer_pool_init (GstXImageBufferPool * pool)
{
pool->priv = GST_XIMAGE_BUFFER_POOL_GET_PRIVATE (pool);
/* nothing to do here */
}
static void
gst_ximage_buffer_pool_finalize (GObject * object)
{
GstXImageBufferPool *pool = GST_XIMAGE_BUFFER_POOL_CAST (object);
GstXImageBufferPoolPrivate *priv = pool->priv;
GST_LOG_OBJECT (pool, "finalize XImage buffer pool %p", pool);
if (priv->caps)
gst_caps_unref (priv->caps);
if (pool->caps)
gst_caps_unref (pool->caps);
gst_object_unref (pool->sink);
gst_object_unref (pool->allocator);

View file

@ -43,7 +43,6 @@ typedef struct _GstXImageMemory GstXImageMemory;
typedef struct _GstXImageBufferPool GstXImageBufferPool;
typedef struct _GstXImageBufferPoolClass GstXImageBufferPoolClass;
typedef struct _GstXImageBufferPoolPrivate GstXImageBufferPoolPrivate;
#include "ximagesink.h"
@ -88,7 +87,13 @@ struct _GstXImageBufferPool
GstXImageSink *sink;
GstAllocator *allocator;
GstXImageBufferPoolPrivate *priv;
GstCaps *caps;
GstVideoInfo info;
GstVideoAlignment align;
guint padded_width;
guint padded_height;
gboolean add_metavideo;
gboolean need_alignment;
};
struct _GstXImageBufferPoolClass