tizen 2.0 init
[framework/multimedia/gst-plugins-base0.10.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
11 my (%pipes, %cfg);
12
13 sub read_config
14 {
15   my $config_file = `echo -n ~`."/.gst";
16   if (-e $config_file)
17   {
18     open CONFIG, $config_file;
19     while (<CONFIG>)
20     {
21       chomp;
22       s/#.*//;
23       s/\s+$//;
24       next unless length;
25       my ($var, $value) = split (/\s*=\s*/, $_, 2);
26       $cfg{$var} = $value;
27     }
28     if (!($cfg{AUDIOSRC}))
29     {
30       print "Please add an AUDIOSRC to $config_file !\n";
31     }
32     if (!($cfg{VIDEOSINK}))
33     {
34       print "Please add a VIDEOSINK to $config_file !\n";
35     }
36   }
37   else
38   {
39     print "No configuration file $config_file found.  You might want to create one.\n";
40   }
41   if (!defined $cfg{AUDIOSRC})   { $cfg{AUDIOSRC} = "osssrc"; }
42   if (!defined $cfg{VIDEOSINK})  { $cfg{VIDEOSINK} = "xvimagesink"; }
43   if (!defined $cfg{CVS_PATH})   { $cfg{CVS_PATH} =  `echo -n ~`."/gst/cvs"; }
44 }
45
46 sub visualise(@)
47 {
48     my $vis = $cfg{VISUALIZER};
49     $vis = shift() if ($#_ != -1);
50     $vis = "goom" unless $vis;
51
52     my $pipe;
53     $pipe = $vis unless $pipe = $pipes{$vis};
54
55     $command = "gst-launch-@GST_MAJORMINOR@ $cfg{AUDIOSRC} ! $pipe ! { queue ! ffmpegcolorspace ! $cfg{VIDEOSINK} }";
56     print "Running $command\n";
57     system ("PATH=\$PATH:".$cfg{CVS_PATH}."/gstreamer/tools $command");
58 }
59
60 ### main
61
62 read_config ();
63
64 %pipes = ( 
65   "goom", "goom",
66   "chart", "audioconvert ! chart",
67   "synaesthesia", "synaesthesia",
68   "monoscope", "audioconvert ! monoscope"
69 );
70
71 if ($#ARGV > 0) {
72     print STDERR "Usage: gst-visualise [visualiser]\n";
73     exit 1;
74 }
75
76 visualise(@ARGV);
77