mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
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:
parent
de1d561cdb
commit
097ca31255
8 changed files with 113 additions and 20 deletions
|
@ -4,6 +4,8 @@
|
|||
%include "typemap.i"
|
||||
%include "GstPipeline.i"
|
||||
%include "GstElement.i"
|
||||
%include "GstBin.i"
|
||||
%include "GstPad.i"
|
||||
|
||||
%{
|
||||
#include <gst/gst.h>
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
GstElement*
|
||||
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
3
swig/GstPad.i
Normal file
|
@ -0,0 +1,3 @@
|
|||
gboolean
|
||||
gst_pad_connect (GstPad *srcpad, GstPad *sinkpad);
|
||||
|
15
swig/README
Normal file
15
swig/README
Normal 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.
|
|
@ -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 && \
|
||||
perl Makefile.PL && \
|
||||
make
|
||||
|
|
|
@ -6,18 +6,40 @@ void init ()
|
|||
int argc = 3;
|
||||
char **argv = NULL;
|
||||
|
||||
g_module_open ("libgst.so", G_MODULE_BIND_LAZY);
|
||||
|
||||
argv = (char **) malloc (sizeof (char *) * 3);
|
||||
argv[0] = (char *) malloc (80);
|
||||
argv[1] = (char *) malloc (80);
|
||||
argv[2] = (char *) malloc (80);
|
||||
strcpy (argv[0], "swigged gst");
|
||||
strcpy (argv[1], "--gst-debug-mask=-1");
|
||||
strcpy (argv[2], "--gst-info-mask=-1");
|
||||
strcpy (argv[1], "--gst-debug-mask=0");
|
||||
strcpy (argv[2], "--gst-info-mask=0");
|
||||
|
||||
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
48
swig/helloworld.pl
Executable 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);
|
||||
}
|
||||
|
16
swig/test.pl
16
swig/test.pl
|
@ -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]);
|
Loading…
Reference in a new issue