1 | #include <gst/gst.h> |
---|
2 | |
---|
3 | #define ITERS 100 |
---|
4 | #include <stdlib.h> |
---|
5 | #include "mem.h" |
---|
6 | |
---|
7 | int |
---|
8 | main (int argc, gchar * argv[]) |
---|
9 | { |
---|
10 | GstElement *element; |
---|
11 | GstElement *element2; |
---|
12 | GstPad *pad; |
---|
13 | long usage1; |
---|
14 | gint i, iters; |
---|
15 | |
---|
16 | gst_init (&argc, &argv); |
---|
17 | |
---|
18 | if (argc == 2) |
---|
19 | iters = atoi (argv[1]); |
---|
20 | else |
---|
21 | iters = ITERS; |
---|
22 | |
---|
23 | g_print ("starting element with pad test with %d iterations\n", iters); |
---|
24 | usage1 = vmsize (); |
---|
25 | |
---|
26 | element = gst_element_factory_make ("fakesink", NULL);; |
---|
27 | g_assert (GST_IS_ELEMENT (element)); |
---|
28 | pad = gst_element_get_pad (element, "sink"); |
---|
29 | g_assert (GST_IS_PAD (pad)); |
---|
30 | g_assert (GST_OBJECT_FLOATING (element)); |
---|
31 | g_assert (!GST_OBJECT_FLOATING (pad)); |
---|
32 | g_assert (gst_pad_get_parent (pad) == element); |
---|
33 | gst_object_unref (GST_OBJECT (element)); |
---|
34 | g_print ("create/addpad/unref 1 new element: %ld\n", vmsize () - usage1); |
---|
35 | |
---|
36 | for (i = 0; i < iters; i++) { |
---|
37 | element = gst_element_factory_make ("fakesink", NULL);; |
---|
38 | g_assert (GST_IS_ELEMENT (element)); |
---|
39 | gst_object_unref (GST_OBJECT (element)); |
---|
40 | } |
---|
41 | g_print ("create/unref %d elements: %ld\n", iters, vmsize () - usage1); |
---|
42 | |
---|
43 | for (i = 0; i < iters / 2; i++) { |
---|
44 | element = gst_element_factory_make ("fakesink", NULL); |
---|
45 | g_assert (GST_IS_ELEMENT (element)); |
---|
46 | element2 = gst_element_factory_make ("fakesrc", NULL); |
---|
47 | g_assert (GST_IS_ELEMENT (element2)); |
---|
48 | gst_element_link_pads (element2, "src", element, "sink"); |
---|
49 | g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src"))); |
---|
50 | g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink"))); |
---|
51 | gst_object_unref (GST_OBJECT (element)); |
---|
52 | g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src"))); |
---|
53 | gst_object_unref (GST_OBJECT (element2)); |
---|
54 | } |
---|
55 | g_print ("create/link/unref %d element duos: %ld\n", iters / 2, |
---|
56 | vmsize () - usage1); |
---|
57 | |
---|
58 | element = gst_element_factory_make ("fakesink", NULL);; |
---|
59 | g_assert (GST_IS_ELEMENT (element)); |
---|
60 | pad = gst_element_get_pad (element, "sink"); |
---|
61 | g_assert (GST_IS_PAD (pad)); |
---|
62 | gst_element_remove_pad (element, pad); |
---|
63 | g_assert (gst_element_get_pad (element, "sink") == NULL); |
---|
64 | gst_object_unref (GST_OBJECT (element)); |
---|
65 | |
---|
66 | g_print ("pad removal on one element: %ld\n", vmsize () - usage1); |
---|
67 | |
---|
68 | for (i = 0; i < iters / 2; i++) { |
---|
69 | element = gst_element_factory_make ("fakesink", NULL);; |
---|
70 | g_assert (GST_IS_ELEMENT (element)); |
---|
71 | pad = gst_element_get_pad (element, "sink"); |
---|
72 | g_assert (GST_IS_PAD (pad)); |
---|
73 | gst_element_remove_pad (element, pad); |
---|
74 | g_assert (gst_element_get_pad (element, "sink") == NULL); |
---|
75 | gst_object_unref (GST_OBJECT (element)); |
---|
76 | } |
---|
77 | g_print ("pad removal loop on %d elements: %ld\n", iters / 2, |
---|
78 | vmsize () - usage1); |
---|
79 | |
---|
80 | for (i = 0; i < iters / 2; i++) { |
---|
81 | element = gst_element_factory_make ("fakesink", NULL);; |
---|
82 | g_assert (GST_IS_ELEMENT (element)); |
---|
83 | pad = gst_element_get_pad (element, "sink"); |
---|
84 | g_assert (GST_IS_PAD (pad)); |
---|
85 | gst_object_ref (GST_OBJECT (pad)); |
---|
86 | gst_element_remove_pad (element, pad); |
---|
87 | g_assert (gst_pad_get_parent (pad) == NULL); |
---|
88 | gst_object_unref (GST_OBJECT (pad)); |
---|
89 | gst_object_unref (GST_OBJECT (element)); |
---|
90 | } |
---|
91 | g_print ("pad ref/removal/test loop on %d elements: %ld\n", iters / 2, |
---|
92 | vmsize () - usage1); |
---|
93 | |
---|
94 | element = gst_element_factory_make ("fakesink", NULL);; |
---|
95 | g_assert (GST_IS_ELEMENT (element)); |
---|
96 | pad = gst_element_get_pad (element, "sink"); |
---|
97 | g_assert (GST_IS_PAD (pad)); |
---|
98 | gst_object_unref (GST_OBJECT (element)); |
---|
99 | |
---|
100 | g_print ("pad unref on one element: %ld\n", vmsize () - usage1); |
---|
101 | |
---|
102 | for (i = 0; i < iters / 2; i++) { |
---|
103 | element = gst_element_factory_make ("fakesink", NULL); |
---|
104 | g_assert (GST_IS_ELEMENT (element)); |
---|
105 | pad = gst_element_get_pad (element, "sink"); |
---|
106 | g_assert (GST_IS_PAD (pad)); |
---|
107 | gst_object_unref (GST_OBJECT (element)); |
---|
108 | } |
---|
109 | g_print ("pad unref loop on %d elements: %ld\n", iters / 2, |
---|
110 | vmsize () - usage1); |
---|
111 | |
---|
112 | g_print ("leaked: %ld\n", vmsize () - usage1); |
---|
113 | |
---|
114 | return 0; |
---|
115 | } |
---|