pitivi r1267 - in trunk: . pitivi pitivi/ui



Author: edwardrv
Date: Fri Sep 26 17:12:27 2008
New Revision: 1267
URL: http://svn.gnome.org/viewvc/pitivi?rev=1267&view=rev

Log:
* pitivi/bin.py:
There's currently an issue with audio sources by which they do not
properly reset when going to READY. We workaround this by forcing the
sources to NULL and then back to READY before capturing.
Name the various queues to make debugging easier.
Increase the size of the queues.
* pitivi/ui/webcam_managerdialog.py:
Name the various queues to make debugging easier.
Increase the size of the queues.

Modified:
   trunk/ChangeLog
   trunk/pitivi/bin.py
   trunk/pitivi/ui/webcam_managerdialog.py

Modified: trunk/pitivi/bin.py
==============================================================================
--- trunk/pitivi/bin.py	(original)
+++ trunk/pitivi/bin.py	Fri Sep 26 17:12:27 2008
@@ -293,6 +293,7 @@
         ##
 
         ainq = gst.element_factory_make("queue", "ainq")
+        ainq.props.max_size_time = 5 * gst.SECOND
         aident = gst.element_factory_make("identity", "aident")
         aident.props.single_segment = True
         aconv = gst.element_factory_make("audioconvert", "aconv")
@@ -523,21 +524,26 @@
 
     def __init__(self):
         gst.log("Creating new smartcapturebin")
-        self.videosrc = gst.element_factory_make("v4l2src", "vsrc")
-        self.audiosrc = gst.element_factory_make("alsasrc", "asrc")
+        self.videosrc = gst.element_factory_make("v4l2src", "webcam-vsrc")
+        self.audiosrc = gst.element_factory_make("alsasrc", "webcam-asrc")
 
         SmartBin.__init__(self, "smartcapturebin", has_video=True, has_audio=True,
                           width=640, height=480)
 
     def _addSource(self):
-	self.q1 = gst.element_factory_make("queue")
-	self.q2 = gst.element_factory_make("queue")
+	self.q1 = gst.element_factory_make("queue", "webcam-firstvqueue")
+        self.q1.props.max_size_time = 10 * gst.SECOND
+	self.q2 = gst.element_factory_make("queue", "webcam-firstaqueue")
+        self.q2.props.max_size_time = 30 * gst.SECOND
+        self.q2.props.max_size_buffers = 0
+        self.q2.props.max_size_bytes = 0
         self.add(self.videosrc,self.audiosrc,self.q1,self.q2)
 
+
     def _connectSource(self):
         self.debug("connecting sources")
         #vcaps = gst.caps_from_string("video/x-raw-yuv,width=320,height=240,framerate=25.0")
-	
+
 	gst.element_link_many(self.videosrc,self.q1,self.vtee)
  	gst.element_link_many(self.audiosrc,self.q2,self.atee)
 
@@ -545,6 +551,7 @@
 	#self.audiosrc.get_pad("src").link(self.atee.get_pad("sink"))
 
         self.debug("finished connecting sources")
+
     def record(self, uri, settings=None):
         """
         Render the SmartBin to the given uri.
@@ -554,15 +561,31 @@
             self.warning("Couldn't switch to READY !")
             return False
 
+        # FIXME : This is maybe a temporary hack.
+        #
+        # EXPLANATION : The problem is that alsasrc (or any other audio source) will
+        # not reset the timestamps when going down to READY, but v4l2src (or any
+        # other element that resets itself in READY) will properly reset the
+        # timestamps.
+        # The resulting behaviour (without this fix) is that v4l2src will output
+        # buffers starting from 0 whereas alsasrc will output buffers starting from
+        # the last outputted buffer timestamp
+        self.debug("Setting sources to NULL again to reset their timestamps !")
+        self.videosrc.set_state(gst.STATE_NULL)
+        self.videosrc.set_state(gst.STATE_READY)
+
+        self.audiosrc.set_state(gst.STATE_NULL)
+        self.audiosrc.set_state(gst.STATE_READY)
+
         if self.recording:
             self.error("This bin is already in in recording mode !")
             return
 
         # temporarily remove the audiosinkthread
-        self.debug("disconnecting audio sink thread")
-        self.tmpasink = self.asinkthread
-        if not self.removeAudioSinkThread():
-            return False
+        #self.debug("disconnecting audio sink thread")
+        #self.tmpasink = self.asinkthread
+        #if not self.removeAudioSinkThread():
+        #    return False
 
         self.debug("creating and adding encoding thread")
         self.encthread = self._makeEncThread(uri, settings)

Modified: trunk/pitivi/ui/webcam_managerdialog.py
==============================================================================
--- trunk/pitivi/ui/webcam_managerdialog.py	(original)
+++ trunk/pitivi/ui/webcam_managerdialog.py	Fri Sep 26 17:12:27 2008
@@ -22,9 +22,7 @@
 import gtk
 import os
 import gtk.glade
-import pygst
 from pitivi import instance
-pygst.require("0.10")
 import gst
 import tempfile
 from gettext import gettext as _
@@ -51,17 +49,17 @@
 		self.close_btn.connect("clicked",self.close)
 		self.record_btn.connect("clicked", self.do_recording)
 		self.cam_window.connect("destroy",self.close)
-		
+
 		self.record_btn = self.record_btn.get_children()[0]
 		self.record_btn = self.record_btn.get_children()[0].get_children()[1]
 		self.record_btn.set_label("Start Recording")
-	
+
 		self.sourcefactories = SourceFactoriesWidget()
 
 		gst.debug("SmartCaptureBin player created")
-		self.player = SmartCaptureBin()		
+		self.player = SmartCaptureBin()
 		self.setSinks()
-	
+
 
 
 		self.player.set_state(gst.STATE_PLAYING)
@@ -69,13 +67,14 @@
 
 	# Record button action callback
 	def do_recording(self, w):
-	
+
 		if self.record_btn.get_label() == "Start Recording":
 			gst.debug("recording started")
 			self.filepath = 'file://'+tempfile.mktemp()+'.ogg'
-			self.player.record(self.filepath,ExportSettings())
+
+			if not self.player.record(self.filepath,ExportSettings()):
+				print "FAILURE !"
 			self.record_btn.set_label("Stop Recording")
-			self.player.set_state(gst.STATE_PLAYING)
 
 
 
@@ -92,10 +91,10 @@
 
 		self.videosink = plumber.get_video_sink()
 
-		vsinkthread = gst.Bin('vsinkthread')
-		vqueue = gst.element_factory_make('queue')
-		cspace = gst.element_factory_make('ffmpegcolorspace')
-		vscale = gst.element_factory_make('videoscale')
+		vsinkthread = gst.Bin('webcam-vsinkthread')
+		vqueue = gst.element_factory_make("queue", 'webcam-vqueue')
+		cspace = gst.element_factory_make("ffmpegcolorspace", 'webcam-ffmpegcolorspace')
+		vscale = gst.element_factory_make("videoscale", 'webcam-videoscale')
 		vscale.props.method = 1
 		vsinkthread.add(self.videosink, vqueue, vscale, cspace)
 		vqueue.link(self.videosink)
@@ -107,16 +106,17 @@
 
         	gst.debug("Creating audio sink")
         	self.audiosink = plumber.get_audio_sink()
-        	asinkthread = gst.Bin('asinkthread')
-        	aqueue = gst.element_factory_make('queue')
-        	aconv = gst.element_factory_make('audioconvert')
-        	asinkthread.add(self.audiosink, aqueue, aconv)
-        	aconv.link(aqueue)
-        	aqueue.link(self.audiosink)
+        	asinkthread = gst.Bin('webcam-asinkthread')
+		abqueue = gst.element_factory_make("queue", "webcam-abqueue")
+        	aqueue = gst.element_factory_make('queue', 'webcam-aqueue')
+		aqueue.props.max_size_time = 5 * gst.SECOND
+        	aconv = gst.element_factory_make("audioconvert", 'webcam-audioconvert')
+        	asinkthread.add(self.audiosink, abqueue, aqueue, aconv)
+		gst.element_link_many(abqueue, aconv, aqueue, self.audiosink)
         	asinkthread.audiosink = self.audiosink
-        	asinkthread.add_pad(gst.GhostPad("sink", aconv.get_pad('sink')))
+        	asinkthread.add_pad(gst.GhostPad("sink", abqueue.get_pad('sink')))
 		self.player.setAudioSinkThread(asinkthread)
-	
+
 		bus = self.player.get_bus()
 		bus.add_signal_watch()
 		bus.enable_sync_message_emission()
@@ -127,7 +127,7 @@
 	def close(self,w):
 		self.cam_window.destroy()
 		self.player.set_state(gst.STATE_NULL)
-		
+
 	# For draw_window syncs
 	def on_sync_message(self, bus, message):
 		if message.structure is None:



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