pitivi r1350 - trunk/pitivi
- From: edwardrv svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1350 - trunk/pitivi
- Date: Mon, 3 Nov 2008 12:28:12 +0000 (UTC)
Author: edwardrv
Date: Mon Nov 3 12:28:12 2008
New Revision: 1350
URL: http://svn.gnome.org/viewvc/pitivi?rev=1350&view=rev
Log:
ObjectFactory/Discoverer : Add new PictureFileSourceFactory, use it from the discoverer
Modified:
trunk/pitivi/discoverer.py
trunk/pitivi/objectfactory.py
Modified: trunk/pitivi/discoverer.py
==============================================================================
--- trunk/pitivi/discoverer.py (original)
+++ trunk/pitivi/discoverer.py Mon Nov 3 12:28:12 2008
@@ -29,9 +29,14 @@
import gobject
import gst
-from objectfactory import FileSourceFactory
+from objectfactory import FileSourceFactory, PictureFileSourceFactory
from signalinterface import Signallable
+# FIXME: We need to store more information regarding streams
+# i.e. remember the path took to get to a raw stream, and figure out
+# what encoded format it is
+# We will need that in order to create proper Stream objects.
+
class Discoverer(object, Signallable):
"""
Queues requests to discover information about given files.
@@ -78,7 +83,7 @@
self.error = None # reason for error
self.extrainfo = None # extra information about the error
self.fakesink = None
- self.isimage = False # Used to know if the file is an image
+ self.__is_image = False # Used to know if the file is an image
self.bus = None
def addFile(self, filename):
@@ -144,9 +149,9 @@
self.emit('not_media_file', self.current, self.error, self.extrainfo)
elif self.currentfactory:
self.currentfactory.addMediaTags(self.currentTags)
- if self.isimage:
+ if self.__is_image:
self.currentfactory.thumbnail = gst.uri_get_location(self.current)
- if not self.currentfactory.duration and not self.isimage:
+ if not self.currentfactory.duration and not self.__is_image:
self.emit('not_media_file', self.current,
_("Could not establish the duration of the file."),
_("This clip seems to be in a format which cannot be accessed in a random fashion."))
@@ -162,7 +167,7 @@
self.nomorepads = False
self.error = None
self.extrainfo = None
- self.isimage = False
+ self.__is_image = False
# restart an analysis if there's more...
if self.queue:
@@ -207,7 +212,8 @@
self.signalsid.append((dbin, dbin.connect("unknown-type", self._unknownTypeCb)))
self.signalsid.append((dbin, dbin.connect("no-more-pads", self._noMorePadsCb)))
tfind = dbin.get_by_name("typefind")
- self.signalsid.append((tfind, tfind.connect("have-type", self._typefindHaveTypeCb)))
+ self.signalsid.append((tfind.get_pad("src"),
+ tfind.get_pad("src").connect("notify::caps", self.__test)))
self.pipeline.add(source, dbin)
source.link(dbin)
gst.info("analysis pipeline created")
@@ -234,9 +240,9 @@
# return False so we don't get called again
return False
- def _typefindHaveTypeCb(self, unused_typefind, unused_perc, caps):
- if caps.to_string().startswith("image/"):
- self.isimage = True
+ def __test(self, apad, something):
+ if apad.get_caps().to_string().startswith("image/"):
+ self.__is_image = True
def _busMessageCb(self, unused_bus, message):
if self.thisdone:
@@ -251,7 +257,7 @@
# Let's get the information from all the pads
self._getPadsInfo()
# Only go to PLAYING if we have an video stream to thumbnail
- if self.currentfactory and self.currentfactory.is_video and not self.isimage:
+ if self.currentfactory and self.currentfactory.is_video and not self.__is_image:
gst.log("pipeline has gone to PAUSED, now pushing to PLAYING")
if self.pipeline.set_state(gst.STATE_PLAYING) == gst.STATE_CHANGE_FAILURE:
if not self.error:
@@ -314,9 +320,9 @@
if caps and caps.is_fixed():
if not self.currentfactory:
- self.currentfactory = FileSourceFactory(filename=self.current,
- project=self.project)
+ self.currentfactory = self.__makefactory()
self.emit("new_sourcefilefactory", self.currentfactory)
+ # FIXME : we should just have to tell the factory that it contains a new stream
if caps.to_string().startswith("audio/x-raw") and not self.currentfactory.audio_info:
self.currentfactory.audio_info = caps
elif caps.to_string().startswith("video/x-raw") and not self.currentfactory.video_info:
@@ -410,14 +416,12 @@
gst.info("pad:%s caps:%s is_last:%s" % (pad, capsstr, is_last))
if capsstr.startswith("video/x-raw"):
if not self.currentfactory:
- self.currentfactory = FileSourceFactory(filename=self.current,
- project=self.project)
+ self.currentfactory = self.__makefactory()
self.emit("new_sourcefilefactory", self.currentfactory)
self._newVideoPadCb(element, pad)
elif capsstr.startswith("audio/x-raw"):
if not self.currentfactory:
- self.currentfactory = FileSourceFactory(filename=self.current,
- project=self.project)
+ self.currentfactory = self.__makefactory()
self.emit("new_sourcefilefactory", self.currentfactory)
self._newAudioPadCb(element, pad)
else:
@@ -440,3 +444,11 @@
self.pipeline.remove(self.fakesink)
self.fakesink = None
# normally state changes should end the discovery
+
+ def __makefactory(self):
+ if self.__is_image:
+ facttype = PictureFileSourceFactory
+ else:
+ facttype = FileSourceFactory
+ return facttype(filename=self.current,
+ project=self.project)
Modified: trunk/pitivi/objectfactory.py
==============================================================================
--- trunk/pitivi/objectfactory.py (original)
+++ trunk/pitivi/objectfactory.py Mon Nov 3 12:28:12 2008
@@ -38,6 +38,7 @@
from gettext import gettext as _
from elements.singledecodebin import SingleDecodeBin
+from elements.imagefreeze import ImageFreeze
class ObjectFactory(Serializable):
"""
@@ -488,6 +489,42 @@
self._length = obj["length"]
+class PictureFileSourceFactory(FileSourceFactory):
+
+ def _getDuration(self):
+ return 3600 * gst.SECOND
+
+ def _getDefaultDuration(self):
+ return 5 * gst.SECOND
+
+ def makeVideoBin(self):
+ gst.debug("making picture bin for %s" % self.name)
+ res = gst.Bin("picture-%s-%d" % (self.name,
+ self.lastbinid))
+ self.lastbinid = self.lastbinid + 1
+ freeze = ImageFreeze()
+ # let's get a single stream provider
+ dbin = FileSourceFactory.makeVideoBin(self)
+ res.add(dbin, freeze)
+ dbin.connect("pad-added", self.__dbinPadAddedCb, freeze, res)
+ dbin.connect("pad-removed", self.__dbinPadRemovedCb, freeze, res)
+ gst.debug("Returning %r" % res)
+ return res
+
+ def __dbinPadAddedCb(self, unused_dbin, pad, freeze, container):
+ pad.link(freeze.get_pad("sink"))
+ ghost = gst.GhostPad("src", freeze.get_pad("src"))
+ ghost.set_active(True)
+ container.add_pad(ghost)
+
+ def __dbinPadRemovedCb(self, unused_dbin, pad, freeze, container):
+ ghost = container.get_pad("src")
+ target = ghost.get_target()
+ peer = target.get_peer()
+ target.unlink(peer)
+ container.remove_pad(ghost)
+ pad.unlink(freeze.get_pad("sink"))
+
class OperationFactory(ObjectFactory):
"""
Provides operations useable in a timeline
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]