pitivi r1233 - in branches/SOC_2008_SLAKSHMAN/pitivi: . ui
- From: slynux svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1233 - in branches/SOC_2008_SLAKSHMAN/pitivi: . ui
- Date: Sat, 16 Aug 2008 04:16:29 +0000 (UTC)
Author: slynux
Date: Sat Aug 16 04:16:29 2008
New Revision: 1233
URL: http://svn.gnome.org/viewvc/pitivi?rev=1233&view=rev
Log:
update bin.py
Modified:
branches/SOC_2008_SLAKSHMAN/pitivi/bin.py
branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py
branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/bin.py
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/bin.py (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/bin.py Sat Aug 16 04:16:29 2008
@@ -27,7 +27,7 @@
import gst
from elements.smartscale import SmartVideoScale
from objectfactory import FileSourceFactory
-
+from ui import plumber
class SmartBin(gst.Pipeline):
"""
@@ -293,7 +293,6 @@
##
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")
@@ -509,6 +508,43 @@
self.debug("finished connecting sources")
+class SinkBin:
+ """
+ A general purpose sink with audio and video. This can be used as sink for Capture
+ classes and for testing. Source for this sink is a Pipeline.
+ """
+ def __init__(self):
+
+ self.videosink = plumber.get_video_sink()
+
+ self.vsinkthread = gst.Bin('vsinkthread')
+ vqueue = gst.element_factory_make('queue')
+ cspace = gst.element_factory_make('ffmpegcolorspace')
+ vscale = gst.element_factory_make('videoscale')
+ vscale.props.method = 1
+ self.vsinkthread.add(self.videosink, vqueue, vscale, cspace)
+ vqueue.link(self.videosink)
+ cspace.link(vscale)
+ vscale.link(vqueue)
+ self.vsinkthread.videosink = self.videosink
+ self.vsinkthread.add_pad(gst.GhostPad("sink", cspace.get_pad('sink')))
+
+ gst.debug("Creating audio sink")
+ self.audiosink = plumber.get_audio_sink()
+ self.asinkthread = gst.Bin('asinkthread')
+ aqueue = gst.element_factory_make('queue')
+ aconv = gst.element_factory_make('audioconvert')
+ self.asinkthread.add(self.audiosink, aqueue, aconv)
+ aconv.link(aqueue)
+ aqueue.link(self.audiosink)
+ self.asinkthread.audiosink = self.audiosink
+ self.asinkthread.add_pad(gst.GhostPad("sink", aconv.get_pad('sink')))
+
+ def connectSink(self,player):
+ player.setVideoSinkThread(self.vsinkthread)
+ player.setAudioSinkThread(self.asinkthread)
+
+ gst.debug("success connecting sources to SinkBin")
class SmartCaptureBin(SmartBin):
@@ -518,26 +554,23 @@
def __init__(self):
gst.log("Creating new smartcapturebin")
- self.videosrc = gst.element_factory_make("v4l2src", "webcam-vsrc")
- self.audiosrc = gst.element_factory_make("alsasrc", "webcam-asrc")
+ self.videosrc = gst.element_factory_make("v4l2src", "vsrc")
+ self.audiosrc = gst.element_factory_make("alsasrc", "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", "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.q1 = gst.element_factory_make("queue")
+ self.q2 = gst.element_factory_make("queue")
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)
@@ -546,99 +579,8 @@
self.debug("finished connecting sources")
- def record(self, uri, settings=None):
- """
- Render the SmartBin to the given uri.
- Returns : True if the encoding process could be started properly, False otherwise."""
- self.debug("setting to READY")
- if self.set_state(gst.STATE_READY) == gst.STATE_CHANGE_FAILURE:
- 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("creating and adding encoding thread")
- self.encthread = self._makeEncThread(uri, settings)
- if not self.encthread:
- gst.warning("Couldn't create encoding thread")
- return False
- self.add(self.encthread)
- self.debug("encoding thread added")
-
- # set sync=false on the videosink
- #self.getRealVideoSink().set_property("sync", False)
-
- self.debug("linking vtee to ecnthread:vsink")
- try:
- self.vtee.get_request_pad("src%d").link(self.encthread.get_pad("vsink"))
- except:
- return False
-
- self.debug("linking atee to encthread:asink")
- try:
- self.atee.get_request_pad("src%d").link(self.encthread.get_pad("asink"))
- except:
- return False
-
- self.debug("going back to PLAYING")
- changeret = self.set_state(gst.STATE_PLAYING)
- self.debug("now in PLAYING, set_state() returned %r" % changeret)
- if changeret == gst.STATE_CHANGE_FAILURE:
- return False
-
- self.recording = True
- return True
-
- def stopRecording(self):
- """ stop the recording, removing the encoding thread """
- if self.recording == False:
- self.warning("This bin is not in recording mode !")
- return False
-
- self.set_state(gst.STATE_PAUSED)
-
- if self.encthread:
- apad = self.encthread.get_pad("vsink")
- apad.get_peer().unlink(apad)
- apad = self.encthread.get_pad("asink")
- apad.get_peer().unlink(apad)
- self.remove(self.encthread)
- self.encthread.set_state(gst.STATE_NULL)
- del self.encthread
- self.encthread = None
-
- self.getRealVideoSink().set_property("sync", True)
-
- self.recording = False
- return True
-
-
-
+
class SmartStreamBin(SmartFileBin):
"""
SmartStreamBin with network stream from URI can be used as source.
@@ -655,77 +597,3 @@
SmartBin.__init__(self, "smartdefaultbin", has_video=True, has_audio=True)
- def record(self, uri, settings=None):
- """
- Render the SmartBin to the given uri.
- Returns : True if the encoding process could be started properly, False otherwise."""
- self.debug("setting to READY")
- if self.set_state(gst.STATE_READY) == gst.STATE_CHANGE_FAILURE:
- self.warning("Couldn't switch to READY !")
- return False
-
- 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("creating and adding encoding thread")
- self.encthread = self._makeEncThread(uri, settings)
- if not self.encthread:
- gst.warning("Couldn't create encoding thread")
- return False
- self.add(self.encthread)
- self.debug("encoding thread added")
-
- # set sync=false on the videosink
- #self.getRealVideoSink().set_property("sync", False)
-
- self.debug("linking vtee to ecnthread:vsink")
- try:
- self.vtee.get_request_pad("src%d").link(self.encthread.get_pad("vsink"))
- except:
- return False
-
- self.debug("linking atee to encthread:asink")
- try:
- self.atee.get_request_pad("src%d").link(self.encthread.get_pad("asink"))
- except:
- return False
-
- self.debug("going back to PLAYING")
- changeret = self.set_state(gst.STATE_PLAYING)
- self.debug("now in PLAYING, set_state() returned %r" % changeret)
- if changeret == gst.STATE_CHANGE_FAILURE:
- return False
-
- self.recording = True
- return True
-
- def stopRecording(self):
- """ stop the recording, removing the encoding thread """
- if self.recording == False:
- self.warning("This bin is not in recording mode !")
- return False
-
- self.set_state(gst.STATE_PAUSED)
-
- if self.encthread:
- apad = self.encthread.get_pad("vsink")
- apad.get_peer().unlink(apad)
- apad = self.encthread.get_pad("asink")
- apad.get_peer().unlink(apad)
- self.remove(self.encthread)
- self.encthread.set_state(gst.STATE_NULL)
- del self.encthread
- self.encthread = None
-
- self.getRealVideoSink().set_property("sync", True)
-
- self.recording = False
- return True
-
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py Sat Aug 16 04:16:29 2008
@@ -29,11 +29,10 @@
pygst.require("0.10")
import gst
import tempfile
-import plumber
from gettext import gettext as _
from pitivi import instance
from sourcefactories import SourceFactoriesWidget
-from pitivi.bin import SmartStreamBin
+from pitivi.bin import SmartStreamBin, SinkBin
from pitivi.settings import ExportSettings
class NetstreamManagerDialog(object):
@@ -44,14 +43,6 @@
self.capture_pipe = None
self.player = None
-
- '''
- h=SmartStreamBin("http://127.0.0.1:8080")
- instance.PiTiVi.playground._playTemporaryBin(h)
-
- h.record("file:///tmp/test.ogg",ExportSettings())
- '''
-
glade_dir = os.path.dirname(os.path.abspath(__file__))
self.objectpool_ui = gtk.glade.XML(os.path.join(glade_dir, "net_capture.glade"))
self.stream_window = self.objectpool_ui.get_widget("network_capture")
@@ -97,33 +88,8 @@
gst.debug("SmartStreamBin player created")
self.player = SmartStreamBin(uri)
- 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')
- vscale.props.method = 1
- vsinkthread.add(self.videosink, vqueue, vscale, cspace)
- vqueue.link(self.videosink)
- cspace.link(vscale)
- vscale.link(vqueue)
- vsinkthread.videosink = self.videosink
- vsinkthread.add_pad(gst.GhostPad("sink", cspace.get_pad('sink')))
- self.player.setVideoSinkThread(vsinkthread)
-
- 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.audiosink = self.audiosink
- asinkthread.add_pad(gst.GhostPad("sink", aconv.get_pad('sink')))
- self.player.setAudioSinkThread(asinkthread)
-
+ sink = SinkBin()
+ sink.connectSink(self.player)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py Sat Aug 16 04:16:29 2008
@@ -22,14 +22,15 @@
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 _
-import plumber
from pitivi.settings import ExportSettings
from sourcefactories import SourceFactoriesWidget
-from pitivi.bin import SmartCaptureBin
+from pitivi.bin import SmartCaptureBin,SinkBin
from pitivi.playground import PlayGround
@@ -49,17 +50,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)
@@ -67,14 +68,13 @@
# 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'
-
- if not self.player.record(self.filepath,ExportSettings()):
- print "FAILURE !"
+ self.player.record(self.filepath,ExportSettings())
self.record_btn.set_label("Stop Recording")
+ self.player.set_state(gst.STATE_PLAYING)
@@ -82,41 +82,13 @@
gst.debug("recording stopped")
self.player.stopRecording()
self.sourcefactories.sourcelist.addFiles([self.filepath])
-
-
self.record_btn.set_label("Start Recording")
+
# For Setting up audio,video sinks
def setSinks(self):
-
- self.videosink = plumber.get_video_sink()
-
- 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)
- cspace.link(vscale)
- vscale.link(vqueue)
- vsinkthread.videosink = self.videosink
- vsinkthread.add_pad(gst.GhostPad("sink", cspace.get_pad('sink')))
- self.player.setVideoSinkThread(vsinkthread)
-
- gst.debug("Creating audio sink")
- self.audiosink = plumber.get_audio_sink()
- 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", abqueue.get_pad('sink')))
- self.player.setAudioSinkThread(asinkthread)
-
+ sink = SinkBin()
+ sink.connectSink(self.player)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
@@ -127,7 +99,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]