File: memory_test.c

package info (click to toggle)
gstreamer1.0 1.28.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,604 kB
  • sloc: ansic: 203,072; python: 1,985; sh: 566; lex: 188; lisp: 154; java: 81; makefile: 59; cpp: 58; perl: 46
file content (54 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <gst/gst.h>

#include "my-memory.h"
#include "my-vidmem.h"

int
main (int argc, char **argv)
{
  GstAllocator *alloc;
  GstMemory *mem;
  GstAllocationParams params;
  GstMapInfo info;
  guint f, w, h;

  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_object_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_object_unref (alloc);

  return 0;
}