2001-05-25 21:00:07 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2003-10-15 01:25:41 +00:00
|
|
|
#define ITERS 100
|
2001-05-25 21:00:07 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "mem.h"
|
|
|
|
|
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
main (int argc, gchar * argv[])
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
|
|
|
GstElement *element;
|
|
|
|
GstElement *element2;
|
|
|
|
GstPad *pad;
|
|
|
|
long usage1;
|
|
|
|
gint i, iters;
|
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
iters = atoi (argv[1]);
|
|
|
|
else
|
|
|
|
iters = ITERS;
|
|
|
|
|
|
|
|
g_print ("starting element with pad test with %d iterations\n", iters);
|
2004-03-13 15:27:01 +00:00
|
|
|
usage1 = vmsize ();
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_PAD (pad));
|
2005-03-09 17:30:43 +00:00
|
|
|
g_assert (GST_OBJECT_IS_FLOATING (element));
|
|
|
|
g_assert (!GST_OBJECT_IS_FLOATING (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
g_assert (gst_pad_get_parent (pad) == element);
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
2004-04-13 10:44:29 +00:00
|
|
|
g_print ("create/addpad/unref 1 new element: %ld\n", vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters; i++) {
|
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
2004-04-13 10:44:29 +00:00
|
|
|
g_print ("create/unref %d elements: %ld\n", iters, vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters / 2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2002-05-11 20:30:05 +00:00
|
|
|
element2 = gst_element_factory_make ("fakesrc", NULL);
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element2));
|
|
|
|
gst_element_link_pads (element2, "src", element, "sink");
|
2003-01-10 04:54:20 +00:00
|
|
|
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
|
|
|
|
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink")));
|
2003-04-15 18:17:24 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
2003-01-10 04:54:20 +00:00
|
|
|
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element2));
|
|
|
|
}
|
2004-04-13 10:44:29 +00:00
|
|
|
g_print ("create/link/unref %d element duos: %ld\n", iters / 2,
|
2004-03-13 15:27:01 +00:00
|
|
|
vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_PAD (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_remove_pad (element, pad);
|
|
|
|
g_assert (gst_element_get_pad (element, "sink") == NULL);
|
2004-04-13 10:44:29 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
|
|
|
|
g_print ("pad removal on one element: %ld\n", vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters / 2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_PAD (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_element_remove_pad (element, pad);
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (gst_element_get_pad (element, "sink") == NULL);
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
2004-04-13 10:44:29 +00:00
|
|
|
g_print ("pad removal loop on %d elements: %ld\n", iters / 2,
|
|
|
|
vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters / 2; i++) {
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_PAD (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_ref (GST_OBJECT (pad));
|
|
|
|
gst_element_remove_pad (element, pad);
|
|
|
|
g_assert (gst_pad_get_parent (pad) == NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (pad));
|
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
2004-04-13 10:44:29 +00:00
|
|
|
g_print ("pad ref/removal/test loop on %d elements: %ld\n", iters / 2,
|
2004-03-13 15:27:01 +00:00
|
|
|
vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);;
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_PAD (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
|
2004-04-13 10:44:29 +00:00
|
|
|
g_print ("pad unref on one element: %ld\n", vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < iters / 2; i++) {
|
2004-04-13 10:44:29 +00:00
|
|
|
element = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
g_assert (GST_IS_ELEMENT (element));
|
2001-05-25 21:00:07 +00:00
|
|
|
pad = gst_element_get_pad (element, "sink");
|
2004-04-13 10:44:29 +00:00
|
|
|
g_assert (GST_IS_PAD (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
gst_object_unref (GST_OBJECT (element));
|
|
|
|
}
|
2004-04-13 10:44:29 +00:00
|
|
|
g_print ("pad unref loop on %d elements: %ld\n", iters / 2,
|
|
|
|
vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("leaked: %ld\n", vmsize () - usage1);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-04-15 04:54:53 +00:00
|
|
|
return 0;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|