[transmageddon] Some smaller fixes to move DVD support a little bit forward



commit d7e6f916b742c7d97b566b29913306ddd9574aad
Author: Christian Fredrik Kalager Schaller <uraeus linuxrising org>
Date:   Tue Jun 25 11:47:25 2013 +0200

    Some smaller fixes to move DVD support a little bit forward

 src/transcoder_engine.py |   12 +++++--
 src/transmageddon.py     |   69 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 70 insertions(+), 11 deletions(-)
---
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index 71c6cdd..3e03d85 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -143,12 +143,14 @@ class Transcoder(GObject.GObject):
        # including any extra elements between uridecodebin and encodebin
        x=0
        self.audioprofilenames=[]
+       # print(self.audiodata)
        while x < len(self.audiodata): 
-           if self.audiodata[x]['outputaudiocaps'] != False:
+           if self.audiodata[x]['outputaudiocaps'] != (False or "noaud"):
                if self.container==False:
                    self.encodebinprofile = GstPbutils.EncodingAudioProfile.new 
(self.audiodata[x]['outputaudiocaps'], audiopreset, Gst.Caps.new_any(), 0)
                else:
                    audiopreset=None
+                   # print(self.audiodata[x]['outputaudiocaps'])
                    self.audioprofile = 
GstPbutils.EncodingAudioProfile.new(self.audiodata[x]['outputaudiocaps'], audiopreset, Gst.Caps.new_any(), 0)
                    self.audioprofilenames.append("audioprofilename"+str(x))
                    self.audioprofile.set_name(self.audioprofilenames[x])
@@ -332,9 +334,11 @@ class Transcoder(GObject.GObject):
                    if self.probestreamid not in self.usedstreamids:
                        #FIXME - Need to clean usedstreamid list at some point
                        self.usedstreamids.append(self.probestreamid)
-                       # print(str(pad)+" - "+"streamid from parse_stream_start "+ str(self.probestreamid))
-                       self.sinkpad = self.encodebin.emit("request-profile-pad", self.audioprofilenames[x])
-                       pad.link(self.sinkpad)
+                       if x < len(self.audioprofilenames):
+                           #print(self.audioprofilenames)
+                           #print(x)
+                           self.sinkpad = self.encodebin.emit("request-profile-pad", 
self.audioprofilenames[x])
+                           pad.link(self.sinkpad)
                x=x+1
        return Gst.PadProbeReturn.OK
 
diff --git a/src/transmageddon.py b/src/transmageddon.py
index f2c34e1..17eb26d 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -40,7 +40,7 @@ import transcoder_engine
 from urllib.parse import urlparse
 import codecfinder
 import about
-import presets
+import presets, udevdisco
 import utils
 import datetime
 import langchooser, dvdtrackchooser
@@ -231,6 +231,10 @@ class TransmageddonUI(Gtk.ApplicationWindow):
        self.audiocodecs=[]
        self.videocodecs=[]
 
+       # The variables are used for the DVD discovery
+       self.finder = None
+       self.finder_video_found = None
+       self.finder_video_lost = None
        self.isdvd = False
        
        self.fileiter = None
@@ -621,7 +625,7 @@ class TransmageddonUI(Gtk.ApplicationWindow):
        if self.isdvd:
            element.set_property("device", self.dvddevice)
            # print("Title " + str(self.dvdttitle))
-           element.set_property("title", 0)
+           element.set_property("title", 0) # FIXME
 
 
  
@@ -1208,6 +1212,34 @@ class TransmageddonUI(Gtk.ApplicationWindow):
 
     return icon
 
+   def on_disc_found(self, finder, device, label):
+       """
+       A video DVD has been found, update the source combo box!
+       """
+       print("dvd found")
+       model = self.combo.get_model()
+       for pos, item in enumerate(model):
+           print("model is " +str(model))
+           if item[2] and item[2][0].endswith(device.path):
+               model[pos] = (item[0], device.nice_label, (item[2][0], True))
+               break
+    
+   def on_disc_lost(self, finder, device, label):
+       """
+            A video DVD has been removed, update the source combo box!
+       """
+       print("dvd lost")
+       model = self.combo.get_model()
+       for pos, item in enumerate(model):
+           print("pos is " +str(pos))
+           print("item0 is " +str(item[0]))
+           print("item1 is " +str(item[1]))
+           print("item2 is " +str(item[2]))
+           print("device path " +str(device.path))
+           if item[2] and item[2][0].endswith(device.path):
+               model[pos] = (item[0], device.nice_label, (item[2][0], False))
+               break
+
    def setup_source(self):
        """
            Setup the source widget. Creates a combo box or a file input button
@@ -1222,13 +1254,35 @@ class TransmageddonUI(Gtk.ApplicationWindow):
            self.source_hbox.remove(self.combo)
            self.combo.destroy()
         
+
+       if self.finder:
+            if self.finder_disc_found is not None:
+                self.finder.disconnect(self.finder_disc_found)
+                self.finder_disc_found = None
+            
+            if self.finder_disc_lost is not None:
+                self.finder.disconnect(self.finder_disc_lost)
+                self.finder_disc_lost = None
+
        # udev code to find DVD drive on system
+
        client = GUdev.Client(subsystems=['block'])
        for device in client.query_by_subsystem("block"):
            if device.has_property("ID_CDROM"):
                self.dvddevice=device.get_device_file()
                self.dvdname=device.get_property("ID_FS_LABEL")
 
+       # Setup input source discovery
+       if not self.finder:
+           self.finder = udevdisco.InputFinder()
+           print(self.finder)
+
+           # Watch for DVD discovery events
+           self.finder_disc_found = self.finder.connect("disc-found",
+                                                        self.on_disc_found)
+           self.finder_disc_lost = self.finder.connect("disc-lost",
+                                                        self.on_disc_lost)
+
        if self.dvddevice:
 
            theme = Gtk.IconTheme.get_default()
@@ -1237,10 +1291,10 @@ class TransmageddonUI(Gtk.ApplicationWindow):
            fileopen=theme.load_icon(Gtk.STOCK_OPEN, size, 0)
 
 
-           liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING, GObject.TYPE_INT)
-           liststore.append([None, "", 0])
-           liststore.append([fileopen, "Choose File...", 1])
-           liststore.append([cdrom, self.dvdname, 2])
+           liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING, GObject.TYPE_STRING, 
GObject.TYPE_INT)
+           liststore.append([None, "", "", 0])
+           liststore.append([fileopen, "Choose File...", "", 1])
+           liststore.append([cdrom, self.dvdname, self.dvddevice,  2])
 
            self.combo = Gtk.ComboBox(model=liststore)
 
@@ -1274,7 +1328,8 @@ class TransmageddonUI(Gtk.ApplicationWindow):
         
        iter = widget.get_active_iter()
        model = widget.get_model()
-       item = model.get_value(iter, 2)
+       item = model.get_value(iter, 3)
+       print("item is " + str(item))
 
        if item == 1:
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]