source: trunk/third/gstreamer/testsuite/elements/property.c @ 21005

Revision 21005, 2.0 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * test for setting and getting of object properties
3 * creates a fakesrc
4 * sets silent (boolean), name (string), and sizemin (int)
5 * then retrieves the set values and compares
6 * thomas@apestaart.org
7 * originally written for 0.4.0
8 */
9
10#include <string.h>
11#include <gst/gst.h>
12
13GstElement *
14element_create (char *name, char *element)
15  /*
16   * create the element
17   * print an error if it can't be created
18   * return NULL if it couldn't be created
19   * return element if it did work
20   */
21{
22  GstElement *el = NULL;
23
24  el = (GstElement *) gst_element_factory_make (element, name);
25  if (el == NULL) {
26    fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
27    return NULL;
28  } else
29    return el;
30}
31
32int
33main (int argc, char *argv[])
34{
35  GstElement *src;
36  gint retval = 0;
37  gboolean silent_set, silent_get;
38  gint sizemin_set, sizemin_get;
39  gchar *name_set, *name_get;
40
41  /* init */
42  gst_init (&argc, &argv);
43
44  /* create */
45  g_print ("Creating element\n");
46  if (!(src = element_create ("src", "fakesrc")))
47    return 1;
48
49  /* set */
50  silent_set = TRUE;
51  sizemin_set = 1;
52  name_set = g_strdup_printf ("test");
53
54  gst_element_set (src,
55      "name", name_set, "sizemin", sizemin_set, "silent", silent_set, NULL);
56  /* get */
57  gst_element_get (src,
58      "name", &name_get, "sizemin", &sizemin_get, "silent", &silent_get, NULL);
59
60  /* compare */
61  if (sizemin_set != sizemin_get) {
62    g_print ("sizemin: set value %d differs from returned value %d\n",
63        sizemin_set, sizemin_get);
64    retval = 1;
65  } else
66    g_print ("name: set right\n");
67
68  if (silent_set != silent_get) {
69    g_print ("silent: set value %s differs from returned value %s\n",
70        silent_set ? "TRUE" : "FALSE", silent_get ? "TRUE" : "FALSE");
71    retval = 1;
72  } else
73    g_print ("silent: set right\n");
74
75  if (strcmp (name_set, name_get) != 0) {
76    g_print ("name: set value %s differs from returned value %s\n",
77        name_set, name_get);
78    retval = 1;
79  } else
80    g_print ("name: set right\n");
81
82  return retval;
83}
Note: See TracBrowser for help on using the repository browser.