mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
ximagesink: get rid of unnecessary private struct for pool
This is not exposed as API after all.
This commit is contained in:
parent
324ebd19e3
commit
fb8f53efb7
2 changed files with 38 additions and 54 deletions
|
@ -35,17 +35,6 @@
|
||||||
GST_DEBUG_CATEGORY_EXTERN (gst_debug_ximagepool);
|
GST_DEBUG_CATEGORY_EXTERN (gst_debug_ximagepool);
|
||||||
#define GST_CAT_DEFAULT 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 */
|
/* X11 stuff */
|
||||||
static gboolean error_caught = FALSE;
|
static gboolean error_caught = FALSE;
|
||||||
|
|
||||||
|
@ -225,15 +214,13 @@ ximage_memory_alloc (GstXImageBufferPool * xpool)
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
GstXContext *xcontext;
|
GstXContext *xcontext;
|
||||||
gint width, height, align = 15, offset;
|
gint width, height, align = 15, offset;
|
||||||
GstXImageBufferPoolPrivate *priv;
|
|
||||||
GstXImageMemory *mem;
|
GstXImageMemory *mem;
|
||||||
|
|
||||||
priv = xpool->priv;
|
|
||||||
ximagesink = xpool->sink;
|
ximagesink = xpool->sink;
|
||||||
xcontext = ximagesink->xcontext;
|
xcontext = ximagesink->xcontext;
|
||||||
|
|
||||||
width = priv->padded_width;
|
width = xpool->padded_width;
|
||||||
height = priv->padded_height;
|
height = xpool->padded_height;
|
||||||
|
|
||||||
mem = g_slice_new (GstXImageMemory);
|
mem = g_slice_new (GstXImageMemory);
|
||||||
|
|
||||||
|
@ -241,10 +228,10 @@ ximage_memory_alloc (GstXImageBufferPool * xpool)
|
||||||
mem->SHMInfo.shmaddr = ((void *) -1);
|
mem->SHMInfo.shmaddr = ((void *) -1);
|
||||||
mem->SHMInfo.shmid = -1;
|
mem->SHMInfo.shmid = -1;
|
||||||
#endif
|
#endif
|
||||||
mem->x = priv->align.padding_left;
|
mem->x = xpool->align.padding_left;
|
||||||
mem->y = priv->align.padding_top;
|
mem->y = xpool->align.padding_top;
|
||||||
mem->width = GST_VIDEO_INFO_WIDTH (&priv->info);
|
mem->width = GST_VIDEO_INFO_WIDTH (&xpool->info);
|
||||||
mem->height = GST_VIDEO_INFO_HEIGHT (&priv->info);
|
mem->height = GST_VIDEO_INFO_HEIGHT (&xpool->info);
|
||||||
mem->sink = gst_object_ref (ximagesink);
|
mem->sink = gst_object_ref (ximagesink);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ximagesink, "creating image %p (%dx%d)", mem,
|
GST_DEBUG_OBJECT (ximagesink, "creating image %p (%dx%d)", mem,
|
||||||
|
@ -535,9 +522,6 @@ beach:
|
||||||
/* bufferpool */
|
/* bufferpool */
|
||||||
static void gst_ximage_buffer_pool_finalize (GObject * object);
|
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
|
#define gst_ximage_buffer_pool_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstXImageBufferPool, gst_ximage_buffer_pool,
|
G_DEFINE_TYPE (GstXImageBufferPool, gst_ximage_buffer_pool,
|
||||||
GST_TYPE_BUFFER_POOL);
|
GST_TYPE_BUFFER_POOL);
|
||||||
|
@ -556,7 +540,6 @@ static gboolean
|
||||||
ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
{
|
{
|
||||||
GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
|
GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
|
||||||
GstXImageBufferPoolPrivate *priv = xpool->priv;
|
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
|
@ -574,44 +557,44 @@ ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
caps);
|
caps);
|
||||||
|
|
||||||
/* keep track of the width and height and caps */
|
/* keep track of the width and height and caps */
|
||||||
if (priv->caps)
|
if (xpool->caps)
|
||||||
gst_caps_unref (priv->caps);
|
gst_caps_unref (xpool->caps);
|
||||||
priv->caps = gst_caps_ref (caps);
|
xpool->caps = gst_caps_ref (caps);
|
||||||
|
|
||||||
/* check for the configured metadata */
|
/* check for the configured metadata */
|
||||||
priv->add_metavideo =
|
xpool->add_metavideo =
|
||||||
gst_buffer_pool_config_has_option (config,
|
gst_buffer_pool_config_has_option (config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||||
|
|
||||||
/* parse extra alignment info */
|
/* 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);
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||||
|
|
||||||
if (priv->need_alignment) {
|
if (xpool->need_alignment) {
|
||||||
gst_buffer_pool_config_get_video_alignment (config, &priv->align);
|
gst_buffer_pool_config_get_video_alignment (config, &xpool->align);
|
||||||
|
|
||||||
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", priv->align.padding_top,
|
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", xpool->align.padding_top,
|
||||||
priv->align.padding_left, priv->align.padding_left,
|
xpool->align.padding_left, xpool->align.padding_left,
|
||||||
priv->align.padding_bottom);
|
xpool->align.padding_bottom);
|
||||||
|
|
||||||
/* do padding and alignment */
|
/* 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 */
|
/* we need the video metadata too now */
|
||||||
priv->add_metavideo = TRUE;
|
xpool->add_metavideo = TRUE;
|
||||||
} else {
|
} else {
|
||||||
gst_video_alignment_reset (&priv->align);
|
gst_video_alignment_reset (&xpool->align);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the padding */
|
/* add the padding */
|
||||||
priv->padded_width =
|
xpool->padded_width =
|
||||||
GST_VIDEO_INFO_WIDTH (&info) + priv->align.padding_left +
|
GST_VIDEO_INFO_WIDTH (&info) + xpool->align.padding_left +
|
||||||
priv->align.padding_right;
|
xpool->align.padding_right;
|
||||||
priv->padded_height =
|
xpool->padded_height =
|
||||||
GST_VIDEO_INFO_HEIGHT (&info) + priv->align.padding_top +
|
GST_VIDEO_INFO_HEIGHT (&info) + xpool->align.padding_top +
|
||||||
priv->align.padding_bottom;
|
xpool->align.padding_bottom;
|
||||||
|
|
||||||
priv->info = info;
|
xpool->info = info;
|
||||||
|
|
||||||
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config);
|
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)
|
GstBufferPoolAcquireParams * params)
|
||||||
{
|
{
|
||||||
GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
|
GstXImageBufferPool *xpool = GST_XIMAGE_BUFFER_POOL_CAST (pool);
|
||||||
GstXImageBufferPoolPrivate *priv = xpool->priv;
|
|
||||||
GstVideoInfo *info;
|
GstVideoInfo *info;
|
||||||
GstBuffer *ximage;
|
GstBuffer *ximage;
|
||||||
GstMemory *mem;
|
GstMemory *mem;
|
||||||
|
|
||||||
info = &priv->info;
|
info = &xpool->info;
|
||||||
|
|
||||||
ximage = gst_buffer_new ();
|
ximage = gst_buffer_new ();
|
||||||
mem = ximage_memory_alloc (xpool);
|
mem = ximage_memory_alloc (xpool);
|
||||||
|
@ -655,7 +637,7 @@ ximage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
}
|
}
|
||||||
gst_buffer_append_memory (ximage, mem);
|
gst_buffer_append_memory (ximage, mem);
|
||||||
|
|
||||||
if (priv->add_metavideo) {
|
if (xpool->add_metavideo) {
|
||||||
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
|
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
|
||||||
/* these are just the defaults for now */
|
/* these are just the defaults for now */
|
||||||
gst_buffer_add_video_meta_full (ximage, GST_VIDEO_FRAME_FLAG_NONE,
|
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;
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||||
GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
|
GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GstXImageBufferPoolPrivate));
|
|
||||||
|
|
||||||
gobject_class->finalize = gst_ximage_buffer_pool_finalize;
|
gobject_class->finalize = gst_ximage_buffer_pool_finalize;
|
||||||
|
|
||||||
gstbufferpool_class->get_options = ximage_buffer_pool_get_options;
|
gstbufferpool_class->get_options = ximage_buffer_pool_get_options;
|
||||||
|
@ -709,19 +689,18 @@ gst_ximage_buffer_pool_class_init (GstXImageBufferPoolClass * klass)
|
||||||
static void
|
static void
|
||||||
gst_ximage_buffer_pool_init (GstXImageBufferPool * pool)
|
gst_ximage_buffer_pool_init (GstXImageBufferPool * pool)
|
||||||
{
|
{
|
||||||
pool->priv = GST_XIMAGE_BUFFER_POOL_GET_PRIVATE (pool);
|
/* nothing to do here */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_ximage_buffer_pool_finalize (GObject * object)
|
gst_ximage_buffer_pool_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstXImageBufferPool *pool = GST_XIMAGE_BUFFER_POOL_CAST (object);
|
GstXImageBufferPool *pool = GST_XIMAGE_BUFFER_POOL_CAST (object);
|
||||||
GstXImageBufferPoolPrivate *priv = pool->priv;
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (pool, "finalize XImage buffer pool %p", pool);
|
GST_LOG_OBJECT (pool, "finalize XImage buffer pool %p", pool);
|
||||||
|
|
||||||
if (priv->caps)
|
if (pool->caps)
|
||||||
gst_caps_unref (priv->caps);
|
gst_caps_unref (pool->caps);
|
||||||
gst_object_unref (pool->sink);
|
gst_object_unref (pool->sink);
|
||||||
gst_object_unref (pool->allocator);
|
gst_object_unref (pool->allocator);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ typedef struct _GstXImageMemory GstXImageMemory;
|
||||||
|
|
||||||
typedef struct _GstXImageBufferPool GstXImageBufferPool;
|
typedef struct _GstXImageBufferPool GstXImageBufferPool;
|
||||||
typedef struct _GstXImageBufferPoolClass GstXImageBufferPoolClass;
|
typedef struct _GstXImageBufferPoolClass GstXImageBufferPoolClass;
|
||||||
typedef struct _GstXImageBufferPoolPrivate GstXImageBufferPoolPrivate;
|
|
||||||
|
|
||||||
#include "ximagesink.h"
|
#include "ximagesink.h"
|
||||||
|
|
||||||
|
@ -88,7 +87,13 @@ struct _GstXImageBufferPool
|
||||||
GstXImageSink *sink;
|
GstXImageSink *sink;
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
|
|
||||||
GstXImageBufferPoolPrivate *priv;
|
GstCaps *caps;
|
||||||
|
GstVideoInfo info;
|
||||||
|
GstVideoAlignment align;
|
||||||
|
guint padded_width;
|
||||||
|
guint padded_height;
|
||||||
|
gboolean add_metavideo;
|
||||||
|
gboolean need_alignment;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstXImageBufferPoolClass
|
struct _GstXImageBufferPoolClass
|
||||||
|
|
Loading…
Reference in a new issue