GObject boilerplate
[gst-scaletempo-demo-rj.git] / src / demo-main.c
blob15fb3b09be8ea1ffe449fad1932af1bd3dc0b8fd
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/gst.h>
23 #include "demo-player.h"
25 int
26 main (int argc, char *argv[])
28 gchar **uris = NULL;
29 gchar *filter_name = "identity";
31 const GOptionEntry entries[] = {
32 { "filter", '\0', 0, G_OPTION_ARG_STRING, &filter_name,
33 "filter", "NAME" },
34 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uris,
35 "Special option that collects any remaining arguments for us" },
36 { NULL, }
39 if (!g_thread_supported())
40 g_thread_init (NULL);
42 GOptionContext *ctx = g_option_context_new ("[ --filter=<plugin> ] uri ...");
43 g_option_context_add_group (ctx, gst_init_get_option_group ());
44 g_option_context_add_main_entries (ctx, entries, NULL);
45 GError *err = NULL;
46 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
47 g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
48 g_error_free (err);
49 return -1;
51 g_option_context_free (ctx);
53 if (uris == NULL || *uris == NULL) {
54 g_print ("Please specify a URI to play\n\n");
55 return -1;
58 DemoPlayer *player = g_object_new (DEMO_TYPE_PLAYER, "filter", filter_name, NULL);
59 g_print ("Hello World!\nFilter = %s\n", player->filter);
61 gint i, num = g_strv_length (uris);
62 for (i = 0; i < num; i++) {
63 demo_player_play_uri(player, uris[i]);
65 g_strfreev (uris);
67 return 0;