#!/usr/bin/perl
use utf8;
use strict;
use warnings;
use GStreamer -init;

# my $pipeline = GStreamer::Pipeline->new("pipeline");
my $pipeline = GStreamer::Thread->new("pipeline");
my $thread = GStreamer::Thread->new("thread");

my ($source, $decode, $queue, $sink) =
  GStreamer::ElementFactory->make(filesrc => "file",
                                  mad => "decode",
                                  queue => "queue",
                                  osssink => "sink");

$source->set(location => $ARGV[0]);

$pipeline->add($source, $decode, $queue);
$thread->add($sink);
$pipeline->add($thread);

$source->link($decode, $queue, $sink);

$pipeline->set_state("playing");

# while ($pipeline->iterate) {}
GStreamer->main;

$pipeline->set_state("null");
