1 #include <gst/gst.h>
2
3 #include "my-memory.h"
4 #include "my-vidmem.h"
5
6 int
main(int argc,char ** argv)7 main (int argc, char **argv)
8 {
9 GstAllocator *alloc;
10 GstMemory *mem;
11 GstAllocationParams params;
12 GstMapInfo info;
13 guint f, w, h;
14
15 gst_init (&argc, &argv);
16
17 /* memory using the default API */
18 my_memory_init ();
19
20 alloc = gst_allocator_find ("MyMemory");
21
22 gst_allocation_params_init (¶ms);
23 mem = gst_allocator_alloc (alloc, 1024, ¶ms);
24
25 gst_memory_map (mem, &info, GST_MAP_READ);
26 gst_memory_unmap (mem, &info);
27
28 gst_memory_unref (mem);
29 gst_object_unref (alloc);
30
31 /* allocator with custom alloc API */
32 my_vidmem_init ();
33
34 /* we can get the allocator but we can only make objects from it when we know
35 * the API */
36 alloc = gst_allocator_find ("MyVidmem");
37
38 /* use custom api to alloc */
39 mem = my_vidmem_alloc (0, 640, 480);
40 g_assert (my_is_vidmem (mem));
41
42 my_vidmem_get_format (mem, &f, &w, &h);
43 g_assert (f == 0);
44 g_assert (w == 640);
45 g_assert (h == 480);
46
47 gst_memory_map (mem, &info, GST_MAP_READ);
48 gst_memory_unmap (mem, &info);
49
50 gst_memory_unref (mem);
51 gst_object_unref (alloc);
52
53 return 0;
54 }
55