1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gstreamer-GstBuffer.html
27  * outPack = gstreamer
28  * outFile = Buffer
29  * strct   = GstBuffer
30  * realStrct=
31  * ctorStrct=
32  * clss    = Buffer
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_buffer_
41  * omit structs:
42  * 	- GstBuffer
43  * omit prefixes:
44  * omit code:
45  * 	- gst_buffer_extract_dup
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- gstreamer.Allocator
50  * 	- gstreamer.Memory
51  * 	- gstreamer.Meta
52  * structWrap:
53  * 	- GstAllocator* -> Allocator
54  * 	- GstBuffer* -> Buffer
55  * 	- GstMemory* -> Memory
56  * module aliases:
57  * local aliases:
58  * overrides:
59  */
60 
61 module gstreamer.Buffer;
62 
63 public  import gstreamerc.gstreamertypes;
64 
65 private import gstreamerc.gstreamer;
66 private import glib.ConstructionException;
67 private import gobject.ObjectG;
68 
69 
70 private import glib.Str;
71 private import gstreamer.Allocator;
72 private import gstreamer.Memory;
73 private import gstreamer.Meta;
74 
75 
76 
77 
78 /**
79  * Buffers are the basic unit of data transfer in GStreamer. They contain the
80  * timing and offset along with other arbitrary metadata that is associated
81  * with the GstMemory blocks that the buffer contains.
82  *
83  * Buffers are usually created with gst_buffer_new(). After a buffer has been
84  * created one will typically allocate memory for it and add it to the buffer.
85  * The following example creates a buffer that can hold a given video frame
86  * with a given width, height and bits per plane.
87  *
88  * $(DDOC_COMMENT example)
89  *
90  * Alternatively, use gst_buffer_new_allocate()
91  * to create a buffer with preallocated data of a given size.
92  *
93  * Buffers can contain a list of GstMemory objects. You can retrieve how many
94  * memory objects with gst_buffer_n_memory() and you can get a pointer
95  * to memory with gst_buffer_peek_memory()
96  *
97  * A buffer will usually have timestamps, and a duration, but neither of these
98  * are guaranteed (they may be set to GST_CLOCK_TIME_NONE). Whenever a
99  * meaningful value can be given for these, they should be set. The timestamps
100  * and duration are measured in nanoseconds (they are GstClockTime values).
101  *
102  * The buffer DTS refers to the timestamp when the buffer should be decoded and
103  * is usually monotonically increasing. The buffer PTS refers to the timestamp when
104  * the buffer content should be presented to the user and is not always
105  * monotonically increasing.
106  *
107  * A buffer can also have one or both of a start and an end offset. These are
108  * media-type specific. For video buffers, the start offset will generally be
109  * the frame number. For audio buffers, it will be the number of samples
110  * produced so far. For compressed data, it could be the byte offset in a
111  * source or destination file. Likewise, the end offset will be the offset of
112  * the end of the buffer. These can only be meaningfully interpreted if you
113  * know the media type of the buffer (the preceeding CAPS event). Either or both
114  * can be set to GST_BUFFER_OFFSET_NONE.
115  *
116  * gst_buffer_ref() is used to increase the refcount of a buffer. This must be
117  * done when you want to keep a handle to the buffer after pushing it to the
118  * next element. The buffer refcount determines the writability of the buffer, a
119  * buffer is only writable when the refcount is exactly 1, i.e. when the caller
120  * has the only reference to the buffer.
121  *
122  * To efficiently create a smaller buffer out of an existing one, you can
123  * use gst_buffer_copy_region(). This method tries to share the memory objects
124  * between the two buffers.
125  *
126  * If a plug-in wants to modify the buffer data or metadata in-place, it should
127  * first obtain a buffer that is safe to modify by using
128  * gst_buffer_make_writable(). This function is optimized so that a copy will
129  * only be made when it is necessary.
130  *
131  * Several flags of the buffer can be set and unset with the
132  * GST_BUFFER_FLAG_SET() and GST_BUFFER_FLAG_UNSET() macros. Use
133  * GST_BUFFER_FLAG_IS_SET() to test if a certain GstBufferFlag is set.
134  *
135  * Buffers can be efficiently merged into a larger buffer with
136  * gst_buffer_append(). Copying of memory will only be done when absolutely
137  * needed.
138  *
139  * Arbitrary extra metadata can be set on a buffer with gst_buffer_add_meta().
140  * Metadata can be retrieved with gst_buffer_get_meta(). See also GstMeta
141  *
142  * An element should either unref the buffer or push it out on a src pad
143  * using gst_pad_push() (see GstPad).
144  *
145  * Buffers are usually freed by unreffing them with gst_buffer_unref(). When
146  * the refcount drops to 0, any memory and metadata pointed to by the buffer is
147  * unreffed as well. Buffers allocated from a GstBufferPool will be returned to
148  * the pool when the refcount drops to 0.
149  *
150  * Last reviewed on 2012-03-28 (0.11.3)
151  */
152 public class Buffer
153 {
154 	
155 	/** the main Gtk struct */
156 	protected GstBuffer* gstBuffer;
157 	
158 	
159 	public GstBuffer* getBufferStruct()
160 	{
161 		return gstBuffer;
162 	}
163 	
164 	
165 	/** the main Gtk struct as a void* */
166 	protected void* getStruct()
167 	{
168 		return cast(void*)gstBuffer;
169 	}
170 	
171 	/**
172 	 * Sets our main struct and passes it to the parent class
173 	 */
174 	public this (GstBuffer* gstBuffer)
175 	{
176 		this.gstBuffer = gstBuffer;
177 	}
178 	
179 	/**
180 	 * Extracts a copy of at most size bytes the data at offset into a GBytes.
181 	 * dest must be freed using g_free() when done.
182 	 * Since 1.0.10
183 	 * Params:
184 	 * offset = the offset to extract
185 	 * size = the size to extract
186 	 * dest = A pointer where
187 	 * the destination array will be written. [array length=dest_size][element-type guint8][out]
188 	 */
189 	public void extractDup(gsize offset, gsize size, out void[] dest)
190 	{
191 		// void gst_buffer_extract_dup (GstBuffer *buffer,  gsize offset,  gsize size,  gpointer *dest,  gsize *dest_size);
192 		void* outdest = null;
193 		gsize destSize;
194 		
195 		gst_buffer_extract_dup(gstBuffer, offset, size, &outdest, &destSize);
196 		
197 		dest = outdest[0 .. destSize];
198 	}
199 	
200 	/**
201 	 */
202 	
203 	/**
204 	 * Creates a newly allocated buffer without any data.
205 	 * MT safe.
206 	 * Throws: ConstructionException GTK+ fails to create the object.
207 	 */
208 	public this ()
209 	{
210 		// GstBuffer * gst_buffer_new (void);
211 		auto p = gst_buffer_new();
212 		if(p is null)
213 		{
214 			throw new ConstructionException("null returned by gst_buffer_new()");
215 		}
216 		this(cast(GstBuffer*) p);
217 	}
218 	
219 	/**
220 	 * Tries to create a newly allocated buffer with data of the given size and
221 	 * extra parameters from allocator. If the requested amount of memory can't be
222 	 * allocated, NULL will be returned. The allocated buffer memory is not cleared.
223 	 * When allocator is NULL, the default memory allocator will be used.
224 	 * Note that when size == 0, the buffer will not have memory associated with it.
225 	 * MT safe.
226 	 * Params:
227 	 * allocator = the GstAllocator to use, or NULL to use the
228 	 * default allocator. [transfer none][allow-none]
229 	 * size = the size in bytes of the new buffer's data.
230 	 * params = optional parameters. [transfer none][allow-none]
231 	 * Throws: ConstructionException GTK+ fails to create the object.
232 	 */
233 	public this (Allocator allocator, gsize size, GstAllocationParams* params)
234 	{
235 		// GstBuffer * gst_buffer_new_allocate (GstAllocator *allocator,  gsize size,  GstAllocationParams *params);
236 		auto p = gst_buffer_new_allocate((allocator is null) ? null : allocator.getAllocatorStruct(), size, params);
237 		if(p is null)
238 		{
239 			throw new ConstructionException("null returned by gst_buffer_new_allocate((allocator is null) ? null : allocator.getAllocatorStruct(), size, params)");
240 		}
241 		this(cast(GstBuffer*) p);
242 	}
243 	
244 	/**
245 	 * Creates a new buffer that wraps the given data. The memory will be freed
246 	 * with g_free and will be marked writable.
247 	 * MT safe.
248 	 * Params:
249 	 * data = data to wrap. [array length=size][element-type guint8][transfer full]
250 	 * Throws: ConstructionException GTK+ fails to create the object.
251 	 */
252 	public this (void[] data)
253 	{
254 		// GstBuffer * gst_buffer_new_wrapped (gpointer data,  gsize size);
255 		auto p = gst_buffer_new_wrapped(data.ptr, cast(int) data.length);
256 		if(p is null)
257 		{
258 			throw new ConstructionException("null returned by gst_buffer_new_wrapped(data.ptr, cast(int) data.length)");
259 		}
260 		this(cast(GstBuffer*) p);
261 	}
262 	
263 	/**
264 	 * Allocate a new buffer that wraps the given memory. data must point to
265 	 * maxsize of memory, the wrapped buffer will have the region from offset and
266 	 * size visible.
267 	 * When the buffer is destroyed, notify will be called with user_data.
268 	 * The prefix/padding must be filled with 0 if flags contains
269 	 * GST_MEMORY_FLAG_ZERO_PREFIXED and GST_MEMORY_FLAG_ZERO_PADDED respectively.
270 	 * Params:
271 	 * flags = GstMemoryFlags
272 	 * data = data to wrap. [array length=size][element-type guint8][transfer none]
273 	 * maxsize = allocated size of data
274 	 * offset = offset in data
275 	 * size = size of valid data
276 	 * userData = user_data. [allow-none]
277 	 * notify = called with user_data when the memory is freed. [allow-none][scope async][closure user_data]
278 	 * Throws: ConstructionException GTK+ fails to create the object.
279 	 */
280 	public this (GstMemoryFlags flags, void* data, gsize maxsize, gsize offset, gsize size, void* userData, GDestroyNotify notify)
281 	{
282 		// GstBuffer * gst_buffer_new_wrapped_full (GstMemoryFlags flags,  gpointer data,  gsize maxsize,  gsize offset,  gsize size,  gpointer user_data,  GDestroyNotify notify);
283 		auto p = gst_buffer_new_wrapped_full(flags, data, maxsize, offset, size, userData, notify);
284 		if(p is null)
285 		{
286 			throw new ConstructionException("null returned by gst_buffer_new_wrapped_full(flags, data, maxsize, offset, size, userData, notify)");
287 		}
288 		this(cast(GstBuffer*) p);
289 	}
290 	
291 	/**
292 	 * Increases the refcount of the given buffer by one.
293 	 * Note that the refcount affects the writeability
294 	 * of buf and its metadata, see gst_buffer_is_writable().
295 	 * It is important to note that keeping additional references to
296 	 * GstBuffer instances can potentially increase the number
297 	 * of memcpy operations in a pipeline.
298 	 * Returns: buf. [transfer full]
299 	 */
300 	public Buffer doref()
301 	{
302 		// GstBuffer * gst_buffer_ref (GstBuffer *buf);
303 		auto p = gst_buffer_ref(gstBuffer);
304 		
305 		if(p is null)
306 		{
307 			return null;
308 		}
309 		
310 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
311 	}
312 	
313 	/**
314 	 * Decreases the refcount of the buffer. If the refcount reaches 0, the buffer
315 	 * with the associated metadata and memory will be freed.
316 	 */
317 	public void unref()
318 	{
319 		// void gst_buffer_unref (GstBuffer *buf);
320 		gst_buffer_unref(gstBuffer);
321 	}
322 	
323 	/**
324 	 * Get the total size of the memory blocks in b.
325 	 * When not NULL, offset will contain the offset of the data in the
326 	 * first memory block in buffer and maxsize will contain the sum of
327 	 * the size and offset and the amount of extra padding on the last
328 	 * memory block. offset and maxsize can be used to resize the
329 	 * buffer memory blocks with gst_buffer_resize().
330 	 * Params:
331 	 * offset = a pointer to the offset. [out]
332 	 * maxsize = a pointer to the maxsize. [out]
333 	 * Returns: total size of the memory blocks in buffer.
334 	 */
335 	public gsize getSizes(out gsize offset, out gsize maxsize)
336 	{
337 		// gsize gst_buffer_get_sizes (GstBuffer *buffer,  gsize *offset,  gsize *maxsize);
338 		return gst_buffer_get_sizes(gstBuffer, &offset, &maxsize);
339 	}
340 	
341 	/**
342 	 * Get the total size of the memory blocks in buffer.
343 	 * Returns: total size of the memory blocks in buffer.
344 	 */
345 	public gsize getSize()
346 	{
347 		// gsize gst_buffer_get_size (GstBuffer *buffer);
348 		return gst_buffer_get_size(gstBuffer);
349 	}
350 	
351 	/**
352 	 * Get the total size of length memory blocks stating from idx in buffer.
353 	 * When not NULL, offset will contain the offset of the data in the
354 	 * memory block in buffer at idx and maxsize will contain the sum of the size
355 	 * and offset and the amount of extra padding on the memory block at idx +
356 	 * length -1.
357 	 * offset and maxsize can be used to resize the buffer memory blocks with
358 	 * gst_buffer_resize_range().
359 	 * Params:
360 	 * idx = an index
361 	 * length = a length
362 	 * offset = a pointer to the offset. [out]
363 	 * maxsize = a pointer to the maxsize. [out]
364 	 * Returns: total size of length memory blocks starting at idx in buffer.
365 	 */
366 	public gsize getSizesRange(uint idx, int length, out gsize offset, out gsize maxsize)
367 	{
368 		// gsize gst_buffer_get_sizes_range (GstBuffer *buffer,  guint idx,  gint length,  gsize *offset,  gsize *maxsize);
369 		return gst_buffer_get_sizes_range(gstBuffer, idx, length, &offset, &maxsize);
370 	}
371 	
372 	/**
373 	 * Set the total size of the length memory blocks starting at idx in
374 	 * buffer
375 	 * Params:
376 	 * idx = an index
377 	 * length = a length
378 	 * offset = the offset adjustement
379 	 * size = the new size or -1 to just adjust the offset
380 	 * Returns: TRUE if resizing succeeded, FALSE otherwise.
381 	 */
382 	public int resizeRange(uint idx, int length, gssize offset, gssize size)
383 	{
384 		// gboolean gst_buffer_resize_range (GstBuffer *buffer,  guint idx,  gint length,  gssize offset,  gssize size);
385 		return gst_buffer_resize_range(gstBuffer, idx, length, offset, size);
386 	}
387 	
388 	/**
389 	 * Set the offset and total size of the memory blocks in buffer.
390 	 * Params:
391 	 * offset = the offset adjustement
392 	 * size = the new size or -1 to just adjust the offset
393 	 */
394 	public void resize(gssize offset, gssize size)
395 	{
396 		// void gst_buffer_resize (GstBuffer *buffer,  gssize offset,  gssize size);
397 		gst_buffer_resize(gstBuffer, offset, size);
398 	}
399 	
400 	/**
401 	 * Set the total size of the memory blocks in buffer.
402 	 * Params:
403 	 * size = the new size
404 	 */
405 	public void setSize(gssize size)
406 	{
407 		// void gst_buffer_set_size (GstBuffer *buffer,  gssize size);
408 		gst_buffer_set_size(gstBuffer, size);
409 	}
410 	
411 	/**
412 	 * Get the memory block at idx in buffer. The memory block stays valid until
413 	 * the memory block in buffer is removed, replaced or merged, typically with
414 	 * any call that modifies the memory in buffer.
415 	 * Since this call does not influence the refcount of the memory,
416 	 * gst_memory_is_writable() can be used to check if buffer is the sole owner
417 	 * of the returned memory.
418 	 * Params:
419 	 * idx = an index
420 	 * Returns: the GstMemory at idx. [transfer none]
421 	 */
422 	public Memory peekMemory(uint idx)
423 	{
424 		// GstMemory * gst_buffer_peek_memory (GstBuffer *buffer,  guint idx);
425 		auto p = gst_buffer_peek_memory(gstBuffer, idx);
426 		
427 		if(p is null)
428 		{
429 			return null;
430 		}
431 		
432 		return ObjectG.getDObject!(Memory)(cast(GstMemory*) p);
433 	}
434 	
435 	/**
436 	 * Get the amount of memory blocks that this buffer has. This amount is never
437 	 * larger than what gst_buffer_get_max_memory() returns.
438 	 * Returns: the amount of memory block in this buffer. [transfer full]
439 	 */
440 	public uint nMemory()
441 	{
442 		// guint gst_buffer_n_memory (GstBuffer *buffer);
443 		return gst_buffer_n_memory(gstBuffer);
444 	}
445 	
446 	/**
447 	 * Insert the memory block mem to buffer at idx. This function takes ownership
448 	 * of mem and thus doesn't increase its refcount.
449 	 * Only gst_buffer_get_max_memory() can be added to a buffer. If more memory is
450 	 * added, existing memory blocks will automatically be merged to make room for
451 	 * the new memory.
452 	 * Params:
453 	 * idx = the index to add the memory at, or -1 to append it to the end
454 	 * mem = a GstMemory. [transfer full]
455 	 */
456 	public void insertMemory(int idx, Memory mem)
457 	{
458 		// void gst_buffer_insert_memory (GstBuffer *buffer,  gint idx,  GstMemory *mem);
459 		gst_buffer_insert_memory(gstBuffer, idx, (mem is null) ? null : mem.getMemoryStruct());
460 	}
461 	
462 	/**
463 	 * Replaces length memory blocks in buffer starting at idx with mem.
464 	 * If length is -1, all memory starting from idx will be removed and
465 	 * replaced with mem.
466 	 * buffer should be writable.
467 	 * Params:
468 	 * idx = an index
469 	 * length = a length should not be 0
470 	 * mem = a GstMemory. [transfer full]
471 	 */
472 	public void replaceMemoryRange(uint idx, int length, Memory mem)
473 	{
474 		// void gst_buffer_replace_memory_range (GstBuffer *buffer,  guint idx,  gint length,  GstMemory *mem);
475 		gst_buffer_replace_memory_range(gstBuffer, idx, length, (mem is null) ? null : mem.getMemoryStruct());
476 	}
477 	
478 	/**
479 	 * Get length memory blocks in buffer starting at idx. The memory blocks will
480 	 * be merged into one large GstMemory.
481 	 * If length is -1, all memory starting from idx is merged.
482 	 * Params:
483 	 * idx = an index
484 	 * length = a length
485 	 * Returns: a GstMemory that contains the merged data of length blocks starting at idx. Use gst_memory_unref() after usage. [transfer full]
486 	 */
487 	public Memory getMemoryRange(uint idx, int length)
488 	{
489 		// GstMemory * gst_buffer_get_memory_range (GstBuffer *buffer,  guint idx,  gint length);
490 		auto p = gst_buffer_get_memory_range(gstBuffer, idx, length);
491 		
492 		if(p is null)
493 		{
494 			return null;
495 		}
496 		
497 		return ObjectG.getDObject!(Memory)(cast(GstMemory*) p);
498 	}
499 	
500 	/**
501 	 * Remove length memory blocks in buffer starting from idx.
502 	 * length can be -1, in which case all memory starting from idx is removed.
503 	 * Params:
504 	 * idx = an index
505 	 * length = a length
506 	 */
507 	public void removeMemoryRange(uint idx, int length)
508 	{
509 		// void gst_buffer_remove_memory_range (GstBuffer *buffer,  guint idx,  gint length);
510 		gst_buffer_remove_memory_range(gstBuffer, idx, length);
511 	}
512 	
513 	/**
514 	 * Find the memory blocks that span size bytes starting from offset
515 	 * in buffer.
516 	 * When this function returns TRUE, idx will contain the index of the first
517 	 * memory bock where the byte for offset can be found and length contains the
518 	 * number of memory blocks containing the size remaining bytes. skip contains
519 	 * the number of bytes to skip in the memory bock at idx to get to the byte
520 	 * for offset.
521 	 * size can be -1 to get all the memory blocks after idx.
522 	 * Params:
523 	 * offset = an offset
524 	 * size = a size
525 	 * idx = pointer to index. [out]
526 	 * length = pointer to length. [out]
527 	 * skip = pointer to skip. [out]
528 	 * Returns: TRUE when size bytes starting from offset could be found in buffer and idx, length and skip will be filled.
529 	 */
530 	public int findMemory(gsize offset, gsize size, out uint idx, out uint length, out gsize skip)
531 	{
532 		// gboolean gst_buffer_find_memory (GstBuffer *buffer,  gsize offset,  gsize size,  guint *idx,  guint *length,  gsize *skip);
533 		return gst_buffer_find_memory(gstBuffer, offset, size, &idx, &length, &skip);
534 	}
535 	
536 	/**
537 	 * Prepend the memory block mem to buffer. This function takes
538 	 * ownership of mem and thus doesn't increase its refcount.
539 	 * This function is identical to gst_buffer_insert_memory() with an index of 0.
540 	 * See gst_buffer_insert_memory() for more details.
541 	 * Params:
542 	 * mem = a GstMemory. [transfer full]
543 	 */
544 	public void prependMemory(Memory mem)
545 	{
546 		// void gst_buffer_prepend_memory (GstBuffer *buffer,  GstMemory *mem);
547 		gst_buffer_prepend_memory(gstBuffer, (mem is null) ? null : mem.getMemoryStruct());
548 	}
549 	
550 	/**
551 	 * Append the memory block mem to buffer. This function takes
552 	 * ownership of mem and thus doesn't increase its refcount.
553 	 * This function is identical to gst_buffer_insert_memory() with an index of -1.
554 	 * See gst_buffer_insert_memory() for more details.
555 	 * Params:
556 	 * mem = a GstMemory. [transfer full]
557 	 */
558 	public void appendMemory(Memory mem)
559 	{
560 		// void gst_buffer_append_memory (GstBuffer *buffer,  GstMemory *mem);
561 		gst_buffer_append_memory(gstBuffer, (mem is null) ? null : mem.getMemoryStruct());
562 	}
563 	
564 	/**
565 	 * Replaces the memory block at index idx in buffer with mem.
566 	 * Params:
567 	 * idx = an index
568 	 * mem = a GstMemory. [transfer full]
569 	 */
570 	public void replaceMemory(uint idx, Memory mem)
571 	{
572 		// void gst_buffer_replace_memory (GstBuffer *buffer,  guint idx,  GstMemory *mem);
573 		gst_buffer_replace_memory(gstBuffer, idx, (mem is null) ? null : mem.getMemoryStruct());
574 	}
575 	
576 	/**
577 	 * Replaces all memory in buffer with mem.
578 	 * Params:
579 	 * mem = a GstMemory. [transfer full]
580 	 */
581 	public void replaceAllMemory(Memory mem)
582 	{
583 		// void gst_buffer_replace_all_memory (GstBuffer *buffer,  GstMemory *mem);
584 		gst_buffer_replace_all_memory(gstBuffer, (mem is null) ? null : mem.getMemoryStruct());
585 	}
586 	
587 	/**
588 	 * Get the memory block at index idx in buffer.
589 	 * Params:
590 	 * idx = an index
591 	 * Returns: a GstMemory that contains the data of the memory block at idx. Use gst_memory_unref() after usage. [transfer full]
592 	 */
593 	public Memory getMemory(uint idx)
594 	{
595 		// GstMemory * gst_buffer_get_memory (GstBuffer *buffer,  guint idx);
596 		auto p = gst_buffer_get_memory(gstBuffer, idx);
597 		
598 		if(p is null)
599 		{
600 			return null;
601 		}
602 		
603 		return ObjectG.getDObject!(Memory)(cast(GstMemory*) p);
604 	}
605 	
606 	/**
607 	 * Get all the memory block in buffer. The memory blocks will be merged
608 	 * into one large GstMemory.
609 	 * Returns: a GstMemory that contains the merged memory. Use gst_memory_unref() after usage. [transfer full]
610 	 */
611 	public Memory getAllMemory()
612 	{
613 		// GstMemory * gst_buffer_get_all_memory (GstBuffer *buffer);
614 		auto p = gst_buffer_get_all_memory(gstBuffer);
615 		
616 		if(p is null)
617 		{
618 			return null;
619 		}
620 		
621 		return ObjectG.getDObject!(Memory)(cast(GstMemory*) p);
622 	}
623 	
624 	/**
625 	 * Remove the memory block in b at index i.
626 	 * Params:
627 	 * idx = an index
628 	 */
629 	public void removeMemory(uint idx)
630 	{
631 		// void gst_buffer_remove_memory (GstBuffer *buffer,  guint idx);
632 		gst_buffer_remove_memory(gstBuffer, idx);
633 	}
634 	
635 	/**
636 	 * Remove all the memory blocks in buffer.
637 	 */
638 	public void removeAllMemory()
639 	{
640 		// void gst_buffer_remove_all_memory (GstBuffer *buffer);
641 		gst_buffer_remove_all_memory(gstBuffer);
642 	}
643 	
644 	/**
645 	 * This function fills info with the GstMapInfo of all merged memory
646 	 * blocks in buffer.
647 	 * flags describe the desired access of the memory. When flags is
648 	 * GST_MAP_WRITE, buffer should be writable (as returned from
649 	 * gst_buffer_is_writable()).
650 	 * When buffer is writable but the memory isn't, a writable copy will
651 	 * automatically be created and returned. The readonly copy of the
652 	 * buffer memory will then also be replaced with this writable copy.
653 	 * The memory in info should be unmapped with gst_buffer_unmap() after
654 	 * usage.
655 	 * Params:
656 	 * info = info about the mapping. [out]
657 	 * flags = flags for the mapping
658 	 * Returns: TRUE if the map succeeded and info contains valid data.
659 	 */
660 	public int map(out GstMapInfo info, GstMapFlags flags)
661 	{
662 		// gboolean gst_buffer_map (GstBuffer *buffer,  GstMapInfo *info,  GstMapFlags flags);
663 		return gst_buffer_map(gstBuffer, &info, flags);
664 	}
665 	
666 	/**
667 	 * This function fills info with the GstMapInfo of length merged memory blocks
668 	 * starting at idx in buffer. When length is -1, all memory blocks starting
669 	 * from idx are merged and mapped.
670 	 * flags describe the desired access of the memory. When flags is
671 	 * GST_MAP_WRITE, buffer should be writable (as returned from
672 	 * gst_buffer_is_writable()).
673 	 * When buffer is writable but the memory isn't, a writable copy will
674 	 * automatically be created and returned. The readonly copy of the buffer memory
675 	 * will then also be replaced with this writable copy.
676 	 * The memory in info should be unmapped with gst_buffer_unmap() after usage.
677 	 * Params:
678 	 * idx = an index
679 	 * length = a length
680 	 * info = info about the mapping. [out]
681 	 * flags = flags for the mapping
682 	 * Returns: TRUE if the map succeeded and info contains valid data.
683 	 */
684 	public int mapRange(uint idx, int length, out GstMapInfo info, GstMapFlags flags)
685 	{
686 		// gboolean gst_buffer_map_range (GstBuffer *buffer,  guint idx,  gint length,  GstMapInfo *info,  GstMapFlags flags);
687 		return gst_buffer_map_range(gstBuffer, idx, length, &info, flags);
688 	}
689 	
690 	/**
691 	 * Release the memory previously mapped with gst_buffer_map().
692 	 * Params:
693 	 * info = a GstMapInfo
694 	 */
695 	public void unmap(ref GstMapInfo info)
696 	{
697 		// void gst_buffer_unmap (GstBuffer *buffer,  GstMapInfo *info);
698 		gst_buffer_unmap(gstBuffer, &info);
699 	}
700 	
701 	/**
702 	 * Compare size bytes starting from offset in buffer with the memory in mem.
703 	 * Params:
704 	 * offset = the offset in buffer
705 	 * mem = the memory to compare. [array length=size][element-type guint8]
706 	 * size = the size to compare
707 	 * Returns: 0 if the memory is equal.
708 	 */
709 	public int memcmp(gsize offset, void[] mem)
710 	{
711 		// gint gst_buffer_memcmp (GstBuffer *buffer,  gsize offset,  gconstpointer mem,  gsize size);
712 		return gst_buffer_memcmp(gstBuffer, offset, mem.ptr, cast(int) mem.length);
713 	}
714 	
715 	/**
716 	 * Copy size bytes starting from offset in buffer to dest.
717 	 * Params:
718 	 * offset = the offset to extract
719 	 * dest = the destination address
720 	 * size = the size to extract
721 	 * Returns: The amount of bytes extracted. This value can be lower than size when buffer did not contain enough data.
722 	 */
723 	public gsize extract(gsize offset, void[] dest)
724 	{
725 		// gsize gst_buffer_extract (GstBuffer *buffer,  gsize offset,  gpointer dest,  gsize size);
726 		return gst_buffer_extract(gstBuffer, offset, dest.ptr, cast(int) dest.length);
727 	}
728 	
729 	/**
730 	 * Copy size bytes from src to buffer at offset.
731 	 * Params:
732 	 * offset = the offset to fill
733 	 * src = the source address. [array length=size][element-type guint8]
734 	 * size = the size to fill
735 	 * Returns: The amount of bytes copied. This value can be lower than size when buffer did not contain enough data.
736 	 */
737 	public gsize fill(gsize offset, void[] src)
738 	{
739 		// gsize gst_buffer_fill (GstBuffer *buffer,  gsize offset,  gconstpointer src,  gsize size);
740 		return gst_buffer_fill(gstBuffer, offset, src.ptr, cast(int) src.length);
741 	}
742 	
743 	/**
744 	 * Fill buf with size bytes with val starting from offset.
745 	 * Params:
746 	 * offset = the offset in buffer
747 	 * val = the value to set
748 	 * size = the size to set
749 	 * Returns: The amount of bytes filled. This value can be lower than size when buffer did not contain enough data.
750 	 */
751 	public gsize memset(gsize offset, ubyte val, gsize size)
752 	{
753 		// gsize gst_buffer_memset (GstBuffer *buffer,  gsize offset,  guint8 val,  gsize size);
754 		return gst_buffer_memset(gstBuffer, offset, val, size);
755 	}
756 	
757 	/**
758 	 * Create a copy of the given buffer. This will also make a newly allocated
759 	 * copy of the data the source buffer contains.
760 	 * Returns: a new copy of buf. [transfer full]
761 	 */
762 	public Buffer copy()
763 	{
764 		// GstBuffer * gst_buffer_copy (const GstBuffer *buf);
765 		auto p = gst_buffer_copy(gstBuffer);
766 		
767 		if(p is null)
768 		{
769 			return null;
770 		}
771 		
772 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
773 	}
774 	
775 	/**
776 	 * Copies the information from src into dest.
777 	 * If dest already contains memory and flags contains GST_BUFFER_COPY_MEMORY,
778 	 * the memory from src will be appended to dest.
779 	 * flags indicate which fields will be copied.
780 	 * Params:
781 	 * src = a source GstBuffer
782 	 * flags = flags indicating what metadata fields should be copied.
783 	 * offset = offset to copy from
784 	 * size = total size to copy. If -1, all data is copied.
785 	 * Returns: TRUE if the copying succeeded, FALSE otherwise.
786 	 */
787 	public int copyInto(Buffer src, GstBufferCopyFlags flags, gsize offset, gsize size)
788 	{
789 		// gboolean gst_buffer_copy_into (GstBuffer *dest,  GstBuffer *src,  GstBufferCopyFlags flags,  gsize offset,  gsize size);
790 		return gst_buffer_copy_into(gstBuffer, (src is null) ? null : src.getBufferStruct(), flags, offset, size);
791 	}
792 	
793 	/**
794 	 * Creates a sub-buffer from parent at offset and size.
795 	 * This sub-buffer uses the actual memory space of the parent buffer.
796 	 * This function will copy the offset and timestamp fields when the
797 	 * offset is 0. If not, they will be set to GST_CLOCK_TIME_NONE and
798 	 * GST_BUFFER_OFFSET_NONE.
799 	 * If offset equals 0 and size equals the total size of buffer, the
800 	 * duration and offset end fields are also copied. If not they will be set
801 	 * to GST_CLOCK_TIME_NONE and GST_BUFFER_OFFSET_NONE.
802 	 * MT safe.
803 	 * Params:
804 	 * flags = the GstBufferCopyFlags
805 	 * offset = the offset into parent GstBuffer at which the new sub-buffer
806 	 * begins.
807 	 * size = the size of the new GstBuffer sub-buffer, in bytes.
808 	 * Returns: the new GstBuffer or NULL if the arguments were invalid. [transfer full]
809 	 */
810 	public Buffer copyRegion(GstBufferCopyFlags flags, gsize offset, gsize size)
811 	{
812 		// GstBuffer * gst_buffer_copy_region (GstBuffer *parent,  GstBufferCopyFlags flags,  gsize offset,  gsize size);
813 		auto p = gst_buffer_copy_region(gstBuffer, flags, offset, size);
814 		
815 		if(p is null)
816 		{
817 			return null;
818 		}
819 		
820 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
821 	}
822 	
823 	/**
824 	 * Modifies a pointer to a GstBuffer to point to a different GstBuffer. The
825 	 * modification is done atomically (so this is useful for ensuring thread safety
826 	 * in some cases), and the reference counts are updated appropriately (the old
827 	 * buffer is unreffed, the new is reffed).
828 	 * Either nbuf or the GstBuffer pointed to by obuf may be NULL.
829 	 * Params:
830 	 * obuf = pointer to a pointer to a GstBuffer to be
831 	 * replaced. [inout][transfer full]
832 	 * nbuf = pointer to a GstBuffer that will
833 	 * replace the buffer pointed to by obuf. [transfer none][allow-none]
834 	 * Returns: TRUE when obuf was different from nbuf.
835 	 */
836 	public static int replace(ref Buffer obuf, Buffer nbuf)
837 	{
838 		// gboolean gst_buffer_replace (GstBuffer **obuf,  GstBuffer *nbuf);
839 		GstBuffer* outobuf = (obuf is null) ? null : obuf.getBufferStruct();
840 		
841 		auto p = gst_buffer_replace(&outobuf, (nbuf is null) ? null : nbuf.getBufferStruct());
842 		
843 		obuf = ObjectG.getDObject!(Buffer)(outobuf);
844 		return p;
845 	}
846 	
847 	/**
848 	 * Append all the memory from buf2 to buf1. The result buffer will contain a
849 	 * concatenation of the memory of buf1 and buf2.
850 	 * Params:
851 	 * buf2 = the second source GstBuffer to append. [transfer full]
852 	 * Returns: the new GstBuffer that contains the memory of the two source buffers. [transfer full]
853 	 */
854 	public Buffer append(Buffer buf2)
855 	{
856 		// GstBuffer * gst_buffer_append (GstBuffer *buf1,  GstBuffer *buf2);
857 		auto p = gst_buffer_append(gstBuffer, (buf2 is null) ? null : buf2.getBufferStruct());
858 		
859 		if(p is null)
860 		{
861 			return null;
862 		}
863 		
864 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
865 	}
866 	
867 	/**
868 	 * Append size bytes at offset from buf2 to buf1. The result buffer will
869 	 * contain a concatenation of the memory of buf1 and the requested region of
870 	 * buf2.
871 	 * Params:
872 	 * buf2 = the second source GstBuffer to append. [transfer full]
873 	 * offset = the offset in buf2
874 	 * size = the size or -1 of buf2
875 	 * Returns: the new GstBuffer that contains the memory of the two source buffers. [transfer full]
876 	 */
877 	public Buffer appendRegion(Buffer buf2, gssize offset, gssize size)
878 	{
879 		// GstBuffer * gst_buffer_append_region (GstBuffer *buf1,  GstBuffer *buf2,  gssize offset,  gssize size);
880 		auto p = gst_buffer_append_region(gstBuffer, (buf2 is null) ? null : buf2.getBufferStruct(), offset, size);
881 		
882 		if(p is null)
883 		{
884 			return null;
885 		}
886 		
887 		return ObjectG.getDObject!(Buffer)(cast(GstBuffer*) p);
888 	}
889 	
890 	/**
891 	 * Get the metadata for api on buffer. When there is no such
892 	 * metadata, NULL is returned.
893 	 * Params:
894 	 * api = the GType of an API
895 	 * Returns: the metadata for api on buffer. [transfer none]
896 	 */
897 	public GstMeta* getMeta(GType api)
898 	{
899 		// GstMeta * gst_buffer_get_meta (GstBuffer *buffer,  GType api);
900 		return gst_buffer_get_meta(gstBuffer, api);
901 	}
902 	
903 	/**
904 	 * Add metadata for info to buffer using the parameters in params.
905 	 * Params:
906 	 * info = a GstMetaInfo
907 	 * params = params for info
908 	 * Returns: the metadata for the api in info on buffer. [transfer none]
909 	 */
910 	public GstMeta* addMeta(GstMetaInfo* info, void* params)
911 	{
912 		// GstMeta * gst_buffer_add_meta (GstBuffer *buffer,  const GstMetaInfo *info,  gpointer params);
913 		return gst_buffer_add_meta(gstBuffer, info, params);
914 	}
915 	
916 	/**
917 	 * Remove the metadata for meta on buffer.
918 	 * Params:
919 	 * meta = a GstMeta
920 	 * Returns: TRUE if the metadata existed and was removed, FALSE if no such metadata was on buffer.
921 	 */
922 	public int removeMeta(GstMeta* meta)
923 	{
924 		// gboolean gst_buffer_remove_meta (GstBuffer *buffer,  GstMeta *meta);
925 		return gst_buffer_remove_meta(gstBuffer, meta);
926 	}
927 	
928 	/**
929 	 * Retrieve the next GstMeta after current. If state points
930 	 * to NULL, the first metadata is returned.
931 	 * state will be updated with an opage state pointer
932 	 * Params:
933 	 * state = an opaque state pointer
934 	 * Returns: The next GstMeta or NULL when there are no more items. [transfer none]
935 	 */
936 	public GstMeta* iterateMeta(void** state)
937 	{
938 		// GstMeta * gst_buffer_iterate_meta (GstBuffer *buffer,  gpointer *state);
939 		return gst_buffer_iterate_meta(gstBuffer, state);
940 	}
941 	
942 	/**
943 	 * Call func with user_data for each meta in buffer.
944 	 * func can modify the passed meta pointer or its contents. The return value
945 	 * of func define if this function returns or if the remaining metadata items
946 	 * in the buffer should be skipped.
947 	 * Params:
948 	 * func = a GstBufferForeachMetaFunc to call. [scope call]
949 	 * userData = user data passed to func. [closure]
950 	 * Returns: FALSE when func returned FALSE for one of the metadata.
951 	 */
952 	public int foreachMeta(GstBufferForeachMetaFunc func, void* userData)
953 	{
954 		// gboolean gst_buffer_foreach_meta (GstBuffer *buffer,  GstBufferForeachMetaFunc func,  gpointer user_data);
955 		return gst_buffer_foreach_meta(gstBuffer, func, userData);
956 	}
957 }