1
/* GST123 - GStreamer based command line media player
2
* Copyright (C) 2006-2010 Stefan Westerfeld
3
* Copyright (C) 2010 أحمد المحمودي (Ahmed El-Mahmoudy)
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General
16
* Public License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18
* Boston, MA 02111-1307, USA.
27
#include "gtkinterface.h"
29
Options *Options::instance = NULL;
34
instance = this; // singleton
36
program_name = "gst123";
44
Options::parse (int argc, char **argv)
46
GOptionContext *context = g_option_context_new ("<URI>... - Play video and audio clips");
47
const GOptionEntry all_options[] = {
48
{"list", '@', G_OPTION_FLAG_FILENAME, G_OPTION_ARG_CALLBACK,
49
(GOptionParseFunc*) Options::add_playlist,
50
"read playlist of files and URIs from <filename>", "<filename>"},
51
{"version", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
52
(GOptionParseFunc*) Options::print_version, "print version", NULL },
53
{"verbose", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &instance->verbose,
54
"print GStreamer pipeline used to play files", NULL},
55
{"shuffle", 'z', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &instance->shuffle,
56
"play files in pseudo random order", NULL},
57
{"novideo", 'x', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE, &instance->novideo,
58
"do not play the video stream", NULL},
59
{G_OPTION_REMAINING, '\0', G_OPTION_FLAG_FILENAME, G_OPTION_ARG_FILENAME_ARRAY, &instance->uris, "Movies to play", NULL},
60
{NULL} /* end the list */
62
g_option_context_add_main_entries (context, all_options, NULL);
63
g_option_context_add_group (context, gst_init_get_option_group());
65
if (GtkInterface::have_x11_display())
66
g_option_context_add_group (context, gtk_get_option_group (TRUE));
69
bool option_parse_ret = g_option_context_parse (context, &argc, &argv, &error);
70
usage = g_option_context_get_help (context, TRUE, NULL);
71
if (!option_parse_ret)
73
g_print ("%s\n%s", error->message, usage.c_str());
75
g_option_context_free (context);
78
g_option_context_free (context);
82
Options::print_version ()
84
printf ("%s %s\n", instance->program_name.c_str(), VERSION);
89
Options::add_playlist (const gchar *option_name, const gchar *value)
91
instance->playlists.push_back (value);