]> git.parisson.com Git - timeside.git/commitdiff
Merge fix_streaming_bugbranch in dev + Core : enable to run pipe with only a decoder
authorThomas Fillon <thomas@parisson.com>
Fri, 14 Feb 2014 10:53:54 +0000 (11:53 +0100)
committerThomas Fillon <thomas@parisson.com>
Fri, 14 Feb 2014 10:53:54 +0000 (11:53 +0100)
1  2 
timeside/core.py
timeside/encoder/core.py
timeside/encoder/mp3.py
timeside/tools/gstutils.py

index 1f6e13bac37de324a18d690a72811e79b403a97c,df01a7b99f70276c4fee7fe162f18e6125f1efab..5d16bd47d6630aa2713c15bbeb430526b2f59aad
@@@ -298,6 -305,12 +305,13 @@@ class ProcessPipe(object)
              last = item
  
          # now stream audio data along the pipe
 -            self._is_running = True
+         if self._stream_thread:
+             self._running_cond.acquire()
++        self._is_running = True
++        if self._stream_thread:
+             self._running_cond.notify()
+             self._running_cond.release()
          eod = False
  
          if source.id() == 'gst_live_dec':
index 24cc82358ed8a27c350b88c56872c8d192f4c1e6,db34c41a8908b654473241435a3fb4833c64b406..df0d3d8f09303b6918d9a749027a7f354463a083
  
  
  from timeside.core import Processor, implements, interfacedoc
- from timeside.component import implements, abstract
+ from timeside.component import abstract
  from timeside.api import IEncoder
- from timeside.tools import *
- from gst import _gst as gst
- import threading
+ from timeside.tools import numpy_array_to_gst_buffer, MainloopThread
  
 -#from gst import _gst as gst
+ import pygst
+ pygst.require('0.10')
+ import gst
  
- class MainloopThread(threading.Thread):
+ import gobject
+ gobject.threads_init()
  
-     def __init__(self, mainloop):
-         threading.Thread.__init__(self)
-         self.mainloop = mainloop
+ import threading
  
-     def run(self):
-         self.mainloop.run()
+ # Streaming queue configuration
+ QUEUE_SIZE = 10
+ GST_APPSINK_MAX_BUFFERS = 10
  
  
  class GstEncoder(Processor):
              self.end_cond.notify()
              self.end_cond.release()
  
+     def _on_new_buffer_streaming(self, appsink):
+         #print 'pull-buffer'
+         chunk = appsink.emit('pull-buffer')
+         self._streaming_queue.put(chunk)
+     def _on_new_preroll_streaming(self, appsink):
+         # print 'preroll'
+         chunk = appsink.emit('pull-preroll')
+         self._streaming_queue.put(chunk)
 +    @interfacedoc
 +    def set_metadata(self, metadata):
 +        self.metadata = metadata
 +
      @interfacedoc
      def process(self, frames, eod=False):
          self.eod = eod
          if eod:
-             self.num_samples +=  frames.shape[0]
+             self.num_samples += frames.shape[0]
          else:
              self.num_samples += self.blocksize()
-         buf = numpy_array_to_gst_buffer(frames, frames.shape[0], self.num_samples, self.samplerate())
++
+         buf = numpy_array_to_gst_buffer(frames, frames.shape[0],
+                                         self.num_samples, self.samplerate())
++
          self.src.emit('push-buffer', buf)
          if self.eod:
              self.src.emit('end-of-stream')
index 61b9e4cca8924110568e46178d738b74594f00a2,2d5addcd46f78a4c56a87e021d12c26aa73fcbaf..a69b6e5ab39fa751a8d63148083275f6b0403492
@@@ -27,7 -28,8 +28,7 @@@
  from timeside.core import implements, interfacedoc
  from timeside.encoder.core import GstEncoder
  from timeside.api import IEncoder
- from timeside.tools import *
 -import mutagen
  
  
  class Mp3Encoder(GstEncoder):
index cb6406848624ced26bcd27b6aa01b14d970b1ca3,2722085c297ceeaef77ef5ec2ff3c7691f420ec5..67e09c64aac59703527c40ad81536fa456e400e6
@@@ -6,8 -6,10 +6,10 @@@ import gs
  import gobject
  gobject.threads_init()
  
+ import threading
  
 -def numpy_array_to_gst_buffer(frames, CHUNK_SIZE, num_samples, SAMPLE_RATE):
 +def numpy_array_to_gst_buffer(frames, chunk_size, num_samples, sample_rate):
      from gst import Buffer
      """ gstreamer buffer to numpy array conversion """
      buf = Buffer(getbuffer(frames.astype("float32")))