[svn r820] Added gmyth_scheduler_add_exception() function to remove only one schedule when all occurrences options has been used.
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,
27 GstPad * pad, gboolean arg1,
30 StreamData *data = (StreamData *) user_data;
33 GstCaps *caps = gst_pad_get_caps(pad);
34 gchar *str_caps = gst_caps_to_string(caps);
36 g_debug("decode caps: [%d] [%s]", data->type, str_caps);
39 case MY_STREAM_TYPE_AUDIO:
41 if (strstr(str_caps, "audio") == NULL)
44 case MY_STREAM_TYPE_VIDEO:
46 if (strstr(str_caps, "video") == NULL)
51 queue = gst_bin_get_by_name(GST_BIN(data->bin), "queue");
52 sink_pad = gst_element_get_pad(queue, "sink");
54 if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) {
55 g_warning("Failed to link decode");
58 gst_object_unref(queue);
59 gst_object_unref(sink_pad);
70 _create_src_element(const gchar * name,
71 const gchar * uri, MyStreamType type, guint priority)
82 g_debug("element from uri: %s", uri);
84 bin = gst_bin_new("bin");
85 src = gst_element_make_from_uri(GST_URI_SRC, uri, "src");
86 g_return_val_if_fail(src != NULL, NULL);
88 decode = gst_element_factory_make("decodebin", NULL);
89 g_return_val_if_fail(decode != NULL, NULL);
91 queue = gst_element_factory_make("queue", "queue");
92 g_return_val_if_fail(queue != NULL, NULL);
94 gst_bin_add_many(GST_BIN(bin), src, decode, queue, NULL);
95 gst_element_link(src, decode);
97 data = g_new0(StreamData, 1);
100 g_debug("Type : %d = %d", type, data->type);
102 g_signal_connect(G_OBJECT(decode), "new-decoded-pad",
103 G_CALLBACK(_stream_decode_pad_added_cb), data);
106 src_pad = gst_element_get_pad(queue, "src");
107 g_return_val_if_fail(src_pad != NULL, NULL);
109 gst_element_add_pad(bin, gst_ghost_pad_new("src", src_pad));
111 gst_object_unref(src_pad);
113 gnl_src = gst_element_factory_make("gnlsource", name);
114 g_return_val_if_fail(gnl_src != NULL, NULL);
115 gst_bin_add(GST_BIN(gnl_src), bin);
117 g_debug("ADDING WITH: START [%lli] DUR [%lli]", d, gap);
119 g_object_set(G_OBJECT(gnl_src),
121 "duration", 10 * GST_SECOND,
122 // "media-start", 0L,
123 // "media-duration", 10 * GST_SECOND,
124 "priority", priority, NULL);
127 g_object_set(G_OBJECT(gnl_src),
128 "start", 10 * GST_SECOND, "duration", 10 * GST_SECOND,
129 // /"media-start", 10 * GST_SECOND,
130 // "media-duration", 10 * GST_SECOND,
131 "priority", priority, NULL);
140 _composition_pad_added_cb(GstElement * composition,
141 GstPad * pad, gpointer data)
144 gst_element_get_pad(GST_ELEMENT(data), "sink");
145 g_debug("compose pad added");
147 if (gst_pad_link(pad, sink_pad) != GST_PAD_LINK_OK) {
148 g_warning("Failed to link decode");
151 g_debug("Linked ok");
155 _compose_add_file(GstElement * compose,
156 const gchar * e_name,
157 const gchar * uri, MyStreamType type, guint priority)
161 src = _create_src_element(e_name, uri, type, priority);
162 gst_bin_add(GST_BIN(compose), src);
167 main(int argc, char **argv)
170 GstElement *gnl_compose_a;
171 GstElement *gnl_compose_v;
178 gst_init(&argc, &argv);
180 mainloop = g_main_loop_new(NULL, FALSE);
182 pipe = gst_pipeline_new("test_pipeline");
184 gnl_compose_a = gst_element_factory_make("gnlcomposition", "acompose");
185 g_return_val_if_fail(gnl_compose_a != NULL, 1);
187 gnl_compose_v = gst_element_factory_make("gnlcomposition", "vcompose");
188 g_return_val_if_fail(gnl_compose_v != NULL, 1);
191 // _compose_add_file (gnl_compose_a, "src0", argv[1],
192 // MY_STREAM_TYPE_AUDIO, 1);
193 // _compose_add_file (gnl_compose_a, "src1", argv[2],
194 // MY_STREAM_TYPE_AUDIO, 1);
198 _compose_add_file(gnl_compose_v, "src2", argv[1], MY_STREAM_TYPE_VIDEO,
200 _compose_add_file(gnl_compose_v, "src3", argv[2], MY_STREAM_TYPE_VIDEO,
204 // aqueue = gst_element_factory_make ("queue", "aqueue");
205 // asink = gst_element_factory_make ("alsasink", "asink");
207 vqueue = gst_element_factory_make("queue", "vqueue");
208 vsink = gst_element_factory_make("xvimagesink", "vsink");
210 gst_bin_add_many(GST_BIN(pipe), gnl_compose_a, gnl_compose_v, vqueue,
215 gst_element_link(vqueue, vsink);
216 // gst_element_link (aqueue, asink);
218 // g_signal_connect (G_OBJECT (gnl_compose_a), "pad-added",
219 // G_CALLBACK (_composition_pad_added_cb), aqueue);
221 g_signal_connect(G_OBJECT(gnl_compose_v), "pad-added",
222 G_CALLBACK(_composition_pad_added_cb), vqueue);
225 // g_idle_add (_play, pipe);
226 gst_element_set_state(GST_ELEMENT(pipe), GST_STATE_PLAYING);
227 g_main_loop_run(mainloop);