first working version of helloworld in perl no eos signal callback yet some wrapper functions

Original commit message from CVS:
first working version of helloworld in perl
no eos signal callback yet
some wrapper functions
This commit is contained in:
Thomas Vander Stichele 2001-08-13 20:42:20 +00:00
parent de1d561cdb
commit 097ca31255
8 changed files with 113 additions and 20 deletions

View file

@ -4,6 +4,8 @@
%include "typemap.i" %include "typemap.i"
%include "GstPipeline.i" %include "GstPipeline.i"
%include "GstElement.i" %include "GstElement.i"
%include "GstBin.i"
%include "GstPad.i"
%{ %{
#include <gst/gst.h> #include <gst/gst.h>

View file

@ -1,3 +1,17 @@
GstElement* GstElement*
gst_elementfactory_make (const gchar *factoryname, const gchar *name); gst_elementfactory_make (const gchar *factoryname, const gchar *name);
GstPad*
gst_element_get_pad (GstElement *element, const gchar *name);
gint
gst_element_set_state (GstElement *element, GstElementState state);
typedef enum {
GST_STATE_VOID_PENDING = 0,
GST_STATE_NULL = (1 << 0),
GST_STATE_READY = (1 << 1),
GST_STATE_PAUSED = (1 << 2),
GST_STATE_PLAYING = (1 << 3),
} GstElementState;

3
swig/GstPad.i Normal file
View file

@ -0,0 +1,3 @@
gboolean
gst_pad_connect (GstPad *srcpad, GstPad *sinkpad);

15
swig/README Normal file
View file

@ -0,0 +1,15 @@
Perl bindings for Gstreamer
thomas@apestaart.org, August 2001
This is work in progress.
Here's some basic instructions :
* configure gstreamer
* run ./bootstrap in this directory; this will create a symbolic link to
Gst.so which will be made later on so that you can test the module without
installing it.
* run helloworld.pl /path/to/mp3
Some of the gstreamer functions are wrapped up now, we'll change that
later.

View file

@ -1,3 +1,8 @@
#!/bin/bash
if test ! -e Gst.so
then
ln -s blib/arch/auto/Gst/Gst.so
fi
swig -perl5 Gst.i && \ swig -perl5 Gst.i && \
perl Makefile.PL && \ perl Makefile.PL && \
make make

View file

@ -6,18 +6,40 @@ void init ()
int argc = 3; int argc = 3;
char **argv = NULL; char **argv = NULL;
g_module_open ("libgst.so", G_MODULE_BIND_LAZY);
argv = (char **) malloc (sizeof (char *) * 3); argv = (char **) malloc (sizeof (char *) * 3);
argv[0] = (char *) malloc (80); argv[0] = (char *) malloc (80);
argv[1] = (char *) malloc (80); argv[1] = (char *) malloc (80);
argv[2] = (char *) malloc (80); argv[2] = (char *) malloc (80);
strcpy (argv[0], "swigged gst"); strcpy (argv[0], "swigged gst");
strcpy (argv[1], "--gst-debug-mask=-1"); strcpy (argv[1], "--gst-debug-mask=0");
strcpy (argv[2], "--gst-info-mask=-1"); strcpy (argv[2], "--gst-info-mask=0");
gst_init (&argc, &argv); gst_init (&argc, &argv);
} }
void gobject_set (GtkObject* object, const gchar *first_arg_name, const gchar *first_arg_value) // FIXME: find a way to get the actual macro from gobject2gtk in here
void gobject_set (GstElement* element, const gchar *first_arg_name, const gchar *first_arg_value)
{ {
gtk_object_set (object, first_arg_name, first_arg_value); gtk_object_set ((GtkObject*) element, first_arg_name, first_arg_value, NULL);
}
// FIXME: the typecast should be done using typemaps or some other way
void wrap_gst_bin_add (GstElement *bin, GstElement *element)
{
gst_bin_add ((GstBin *) bin, element);
}
// FIXME: no wrapper, the actual enums should be used
gint gst_element_set_state_play (GstElement *bin)
{
gst_element_set_state (bin, GST_STATE_PLAYING);
}
// FIXME: no wrapper, typeconversion should be automatic
gboolean wrap_gst_bin_iterate (GstElement *bin)
{
gst_bin_iterate (bin);
} }

48
swig/helloworld.pl Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/perl -w
use Gst;
Gst::init ();
my $bin = Gst::gst_pipeline_new ("pipeline")
or die "Cannot create pipeline !\n";
print "DEBUG: bin: $bin\n";
my $file = shift || die "Please give a file to test !";
my $parse = Gst::gst_elementfactory_make ("mp3parse", "parse")
or die "Cannot create mp3parse element !\n";
my $disksrc = Gst::gst_elementfactory_make ("disksrc", "disk_source")
or die "Cannot create disksrc element !\n";
Gst::gobject_set ($disksrc, "location", $file);
my $decoder = Gst::gst_elementfactory_make ("mpg123", "decoder")
or die "Cannot create decoder element !\n";
my $osssink = Gst::gst_elementfactory_make ("osssink", "play_audio")
or die "Cannot create decoder element !\n";
Gst::wrap_gst_bin_add ($bin, $disksrc);
Gst::wrap_gst_bin_add ($bin, $parse);
Gst::wrap_gst_bin_add ($bin, $decoder);
Gst::wrap_gst_bin_add ($bin, $osssink);
Gst::gst_pad_connect (Gst::gst_element_get_pad ($disksrc, "src"),
Gst::gst_element_get_pad ($parse, "sink"));
Gst::gst_pad_connect (Gst::gst_element_get_pad ($parse, "src"),
Gst::gst_element_get_pad ($decoder, "sink"));
Gst::gst_pad_connect (Gst::gst_element_get_pad ($decoder, "src"),
Gst::gst_element_get_pad ($osssink, "sink"));
#print "DEBUG: disksrc: $disksrc\n";
#FIXME
#Gst::gst_element_set_state ($bin, GST_STATE_PLAYING);
Gst::gst_element_set_state_play ($bin);
my $playing = 1;
while ($playing)
{
Gst::wrap_gst_bin_iterate ($bin);
}

View file

@ -1,16 +0,0 @@
#!/usr/bin/perl -w
use Gst;
Gst::init ();
my $bin = Gst::gst_pipeline_new ("pipeline")
or die "Cannot create pipeline !\n";
print "DEBUG: bin: $bin\n";
my $parse = Gst::gst_elementfactory_make ("mp3parse", "parse")
or die "Cannot create mp3parse element !\n";
my $disksrc = Gst::gst_elementfactory_make ("disksrc", "disk_source")
or die "Cannot create disksrc element !\n";
print "DEBUG: disksrc: $disksrc\n";
Gst::gobject_set ($disksrc, "location", $ARGV[1]);