mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 09:41:07 +00:00
Added the bufferpool handler.
Original commit message from CVS: Added the bufferpool handler. This object is able to generate buffers and is passed between elements to exchange buffers. Elements can also use this pool to efficiently generate output buffers.
This commit is contained in:
parent
202ba2ae4a
commit
d9701bf8a7
2 changed files with 154 additions and 0 deletions
86
gst/gstbufferpool.c
Normal file
86
gst/gstbufferpool.c
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/* Gnome-Streamer
|
||||||
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/gstbufferpool.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_buffer_pool_new:
|
||||||
|
*
|
||||||
|
* Create a new buffer pool.
|
||||||
|
*
|
||||||
|
* Returns: new buffer pool
|
||||||
|
*/
|
||||||
|
GstBufferPool *gst_buffer_pool_new()
|
||||||
|
{
|
||||||
|
GstBufferPool *pool;
|
||||||
|
|
||||||
|
pool = g_malloc(sizeof(GstBufferPool));
|
||||||
|
DEBUG("BUF: allocating new buffer pool %p\n", pool);
|
||||||
|
|
||||||
|
pool->new_buffer = NULL;
|
||||||
|
pool->destroy_buffer = NULL;
|
||||||
|
return pool;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gst_buffer_pool_set_create_function(GstBufferPool *pool, GstBufferPoolCreateFunction create, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail(pool != NULL);
|
||||||
|
|
||||||
|
pool->new_buffer = create;
|
||||||
|
pool->new_user_data = user_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gst_buffer_pool_set_destroy_function(GstBufferPool *pool, GstBufferPoolDestroyFunction destroy, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail(pool != NULL);
|
||||||
|
|
||||||
|
pool->destroy_buffer = destroy;
|
||||||
|
pool->destroy_user_data = user_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gst_buffer_pool_destroy(GstBufferPool *pool)
|
||||||
|
{
|
||||||
|
g_return_if_fail(pool != NULL);
|
||||||
|
|
||||||
|
g_free(pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
GstBuffer *gst_buffer_pool_new_buffer(GstBufferPool *pool)
|
||||||
|
{
|
||||||
|
GstBuffer *buffer;
|
||||||
|
|
||||||
|
g_return_val_if_fail(pool != NULL, NULL);
|
||||||
|
|
||||||
|
buffer = pool->new_buffer(pool, pool->new_user_data);
|
||||||
|
buffer->pool = pool;
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gst_buffer_pool_destroy_buffer(GstBufferPool *pool, GstBuffer *buffer)
|
||||||
|
{
|
||||||
|
g_return_if_fail(pool != NULL);
|
||||||
|
g_return_if_fail(buffer != NULL);
|
||||||
|
|
||||||
|
pool->destroy_buffer(pool, buffer, pool->new_user_data);
|
||||||
|
}
|
68
gst/gstbufferpool.h
Normal file
68
gst/gstbufferpool.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/* Gnome-Streamer
|
||||||
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __GST_BUFFER_POOL_H__
|
||||||
|
#define __GST_BUFFER_POOL_H__
|
||||||
|
|
||||||
|
#include "gstbuffer.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#define GST_BUFFER_POOL(buf) \
|
||||||
|
((GstBufferPool *)(buf))
|
||||||
|
|
||||||
|
typedef struct _GstBufferPool GstBufferPool;
|
||||||
|
|
||||||
|
typedef GstBuffer *(*GstBufferPoolCreateFunction) (GstBufferPool *pool, gpointer user_data);
|
||||||
|
typedef void (*GstBufferPoolDestroyFunction) (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data);
|
||||||
|
|
||||||
|
struct _GstBufferPool {
|
||||||
|
/* will be called when a new buffer is to be created */
|
||||||
|
GstBufferPoolCreateFunction new_buffer;
|
||||||
|
/* user data to pass with the new_buffer function */
|
||||||
|
gpointer new_user_data;
|
||||||
|
|
||||||
|
gpointer destroy_user_data;
|
||||||
|
GstBufferPoolDestroyFunction destroy_buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* creating a new buffer pool from scratch */
|
||||||
|
GstBufferPool *gst_buffer_pool_new();
|
||||||
|
|
||||||
|
/* creating a buffer from the pool */
|
||||||
|
GstBuffer *gst_buffer_pool_new_buffer(GstBufferPool *pool);
|
||||||
|
void gst_buffer_pool_destroy_buffer(GstBufferPool *pool, GstBuffer *buffer);
|
||||||
|
|
||||||
|
/* setting create and destroy functions */
|
||||||
|
void gst_buffer_pool_set_create_function(GstBufferPool *pool, GstBufferPoolCreateFunction create, gpointer user_data);
|
||||||
|
void gst_buffer_pool_set_destroy_function(GstBufferPool *pool, GstBufferPoolDestroyFunction destroy, gpointer user_data);
|
||||||
|
|
||||||
|
/* destroying the buffer pool */
|
||||||
|
void gst_buffer_pool_destroy(GstBufferPool *pool);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GST_BUFFER_POOL_H__ */
|
Loading…
Reference in a new issue