1 /* GStreamer Editing Services
2 * Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 main (int argc, gchar ** argv)
25 GESPipeline *pipeline;
26 GESTimeline *timeline;
33 gst_print ("Usage: %s <list of audio files>\n", argv[0]);
37 /* Initialize GStreamer (this will parse environment variables and commandline
39 gst_init (&argc, &argv);
41 /* Initialize the GStreamer Editing Services */
44 /* Setup of an audio timeline */
46 /* This is our main GESTimeline */
47 timeline = ges_timeline_new ();
49 tracka = GES_TRACK (ges_audio_track_new ());
51 /* We are only going to be doing one layer of clips */
52 layer = ges_layer_new ();
54 /* Add the tracks and the layer to the timeline */
55 if (!ges_timeline_add_layer (timeline, layer))
57 if (!ges_timeline_add_track (timeline, tracka))
60 /* Here we've finished initializing our timeline, we're
61 * ready to start using it... by solely working with the layer ! */
63 for (i = 1; i < argc; i++) {
64 gchar *uri = gst_filename_to_uri (argv[i], NULL);
65 GESUriClip *src = ges_uri_clip_new (uri);
70 g_object_set (src, "start", ges_layer_get_duration (layer),
71 "duration", GST_SECOND, NULL);
72 ges_layer_add_clip (layer, (GESClip *) src);
75 /* In order to view our timeline, let's grab a convenience pipeline to put
77 pipeline = ges_pipeline_new ();
79 /* Add the timeline to that pipeline */
80 if (!ges_pipeline_set_timeline (pipeline, timeline))
83 /* The following is standard usage of a GStreamer pipeline (note how you haven't
84 * had to care about GStreamer so far ?).
86 * We set the pipeline to playing ... */
87 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
89 /* .. and we start a GMainLoop. GES **REQUIRES** a GMainLoop to be running in
90 * order to function properly ! */
91 mainloop = g_main_loop_new (NULL, FALSE);
93 /* Simple code to have the mainloop shutdown after 4s */
94 g_timeout_add_seconds (argc - 1, (GSourceFunc) g_main_loop_quit, mainloop);
95 g_main_loop_run (mainloop);