#!/usr/bin/perl

my $home=$ENV{"HOME"};

my $streamout;
my $streamin;

if (!defined($ARGV[0])) {
   exit 1;
}

my $com=$ARGV[0];

if (defined($ARGV[1])) {
   $streamout=$ARGV[1];
}	
else {
     $streamout="/tmp/glcfifo";
}


if (defined($ARGV[2])) {
   $streamin=$ARGV[2];
}	
else {
     $streamin="$home/lives-glcstream.yuv";
}


system "mkfifo \"$streamin\"";
system "mkfifo \"$streamout\"";

system "glc-capture --disable-audio -b back -i -f 25 -s -z none -c 640x480+192+100 -g -o \"$streamout\" \"$com\" &";

system "glc-play -f 25 -t /tmp/glcfifo -y 1 -o \"$streamin\"";

unlink "$streamin";
unlink "$streamout";

