[transmageddon] Fix error handling for missing parsers
- From: Christian Fredrik Kalager Schaller <uraeus src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [transmageddon] Fix error handling for missing parsers
- Date: Sat, 10 Oct 2009 23:26:10 +0000 (UTC)
commit f9373d6fb95591e7b3077a111224582127718900
Author: Christian F.K. Schaller <christian schaller collabora co uk>
Date: Sun Oct 11 00:25:47 2009 +0100
Fix error handling for missing parsers
src/transcoder_engine.py | 33 +++++++++++++++++++++++++++++----
src/transmageddon.py | 38 +++++++++++++++++++++++++++++++-------
2 files changed, 60 insertions(+), 11 deletions(-)
---
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index 83e918c..2d70c8e 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -34,7 +34,8 @@ class Transcoder(gobject.GObject):
__gsignals__ = {
'ready-for-querying' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
- 'got-eos' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
+ 'got-eos' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+ 'got-error' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
}
def __init__(self, FILECHOSEN, FILENAME, DESTDIR, CONTAINERCHOICE, AUDIOCODECVALUE, VIDEOCODECVALUE, PRESET,
@@ -48,7 +49,7 @@ class Transcoder(gobject.GObject):
# Choose plugin based on Codec Name
# or switch to remuxing mode if any of the values are set to 'pastr'
-
+ self.stoptoggle=False
self.audiocaps = AUDIOCODECVALUE
self.videocaps = VIDEOCODECVALUE
self.audiopasstoggle = AUDIOPASSTOGGLE
@@ -289,6 +290,7 @@ class Transcoder(gobject.GObject):
def on_message(self, bus, message):
mtype = message.type
+ # print mtype
if mtype == gst.MESSAGE_ERROR:
err, debug = message.parse_error()
print err
@@ -304,6 +306,10 @@ class Transcoder(gobject.GObject):
os.remove(self.cachefile)
self.emit('got-eos')
self.pipeline.set_state(gst.STATE_NULL)
+ elif mtype == gst.MESSAGE_APPLICATION:
+ print "I am getting the appliation message"
+ self.pipeline.set_state(gst.STATE_NULL)
+ self.pipeline.remove(self.uridecoder)
return True
def list_compat(self, a1, b1):
@@ -315,6 +321,10 @@ class Transcoder(gobject.GObject):
def OnDynamicPad(self, dbin, sink_pad):
c = sink_pad.get_caps().to_string()
if c.startswith("audio/"):
+ if self.stoptoggle==True:
+ bus = self.pipeline.get_bus()
+ bus.post(gst.message_new_application(self.pipeline, gst.Structure('STOP TRANSCODER')))
+ return
# First check for passthough mode
if self.audiopasstoggle is False:
# Check if either we are not doing multipass or if its the final pass before enabling audio
@@ -370,6 +380,7 @@ class Transcoder(gobject.GObject):
else:
flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
parsers = []
+ self.aparserelement = False
for fact in flist:
# print "fact is " + str(fact)
if self.list_compat(["Codec", "Parser","Audio"], fact.get_klass().split('/')):
@@ -384,7 +395,11 @@ class Transcoder(gobject.GObject):
parseintersect = caps.intersect(gst.caps_from_string(self.audiocaps))
if parseintersect != ("EMPTY"):
self.aparserelement = parser
-
+ if self.aparserelement == False:
+ error_message="noaudioparser"
+ self.emit("got-error", error_message)
+ self.stoptoggle=True
+ return
self.audioparse = gst.element_factory_make(self.aparserelement)
self.pipeline.add(self.audioparse)
@@ -396,6 +411,10 @@ class Transcoder(gobject.GObject):
self.gstmultiqueue.set_state(gst.STATE_PAUSED)
elif c.startswith("video/"):
+ if self.stoptoggle==True:
+ bus = self.pipeline.get_bus()
+ bus.post(gst.message_new_application(self.pipeline, gst.Structure('STOP TRANSCODER')))
+ return
if self.videopasstoggle == False:
# print "Got an video cap"
self.colorspaceconverter = gst.element_factory_make("ffmpegcolorspace")
@@ -516,6 +535,7 @@ class Transcoder(gobject.GObject):
else:
flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
parsers = []
+ self.vparserelement = False
for fact in flist:
if self.list_compat(["Codec", "Parser","Video"], fact.get_klass().split('/')):
parsers.append(fact.get_name())
@@ -530,7 +550,12 @@ class Transcoder(gobject.GObject):
if parseintersect == ("EMPTY"):
parseintersect = caps.intersect(gst.caps_from_string(self.videocaps))
if parseintersect != ("EMPTY"):
- self.vparserelement = parser
+ self.vparserelement = parser
+ if self.vparserelement == False:
+ error_message="novideoparser"
+ self.emit("got-error", error_message)
+ self.stoptoggle=True
+ return
self.videoparse = gst.element_factory_make(self.vparserelement)
diff --git a/src/transmageddon.py b/src/transmageddon.py
index cd693f5..bce9470 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -370,12 +370,6 @@ class TransmageddonUI (gtk.glade.XML):
gobject.timeout_add(500, self.Increment_Progressbar)
# print "ProgressBar timeout_add startet"
-
- # Set up function to start listening on the GStreamer bus
- # We need this so we know when the pipeline has started and when the pipeline has stopped
- # listening for ASYNC_DONE is sorta ok way to listen for when the pipeline is running
- # You need to listen on the GStreamer bus to know when EOS is hit for instance.
-
def _on_eos(self, source):
context_id = self.StatusBar.get_context_id("EOS")
if (self.multipass == False) or (self.passcounter == int(0)):
@@ -515,9 +509,9 @@ class TransmageddonUI (gtk.glade.XML):
vheight, vwidth, ratenum, ratednom, achannels,
self.multipass, self.passcounter, self.outputfilename,
self.timestamp, self.rotationvalue, self.audiopasstoggle, self.videopasstoggle)
-
self._transcoder.connect("ready-for-querying", self.ProgressBarUpdate)
self._transcoder.connect("got-eos", self._on_eos)
+ self._transcoder.connect("got-error", self.show_error)
return True
@@ -702,6 +696,36 @@ class TransmageddonUI (gtk.glade.XML):
"""
about.AboutDialog()
+
+ def show_error(self, NONE, error_string):
+ if (error_string=="noaudioparser") or (error_string=="novideoparser"):
+ self.FileChooser.set_sensitive(True)
+ self.containerchoice.set_sensitive(True)
+ self.CodecBox.set_sensitive(True)
+ self.presetchoice.set_sensitive(True)
+ self.rotationchoice.set_sensitive(True)
+ self.presetchoice.set_active(0)
+ self.cancelbutton.set_sensitive(True)
+ self.ProgressBar.set_fraction(0.0)
+ self.ProgressBar.set_text(_("Transcoding Progress"))
+ if error_string=="noaudioparser":
+ error_message = _("No audio parser, passthrough not available")
+ self.codec_buttons["apass"].set_sensitive(False)
+ codecs = supported_container_map[self.container]
+ self.AudioCodec = codecs[0]
+ self.codec_buttons[self.AudioCodec].set_active(True)
+ elif error_string=="novideoparser":
+ error_message= _("No video parser, passthrough not available")
+ self.codec_buttons["vpass"].set_sensitive(False)
+ codecs = supported_container_map[self.container]
+ self.VideoCodec = codecs[1]
+ self.codec_buttons[self.VideoCodec].set_active(True)
+ else:
+ error_message=_("Uknown error")
+ context_id = self.StatusBar.get_context_id("EOS")
+ self.StatusBar.push(context_id, error_message)
+
+
def on_debug_activate(self, widget):
dotfile = "/tmp/transmageddon-debug-graph.dot"
pngfile = "/tmp/transmageddon-pipeline.png"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]