X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgstmemory.h;h=8244da928d7c039e2b2c6ba348620c2440466563;hb=bb07550c2dc9a62dfaa58701d085f9ff7658d75f;hp=e249cb4b719263da892948c58b3c90d593720a3c;hpb=f362f643ac583e14f729963988b81ebc45916122;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstmemory.h b/gst/gstmemory.h index e249cb4..8244da9 100644 --- a/gst/gstmemory.h +++ b/gst/gstmemory.h @@ -15,8 +15,8 @@ * * 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. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ @@ -26,10 +26,15 @@ #include #include +#include +#include G_BEGIN_DECLS -#define GST_TYPE_MEMORY (gst_memory_get_type()) +GST_API GType _gst_memory_type; +#define GST_TYPE_MEMORY (_gst_memory_type) + +GST_API GType gst_memory_get_type(void); typedef struct _GstMemory GstMemory; @@ -45,6 +50,8 @@ typedef struct _GstAllocator GstAllocator; * made when this memory needs to be shared between buffers. * @GST_MEMORY_FLAG_ZERO_PREFIXED: the memory prefix is filled with 0 bytes * @GST_MEMORY_FLAG_ZERO_PADDED: the memory padding is filled with 0 bytes + * @GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS: the memory is physically contiguous. (Since 1.2) + * @GST_MEMORY_FLAG_NOT_MAPPABLE: the memory can't be mapped via gst_memory_map() without any preconditions. (Since 1.2) * @GST_MEMORY_FLAG_LAST: first flag that can be used for custom purposes * * Flags for wrapped memory. @@ -54,6 +61,8 @@ typedef enum { GST_MEMORY_FLAG_NO_SHARE = (GST_MINI_OBJECT_FLAG_LAST << 0), GST_MEMORY_FLAG_ZERO_PREFIXED = (GST_MINI_OBJECT_FLAG_LAST << 1), GST_MEMORY_FLAG_ZERO_PADDED = (GST_MINI_OBJECT_FLAG_LAST << 2), + GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS = (GST_MINI_OBJECT_FLAG_LAST << 3), + GST_MEMORY_FLAG_NOT_MAPPABLE = (GST_MINI_OBJECT_FLAG_LAST << 4), GST_MEMORY_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 16) } GstMemoryFlags; @@ -111,6 +120,25 @@ typedef enum { */ #define GST_MEMORY_IS_ZERO_PADDED(mem) GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_ZERO_PADDED) +/** + * GST_MEMORY_IS_PHYSICALLY_CONTIGUOUS: + * @mem: a #GstMemory. + * + * Check if @mem is physically contiguous. + * + * Since: 1.2 + */ +#define GST_MEMORY_IS_PHYSICALLY_CONTIGUOUS(mem) GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS) + +/** + * GST_MEMORY_IS_NOT_MAPPABLE: + * @mem: a #GstMemory. + * + * Check if @mem can't be mapped via gst_memory_map() without any preconditions + * + * Since: 1.2 + */ +#define GST_MEMORY_IS_NOT_MAPPABLE(mem) GST_MEMORY_FLAG_IS_SET(mem,GST_MEMORY_FLAG_NOT_MAPPABLE) /** * GstMemory: @@ -153,11 +181,11 @@ typedef enum { } GstMapFlags; /** - * GST_MAP_READWRITE: + * GST_MAP_READWRITE: (value 3) (type GstMapFlags) * * GstMapFlags value alias for GST_MAP_READ | GST_MAP_WRITE */ -#define GST_MAP_READWRITE (GST_MAP_READ | GST_MAP_WRITE) +#define GST_MAP_READWRITE ((GstMapFlags) (GST_MAP_READ | GST_MAP_WRITE)) /** @@ -179,8 +207,11 @@ typedef struct { guint8 *data; gsize size; gsize maxsize; - /*< private >*/ + /*< protected >*/ gpointer user_data[4]; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; } GstMapInfo; /** @@ -188,7 +219,7 @@ typedef struct { * * Initializer for #GstMapInfo */ -#define GST_MAP_INFO_INIT { NULL, 0, NULL, 0, 0, } +#define GST_MAP_INFO_INIT { NULL, (GstMapFlags) 0, NULL, 0, 0, { NULL, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL}} /** * GstMemoryMapFunction: @@ -206,16 +237,38 @@ typedef struct { typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize maxsize, GstMapFlags flags); /** + * GstMemoryMapFullFunction: + * @mem: a #GstMemory + * @info: the #GstMapInfo to map with + * @maxsize: size to map + * + * Get the memory of @mem that can be accessed according to the mode specified + * in @info's flags. The function should return a pointer that contains at least + * @maxsize bytes. + * + * Returns: a pointer to memory of which at least @maxsize bytes can be + * accessed according to the access pattern in @info's flags. + */ +typedef gpointer (*GstMemoryMapFullFunction) (GstMemory *mem, GstMapInfo * info, gsize maxsize); + +/** * GstMemoryUnmapFunction: * @mem: a #GstMemory * * Return the pointer previously retrieved with gst_memory_map(). - * - * Returns: %TRUE on success. */ typedef void (*GstMemoryUnmapFunction) (GstMemory *mem); /** + * GstMemoryUnmapFullFunction: + * @mem: a #GstMemory + * @info: a #GstMapInfo + * + * Return the pointer previously retrieved with gst_memory_map() with @info. + */ +typedef void (*GstMemoryUnmapFullFunction) (GstMemory *mem, GstMapInfo * info); + +/** * GstMemoryCopyFunction: * @mem: a #GstMemory * @offset: an offset @@ -257,10 +310,14 @@ typedef GstMemory * (*GstMemoryShareFunction) (GstMemory *mem, gssize offset */ typedef gboolean (*GstMemoryIsSpanFunction) (GstMemory *mem1, GstMemory *mem2, gsize *offset); +GST_API void gst_memory_init (GstMemory *mem, GstMemoryFlags flags, GstAllocator *allocator, GstMemory *parent, gsize maxsize, gsize align, gsize offset, gsize size); +GST_API +gboolean gst_memory_is_type (GstMemory *mem, const gchar *mem_type); + /* refcounting */ /** * gst_memory_ref: @@ -270,10 +327,6 @@ void gst_memory_init (GstMemory *mem, GstMemoryFlags flags, * * Returns: (transfer full): @memory (for convenience when doing assignments) */ -#ifdef _FOOL_GTK_DOC_ -G_INLINE_FUNC GstMemory * gst_memory_ref (GstMemory * memory); -#endif - static inline GstMemory * gst_memory_ref (GstMemory * memory) { @@ -286,10 +339,6 @@ gst_memory_ref (GstMemory * memory) * * Decrease the refcount of an memory, freeing it if the refcount reaches 0. */ -#ifdef _FOOL_GTK_DOC_ -G_INLINE_FUNC void gst_memory_unref (GstMemory * memory); -#endif - static inline void gst_memory_unref (GstMemory * memory) { @@ -297,25 +346,50 @@ gst_memory_unref (GstMemory * memory) } /* getting/setting memory properties */ + +GST_API gsize gst_memory_get_sizes (GstMemory *mem, gsize *offset, gsize *maxsize); + +GST_API void gst_memory_resize (GstMemory *mem, gssize offset, gsize size); #define gst_memory_lock(m,f) gst_mini_object_lock (GST_MINI_OBJECT_CAST (m), (f)) #define gst_memory_unlock(m,f) gst_mini_object_unlock (GST_MINI_OBJECT_CAST (m), (f)) #define gst_memory_is_writable(m) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (m)) +#define gst_memory_make_writable(m) GST_MEMORY_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (m))) /* retrieving data */ -GstMemory * gst_memory_make_mapped (GstMemory *mem, GstMapInfo *info, GstMapFlags flags); + +GST_API +GstMemory * gst_memory_make_mapped (GstMemory *mem, GstMapInfo *info, GstMapFlags flags) G_GNUC_WARN_UNUSED_RESULT; + +GST_API gboolean gst_memory_map (GstMemory *mem, GstMapInfo *info, GstMapFlags flags); + +GST_API void gst_memory_unmap (GstMemory *mem, GstMapInfo *info); /* copy and subregions */ -GstMemory * gst_memory_copy (GstMemory *mem, gssize offset, gssize size); -GstMemory * gst_memory_share (GstMemory *mem, gssize offset, gssize size); + +GST_API +GstMemory * gst_memory_copy (GstMemory *mem, gssize offset, gssize size) G_GNUC_WARN_UNUSED_RESULT; + +GST_API +GstMemory * gst_memory_share (GstMemory *mem, gssize offset, gssize size) G_GNUC_WARN_UNUSED_RESULT; /* span memory */ + +GST_API gboolean gst_memory_is_span (GstMemory *mem1, GstMemory *mem2, gsize *offset); +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMemory, gst_memory_unref) +#endif + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAllocator, gst_object_unref) +#endif + G_END_DECLS #endif /* __GST_MEMORY_H__ */