diff --git a/ChangeLog b/ChangeLog index 7d91d67..5de7d68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-05-23 Thomas Vander Stichele + + * morituri/common/encode.py: + Convert TagReadTask to gstreamer.GstPipelineTask and + remove lots of duplicate code. + 2011-05-23 Thomas Vander Stichele * morituri/common/checksum.py: diff --git a/morituri/common/encode.py b/morituri/common/encode.py index 207993b..a069f9a 100644 --- a/morituri/common/encode.py +++ b/morituri/common/encode.py @@ -251,7 +251,7 @@ class EncodeTask(gstreamer.GstPipelineTask): else: self.warning('No peak found, something went wrong!') -class TagReadTask(task.Task): +class TagReadTask(gstreamer.GstPipelineTask): """ I am a task that reads tags. @@ -272,54 +272,21 @@ class TagReadTask(task.Task): self._path = path - def start(self, runner): - task.Task.start(self, runner) - - # here to avoid import gst eating our options - import gst - - self._pipeline = gst.parse_launch(''' + def getPipelineDesc(self): + return ''' filesrc location="%s" ! decodebin name=decoder ! fakesink''' % ( - common.quoteParse(self._path).encode('utf-8'))) + common.quoteParse(self._path).encode('utf-8')) - self.debug('pausing pipeline') - self._pipeline.set_state(gst.STATE_PAUSED) - ret = self._pipeline.get_state() - self.debug('paused pipeline, get_state returned %r', ret) - - # add eos handling - bus = self._pipeline.get_bus() - bus.add_signal_watch() - bus.connect('message::eos', self._message_eos_cb) - - # set up tag callbacks - bus.connect('message::tag', self._message_tag_cb) - - def play(): - self._pipeline.set_state(gst.STATE_PLAYING) - return False - self.runner.schedule(0, play) - - def _message_eos_cb(self, bus, message): + def bus_eos_cb(self, bus, message): self.debug('eos, scheduling stop') self.runner.schedule(0, self.stop) - def _message_tag_cb(self, bus, message): + def bus_tag_cb(self, bus, message): taglist = message.parse_tag() self.taglist = taglist - def stop(self): - # here to avoid import gst eating our options - import gst - - self.debug('stopping') - self.debug('setting state to NULL') - self._pipeline.set_state(gst.STATE_NULL) - self.debug('set state to NULL') - task.Task.stop(self) - class TagWriteTask(task.Task): """ I am a task that retags an encoded file.