[svn r637] Added automake task to auto-indent all the source files.
10 static GMainLoop *mainloop = NULL;
12 static gint64 gap = 10;
15 MY_STREAM_TYPE_AUDIO = 0,
16 MY_STREAM_TYPE_VIDEO = 1
19 typedef struct _StreamData StreamData;
26 _stream_decode_pad_added_cb (GstElement *decode,
31 StreamData *data = (StreamData *) user_data;
34 GstCaps* caps = gst_pad_get_caps (pad);
35 gchar *str_caps = gst_caps_to_string (caps);
37 g_debug ("decode caps: [%d] [%s]", data->type, str_caps);
41 case MY_STREAM_TYPE_AUDIO:
43 if (strstr (str_caps, "audio") == NULL)
46 case MY_STREAM_TYPE_VIDEO:
48 if (strstr (str_caps, "video") == NULL)
53 queue = gst_bin_get_by_name (GST_BIN (data->bin), "queue");
54 sink_pad = gst_element_get_pad (queue, "sink");
56 if (gst_pad_link (pad, sink_pad) != GST_PAD_LINK_OK) {
57 g_warning ("Failed to link decode");
60 gst_object_unref (queue);
61 gst_object_unref (sink_pad);
66 gst_caps_unref (caps);
72 _create_src_element (const gchar* name,
86 g_debug ("element from uri: %s", uri);
88 bin = gst_bin_new ("bin");
89 src = gst_element_make_from_uri (GST_URI_SRC, uri, "src");
90 g_return_val_if_fail (src != NULL, NULL);
92 decode = gst_element_factory_make ("decodebin", NULL);
93 g_return_val_if_fail (decode != NULL, NULL);
95 queue = gst_element_factory_make ("queue", "queue");
96 g_return_val_if_fail (queue != NULL, NULL);
98 gst_bin_add_many (GST_BIN (bin), src, decode, queue, NULL);
99 gst_element_link (src, decode);
101 data = g_new0 (StreamData, 1);
104 g_debug ("Type : %d = %d", type, data->type);
106 g_signal_connect (G_OBJECT (decode), "new-decoded-pad",
107 G_CALLBACK (_stream_decode_pad_added_cb),
111 src_pad = gst_element_get_pad (queue, "src");
112 g_return_val_if_fail (src_pad != NULL, NULL);
114 gst_element_add_pad (bin,
115 gst_ghost_pad_new ("src", src_pad));
117 gst_object_unref (src_pad);
119 gnl_src = gst_element_factory_make ("gnlsource", name);
120 g_return_val_if_fail (gnl_src != NULL, NULL);
121 gst_bin_add (GST_BIN (gnl_src), bin);
123 g_debug ("ADDING WITH: START [%lli] DUR [%lli]", d, gap);
125 g_object_set (G_OBJECT (gnl_src),
127 "duration", 10 * GST_SECOND,
129 //"media-duration", 10 * GST_SECOND,
130 "priority", priority,
134 g_object_set (G_OBJECT (gnl_src),
135 "start", 10 * GST_SECOND,
136 "duration", 10 * GST_SECOND,
137 ///"media-start", 10 * GST_SECOND,
138 //"media-duration", 10 * GST_SECOND,
139 "priority", priority,
149 _composition_pad_added_cb (GstElement *composition,
153 GstPad *sink_pad = gst_element_get_pad (GST_ELEMENT (data), "sink");
154 g_debug ("compose pad added");
156 if (gst_pad_link (pad, sink_pad) != GST_PAD_LINK_OK) {
157 g_warning ("Failed to link decode");
160 g_debug ("Linked ok");
164 _compose_add_file (GstElement *compose,
172 src = _create_src_element (e_name, uri, type, priority);
173 gst_bin_add (GST_BIN (compose), src);
178 main (int argc, char** argv)
181 GstElement* gnl_compose_a;
182 GstElement* gnl_compose_v;
189 gst_init (&argc, &argv);
191 mainloop = g_main_loop_new (NULL, FALSE);
193 pipe = gst_pipeline_new ("test_pipeline");
195 gnl_compose_a = gst_element_factory_make ("gnlcomposition", "acompose");
196 g_return_val_if_fail (gnl_compose_a != NULL, 1);
198 gnl_compose_v = gst_element_factory_make ("gnlcomposition", "vcompose");
199 g_return_val_if_fail (gnl_compose_v != NULL, 1);
202 //_compose_add_file (gnl_compose_a, "src0", argv[1], MY_STREAM_TYPE_AUDIO, 1);
203 //_compose_add_file (gnl_compose_a, "src1", argv[2], MY_STREAM_TYPE_AUDIO, 1);
207 _compose_add_file (gnl_compose_v, "src2", argv[1], MY_STREAM_TYPE_VIDEO, 1);
208 _compose_add_file (gnl_compose_v, "src3", argv[2], MY_STREAM_TYPE_VIDEO, 1);
211 //aqueue = gst_element_factory_make ("queue", "aqueue");
212 //asink = gst_element_factory_make ("alsasink", "asink");
214 vqueue = gst_element_factory_make ("queue", "vqueue");
215 vsink = gst_element_factory_make ("xvimagesink", "vsink");
217 gst_bin_add_many (GST_BIN (pipe), gnl_compose_a, gnl_compose_v,
222 gst_element_link (vqueue, vsink);
223 //gst_element_link (aqueue, asink);
225 //g_signal_connect (G_OBJECT (gnl_compose_a), "pad-added",
226 // G_CALLBACK (_composition_pad_added_cb), aqueue);
228 g_signal_connect (G_OBJECT (gnl_compose_v), "pad-added",
229 G_CALLBACK (_composition_pad_added_cb), vqueue);
232 //g_idle_add (_play, pipe);
233 gst_element_set_state (GST_ELEMENT (pipe), GST_STATE_PLAYING);
234 g_main_loop_run (mainloop);