[xiph-commits] r11793 - trunk/souffleur

daraku at svn.xiph.org daraku at svn.xiph.org
Fri Aug 18 12:00:05 PDT 2006


Author: daraku
Date: 2006-08-18 11:59:56 -0700 (Fri, 18 Aug 2006)
New Revision: 11793

Modified:
   trunk/souffleur/MediaInfo.py
   trunk/souffleur/Souffleur.py
   trunk/souffleur/SouffleurXML.py
   trunk/souffleur/Subtitles.py
   trunk/souffleur/souffleur.glade
Log:
Added callback for "delte stream" tool button.
Some fix in addStream function.
Added callback for "mod stream" tool button, if in stream window selected subtitle stream, it wiil be set as current.
Fix some bug in addStream function.
Fix some errors whith types.
Added callback for "save stream" tool button. It only save subtitles stream.


Modified: trunk/souffleur/MediaInfo.py
===================================================================
--- trunk/souffleur/MediaInfo.py	2006-08-17 18:34:05 UTC (rev 11792)
+++ trunk/souffleur/MediaInfo.py	2006-08-18 18:59:56 UTC (rev 11793)
@@ -412,7 +412,7 @@
         self.demux = gst.element_factory_make('decodebin')
         self.mux = gst.element_factory_make('oggmux')
 
-        self.add(self.demux, self.mux)
+        self.add(self.demux) #, self.mux)
 
         self.add_pad(gst.GhostPad('sink', self.demux.get_pad('sink')))
         self.add_pad(gst.GhostPad('src', self.mux.get_pad('src')))

Modified: trunk/souffleur/Souffleur.py
===================================================================
--- trunk/souffleur/Souffleur.py	2006-08-17 18:34:05 UTC (rev 11792)
+++ trunk/souffleur/Souffleur.py	2006-08-18 18:59:56 UTC (rev 11793)
@@ -112,12 +112,15 @@
         self.PFileName=None
         self.windowMediaOpen=None
         self.windowStreams=gtk.glade.XML (self.gladefile,"STREAM_WINDOW")
-        dic = {"on_TOOL_ADD_STREAM_clicked": self.cb_addNewStream}
+        dic = {"on_TOOL_DEL_STREAM_clicked": self.cb_delStream,\
+                "on_TOOL_MOD_STREAM_clicked": self.cb_modStream,\
+                "on_TOOL_SAVE_STREAM_clicked": self.cb_saveStream,\
+                "on_TOOL_ADD_STREAM_clicked": self.cb_addNewStream}
         self.windowStreams.signal_autoconnect (dic)
         ### Setup LIST_STREAMS
         LIST = self.windowStreams.get_widget("LIST_STREAMS")
         if LIST:
-            self.streamsTreeStore = gtk.TreeStore(gobject.TYPE_STRING)
+            self.streamsTreeStore = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_UINT)
             LIST.set_model(self.streamsTreeStore)
             cell = gtk.CellRendererText()
             tvcolumn = gtk.TreeViewColumn('Streams', cell, text = 0)
@@ -158,6 +161,79 @@
         self.playButton = self.wTree.get_widget("TOOL_PLAY")
         return
 #==============================================================================
+    def getSubtitle(self, source):
+        for i in self.Subtitles:
+            if i.subSource==source:
+                return i
+        return None
+#==============================================================================
+    def cb_saveStream(self, widget):
+        if not self.windowStreams:
+            return
+        if not self.streamsTreeStore:
+            return
+        TView = self.windowStreams.get_widget("LIST_STREAMS")
+        TSelec = TView.get_selection()
+        TModel, TIter = TSelec.get_selected()
+        if not TIter:
+            return
+        N=TModel.get_value(TIter, 1)
+        mInfo = self.media[N]
+        if "subtitle" in mInfo.MIME:
+            tSubtitle = self.getSubtitle(mInfo.Streams[0].ID)
+            tSubtitle.subSave(mInfo.source, 1)
+#==============================================================================
+    def cb_modStream(self, widget):
+        if not self.windowStreams:
+            return
+        if not self.streamsTreeStore:
+            return
+        TView = self.windowStreams.get_widget("LIST_STREAMS")
+        TSelec = TView.get_selection()
+        TModel, TIter = TSelec.get_selected()
+        if not TIter:
+            return
+        N=TModel.get_value(TIter, 1)
+        mInfo = self.media[N]
+        if "subtitle" in mInfo.MIME:
+            self.setSubtitle(mInfo.Streams[0].ID)
+#==============================================================================
+    def setSubtitle(self, source):
+        for i in self.Subtitles:
+            if i.subSource==source:
+                self.Subtitle=i
+                break
+        if self.Subtitle:
+            if (self.windowStreams):
+                WND=self.windowSubsList.get_widget("SUBS_LIST")
+                WND.show()
+            self.subsWindowUpdate()
+#==============================================================================
+    def updateStreamWindow(self):
+        if not self.streamsTreeStore:
+            return
+        self.streamsTreeStore.clear()
+        for mInfo in self.media:
+            iter = self.streamsTreeStore.append(None)
+            self.streamsTreeStore.set(iter, 0, mInfo.MIME + " ("+mInfo.source+")", 1, self.media.index(mInfo))
+            for i in mInfo.Streams:
+                child = self.streamsTreeStore.append(iter)
+                self.streamsTreeStore.set(child, 0, i.MIME + " ("+i.Name+")", 1, self.media.index(mInfo))
+#==============================================================================
+    def cb_delStream(self, widget):
+        if not self.windowStreams:
+            return
+        if not self.streamsTreeStore:
+            return
+        TView = self.windowStreams.get_widget("LIST_STREAMS")
+        TSelec = TView.get_selection()
+        TModel, TIter = TSelec.get_selected()
+        if not TIter:
+            return
+        N=TModel.get_value(TIter, 1)
+        del self.media[N]
+        self.updateStreamWindow()
+#==============================================================================
     def cb_openMediaCancel(self, widget):
         if self.windowMediaOpen:
             WND=self.windowMediaOpen.get_widget("OPEN_MEDIA")
@@ -168,10 +244,10 @@
         FN=WND.get_filename()
         URI=WND.get_uri()
         WND.hide()
-        print FN, URI
         MI = MediaInfo(URI, FN, self.lastID)
         MI.run()
         tMedia = MI.getMedia()
+        MI=None
         self.addMedia(tMedia)
 #==============================================================================
     def cb_addNewStream(self, widget):
@@ -237,14 +313,16 @@
                         self.play_toggled()
 #==============================================================================
     def subsWindowUpdate(self):
-        if (self.windowSubsList):
+        if not self.Subtitle:
+            return
+        if self.windowSubsList:
             self.subsListStore.clear()
             for i in self.Subtitle.subKeys:
                 S=self.Subtitle.subs[i]
                 iter = self.subsListStore.append(None)
-                self.subsListStore.set(iter, 0, S.start_time,
-                                            1, S.end_time,
-                                            2, S.text)
+                self.subsListStore.set(iter, 0, int(S.start_time),
+                                            1, int(S.end_time),
+                                            2, str(S.text))
 #==============================================================================
     def saveProject(self):
         if not self.PFileName:
@@ -320,6 +398,9 @@
                     self.Subtitle.subs[int(self.curSub)].start_time=newTime
                     self.Subtitle.subUpdate(int(self.curSub))
                     self.curSub = newTime
+                #for i in self.Subtitles:
+                #    if i.subSource == self.Subtitle.subSource:
+                #        self.Subtitles[self.Subtitles.index(i)]=self.Subtitle
                 self.subsWindowUpdate()
             else:
                 self.subAdd()
@@ -411,13 +492,9 @@
         PXML.load(self.PFileName)
         for i in PXML.getMedia():
             self.addMedia(i)
+        self.Subtitles=[]
         for i in PXML.getSubtitle():
             self.Subtitles.append(i)
-        if len(self.Subtitles)>0:
-            if (self.windowStreams):
-                WND=self.windowSubsList.get_widget("SUBS_LIST")
-                WND.show()
-                self.subsWindowUpdate()
         if len(self.media)>0:
             WND=self.windowStreams.get_widget("STREAM_WINDOW")
             WND.show()
@@ -426,22 +503,14 @@
     def addMedia(self, mInfo):
         if not mInfo:
             return
+        N=len(self.media)
         self.media.append(mInfo)
         self.lastID = mInfo.lastID
-        iter = self.streamsTreeStore.append(None)
-        self.streamsTreeStore.set(iter, 0, mInfo.MIME + " ("+mInfo.source+")")
-        for i in mInfo.Streams:
-            child = self.streamsTreeStore.append(iter)
-            self.streamsTreeStore.set(child, 0, i.MIME + " ("+i.Name+")")
+        self.updateStreamWindow()
         if "subtitle" in mInfo.MIME:
-            self.Subtitle = Subtitles()
-            self.Subtitle.subLoad(mInfo.source, mInfo.Streams[0].ID)
-            self.Subtitles.append(self.Subtitle)
-            if (self.windowStreams):
-                WND=self.windowSubsList.get_widget("SUBS_LIST")
-                WND.show()
-                self.subsWindowUpdate()
-                
+            tSubtitle = Subtitles()
+            tSubtitle.subLoad(mInfo.source, mInfo.Streams[0].ID)
+            self.Subtitles.append(tSubtitle)
         else:
             self.videoWidgetGst=VideoWidget(self.videoWidget)
             self.player=GstPlayer(self.videoWidgetGst)

Modified: trunk/souffleur/SouffleurXML.py
===================================================================
--- trunk/souffleur/SouffleurXML.py	2006-08-17 18:34:05 UTC (rev 11792)
+++ trunk/souffleur/SouffleurXML.py	2006-08-18 18:59:56 UTC (rev 11793)
@@ -194,17 +194,17 @@
                 tSubtitles=Subtitles()
                 for j in i.childNodes:
                     if j.nodeName=="source":
-                        tSubtitles.ID=j.childNodes[0].nodeValue
+                        tSubtitles.subSource=j.childNodes[0].nodeValue
                     elif j.nodeName=="sub":
                         tSub=Sub()
                         for k in j.childNodes:
                             nodeName = k.nodeName
                             if nodeName == "start":
-                                tSub.start_time=k.childNodes[0].nodeValue
+                                tSub.start_time=int(k.childNodes[0].nodeValue)
                             elif nodeName == "end":
-                                tSub.end_time=k.childNodes[0].nodeValue
+                                tSub.end_time=int(k.childNodes[0].nodeValue)
                             elif nodeName == "text":
-                                tSub.text=k.childNodes[0].nodeValue
+                                tSub.text=str(k.childNodes[0].nodeValue)
                         tSubtitles.subs[tSub.start_time]=tSub
                         tSubtitles.updateKeys()
                 ret.append(tSubtitles)

Modified: trunk/souffleur/Subtitles.py
===================================================================
--- trunk/souffleur/Subtitles.py	2006-08-17 18:34:05 UTC (rev 11792)
+++ trunk/souffleur/Subtitles.py	2006-08-18 18:59:56 UTC (rev 11793)
@@ -37,23 +37,23 @@
 
         self.subSource=ID
 #==============================================================================    
-    def subSave(self, format):
+    def subSave(self, FN, format):
         if (self.subSource!=None):
-            FUN=os.open(self.subSource,os.O_WRONLY|os.O_CREAT|os.O_TRUNC)
+            FUN=os.open(FN,os.O_WRONLY|os.O_CREAT|os.O_TRUNC)
             N=1
             for i in self.subKeys:
                 SUB = self.subs[int(i)]
-                Text=str(N)+"\n"
+                Text=str(N)+"\r\n"
                 Hour, Min, Sec, MSec = self._subTime2SRTtime(SUB.start_time)
                 #Text+=str(Hour)+":"+str(Min)+":"+str(Sec)+","+str(MSec)
                 Text+="%02d:%02d:%02d,%03d"%(Hour, Min, Sec, MSec)
                 Text+=" --> "
                 Hour, Min, Sec, MSec = self._subTime2SRTtime(SUB.end_time)
                 #Text+=str(Hour)+":"+str(Min)+":"+str(Sec)+","+str(MSec)+"\n"
-                Text+="%02d:%02d:%02d,%03d"%(Hour, Min, Sec, MSec)+"\n"
-                Text+=SUB.text+"\n"
-                if (SUB.text[-1]!='\n'):
-                    Text+="\n"
+                Text+="%02d:%02d:%02d,%03d"%(Hour, Min, Sec, MSec)+"\r\n"
+                Text+=SUB.text+"\r\n"
+                if (SUB.text[-2]!="\r\n"):
+                    Text+="\r\n"
                 os.write(FUN, Text)
                 N+=1
             os.close(FUN)

Modified: trunk/souffleur/souffleur.glade
===================================================================
--- trunk/souffleur/souffleur.glade	2006-08-17 18:34:05 UTC (rev 11792)
+++ trunk/souffleur/souffleur.glade	2006-08-18 18:59:56 UTC (rev 11793)
@@ -1188,6 +1188,7 @@
 	      <property name="visible_horizontal">True</property>
 	      <property name="visible_vertical">True</property>
 	      <property name="is_important">False</property>
+	      <signal name="clicked" handler="on_TOOL_MOD_STREAM_clicked" last_modification_time="Thu, 17 Aug 2006 19:14:33 GMT"/>
 	    </widget>
 	    <packing>
 	      <property name="expand">False</property>
@@ -1202,6 +1203,7 @@
 	      <property name="visible_horizontal">True</property>
 	      <property name="visible_vertical">True</property>
 	      <property name="is_important">False</property>
+	      <signal name="clicked" handler="on_TOOL_SAVE_STREAM_clicked" last_modification_time="Fri, 18 Aug 2006 18:48:21 GMT"/>
 	    </widget>
 	    <packing>
 	      <property name="expand">False</property>
@@ -1216,6 +1218,7 @@
 	      <property name="visible_horizontal">True</property>
 	      <property name="visible_vertical">True</property>
 	      <property name="is_important">False</property>
+	      <signal name="clicked" handler="on_TOOL_DEL_STREAM_clicked" last_modification_time="Thu, 17 Aug 2006 18:43:12 GMT"/>
 	    </widget>
 	    <packing>
 	      <property name="expand">False</property>
@@ -1289,7 +1292,6 @@
 
       <child>
 	<widget class="GtkToolbar" id="toolbar3">
-	  <property name="visible">True</property>
 	  <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
 	  <property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
 	  <property name="tooltips">True</property>



More information about the commits mailing list