source: trunk/third/gstreamer/testsuite/threads/159566.c @ 21448

Revision 21448, 2.3 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21447, which included commits to RCS files with non-trunk default branches.
Line 
1#include <string.h>
2#include <unistd.h>
3#include <gst/gst.h>
4
5static GstElement *src1, *sink1;
6static gboolean need_src1 = TRUE;
7static gint iter = 0;
8
9static void
10object_deep_notify (GObject * object, GstObject * orig,
11    GParamSpec * pspec, gchar ** excluded_props)
12{
13  GValue value = { 0, };        /* the important thing is that value.type = 0 */
14  gchar *str = NULL;
15
16  if (strcmp (pspec->name, "last-message") != 0)
17    return;
18
19  if (GST_ELEMENT (orig) != src1 && GST_ELEMENT (orig) != sink1)
20    return;
21
22  g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
23  g_object_get_property (G_OBJECT (orig), pspec->name, &value);
24
25  str = g_strdup_value_contents (&value);
26  g_value_unset (&value);
27
28  if (strstr (str, "E (type:") != NULL) {
29    g_free (str);
30    return;
31  }
32
33  if (iter++ == 100) {
34    g_print (".");
35    iter = 0;
36  }
37  g_free (str);
38  if (need_src1 && GST_ELEMENT (orig) != src1) {
39    g_assert_not_reached ();
40  } else if (!need_src1 && GST_ELEMENT (orig) != sink1) {
41    g_assert_not_reached ();
42  }
43  need_src1 = !need_src1;
44}
45
46
47int
48main (int argc, char **argv)
49{
50  GstElement *thread1, *thread2, *pipeline;
51  GstElement *src2, *sink2;
52
53  gst_init (&argc, &argv);
54
55  pipeline = gst_element_factory_make ("pipeline", "pipeline");
56  thread1 = gst_element_factory_make ("thread", "thread1");
57  g_assert (thread1);
58
59  src1 = gst_element_factory_make ("fakesrc", "src1");
60  g_assert (src1);
61  sink1 = gst_element_factory_make ("fakesink", "sink1");
62  g_assert (sink1);
63
64  thread2 = gst_element_factory_make ("thread", "thread2");
65  g_assert (thread2);
66
67  src2 = gst_element_factory_make ("fakesrc", "src2");
68  g_assert (src2);
69  sink2 = gst_element_factory_make ("fakesink", "sink2");
70  g_assert (sink2);
71
72  gst_bin_add_many (GST_BIN (thread1), src1, sink1, NULL);
73  gst_bin_add_many (GST_BIN (thread2), src2, sink2, NULL);
74
75  gst_bin_add (GST_BIN (pipeline), thread1);
76  gst_bin_add (GST_BIN (pipeline), thread2);
77
78  g_signal_connect (G_OBJECT (pipeline), "deep_notify",
79      G_CALLBACK (object_deep_notify), NULL);
80
81  if (!gst_element_link_many (src1, sink1, NULL))
82    g_assert_not_reached ();
83
84  if (!gst_element_link_many (src2, sink2, NULL))
85    g_assert_not_reached ();
86
87  /* run a bit */
88  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
89    g_assert_not_reached ();
90
91  sleep (10000);
92  g_print ("done\n");
93
94  return 0;
95}
Note: See TracBrowser for help on using the repository browser.