implement gui/tui
[gst-scaletempo-demo-rj.git] / src / main.c
blobf54b3ae7892cf23765666d76bdbefa9dc6c7e642
1 /* main.c
2 * Copyright (C) 2008 Rov Juvano <rovjuvano@users.sourceforge.net>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
22 #include "gst-app.h"
24 int
25 main (int argc, char *argv[])
27 gchar **uris = NULL;
28 gboolean no_gui = FALSE;
29 gchar *filter_name = "identity";
31 const GOptionEntry entries[] = {
32 { "filter", '\0', 0, G_OPTION_ARG_STRING, &filter_name,
33 "filter", "NAME" },
34 { "no-gui", '\0', 0, G_OPTION_ARG_NONE, &no_gui,
35 "do not lauch GUI", NULL },
36 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uris,
37 "Special option that collects any remaining arguments for us" },
38 { NULL, }
40 GOptionContext *ctx;
41 GError *err = NULL;
43 /* Before calling any GLib or GStreamer function, we must initialise
44 * the GLib threading system */
45 if (!g_thread_supported())
46 g_thread_init (NULL);
48 ctx = g_option_context_new ("[ --filter=<plugin> ] uri ...");
49 g_option_context_add_group (ctx, gst_init_get_option_group ());
50 g_option_context_add_main_entries (ctx, entries, NULL);
52 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
53 g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
54 g_error_free (err);
55 return -1;
57 g_option_context_free (ctx);
59 if (uris == NULL || *uris == NULL) {
60 g_print ("Please specify a URI to play\n\n");
61 return -1;
64 gint i, num = g_strv_length (uris);
65 gpointer *window_ref = NULL;
67 for (i = 0; i < num; i++) {
68 if (no_gui) {
69 tui_play_uri(uris[i], filter_name);
70 } else {
71 if (!window_ref || !*window_ref)
72 gui_build(argc, argv, &window_ref);
73 gui_play_uri(uris[i], filter_name);
76 g_strfreev (uris);
78 return 0;