add gui
[gst-scaletempo-demo-rj.git] / src / main.c
blobfab67557df35c9df50ddbdb1a9152265e9b16d9d
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 **filenames = NULL;
28 pipeline_args t;
29 pipeline_args *args = &t;
30 args->silent = FALSE;
31 args->israwfile = FALSE;
32 args->filter_name = "identity";
33 args->param_name = NULL;
34 args->scale = 1.0;
35 args->temp = 1.0;
36 args->num_buffers = 0;
37 args->noaudio = FALSE;
38 args->novideo = FALSE;
40 const GOptionEntry entries[] = {
41 { "silent", 's', 0, G_OPTION_ARG_NONE, &(args->silent),
42 "do not output status information", NULL },
43 { "raw", '\0', 0, G_OPTION_ARG_NONE, &(args->israwfile),
44 "file is raw 32bit-PCM 2ch/LE @ 44100Hz", "FILE" },
45 { "filter", '\0', 0, G_OPTION_ARG_STRING, &(args->filter_name),
46 "filter", "NAME" },
47 { "param", '\0', 0, G_OPTION_ARG_STRING, &(args->param_name),
48 "scale parameter name", "NAME" },
49 { "scale", 's', 0, G_OPTION_ARG_DOUBLE, &(args->scale),
50 "playback rate", "FLOAT" },
51 { "temp", '\0', 0, G_OPTION_ARG_DOUBLE, &(args->temp),
52 "temp", "FLOAT" },
53 { "num_buffers", '\0', 0, G_OPTION_ARG_INT, &(args->num_buffers),
54 "number of buffers to play", "INT" },
55 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
56 "Special option that collects any remaining arguments for us" },
57 { NULL, }
59 GOptionContext *ctx;
60 GError *err = NULL;
62 /* Before calling any GLib or GStreamer function, we must initialise
63 * the GLib threading system */
64 if (!g_thread_supported())
65 g_thread_init (NULL);
67 ctx = g_option_context_new ("[FILE1] [FILE2] ...");
68 g_option_context_add_group (ctx, gst_init_get_option_group ());
69 g_option_context_add_main_entries (ctx, entries, NULL);
71 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
72 g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
73 g_error_free (err);
74 return -1;
76 g_option_context_free (ctx);
78 if (filenames == NULL || *filenames == NULL) {
79 g_print ("Please specify a file to play\n\n");
80 return -1;
83 if (args->scale != 1.0 && !args->param_name) {
84 g_print("\n** WARNING: scale set but not param **\n\n");
85 return -1;
88 lauch_gui(&argc, &argv, filenames, args);
90 g_strfreev (filenames);
91 return 0;