Blame gst/gstbufferpool.h

Packit Service 963350
/* GStreamer
Packit Service 963350
 * Copyright (C) 2010 Wim Taymans <wim.taymans@gmail.com>
Packit Service 963350
 *
Packit Service 963350
 * gstbufferpool.h: Header for GstBufferPool object
Packit Service 963350
 *
Packit Service 963350
 * This library is free software; you can redistribute it and/or
Packit Service 963350
 * modify it under the terms of the GNU Library General Public
Packit Service 963350
 * License as published by the Free Software Foundation; either
Packit Service 963350
 * version 2 of the License, or (at your option) any later version.
Packit Service 963350
 *
Packit Service 963350
 * This library is distributed in the hope that it will be useful,
Packit Service 963350
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 963350
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 963350
 * Library General Public License for more details.
Packit Service 963350
 *
Packit Service 963350
 * You should have received a copy of the GNU Library General Public
Packit Service 963350
 * License along with this library; if not, write to the
Packit Service 963350
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit Service 963350
 * Boston, MA 02110-1301, USA.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
Packit Service 963350
#ifndef __GST_BUFFER_POOL_H__
Packit Service 963350
#define __GST_BUFFER_POOL_H__
Packit Service 963350
Packit Service 963350
#include <gst/gstminiobject.h>
Packit Service 963350
#include <gst/gstpad.h>
Packit Service 963350
#include <gst/gstbuffer.h>
Packit Service 963350
Packit Service 963350
G_BEGIN_DECLS
Packit Service 963350
Packit Service 963350
typedef struct _GstBufferPoolPrivate GstBufferPoolPrivate;
Packit Service 963350
typedef struct _GstBufferPoolClass GstBufferPoolClass;
Packit Service 963350
Packit Service 963350
#define GST_TYPE_BUFFER_POOL                 (gst_buffer_pool_get_type())
Packit Service 963350
#define GST_IS_BUFFER_POOL(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_POOL))
Packit Service 963350
#define GST_IS_BUFFER_POOL_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_POOL))
Packit Service 963350
#define GST_BUFFER_POOL_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_POOL, GstBufferPoolClass))
Packit Service 963350
#define GST_BUFFER_POOL(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_POOL, GstBufferPool))
Packit Service 963350
#define GST_BUFFER_POOL_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_POOL, GstBufferPoolClass))
Packit Service 963350
#define GST_BUFFER_POOL_CAST(obj)            ((GstBufferPool *)(obj))
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBufferPoolAcquireFlags:
Packit Service 963350
 * @GST_BUFFER_POOL_ACQUIRE_FLAG_NONE: no flags
Packit Service 963350
 * @GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT: buffer is keyframe
Packit Service 963350
 * @GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT: when the bufferpool is empty, acquire_buffer
Packit Service 963350
 * will by default block until a buffer is released into the pool again. Setting
Packit Service 963350
 * this flag makes acquire_buffer return #GST_FLOW_EOS instead of blocking.
Packit Service 963350
 * @GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT: buffer is discont
Packit Service 963350
 * @GST_BUFFER_POOL_ACQUIRE_FLAG_LAST: last flag, subclasses can use private flags
Packit Service 963350
 *    starting from this value.
Packit Service 963350
 *
Packit Service 963350
 * Additional flags to control the allocation of a buffer
Packit Service 963350
 */
Packit Service 963350
typedef enum {
Packit Service 963350
  GST_BUFFER_POOL_ACQUIRE_FLAG_NONE     = 0,
Packit Service 963350
  GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT = (1 << 0),
Packit Service 963350
  GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT = (1 << 1),
Packit Service 963350
  GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT  = (1 << 2),
Packit Service 963350
  GST_BUFFER_POOL_ACQUIRE_FLAG_LAST     = (1 << 16),
Packit Service 963350
} GstBufferPoolAcquireFlags;
Packit Service 963350
Packit Service 963350
typedef struct _GstBufferPoolAcquireParams GstBufferPoolAcquireParams;
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBufferPoolAcquireParams:
Packit Service 963350
 * @format: the format of @start and @stop
Packit Service 963350
 * @start: the start position
Packit Service 963350
 * @stop: the stop position
Packit Service 963350
 * @flags: additional flags
Packit Service 963350
 *
Packit Service 963350
 * Parameters passed to the gst_buffer_pool_acquire_buffer() function to control the
Packit Service 963350
 * allocation of the buffer.
Packit Service 963350
 *
Packit Service 963350
 * The default implementation ignores the @start and @stop members but other
Packit Service 963350
 * implementations can use this extra information to decide what buffer to
Packit Service 963350
 * return.
Packit Service 963350
 */
Packit Service 963350
struct _GstBufferPoolAcquireParams {
Packit Service 963350
  GstFormat                 format;
Packit Service 963350
  gint64                    start;
Packit Service 963350
  gint64                    stop;
Packit Service 963350
  GstBufferPoolAcquireFlags flags;
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING];
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GST_BUFFER_POOL_IS_FLUSHING:
Packit Service 963350
 * @pool: a GstBufferPool
Packit Service 963350
 *
Packit Service 963350
 * Check if the bufferpool is flushing. Subclasses might want to check the
Packit Service 963350
 * state of the pool in the acquire function.
Packit Service 963350
 */
Packit Service 963350
#define GST_BUFFER_POOL_IS_FLUSHING(pool)  (g_atomic_int_get (&pool->flushing))
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBufferPool:
Packit Service 963350
 *
Packit Service 963350
 * The structure of a #GstBufferPool. Use the associated macros to access the public
Packit Service 963350
 * variables.
Packit Service 963350
 */
Packit Service 963350
struct _GstBufferPool {
Packit Service 963350
  GstObject            object;
Packit Service 963350
Packit Service 963350
  /*< protected >*/
Packit Service 963350
  gint                 flushing;
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  GstBufferPoolPrivate *priv;
Packit Service 963350
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING];
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBufferPoolClass:
Packit Service 963350
 * @object_class:  Object parent class
Packit Service 963350
 * @get_options: get a list of options supported by this pool
Packit Service 963350
 * @set_config: apply the bufferpool configuration. The default configuration
Packit Service 963350
 *              will parse the default config parameters
Packit Service 963350
 * @start: start the bufferpool. The default implementation will preallocate
Packit Service 963350
 *         min-buffers buffers and put them in the queue
Packit Service 963350
 * @stop: stop the bufferpool. the default implementation will free the
Packit Service 963350
 *        preallocated buffers. This function is called when all the buffers are
Packit Service 963350
 *        returned to the pool.
Packit Service 963350
 * @acquire_buffer: get a new buffer from the pool. The default implementation
Packit Service 963350
 *        will take a buffer from the queue and optionally wait for a buffer to
Packit Service 963350
 *        be released when there are no buffers available.
Packit Service 963350
 * @alloc_buffer: allocate a buffer. the default implementation allocates
Packit Service 963350
 *        buffers from the configured memory allocator and with the configured
Packit Service 963350
 *        parameters. All metadata that is present on the allocated buffer will
Packit Service 963350
 *        be marked as #GST_META_FLAG_POOLED and #GST_META_FLAG_LOCKED and will
Packit Service 963350
 *        not be removed from the buffer in @reset_buffer. The buffer should
Packit Service 963350
 *        have the GST_BUFFER_FLAG_TAG_MEMORY cleared.
Packit Service 963350
 * @reset_buffer: reset the buffer to its state when it was freshly allocated.
Packit Service 963350
 *        The default implementation will clear the flags, timestamps and
Packit Service 963350
 *        will remove the metadata without the #GST_META_FLAG_POOLED flag (even
Packit Service 963350
 *        the metadata with #GST_META_FLAG_LOCKED). If the
Packit Service 963350
 *        #GST_BUFFER_FLAG_TAG_MEMORY was set, this function can also try to
Packit Service 963350
 *        restore the memory and clear the #GST_BUFFER_FLAG_TAG_MEMORY again.
Packit Service 963350
 * @release_buffer: release a buffer back in the pool. The default
Packit Service 963350
 *        implementation will put the buffer back in the queue and notify any
Packit Service 963350
 *        blocking acquire_buffer calls when the #GST_BUFFER_FLAG_TAG_MEMORY
Packit Service 963350
 *        is not set on the buffer. If #GST_BUFFER_FLAG_TAG_MEMORY is set, the
Packit Service 963350
 *        buffer will be freed with @free_buffer.
Packit Service 963350
 * @free_buffer: free a buffer. The default implementation unrefs the buffer.
Packit Service 963350
 * @flush_start: enter the flushing state. (Since 1.4)
Packit Service 963350
 * @flush_stop: leave the flushign state. (Since 1.4)
Packit Service 963350
 *
Packit Service 963350
 * The GstBufferPool class.
Packit Service 963350
 */
Packit Service 963350
struct _GstBufferPoolClass {
Packit Service 963350
  GstObjectClass    object_class;
Packit Service 963350
Packit Service 963350
  /*< public >*/
Packit Service 963350
  const gchar ** (*get_options)    (GstBufferPool *pool);
Packit Service 963350
  gboolean       (*set_config)     (GstBufferPool *pool, GstStructure *config);
Packit Service 963350
Packit Service 963350
  gboolean       (*start)          (GstBufferPool *pool);
Packit Service 963350
  gboolean       (*stop)           (GstBufferPool *pool);
Packit Service 963350
Packit Service 963350
  GstFlowReturn  (*acquire_buffer) (GstBufferPool *pool, GstBuffer **buffer,
Packit Service 963350
                                    GstBufferPoolAcquireParams *params);
Packit Service 963350
  GstFlowReturn  (*alloc_buffer)   (GstBufferPool *pool, GstBuffer **buffer,
Packit Service 963350
                                    GstBufferPoolAcquireParams *params);
Packit Service 963350
  void           (*reset_buffer)   (GstBufferPool *pool, GstBuffer *buffer);
Packit Service 963350
  void           (*release_buffer) (GstBufferPool *pool, GstBuffer *buffer);
Packit Service 963350
  void           (*free_buffer)    (GstBufferPool *pool, GstBuffer *buffer);
Packit Service 963350
  void           (*flush_start)    (GstBufferPool *pool);
Packit Service 963350
  void           (*flush_stop)     (GstBufferPool *pool);
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING - 2];
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GType       gst_buffer_pool_get_type (void);
Packit Service 963350
Packit Service 963350
/* allocation */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstBufferPool *  gst_buffer_pool_new  (void);
Packit Service 963350
Packit Service 963350
/* state management */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_set_active      (GstBufferPool *pool, gboolean active);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_is_active       (GstBufferPool *pool);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_set_config      (GstBufferPool *pool, GstStructure *config);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstStructure *   gst_buffer_pool_get_config      (GstBufferPool *pool);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
const gchar **   gst_buffer_pool_get_options     (GstBufferPool *pool);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_has_option      (GstBufferPool *pool, const gchar *option);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void             gst_buffer_pool_set_flushing    (GstBufferPool *pool, gboolean flushing);
Packit Service 963350
Packit Service 963350
/* helpers for configuring the config structure */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void             gst_buffer_pool_config_set_params    (GstStructure *config, GstCaps *caps,
Packit Service 963350
                                                       guint size, guint min_buffers, guint max_buffers);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_config_get_params    (GstStructure *config, GstCaps **caps,
Packit Service 963350
                                                       guint *size, guint *min_buffers, guint *max_buffers);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void             gst_buffer_pool_config_set_allocator (GstStructure *config, GstAllocator *allocator,
Packit Service 963350
                                                       const GstAllocationParams *params);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_config_get_allocator (GstStructure *config, GstAllocator **allocator,
Packit Service 963350
                                                       GstAllocationParams *params);
Packit Service 963350
Packit Service 963350
/* options */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
guint            gst_buffer_pool_config_n_options   (GstStructure *config);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void             gst_buffer_pool_config_add_option  (GstStructure *config, const gchar *option);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
const gchar *    gst_buffer_pool_config_get_option  (GstStructure *config, guint index);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_config_has_option  (GstStructure *config, const gchar *option);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean         gst_buffer_pool_config_validate_params (GstStructure *config, GstCaps *caps,
Packit Service 963350
                                                         guint size, guint min_buffers, guint max_buffers);
Packit Service 963350
Packit Service 963350
/* buffer management */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstFlowReturn    gst_buffer_pool_acquire_buffer  (GstBufferPool *pool, GstBuffer **buffer,
Packit Service 963350
                                                  GstBufferPoolAcquireParams *params);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void             gst_buffer_pool_release_buffer  (GstBufferPool *pool, GstBuffer *buffer);
Packit Service 963350
Packit Service 963350
G_END_DECLS
Packit Service 963350
Packit Service 963350
#endif /* __GST_BUFFER_POOL_H__ */