gstreamer/tests/examples/memory/memory_test.c

55 lines
1.1 KiB
C
Raw Normal View History

2012-07-05 12:25:13 +00:00
#include <gst/gst.h>
#include "my-memory.h"
#include "my-vidmem.h"
2012-07-05 12:25:13 +00:00
int
main (int argc, char **argv)
{
GstAllocator *alloc;
GstMemory *mem;
GstAllocationParams params;
GstMapInfo info;
guint f, w, h;
2012-07-05 12:25:13 +00:00
gst_init (&argc, &argv);
/* memory using the default API */
my_memory_init ();
alloc = gst_allocator_find ("MyMemory");
gst_allocation_params_init (&params);
mem = gst_allocator_alloc (alloc, 1024, &params);
gst_memory_map (mem, &info, GST_MAP_READ);
gst_memory_unmap (mem, &info);
gst_memory_unref (mem);
gst_allocator_unref (alloc);
/* allocator with custom alloc API */
my_vidmem_init ();
/* we can get the allocator but we can only make objects from it when we know
* the API */
alloc = gst_allocator_find ("MyVidmem");
/* use custom api to alloc */
mem = my_vidmem_alloc (0, 640, 480);
g_assert (my_is_vidmem (mem));
my_vidmem_get_format (mem, &f, &w, &h);
g_assert (f == 0);
g_assert (w == 640);
g_assert (h == 480);
gst_memory_map (mem, &info, GST_MAP_READ);
gst_memory_unmap (mem, &info);
gst_memory_unref (mem);
gst_allocator_unref (alloc);
2012-07-05 12:25:13 +00:00
return 0;
}