-Wold-style-definition is not valid for C++
[platform/upstream/gstreamer.git] / tools / gst-visualise-m.m
1 #!/usr/bin/perl -w
2
3 # launch a gst-launch pipeline to display a visualisation of the 
4 # input audio.
5 # make use of default input srcs.
6 # visualisation plugin is specified on command line.
7
8 ### packages
9
10 use File::Basename;
11
12
13 my (%pipes, %cfg);
14
15 sub read_config
16 {
17   my $config_file = `echo -n ~`."/.gst";
18   if (-e $config_file)
19   {
20     open CONFIG, $config_file;
21     while (<CONFIG>)
22     {
23       chomp;
24       s/#.*//;
25       s/\s+$//;
26       next unless length;
27       my ($var, $value) = split (/\s*=\s*/, $_, 2);
28       $cfg{$var} = $value;
29     }
30     if (!($cfg{AUDIOSRC}))
31     {
32       print "Please add an AUDIOSRC to $config_file !\n";
33     }
34     if (!($cfg{VIDEOSINK}))
35     {
36       print "Please add a VIDEOSINK to $config_file !\n";
37     }
38   }
39   else
40   {
41     print "No configuration file $config_file found.  You might want to create one.\n";
42   }
43   if (!defined $cfg{AUDIOSRC})   { $cfg{AUDIOSRC} = "osssrc"; }
44   if (!defined $cfg{VIDEOSINK})  { $cfg{VIDEOSINK} = "xvimagesink"; }
45   if (!defined $cfg{CVS_PATH})   { $cfg{CVS_PATH} =  `echo -n ~`."/gst/cvs"; }
46 }
47
48 sub visualise(@)
49 {
50     my $vis = $cfg{VISUALIZER};
51     $vis = shift() if ($#_ != -1);
52     $vis = "goom" unless $vis;
53
54     my $pipe;
55     $pipe = $vis unless $pipe = $pipes{$vis};
56
57     $command = "gst-launch-@GST_MAJORMINOR@ $cfg{AUDIOSRC} ! $pipe ! { queue ! ffmpegcolorspace ! $cfg{VIDEOSINK} }";
58     print "Running $command\n";
59     system ("PATH=\$PATH:".$cfg{CVS_PATH}."/gstreamer/tools $command");
60 }
61
62 ### main
63
64 read_config ();
65
66 %pipes = ( 
67   "goom", "goom",
68   "chart", "audioconvert ! chart",
69   "synaesthesia", "synaesthesia",
70   "monoscope", "audioconvert ! monoscope"
71 );
72
73 if ($#ARGV > 0) {
74     print STDERR "Usage: gst-visualise [visualiser]\n";
75     exit 1;
76 }
77
78 visualise(@ARGV);
79