2012-07-05 12:25:13 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2012-07-05 15:11:01 +00:00
|
|
|
#include "my-memory.h"
|
2012-07-05 16:07:52 +00:00
|
|
|
#include "my-vidmem.h"
|
2012-07-05 15:11:01 +00:00
|
|
|
|
2012-07-05 12:25:13 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2012-07-05 15:11:01 +00:00
|
|
|
GstAllocator *alloc;
|
|
|
|
GstMemory *mem;
|
|
|
|
GstAllocationParams params;
|
|
|
|
GstMapInfo info;
|
2012-07-05 16:07:52 +00:00
|
|
|
guint f, w, h;
|
2012-07-05 15:11:01 +00:00
|
|
|
|
2012-07-05 12:25:13 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
2012-07-05 16:07:52 +00:00
|
|
|
/* memory using the default API */
|
2012-07-05 15:11:01 +00:00
|
|
|
my_memory_init ();
|
|
|
|
|
|
|
|
alloc = gst_allocator_find ("MyMemory");
|
|
|
|
|
|
|
|
gst_allocation_params_init (¶ms);
|
|
|
|
mem = gst_allocator_alloc (alloc, 1024, ¶ms);
|
|
|
|
|
|
|
|
gst_memory_map (mem, &info, GST_MAP_READ);
|
|
|
|
gst_memory_unmap (mem, &info);
|
|
|
|
|
|
|
|
gst_memory_unref (mem);
|
2012-07-05 16:07:52 +00:00
|
|
|
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 15:11:01 +00:00
|
|
|
|
2012-07-05 12:25:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|