#!/usr/bin/perl

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

my $streamout;
my $streamin;

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

my $com=$ARGV[1];

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


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


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

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

system "glc-play /tmp/glcfifo -y 1 -o \"$streamin\" &";

system "lives -noset -yuvin \"$streamin\"";

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

