[gst-devel] new plugin & fix for int2float filter

Leif Morgan Johnson lmjohns3 at eos.ncsu.edu
Sun Nov 25 18:04:03 CET 2001


hi all -

never posted to the list before, but Wingo and i have been working on some
gstreamer stuff as of late. there are two updates i'd like to see if i
could get checked into the gstreamer cvs :

1. a new filter plugin, playondemand.

   in brief : the filter keeps an internal storage buffer that records the
   data coming in on the filter's sink pad. it also keeps an array of
   buffer offsets. on startup, the array of offsets contains only invalid
   values (initialized to G_MAXUINT), and the filter outputs silence
   (i.e., it traps incoming data and outputs nothing). but when the filter
   receives a 'play' signal it adds an offset to the array and starts
   putting data from its internal buffer on its src pad. sending multiple
   'play' signals creates multiple offsets, causing the output stream to
   contain multiple copies of whatever the input stream was, all added
   together. offsets are reset to G_MAXUINT when they surpass the internal
   buffer's stored data.

   the filter can be set to play either the first x seconds of an input
   stream (where the internal buffer acts as a simple straight buffer) or
   the last x seconds of an input stream (where the internal buffer is
   treated as a ring buffer).

   the filter traps (accepts but does not pass on) eos events to prevent
   the pipeline from shutting down. this is because the filter needs to be
   able to output buffers even after the input stream has ended.

   the motivation for this plugin comes from a drum machine type program
   Wingo and i are working on : we needed some way to be able to play a
   sound at given times (on certain beats), even after the end of the
   input sound, without changing around the pipeline. the reason i'm
   sending the plugin to the list is that it seemed potentially useful for
   other apps as well.

2. a slight modification of int2float that allows multiple src request
   pads to duplicate the incoming stream to arbitrarily many output
   streams.

   Wingo and i made these changes because we wanted to convert a mono or
   stereo (noninterleaved or interleaved integer, respectively) input
   stream to many separate (noninterleaved float) output streams.

so, with that said, the files attached to this email are :

1. playondemand.tar.gz - the playondemand filter directory. packed from
   gstreamer/plugins/filters/ on my machine.

2. 20011125-gstreamer.patch - patch for the int2float filter and for the
   playondemand plugin changes to gstreamer/configure.base and
   gstreamer/plugins/filters/Makefile.am. created with "cvs diff -u" from
   gstreamer/.

3. testpod.c - small test app for playondemand filter. was in
   gstreamer/test/ on my machine. not too pretty, but it is fun to press
   the play button and hear a new copy of the input stream ...

ok, hope that wasn't too long. cheers !

leif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: playondemand.tar.gz
Type: application/octet-stream
Size: 5747 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20011125/65091858/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testpod.c
Type: text/x-csrc
Size: 2844 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20011125/65091858/attachment.c>
-------------- next part --------------
? automake
? patch.patch
? reg.xml
? tmp.wav
? translog.20011124153352.log
? plugins/filters/playondemand
? plugins/filters/playondemand.tar.gz
? test/testpod
? test/testpod.c
? test/events/seek
? test/memchunk/gmemchunktest
? test/memchunk/gstmemchunktest
? tests/timecache
Index: configure.base
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/configure.base,v
retrieving revision 1.100
diff -u -r1.100 configure.base
--- configure.base	2001/11/21 23:07:36	1.100
+++ configure.base	2001/11/25 23:56:38
@@ -1255,6 +1255,7 @@
 plugins/filters/deinterlace/Makefile
 plugins/filters/volume/Makefile
 plugins/filters/speed/Makefile
+plugins/filters/playondemand/Makefile
 plugins/gnomevfs/Makefile
 plugins/icecast/Makefile
 plugins/icecast/icecastsend/Makefile
Index: plugins/filters/Makefile.am
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/filters/Makefile.am,v
retrieving revision 1.17
diff -u -r1.17 Makefile.am
--- plugins/filters/Makefile.am	2001/07/10 23:47:30	1.17
+++ plugins/filters/Makefile.am	2001/11/25 23:56:40
@@ -12,10 +12,10 @@
 
 SUBDIRS = smooth median stereo2mono mono2stereo intfloatconvert \
 passthrough volenv adder level $(OSS_SUBDS) $(HERMES_SUBDS) lav \
-deinterlace speed volume
+deinterlace speed volume playondemand
 
 # cutter -- FIXME!
 
 DIST_SUBDIRS = smooth median stereo2mono mono2stereo intfloatconvert \
 passthrough volenv adder level cutter ladspa colorspace lav \
-deinterlace speed volume
+deinterlace speed volume playondemand
Index: plugins/filters/intfloatconvert/int2float.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/filters/intfloatconvert/int2float.c,v
retrieving revision 1.8
diff -u -r1.8 int2float.c
--- plugins/filters/intfloatconvert/int2float.c	2001/10/17 10:21:25	1.8
+++ plugins/filters/intfloatconvert/int2float.c	2001/11/25 23:56:40
@@ -286,11 +286,11 @@
 
   num_frames = GST_BUFFER_SIZE(buf_in)/(2*plugin->channels);
   data_in=(gint16 *)GST_BUFFER_DATA(buf_in);
-  buffers = g_new0(GstBuffer*,plugin->channels);
+  buffers = g_new0(GstBuffer*, plugin->numsrcpads);
   buffer_byte_size = sizeof(gfloat) * num_frames;
   pool = gst_buffer_pool_get_default (buffer_byte_size, 4);
   
-  for (i = 0; (i < plugin->channels) && (i < plugin->numsrcpads); i++) {
+  for (i = 0; i < plugin->numsrcpads; i++) {
 
     buffers[i] = gst_buffer_new_from_pool(pool, 0, 0);
     
@@ -298,14 +298,14 @@
     GST_BUFFER_SIZE(buffers[i]) = buffer_byte_size;
     
     for (j = 0; j < num_frames; j++) {
-      data_out[j] = ((gfloat)data_in[(j*plugin->channels) + i]) / 32767.0;
+      data_out[j] = ((gfloat)data_in[(j*plugin->channels) + (i % plugin->channels)]) / 32767.0;
     }
   }
 
   gst_buffer_unref(buf_in);
   srcpads=plugin->srcpads;
    
-  for (i = 0; (i < plugin->channels) && (srcpads != NULL) ; i++) {
+  for (i = 0; srcpads != NULL; i++) {
     // g_print("pushing to %s:%s\n", GST_DEBUG_PAD_NAME(GST_INT2FLOAT_SRCPAD(srcpads)));
 
     gst_pad_push(GST_INT2FLOAT_SRCPAD(srcpads),buffers[i]);


More information about the gstreamer-devel mailing list