2011-03-18 17:35:42 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2009 Wim Taymans <wim.taymans@gmail.be>
|
|
|
|
*
|
|
|
|
* gstmemory.h: Header for memory blocks
|
|
|
|
*
|
|
|
|
* 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_MEMORY_H__
|
|
|
|
#define __GST_MEMORY_H__
|
|
|
|
|
2011-03-18 18:28:17 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2011-03-18 17:35:42 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
typedef struct _GstMemory GstMemory;
|
|
|
|
typedef struct _GstMemoryInfo GstMemoryInfo;
|
2011-03-18 18:28:17 +00:00
|
|
|
typedef struct _GstMemoryImpl GstMemoryImpl;
|
2011-03-18 17:35:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstMemory:
|
|
|
|
* @info: pointer to the #GstMemoryInfo
|
|
|
|
*
|
|
|
|
* Base structure for memory implementations. Custom memory will put this structure
|
|
|
|
* as the first member of their structure.
|
|
|
|
*/
|
|
|
|
struct _GstMemory {
|
2011-03-18 18:28:17 +00:00
|
|
|
const GstMemoryImpl *impl;
|
2011-03-18 17:35:42 +00:00
|
|
|
|
|
|
|
gint refcount;
|
|
|
|
};
|
|
|
|
|
2011-03-18 18:28:17 +00:00
|
|
|
typedef enum {
|
|
|
|
GST_MAP_READ,
|
|
|
|
GST_MAP_WRITE,
|
|
|
|
} GstMapFlags;
|
|
|
|
|
2011-03-18 17:35:42 +00:00
|
|
|
/**
|
|
|
|
* GST_MEMORY_TRACE_NAME:
|
|
|
|
*
|
|
|
|
* The name used for tracing memory allocations.
|
|
|
|
*/
|
|
|
|
#define GST_MEMORY_TRACE_NAME "GstMemory"
|
|
|
|
|
|
|
|
typedef gsize (*GstMemoryGetSizesFunction) (GstMemory *mem, gsize *maxsize);
|
|
|
|
|
|
|
|
typedef void (*GstMemorySetSizeFunction) (GstMemory *mem, gsize size);
|
2011-03-18 18:28:17 +00:00
|
|
|
typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize *size, gsize *maxsize,
|
2011-03-18 17:35:42 +00:00
|
|
|
GstMapFlags flags);
|
|
|
|
typedef gboolean (*GstMemoryUnmapFunction) (GstMemory *mem, gpointer data, gsize size);
|
|
|
|
|
2011-03-18 18:28:17 +00:00
|
|
|
typedef void (*GstMemoryFreeFunction) (GstMemory *mem);
|
2011-03-18 17:35:42 +00:00
|
|
|
typedef GstMemory * (*GstMemoryCopyFunction) (GstMemory *mem);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstMemoryInfo:
|
|
|
|
* @impl: tag indentifying the implementor of the api
|
|
|
|
* @size: size of the memory structure
|
|
|
|
*
|
|
|
|
* The #GstMemoryInfo provides information about a specific metadata
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
struct _GstMemoryInfo {
|
|
|
|
GstMemoryGetSizesFunction get_sizes;
|
|
|
|
GstMemorySetSizeFunction set_size;
|
|
|
|
GstMemoryMapFunction map;
|
|
|
|
GstMemoryUnmapFunction unmap;
|
2011-03-18 18:28:17 +00:00
|
|
|
GstMemoryFreeFunction free;
|
2011-03-18 17:35:42 +00:00
|
|
|
GstMemoryCopyFunction copy;
|
|
|
|
};
|
|
|
|
|
|
|
|
void _gst_memory_init (void);
|
|
|
|
|
|
|
|
GstMemory * gst_memory_ref (GstMemory *mem);
|
|
|
|
void gst_memory_unref (GstMemory *mem);
|
|
|
|
|
|
|
|
gsize gst_memory_get_sizes (GstMemory *mem, gsize *maxsize);
|
|
|
|
void gst_memory_set_size (GstMemory *mem, gsize size);
|
|
|
|
|
|
|
|
gpointer gst_memory_map (GstMemory *mem, gsize *size, gsize *maxsize,
|
|
|
|
GstMapFlags flags);
|
|
|
|
gboolean gst_memory_unmap (GstMemory *mem, gpointer data, gsize size);
|
|
|
|
|
|
|
|
GstMemory * gst_memory_copy (GstMemory *mem);
|
|
|
|
|
|
|
|
|
|
|
|
GstMemory * gst_memory_new_wrapped (gpointer data, GFreeFunc free_func,
|
|
|
|
gsize maxsize, gsize offset, gsize size);
|
|
|
|
GstMemory * gst_memory_new_alloc (gsize maxsize, gsize align);
|
|
|
|
|
|
|
|
|
2011-03-18 18:28:17 +00:00
|
|
|
const GstMemoryImpl * gst_memory_register (const gchar *impl, const GstMemoryInfo *info);
|
|
|
|
|
2011-03-18 17:35:42 +00:00
|
|
|
#if 0
|
|
|
|
const GstMemoryInfo * gst_memory_get_info (const gchar * impl);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_MEMORY_H__ */
|