]> git.parisson.com Git - timeside.git/commitdiff
Fix gstreamer caps issue in decoder core related to Gnonlin
authorThomas Fillon <thomas@parisson.com>
Wed, 17 Jul 2013 09:04:34 +0000 (11:04 +0200)
committerThomas Fillon <thomas@parisson.com>
Mon, 19 Aug 2013 13:23:30 +0000 (15:23 +0200)
Gnonlin gnlurisource needs the fields 'start' and 'duration' to be set to be abble to query the duration of the segment

timeside/core.py
timeside/decoder/core.py

index 1f8337af7519bc6f08b5e28f3917c68193021c9d..6979b8beea563d8ee1e2d979ac168d58f2be2e9a 100644 (file)
@@ -232,4 +232,4 @@ class ProcessPipe(object):
         for item in items:
             item.release()
 
-        return self
+        return self
\ No newline at end of file
index 54aaab23561d94a0db49c6b437e97e3fb13cf6c4..e6d838064aa4eff3c290846b9c16ff4669af3fa9 100644 (file)
@@ -68,7 +68,7 @@ class FileDecoder(Processor):
             self.uri = uri
         else:
             raise IOError, 'File not found!'
-        
+
         if uri_segment:
             self.uri_start = uri_segment['start']
             self.uri_duration = uri_segment['duration']
@@ -92,6 +92,8 @@ class FileDecoder(Processor):
             uri_start = uint64(round(self.uri_start*gst.SECOND))
             uri_duration = int64(round(self.uri_duration*gst.SECOND))
             self.pipe = ''' gnlurisource uri={uri}
+                            start=0
+                            duration={uri_duration}
                             media-start={uri_start}
                             media-duration={uri_duration}
                             ! audioconvert name=audioconvert
@@ -104,7 +106,7 @@ class FileDecoder(Processor):
                             ! audioresample
                             ! appsink name=sink sync=False async=True
                             '''.format(**locals())
-                        
+
         self.pipeline = gst.parse_launch(self.pipe)
 
         if self.output_channels:
@@ -138,6 +140,7 @@ class FileDecoder(Processor):
         self.queue = Queue.Queue(QUEUE_SIZE)
 
         import threading
+
         class MainloopThread(threading.Thread):
             def __init__(self, mainloop):
                 threading.Thread.__init__(self)
@@ -160,11 +163,11 @@ class FileDecoder(Processor):
 
         self.discovered_cond.acquire()
         while not self.discovered:
-          #print 'waiting'
-          self.discovered_cond.wait()
+            #print 'waiting'
+            self.discovered_cond.wait()
         self.discovered_cond.release()
 
-        if not hasattr(self,'input_samplerate'):
+        if not hasattr(self, 'input_samplerate'):
             if hasattr(self, 'error_msg'):
                 raise IOError(self.error_msg)
             else:
@@ -198,10 +201,10 @@ class FileDecoder(Processor):
         if "audio" in caps.to_string():
             self.input_samplerate = caps[0]["rate"]
             if not self.output_samplerate:
-              self.output_samplerate = self.input_samplerate
+                self.output_samplerate = self.input_samplerate
             self.input_channels = caps[0]["channels"]
             if not self.output_channels:
-              self.output_channels = self.input_channels
+                self.output_channels = self.input_channels
             self.input_duration = length / 1.e9
             self.input_totalframes = int(self.input_duration * self.input_samplerate)
             if "x-raw-float" in caps.to_string():
@@ -246,10 +249,10 @@ class FileDecoder(Processor):
             new_block = self.last_buffer[:self.output_blocksize]
             self.last_buffer = self.last_buffer[self.output_blocksize:]
             #print 'queueing', new_block.shape, 'remaining', self.last_buffer.shape
-            self.queue.put( [new_block, False ] )
+            self.queue.put([new_block, False])
 
     @interfacedoc
-    def process(self, frames = None, eod = False):
+    def process(self, frames=None, eod=False):
         buf = self.queue.get()
         if buf == gst.MESSAGE_EOS:
             return self.last_buffer, True
@@ -258,7 +261,7 @@ class FileDecoder(Processor):
 
     @interfacedoc
     def channels(self):
-        return  self.output_channels
+        return self.output_channels
 
     @interfacedoc
     def samplerate(self):
@@ -305,5 +308,4 @@ class FileDecoder(Processor):
     @interfacedoc
     def metadata(self):
         # TODO check
-        return self.tags
-
+        return self.tags
\ No newline at end of file