1 | /* GStreamer |
---|
2 | * |
---|
3 | * parent.c: test to check that setting state on a parent sets same state |
---|
4 | * recursively on children |
---|
5 | * |
---|
6 | * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org> |
---|
7 | * |
---|
8 | * This library is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU Library General Public |
---|
10 | * License as published by the Free Software Foundation; either |
---|
11 | * version 2 of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This library is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | * Library General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU Library General Public |
---|
19 | * License along with this library; if not, write to the |
---|
20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | * Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include <gst/gst.h> |
---|
25 | |
---|
26 | gint |
---|
27 | main (gint argc, gchar * argv[]) |
---|
28 | { |
---|
29 | GstElement *pipeline; |
---|
30 | GstElement *bin1, *bin2; |
---|
31 | GstElement *fakesrc, *identity, *fakesink; |
---|
32 | |
---|
33 | gst_init (&argc, &argv); |
---|
34 | |
---|
35 | /* |
---|
36 | * +-pipeline----------------------------------------+ |
---|
37 | * | +-bin2----------------------------------------+ | |
---|
38 | * | | +-bin1-----------------------+ | | |
---|
39 | * | | | +---------+ +----------+ | +----------+ | | |
---|
40 | * | | | | fakesrc |---| identity |---| fakesink | | | |
---|
41 | * | | | +---------+ +----------- | +----------+ | | |
---|
42 | * | | +----------------------------+ | | |
---|
43 | * | +---------------------------------------------+ | |
---|
44 | * +-------------------------------------------------+ |
---|
45 | */ |
---|
46 | |
---|
47 | pipeline = gst_pipeline_new ("pipeline"); |
---|
48 | g_assert (pipeline); |
---|
49 | bin1 = gst_bin_new ("bin1"); |
---|
50 | g_assert (bin1); |
---|
51 | bin2 = gst_bin_new ("bin2"); |
---|
52 | g_assert (bin2); |
---|
53 | |
---|
54 | fakesrc = gst_element_factory_make ("fakesrc", "fakesrc"); |
---|
55 | g_assert (fakesrc); |
---|
56 | g_object_set (G_OBJECT (fakesrc), "num_buffers", 5, NULL); |
---|
57 | identity = gst_element_factory_make ("identity", "identity"); |
---|
58 | g_assert (identity); |
---|
59 | fakesink = gst_element_factory_make ("fakesink", "fakesink"); |
---|
60 | g_assert (fakesink); |
---|
61 | |
---|
62 | gst_bin_add_many (GST_BIN (bin1), fakesrc, identity, NULL); |
---|
63 | g_assert (gst_element_link (fakesrc, identity)); |
---|
64 | |
---|
65 | gst_bin_add_many (GST_BIN (bin2), bin1, fakesink, NULL); |
---|
66 | g_assert (gst_element_link (identity, fakesink)); |
---|
67 | |
---|
68 | gst_bin_add (GST_BIN (pipeline), bin2); |
---|
69 | g_signal_connect (G_OBJECT (pipeline), "deep_notify", |
---|
70 | G_CALLBACK (gst_element_default_deep_notify), NULL); |
---|
71 | |
---|
72 | /* setting pipeline to READY should bring in all children to READY */ |
---|
73 | gst_element_set_state (pipeline, GST_STATE_READY); |
---|
74 | g_assert (GST_STATE (bin1) == GST_STATE_READY); |
---|
75 | g_assert (GST_STATE (bin2) == GST_STATE_READY); |
---|
76 | g_assert (GST_STATE (fakesrc) == GST_STATE_READY); |
---|
77 | g_assert (GST_STATE (identity) == GST_STATE_READY); |
---|
78 | g_assert (GST_STATE (fakesink) == GST_STATE_READY); |
---|
79 | |
---|
80 | /* setting fakesink to PAUSED should set pipeline and bin2 to PAUSED */ |
---|
81 | gst_element_set_state (fakesink, GST_STATE_PAUSED); |
---|
82 | g_assert (GST_STATE (bin1) == GST_STATE_READY); |
---|
83 | g_assert (GST_STATE (bin2) == GST_STATE_PAUSED); |
---|
84 | g_assert (GST_STATE (fakesrc) == GST_STATE_READY); |
---|
85 | g_assert (GST_STATE (identity) == GST_STATE_READY); |
---|
86 | g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED); |
---|
87 | |
---|
88 | /* setting fakesrc to PAUSED should set bin1 and fakesrc to PAUSED */ |
---|
89 | gst_element_set_state (fakesrc, GST_STATE_PAUSED); |
---|
90 | g_assert (GST_STATE (bin1) == GST_STATE_PAUSED); |
---|
91 | g_assert (GST_STATE (bin2) == GST_STATE_PAUSED); |
---|
92 | g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED); |
---|
93 | g_assert (GST_STATE (identity) == GST_STATE_READY); |
---|
94 | g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED); |
---|
95 | |
---|
96 | /* setting bin1 to PAUSED, even though it is already, should set |
---|
97 | * identity to PAUSED as well */ |
---|
98 | gst_element_set_state (bin1, GST_STATE_PAUSED); |
---|
99 | g_assert (GST_STATE (bin1) == GST_STATE_PAUSED); |
---|
100 | g_assert (GST_STATE (bin2) == GST_STATE_PAUSED); |
---|
101 | g_assert (GST_STATE (fakesrc) == GST_STATE_PAUSED); |
---|
102 | g_assert (GST_STATE (identity) == GST_STATE_PAUSED); |
---|
103 | g_assert (GST_STATE (fakesink) == GST_STATE_PAUSED); |
---|
104 | |
---|
105 | g_print ("passed.\n"); |
---|
106 | return 0; |
---|
107 | } |
---|