1 /* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 * DEALINGS IN THE SOFTWARE.
21 * Alternatively, the contents of this file may be used under the
22 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
23 * which case the following provisions apply instead of the ones
26 * This library is free software; you can redistribute it and/or
27 * modify it under the terms of the GNU Library General Public
28 * License as published by the Free Software Foundation; either
29 * version 2 of the License, or (at your option) any later version.
31 * This library is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 * Library General Public License for more details.
36 * You should have received a copy of the GNU Library General Public
37 * License along with this library; if not, write to the
38 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
39 * Boston, MA 02111-1307, USA.
49 main (int argc
, char *argv
[])
51 gchar
**filenames
= NULL
;
53 play_file_args
*args
= &t
;
55 args
->israwfile
= FALSE
;
56 args
->filter_name
= "identity";
57 args
->param_name
= NULL
;
60 args
->num_buffers
= 0;
61 args
->noaudio
= FALSE
;
62 args
->novideo
= FALSE
;
64 const GOptionEntry entries
[] = {
65 { "silent", 's', 0, G_OPTION_ARG_NONE
, &(args
->silent
),
66 "do not output status information", NULL
},
67 { "raw", '\0', 0, G_OPTION_ARG_NONE
, &(args
->israwfile
),
68 "file is raw 32bit-PCM 2ch/LE @ 44100Hz", "FILE" },
69 { "filter", '\0', 0, G_OPTION_ARG_STRING
, &(args
->filter_name
),
71 { "param", '\0', 0, G_OPTION_ARG_STRING
, &(args
->param_name
),
72 "scale parameter name", "NAME" },
73 { "scale", 's', 0, G_OPTION_ARG_DOUBLE
, &(args
->scale
),
74 "playback rate", "FLOAT" },
75 { "temp", '\0', 0, G_OPTION_ARG_DOUBLE
, &(args
->temp
),
77 { "num_buffers", '\0', 0, G_OPTION_ARG_INT
, &(args
->num_buffers
),
78 "number of buffers to play", "INT" },
79 { G_OPTION_REMAINING
, 0, 0, G_OPTION_ARG_FILENAME_ARRAY
, &filenames
,
80 "Special option that collects any remaining arguments for us" },
87 /* Before calling any GLib or GStreamer function, we must initialise
88 * the GLib threading system */
89 if (!g_thread_supported())
92 ctx
= g_option_context_new ("[FILE1] [FILE2] ...");
93 g_option_context_add_group (ctx
, gst_init_get_option_group ());
94 g_option_context_add_main_entries (ctx
, entries
, NULL
);
96 if (!g_option_context_parse (ctx
, &argc
, &argv
, &err
)) {
97 g_print ("Error initializing: %s\n", GST_STR_NULL (err
->message
));
101 g_option_context_free (ctx
);
103 if (filenames
== NULL
|| *filenames
== NULL
) {
104 g_print ("Please specify a file to play\n\n");
108 if (args
->scale
!= 1.0 && !args
->param_name
) {
109 g_print("\n** WARNING: scale set but not param **\n\n");
113 num
= g_strv_length (filenames
);
115 for (i
= 0; i
< num
; ++i
) {
116 play_file (filenames
[i
], args
);
119 g_strfreev (filenames
);