3 * seek.c: seeking sample application
5 * Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
6 * 2006 Stefan Kost <ensonic@users.sf.net>
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.
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.
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.
23 /* FIXME: remove #if 0 code
32 GST_DEBUG_CATEGORY_STATIC (seek_debug);
33 #define GST_CAT_DEFAULT (seek_debug)
37 //#define SOURCE "filesrc"
38 #define SOURCE "gnomevfssrc"
40 #define ASINK "alsasink"
41 //#define ASINK "osssink"
43 #define VSINK "xvimagesink"
44 //#define VSINK "sdlvideosink"
45 //#define VSINK "ximagesink"
46 //#define VSINK "aasink"
47 //#define VSINK "cacasink"
49 //#define UPDATE_INTERVAL 500
50 //#define UPDATE_INTERVAL 100
51 #define UPDATE_INTERVAL 10
53 /* number of milliseconds to play for after a seek */
54 #define SCRUB_TIME 100
56 /* timeout for gst_element_get_state() after a seek */
57 #define SEEK_TIMEOUT 40 * GST_MSECOND
60 static GList *seekable_pads = NULL;
61 static GList *rate_pads = NULL;
62 static GList *seekable_elements = NULL;
64 static gboolean accurate_seek = FALSE;
65 static gboolean keyframe_seek = FALSE;
66 static gboolean loop_seek = FALSE;
67 static gboolean flush_seek = TRUE;
68 static gboolean scrub = TRUE;
69 static gboolean play_scrub = FALSE;
70 static gdouble rate = 1.0;
72 static GstElement *pipeline;
73 static gint pipeline_type;
74 static const gchar *pipeline_spec;
75 static gint64 position = -1;
76 static gint64 duration = -1;
77 static GtkAdjustment *adjustment;
78 static GtkWidget *hscale;
79 static gboolean stats = FALSE;
80 static gboolean elem_seek = FALSE;
81 static gboolean verbose = FALSE;
83 static GstState state = GST_STATE_NULL;
84 static guint update_id = 0;
85 static guint seek_timeout_id = 0;
86 static gulong changed_id;
88 static gint n_video = 0, n_audio = 0, n_text = 0;
89 static gboolean need_streams = TRUE;
90 static GtkWidget *video_combo, *audio_combo, *text_combo, *vis_combo;
91 static GtkWidget *vis_checkbox, *video_checkbox, *audio_checkbox;
92 static GtkWidget *text_checkbox, *mute_checkbox, *volume_spinbutton;
94 /* we keep an array of the visualisation entries so that we can easily switch
95 * with the combo box index. */
98 GstElementFactory *factory;
101 static GArray *vis_entries;
103 static void clear_streams (GstElement * pipeline);
105 /* pipeline construction */
109 const gchar *padname;
116 gst_element_factory_make_or_warn (gchar * type, gchar * name)
118 GstElement *element = gst_element_factory_make (type, name);
121 g_warning ("Failed to create element %s of type %s", name, type);
128 dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
131 dyn_link *connect = (dyn_link *) data;
133 padname = gst_pad_get_name (newpad);
135 if (connect->padname == NULL || !strcmp (padname, connect->padname)) {
137 gst_bin_add (GST_BIN (pipeline), connect->bin);
138 gst_pad_link (newpad, connect->target);
140 //seekable_pads = g_list_prepend (seekable_pads, newpad);
141 rate_pads = g_list_prepend (rate_pads, newpad);
147 setup_dynamic_link (GstElement * element, const gchar * padname,
148 GstPad * target, GstElement * bin)
152 connect = g_new0 (dyn_link, 1);
153 connect->padname = g_strdup (padname);
154 connect->target = target;
157 g_signal_connect (G_OBJECT (element), "pad-added", G_CALLBACK (dynamic_link),
162 make_mod_pipeline (const gchar * location)
164 GstElement *pipeline;
165 GstElement *src, *decoder, *audiosink;
168 pipeline = gst_pipeline_new ("app");
170 src = gst_element_factory_make_or_warn (SOURCE, "src");
171 decoder = gst_element_factory_make_or_warn ("modplug", "decoder");
172 audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
173 //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
175 g_object_set (G_OBJECT (src), "location", location, NULL);
177 gst_bin_add (GST_BIN (pipeline), src);
178 gst_bin_add (GST_BIN (pipeline), decoder);
179 gst_bin_add (GST_BIN (pipeline), audiosink);
181 gst_element_link (src, decoder);
182 gst_element_link (decoder, audiosink);
184 seekable = gst_element_get_pad (decoder, "src");
185 seekable_pads = g_list_prepend (seekable_pads, seekable);
186 rate_pads = g_list_prepend (rate_pads, seekable);
187 rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink"));
193 make_dv_pipeline (const gchar * location)
195 GstElement *pipeline;
196 GstElement *src, *demux, *decoder, *audiosink, *videosink;
197 GstElement *a_queue, *v_queue;
200 pipeline = gst_pipeline_new ("app");
202 src = gst_element_factory_make_or_warn (SOURCE, "src");
203 demux = gst_element_factory_make_or_warn ("dvdemux", "demuxer");
204 v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
205 decoder = gst_element_factory_make_or_warn ("ffdec_dvvideo", "decoder");
206 videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
207 a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
208 audiosink = gst_element_factory_make_or_warn ("alsasink", "a_sink");
210 g_object_set (G_OBJECT (src), "location", location, NULL);
212 gst_bin_add (GST_BIN (pipeline), src);
213 gst_bin_add (GST_BIN (pipeline), demux);
214 gst_bin_add (GST_BIN (pipeline), a_queue);
215 gst_bin_add (GST_BIN (pipeline), audiosink);
216 gst_bin_add (GST_BIN (pipeline), v_queue);
217 gst_bin_add (GST_BIN (pipeline), decoder);
218 gst_bin_add (GST_BIN (pipeline), videosink);
220 gst_element_link (src, demux);
221 gst_element_link (a_queue, audiosink);
222 gst_element_link (v_queue, decoder);
223 gst_element_link (decoder, videosink);
225 setup_dynamic_link (demux, "video", gst_element_get_pad (v_queue, "sink"),
227 setup_dynamic_link (demux, "audio", gst_element_get_pad (a_queue, "sink"),
230 seekable = gst_element_get_pad (decoder, "src");
231 seekable_pads = g_list_prepend (seekable_pads, seekable);
232 rate_pads = g_list_prepend (rate_pads, seekable);
238 make_wav_pipeline (const gchar * location)
240 GstElement *pipeline;
241 GstElement *src, *decoder, *audiosink;
243 pipeline = gst_pipeline_new ("app");
245 src = gst_element_factory_make_or_warn (SOURCE, "src");
246 decoder = gst_element_factory_make_or_warn ("wavparse", "decoder");
247 audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
249 g_object_set (G_OBJECT (src), "location", location, NULL);
251 gst_bin_add (GST_BIN (pipeline), src);
252 gst_bin_add (GST_BIN (pipeline), decoder);
253 gst_bin_add (GST_BIN (pipeline), audiosink);
255 gst_element_link (src, decoder);
257 setup_dynamic_link (decoder, "src", gst_element_get_pad (audiosink, "sink"),
260 seekable_elements = g_list_prepend (seekable_elements, audiosink);
262 /* force element seeking on this pipeline */
269 make_flac_pipeline (const gchar * location)
271 GstElement *pipeline;
272 GstElement *src, *decoder, *audiosink;
275 pipeline = gst_pipeline_new ("app");
277 src = gst_element_factory_make_or_warn (SOURCE, "src");
278 decoder = gst_element_factory_make_or_warn ("flacdec", "decoder");
279 audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
280 g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
282 g_object_set (G_OBJECT (src), "location", location, NULL);
284 gst_bin_add (GST_BIN (pipeline), src);
285 gst_bin_add (GST_BIN (pipeline), decoder);
286 gst_bin_add (GST_BIN (pipeline), audiosink);
288 gst_element_link (src, decoder);
289 gst_element_link (decoder, audiosink);
291 seekable = gst_element_get_pad (decoder, "src");
292 seekable_pads = g_list_prepend (seekable_pads, seekable);
293 rate_pads = g_list_prepend (rate_pads, seekable);
294 rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink"));
300 make_sid_pipeline (const gchar * location)
302 GstElement *pipeline;
303 GstElement *src, *decoder, *audiosink;
306 pipeline = gst_pipeline_new ("app");
308 src = gst_element_factory_make_or_warn (SOURCE, "src");
309 decoder = gst_element_factory_make_or_warn ("siddec", "decoder");
310 audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
311 //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
313 g_object_set (G_OBJECT (src), "location", location, NULL);
315 gst_bin_add (GST_BIN (pipeline), src);
316 gst_bin_add (GST_BIN (pipeline), decoder);
317 gst_bin_add (GST_BIN (pipeline), audiosink);
319 gst_element_link (src, decoder);
320 gst_element_link (decoder, audiosink);
322 seekable = gst_element_get_pad (decoder, "src");
323 seekable_pads = g_list_prepend (seekable_pads, seekable);
324 rate_pads = g_list_prepend (rate_pads, seekable);
325 rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink"));
331 make_parse_pipeline (const gchar * location)
333 GstElement *pipeline;
334 GstElement *src, *parser, *fakesink;
337 pipeline = gst_pipeline_new ("app");
339 src = gst_element_factory_make_or_warn (SOURCE, "src");
340 parser = gst_element_factory_make_or_warn ("mpegparse", "parse");
341 fakesink = gst_element_factory_make_or_warn ("fakesink", "sink");
342 g_object_set (G_OBJECT (fakesink), "silent", TRUE, NULL);
343 g_object_set (G_OBJECT (fakesink), "sync", TRUE, NULL);
345 g_object_set (G_OBJECT (src), "location", location, NULL);
347 gst_bin_add (GST_BIN (pipeline), src);
348 gst_bin_add (GST_BIN (pipeline), parser);
349 gst_bin_add (GST_BIN (pipeline), fakesink);
351 gst_element_link (src, parser);
352 gst_element_link (parser, fakesink);
354 seekable = gst_element_get_pad (parser, "src");
355 seekable_pads = g_list_prepend (seekable_pads, seekable);
356 rate_pads = g_list_prepend (rate_pads, seekable);
357 rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (parser, "sink"));
363 make_vorbis_pipeline (const gchar * location)
365 GstElement *pipeline, *audio_bin;
366 GstElement *src, *demux, *decoder, *convert, *audiosink;
367 GstPad *pad, *seekable;
369 pipeline = gst_pipeline_new ("app");
371 src = gst_element_factory_make_or_warn (SOURCE, "src");
372 demux = gst_element_factory_make_or_warn ("oggdemux", "demux");
373 decoder = gst_element_factory_make_or_warn ("vorbisdec", "decoder");
374 convert = gst_element_factory_make_or_warn ("audioconvert", "convert");
375 audiosink = gst_element_factory_make_or_warn (ASINK, "sink");
376 g_object_set (G_OBJECT (audiosink), "sync", TRUE, NULL);
378 g_object_set (G_OBJECT (src), "location", location, NULL);
380 audio_bin = gst_bin_new ("a_decoder_bin");
382 gst_bin_add (GST_BIN (pipeline), src);
383 gst_bin_add (GST_BIN (pipeline), demux);
384 gst_bin_add (GST_BIN (audio_bin), decoder);
385 gst_bin_add (GST_BIN (audio_bin), convert);
386 gst_bin_add (GST_BIN (audio_bin), audiosink);
387 gst_bin_add (GST_BIN (pipeline), audio_bin);
389 gst_element_link (src, demux);
390 gst_element_link (decoder, convert);
391 gst_element_link (convert, audiosink);
393 pad = gst_element_get_pad (decoder, "sink");
394 gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
395 gst_object_unref (pad);
397 setup_dynamic_link (demux, NULL, gst_element_get_pad (audio_bin, "sink"),
400 seekable = gst_element_get_pad (decoder, "src");
401 seekable_pads = g_list_prepend (seekable_pads, seekable);
402 rate_pads = g_list_prepend (rate_pads, seekable);
403 rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink"));
409 make_theora_pipeline (const gchar * location)
411 GstElement *pipeline, *video_bin;
412 GstElement *src, *demux, *decoder, *convert, *videosink;
413 GstPad *pad, *seekable;
415 pipeline = gst_pipeline_new ("app");
417 src = gst_element_factory_make_or_warn (SOURCE, "src");
418 demux = gst_element_factory_make_or_warn ("oggdemux", "demux");
419 decoder = gst_element_factory_make_or_warn ("theoradec", "decoder");
420 convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "convert");
421 videosink = gst_element_factory_make_or_warn (VSINK, "sink");
423 g_object_set (G_OBJECT (src), "location", location, NULL);
425 video_bin = gst_bin_new ("v_decoder_bin");
427 gst_bin_add (GST_BIN (pipeline), src);
428 gst_bin_add (GST_BIN (pipeline), demux);
429 gst_bin_add (GST_BIN (video_bin), decoder);
430 gst_bin_add (GST_BIN (video_bin), convert);
431 gst_bin_add (GST_BIN (video_bin), videosink);
432 gst_bin_add (GST_BIN (pipeline), video_bin);
434 gst_element_link (src, demux);
435 gst_element_link (decoder, convert);
436 gst_element_link (convert, videosink);
438 pad = gst_element_get_pad (decoder, "sink");
439 gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
440 gst_object_unref (pad);
442 setup_dynamic_link (demux, NULL, gst_element_get_pad (video_bin, "sink"),
445 seekable = gst_element_get_pad (decoder, "src");
446 seekable_pads = g_list_prepend (seekable_pads, seekable);
447 rate_pads = g_list_prepend (rate_pads, seekable);
448 rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink"));
454 make_vorbis_theora_pipeline (const gchar * location)
456 GstElement *pipeline, *audio_bin, *video_bin;
457 GstElement *src, *demux, *a_decoder, *a_convert, *v_decoder, *v_convert;
458 GstElement *audiosink, *videosink;
459 GstElement *a_queue, *v_queue, *v_scale;
463 pipeline = gst_pipeline_new ("app");
465 src = gst_element_factory_make_or_warn (SOURCE, "src");
466 g_object_set (G_OBJECT (src), "location", location, NULL);
468 demux = gst_element_factory_make_or_warn ("oggdemux", "demux");
470 gst_bin_add (GST_BIN (pipeline), src);
471 gst_bin_add (GST_BIN (pipeline), demux);
472 gst_element_link (src, demux);
474 audio_bin = gst_bin_new ("a_decoder_bin");
475 a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
476 a_decoder = gst_element_factory_make_or_warn ("vorbisdec", "a_dec");
477 a_convert = gst_element_factory_make_or_warn ("audioconvert", "a_convert");
478 audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
480 gst_bin_add (GST_BIN (pipeline), audio_bin);
482 gst_bin_add (GST_BIN (audio_bin), a_queue);
483 gst_bin_add (GST_BIN (audio_bin), a_decoder);
484 gst_bin_add (GST_BIN (audio_bin), a_convert);
485 gst_bin_add (GST_BIN (audio_bin), audiosink);
487 gst_element_link (a_queue, a_decoder);
488 gst_element_link (a_decoder, a_convert);
489 gst_element_link (a_convert, audiosink);
491 pad = gst_element_get_pad (a_queue, "sink");
492 gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
493 gst_object_unref (pad);
495 setup_dynamic_link (demux, NULL, gst_element_get_pad (audio_bin, "sink"),
498 video_bin = gst_bin_new ("v_decoder_bin");
499 v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
500 v_decoder = gst_element_factory_make_or_warn ("theoradec", "v_dec");
502 gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert");
503 v_scale = gst_element_factory_make_or_warn ("videoscale", "v_scale");
504 videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
506 gst_bin_add (GST_BIN (pipeline), video_bin);
508 gst_bin_add (GST_BIN (video_bin), v_queue);
509 gst_bin_add (GST_BIN (video_bin), v_decoder);
510 gst_bin_add (GST_BIN (video_bin), v_convert);
511 gst_bin_add (GST_BIN (video_bin), v_scale);
512 gst_bin_add (GST_BIN (video_bin), videosink);
514 gst_element_link_many (v_queue, v_decoder, v_convert, v_scale, videosink,
517 pad = gst_element_get_pad (v_queue, "sink");
518 gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
519 gst_object_unref (pad);
521 setup_dynamic_link (demux, NULL, gst_element_get_pad (video_bin, "sink"),
524 seekable = gst_element_get_pad (a_decoder, "src");
525 seekable_pads = g_list_prepend (seekable_pads, seekable);
526 rate_pads = g_list_prepend (rate_pads, seekable);
528 g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
534 make_avi_msmpeg4v3_mp3_pipeline (const gchar * location)
536 GstElement *pipeline, *audio_bin, *video_bin;
537 GstElement *src, *demux, *a_decoder, *a_convert, *v_decoder, *v_convert;
538 GstElement *audiosink, *videosink;
539 GstElement *a_queue, *v_queue;
540 GstPad *seekable, *pad;
542 pipeline = gst_pipeline_new ("app");
544 src = gst_element_factory_make_or_warn (SOURCE, "src");
545 g_object_set (G_OBJECT (src), "location", location, NULL);
547 demux = gst_element_factory_make_or_warn ("avidemux", "demux");
549 gst_bin_add (GST_BIN (pipeline), src);
550 gst_bin_add (GST_BIN (pipeline), demux);
551 gst_element_link (src, demux);
553 audio_bin = gst_bin_new ("a_decoder_bin");
554 a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
555 a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
556 a_convert = gst_element_factory_make_or_warn ("audioconvert", "a_convert");
557 audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
559 gst_bin_add (GST_BIN (audio_bin), a_queue);
560 gst_bin_add (GST_BIN (audio_bin), a_decoder);
561 gst_bin_add (GST_BIN (audio_bin), a_convert);
562 gst_bin_add (GST_BIN (audio_bin), audiosink);
564 gst_element_link (a_queue, a_decoder);
565 gst_element_link (a_decoder, a_convert);
566 gst_element_link (a_convert, audiosink);
568 gst_bin_add (GST_BIN (pipeline), audio_bin);
570 pad = gst_element_get_pad (a_queue, "sink");
571 gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
572 gst_object_unref (pad);
574 setup_dynamic_link (demux, NULL, gst_element_get_pad (audio_bin, "sink"),
577 video_bin = gst_bin_new ("v_decoder_bin");
578 v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
579 v_decoder = gst_element_factory_make_or_warn ("ffdec_msmpeg4", "v_dec");
581 gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert");
582 videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
584 gst_bin_add (GST_BIN (video_bin), v_queue);
585 gst_bin_add (GST_BIN (video_bin), v_decoder);
586 gst_bin_add (GST_BIN (video_bin), v_convert);
587 gst_bin_add (GST_BIN (video_bin), videosink);
589 gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
591 gst_bin_add (GST_BIN (pipeline), video_bin);
593 pad = gst_element_get_pad (v_queue, "sink");
594 gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
595 gst_object_unref (pad);
597 setup_dynamic_link (demux, NULL, gst_element_get_pad (video_bin, "sink"),
600 seekable = gst_element_get_pad (a_decoder, "src");
601 seekable_pads = g_list_prepend (seekable_pads, seekable);
602 rate_pads = g_list_prepend (rate_pads, seekable);
604 g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
610 make_mp3_pipeline (const gchar * location)
612 GstElement *pipeline;
613 GstElement *src, *decoder, *osssink, *queue;
616 pipeline = gst_pipeline_new ("app");
618 src = gst_element_factory_make_or_warn (SOURCE, "src");
619 decoder = gst_element_factory_make_or_warn ("mad", "dec");
620 queue = gst_element_factory_make_or_warn ("queue", "queue");
621 osssink = gst_element_factory_make_or_warn (ASINK, "sink");
623 seekable_elements = g_list_prepend (seekable_elements, osssink);
625 g_object_set (G_OBJECT (src), "location", location, NULL);
626 //g_object_set (G_OBJECT (osssink), "fragment", 0x00180008, NULL);
628 gst_bin_add (GST_BIN (pipeline), src);
629 gst_bin_add (GST_BIN (pipeline), decoder);
630 gst_bin_add (GST_BIN (pipeline), queue);
631 gst_bin_add (GST_BIN (pipeline), osssink);
633 gst_element_link (src, decoder);
634 gst_element_link (decoder, queue);
635 gst_element_link (queue, osssink);
637 seekable = gst_element_get_pad (queue, "src");
638 seekable_pads = g_list_prepend (seekable_pads, seekable);
639 rate_pads = g_list_prepend (rate_pads, seekable);
640 rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink"));
646 make_avi_pipeline (const gchar * location)
648 GstElement *pipeline, *audio_bin, *video_bin;
649 GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink;
650 GstElement *a_queue = NULL, *v_queue = NULL;
653 pipeline = gst_pipeline_new ("app");
655 src = gst_element_factory_make_or_warn (SOURCE, "src");
656 g_object_set (G_OBJECT (src), "location", location, NULL);
658 demux = gst_element_factory_make_or_warn ("avidemux", "demux");
659 seekable_elements = g_list_prepend (seekable_elements, demux);
661 gst_bin_add (GST_BIN (pipeline), src);
662 gst_bin_add (GST_BIN (pipeline), demux);
663 gst_element_link (src, demux);
665 audio_bin = gst_bin_new ("a_decoder_bin");
666 a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
667 audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
668 a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
669 gst_element_link (a_decoder, a_queue);
670 gst_element_link (a_queue, audiosink);
671 gst_bin_add (GST_BIN (audio_bin), a_decoder);
672 gst_bin_add (GST_BIN (audio_bin), a_queue);
673 gst_bin_add (GST_BIN (audio_bin), audiosink);
674 gst_element_set_state (audio_bin, GST_STATE_PAUSED);
676 setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
679 seekable = gst_element_get_pad (a_queue, "src");
680 seekable_pads = g_list_prepend (seekable_pads, seekable);
681 rate_pads = g_list_prepend (rate_pads, seekable);
683 g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
685 video_bin = gst_bin_new ("v_decoder_bin");
686 v_decoder = gst_element_factory_make_or_warn ("ffmpegdecall", "v_dec");
687 videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
688 v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
689 gst_element_link (v_decoder, v_queue);
690 gst_element_link (v_queue, videosink);
691 gst_bin_add (GST_BIN (video_bin), v_decoder);
692 gst_bin_add (GST_BIN (video_bin), v_queue);
693 gst_bin_add (GST_BIN (video_bin), videosink);
695 gst_element_set_state (video_bin, GST_STATE_PAUSED);
697 setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
700 seekable = gst_element_get_pad (v_queue, "src");
701 seekable_pads = g_list_prepend (seekable_pads, seekable);
702 rate_pads = g_list_prepend (rate_pads, seekable);
704 g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
710 make_mpeg_pipeline (const gchar * location)
712 GstElement *pipeline, *audio_bin, *video_bin;
713 GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
714 GstElement *audiosink, *videosink;
715 GstElement *a_queue, *v_queue;
719 pipeline = gst_pipeline_new ("app");
721 src = gst_element_factory_make_or_warn (SOURCE, "src");
722 g_object_set (G_OBJECT (src), "location", location, NULL);
724 //demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
725 demux = gst_element_factory_make_or_warn ("flupsdemux", "demux");
727 gst_bin_add (GST_BIN (pipeline), src);
728 gst_bin_add (GST_BIN (pipeline), demux);
729 gst_element_link (src, demux);
731 audio_bin = gst_bin_new ("a_decoder_bin");
732 a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
733 a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
734 audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
735 gst_bin_add (GST_BIN (audio_bin), a_decoder);
736 gst_bin_add (GST_BIN (audio_bin), a_queue);
737 gst_bin_add (GST_BIN (audio_bin), audiosink);
739 gst_element_link (a_decoder, a_queue);
740 gst_element_link (a_queue, audiosink);
742 gst_bin_add (GST_BIN (pipeline), audio_bin);
744 pad = gst_element_get_pad (a_decoder, "sink");
745 gst_element_add_pad (audio_bin, gst_ghost_pad_new ("sink", pad));
746 gst_object_unref (pad);
748 setup_dynamic_link (demux, "audio_c0", gst_element_get_pad (audio_bin,
751 video_bin = gst_bin_new ("v_decoder_bin");
752 v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
753 v_queue = gst_element_factory_make_or_warn ("queue", "v_queue");
754 v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
755 videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
757 gst_bin_add (GST_BIN (video_bin), v_decoder);
758 gst_bin_add (GST_BIN (video_bin), v_queue);
759 gst_bin_add (GST_BIN (video_bin), v_filter);
760 gst_bin_add (GST_BIN (video_bin), videosink);
762 gst_element_link (v_decoder, v_queue);
763 gst_element_link (v_queue, v_filter);
764 gst_element_link (v_filter, videosink);
766 gst_bin_add (GST_BIN (pipeline), video_bin);
768 pad = gst_element_get_pad (v_decoder, "sink");
769 gst_element_add_pad (video_bin, gst_ghost_pad_new ("sink", pad));
770 gst_object_unref (pad);
772 setup_dynamic_link (demux, "video_e0", gst_element_get_pad (video_bin,
775 seekable = gst_element_get_pad (v_filter, "src");
776 seekable_pads = g_list_prepend (seekable_pads, seekable);
777 rate_pads = g_list_prepend (rate_pads, seekable);
779 g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
785 make_mpegnt_pipeline (const gchar * location)
787 GstElement *pipeline, *audio_bin, *video_bin;
788 GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
789 GstElement *audiosink, *videosink;
793 pipeline = gst_pipeline_new ("app");
795 src = gst_element_factory_make_or_warn (SOURCE, "src");
796 g_object_set (G_OBJECT (src), "location", location, NULL);
798 demux = gst_element_factory_make_or_warn ("mpegdemux", "demux");
799 //g_object_set (G_OBJECT (demux), "sync", TRUE, NULL);
801 seekable_elements = g_list_prepend (seekable_elements, demux);
803 gst_bin_add (GST_BIN (pipeline), src);
804 gst_bin_add (GST_BIN (pipeline), demux);
805 gst_element_link (src, demux);
807 audio_bin = gst_bin_new ("a_decoder_bin");
808 a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec");
809 a_queue = gst_element_factory_make_or_warn ("queue", "a_queue");
810 audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink");
811 //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL);
812 g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL);
813 gst_element_link (a_decoder, a_queue);
814 gst_element_link (a_queue, audiosink);
815 gst_bin_add (GST_BIN (audio_bin), a_decoder);
816 gst_bin_add (GST_BIN (audio_bin), a_queue);
817 gst_bin_add (GST_BIN (audio_bin), audiosink);
819 setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
822 seekable = gst_element_get_pad (a_queue, "src");
823 seekable_pads = g_list_prepend (seekable_pads, seekable);
824 rate_pads = g_list_prepend (rate_pads, seekable);
826 g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
828 video_bin = gst_bin_new ("v_decoder_bin");
829 v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
830 v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter");
831 videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
832 gst_element_link_many (v_decoder, v_filter, videosink, NULL);
834 gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL);
836 setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
839 seekable = gst_element_get_pad (v_decoder, "src");
840 seekable_pads = g_list_prepend (seekable_pads, seekable);
841 rate_pads = g_list_prepend (rate_pads, seekable);
843 g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
849 make_playerbin_pipeline (const gchar * location)
853 player = gst_element_factory_make ("playbin", "player");
856 g_object_set (G_OBJECT (player), "uri", location, NULL);
858 seekable_elements = g_list_prepend (seekable_elements, player);
860 /* force element seeking on this pipeline */
867 make_playerbin2_pipeline (const gchar * location)
871 player = gst_element_factory_make ("playbin2", "player");
874 g_object_set (G_OBJECT (player), "uri", location, NULL);
876 seekable_elements = g_list_prepend (seekable_elements, player);
878 /* force element seeking on this pipeline */
884 #ifndef GST_DISABLE_PARSE
886 make_parselaunch_pipeline (const gchar * description)
888 GstElement *pipeline;
891 pipeline = gst_parse_launch (description, &error);
893 seekable_elements = g_list_prepend (seekable_elements, pipeline);
904 GstElement *(*func) (const gchar * location);
908 static Pipeline pipelines[] = {
909 {"mp3", make_mp3_pipeline},
910 {"avi", make_avi_pipeline},
911 {"mpeg1", make_mpeg_pipeline},
912 {"mpegparse", make_parse_pipeline},
913 {"vorbis", make_vorbis_pipeline},
914 {"theora", make_theora_pipeline},
915 {"ogg/v/t", make_vorbis_theora_pipeline},
916 {"avi/msmpeg4v3/mp3", make_avi_msmpeg4v3_mp3_pipeline},
917 {"sid", make_sid_pipeline},
918 {"flac", make_flac_pipeline},
919 {"wav", make_wav_pipeline},
920 {"mod", make_mod_pipeline},
921 {"dv", make_dv_pipeline},
922 {"mpeg1nothreads", make_mpegnt_pipeline},
923 {"playerbin", make_playerbin_pipeline},
924 #ifndef GST_DISABLE_PARSE
925 {"parse-launch", make_parselaunch_pipeline},
927 {"playerbin2", make_playerbin2_pipeline},
931 #define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
933 /* ui callbacks and helpers */
936 format_value (GtkScale * scale, gdouble value)
942 real = value * duration / 100;
943 seconds = (gint64) real / GST_SECOND;
944 subseconds = (gint64) real / (GST_SECOND / 100);
946 return g_strdup_printf ("%02" G_GINT64_FORMAT ":%02" G_GINT64_FORMAT ":%02"
947 G_GINT64_FORMAT, seconds / 60, seconds % 60, subseconds % 100);
953 const GstFormat format;
957 static seek_format seek_formats[] = {
958 {"tim", GST_FORMAT_TIME},
959 {"byt", GST_FORMAT_BYTES},
960 {"buf", GST_FORMAT_BUFFERS},
961 {"def", GST_FORMAT_DEFAULT},
965 G_GNUC_UNUSED static void
968 GList *walk = rate_pads;
971 GstPad *pad = GST_PAD (walk->data);
974 g_print ("rate/sec %8.8s: ", GST_PAD_NAME (pad));
975 while (seek_formats[i].name) {
979 format = seek_formats[i].format;
981 if (gst_pad_query_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format,
983 g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
985 g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
990 g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
992 walk = g_list_next (walk);
996 G_GNUC_UNUSED static void
997 query_positions_elems ()
999 GList *walk = seekable_elements;
1002 GstElement *element = GST_ELEMENT (walk->data);
1005 g_print ("positions %8.8s: ", GST_ELEMENT_NAME (element));
1006 while (seek_formats[i].name) {
1007 gint64 position, total;
1010 format = seek_formats[i].format;
1012 if (gst_element_query_position (element, &format, &position) &&
1013 gst_element_query_duration (element, &format, &total)) {
1014 g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
1015 seek_formats[i].name, position, total);
1017 g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
1022 g_print (" %s\n", GST_ELEMENT_NAME (element));
1024 walk = g_list_next (walk);
1028 G_GNUC_UNUSED static void
1029 query_positions_pads ()
1031 GList *walk = seekable_pads;
1034 GstPad *pad = GST_PAD (walk->data);
1037 g_print ("positions %8.8s: ", GST_PAD_NAME (pad));
1038 while (seek_formats[i].name) {
1040 gint64 position, total;
1042 format = seek_formats[i].format;
1044 if (gst_pad_query_position (pad, &format, &position) &&
1045 gst_pad_query_duration (pad, &format, &total)) {
1046 g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
1047 seek_formats[i].name, position, total);
1049 g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
1055 g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
1057 walk = g_list_next (walk);
1061 static gboolean start_seek (GtkWidget * widget, GdkEventButton * event,
1062 gpointer user_data);
1063 static gboolean stop_seek (GtkWidget * widget, GdkEventButton * event,
1064 gpointer user_data);
1065 static void seek_cb (GtkWidget * widget);
1068 set_scale (gdouble value)
1070 g_signal_handlers_block_by_func (hscale, (void *) start_seek,
1072 g_signal_handlers_block_by_func (hscale, (void *) stop_seek,
1074 g_signal_handlers_block_by_func (hscale, (void *) seek_cb, (void *) pipeline);
1075 gtk_adjustment_set_value (adjustment, value);
1076 g_signal_handlers_unblock_by_func (hscale, (void *) start_seek,
1078 g_signal_handlers_unblock_by_func (hscale, (void *) stop_seek,
1080 g_signal_handlers_unblock_by_func (hscale, (void *) seek_cb,
1082 gtk_widget_queue_draw (hscale);
1086 update_scale (gpointer data)
1088 GstFormat format = GST_FORMAT_TIME;
1094 if (seekable_elements) {
1095 GstElement *element = GST_ELEMENT (seekable_elements->data);
1097 gst_element_query_position (element, &format, &position);
1098 gst_element_query_duration (element, &format, &duration);
1101 if (seekable_pads) {
1102 GstPad *pad = GST_PAD (seekable_pads->data);
1104 gst_pad_query_position (pad, &format, &position);
1105 gst_pad_query_duration (pad, &format, &duration);
1111 query_positions_elems ();
1113 query_positions_pads ();
1117 if (position >= duration)
1118 duration = position;
1121 set_scale (position * 100.0 / duration);
1127 static void do_seek (GtkWidget * widget);
1128 static void connect_bus_signals (GstElement * pipeline);
1129 static void set_update_scale (gboolean active);
1132 end_scrub (GtkWidget * widget)
1134 GST_DEBUG ("end scrub, PAUSE");
1135 gst_element_set_state (pipeline, GST_STATE_PAUSED);
1136 seek_timeout_id = 0;
1142 send_event (GstEvent * event)
1144 gboolean res = FALSE;
1147 GList *walk = seekable_pads;
1150 GstPad *seekable = GST_PAD (walk->data);
1152 GST_DEBUG ("send event on pad %s:%s", GST_DEBUG_PAD_NAME (seekable));
1154 gst_event_ref (event);
1155 res = gst_pad_send_event (seekable, event);
1157 walk = g_list_next (walk);
1160 GList *walk = seekable_elements;
1163 GstElement *seekable = GST_ELEMENT (walk->data);
1165 GST_DEBUG ("send event on element %s", GST_ELEMENT_NAME (seekable));
1167 gst_event_ref (event);
1168 res = gst_element_send_event (seekable, event);
1170 walk = g_list_next (walk);
1173 gst_event_unref (event);
1178 do_seek (GtkWidget * widget)
1181 gboolean res = FALSE;
1185 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
1189 flags |= GST_SEEK_FLAG_FLUSH;
1191 flags |= GST_SEEK_FLAG_ACCURATE;
1193 flags |= GST_SEEK_FLAG_KEY_UNIT;
1195 flags |= GST_SEEK_FLAG_SEGMENT;
1198 s_event = gst_event_new_seek (rate,
1199 GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_SET, -1);
1200 GST_DEBUG ("seek with rate %lf to %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
1201 rate, GST_TIME_ARGS (real), GST_TIME_ARGS (duration));
1203 s_event = gst_event_new_seek (rate,
1204 GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
1205 GST_SEEK_TYPE_SET, real);
1206 GST_DEBUG ("seek with rate %lf to %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
1207 rate, GST_TIME_ARGS (0), GST_TIME_ARGS (real));
1210 res = send_event (s_event);
1214 gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, SEEK_TIMEOUT);
1216 set_update_scale (TRUE);
1219 g_print ("seek failed\n");
1220 set_update_scale (TRUE);
1225 seek_cb (GtkWidget * widget)
1227 /* If the timer hasn't expired yet, then the pipeline is running */
1228 if (play_scrub && seek_timeout_id != 0) {
1229 GST_DEBUG ("do scrub seek, PAUSED");
1230 gst_element_set_state (pipeline, GST_STATE_PAUSED);
1233 GST_DEBUG ("do seek");
1237 GST_DEBUG ("do scrub seek, PLAYING");
1238 gst_element_set_state (pipeline, GST_STATE_PLAYING);
1240 if (seek_timeout_id == 0) {
1242 g_timeout_add (SCRUB_TIME, (GSourceFunc) end_scrub, widget);
1248 set_update_scale (gboolean active)
1251 GST_DEBUG ("update scale is %d", active);
1254 if (update_id == 0) {
1256 g_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
1260 g_source_remove (update_id);
1267 start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
1269 if (event->type != GDK_BUTTON_PRESS)
1272 set_update_scale (FALSE);
1274 if (state == GST_STATE_PLAYING && flush_seek && scrub) {
1275 GST_DEBUG ("start scrub seek, PAUSE");
1276 gst_element_set_state (pipeline, GST_STATE_PAUSED);
1279 if (changed_id == 0 && flush_seek && scrub) {
1280 changed_id = gtk_signal_connect (GTK_OBJECT (hscale),
1281 "value_changed", G_CALLBACK (seek_cb), pipeline);
1288 stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
1291 g_signal_handler_disconnect (GTK_OBJECT (hscale), changed_id);
1295 if (!flush_seek || !scrub) {
1296 GST_DEBUG ("do final seek");
1300 if (seek_timeout_id != 0) {
1301 g_source_remove (seek_timeout_id);
1302 seek_timeout_id = 0;
1303 /* Still scrubbing, so the pipeline is playing, see if we need PAUSED
1305 if (state == GST_STATE_PAUSED) {
1306 GST_DEBUG ("stop scrub seek, PAUSED");
1307 gst_element_set_state (pipeline, GST_STATE_PAUSED);
1310 if (state == GST_STATE_PLAYING) {
1311 GST_DEBUG ("stop scrub seek, PLAYING");
1312 gst_element_set_state (pipeline, GST_STATE_PLAYING);
1320 play_cb (GtkButton * button, gpointer data)
1322 GstStateChangeReturn ret;
1324 if (state != GST_STATE_PLAYING) {
1325 g_print ("PLAY pipeline\n");
1326 ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
1327 if (ret == GST_STATE_CHANGE_FAILURE)
1331 state = GST_STATE_PLAYING;
1337 g_print ("PLAY failed\n");
1342 pause_cb (GtkButton * button, gpointer data)
1344 if (state != GST_STATE_PAUSED) {
1345 GstStateChangeReturn ret;
1347 g_print ("PAUSE pipeline\n");
1348 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
1349 if (ret == GST_STATE_CHANGE_FAILURE)
1352 state = GST_STATE_PAUSED;
1358 g_print ("PAUSE failed\n");
1363 stop_cb (GtkButton * button, gpointer data)
1365 if (state != GST_STATE_READY) {
1366 GstStateChangeReturn ret;
1368 g_print ("READY pipeline\n");
1369 ret = gst_element_set_state (pipeline, GST_STATE_READY);
1370 if (ret == GST_STATE_CHANGE_FAILURE)
1373 state = GST_STATE_READY;
1375 set_update_scale (FALSE);
1378 if (pipeline_type == 16)
1379 clear_streams (pipeline);
1381 /* if one uses parse_launch, play, stop and play again it fails as all the
1382 * pads after the demuxer can't be reconnected
1384 if (!strcmp (pipelines[pipeline_type].name, "parse-launch")) {
1385 gst_element_set_state (pipeline, GST_STATE_NULL);
1386 gst_object_unref (pipeline);
1388 pipeline = pipelines[pipeline_type].func (pipeline_spec);
1389 g_assert (pipeline);
1390 gst_element_set_state (pipeline, GST_STATE_READY);
1391 connect_bus_signals (pipeline);
1398 g_print ("STOP failed\n");
1403 accurate_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1405 accurate_seek = gtk_toggle_button_get_active (button);
1409 key_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1411 keyframe_seek = gtk_toggle_button_get_active (button);
1415 loop_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1417 loop_seek = gtk_toggle_button_get_active (button);
1418 if (state == GST_STATE_PLAYING) {
1424 flush_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1426 flush_seek = gtk_toggle_button_get_active (button);
1430 scrub_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1432 scrub = gtk_toggle_button_get_active (button);
1436 play_scrub_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1438 play_scrub = gtk_toggle_button_get_active (button);
1442 rate_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
1444 gboolean res = FALSE;
1448 rate = gtk_spin_button_get_value (button);
1452 flags |= GST_SEEK_FLAG_FLUSH;
1454 flags |= GST_SEEK_FLAG_SEGMENT;
1456 flags |= GST_SEEK_FLAG_ACCURATE;
1458 flags |= GST_SEEK_FLAG_KEY_UNIT;
1461 s_event = gst_event_new_seek (rate,
1462 GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
1463 GST_SEEK_TYPE_SET, -1);
1465 s_event = gst_event_new_seek (rate,
1466 GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
1467 GST_SEEK_TYPE_SET, position);
1470 GST_DEBUG ("rate changed to %lf", rate);
1472 res = send_event (s_event);
1476 gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, SEEK_TIMEOUT);
1479 g_print ("seek failed\n");
1483 update_flag (GstPipeline * pipeline, gint num, gboolean state)
1487 g_object_get (pipeline, "flags", &flags, NULL);
1489 flags |= (1 << num);
1491 flags &= ~(1 << num);
1492 g_object_set (pipeline, "flags", flags, NULL);
1496 vis_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1500 state = gtk_toggle_button_get_active (button);
1501 update_flag (pipeline, 3, state);
1502 gtk_widget_set_sensitive (vis_combo, state);
1506 audio_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1508 update_flag (pipeline, 1, gtk_toggle_button_get_active (button));
1512 video_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1514 update_flag (pipeline, 0, gtk_toggle_button_get_active (button));
1518 text_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1520 update_flag (pipeline, 2, gtk_toggle_button_get_active (button));
1524 mute_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
1528 mute = gtk_toggle_button_get_active (button);
1529 g_object_set (pipeline, "mute", mute, NULL);
1533 clear_streams (GstElement * pipeline)
1537 /* remove previous info */
1538 for (i = 0; i < n_video; i++)
1539 gtk_combo_box_remove_text (GTK_COMBO_BOX (video_combo), 0);
1540 for (i = 0; i < n_audio; i++)
1541 gtk_combo_box_remove_text (GTK_COMBO_BOX (audio_combo), 0);
1542 for (i = 0; i < n_text; i++)
1543 gtk_combo_box_remove_text (GTK_COMBO_BOX (text_combo), 0);
1545 n_audio = n_video = n_text = 0;
1546 gtk_widget_set_sensitive (video_combo, FALSE);
1547 gtk_widget_set_sensitive (audio_combo, FALSE);
1548 gtk_widget_set_sensitive (text_combo, FALSE);
1550 need_streams = TRUE;
1554 update_streams (GstPipeline * pipeline)
1558 if (pipeline_type == 16 && need_streams) {
1563 /* remove previous info */
1564 clear_streams (GST_ELEMENT_CAST (pipeline));
1566 /* here we get and update the different streams detected by playbin2 */
1567 g_object_get (pipeline, "n-video", &n_video, NULL);
1568 g_object_get (pipeline, "n-audio", &n_audio, NULL);
1569 g_object_get (pipeline, "n-text", &n_text, NULL);
1571 g_print ("video %d, audio %d, text %d\n", n_video, n_audio, n_text);
1574 for (i = 0; i < n_video; i++) {
1575 g_signal_emit_by_name (pipeline, "get-video-tags", i, &tags);
1576 /* find good name for the label */
1577 name = g_strdup_printf ("video %d", i + 1);
1578 gtk_combo_box_append_text (GTK_COMBO_BOX (video_combo), name);
1581 gtk_widget_set_sensitive (video_combo, n_video > 0);
1582 gtk_combo_box_set_active (GTK_COMBO_BOX (video_combo), active_idx);
1585 for (i = 0; i < n_audio; i++) {
1586 g_signal_emit_by_name (pipeline, "get-audio-tags", i, &tags);
1587 /* find good name for the label */
1588 name = g_strdup_printf ("audio %d", i + 1);
1589 gtk_combo_box_append_text (GTK_COMBO_BOX (audio_combo), name);
1592 gtk_widget_set_sensitive (audio_combo, n_audio > 0);
1593 gtk_combo_box_set_active (GTK_COMBO_BOX (audio_combo), active_idx);
1596 for (i = 0; i < n_text; i++) {
1597 g_signal_emit_by_name (pipeline, "get-text-tags", i, &tags);
1598 /* find good name for the label */
1599 name = g_strdup_printf ("text %d", i + 1);
1600 gtk_combo_box_append_text (GTK_COMBO_BOX (text_combo), name);
1603 gtk_widget_set_sensitive (text_combo, n_text > 0);
1604 gtk_combo_box_set_active (GTK_COMBO_BOX (text_combo), active_idx);
1606 need_streams = FALSE;
1611 video_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
1613 g_object_set (pipeline, "current-video", gtk_combo_box_get_active (combo),
1618 audio_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
1620 g_object_set (pipeline, "current-audio", gtk_combo_box_get_active (combo),
1625 text_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
1627 g_object_set (pipeline, "current-text", gtk_combo_box_get_active (combo),
1632 filter_features (GstPluginFeature * feature, gpointer data)
1634 GstElementFactory *f;
1636 if (!GST_IS_ELEMENT_FACTORY (feature))
1638 f = GST_ELEMENT_FACTORY (feature);
1639 if (!g_strrstr (gst_element_factory_get_klass (f), "Visualization"))
1646 init_visualization_features (void)
1650 vis_entries = g_array_new (FALSE, FALSE, sizeof (VisEntry));
1652 list = gst_registry_feature_filter (gst_registry_get_default (),
1653 filter_features, FALSE, NULL);
1655 for (walk = list; walk; walk = g_list_next (walk)) {
1659 entry.factory = GST_ELEMENT_FACTORY (walk->data);
1660 name = gst_element_factory_get_longname (entry.factory);
1662 g_array_append_val (vis_entries, entry);
1663 gtk_combo_box_append_text (GTK_COMBO_BOX (vis_combo), name);
1665 gtk_combo_box_set_active (GTK_COMBO_BOX (vis_combo), 0);
1669 vis_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
1673 GstElement *element;
1675 /* get the selected index and get the factory for this index */
1676 index = gtk_combo_box_get_active (GTK_COMBO_BOX (vis_combo));
1677 entry = &g_array_index (vis_entries, VisEntry, index);
1678 /* create an instance of the element from the factory */
1679 element = gst_element_factory_create (entry->factory, NULL);
1683 /* set vis plugin for playbin2 */
1684 g_object_set (pipeline, "vis-plugin", element, NULL);
1688 volume_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
1692 volume = gtk_spin_button_get_value (button);
1694 g_object_set (pipeline, "volume", volume, NULL);
1698 shot_cb (GtkButton * button, gpointer data)
1703 /* convert to our desired format (RGB24) */
1704 caps = gst_caps_new_simple ("video/x-raw-rgb",
1705 "bpp", G_TYPE_INT, 24, "depth", G_TYPE_INT, 24,
1706 /* Note: we don't ask for a specific width/height here, so that
1707 * videoscale can adjust dimensions from a non-1/1 pixel aspect
1708 * ratio to a 1/1 pixel-aspect-ratio */
1709 "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
1710 "endianness", G_TYPE_INT, G_BIG_ENDIAN,
1711 "red_mask", G_TYPE_INT, 0xff0000,
1712 "green_mask", G_TYPE_INT, 0x00ff00,
1713 "blue_mask", G_TYPE_INT, 0x0000ff, NULL);
1715 /* convert the latest frame to the requested format */
1716 g_signal_emit_by_name (pipeline, "convert-frame", caps, &buffer);
1717 gst_caps_unref (caps);
1725 GError *error = NULL;
1727 /* get the snapshot buffer format now. We set the caps on the appsink so
1728 * that it can only be an rgb buffer. The only thing we have not specified
1729 * on the caps is the height, which is dependant on the pixel-aspect-ratio
1730 * of the source material */
1731 caps = GST_BUFFER_CAPS (buffer);
1733 g_warning ("could not get snapshot format\n");
1736 s = gst_caps_get_structure (caps, 0);
1738 /* we need to get the final caps on the buffer to get the size */
1739 res = gst_structure_get_int (s, "width", &width);
1740 res |= gst_structure_get_int (s, "height", &height);
1742 g_warning ("could not get snapshot dimension\n");
1746 /* create pixmap from buffer and save, gstreamer video buffers have a stride
1747 * that is rounded up to the nearest multiple of 4 */
1748 pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buffer),
1749 GDK_COLORSPACE_RGB, FALSE, 8, width, height,
1750 GST_ROUND_UP_4 (width * 3), NULL, NULL);
1752 /* save the pixbuf */
1753 gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
1756 gst_buffer_unref (buffer);
1761 message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
1763 const GstStructure *s;
1765 s = gst_message_get_structure (message);
1766 g_print ("message from \"%s\" (%s): ",
1767 GST_STR_NULL (GST_ELEMENT_NAME (GST_MESSAGE_SRC (message))),
1768 gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
1772 sstr = gst_structure_to_string (s);
1773 g_print ("%s\n", sstr);
1776 g_print ("no message details\n");
1781 msg_async_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
1783 GST_DEBUG ("async done");
1784 /* when we get ASYNC_DONE we can query position, duration and other
1786 update_scale (pipeline);
1788 /* update the available streams */
1789 update_streams (pipeline);
1793 msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
1795 const GstStructure *s;
1797 s = gst_message_get_structure (message);
1799 /* We only care about state changed on the pipeline */
1800 if (s && GST_MESSAGE_SRC (message) == GST_OBJECT_CAST (pipeline)) {
1801 GstState old, new, pending;
1803 gst_message_parse_state_changed (message, &old, &new, &pending);
1805 /* When state of the pipeline changes to paused or playing we start updating scale */
1806 if (new == GST_STATE_PLAYING) {
1807 set_update_scale (TRUE);
1809 set_update_scale (FALSE);
1815 msg_segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
1822 GST_DEBUG ("position is %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
1823 gst_message_parse_segment_done (message, &format, &position);
1824 GST_DEBUG ("end of segment at %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
1827 /* in the segment-done callback we never flush as this would not make sense
1828 * for seamless playback. */
1830 flags = GST_SEEK_FLAG_SEGMENT;
1832 s_event = gst_event_new_seek (rate,
1833 GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
1834 GST_SEEK_TYPE_SET, duration);
1836 GST_DEBUG ("restart loop with rate %lf to 0 / %" GST_TIME_FORMAT,
1837 rate, GST_TIME_ARGS (duration));
1839 res = send_event (s_event);
1841 g_print ("segment seek failed\n");
1845 connect_bus_signals (GstElement * pipeline)
1847 GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
1849 gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
1851 g_signal_connect (bus, "message::state-changed",
1852 (GCallback) msg_state_changed, pipeline);
1853 g_signal_connect (bus, "message::segment-done", (GCallback) msg_segment_done,
1855 g_signal_connect (bus, "message::async-done", (GCallback) msg_async_done,
1858 g_signal_connect (bus, "message::new-clock", (GCallback) message_received,
1860 g_signal_connect (bus, "message::error", (GCallback) message_received,
1862 g_signal_connect (bus, "message::warning", (GCallback) message_received,
1864 g_signal_connect (bus, "message::eos", (GCallback) message_received,
1866 g_signal_connect (bus, "message::tag", (GCallback) message_received,
1868 g_signal_connect (bus, "message::element", (GCallback) message_received,
1870 g_signal_connect (bus, "message::segment-done", (GCallback) message_received,
1873 gst_object_unref (bus);
1877 print_usage (int argc, char **argv)
1881 g_print ("usage: %s <type> <filename>\n", argv[0]);
1882 g_print (" possible types:\n");
1884 for (i = 0; i < NUM_TYPES; i++) {
1885 g_print (" %d = %s\n", i, pipelines[i].name);
1890 main (int argc, char **argv)
1892 GtkWidget *window, *hbox, *vbox, *panel, *boxes, *flagtable, *boxes2;
1893 GtkWidget *play_button, *pause_button, *stop_button, *shot_button;
1894 GtkWidget *accurate_checkbox, *key_checkbox, *loop_checkbox, *flush_checkbox;
1895 GtkWidget *scrub_checkbox, *play_scrub_checkbox, *rate_spinbutton;
1896 GtkWidget *rate_label;
1898 GOptionEntry options[] = {
1899 {"stats", 's', 0, G_OPTION_ARG_NONE, &stats,
1900 "Show pad stats", NULL},
1901 {"elem", 'e', 0, G_OPTION_ARG_NONE, &elem_seek,
1902 "Seek on elements instead of pads", NULL},
1903 {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
1904 "Verbose properties", NULL},
1907 GOptionContext *ctx;
1910 if (!g_thread_supported ())
1911 g_thread_init (NULL);
1913 ctx = g_option_context_new ("- test seeking in gsteamer");
1914 g_option_context_add_main_entries (ctx, options, NULL);
1915 g_option_context_add_group (ctx, gst_init_get_option_group ());
1917 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
1918 g_print ("Error initializing: %s\n", err->message);
1922 GST_DEBUG_CATEGORY_INIT (seek_debug, "seek", 0, "seek example");
1924 gtk_init (&argc, &argv);
1927 print_usage (argc, argv);
1931 pipeline_type = atoi (argv[1]);
1933 if (pipeline_type < 0 || pipeline_type >= NUM_TYPES) {
1934 print_usage (argc, argv);
1938 pipeline_spec = argv[2];
1940 pipeline = pipelines[pipeline_type].func (pipeline_spec);
1941 g_assert (pipeline);
1943 /* initialize gui elements ... */
1944 tips = gtk_tooltips_new ();
1945 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1946 hbox = gtk_hbox_new (FALSE, 0);
1947 vbox = gtk_vbox_new (FALSE, 0);
1948 flagtable = gtk_table_new (4, 2, FALSE);
1949 gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
1951 /* media controls */
1952 play_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
1953 pause_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PAUSE);
1954 stop_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_STOP);
1957 accurate_checkbox = gtk_check_button_new_with_label ("Accurate Seek");
1958 key_checkbox = gtk_check_button_new_with_label ("Key-unit Seek");
1959 loop_checkbox = gtk_check_button_new_with_label ("Loop");
1960 flush_checkbox = gtk_check_button_new_with_label ("Flush");
1961 scrub_checkbox = gtk_check_button_new_with_label ("Scrub");
1962 play_scrub_checkbox = gtk_check_button_new_with_label ("Play Scrub");
1963 rate_spinbutton = gtk_spin_button_new_with_range (-100, 100, 0.1);
1964 gtk_spin_button_set_digits (GTK_SPIN_BUTTON (rate_spinbutton), 3);
1965 rate_label = gtk_label_new ("Rate");
1967 gtk_tooltips_set_tip (tips, accurate_checkbox,
1968 "accurate position is requested, this might be considerably slower for some formats",
1970 gtk_tooltips_set_tip (tips, key_checkbox,
1971 "seek to the nearest keyframe. This might be faster but less accurate",
1973 gtk_tooltips_set_tip (tips, loop_checkbox, "loop playback", NULL);
1974 gtk_tooltips_set_tip (tips, flush_checkbox, "flush pipeline after seeking",
1976 gtk_tooltips_set_tip (tips, rate_spinbutton, "define the playback rate, "
1977 "negative value trigger reverse playback", NULL);
1978 gtk_tooltips_set_tip (tips, scrub_checkbox, "show images while seeking",
1980 gtk_tooltips_set_tip (tips, play_scrub_checkbox, "play video while seeking",
1983 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (flush_checkbox), TRUE);
1984 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scrub_checkbox), TRUE);
1986 gtk_spin_button_set_value (GTK_SPIN_BUTTON (rate_spinbutton), rate);
1990 GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
1991 hscale = gtk_hscale_new (adjustment);
1992 gtk_scale_set_digits (GTK_SCALE (hscale), 2);
1993 #if GTK_CHECK_VERSION(2,12,0)
1994 gtk_range_set_show_fill_level (GTK_RANGE (hscale), TRUE);
1995 gtk_range_set_fill_level (GTK_RANGE (hscale), 100.0);
1997 gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
1999 gtk_signal_connect (GTK_OBJECT (hscale),
2000 "button_press_event", G_CALLBACK (start_seek), pipeline);
2001 gtk_signal_connect (GTK_OBJECT (hscale),
2002 "button_release_event", G_CALLBACK (stop_seek), pipeline);
2003 gtk_signal_connect (GTK_OBJECT (hscale),
2004 "format_value", G_CALLBACK (format_value), pipeline);
2006 if (pipeline_type == 16) {
2007 /* the playbin2 panel controls for the video/audio/subtitle tracks */
2008 panel = gtk_hbox_new (FALSE, 0);
2009 video_combo = gtk_combo_box_new_text ();
2010 audio_combo = gtk_combo_box_new_text ();
2011 text_combo = gtk_combo_box_new_text ();
2012 gtk_widget_set_sensitive (video_combo, FALSE);
2013 gtk_widget_set_sensitive (audio_combo, FALSE);
2014 gtk_widget_set_sensitive (text_combo, FALSE);
2015 gtk_box_pack_start (GTK_BOX (panel), video_combo, TRUE, TRUE, 2);
2016 gtk_box_pack_start (GTK_BOX (panel), audio_combo, TRUE, TRUE, 2);
2017 gtk_box_pack_start (GTK_BOX (panel), text_combo, TRUE, TRUE, 2);
2018 g_signal_connect (G_OBJECT (video_combo), "changed",
2019 G_CALLBACK (video_combo_cb), pipeline);
2020 g_signal_connect (G_OBJECT (audio_combo), "changed",
2021 G_CALLBACK (audio_combo_cb), pipeline);
2022 g_signal_connect (G_OBJECT (text_combo), "changed",
2023 G_CALLBACK (text_combo_cb), pipeline);
2024 /* playbin2 panel for flag checkboxes and volume/mute */
2025 boxes = gtk_hbox_new (FALSE, 0);
2026 vis_checkbox = gtk_check_button_new_with_label ("Vis");
2027 video_checkbox = gtk_check_button_new_with_label ("Video");
2028 audio_checkbox = gtk_check_button_new_with_label ("Audio");
2029 text_checkbox = gtk_check_button_new_with_label ("Text");
2030 mute_checkbox = gtk_check_button_new_with_label ("Mute");
2031 volume_spinbutton = gtk_spin_button_new_with_range (0, 10.0, 0.1);
2032 gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), 1.0);
2033 gtk_box_pack_start (GTK_BOX (boxes), vis_checkbox, TRUE, TRUE, 2);
2034 gtk_box_pack_start (GTK_BOX (boxes), audio_checkbox, TRUE, TRUE, 2);
2035 gtk_box_pack_start (GTK_BOX (boxes), video_checkbox, TRUE, TRUE, 2);
2036 gtk_box_pack_start (GTK_BOX (boxes), text_checkbox, TRUE, TRUE, 2);
2037 gtk_box_pack_start (GTK_BOX (boxes), mute_checkbox, TRUE, TRUE, 2);
2038 gtk_box_pack_start (GTK_BOX (boxes), volume_spinbutton, TRUE, TRUE, 2);
2039 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vis_checkbox), FALSE);
2040 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (audio_checkbox), TRUE);
2041 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (video_checkbox), TRUE);
2042 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text_checkbox), TRUE);
2043 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_checkbox), FALSE);
2044 g_signal_connect (G_OBJECT (vis_checkbox), "toggled",
2045 G_CALLBACK (vis_toggle_cb), pipeline);
2046 g_signal_connect (G_OBJECT (audio_checkbox), "toggled",
2047 G_CALLBACK (audio_toggle_cb), pipeline);
2048 g_signal_connect (G_OBJECT (video_checkbox), "toggled",
2049 G_CALLBACK (video_toggle_cb), pipeline);
2050 g_signal_connect (G_OBJECT (text_checkbox), "toggled",
2051 G_CALLBACK (text_toggle_cb), pipeline);
2052 g_signal_connect (G_OBJECT (mute_checkbox), "toggled",
2053 G_CALLBACK (mute_toggle_cb), pipeline);
2054 g_signal_connect (G_OBJECT (volume_spinbutton), "value_changed",
2055 G_CALLBACK (volume_spinbutton_changed_cb), pipeline);
2056 /* playbin2 panel for snapshot */
2057 boxes2 = gtk_hbox_new (FALSE, 0);
2058 shot_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
2059 gtk_tooltips_set_tip (tips, shot_button,
2060 "save a screenshot .png in the current directory", NULL);
2061 g_signal_connect (G_OBJECT (shot_button), "clicked", G_CALLBACK (shot_cb),
2063 vis_combo = gtk_combo_box_new_text ();
2064 g_signal_connect (G_OBJECT (vis_combo), "changed",
2065 G_CALLBACK (vis_combo_cb), pipeline);
2066 gtk_widget_set_sensitive (vis_combo, FALSE);
2067 gtk_box_pack_start (GTK_BOX (boxes2), shot_button, TRUE, TRUE, 2);
2068 gtk_box_pack_start (GTK_BOX (boxes2), vis_combo, TRUE, TRUE, 2);
2070 /* fill the vis combo box and the array of factories */
2071 init_visualization_features ();
2073 panel = boxes = boxes2 = NULL;
2076 /* do the packing stuff ... */
2077 gtk_window_set_default_size (GTK_WINDOW (window), 250, 96);
2078 gtk_container_add (GTK_CONTAINER (window), vbox);
2079 gtk_container_add (GTK_CONTAINER (vbox), hbox);
2080 gtk_box_pack_start (GTK_BOX (hbox), play_button, FALSE, FALSE, 2);
2081 gtk_box_pack_start (GTK_BOX (hbox), pause_button, FALSE, FALSE, 2);
2082 gtk_box_pack_start (GTK_BOX (hbox), stop_button, FALSE, FALSE, 2);
2083 gtk_box_pack_start (GTK_BOX (hbox), flagtable, FALSE, FALSE, 2);
2084 gtk_table_attach_defaults (GTK_TABLE (flagtable), accurate_checkbox, 0, 1, 0,
2086 gtk_table_attach_defaults (GTK_TABLE (flagtable), flush_checkbox, 1, 2, 0, 1);
2087 gtk_table_attach_defaults (GTK_TABLE (flagtable), loop_checkbox, 2, 3, 0, 1);
2088 gtk_table_attach_defaults (GTK_TABLE (flagtable), key_checkbox, 0, 1, 1, 2);
2089 gtk_table_attach_defaults (GTK_TABLE (flagtable), scrub_checkbox, 1, 2, 1, 2);
2090 gtk_table_attach_defaults (GTK_TABLE (flagtable), play_scrub_checkbox, 2, 3,
2092 gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_label, 3, 4, 0, 1);
2093 gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_spinbutton, 3, 4, 1,
2095 if (panel && boxes && boxes2) {
2096 gtk_box_pack_start (GTK_BOX (vbox), panel, TRUE, TRUE, 2);
2097 gtk_box_pack_start (GTK_BOX (vbox), boxes, TRUE, TRUE, 2);
2098 gtk_box_pack_start (GTK_BOX (vbox), boxes2, TRUE, TRUE, 2);
2100 gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
2102 /* connect things ... */
2103 g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
2105 g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
2107 g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
2109 g_signal_connect (G_OBJECT (accurate_checkbox), "toggled",
2110 G_CALLBACK (accurate_toggle_cb), pipeline);
2111 g_signal_connect (G_OBJECT (key_checkbox), "toggled",
2112 G_CALLBACK (key_toggle_cb), pipeline);
2113 g_signal_connect (G_OBJECT (loop_checkbox), "toggled",
2114 G_CALLBACK (loop_toggle_cb), pipeline);
2115 g_signal_connect (G_OBJECT (flush_checkbox), "toggled",
2116 G_CALLBACK (flush_toggle_cb), pipeline);
2117 g_signal_connect (G_OBJECT (scrub_checkbox), "toggled",
2118 G_CALLBACK (scrub_toggle_cb), pipeline);
2119 g_signal_connect (G_OBJECT (play_scrub_checkbox), "toggled",
2120 G_CALLBACK (play_scrub_toggle_cb), pipeline);
2121 g_signal_connect (G_OBJECT (rate_spinbutton), "value_changed",
2122 G_CALLBACK (rate_spinbutton_changed_cb), pipeline);
2124 g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
2127 gtk_widget_show_all (window);
2130 g_signal_connect (pipeline, "deep_notify",
2131 G_CALLBACK (gst_object_default_deep_notify), NULL);
2134 connect_bus_signals (pipeline);
2137 g_print ("NULL pipeline\n");
2138 gst_element_set_state (pipeline, GST_STATE_NULL);
2140 g_print ("free pipeline\n");
2141 gst_object_unref (pipeline);