from timeside.core import Processor, implements, interfacedoc
from timeside.api import IDecoder
-from numpy import array, frombuffer, getbuffer, float32
+from numpy import array, frombuffer, getbuffer, float32, append
import Queue
import pygst
# the output data format we want
caps = "audio/x-raw-float, width=32"
- self.pipeline = gst.parse_launch('''uridecodebin uri="%s"
+ self.pipeline = gst.parse_launch('''uridecodebin uri="%s" name=src
! audioconvert
! %s
! appsink name=sink sync=False ''' % (self.uri, caps))
self.sink = self.pipeline.get_by_name('sink')
self.sink.set_property('emit-signals', True)
# adjust length of emitted buffers
- self.sink.set_property('blocksize', 16384)
+# self.sink.set_property('blocksize', self.buffer_size)
+ self.src = self.pipeline.get_by_name('src')
+# self.src.set_property('use-buffering', True)
+# self.src.set_property('buffer_size', self.buffer_size)
# start pipeline
self.pipeline.set_state(gst.STATE_PLAYING)
@interfacedoc
def process(self, frames = None, eod = False):
try:
- buf = self.sink.emit('pull-buffer')
+ buf = self.sink.emit('pull-buffer')
except SystemError, e:
# should never happen
print 'SystemError', e
super(VorbisEncoder, self).setup(channels, samplerate, nframes)
# TODO open file for writing
# the output data format we want
- pipe = ''' appsrc name=src
+ self.pipe = ''' appsrc name=src
! audioconvert
! vorbisenc
! oggmux
'''
if self.filename and self.streaming:
- pipe += '''
+ self.pipe += '''
! tee name=t
! queue ! appsink name=app sync=False
t. ! queue ! filesink location=%s
''' % self.filename
elif self.filename :
- pipe += '! filesink location=%s ' % self.filename
+ self.pipe += '! filesink location=%s ' % self.filename
else:
- pipe += '! appsink name=app sync=False '
+ self.pipe += '! appsink name=app sync=False '
- self.pipeline = gst.parse_launch(pipe)
+ self.pipeline = gst.parse_launch(self.pipe)
# store a pointer to appsrc in our encoder object
self.src = self.pipeline.get_by_name('src')
# store a pointer to appsink in our encoder object